Skip to content
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
5 changes: 3 additions & 2 deletions kubernetes/stream/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,9 @@ def websocket_proxycare(connect_opt, configuration, url, headers):
for key,value in configuration.proxy_headers.items():
if key == 'proxy-authorization' and value.startswith('Basic'):
b64value = value.split()[1]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description also mentions a bare Basic header, but that still raises IndexError here. Could it get the same error?

auth = urlsafe_b64decode(b64value).decode().split(':')
connect_opt.update({'http_proxy_auth': (auth[0], auth[1]) })
auth = urlsafe_b64decode(b64value).decode().split(':', 1)
if len(auth) == 2:
connect_opt.update({'http_proxy_auth': (auth[0], auth[1]) })
Comment on lines +603 to +604

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a credential that has no colon, this now silently skips http_proxy_auth: the CONNECT goes out without Proxy-Authorization, and the user gets failed CONNECT via proxy status: 407 instead of an error about the header. Could we raise an ApiValueError here (bad base64 or non-UTF-8 credentials already raise in this block), and have the useronly test case expect it?

return(connect_opt)


Expand Down
2 changes: 2 additions & 0 deletions kubernetes/stream/ws_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def test_websocket_proxycare(self):
( 'http://proxy.example.com:8080/', 'user:pass', '*', 'proxy.example.com', 8080, ('user','pass'), ['*']),
( 'http://proxy.example.com:8080/', 'user:pass', '.example.com', 'proxy.example.com', 8080, ('user','pass'), ['.example.com']),
( 'http://proxy.example.com:8080/', 'user:pass', 'localhost,.local,.example.com', 'proxy.example.com', 8080, ('user','pass'), ['localhost','.local','.example.com']),
( 'http://proxy.example.com:8080/', 'user:pa:ss:word', None, 'proxy.example.com', 8080, ('user','pa:ss:word'), None),
( 'http://proxy.example.com:8080/', 'useronly', None, 'proxy.example.com', 8080, None, None),
]:
# input setup
cfg = Configuration(proxy='', no_proxy='')
Expand Down
Loading