Merge pull request #6255 from vieux/improve_trusted_detection
improve trusted location detection
This commit is contained in:
commit
80db172a18
@ -766,7 +766,7 @@ func trustedLocation(req *http.Request) bool {
|
||||
}
|
||||
|
||||
for _, trusted := range trusteds {
|
||||
if strings.HasSuffix(hostname, trusted) {
|
||||
if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ func TestValidRepositoryName(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)
|
||||
if trustedLocation(req) == true {
|
||||
t.Fatalf("'%s' shouldn't be detected as a trusted location", url)
|
||||
|
Loading…
Reference in New Issue
Block a user