-
Notifications
You must be signed in to change notification settings - Fork 898
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
Resolve string handling for "https://" or "http://" in update_rhsm_conf #17222
Resolve string handling for "https://" or "http://" in update_rhsm_conf #17222
Conversation
From BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1561448 The issue arises if, in the editing window where you type the URL of the proxy (Configuration=> Settings=> Region=> Redhat Updates=> Edit), you specify the proxy prefixed with "https://" or "http://". This will incorrectly assume everything after the colon is a port number. This is likely a text parsing issue, reading the colon as the port indicator and subsequently breaking up the line like so:
Workaround is to either:
The above patch didn't seem to need any new specs, and I call into question my own if/else statement, but couldn't make a smaller |
I stupidly didn't test with raw IP's - correcting and squashing shortly. Build fails when we try something like:
So need to revamp the test before we handle a URI - open to suggestions as well. |
Previously, if a proxy URI was entered into the registration page leading with "https://" or "http://", it would be incorrectly entered into the rhsm.conf. This patch prevents this by ensuring it is a valid URI, and correctly parsing the string regardless if it has only a host in the URI or if it leads with the protocol. https://bugzilla.redhat.com/show_bug.cgi?id=1561448
- Allow for http(s) or other schemes - Allow for hostname, IPv4 or IPv6 addresses https://bugzilla.redhat.com/show_bug.cgi?id=1561448
@carbonin Can I get another set of 👀 on this since I'm also a committer here? |
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.
👍
Checked commits https://github.com/robbmanes/manageiq/compare/ab7f65233e51e43c983c88f726efcd3d7a39f40d~...963a3f3a6c2a5d2b5f1059b06c75756323f22a13 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -83,8 +83,9 @@ def self.update_rhsm_conf(options = {}) | |||
|
|||
return unless option_values[:proxy_address] | |||
|
|||
write_rhsm_config(:proxy_hostname => option_values[:proxy_address].split(':')[0], | |||
:proxy_port => option_values[:proxy_address].split(':')[1], | |||
proxy_uri = URI.parse(option_values[:proxy_address].include?("://") ? option_values[:proxy_address] : "http://#{option_values[:proxy_address]}") |
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 feel like this just punts the issue down the road. Is there no field validation for this? Couldn't we just say "This thing needs to be a valid URI" and give a flash message otherwise?
For example if someone were to forget a /
and enter "http:/example.com:123" you would end up in this situation right?
irb(main):007:0> uri = URI.parse("http://http:/example.com:123")
=> #<URI::HTTP http://http/example.com:123>
irb(main):008:0> uri.host
=> "http"
irb(main):009:0> uri.port
=> 80
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 agree - I tried using Addressable::URI
objects initially before I did string checking but am not sure there is error checking by the caller of this method, and testing with that manner threw other ugly exceptions further down the stack that similar didn't appear in the UI or any easy-to-interpret log, so I instead just altered the string validation.
I can look at it deeper after this week, I am onsite with a customer now unfortunately, or we can close this PR in favor of a method that does better error handling.
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 I'm okay with this as is for now. @carbonin and I were just discussing that we may want to open a RFE to the UI to add validation to this field. At least this adds the ability to accept URLs
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.
Agree with @bdunne. This is nothing but an improvement so LGTM.
@robbmanes @carbonin Can this be |
Resolve string handling for "https://" or "http://" in update_rhsm_conf (cherry picked from commit b44f6b1) https://bugzilla.redhat.com/show_bug.cgi?id=1566562
Gaprindashvili backport details:
|
@robbmanes @bdunne Can this be |
Resolve string handling for "https://" or "http://" in update_rhsm_conf (cherry picked from commit b44f6b1) https://bugzilla.redhat.com/show_bug.cgi?id=1572621
Fine backport details:
|
…oxy_urls Resolve string handling for "https://" or "http://" in update_rhsm_conf (cherry picked from commit b44f6b1) https://bugzilla.redhat.com/show_bug.cgi?id=1572621
Previously, if a proxy URI was entered into the registration page leading with
"https://" or "http://", it would be incorrectly entered into the rhsm.conf.
This patch prevents this by ensuring it is a valid URI, and correctly parsing
the string regardless if it has only a host in the URI or if it leads with the
protocol.