Skip to content
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

Correctly match JVM version ranges #2114

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Correctly match JVM version ranges #2114

wants to merge 5 commits into from

Conversation

wagoodman
Copy link
Contributor

@wagoodman wagoodman commented Sep 13, 2024

This builds on anchore/syft#3217 being able to correctly reason about pre and post JEP 223 versions (1.8.0 = 8.0.0). Specifically, when a package is detected to be a JVM package, and the vuln data indicates it's for a JVM package, then we'll correctly reason about JVM versions when making the comparison. For instance 1.8.0_372 == 8.0.372 based on the JEP223 spec and convention of the patch version in popular jdk releases. Today this nuance is not taken into consideration.

Additionally, this PR uses the CPE update field, which is commonly used in the vulnerability field for <= v1.8 JVMs -- without using this field we could never make the correct comparison.

Closes #1718

Signed-off-by: Alex Goodman <[email protected]>
Signed-off-by: Alex Goodman <[email protected]>
@wagoodman wagoodman marked this pull request as ready for review September 17, 2024 16:59
@westonsteimel
Copy link
Contributor

westonsteimel commented Sep 18, 2024

Hmm, something here appears to cause matches for python and go binaries to get dropped. Any ideas why that may be? It may actually be the syft changes which are causing it

@westonsteimel
Copy link
Contributor

Hmm, something here appears to cause matches for python and go binaries to get dropped. Any ideas why that may be? It may actually be the syft changes which are causing it

It's something on the grype matcher side. I tried with an old syft sbom and it still drops the python binary vuln matches

@wagoodman
Copy link
Contributor Author

Yeah, I was trying to figure out last night why this was happening -- I figured it out this morning: we stop at the first matcher that claims it can find a match for a package. The JVM matcher was making this claim for all binary type packages, which means it would stop the correct (stock) matcher from being used in other cases (like golang and python).

I added the JVM matcher to make certain we're always searching by CPE, however, in this case it's only a version comparison change and the stock matcher already searches by CPE by default. I'll remove the JVM matcher for now and let the stock matcher to continue to raise these matches up.

Signed-off-by: Alex Goodman <[email protected]>
@wagoodman wagoodman changed the title Add JVM matcher Correctly match JVM version ranges Sep 18, 2024
@wagoodman wagoodman added the bug Something isn't working label Sep 18, 2024
@wagoodman wagoodman self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Matching java binary packages with NVD records is problematic
2 participants