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
fix(sanitization): custom_patterns propagation through sanitize_entry (v0.7.1) (#40)
* fix(sanitization): custom_patterns now propagates through sanitize_entry
The 0.7.0 ContextVar-scoped override was entered only by sanitize_post_data
and sanitize_html. Three detection sites in _sanitize_request /
_sanitize_response that run before either of those — header-value matching
(sanitize_header_value), structured queryString params, and URL query
params (_sanitize_url_query_params) — silently ignored custom_patterns
when callers used sanitize_entry / sanitize_har / sanitize_har_file.
Fix: enter both ContextVar scopes at sanitize_entry, so every detection
site within an entry sees the same extension set.
Adds a parallel _HeaderSets frozen dataclass + _HEADER_SETS_CTX ContextVar
+ _header_sets_scope context manager + _resolve_header_sets resolver
backed by a bounded LRU cache, mirroring the _FieldPatternSet infrastructure
shipped in 0.7.0. sanitize_header_value now reads from the ContextVar
instead of module-global sets, so custom headers.full_redact /
headers.cookie_redact entries take effect end-to-end via the top-level
entry points.
Tests: +12. Header-sets internals (compile / resolve / cache / scope-restore
on exception) + propagation through sanitize_entry and sanitize_har for
each of the three gaps + scope isolation between consecutive entries.
1845 tests pass, 85.65% coverage.
Held locally for the next release cycle (0.7.1). Not pushed.
Closes the gap the reviewer flagged after 0.7.0 shipped: once we fixed the
sanitize_html instance of "module-global predicate bypassed by custom_patterns,"
we should have swept the same class. sanitize_header_value + queryString +
URL query params were structurally identical and got deferred as
"nice-to-have" when they should have been included.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(release): bump version to 0.7.1
Cuts [Unreleased] to [0.7.1] - 2026-04-24 and adds comparison links,
following the release flow documented in CLAUDE.md. Single release PR
(feature fix + version bump).
Release notes summary: custom_patterns now propagates through sanitize_entry
to all detection sites (headers, cookies, queryString, URL-query params,
bodies, inline scripts), closing a security-adjacent gap in 0.7.0 where
top-level entry-point consumers were silently getting unredacted data.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Ken Schulz <kwschulz@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
## [0.7.1] - 2026-04-24
11
+
12
+
### Fixed
13
+
14
+
- **`custom_patterns` now propagates through `sanitize_entry` to all detection sites** — In 0.7.0 the `ContextVar`-scoped override was entered only by `sanitize_post_data` and `sanitize_html`, so three detection sites in `_sanitize_request` / `_sanitize_response` that run before either of those — header-value matching (`sanitize_header_value`), structured `queryString` params, and URL query params (`_sanitize_url_query_params`) — silently ignored `custom_patterns` when callers used the top-level entry points (`sanitize_entry`, `sanitize_har`, `sanitize_har_file`). **Security-adjacent**: consumers passing `custom_patterns={"headers": {"full_redact": ["x-modem-auth"]}}` to `sanitize_har_file` were getting unredacted auth headers in their "sanitized" HAR. Fixed by entering both scopes at `sanitize_entry`, so every detection site within an entry sees the same extension set. Adds a parallel `_HeaderSets` dataclass + `_HEADER_SETS_CTX` ContextVar + `_header_sets_scope` / `_resolve_header_sets` resolver + cache so `sanitize_header_value` picks up custom `headers.full_redact` / `headers.cookie_redact` entries the same way field detection picks up custom `fields.auto_redact_patterns`. Module-global state still never mutated.
0 commit comments