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 <noah.treuhaft@docker.com>
This commit is contained in:
Noah Treuhaft 2016-07-11 12:13:42 -07:00
parent 4e17ab5d31
commit 042bc06175
2 changed files with 6 additions and 0 deletions

View file

@ -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
}
}
}

View file

@ -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"},