fix(java): map legacy Jackson 1.x (-asl) artifacts to org.codehaus.jackson - #5146
Open
ankit090701 wants to merge 1 commit into
Open
fix(java): map legacy Jackson 1.x (-asl) artifacts to org.codehaus.jackson#5146ankit090701 wants to merge 1 commit into
ankit090701 wants to merge 1 commit into
Conversation
…ckson jackson-mapper-asl, jackson-core-asl, and their sibling artifacts (jackson-jaxrs, jackson-xc, jackson-smile) predate the convention of embedding META-INF/maven/.../pom.properties in the jar (they were built with Ant before ~2014). With no POM metadata to read, syft's groupIDFromJavaMetadata falls through to using the artifact name itself as the group ID, e.g. pkg:maven/jackson-mapper-asl/jackson-mapper-asl@1.9.13 instead of the correct pkg:maven/org.codehaus.jackson/jackson-mapper-asl@1.9.13 (confirmed against the published POM on Maven Central for all five artifacts). Because the generated purl's namespace doesn't match the vulnerability database's namespace for these packages, this causes false negatives in downstream scanning (e.g. Grype cannot match known CVEs such as CVE-2019-10202 against jackson-mapper-asl). Add the five artifacts to DefaultArtifactIDToGroupID, the same known- package-list fallback already used for other jars with incomplete metadata (e.g. the existing ant-*, spring-ldap* entries). Fixes anchore#4598 Signed-off-by: ankit090701 <ankitanku090701@gmail.com>
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.
Closes #4598
What
jackson-mapper-asl,jackson-core-asl, and their sibling artifacts (jackson-jaxrs,jackson-xc,jackson-smile) — the pre-2.x "Jackson 1.x" / "jackson-asl" family — predate the convention of embeddingMETA-INF/maven/.../pom.propertiesin the jar (they were built with Ant, before ~2014). I confirmed this directly:jackson-mapper-asl-1.9.13.jargenuinely has noMETA-INF/maven/directory at all.With no POM metadata to read,
groupIDFromJavaMetadatafalls through its precedence chain (POM properties → POM project → known package list → manifest) to the known-package-list lookup, which currently has no entry for these artifacts, so it falls through further and syft ends up using the artifact name itself as the group ID:instead of the correct
I verified the correct group ID for all five artifacts directly against their published POMs on Maven Central (e.g.
https://repo1.maven.org/maven2/org/codehaus/jackson/jackson-mapper-asl/1.9.13/jackson-mapper-asl-1.9.13.pom) — all five have<groupId>org.codehaus.jackson</groupId>.Why it matters
Because the generated purl's namespace doesn't match the vulnerability database's namespace for these packages, this causes false negatives in downstream scanning. Grype's DB correctly has, e.g.,
GHSA-c27h-mcmw-48hv(CVE-2019-10202) scoped toorg.codehaus.jackson:jackson-mapper-asl, but can't match it against syft'spkg:maven/jackson-mapper-asl/jackson-mapper-asl@1.9.13output.Fix
Add the five artifacts to
DefaultArtifactIDToGroupID, the same known-package-list fallback already used for other jars with incomplete metadata (e.g. the existingant-*,spring-ldap*entries — this map is shared by both purl and CPE generation, so both benefit).Testing
Added two cases to
Test_groupIDFromJavaMetadatainsyft/pkg/cataloger/java/package_url_test.go(following the existingspring-ldapregression-test pattern for issue #4030), assertinggroupIDFromJavaMetadata("jackson-mapper-asl", pkg.JavaArchive{})andgroupIDFromJavaMetadata("jackson-core-asl", pkg.JavaArchive{})returnorg.codehaus.jacksonwith no other metadata present.I verified the regression test actually catches the bug: reverting only the map change (
git stashonjava_groupid_map.go, keeping the new tests) makes both new cases fail withexpected: "org.codehaus.jackson", actual: "", exactly reproducing the reported behavior. Restoring the fix makes them pass.go vetis clean andgo test ./syft/pkg/cataloger/java/... ./syft/pkg/cataloger/internal/cpegenerate/...passes for everything my change touches. (Note: on this Windows dev environment,TestSearchMavenForLicenses/TestParseJar/etc. insyft/pkg/cataloger/javaandTest_processCPEListindictionary/index-generatorfail identically on a clean, unmodifiedmaincheckout — pre-existing CRLF/network-dependent environmental issues unrelated to this change, not introduced by it.)