fix: Fix --file-patterns flag (#2625)

This commit is contained in:
Liam Galvin
2022-07-29 19:54:57 +01:00
committed by GitHub
parent c2a7ad5c01
commit 27027cf40d
4 changed files with 87 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ func TestFilesystem(t *testing.T) {
listAllPkgs bool
input string
secretConfig string
filePatterns []string
}
tests := []struct {
name string
@@ -79,6 +80,16 @@ func TestFilesystem(t *testing.T) {
},
golden: "testdata/dockerfile.json.golden",
},
{
name: "dockerfile with custom file pattern",
args: args{
securityChecks: "config",
input: "testdata/fixtures/fs/dockerfile_file_pattern",
namespaces: []string{"testing"},
filePatterns: []string{"dockerfile:Customfile"},
},
golden: "testdata/dockerfile_file_pattern.json.golden",
},
{
name: "dockerfile with rule exception",
args: args{
@@ -178,6 +189,12 @@ func TestFilesystem(t *testing.T) {
defer os.Remove(trivyIgnore)
}
if len(tt.args.filePatterns) != 0 {
for _, filePattern := range tt.args.filePatterns {
osArgs = append(osArgs, "--file-patterns", filePattern)
}
}
// Setup the output file
outputFile := filepath.Join(t.TempDir(), "output.json")
if *update {