From ba0f5839d462aca26b06b060e95e2b381a328ced Mon Sep 17 00:00:00 2001 From: fangliquanflq Date: Mon, 31 Aug 2026 15:48:34 +0800 Subject: [PATCH] fix(redact): keep lowercase assignment scans linear --- agent/redact.py | 6 +++++- tests/agent/test_redact.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/agent/redact.py b/agent/redact.py index 7fa3c11e1d..eb41ef0551 100644 --- a/agent/redact.py +++ b/agent/redact.py @@ -158,8 +158,12 @@ _ENV_ASSIGN_RE = re.compile( # Lowercase env names: only underscore-boundary forms (``openai_key=…``, # ``FAL_KEY=…``, ``db_pw=…``) — NOT bare ``password=``/``token=``/``secret=``, # which appear in prose, URLs, and form bodies (issue #77484). +# Anchor each attempt to the start of an identifier run. Without the +# lookbehind, ``re.sub`` retries the greedy ``[a-z0-9_]+`` prefix at every byte +# of a long non-matching opaque payload, making strict compaction redaction +# quadratic while holding the GIL (#99255). _ENV_ASSIGN_LOWER_RE = re.compile( - rf"([a-z0-9_]+(?:_|^)(?:key|pass|pw|token|secret|password|passwd|credential|auth)(?=[^a-z0-9_]|$))\s*=\s*(['\"]?)(\S+)\2", + rf"(?