Repository navigation
Conversation
…le catalog Gradle remediation only supports version catalogs. The catalog target was resolved to its owning build file and analyzed with `gradle dependencies`, which reports only the current project. Dependencies used solely by subprojects were therefore missing from the remediation report, and a root project with no dependencies made analysis crash outright. When the target is a `*.versions.toml`, now analyze every project in that catalog's build via `discoverGradleSubprojects()`, merge the remediations and deduplicate by purl, then apply them to the catalog through the existing TOML updater. Discovery falls back to analyzing the catalog itself when no settings file or projects are found. Dependencies that are not in the catalog are reported as skipped. Two provider fixes made subproject analysis possible: - read group/name/version from `gradle properties` instead of requiring a `Root project` header, which subprojects do not emit - ignore non-dependency lines such as `No dependencies` instead of treating them as depth-1 tree entries; this also fixes empty Gradle projects and `stack-batch` for subproject build files Both golden fixtures were checked against real Gradle 8.14.3 output. Implements TC-6900 Co-Authored-By: Claude Code <noreply@anthropic.com>
Reviewer's GuideImplementationAnalyze every project in a Gradle catalog’s build, merge and deduplicate findings, and use the existing TOML updater; fall back when project discovery fails and distinguish catalog omissions in skipped results.
Support subproject analysis by sharing bounded build-file discovery, parsing project identity from Gradle properties, and filtering non-dependency output from dependency trees.
DocumentationDocument that catalog remediation includes dependencies used in subprojects and that directly declared Gradle DSL dependencies are skipped.
TestsAdd provider fixtures and coverage for subproject and empty dependency-tree output, and test catalog fan-out, deduplication, skipped dependencies, and fallback behavior.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/remediate.js" line_range="230" />
<code_context>
+ return [manifestPath]
+ }
+
+ const projects = await discoverGradleSubprojects(path.dirname(buildFile), opts)
+ return projects.length > 0 ? projects : [manifestPath]
+}
</code_context>
<issue_to_address>
**Subproject dependencies go unreported**
When a settings-included subproject has no local build file, or Gradle project listing fails while a root build file exists, `discoverGradleSubprojects()` returns only projects with their own build files, and `analysisPathsFor()` treats a nonempty result as complete; when listing fails, it likewise falls back to the root manifest. Dependencies configured for omitted subprojects never reach analysis, so the remediation report misses them.
Discover and analyze every settings-included project, including projects without local build files, and ensure a failed project listing does not silently reduce analysis to the root.
Also at `README.md:866`, `src/remediate.js:231`.
</issue_to_address>
### Comment 2
<location path="src/remediate.js" line_range="325-342" />
<code_context>
+ /** @type {Map<string, import('./remediation.js').Remediation>} */
</code_context>
<issue_to_address>
**Conflicting remediation details disappear**
When analyses report different fixed versions, vulnerability details, or recommendations for the same dependency PURL, `remediationsByPurl` keeps the first remediation and discards later reports, so project discovery order determines the fix and the merged remediation omits details from other projects; the catalog can remain vulnerable and callers receive incomplete results.
Merge or resolve all remediations for each PURL across project reports instead of retaining only the first.
</issue_to_address>
### Comment 3
<location path="src/remediate.js" line_range="225" />
<code_context>
+ return [manifestPath]
+ }
+
+ const buildFile = findNearestBuildFile(path.dirname(manifestPath))
+ if (!buildFile) {
+ return [manifestPath]
</code_context>
<issue_to_address>
**Sibling dependencies go unreported**
When a version catalog is stored beneath a subproject that has its own build file while the build settings file is in an ancestor directory, `findNearestBuildFile()` selects the subproject build file, so `analysisPathsFor()` starts discovery in that subproject and cannot find the ancestor settings file. Discovery falls back to the catalog or analyzes only that subproject, leaving sibling-project dependencies out of the report.
Find the build and settings context that owns the catalog before discovering projects, rather than starting from the nearest subproject build file.
Also at `src/remediate.js:230`.
</issue_to_address>
### Comment 4
<location path="src/remediate.js" line_range="335" />
<code_context>
- const extracted = extractRemediations(analysisReport, {
- providerPriority: providers ? providers.split(',').map(p => p.trim()).filter(Boolean) : undefined,
- })
+ const analysisReport = await analysis.requestStack(provider, analysisPath, url, false, opts)
+ for (const remediation of extractRemediations(analysisReport, { providerPriority })) {
+ if (!remediationsByPurl.has(remediation.purl)) {
</code_context>
<issue_to_address>
**Catalog audit metadata is replaced**
When a version catalog is analyzed through the new project fan-out, `analysis.requestStack()` receives each project build file, so it encodes that file as the source manifest and labels it `build.gradle` or `build.gradle.kts`; the backend receives no version-catalog content for the catalog remediation request.
Preserve the catalog path and content as the audit manifest while separately selecting the project build file used to generate each project's SBOM.
</issue_to_address>
### Comment 5
<location path="src/remediate.js" line_range="225-228" />
<code_context>
+ return [manifestPath]
+ }
+
+ const buildFile = findNearestBuildFile(path.dirname(manifestPath))
+ if (!buildFile) {
+ return [manifestPath]
+ }
+
+ const projects = await discoverGradleSubprojects(path.dirname(buildFile), opts)
</code_context>
<issue_to_address>
**Catalog fallback is silently skipped**
When a target catalog has no nearby Gradle build file, `analysisPathsFor` returns the catalog path when no build file is found, but `match` rejects that path because the Gradle provider requires a nearby build file. The catch then skips it, so remediation returns no results instead of performing the advertised fallback or reporting that analysis is impossible.
Do not route the catalog through provider matching in this state; either report the missing build as an error or implement a fallback that can actually analyze it.
Also at `src/remediate.js:329-333`.
</issue_to_address>
### Comment 6
<location path="src/remediate.js" line_range="230" />
<code_context>
+ return [manifestPath]
+ }
+
+ const projects = await discoverGradleSubprojects(path.dirname(buildFile), opts)
+ return projects.length > 0 ? projects : [manifestPath]
+}
</code_context>
<issue_to_address>
**Gradle discovery can block remediation**
When gradle configuration or plugin resolution stalls while listing projects, `discoverGradleSubprojects` runs Gradle synchronously before analysis, and `invokeCommand` has no timeout. A Gradle configuration or plugin-resolution process that stalls therefore blocks `runRemediation` indefinitely before it can return a report.
Run project discovery with a bounded timeout and surface a clear failure rather than waiting indefinitely.
</issue_to_address>
### Comment 7
<location path="test/remediate.test.js" line_range="332" />
<code_context>
+ test('reports a dependency found in several projects once', async () => {
+ const { tomlPath, cleanup } = createMultiProject()
+ try {
+ requestStackStub.resolves(SUBPROJECT_REPORT)
+
+ const result = await runRemediation(tomlPath, { dryRun: true })
</code_context>
<issue_to_address>
**Subproject findings go unverified**
When the fan-out implementation is broken or analyzes only the root project, when `runRemediation` analyzes only the root project, `requestStackStub.resolves(...)` still supplies the subproject report. The tests `reports a dependency found in several projects once` (lines 329–336) and `reports a subproject dependency absent from the catalog as skipped` (lines 343–357) can therefore pass without analyzing any subproject.
Make the report stubs return the relevant findings only for a subproject path, and assert that the subproject was analyzed.
Also at `test/remediate.test.js:346`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 7 findings to address first, and a remediation found only in a Gradle subproject can now cause the shared version catalog to be updated. If the analysis selects the wrong version, that value remains in the catalog after this code is reverted, but it can be corrected or reverted in the manifest.
Blocking findings: src/remediate.js:230, src/remediate.js:342, src/remediate.js:225, src/remediate.js:335, src/remediate.js:228, and 2 more
| return [manifestPath] | ||
| } | ||
|
|
||
| const projects = await discoverGradleSubprojects(path.dirname(buildFile), opts) |
There was a problem hiding this comment.
🟠 High · Subproject dependencies go unreported
When a settings-included subproject has no local build file, or Gradle project listing fails while a root build file exists, discoverGradleSubprojects() returns only projects with their own build files, and analysisPathsFor() treats a nonempty result as complete; when listing fails, it likewise falls back to the root manifest. Dependencies configured for omitted subprojects never reach analysis, so the remediation report misses them.
Discover and analyze every settings-included project, including projects without local build files, and ensure a failed project listing does not silently reduce analysis to the root.
Also at README.md:866, src/remediate.js:231.
Prompt for AI agents
In `src/remediate.js` at line 230:
**Subproject dependencies go unreported**
When a settings-included subproject has no local build file, or Gradle project listing fails while a root build file exists, `discoverGradleSubprojects()` returns only projects with their own build files, and `analysisPathsFor()` treats a nonempty result as complete; when listing fails, it likewise falls back to the root manifest. Dependencies configured for omitted subprojects never reach analysis, so the remediation report misses them.
Discover and analyze every settings-included project, including projects without local build files, and ensure a failed project listing does not silently reduce analysis to the root.
Also at `README.md:866`, `src/remediate.js:231`.| /** @type {Map<string, import('./remediation.js').Remediation>} */ | ||
| const remediationsByPurl = new Map() | ||
| for (const analysisPath of analysisPaths) { | ||
| let provider | ||
| try { | ||
| provider = match(analysisPath, availableProviders, opts) | ||
| } catch { | ||
| continue | ||
| } | ||
|
|
||
| const analysisReport = await analysis.requestStack(provider, manifestPath, url, false, opts) | ||
| const extracted = extractRemediations(analysisReport, { | ||
| providerPriority: providers ? providers.split(',').map(p => p.trim()).filter(Boolean) : undefined, | ||
| }) | ||
| const analysisReport = await analysis.requestStack(provider, analysisPath, url, false, opts) | ||
| for (const remediation of extractRemediations(analysisReport, { providerPriority })) { | ||
| if (!remediationsByPurl.has(remediation.purl)) { | ||
| remediationsByPurl.set(remediation.purl, remediation) | ||
| } | ||
| } | ||
| } | ||
| const extracted = [...remediationsByPurl.values()].sort((a, b) => a.purl.localeCompare(b.purl)) |
There was a problem hiding this comment.
🟡 Medium · Conflicting remediation details disappear
When analyses report different fixed versions, vulnerability details, or recommendations for the same dependency PURL, remediationsByPurl keeps the first remediation and discards later reports, so project discovery order determines the fix and the merged remediation omits details from other projects; the catalog can remain vulnerable and callers receive incomplete results.
Merge or resolve all remediations for each PURL across project reports instead of retaining only the first.
Prompt for AI agents
In `src/remediate.js` at lines 325-342:
**Conflicting remediation details disappear**
When analyses report different fixed versions, vulnerability details, or recommendations for the same dependency PURL, `remediationsByPurl` keeps the first remediation and discards later reports, so project discovery order determines the fix and the merged remediation omits details from other projects; the catalog can remain vulnerable and callers receive incomplete results.
Merge or resolve all remediations for each PURL across project reports instead of retaining only the first.| return [manifestPath] | ||
| } | ||
|
|
||
| const buildFile = findNearestBuildFile(path.dirname(manifestPath)) |
There was a problem hiding this comment.
🟡 Medium · Sibling dependencies go unreported
When a version catalog is stored beneath a subproject that has its own build file while the build settings file is in an ancestor directory, findNearestBuildFile() selects the subproject build file, so analysisPathsFor() starts discovery in that subproject and cannot find the ancestor settings file. Discovery falls back to the catalog or analyzes only that subproject, leaving sibling-project dependencies out of the report.
Find the build and settings context that owns the catalog before discovering projects, rather than starting from the nearest subproject build file.
Also at src/remediate.js:230.
Prompt for AI agents
In `src/remediate.js` at line 225:
**Sibling dependencies go unreported**
When a version catalog is stored beneath a subproject that has its own build file while the build settings file is in an ancestor directory, `findNearestBuildFile()` selects the subproject build file, so `analysisPathsFor()` starts discovery in that subproject and cannot find the ancestor settings file. Discovery falls back to the catalog or analyzes only that subproject, leaving sibling-project dependencies out of the report.
Find the build and settings context that owns the catalog before discovering projects, rather than starting from the nearest subproject build file.
Also at `src/remediate.js:230`.| const extracted = extractRemediations(analysisReport, { | ||
| providerPriority: providers ? providers.split(',').map(p => p.trim()).filter(Boolean) : undefined, | ||
| }) | ||
| const analysisReport = await analysis.requestStack(provider, analysisPath, url, false, opts) |
There was a problem hiding this comment.
🟡 Medium · Catalog audit metadata is replaced
When a version catalog is analyzed through the new project fan-out, analysis.requestStack() receives each project build file, so it encodes that file as the source manifest and labels it build.gradle or build.gradle.kts; the backend receives no version-catalog content for the catalog remediation request.
Preserve the catalog path and content as the audit manifest while separately selecting the project build file used to generate each project's SBOM.
Prompt for AI agents
In `src/remediate.js` at line 335:
**Catalog audit metadata is replaced**
When a version catalog is analyzed through the new project fan-out, `analysis.requestStack()` receives each project build file, so it encodes that file as the source manifest and labels it `build.gradle` or `build.gradle.kts`; the backend receives no version-catalog content for the catalog remediation request.
Preserve the catalog path and content as the audit manifest while separately selecting the project build file used to generate each project's SBOM.| const buildFile = findNearestBuildFile(path.dirname(manifestPath)) | ||
| if (!buildFile) { | ||
| return [manifestPath] | ||
| } |
There was a problem hiding this comment.
🟡 Medium · Catalog fallback is silently skipped
When a target catalog has no nearby Gradle build file, analysisPathsFor returns the catalog path when no build file is found, but match rejects that path because the Gradle provider requires a nearby build file. The catch then skips it, so remediation returns no results instead of performing the advertised fallback or reporting that analysis is impossible.
Do not route the catalog through provider matching in this state; either report the missing build as an error or implement a fallback that can actually analyze it.
Also at src/remediate.js:329-333.
Prompt for AI agents
In `src/remediate.js` at lines 225-228:
**Catalog fallback is silently skipped**
When a target catalog has no nearby Gradle build file, `analysisPathsFor` returns the catalog path when no build file is found, but `match` rejects that path because the Gradle provider requires a nearby build file. The catch then skips it, so remediation returns no results instead of performing the advertised fallback or reporting that analysis is impossible.
Do not route the catalog through provider matching in this state; either report the missing build as an error or implement a fallback that can actually analyze it.
Also at `src/remediate.js:329-333`.| return [manifestPath] | ||
| } | ||
|
|
||
| const projects = await discoverGradleSubprojects(path.dirname(buildFile), opts) |
There was a problem hiding this comment.
🟡 Medium · Gradle discovery can block remediation
When gradle configuration or plugin resolution stalls while listing projects, discoverGradleSubprojects runs Gradle synchronously before analysis, and invokeCommand has no timeout. A Gradle configuration or plugin-resolution process that stalls therefore blocks runRemediation indefinitely before it can return a report.
Run project discovery with a bounded timeout and surface a clear failure rather than waiting indefinitely.
Prompt for AI agents
In `src/remediate.js` at line 230:
**Gradle discovery can block remediation**
When gradle configuration or plugin resolution stalls while listing projects, `discoverGradleSubprojects` runs Gradle synchronously before analysis, and `invokeCommand` has no timeout. A Gradle configuration or plugin-resolution process that stalls therefore blocks `runRemediation` indefinitely before it can return a report.
Run project discovery with a bounded timeout and surface a clear failure rather than waiting indefinitely.| test('reports a dependency found in several projects once', async () => { | ||
| const { tomlPath, cleanup } = createMultiProject() | ||
| try { | ||
| requestStackStub.resolves(SUBPROJECT_REPORT) |
There was a problem hiding this comment.
🟡 Medium · Subproject findings go unverified
When the fan-out implementation is broken or analyzes only the root project, when runRemediation analyzes only the root project, requestStackStub.resolves(...) still supplies the subproject report. The tests reports a dependency found in several projects once (lines 329–336) and reports a subproject dependency absent from the catalog as skipped (lines 343–357) can therefore pass without analyzing any subproject.
Make the report stubs return the relevant findings only for a subproject path, and assert that the subproject was analyzed.
Also at test/remediate.test.js:346.
Prompt for AI agents
In `test/remediate.test.js` at line 332:
**Subproject findings go unverified**
When the fan-out implementation is broken or analyzes only the root project, when `runRemediation` analyzes only the root project, `requestStackStub.resolves(...)` still supplies the subproject report. The tests `reports a dependency found in several projects once` (lines 329–336) and `reports a subproject dependency absent from the catalog as skipped` (lines 343–357) can therefore pass without analyzing any subproject.
Make the report stubs return the relevant findings only for a subproject path, and assert that the subproject was analyzed.
Also at `test/remediate.test.js:346`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #697 +/- ##
==========================================
+ Coverage 91.60% 91.64% +0.04%
==========================================
Files 44 44
Lines 11638 11676 +38
Branches 2346 2361 +15
==========================================
+ Hits 10661 10701 +40
+ Misses 977 975 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Gradle remediation only supports version catalogs. The catalog target was resolved to its owning build file and analyzed with
gradle dependencies, which reports only the current project. Dependencies used solely by subprojects were therefore missing from the remediation report, and a root project with no dependencies made analysis crash outright.When the target is a
*.versions.toml, now analyze every project in that catalog's build viadiscoverGradleSubprojects(), merge the remediations and deduplicate by purl, then apply them to the catalog through the existing TOML updater. Discovery falls back to analyzing the catalog itself when no settings file or projects are found. Dependencies that are not in the catalog are reported as skipped.Two provider fixes made subproject analysis possible:
gradle propertiesinstead of requiring aRoot projectheader, which subprojects do not emitNo dependenciesinstead of treating them as depth-1 tree entries; this also fixes empty Gradle projects andstack-batchfor subproject build filesBoth golden fixtures were checked against real Gradle 8.14.3 output.
Implements TC-6900
Description
Related issues (if any):
Checklist
Additional information
Summary by Sourcery
Extend Gradle version catalog remediation to cover multi-project builds while making subproject and empty-project dependency analysis reliable.
Bug Fixes:
Enhancements:
Documentation:
Tests: