-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(terraform) adding trivy:ignore for tf scans to align with trivy #1188
Conversation
func Test_TrivyOptionWithAlternativeIDProvider(t *testing.T) { | ||
reg := rules.Register(alwaysFailRule, nil) | ||
defer rules.Deregister(reg) | ||
|
||
options := []options.ScannerOption{ | ||
ScannerWithAlternativeIDProvider(func(s string) []string { | ||
return []string{"something", "altid", "blah"} | ||
}), | ||
} | ||
results := scanWithOptions(t, ` | ||
//trivy:ignore:altid | ||
resource "something" "else" {} | ||
`, options...) | ||
require.Len(t, results.GetFailed(), 0) | ||
require.Len(t, results.GetIgnored(), 1) | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As most of the other inputs are the same, can we make this into a table driven test instead? So something like:
testCases := []struct{
name string
inputOptions string}{
{ name: "tfsec", inputOptions: "..."}}
then you can iterate over them as inputs:
for _, tc := range testCases {
t.Run(...)
}
test/trivy_ignore_test.go
Outdated
@@ -0,0 +1,393 @@ | |||
package test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise with this file as well. ignore_test.go
could include all the ignores, trivy and tfsec as test inputs for each of the existing tests within ignore_test.go
.
@simar7 I made the changes we discussed. please review and merge if all looks good |
076100f
to
46ad24d
Compare
Aligning with trivy to allow inline ignores using trivy:ignore.