fix(java): use the OSGi Bundle-Name as the artifact ID - #5200
Open
ashvinctrl wants to merge 1 commit into
Open
Conversation
Tomcat hand-writes the OSGi headers for every jar it ships and includes no pom, so catalina.jar was named from its filename and cataloged as pkg:maven/org.apache.tomcat-catalina/catalina rather than pkg:maven/org.apache.tomcat/tomcat-catalina. Nothing matches the former, so none of the Tomcat advisories are found against a stock install. The artifact ID is in Bundle-Name, but that field is often a human readable title instead, so only prefer it over the filename when Bundle-SymbolicName is composed from it. Also maps tomcat-coyote-ffm to org.apache.tomcat, the one jar in the distribution missing from the group ID lookup. Signed-off-by: ashvinctrl <sharmaashvin27@gmail.com>
Author
|
Only DCO has run on this PR so far. The rest of the checks are still waiting on a maintainer to approve workflow runs for a first-time contributor, so CI has not actually exercised the change yet. Could someone kick that off? I ran it locally on the PR head in the meantime:
Happy to answer anything on the Bundle-Name heuristic or to add cases if you want the guard tightened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Tomcat hand-writes the OSGi headers for every jar it ships and includes no pom, so syft names those jars from the filename.
catalina.jarcomes out aspkg:maven/org.apache.tomcat-catalina/catalina@10.1.54when the published artifact isorg.apache.tomcat:tomcat-catalina, and nothing is published under the former, so a stock Tomcat install matches no advisories at all.The artifact ID is already in the manifest as
Bundle-Name. That field is often a human readable title rather than an ID, so this only prefers it over the filename whenBundle-SymbolicNameis composed from it. In the same directorytomcat-jdbc.jar("Apache Tomcat JDBC Connection Pool") andecj-4.27.jar("Eclipse Compiler for Java(TM)") both fail that check and keep the names they get today.15 of the 35 jars in
apache-tomcat-10.1.54/libget corrected coordinates and all 15 resolve on Maven Central underorg.apache.tomcat. Scanning the before and after SBOMs with grype v0.117.0 goes from 0 matches to 7 on 10.1.54 (3 critical, 3 high, 1 low, all on tomcat-catalina) and from 4 to 17 on both 9.0.111 and 11.0.13. Every new match is an exact-direct-match against a GHSA advisory for that artifact rather than CPE over-matching, and no existing match is lost. The group ID table already had the corrected names excepttomcat-coyote-ffm, which is added here. I also ran a before/after over 39 jars pulled from Maven Central (spring, jetty, felix, eclipse platform, servicemix, cxf, camel, activemq, jackson, netty and others) and no purls changed.Type of change
Checklist
Issue references
Fixes #4097
Also the cause of anchore/grype#3491, and the reason #4953 could not work on its own: the group ID mapping was already correct, but the artifact ID was still coming from the filename.