Skip to content

Resolve Maven properties in component coordinates - #1882

Merged
Aayush Maini (AMaini503) merged 4 commits into
mainfrom
users/aamaini/fix-maven-coordinate-properties
Sep 29, 2026
Merged

Aayush Maini (AMaini503) merged 4 commits into
mainfrom
users/aamaini/fix-maven-coordinate-properties

Conversation

@AMaini503

@AMaini503 Aayush Maini (AMaini503) commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolve Maven property references in every component coordinate field when the static POM parser is used.

  • interpolate properties in groupId, artifactId, and version
  • recursively resolve nested local and inherited properties with cycle detection
  • support embedded references such as spark-core_${scala.version.major}
  • skip components whose coordinates remain unresolved
  • bump the Maven detector version from 5 to 6

Testing

  • dotnet build --no-restore --configuration Debug
  • dotnet test test\Microsoft.ComponentDetection.Detectors.Tests\Microsoft.ComponentDetection.Detectors.Tests.csproj --no-build --configuration Debug -p:ExcludeIntegrationTests=false -p:TestingPlatformCommandLineArguments="--filter FullyQualifiedName~MvnCliDetectorTests"

Resolve Maven property references in group IDs and artifact IDs as well as versions when using static POM parsing. Skip components whose coordinates remain unresolved and bump the detector version for the output change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Single-pass interpolation incorrectly skips valid components containing nested property references.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Extends Maven static parsing to interpolate properties across dependency coordinates.

Changes:

  • Resolves local and inherited coordinate properties.
  • Skips unresolved coordinates.
  • Adds tests and bumps detector version to 6.
File Description
MvnCliComponentDetector.cs Expands coordinate properties and defers unresolved components.
PendingComponent.cs Renames coordinate fields as templates.
MvnCliDetectorTests.cs Tests interpolation, inheritance, and unresolved coordinates.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs Outdated
Recursively resolve coordinate properties with memoization and cycle detection. Add coverage for nested local and inherited properties and cyclic definitions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unbounded recursive property expansion can terminate scans through stack exhaustion.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread src/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.cs Outdated
Limit recursive coordinate property expansion to prevent deeply nested POM properties from exhausting the process stack. Leave over-depth coordinates unresolved so they are skipped safely.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The unresolved-reference check can register malformed Maven placeholders as valid components.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Unresolved Maven placeholders are incorrectly registered as components

src/​Microsoft.ComponentDetection.Detectors/​maven/​MvnCliComponentDetector.cs:284

This check misses unresolved forms such as ${} and ${missing because the resolution regex requires a nonempty, closed expression. Those versions were previously deferred by StartsWith("${") and skipped, but are now registered as Maven components with literal placeholder text. Use a broader residual-marker check after expansion so any remaining Maven interpolation start causes the coordinate to be skipped.

Treat any residual Maven interpolation marker as unresolved so malformed references are skipped rather than emitted as component coordinates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 19:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation safely handles the documented resolution cases and includes focused regression coverage.

Review effort: Balanced
Findings: None

@AMaini503
Aayush Maini (AMaini503) merged commit 2107109 into main Sep 29, 2026
16 checks passed
@AMaini503
Aayush Maini (AMaini503) deleted the users/aamaini/fix-maven-coordinate-properties branch September 29, 2026 20:03
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