Skip to content

Commit a61531c

Browse files
authored
fix(flag): use globalstar to skip directories (#4854)
1 parent 78cc209 commit a61531c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/fanal/walker/walk.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package walker
22

33
import (
44
"os"
5-
"path"
65
"path/filepath"
76
"strings"
87

@@ -80,7 +79,7 @@ func (w *walker) shouldSkipDir(dir string) bool {
8079

8180
// Skip system dirs and specified dirs (absolute path)
8281
for _, pattern := range w.skipDirs {
83-
if match, err := path.Match(pattern, dir); err != nil {
82+
if match, err := doublestar.Match(pattern, dir); err != nil {
8483
return false // return early if bad pattern
8584
} else if match {
8685
log.Logger.Debugf("Skipping directory: %s", dir)

pkg/fanal/walker/walk_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ func Test_shouldSkipDir(t *testing.T) {
104104
filepath.Join("/etc/foo/bar"): false,
105105
},
106106
},
107+
{
108+
skipDirs: []string{"**/.terraform"},
109+
skipMap: map[string]bool{
110+
".terraform": true,
111+
"test/foo/bar/.terraform": true,
112+
},
113+
},
107114
}
108115

109116
for i, tc := range testCases {

0 commit comments

Comments
 (0)