GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix prefix filter verification for denied artifact paths by harshab054 · Pull Request #2188 · apache/maven-resolver Conversation
Contributor
Description Fixes the Maven Resolver prefix filter behavior when a repository serves an artifact path that is missing from its "prefixes.txt". A repository such as an Artifactory/Nexus virtual repository may expose a prefixes file generated from a public repository index while also serving private/internal artifacts. When the requested artifact path is absent from that prefixes file, the prefix filter can reject an artifact that the repository actually serves. This change verifies a denied path against the repository before permanently rejecting it. Implementation
Security The implementation preserves the security invariant introduced by Resolver PR #2082. A successful verification of one denied path does NOT disable the prefix filter for the entire repository or authorize unrelated artifact paths. Only the exact remotely verified path is allowed. Tests
Related Maven Issue This addresses the underlying Maven Resolver behavior reported in Apache Maven issue #13385: The original issue is reported against Maven because Maven users experience the resolution failure, while the prefix filtering implementation itself lives in Maven Resolver.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
gnodet-bot
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for tackling the per-path caching — the direction is right. A few observations: This review was generated by an AI agent, Hermès on behalf of @gnodet.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
gnodet
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this — the per-path verification caching and the One thing that's missing and would make a real difference for users: an actionable error message when a path is rejected. Right now, when a denied path makes it through the pre-checks and ends up getting a hard rejection (e.g. That's what users see in Since we're already in For user-provided prefix files (not auto-discovered), keep the bare message — those denials are deliberate. Would you be willing to add this here? It's a small addition but would save a lot of debugging time for users hitting this in the wild.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
6 of 7 tasks
1 of 2 tasks
gnodet-bot
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The latest commits address all three previous observations — good follow-up:
The test additions are solid: One informational note: No blocking issues. This review was generated by an AI agent, Hermès on behalf of @gnodet.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
gnodet
approved these changes
|
There was an error while loading. Please reload this page.
|
I am very uneasy on changes like this (and previous #2082) and here is why: prefixes are usually (and are meant) to be resolved from remote, but, there are (may be) cases, when user wants to provide them manually, check out the RRF demo: https://github.com/cstamas/rrf-demo/tree/master/.mvn/rrf So in latter case, prefixes now become "advice" only? In other word, in latter case they are "user provided configuration", that Maven may opt to simply ignore/override? Like, I configured it intentionally like this, but will Maven obey or not, is up to some heuristics. We may then want to distinguish, between "user provided" (when content comes from a configured file) and "remotely resolved" (when it comes from remote)? And this is the reason why I was pushing for "black or white": when present, no magic but fully obeyed, or when absent (404 or user configures it disabled) just work without it. Essentially, it boils down to one thing: "fix your MRM, it is broken". No magic or heuristic helps here, when software is broken. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for raising this concern. I agree that explicitly user-provided prefix filters should be enforced strictly and should not be silently overridden. My intention with this change was to address incomplete, automatically discovered prefix files while preserving strict filtering for user-provided configurations. Would you recommend limiting the verification behavior strictly to automatically discovered prefixes, while keeping user-provided prefix files fully enforced? Or would you prefer a strict, black-or-white policy for both cases? I'd be happy to adjust the implementation based on the intended Resolver behavior. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yes, that would make sense: limit this behaviour for automatically discovered prefix files only. And many-many thanks for the work so far! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @cstamas, I've updated the PR to restrict denied-path verification exclusively to automatically discovered prefix files, while keeping user-provided prefix files strictly enforced. I've also addressed the singleton allocation and synchronization documentation feedback. The targeted tests and all 19 reported CI matrix jobs are passing. Whenever you have time, could you please take another look? Thank you for the feedback! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes Maven Resolver’s prefix filter behavior when a repository serves artifact paths that are missing from an auto-discovered prefixes.txt, by verifying denied paths against the remote repository and caching the outcomes.
Changes:
| File | Description |
|---|---|
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/filter/PrefixesRemoteRepositoryFilterSource.java |
Implements per-path verification outcomes and caching; updates denial reasoning and verification behavior. |
maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/filter/PrefixesRemoteRepositoryFilterSourceVerifyDeniedTest.java |
Adds/updates test coverage for per-path verification, caching semantics, and reasoning content. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| private VerificationOutcome remoteRepositoryServesPath(RemoteRepository repository, String path) { | ||
| Transporter transporter = null; | ||
| try { | ||
| transporter = transporterProvider.newTransporter(session, repository); | ||
| transporter.peek(new PeekTask(new URI(null, null, path, null))); | ||
| return true; | ||
| return VerificationOutcome.SERVED; | ||
| } catch (URISyntaxException e) { | ||
| logger.debug("Cannot construct URI for denied path {} of {}", path, repository, e); | ||
| return false; | ||
| return VerificationOutcome.ABSENT; | ||
| } catch (Exception e) { | ||
| logger.debug("Verification of denied path {} against {} failed", path, repository, e); | ||
| return false; | ||
| if (transporter != null && transporter.classify(e) == Transporter.ERROR_NOT_FOUND) { | ||
| return VerificationOutcome.ABSENT; | ||
| } | ||
| return VerificationOutcome.UNKNOWN; | ||
| } finally { | ||
| if (transporter != null) { | ||
| transporter.close(); | ||
| } | ||
| } | ||
| } |
| private final Set<String> verifiedServedPaths; | ||
| private final Set<String> verifiedAbsentPaths; | ||
|
|
||
| private CachedPrefixes(PrefixTree prefixTree, boolean autoDiscovered) { | ||
| this.prefixTree = prefixTree; | ||
| this.autoDiscovered = autoDiscovered; | ||
| this.verifiedServedPaths = autoDiscovered ? ConcurrentHashMap.newKeySet() : Collections.emptySet(); | ||
| this.verifiedAbsentPaths = autoDiscovered ? ConcurrentHashMap.newKeySet() : Collections.emptySet(); | ||
| } |
| reasoning += " (auto-discovered prefix file appears incomplete). If this repository serves a " | ||
| + "virtual aggregate with an incomplete prefix file, set -D" | ||
| + CONFIG_PROP_VERIFY_DENIED + "." + repository.getId() | ||
| + "=true or report this to the repository administrator. " | ||
| + "See https://maven.apache.org/resolver/remote-repository-filtering.html"; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Following up on my earlier review — all previous observations have been addressed, and the new commit is clean.
The delta (fixing verifiedAbsentResult on the post-lock path, extracting inconclusiveVerificationResult, correcting URISyntaxException → UNKNOWN to prevent false negative caching, leading-slash stripping, and the offline-aware reasoning branch in notAllowedResult) is correct throughout. All new tests exercise the right code paths.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
transporter.close() in the finally block can throw, which would override the intended… · NewVerificationOutcome.ABSENT on URISyntaxException is logically incorrect: URI…verifiedServedPaths / verifiedAbsentPaths sets can grow without bound for… · NewverifiedServedPaths and especially verifiedAbsentPaths sets can grow…probePath by stripping leading slashes, but caching uses the original… · NewprobePath by stripping leading slashes, but caching uses the original… · NewprobePath by stripping leading slashes, but caching uses the original… · NewReview effort: Lite
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| private VerificationOutcome remoteRepositoryServesPath(RemoteRepository repository, String path) { | ||
| Transporter transporter = null; | ||
| try { | ||
| String probePath = path; | ||
| while (probePath.startsWith("/")) { | ||
| probePath = probePath.substring(1); | ||
| } | ||
| transporter = transporterProvider.newTransporter(session, repository); | ||
| transporter.peek(new PeekTask(new URI(null, null, probePath, null))); | ||
| return VerificationOutcome.SERVED; | ||
| } catch (URISyntaxException e) { | ||
| logger.debug("Cannot construct URI for denied path {} of {}", path, repository, e); | ||
| return false; | ||
| return VerificationOutcome.UNKNOWN; | ||
| } catch (Exception e) { | ||
| logger.debug("Verification of denied path {} against {} failed", path, repository, e); | ||
| return false; | ||
| if (transporter != null && transporter.classify(e) == Transporter.ERROR_NOT_FOUND) { | ||
| return VerificationOutcome.ABSENT; | ||
| } | ||
| return VerificationOutcome.UNKNOWN; | ||
| } finally { | ||
| if (transporter != null) { | ||
| transporter.close(); | ||
| } | ||
| } | ||
| } |
| private final Set<String> verifiedServedPaths; | ||
| private final Set<String> verifiedAbsentPaths; | ||
|
|
||
| private CachedPrefixes(PrefixTree prefixTree, boolean autoDiscovered) { | ||
| this.prefixTree = prefixTree; | ||
| this.autoDiscovered = autoDiscovered; | ||
| this.verifiedServedPaths = autoDiscovered ? ConcurrentHashMap.newKeySet() : Collections.emptySet(); | ||
| this.verifiedAbsentPaths = autoDiscovered ? ConcurrentHashMap.newKeySet() : Collections.emptySet(); | ||
| } |
|
|
||
| private void allowVerifiedServedPath(String path) { | ||
| this.verifiedServedPath = path; | ||
| this.verifiedServedPaths.add(path); |
| private void recordVerifiedAbsentPath(String path) { | ||
| this.verifiedAbsentPaths.add(path); | ||
| } |
| String probePath = path; | ||
| while (probePath.startsWith("/")) { | ||
| probePath = probePath.substring(1); | ||
| } |
There was an error while loading. Please reload this page.
…)" This reverts commit 836f47a.
There was an error while loading. Please reload this page.
|
This PR was merged, and now is reverted 7ab6dbb The PR caused massive slowdown, approximately doubling build times. And I am personally back to my original stance: Maven should not "figure out" anything when it comes to broken remote repositories, instead, those using it should pressure vendors to fix them (or just use some other software instead of the broken one). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.