Maven: report declared dependencies as direct in static (pomxml) analysis - #1767
Draft
himynameisdave wants to merge 1 commit into
Draft
Maven: report declared dependencies as direct in static (pomxml) analysis#1767himynameisdave wants to merge 1 commit into
himynameisdave wants to merge 1 commit into
Conversation
The static (pomxml) strategy builds a graph rooted at the project's own coordinate, with submodules as its children. Unlike the dynamic strategies, it never removed those first-party nodes, so the project artifact was reported as the only direct dependency and everything declared in pom.xml showed up as transitive. Shrink the project and submodule nodes out of the static graph after filtering, promoting their children to direct, matching what shrinkRoots does on the dynamic path.
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.
Overview
The static Maven strategy (
pomxml, used whenevermvnis not onPATHor with--static-only-analysis) builds its graph rooted at the project's own coordinate, with submodules as children of that root. Unlike the dynamic strategies, which strip those first-party nodes withshrinkRoots, the static path returned the graph as-is. Result: the project artifact (e.g.com.cascade:cascade) is the only "direct" dependency and every dependency declared inpom.xmlis reported as transitive.This PR shrinks the project and submodule nodes out of the static graph (after submodule/scope filtering), promoting their children to direct, matching what the dynamic path already does.
This affects every GitHub App / Quick Import Maven project, since Hubble always runs static-only analysis with no
mvnavailable. Auto PRs only act on direct dependencies, so those projects currently have nothing to upgrade.Acceptance criteria
fossa analyzeon a Maven project withoutmvnonPATH(or with--static-only-analysis) reports the dependencies declared inpom.xmlas direct, and does not report the project or its modules as dependencies.Testing plan
Unit test added in
test/Maven/PomClosureSpec.hs(getStaticAnalysis): multi-module fixture where one module declaresorg.example:lib:1.0; asserts that is the only vertex and it is direct.Manual repro against https://github.com/himynameisdave/cascade-java (65 declared deps):
Risks
Metrics
N/A
References
shrinkRoots:fossa-cli/src/Strategy/Maven.hs
Lines 187 to 191 in 00580ae
shrinkRoots:fossa-cli/src/Strategy/Maven.hs
Lines 137 to 143 in 00580ae
buildProjectGraph:fossa-cli/src/Strategy/Maven/Pom.hs
Line 105 in 00580ae
shrinkRootsadded to dynamic path only: Ane 907 submodule filtering #1339