"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(redaction): redact lowercase aws_ credential names
t8d3b4531de28
diff --git a/agent/src/tools/redaction.py b/agent/src/tools/redaction.pyindex d34a5fe3c..a595de155 100644--- a/agent/src/tools/redaction.py+++ b/agent/src/tools/redaction.py@@ -401,8 +401,9 @@ def _redact_token_usage(value: Any, *, sink: str) -> Any:#: scoped to credential field names so a benign number in shell output (a#: price, a duration, a timestamp) is never mangled.#:-#: All names are SINGULAR and must start a word: either a ``\b`` boundary, or an-#: UPPERCASE env-style prefix such as ``TUSHARE_`` (see :data:`_TEXT_KV_PATTERN`).+#: All names are SINGULAR and must start a word: either a ``\b`` boundary, an+#: UPPERCASE env-style prefix such as ``TUSHARE_``, or the ``aws_`` prefix (see+#: :data:`_TEXT_KV_PATTERN`).#: A plural is a count or a collection, never a credential, and matching it#: mangles routine output (``tokens: 1204 in / 318 out`` from the LLM usage#: line, ``api_keys: 3``). A lowercase suffix like ``pad_token`` or@@ -435,8 +436,9 @@ _TEXT_KV_PATTERN = re.compile(# ``\b`` for a plain name; for an env-style name the label follows an# UPPERCASE segment and ``_`` (``TUSHARE_TOKEN``). The inline ``(?-i:...)``# keeps the uppercase test case-sensitive under IGNORECASE, so ``pad_token``- # and ``max_token`` still do not match.- r"(?:\b|(?<=(?-i:[A-Z0-9])_))"+ # and ``max_token`` still do not match. ``aws_`` is the one lowercase prefix+ # accepted, for ``~/.aws/credentials`` names such as ``aws_secret_access_key``.+ r"(?:\b|(?<=(?-i:[A-Z0-9])_)|(?<=aws_))"r"(?P<name>" + _TEXT_CREDENTIAL_KEYS + r")\b(?P=q)"r"(?P<sep>\s*[:=]\s*)"r"(?![\"']?" + re.escape(_REDACTED) + r"[\"']?|bearer\b)"diff --git a/agent/tests/test_redaction.py b/agent/tests/test_redaction.pyindex 1c6fc1d3d..00d0fe9ec 100644--- a/agent/tests/test_redaction.py+++ b/agent/tests/test_redaction.py@@ -160,6 +160,10 @@ _CREDENTIAL_SHAPES = (# trailing word boundary needs the full ``secret_access_key`` alternative.("AWS_SECRET_ACCESS_KEY=wJalrXUt/K7MDENG", "AWS_SECRET_ACCESS_KEY=[redacted]"),("secret_access_key: abc123", "secret_access_key: [redacted]"),+ # Lowercase AWS names, as in ~/.aws/credentials. ``aws_`` is the one+ # lowercase prefix accepted; other lowercase prefixes stay identifiers.+ ("aws_secret_access_key = abc123", "aws_secret_access_key = [redacted]"),+ ("aws_session_token = abc123", "aws_session_token = [redacted]"),)@@ -222,6 +226,9 @@ def test_redact_text_is_idempotent(raw: str) -> None:"tokenizer=bert-base version=2",# Lowercase suffixes of longer identifiers are not env-style names."pad_token=0 eos_token=2 max_token=4096",+ # Other aws_ names are config, not credentials.+ "aws_region = us-east-1",+ "aws_profile=default",# JSON fields after a URL must survive; only real userinfo is scrubbed.'{"url":"https://api.x.com","email":"[email protected]"}',# A short SSH username is not a credential; keep it readable.