Scope server credentials and validate legacy relocation coordinates - #12977
Merged
Conversation
This was referenced Aug 31, 2026
Merged
gnodet
marked this pull request as ready for review
September 1, 2026 17:27
gnodet
commented
Sep 1, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
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/andcompat/maven-compat/(4.0.x structure) - Logging:
org.slf4j.Loggerinstead of Plexus Logger - Property flow:
mergedProps.getOrDefault(...)instead ofConfigUtils.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):
- The
MAVEN_REPOSITORY_CREDENTIAL_SCOPEconstant is defined onDefaultRepositorySystemSessionFactoryrather than inorg.apache.maven.api.Constantswhere 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 |
equalsIgnoreCase bug and lacks credential scoping + relocation validation |
master |
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
| ArtifactMetadataRetrievalException exception = | ||
| assertThrows(ArtifactMetadataRetrievalException.class, () -> source.retrieve(request)); | ||
| assertEquals(true, exception.getMessage().contains("a/b")); | ||
| assertEquals(true, exception.getMessage().contains("artifactId")); |
Contributor
Author
There was a problem hiding this comment.
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")); |
3 tasks
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 <noreply@anthropic.com>
gnodet
force-pushed
the
pr/legacy-compat-credential-scope-4.0.x
branch
from
September 1, 2026 21:10
de2b905 to
4b74bb4
Compare
Remove unused import left by rebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The relocatedTarget method now declares ArtifactDescriptorException (added by the relocation validation merge). The test must declare it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Forward-port of #12954 from
maven-3.10.xtomaven-4.0.x, adapting all three fixes for the 4.0.x module structure and API differences:OriginBoundAuthenticationSelector(new file inimpl/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 viamaven.repository.credentialScope:origin(default),strict, andid(legacy).compat/maven-compatMavenMetadataSource): validates relocationgroupId,artifactId, andversioncomponents before applying them, rejecting path traversal characters (/,\,..) and control characters.compat/maven-compatDefaultWagonManager): usesequalsinstead ofequalsIgnoreCasefor server ID matching, consistent withLegacyRepositorySystem.injectAuthenticationand the resolver's authentication selector.Adaptations for 4.0.x
maven-compat/->compat/maven-compat/,maven-core/->impl/maven-core/OriginBoundAuthenticationSelectorusesorg.slf4j.Logger(4.0.x) instead oforg.codehaus.plexus.logging.Logger(3.10.x)mergedProps(4.0.x property flow) instead ofConfigUtils.getString(configProps, ...)(3.10.x)MavenMetadataSourceRelocationTestuses 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 failuresmvn verify -pl compat/maven-compat-- 156 tests pass, 0 failuresOriginBoundAuthenticationSelectorTestcovers: declared origin matching, origin scoping, undeclared ID legacy behavior, strict mode refusal, ID scope passthrough, unknown scope rejection, origin normalizationMavenMetadataSourceRelocationTestcovers: invalid artifactId rejection, well-formed relocation application🤖 Generated with Claude Code