From 042bc06175e0db49bf6d8c287ba6fe6d821dd8d8 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Mon, 11 Jul 2016 12:13:42 -0700 Subject: [PATCH] Properly validate multi-URL foreign layers The existing code effectively ignored errors from all but the last of a foreign layer's URLs. Signed-off-by: Noah Treuhaft --- registry/storage/schema2manifesthandler.go | 1 + registry/storage/schema2manifesthandler_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/registry/storage/schema2manifesthandler.go b/registry/storage/schema2manifesthandler.go index 6456efa4..fc7cc6eb 100644 --- a/registry/storage/schema2manifesthandler.go +++ b/registry/storage/schema2manifesthandler.go @@ -107,6 +107,7 @@ func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst sche pu, err = url.Parse(u) if err != nil || (pu.Scheme != "http" && pu.Scheme != "https") || pu.Fragment != "" { err = errInvalidURL + break } } } diff --git a/registry/storage/schema2manifesthandler_test.go b/registry/storage/schema2manifesthandler_test.go index c2f61edf..766b4535 100644 --- a/registry/storage/schema2manifesthandler_test.go +++ b/registry/storage/schema2manifesthandler_test.go @@ -78,6 +78,11 @@ func TestVerifyManifestForeignLayer(t *testing.T) { []string{"https://foo/bar", ""}, errInvalidURL, }, + { + foreignLayer, + []string{"", "https://foo/bar"}, + errInvalidURL, + }, { foreignLayer, []string{"http://foo/bar"},