github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/terraform/parser/resolvers/local.go (about) 1 package resolvers 2 3 import ( 4 "context" 5 "io/fs" 6 "path/filepath" 7 ) 8 9 type localResolver struct{} 10 11 var Local = &localResolver{} 12 13 func (r *localResolver) Resolve(_ context.Context, target fs.FS, opt Options) (filesystem fs.FS, prefix string, downloadPath string, applies bool, err error) { 14 if !opt.hasPrefix(".", "..") { 15 return nil, "", "", false, nil 16 } 17 joined := filepath.Clean(filepath.Join(opt.ModulePath, opt.Source)) 18 if _, err := fs.Stat(target, filepath.ToSlash(joined)); err == nil { 19 opt.Debug("Module '%s' resolved locally to %s", opt.Name, joined) 20 return target, "", joined, true, nil 21 } 22 23 clean := filepath.Clean(opt.Source) 24 opt.Debug("Module '%s' resolved locally to %s", opt.Name, clean) 25 return target, "", clean, true, nil 26 }