Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: GCS endpoint validation to allow ports #1985

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/s3utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func IsGoogleEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
return false
}
return endpointURL.Host == "storage.googleapis.com"
return endpointURL.Hostname() == "storage.googleapis.com"
}

// Expects ascii encoded strings - from output of urlEncodePath
Expand Down
2 changes: 2 additions & 0 deletions pkg/s3utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ func TestIsGoogleEndpoint(t *testing.T) {
// valid inputs.
{"http://storage.googleapis.com", true},
{"https://storage.googleapis.com", true},
{"http://storage.googleapis.com:80", true},
{"https://storage.googleapis.com:443", true},
}

for i, testCase := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func TestGetEndpointURL(t *testing.T) {
{"192.168.1.1:9000", false, "http://192.168.1.1:9000", nil, true},
{"192.168.1.1:9000", true, "https://192.168.1.1:9000", nil, true},
{"s3.amazonaws.com:443", true, "https://s3.amazonaws.com:443", nil, true},
{"storage.googleapis.com:443", true, "https://storage.googleapis.com:443", nil, true},
{"[::1]", false, "http://[::1]", nil, true},
{"[::1]", true, "https://[::1]", nil, true},
{"[::1]:80", false, "http://[::1]:80", nil, true},
Expand All @@ -122,7 +123,6 @@ func TestGetEndpointURL(t *testing.T) {
{"[::1]:9000", true, "https://[::1]:9000", nil, true},
{"13333.123123.-", true, "", errInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "13333.123123.-")), false},
{"13333.123123.-", true, "", errInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "13333.123123.-")), false},
{"storage.googleapis.com:4000", true, "", errInvalidArgument("Google Cloud Storage endpoint should be 'storage.googleapis.com'."), false},
{"s3.aamzza.-", true, "", errInvalidArgument(fmt.Sprintf("Endpoint: %s does not follow ip address or domain name standards.", "s3.aamzza.-")), false},
{"", true, "", errInvalidArgument("Endpoint: does not follow ip address or domain name standards."), false},
}
Expand Down
Loading