Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,16 @@ private Result acceptPrefix(RemoteRepository repository, String path) {
+ " (verified served despite stale auto-discovered prefixes)");
}
}
return result(
accepted,
NAME,
accepted
? "Path " + path + " allowed from " + repository.getId()
: "Path " + path + " NOT allowed from " + repository.getId());
String reasoning = accepted
? "Path " + path + " allowed from " + repository.getId()
: "Path " + path + " NOT allowed from " + repository.getId();
if (!accepted && cachedPrefixes.autoDiscovered()) {
reasoning += ". The auto-discovered prefixes file may be incomplete. If this repository is a virtual "
+ "aggregate, set -D" + CONFIG_PROP_VERIFY_DENIED_DROPS_TREE + "." + repository.getId()
+ "=true to drop its prefixes file for this session, or contact the repository administrator. "
+ "See https://maven.apache.org/resolver/remote-repository-filtering.html";
}
return result(accepted, NAME, reasoning);
}

private Result noInputResult(RemoteRepository repository, String reasoning) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ void verificationCanBeDisabled() throws Exception {
verify(transporter, never()).peek(any(PeekTask.class));
}

@Test
void deniedAutoDiscoveredPathExplainsRepositorySpecificWorkaround() {
session.setConfigProperty("aether.remoteRepositoryFilter.prefixes.verifyDenied", "false");
RemoteRepositoryFilter filter = subject.getRemoteRepositoryFilter(session);
assertNotNull(filter);

RemoteRepositoryFilter.Result result = filter.acceptArtifact(remoteRepository, jenkinsArtifact);

assertFalse(result.isAccepted());
assertTrue(result.reasoning()
.contains("aether.remoteRepositoryFilter.prefixes.verifyDeniedDropsTree.jenkins-public=true"));
assertTrue(result.reasoning().contains("contact the repository administrator"));
assertTrue(result.reasoning().contains("https://maven.apache.org/resolver/remote-repository-filtering.html"));
}

@Test
void offlineSessionSkipsVerification() throws Exception {
session.setOffline(true);
Expand Down Expand Up @@ -289,7 +304,9 @@ void userProvidedPrefixesAreAuthoritative() throws Exception {
assertNotNull(filter);

// deliberately user-authored prefixes are never second-guessed
assertFalse(filter.acceptArtifact(remoteRepository, jenkinsArtifact).isAccepted());
RemoteRepositoryFilter.Result result = filter.acceptArtifact(remoteRepository, jenkinsArtifact);
assertFalse(result.isAccepted());
assertFalse(result.reasoning().contains("verifyDeniedDropsTree"));
verify(transporter, never()).peek(any(PeekTask.class));
}
}