mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 07:29:00 -08:00
fix: Fix --file-patterns flag (#2625)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user