Conversation
generateSbomFromEffectivePom() excluded test deps by matching effective-pom deps against original-pom test deps via version-sensitive equals(). Parent/BOM -managed test deps (version null in source pom, resolved in effective pom) did not match and leaked into the SBOM. Filter the effective-pom stream by its own isTestDependency() scope instead, which is version-independent and mirrors the JS client. Implements TC-6264 Assisted-by: Claude Code
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe Maven component-analysis path now excludes test-scoped dependencies directly from the effective POM, fixing leaks caused by version-sensitive matching against source-POM dependencies while intentionally retaining provided-scope dependencies. The expected SBOM fixture and associated assertions now validate the six-dependency output. Flow diagram for Maven dependency filteringflowchart TD
A["Effective POM dependencies"] --> B["resolveVersionRanges(deps)"]
B --> C{"dep.isTestDependency()?"}
C -->|Yes| D["Exclude from SBOM"]
C -->|No| E["DependencyAggregator.toPurl"]
E --> F{"Ignored dependency?"}
F -->|Yes| G["Exclude from SBOM"]
F -->|No| H["Add dependency to SBOM"]
I["Provided-scope dependency"] --> E
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the effective-POM scope check is wrong, the generated SBOM could omit a real runtime dependency or include a test-only dependency, causing inaccurate component or vulnerability analysis. The affected SBOMs can be regenerated after reverting or correcting the change, so the error is bounded and repairable.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #583 +/- ##
=======================================
Coverage ? 69.24%
Complexity ? 1040
=======================================
Files ? 66
Lines ? 4367
Branches ? 774
=======================================
Hits ? 3024
Misses ? 1000
Partials ? 343
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Summary
The Maven component-analysis path leaked
test-scoped dependencies into the SBOM sent to the backend, unlike the JavaScript client which excludes them.generateSbomFromEffectivePom()excluded test deps by matching effective-pom deps against test deps read from the original pom using the version-sensitiveDependencyAggregator.equals(). Parent/BOM-managed test deps (e.g.spring-boot-starter-test) haveversion == nullin the source pom but a resolved version in the effective pom, so the match failed and the test dep leaked.Fix: filter the effective-pom stream by each dependency's own
isTestDependency()scope, which is version-independent and mirrors the JS client. Scope is test only —providedfiltering is intentionally out of scope.Changes
JavaMavenProvider.generateSbomFromEffectivePom(): replace the version-sensitivetestsDeps.contains(dep)match with a direct!dep.isTestDependency()scope filter; drop the now-unused original-pomtestsDepscomputation.pom_deps_with_no_ignore_common_paths/expected_component_sbom.json: drop the leakedspring-boot-starter-test@2.3.5.RELEASEentry (7 → 6 deps).Testing
mvn test— all 98 tests pass. The existing parameterizedtest_the_provideComponent/test_the_provideComponent_With_Pathnow assert the corrected 6-dep output forpom_deps_with_no_ignore_common_paths;pom_deps_with_no_ignore_provided_scoperemains unchanged (provided dep still included).Implements TC-6264
🤖 Generated with Claude Code
Summary by Sourcery
Filter Maven component analysis by effective dependency scope to prevent test dependencies from leaking into generated SBOMs.
Bug Fixes:
Tests: