-
Notifications
You must be signed in to change notification settings - Fork 271
MGMT-24487: Allow https scheme in HTTPS proxy URL #10589
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,22 +95,31 @@ func ValidateHTTPFormat(theurl string) error { | |
| return nil | ||
| } | ||
|
|
||
| // ValidateHTTPProxyFormat validates the HTTP Proxy and HTTPS Proxy format | ||
| func ValidateHTTPProxyFormat(proxyURL string) error { | ||
| func validateProxyURLFormat(proxyURL string, allowedSchemes ...string) error { | ||
| if !govalidator.IsURL(proxyURL) { | ||
| return errors.Errorf("Proxy URL format is not valid: '%s'", proxyURL) | ||
| } | ||
| u, err := url.Parse(proxyURL) | ||
| if err != nil { | ||
| return errors.Errorf("Proxy URL format is not valid: '%s'", proxyURL) | ||
| } | ||
| if u.Scheme == "https" { | ||
| return errors.Errorf("The URL scheme must be http; https is currently not supported: '%s'", proxyURL) | ||
| } | ||
| if u.Scheme != "http" { | ||
| return errors.Errorf("The URL scheme must be http and specified in the URL: '%s'", proxyURL) | ||
| for _, scheme := range allowedSchemes { | ||
| if u.Scheme == scheme { | ||
| return nil | ||
| } | ||
| } | ||
| return nil | ||
| return errors.Errorf("The URL scheme must be %s and specified in the URL: '%s'", | ||
| strings.Join(allowedSchemes, " or "), proxyURL) | ||
| } | ||
|
|
||
| // ValidateHTTPProxyFormat validates the HTTP Proxy format (http scheme only) | ||
| func ValidateHTTPProxyFormat(proxyURL string) error { | ||
| return validateProxyURLFormat(proxyURL, "http") | ||
| } | ||
|
|
||
| // ValidateHTTPSProxyFormat validates the HTTPS Proxy URL format (http or https schemes are valid) | ||
| func ValidateHTTPSProxyFormat(proxyURL string) error { | ||
|
yoavsc0302 marked this conversation as resolved.
|
||
| return validateProxyURLFormat(proxyURL, "http", "https") | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: The comment on |
||
|
|
||
| func validateNoProxyEntry(entry string) error { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this calls
ValidateHTTPSProxyFormat, it would be good to add an integration-level test that sends anhttps://URL as httpsProxy through one of the API handlers (e.g.,V2UpdateClusterorRegisterInfraEnv) and asserts success.Currently all the tests that exercise
validateProxySettingspasshttp://or empty string for httpsProxy. The existinghttps://proxy.proxyfixtures at lines 3722 and 5412 ininventory_test.gowrite directly to the DB, bypassing validation entirely. Without a test going through the API path, a future revert of this line would go undetected.