Skip to content

fix(maven): accept list output in module discovery - #699

Merged
a-oren merged 1 commit into
guacsec:mainfrom
a-oren:fix/maven-module-list
Nov 18, 2026
Merged

a-oren merged 1 commit into
guacsec:mainfrom
a-oren:fix/maven-module-list

Conversation

@a-oren

@a-oren a-oren commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Restore Maven multi-module discovery when Maven Help Plugin 3.6.0 returns project.modules using a <list> wrapper instead of the older <strings> wrapper. The existing parser accepted only <strings>, silently leaving child modules undiscovered with the newer output.

  • Accept both wrappers with a one-line parser fallback.
  • Add 13 regression cases covering single/multiple modules, empty lists, nested aggregators with mixed formats, and discovery exclusions.
  • Mock Maven across the import tree so the new regression tests do not require an installed Maven executable.
  • Preserve CLI commands, settings, report/API shapes, Maven/plugin selection, and existing fallback/error handling. No plugin pinning, dependency updates, or version bump.

Related issues (if any): None linked.

Checklist

  • I have followed this repository's contributing guidelines.
  • I will adhere to the project's code of conduct.

Additional information

Verification

  • All 19 Maven discovery tests pass with Maven 3.8.8 and 3.9.11.
  • All 13 new regression tests pass with TRUSTIFY_DA_MVN_PATH=/nonexistent/mvn, confirming test isolation.
  • A seven-POM reproduction project discovers the same seven manifests with both <strings> and <list> output.
  • npm run compile: passes.
  • npm run lint: exits 0; 15 warnings in unchanged files.
  • git diff --check: passes.

Existing full-suite failures

npm test: 1,058 passing, 1 pending, 18 failing in this environment. The same 18 failure names were reproduced by running the four affected test files on unchanged baseline commit ce9658d:

  • 3 OCI SBOM comparison failures.
  • 1 Python BEST_EFFORTS timeout.
  • 2 pipdeptree errors.
  • 2 virtualenv/pip errors.
  • 10 missing-Poetry errors.

These baseline failures are outside the Maven discovery change and are left untouched. The full local suite is therefore not green.

Summary by Sourcery

Support Maven Help Plugin module-list output across both XML wrapper formats while preserving existing discovery behavior.

Bug Fixes:

  • Restore Maven multi-module discovery for both legacy <strings> and newer <list> module output formats.

Tests:

  • Add regression coverage for single, multiple, nested, empty, mixed-format, and excluded Maven module discovery scenarios with mocked Maven execution.

Maven Help Plugin 3.6.0 emits <list> for project.modules where older
versions emit <strings>. Accept both formats so workspace discovery
continues to include child modules.

Signed-off-by: Adva Oren <aoren@redhat.com>
@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Accept Maven Help Plugin output wrapped in either or so module discovery handles both formats.

  • src/providers/java_maven.js L576

Tests

Add regression coverage for both wrappers, including empty output, nested aggregators, exclusions, and mocked Maven execution.

  • test/providers/workspace.test.js L333-405

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/providers/java_maven.js" line_range="576" />
<code_context>
 	const parser = new XMLParser()
 	const parsed = parser.parse(raw)
-	const entries = parsed?.strings?.string
+	const entries = parsed?.strings?.string ?? parsed?.list?.string
 	if (!entries) { return [] }
 	const list = Array.isArray(entries) ? entries : [entries]
</code_context>
<issue_to_address>
**Module paths execute shell commands**

When a Windows user scans an untrusted Maven workspace whose `<list>` output names an existing module directory containing shell metacharacters, `collectMavenModules` resolves the module path and passes its POM to `listMavenModules`; on Windows, `invokeCommand` enables `shell: true` and `handleSpacesInPath` quotes only paths containing spaces, so an ampersand in the path is interpreted as a command separator and runs a command as the scanner user.

Avoid invoking Maven through a shell, or correctly quote/escape every argument passed through the Windows shell.
</issue_to_address>

### Comment 2
<location path="src/providers/java_maven.js" line_range="576" />
<code_context>
 	const parser = new XMLParser()
 	const parsed = parser.parse(raw)
-	const entries = parsed?.strings?.string
+	const entries = parsed?.strings?.string ?? parsed?.list?.string
 	if (!entries) { return [] }
 	const list = Array.isArray(entries) ? entries : [entries]
</code_context>
<issue_to_address>
**Numeric module paths are skipped**

When maven returns a `<list>` containing a valid module path such as `0`, `XMLParser` converts a `<string>0</string>` entry to numeric `0`, so the existing falsy check in `parseMavenModuleList` returns no modules and discovery omits that child POM.

Check for `null` or `undefined` rather than general falsiness before normalizing the entries.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: src/providers/java_maven.js:576, src/providers/java_maven.js:576


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/providers/java_maven.js Resolved
Comment thread src/providers/java_maven.js Resolved
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.60%. Comparing base (ce9658d) to head (1cb43bf).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #699   +/-   ##
=======================================
  Coverage   91.60%   91.60%           
=======================================
  Files          44       44           
  Lines       11638    11638           
  Branches     2346     2347    +1     
=======================================
  Hits        10661    10661           
  Misses        977      977           
Flag Coverage Δ
unit-tests 91.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@a-oren
a-oren requested review from Strum355 and ruromero November 18, 2026 14:58
@a-oren
a-oren merged commit c2ce130 into guacsec:main Nov 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants