You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7d17ea1
Browse filesBrowse the repository at this point in the historyBrowse files
Pin the redaction fingerprint's mappings, and cover the cache-hit path
Review of #5171:
- _log_secret_fingerprint() recorded id(args)/id(secrets). A stored id is only
an integer, so once the mapping it came from is freed CPython may hand that
address to the next allocation and a same-length replacement landing there
compares equal - skipping the rebuild and leaving a just-configured
credential unredacted until the next explicit invalidation. It now holds the
mappings themselves, compared by _log_secret_fingerprint_matches() with `is`
so the recorded address always belongs to a live object and an
equal-but-distinct mapping still counts as a change.
- Corrected the lock comment: it is acquired on every _log_secret_pattern()
call, so on every log line, and only held longer for a rebuild - not "only
ever held for the duration of a rebuild". Records the cross-instance cost of
sharing it, and that nothing reached under it logs, so there is no
re-entrant path back into log() to deadlock a non-reentrant Lock.
- test_log_secret_pattern_cache_is_reused() counts rebuilds, closing the gap
where a regression that recompiled on every log line passed the whole suite.
- test_log_secret_fingerprint_is_not_fooled_by_address_reuse() asserts the
fingerprint refers to the mapping it describes (fails without the fix above).
- The mixin test caught only AttributeError, so any other failure aborted the
run instead of reporting a failed test.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
print("ERROR: the stored fingerprint does not refer to the mapping it describes, so that mapping can be freed and its address handed to a same-length replacement - which would compare as unchanged and skip the rebuild")
1069
+
failed=True
1070
+
1071
+
second_line=redact_log_line("Info: using SECOND-ADDRESS-SECRET-5171", redactor._log_secret_pattern())
0 commit comments