mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
test(fs): add --skip-files, --skip-dirs (#2984)
This commit is contained in:
committed by
GitHub
parent
561b2e7566
commit
a8ff5f06b5
@@ -26,6 +26,8 @@ func TestFilesystem(t *testing.T) {
|
||||
filePatterns []string
|
||||
helmSet []string
|
||||
helmValuesFile []string
|
||||
skipFiles []string
|
||||
skipDirs []string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -40,6 +42,24 @@ func TestFilesystem(t *testing.T) {
|
||||
},
|
||||
golden: "testdata/gomod.json.golden",
|
||||
},
|
||||
{
|
||||
name: "gomod with skip files",
|
||||
args: args{
|
||||
securityChecks: "vuln",
|
||||
input: "testdata/fixtures/fs/gomod",
|
||||
skipFiles: []string{"/testdata/fixtures/fs/gomod/submod2/go.mod"},
|
||||
},
|
||||
golden: "testdata/gomod-skip.json.golden",
|
||||
},
|
||||
{
|
||||
name: "gomod with skip dirs",
|
||||
args: args{
|
||||
securityChecks: "vuln",
|
||||
input: "testdata/fixtures/fs/gomod",
|
||||
skipDirs: []string{"/testdata/fixtures/fs/gomod/submod2"},
|
||||
},
|
||||
golden: "testdata/gomod-skip.json.golden",
|
||||
},
|
||||
{
|
||||
name: "nodejs",
|
||||
args: args{
|
||||
@@ -244,6 +264,18 @@ func TestFilesystem(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(tt.args.skipFiles) != 0 {
|
||||
for _, skipFile := range tt.args.skipFiles {
|
||||
osArgs = append(osArgs, "--skip-files", skipFile)
|
||||
}
|
||||
}
|
||||
|
||||
if len(tt.args.skipDirs) != 0 {
|
||||
for _, skipDir := range tt.args.skipDirs {
|
||||
osArgs = append(osArgs, "--skip-dirs", skipDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the output file
|
||||
outputFile := filepath.Join(t.TempDir(), "output.json")
|
||||
if *update {
|
||||
|
||||
Reference in New Issue
Block a user