-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: move file patterns to a global level to be able to use it on any analyzer #2539
feat: move file patterns to a global level to be able to use it on any analyzer #2539
Conversation
@owenrumney @liamg @knqyf263 |
@owenrumney @liamg @knqyf263 Are you guys straight up collectively ignoring me or is something else going on? |
Hi @jerbob92 - sorry about this! Entirely my fault. It's been a busy couple of weeks and I totally missed this but that's no excuse, I apologise. Looking now 👀 |
Thanks! Just wondering whether I have to keep updating this MR 😅 |
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.
LGTM! 🚀
Sorry for the delay 🐌
If you could check the conflicts I'll make sure we merge this ASAP :) |
@liamg the current failure is this:
That doesn't seem related to my changes, do you have any idea? |
@jerbob92 I haven't seen this failure before - I'll raise it internally and see if I can find a solution. |
Apparently this is a fairly common issue with GHCR being unreliable 😬 - I've kicked off the integration tests again 🤞 |
@knqyf263 What do you think? Can we merge this? 😃 |
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.
Could you also update this doc?
trivy/docs/docs/references/customization/config-file.md
Lines 198 to 200 in 2580ea1
# Same as '--file-patterns' | |
# Default is empty | |
file-patterns: |
pkg/fanal/analyzer/analyzer.go
Outdated
filePatternMatch := false | ||
for _, pattern := range ag.filePatterns[a.Type()] { | ||
if pattern.MatchString(cleanPath) { | ||
filePatternMatch = true | ||
break | ||
} | ||
} |
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.
Having it in a dedicated method seems better.
func (ag AnalyzerGroup) filePatternMatch(analyzerType Type, filePath string) {
for _, pattern := range ag.filePatterns[analyzerType] {
if pattern.MatchString(cleanPath) {
return true
}
}
return false
}
Moving it to scan options? |
Huh? Didn't I already sign this? |
@jerbob92 it seems CLA was updated |
Yes |
Thanks for your contribution and patience🙇 |
Description
This is the functionality of aquasecurity/fanal#372 moved into Trivy since Fanal was merged into it.
This PR moves the file patterns feature from the config analyzers to a global level so that we can use it on any analyzer.
In favor of aquasecurity/fanal#370, aquasecurity/fanal#357, aquasecurity/fanal#355 as this feature will allow you to set the needed file patterns yourself.
This also makes the config analyzers more like the other analyzers.
This can be enabled in Trivy without changing anything to the config scanner. The other commands will just get a --filter-patterns option.
Checklist