"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(channels): keep redacting url userinfo when the authority has whitespace
cgycorey0772d31e34d4
diff --git a/agent/src/channels/config_meta.py b/agent/src/channels/config_meta.pyindex 6bdc409ad..a6584ac7d 100644--- a/agent/src/channels/config_meta.py+++ b/agent/src/channels/config_meta.py@@ -346,7 +346,9 @@ def _mask(value: Any, *, reveal_suffix: bool = True) -> dict[str, Any]:# last '@'. Matching it textually rather than through urllib.parse keeps a# malformed or out-of-range port from defeating the strip: ``urlsplit(...).port``# raises on those, and the fail-open fallback returned the credential.-_URL_USERINFO_RE = re.compile(r"([a-zA-Z][a-zA-Z0-9+.\-]*://)(?:[^/\s?#]*@)?(\S*)")+# The authority is matched as text, so the userinfo group tolerates whitespace+# inside it (``pass word@host``) instead of stopping at the first space.+_URL_USERINFO_RE = re.compile(r"([a-zA-Z][a-zA-Z0-9+.\-]*://)(?:[^/?#]*@)?(\S*)")def _strip_url_userinfo(value: Any) -> Any:diff --git a/agent/tests/test_channel_config_meta.py b/agent/tests/test_channel_config_meta.pyindex ed5e7f50b..1e6394b6b 100644--- a/agent/tests/test_channel_config_meta.py+++ b/agent/tests/test_channel_config_meta.py@@ -619,6 +619,9 @@ def test_proxy_url_userinfo_is_stripped_from_values() -> None:"note": "plain text","bad_proxy": "http://user:pw@host:notaport","far_port": "https://user:pw@host:99999/hook",+ "space_url": "http://admin:pass word@proxy:8080",+ "tab_url": "http://us\ter:pw@host/",+ "space_user_url": "https://user:pw @host:8080","token": "abc",},)@@ -631,6 +634,13 @@ def test_proxy_url_userinfo_is_stripped_from_values() -> None:assert values["bad_proxy"] == "http://host:notaport"# Nor may an out-of-range port (a plausible typo).assert values["far_port"] == "https://host:99999/hook"+ # Whitespace inside the authority must not exempt the URL from redaction.+ assert values["space_url"] == "http://proxy:8080"+ assert "pass word" not in values["space_url"]+ assert values["tab_url"] == "http://host/"+ assert "pw" not in values["tab_url"]+ assert values["space_user_url"] == "https://host:8080"+ assert "user:pw" not in values["space_user_url"]assert secrets["token"] == {"set": True, "masked": "****"}