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:
imSp4rky
2026-08-31 09:45:19 -06:00
parent a01ff594da
commit 57ddefc69b
8 changed files with 81 additions and 48 deletions
+5 -1
View File
@@ -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