The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(debug): only treat a masked scheme as one before a token-shaped key
kshitijk4pooreb4bba0b2d91
diff --git a/hermes_cli/debug_redaction.py b/hermes_cli/debug_redaction.pyindex 99459d1db95..67b965fc645 100644--- a/hermes_cli/debug_redaction.py+++ b/hermes_cli/debug_redaction.py@@ -54,9 +54,9 @@ _QUOTED_HEADER_RE = re.compile(_BARE_HEADER_RE = re.compile(rf"(?P<prefix>\b(?:{_HEADER_NAME_PATTERN})\b\s*[:=]\s*)"# agent.redact masks the scheme of ``x-api-key: Basic <key>`` to ``***`` and- # keeps the key, so ``***`` before a same-line value (not another secret- # header) is a scheme too, and the key after it is the value.- r"(?P<value>(?>(?:(?:Bearer|Basic|Digest)\s+|\*\*\*[ \t]+(?=[^\s,}\]])"+ # keeps the key, so ``***`` before a same-line token-shaped value (not prose+ # and not another secret header) is a scheme too, and the key is the value.+ r"(?P<value>(?>(?:(?:Bearer|Basic|Digest)\s+|\*\*\*[ \t]+(?=[A-Za-z0-9._~+/-]{8,}=*(?![A-Za-z0-9._~+/=-]))"rf"(?!(?:{_HEADER_NAME_PATTERN})\b\s*[:=]))?)(?!\[REDACTED\])[^\s,}}\]]+)",re.IGNORECASE,)diff --git a/tests/tui_gateway/test_diagnostics_share_nous.py b/tests/tui_gateway/test_diagnostics_share_nous.pyindex d508b2a0d66..2c88d2ecc93 100644--- a/tests/tui_gateway/test_diagnostics_share_nous.py+++ b/tests/tui_gateway/test_diagnostics_share_nous.py@@ -189,6 +189,9 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(assert "[REDACTED]]" not in failure["error"]assert failure["error"].endswith(" --header X-API-Key Basic [REDACTED]")assert real_redact(failure["error"]) == failure["error"]+ # Prose after an already-masked value is not a key: kept, and a fixed point.+ benign = real_redact("x-api-key: *** see docs")+ assert benign.endswith(" see docs") and real_redact(benign) == benigndef test_share_nous_linkless_success_is_a_failure(monkeypatch):