diff --git a/pkg/fanal/walker/walk.go b/pkg/fanal/walker/walk.go index c7acbbd4a30f..50fe79b90aa2 100644 --- a/pkg/fanal/walker/walk.go +++ b/pkg/fanal/walker/walk.go @@ -2,7 +2,6 @@ package walker import ( "os" - "path" "path/filepath" "strings" @@ -80,7 +79,7 @@ func (w *walker) shouldSkipDir(dir string) bool { // Skip system dirs and specified dirs (absolute path) for _, pattern := range w.skipDirs { - if match, err := path.Match(pattern, dir); err != nil { + if match, err := doublestar.Match(pattern, dir); err != nil { return false // return early if bad pattern } else if match { log.Logger.Debugf("Skipping directory: %s", dir) diff --git a/pkg/fanal/walker/walk_test.go b/pkg/fanal/walker/walk_test.go index bce2c4228a77..8b19a92899f1 100644 --- a/pkg/fanal/walker/walk_test.go +++ b/pkg/fanal/walker/walk_test.go @@ -104,6 +104,13 @@ func Test_shouldSkipDir(t *testing.T) { filepath.Join("/etc/foo/bar"): false, }, }, + { + skipDirs: []string{"**/.terraform"}, + skipMap: map[string]bool{ + ".terraform": true, + "test/foo/bar/.terraform": true, + }, + }, } for i, tc := range testCases {