-
Notifications
You must be signed in to change notification settings - Fork 233
OCM-18900 | fix: Improve proxy validation error messages for special characters in passwords #3052
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?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3052 +/- ##
==========================================
+ Coverage 23.91% 23.94% +0.03%
==========================================
Files 317 318 +1
Lines 35202 35238 +36
==========================================
+ Hits 8418 8439 +21
- Misses 26143 26159 +16
+ Partials 641 640 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fc09c54 to
aa528ca
Compare
00638f4 to
120a803
Compare
|
/retest-required |
2260456 to
c6b94b4
Compare
|
/retest-required |
|
/retest-required |
hunterkepley
left a comment
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.
The test case in the bug ticket does not seem to pass:
E: parse "http://proxyuser:QvoZjyy/trkCiY5@10.0.0.161:8080": invalid port ":QvoZjyy" after host
I think there may be a bug in the parse code
|
@hunterkepley I just did some tests here, and it seems to be working after the fix, did you test it with the branch locally ? |
96029c9 to
a50904c
Compare
|
/retest-required |
1 similar comment
|
/retest-required |
9502aa4 to
2637639
Compare
560e392 to
3df4265
Compare
|
/test all |
|
/test e2e-presubmits-pr-rosa-sts-advanced |
|
/test e2e-presubmits-pr-rosa-hcp-advanced |
|
Some reason the e2e tests didn't run, I manually ran them so we can verify this MR didn't break any |
3df4265 to
055b821
Compare
|
/retest |
2 similar comments
|
/retest |
|
/retest |
|
/test e2e-presubmits-pr-rosa-hcp-advanced |
|
/test e2e-presubmits-pr-rosa-sts-advanced |
34c6edf to
875a547
Compare
|
@olucasfreitas: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/retest |
875a547 to
4fe55d7
Compare
4fe55d7 to
a51e1b8
Compare
f7318dc to
3d09b7b
Compare
pkg/ocm/helpers.go
Outdated
| } | ||
|
|
||
| // Validate host format | ||
| _, _, err = net.SplitHostPort(parsedURL.Host) |
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.
Could you let me know why this is here?
pkg/ocm/helpers.go
Outdated
| httpProxy := val.(string) | ||
| if httpProxy == "" { | ||
| return nil | ||
| } |
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.
won't this panic if val is not a string?
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.
or a type which can be directly casted into one?
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.
I think there was some confusion on what I suggested in my comment here: #3052 (comment) because the guarding for it panicking was removed after
pkg/ocm/helpers.go
Outdated
| } | ||
|
|
||
| func ValidateHTTPSProxy(val interface{}) error { | ||
| httpsProxy := val.(string) |
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.
won't this panic?
pkg/helper/url/validation.go
Outdated
| schemeIdx := strings.Index(urlString, "://") | ||
| if schemeIdx == -1 { | ||
| return &URLCredentialValidation{} | ||
| } |
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.
Im not sure I understand, we return an empty validation error when there is no ://?
It looks like that previously, this returned an error but didn't have enough information in it. Now it has no information, could you let me know what this block of code should be doing? I might be just confused on it
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.
Also when looking at the block of code above this one, I am even more confused on what this should be accomplishing
| atIdx := strings.LastIndex(rest, "@") | ||
| if atIdx == -1 { | ||
| return &URLCredentialValidation{} | ||
| } |
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.
When an @ is not found, we return an empty validation error
What does this result in when the final error is printed out?
3d09b7b to
770854f
Compare
Details
This PR fixes a usability issue where
rosa create cluster --http-proxywas displaying unhelpful error messages when proxy passwords contained special characters like forward slashes, making it difficult for users to understand what was wrong with their input.Fixed Behavior
Run the command with a proxy password containing a forward slash:
./rosa create cluster --http-proxy "http://proxyuser:QvoZjyy/trkCiY5@10.0.0.161:8080"Now shows clear error message:
Additional Validations Added
Spaces in URL - Detects and rejects URLs with spaces:
./rosa create cluster --http-proxy "http://proxy.example.com :8080"Output:
Invalid Port Range - Validates port numbers are between 1 and 65535:
./rosa create cluster --http-proxy "http://proxy.example.com:99999"Output:
Multiple @ Symbols - Detects unencoded @ in passwords:
./rosa create cluster --http-proxy "http://user:pass@word@proxy.example.com:8080"Output:
The --https-proxy Flag Behavior
Using HTTPS scheme with
--http-proxycontinues to show the existing error:./rosa create cluster --http-proxy "https://proxy.example.com:8080"Output:
Ticket
Closes OCM-18900