feat: let Gradle component metadata resolve distribution URLs on a warm cache - #7049
Open
calhar-snyk wants to merge 1 commit into
Open
feat: let Gradle component metadata resolve distribution URLs on a warm cache#7049calhar-snyk wants to merge 1 commit into
calhar-snyk wants to merge 1 commit into
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. |
cjheppell
force-pushed
the
feat/gradle-include-component-metadata
branch
2 times, most recently
from
July 30, 2026 10:01
0174740 to
5f0bc39
Compare
Component metadata reads artifact provenance as Gradle resolves dependencies. On a warm cache Gradle skips that work, so nothing observes the downloads and distribution:url comes back empty. --gradle-refresh-dependencies is the opt-in that forces a refresh so those reads fire. - Thread the flag through the legacy CLI. cli-extension-dep-graph already forwards --gradle-refresh-dependencies down the legacy resolution path, but the legacy CLI dropped it. Recognise it off its dashed key and pass it as gradleRefreshDependencies, mirroring include-component-metadata. The spread is conditional so the default plugin-options shape is unchanged for scans that never set it. Kept off SupportedUserReachableFacingCliArgs so it stays internal. - Bump cli-extension-dep-graph to v2.8.1, the first release whose legacy resolution forwards the flag rather than dropping it. - Bump cli-extension-sbom, which registers the hidden flag on sbom create so it survives the config clone into that resolution path. - Bump snyk-gradle-plugin to 7.1.0, which reads gradleRefreshDependencies and appends --refresh-dependencies. - Cover the threading in all three states: forwarded when true, forwarded when explicitly false, and absent from the options entirely when unset. The plugin only appends --refresh-dependencies inside its includeComponentMetadata branch, so the flag needs --include-component-metadata alongside it to have any effect. Co-authored-by: Chris Heppell <christopher.heppell@snyk.io> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
cjheppell
force-pushed
the
feat/gradle-include-component-metadata
branch
from
July 30, 2026 14:15
5f0bc39 to
fa6391c
Compare
cjheppell
marked this pull request as ready for review
July 30, 2026 14:16
PR Reviewer Guide 🔍
|
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.
Pull Request Submission Checklist
are release-note ready, emphasizing
what was changed, not how.
--gradle-refresh-dependenciesis deliberately undocumented and kept offSupportedUserReachableFacingCliArgsWhat does this PR do?
Lets Gradle component metadata resolve
distribution:urlprovenance on a warm Gradle cache.Component metadata reads artifact provenance as Gradle resolves dependencies. On a warm cache Gradle
skips the resolution work, so nothing observes the downloads and
distribution:urlcomes back empty.--gradle-refresh-dependenciesis the opt-in that forces Gradle to refresh so those reads fire.Three changes:
get-single-plugin-result.ts,types.ts) —cli-extension-dep-graphalready forwards--gradle-refresh-dependenciesdown the legacyresolution path, but the legacy CLI dropped it. Recognise it off its dashed key and pass it as
gradleRefreshDependencies, mirroring howinclude-component-metadatais handled. The spread isconditional so the default plugin-options shape is unchanged for the overwhelming majority of
scans that never set it. Deliberately kept off
SupportedUserReachableFacingCliArgsso it staysinternal.
cli-extension-dep-graphv2.7.2 → v2.8.1 — v2.7.2 has no knowledge of the flag, so itwould be parsed and then silently dropped before ever reaching the legacy CLI. v2.8.1 is the first
released version whose legacy resolution forwards it. The delta is two commits: the flag itself
(https://github.com/snyk/snyk/issues/225 #226) and a CODEOWNERS chore (fix: bump gradle plugin to fix dep tree annotations #227).
true, forwarded when explicitlyfalse, and absent from the plugin options entirely when unset.Where should the reviewer start?
src/lib/plugins/get-single-plugin-result.ts— the eight added lines are the whole behaviouralchange. Then
test/jest/unit/lib/plugins/get-single-plugin-result.spec.tsfor the three states, andthe
go.mod/go.sumbump last.How should this be manually tested?
snyk-gradle-plugin(7.0.2 is latest) does not yet readgradleRefreshDependencies, so today theflag reaches the plugin and the plugin ignores it. This PR is correct and inert in isolation.
Once
snyk-gradle-pluginis released and bumped here, against a Gradle project with an already-warmGradle cache:
Expect
distribution:urlnode labels to be populated, where the same command without--gradle-refresh-dependenciesleaves them empty on a warm cache. Gradle should be invoked with--refresh-dependencies(visible with-d).Risk assessment (Low | Medium | High)?
Low.
the plugin-options shape is byte-identical when it is absent.
--refresh-dependenciesforces Gradle to hit the network) is opt-in per invocationrather than implied by
--include-component-metadata.Any background context you want to provide?
Pending version bumps — these must follow before the feature works end to end. This PR
intentionally does not contain the local
replace/file:pins used for cross-repo development.cli-extension-dep-graphsnyk-gradle-plugin7.0.0gradleRefreshDependencies, then a bump here. No published version (7.0.0–7.0.2) has it yet. This is what gates end-to-end behaviour.cli-extension-sbomv0.0.0-20260722102401-3c3af28e7b93--gradle-refresh-dependenciesonsnyk sbommergesFull chain, for orientation:
snyk sbom/snyk testflag →cli-extension-sbom(registers, hidden) → config clone →cli-extension-dep-graphlegacy resolution (appends--gradle-refresh-dependencies) → legacy CLI(this PR) →
snyk-gradle-plugin(adds--refresh-dependencies) → Gradle.What are the relevant tickets?
CMPA-649