mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-16 14:05:10 +00:00
feat(proxy): mask proxy credentials in console and API output
Show user:pass as xxxxx:xxxxx in "Using ... Proxy" lines (full URI with -d), hide Basic provider hostnames, and redact proxy URIs in REST API error responses and remote session logs.
This commit is contained in:
@@ -6,6 +6,7 @@ from requests.utils import prepend_scheme_if_needed
|
||||
from urllib3.util import parse_url
|
||||
|
||||
from unshackle.core.proxies.proxy import Proxy
|
||||
from unshackle.core.utils.redact import mask_proxy
|
||||
|
||||
|
||||
class Basic(Proxy):
|
||||
@@ -49,6 +50,9 @@ class Basic(Proxy):
|
||||
proxy = prepend_scheme_if_needed(proxy, "http")
|
||||
parsed_proxy = parse_url(proxy)
|
||||
if not parsed_proxy.host:
|
||||
raise ValueError(f"The proxy '{proxy}' is not a valid proxy URI supported by Python-Requests.")
|
||||
raise ValueError(
|
||||
f"The proxy '{mask_proxy(proxy, mask_host=True, allow_debug=False)}' "
|
||||
"is not a valid proxy URI supported by Python-Requests."
|
||||
)
|
||||
|
||||
return proxy
|
||||
|
||||
Reference in New Issue
Block a user