GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Scope server credentials and validate legacy relocation coordinates by gnodet · Pull Request #12977 · apache/maven

Conversation

@gnodet

@gnodet gnodet commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Forward-port of #12954 from maven-3.10.x to maven-4.0.x, adapting all three fixes for the 4.0.x module structure and API differences:

  • OriginBoundAuthenticationSelector (new file in impl/maven-core): scopes server credentials to the declared origins (protocol, host, port) of repositories and mirrors configured in settings, preventing credential leakage to unrelated repositories. Supports three modes via maven.repository.credentialScope: origin (default), strict, and id (legacy).
  • Relocation coordinate validation (compat/maven-compat MavenMetadataSource): validates relocation groupId, artifactId, and version components before applying them, rejecting path traversal characters (/, \, ..) and control characters.
  • Exact server ID matching (compat/maven-compat DefaultWagonManager): uses equals instead of equalsIgnoreCase for server ID matching, consistent with LegacyRepositorySystem.injectAuthentication and the resolver's authentication selector.

Adaptations for 4.0.x

  • Module paths: maven-compat/ -> compat/maven-compat/, maven-core/ -> impl/maven-core/
  • OriginBoundAuthenticationSelector uses org.slf4j.Logger (4.0.x) instead of org.codehaus.plexus.logging.Logger (3.10.x)
  • Credential scope property read from mergedProps (4.0.x property flow) instead of ConfigUtils.getString(configProps, ...) (3.10.x)
  • MavenMetadataSourceRelocationTest uses constructor injection (4.0.x) instead of reflection-based field injection (3.10.x)

Test plan

  • mvn verify -pl impl/maven-core -- 602 tests pass, 0 failures
  • mvn verify -pl compat/maven-compat -- 156 tests pass, 0 failures
  • New OriginBoundAuthenticationSelectorTest covers: declared origin matching, origin scoping, undeclared ID legacy behavior, strict mode refusal, ID scope passthrough, unknown scope rejection, origin normalization
  • New MavenMetadataSourceRelocationTest covers: invalid artifactId rejection, well-formed relocation application

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Aug 31, 2026
Validate metadata inputs across legacy and new API paths, clone proxies before decryption #12950
Merged
Scope server credentials and validate legacy relocation coordinates #12976
Merged
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 1, 2026
@gnodet gnodet added the bug Something isn't working label Sep 1, 2026
@gnodet
gnodet marked this pull request as ready for review September 1, 2026 17:27
gnodet
gnodet commented Sep 1, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Clean forward-port of #12954 from maven-3.10.x to maven-4.0.x. All adaptations are correctly applied:

  • Module paths: impl/maven-core/ and compat/maven-compat/ (4.0.x structure)
  • Logging: org.slf4j.Logger instead of Plexus Logger
  • Property flow: mergedProps.getOrDefault(...) instead of ConfigUtils.getString(configProps, ...)
  • Test injection: Constructor injection instead of reflection-based field injection

CI passes on all 24 checks (ubuntu, macos, windows; JDK 17, 21, 25). One minor style nit noted inline (carried over from the 3.10.x version).

Observations (informational):

  1. The MAVEN_REPOSITORY_CREDENTIAL_SCOPE constant is defined on DefaultRepositorySystemSessionFactory rather than in org.apache.maven.api.Constants where most other user-facing properties live. Could be moved in a follow-up for consistency.

🔀 Backport / Forward-port Status

Branch Status
maven-3.10.x ✅ #12954 (merged)
maven-4.0.x 🔄 This PR
maven-3.9.x ⚠️ Still has equalsIgnoreCase bug and lacks credential scoping + relocation validation
master ⚠️ Still has equalsIgnoreCase in compat/maven-compat/.../DefaultWagonManager.java and lacks credential scoping

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...ompat/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceRelocationTest.java Outdated
ArtifactMetadataRetrievalException exception =
assertThrows(ArtifactMetadataRetrievalException.class, () -> source.retrieve(request));
assertEquals(true, exception.getMessage().contains("a/b"));
assertEquals(true, exception.getMessage().contains("artifactId"));

@gnodet gnodet Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Style nit (also noted in the 3.10.x review of #12954): assertEquals(true, ...) is less readable than assertTrue(...) for boolean assertions.

Suggested change
assertEquals(true, exception.getMessage().contains("artifactId"));
assertTrue(exception.getMessage().contains("a/b"));
assertTrue(exception.getMessage().contains("artifactId"));

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet mentioned this pull request Sep 1, 2026
Credential scoping + relocation validation (3.9.x backport) #13005
Merged
2 of 3 tasks
@gnodet @claude
Scope server credentials and validate legacy relocation coordinates
4b74bb4
Forward-port of PR #12954 from maven-3.10.x to maven-4.0.x:

- OriginBoundAuthenticationSelector: scopes server credentials to
  declared origins (protocol, host, port) of repositories and mirrors,
  preventing credential leakage to unrelated repositories
- MavenMetadataSource: validates relocation coordinate components
  (groupId, artifactId, version) before applying them, rejecting
  path traversal characters and control characters
- DefaultWagonManager: uses exact server ID matching (equals instead
  of equalsIgnoreCase) consistent with LegacyRepositorySystem and the
  resolver's authentication selector

Adapted for 4.0.x module structure (compat/maven-compat, impl/maven-core)
and API differences (SLF4J logger, constructor injection, merged properties).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gnodet
gnodet force-pushed the pr/legacy-compat-credential-scope-4.0.x branch from de2b905 to 4b74bb4 Compare September 1, 2026 21:10
@gnodet @claude
Fix Spotless formatting violation
cf995d9
Remove unused import left by rebase.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gnodet gnodet mentioned this pull request Sep 1, 2026
Scope server credentials and validate legacy relocation coordinates #12954
Merged
@gnodet @claude
Fix test compilation: add throws clause to noRelocationReturnsNull
9726990
The relocatedTarget method now declares ArtifactDescriptorException
(added by the relocation validation merge). The test must declare it.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gnodet
gnodet merged commit e7b6d36 into maven-4.0.x Sep 2, 2026
23 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@gnodet
gnodet deleted the pr/legacy-compat-credential-scope-4.0.x branch September 2, 2026 06:16
@github-actions github-actions Bot assigned gnodet Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

bug Something isn't working

Projects

None yet

Milestone

4.0.0-rc-7

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@gnodet
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.