Skip to content

Commit

Permalink
fix(flag): use globalstar to skip directories (#4854)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin authored Jul 23, 2023
1 parent 78cc209 commit a61531c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/fanal/walker/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package walker

import (
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions pkg/fanal/walker/walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a61531c

Please sign in to comment.