mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
improve trusted location detection
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
This commit is contained in:
parent
f7e4546af0
commit
daa89c420c
2 changed files with 2 additions and 2 deletions
|
@ -766,7 +766,7 @@ func trustedLocation(req *http.Request) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, trusted := range trusteds {
|
for _, trusted := range trusteds {
|
||||||
if strings.HasSuffix(hostname, trusted) {
|
if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ func TestValidRepositoryName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTrustedLocation(t *testing.T) {
|
func TestTrustedLocation(t *testing.T) {
|
||||||
for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io"} {
|
for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io", "https://fakedocker.com"} {
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
if trustedLocation(req) == true {
|
if trustedLocation(req) == true {
|
||||||
t.Fatalf("'%s' shouldn't be detected as a trusted location", url)
|
t.Fatalf("'%s' shouldn't be detected as a trusted location", url)
|
||||||
|
|
Loading…
Reference in a new issue