Skip to content

The agent that grows with you

fix(debug): scrub the whole free-text Bearer value, inner = padding included

kshitijk4poor25e1fd3b3888
diff --git a/hermes_cli/debug_redaction.py b/hermes_cli/debug_redaction.py
index a860183a8f0..f73dbfc3d2b 100644
--- a/hermes_cli/debug_redaction.py
+++ b/hermes_cli/debug_redaction.py
@@ -112,7 +112,10 @@ _PLAIN_HEADER_ARG_RE = re.compile(
re.IGNORECASE,
)
_SUPPORT_BEARER_RE = re.compile(
- rf"(?P<prefix>\bBearer\s+|\bBasic\s+{_NOT_WORD})(?=[^\s]{{8}}){_KEY}",
+ # Free text has no header boundary to stop at: consume the whole value,
+ # inner ``=`` padding included (``abcd1234==x``), not just a key-shaped prefix.
+ rf"(?P<prefix>\bBearer\s+|\bBasic\s+{_NOT_WORD})(?=[^\s]{{8}})"
+ rf"[{_KEY_CHARS}=]+(?::[{_KEY_CHARS}=]+)*",
re.IGNORECASE,
)
diff --git a/tests/tui_gateway/test_diagnostics_share_nous.py b/tests/tui_gateway/test_diagnostics_share_nous.py
index 517e25cd317..29db6ff2644 100644
--- a/tests/tui_gateway/test_diagnostics_share_nous.py
+++ b/tests/tui_gateway/test_diagnostics_share_nous.py
@@ -205,6 +205,7 @@ def test_redacted_support_egress_scrubs_structured_values_and_errors(
("--header x-api-key *** " + "Q" * 32, "Q" * 32),
("x-api-key: *** sk-abc:xyz123456", "xyz123456"),
("Basic user:passw0rd", "passw0rd"),
+ ("Bearer abcd1234=efgh5678 x", "efgh5678"),
("?r=x%2526access_token%253Dtok123456789", "tok123456789"),
):
assert key not in real_redact(leaky)