-
Notifications
You must be signed in to change notification settings - Fork 597
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
fix upstream match for linux-.*-headers-.* #2320
Conversation
Signed-off-by: Bar Nuri <[email protected]>
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.
We should figure out how to add some tests for this, maybe something in the test/cli package?
i think its very small change and no so familiar with your tests |
@kzantow ? |
hi! any updates? I've tried to look and see if it is easy to add tests here but I didn't find any simple way (and its looks like a small change which can reduce lots of FP) |
I still think we should add a test -- a small change like this could easily regress without one. How about updating these "ignore" tests? |
I've noticed the UT is not protecting as expected the code, since the ignore rules are inside the root:
but they are manually built in the ignore_test, so in case of a change it doesn't detect it. I suggest moving it or refactor the tests.. not sure how. |
Signed-off-by: github-actions <[email protected]>
Signed-off-by: tomersein <[email protected]>
@kzantow hi there is any update of this review ? |
grype/match/ignore.go
Outdated
pattern, err := packageNameRegex(name) | ||
if err != nil { | ||
continue | ||
} |
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.
I think this should be moved outside of the returned func, the same way ifPackageNameApplies
checks the regex once and returns an "always false" func; and we should add debug logging for failures in both places e.g.:
func ifUpstreamPackageNameApplies(name string) ignoreCondition {
pattern, err := packageNameRegex(name)
if err != nil {
log.WithFields("name", name, "error", err).Debug("unable to parse name expression")
return func(Match) bool { return false }
}
return func(match Match) bool {
for _, upstream := range match.Package.Upstreams {
if pattern.MatchString(upstream.Name) {
return true
}
}
return false
}
}
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.
This looks great -- one small tweak requested
Signed-off-by: tomersein <[email protected]>
hi @kzantow , pushed a fix :) |
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.
Thanks for the contribution, @barnuri and @tomersein !
a fix for this PR, the upstream of linux-.-headers-. is linux-aws, linux-azure etc
#2295