Skip to content

Commit e419eb8

Browse files
ccojocargcmurphy
authored andcommitted
Exclude correctly the vendor folder from the scanned packages
Signed-off-by: Cosmin Cojocar <[email protected]>
1 parent 85eb8a5 commit e419eb8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/gosec/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ func main() {
250250
analyzer := gosec.NewAnalyzer(config, logger)
251251
analyzer.LoadRules(ruleDefinitions.Builders())
252252

253-
vendor := regexp.MustCompile(`[\\/]vendor([\\/]|$)`)
253+
var vendor *regexp.Regexp
254+
if !*flagScanVendor {
255+
vendor = regexp.MustCompile(`([\\/])?vendor([\\/])?`)
256+
}
254257
var packages []string
255258
for _, path := range flag.Args() {
256259
pcks, err := gosec.PackagePaths(path, vendor)

0 commit comments

Comments
 (0)