-
Notifications
You must be signed in to change notification settings - Fork 594
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: correct APK CPE version comparison logic #1165
Conversation
An example illustrating this is
CVE-2023-22795 is fixed for ruby 3.2.0 and therefore shouldn't show up, but since the -r6 is causing it to be treated as a pre-release, it currently gets pulled in Thanks to @luhring for the example! |
de25eb9
to
5af75a9
Compare
Previously, the -r{buildindex} suffix of APK package versions were treated as pre-release versions per the fuzzy matcher logic; however, these should be treated as equivalent to the release version for the purposes of collecting CPE-based matches for APK packages. We may want to make a similar change in syft to generate cleaner CPE versions for APK packages, but making the change in grype corrects behaviour for previously-generated SBOMs as well. Signed-off-by: Weston Steimel <[email protected]>
fbd914f
to
94e8087
Compare
Signed-off-by: Weston Steimel <[email protected]>
94e8087
to
8e7bdec
Compare
grype/matcher/apk/matcher.go
Outdated
@@ -45,7 +46,8 @@ func (m *Matcher) Match(store vulnerability.Provider, d *distro.Distro, p pkg.Pa | |||
|
|||
func (m *Matcher) cpeMatchesWithoutSecDBFixes(store vulnerability.Provider, d *distro.Distro, p pkg.Package) ([]match.Match, error) { | |||
// find CPE-indexed vulnerability matches specific to the given package name and version | |||
cpeMatches, err := search.ByPackageCPE(store, p, m.Type()) | |||
cpePackage := cpeComparablePackage(p) | |||
cpeMatches, err := search.ByPackageCPE(store, cpePackage, m.Type()) |
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 be surfacing matches with the original package, the match details should have the necessary (mutated) details. This way we surface the vuln, the original package [from the SBOM as we understand it], and the match details showing what values were used in the search.
Signed-off-by: Weston Steimel <[email protected]>
e85d572
to
98eca0f
Compare
Previously, the -r{buildindex} suffix of APK package versions were treated as pre-release versions per the fuzzy matcher logic; however, these should be treated as equivalent to the release version for the purposes of collecting CPE-based matches for APK packages.
We may want to make a similar change in syft to generate cleaner CPE versions for APK packages, but making the change in grype corrects behaviour for previously-generated SBOMs as well.