feat: add Java/Maven resolver with maven attestor support#13
Open
Sandipmandal25 wants to merge 1 commit intoSBOMit:masterfrom
Open
feat: add Java/Maven resolver with maven attestor support#13Sandipmandal25 wants to merge 1 commit intoSBOMit:masterfrom
Sandipmandal25 wants to merge 1 commit intoSBOMit:masterfrom
Conversation
Signed-off-by: Sandipmandal25 <sandipmandal02.sm@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.
Description
Adds a Java/Maven resolver that supports package resolution from two complementary sources:
File-path resolver
Maps local Maven and Gradle cache paths (e.g.
~/.m2/repository,~/.gradle/caches) topkg:maven/{groupId}/{artifactId}@{version}PURLs.Maven attestor extractor
Extracts structured dependencies from the Witness Maven attestor.
This is required on macOS where syscall-based file tracing is not available.
fix #16
Changes Made
pkg/resolver/java.goImplements
JavaResolverfor Maven local repository and Gradle cache layoutspkg/resolver/java_test.goAdds 12 table-driven unit tests
pkg/resolver/resolver.goRegisters
NewJavaResolver()in the resolver chainpkg/generator/generator.goextractMavenAttestorPackagesfor parsing attestor dependenciesmergeNewPackagesto deduplicate against file-path resultscmd/generate.goEnables
mavenin default--typestest/java-sample-attestation.jsonSample attestation for manual testing
Testing
Unit tests
go test ./pkg/resolver/... -run TestJava -vEnd-to-end (Witness → SBOM → Trivy scan)
witness run -k /tmp/test-key.pem -s maven-build -a maven -o /tmp/java-attestation.json -- mvn dependency:resolve go run . generate /tmp/java-attestation.json --format cdx15 -o /tmp/java-sbom.cdx.json trivy sbom /tmp/java-sbom.cdx.jsonResults
Trivy successfully detected:
CVE-2020-15250(MEDIUM) injunit:junit@4.114.13.1Witness maven attestor capturing
junit:junit:4.11andhamcrest-core:1.3during mvndependency:resolvesbomit parsing 4 attestations (including maven=1) and writing CycloneDX SBOM
Generated SPDX output showing correct
pkg:maven/org.springframework/spring-core@6.1.0PURL format