diff --git a/internal/handler/maven.go b/internal/handler/maven.go index e841d083..cd947633 100644 --- a/internal/handler/maven.go +++ b/internal/handler/maven.go @@ -221,14 +221,11 @@ func (h *MavenHandler) handleDownload(w http.ResponseWriter, r *http.Request, so // e.g., com/google/guava/guava/32.1.3-jre/guava-32.1.3-jre.jar group, artifact, version, filename := h.parsePath(urlPath) if artifact == "" { - if strings.Count(urlPath, "/") >= minMavenParts-1 { - // A dot or colon in a group directory, or a colon in the - // artifact, which the Maven layout never has. Proxied, the - // file would skip the denylist, scan and cooldown. - http.NotFound(w, r) - return - } - h.proxyUpstream(w, r, source, urlPath) + // Too few segments to hold a coordinate, or a dot or colon in a + // group directory, or a colon in the artifact, which the Maven + // layout never has. Proxied, the file would skip the denylist, + // scan and cooldown. + http.NotFound(w, r) return } diff --git a/internal/handler/maven_repositories_test.go b/internal/handler/maven_repositories_test.go index e9b2fcf4..5c9dd717 100644 --- a/internal/handler/maven_repositories_test.go +++ b/internal/handler/maven_repositories_test.go @@ -139,15 +139,17 @@ func TestMavenRepositoryRepointedServesTheNewUpstream(t *testing.T) { } } -// TestMavenDottedGroupDirectoryNotCachedAsGroup checks that a file whose -// group directories contain dots or colons, which the Maven layout never -// has, is not served: it would either share the cache entry of the group -// the dots spell or be proxied past the denylist, scan and cooldown. +// TestMavenDottedGroupDirectoryNotCachedAsGroup checks that a file outside +// the Maven layout is not served: a group directory with a dot or a colon, +// which the layout never has and which would share the cache entry of the +// group the dots spell, and a path too short to hold a coordinate. Proxied, +// they would skip the denylist, scan and cooldown. func TestMavenDottedGroupDirectoryNotCachedAsGroup(t *testing.T) { const standard = "/org/foo/bar/1.0/bar-1.0.jar" odd := []string{ "/org.foo/bar/1.0/bar-1.0.jar", "/org.foo/bar/1.0/bar-1.0-linux.exe", "/org/foo:x/bar/1.0/bar-1.0.jar", "/org/foo/b:ar/1.0/b:ar-1.0.jar", + "/bar/1.0/bar-1.0.jar", "/bar-1.0.jar", } central, requests := mavenRepoUpstream(t, "central", append([]string{standard}, odd...)...) portal, _ := mavenRepoUpstream(t, "portal")