fix: restore graph nodes when moduleArtifacts is empty#331
Open
adrobuta wants to merge 5 commits into
Open
Conversation
|
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
5050968 to
9da1dc1
Compare
After #299, loadGraph/loadSha1MapGraph only processed ResolvedDependency nodes inside getModuleArtifacts(); empty lists skipped the node and never walked d.children, dropping transitives (e.g. lz4-java) and BOM-style nodes under merged configurations. Fall back to a single jar-shaped id and recurse children when the artifact list is empty.
Add fixture mirroring Spring/Kafka/kafka-clients + yawk→org.lz4 substitution and a system test that inspect() includes org.lz4:lz4-java by default scan.
Merged firstLevelModuleDependencies can produce different ResolvedDependency instances for the same GAV with different children. Leaving node ids in currentChain after returning skipped later traversals and dropped transitives. Use try/finally in loadGraph and loadSha1MapGraph.
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.
What this does
After PR #299 (v5 graph changes),
loadGraph / loadSha1MapGraphinlib/init.gradleonly created edges and recursed into d.children insidemoduleArtifacts.each { ... }. WhengetModuleArtifacts()returned null or an empty list (common with merged default configurations, some variants, optional edges, substitution chains), the plugin skipped the node entirely and never walked children, so transitive and substituted dependencies disappeared from JSONDEPS / Gradle dep graph even though Gradle still resolved them (e.g.runtimeClasspath/dependencyInsightshowed them).This change adds a fallback path: if there are no module artifacts, emit a single logical
group:artifact:jar@versionnode, setEdge, and recurse d.children, matching the usual default artifact shape. The same idea is applied inloadSha1MapGraph(SHA-1 keyed like the existing no-file/hash fallback).Notes for the reviewer
How should this be manually tested?
Prerequisites: JDK 17+, network for Maven Central / Snyk API, a Snyk account/token as usual for snyk test.
Link patched plugin into the CLI (adjust paths to your checkout):
Or use whatever internal workflow you use to point the CLI at a local snyk-gradle-plugin build.
Run against the repro fixture (from repo root of this plugin, or pass absolute path):
What to expect (findings / counts)
Dependency count: Scan should report on the order of ~50+ Maven/Groovy dependencies (exact number can shift slightly with CLI/plugin versions; before the fix, org.lz4:lz4-java was often missing from the tested set).
Sanity: Output / dependency list should include org.lz4:lz4-java and org.apache.kafka:kafka-clients; substituted at.yawk.lz4:lz4-java should not appear as the resolved coordinate for the scan.
Screenshots
Visuals that may help the reviewer
Additional questions