Skip to content

ref(integrations): route HTTP header filtering through data collection config - #6788

Merged
ericapisani merged 26 commits into
masterfrom
py-2584-update-wsgi-filter-headers
Jul 22, 2026
Merged

ref(integrations): route HTTP header filtering through data collection config#6788
ericapisani merged 26 commits into
masterfrom
py-2584-update-wsgi-filter-headers

Make changes to adjust to the data collection option being within the…

a590c8e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Jul 9, 2026 in 0s

3 issues

Medium

Allowlist header filtering substitutes `host`, corrupting event URL construction - `sentry_sdk/data_collection.py:109`

When data_collection.http_headers.request is configured in allowlist mode and "host" is not among the allowed terms, _filter_headers (in _wsgi_common.py) legitimately substitutes the host value with "[Filtered]". However, _get_request_data and _get_request_attributes in _asgi_common.py then pass headers.get("host") — now the substituted string "[Filtered]" — directly into _get_url. Because "[Filtered]" is truthy, _get_url builds URLs such as http://[Filtered]/path instead of falling back to the ASGI server field, corrupting the reported request URL. Previously host was never filtered (it is not in SENSITIVE_HEADERS), so this is a regression introduced by routing header filtering through the data-collection config. The fix belongs in _asgi_common.py: derive the host used for URL construction from the raw headers/scope rather than from the scrubbed headers.

Low

Test branches on parametrize ID string instead of `expected is None`, risking silent test failure - `tests/integrations/aiohttp/test_aiohttp.py:1409`

In test_sensitive_header_passthrough_with_pii_span_streaming, use if expected is None instead of if request.node.callspec.id == "data_collection_off_does_not_add_headers". If the parametrize ID is ever renamed, the intended branch is silently skipped and the else branch runs expected["authorization"] on None, raising a TypeError. Keying on the semantically-meaningful expected value is more robust.

Test branching on string test-ID instead of `expected is None`, silently breaks on rename - `tests/integrations/aiohttp/test_aiohttp.py:1410-1414`

The if request.node.callspec.id == "data_collection_off_does_not_add_headers": guard should instead use if expected is None:. If the parametrize ID is ever renamed, the condition silently falls through to the else branch and immediately raises TypeError: 'NoneType' object is not subscriptable on expected["authorization"], producing a confusing failure rather than the intended assertion about absent headers.

4 skills analyzed
Skill Findings Duration Cost
security-review 0 3m 6s $0.61
code-review 1 10m 58s $2.13
find-bugs 2 12m 4s $3.62
skill-scanner 0 8m 4s $0.07

⏱ 34m 13s · 3.0M in / 210.1k out · $6.43