-
Notifications
You must be signed in to change notification settings - Fork 630
fix(aiohttp): Gate url.full, url.path, url.query on send_default_pii #6650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1136,11 +1136,15 @@ | |
| assert event["exception"]["values"][0]["type"] == "ZeroDivisionError" | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
|
Check warning on line 1139 in tests/integrations/aiohttp/test_aiohttp.py
|
||
| async def test_tracing_span_streaming(sentry_init, aiohttp_client, capture_items): | ||
| @pytest.mark.parametrize("send_pii", [True, False]) | ||
| async def test_tracing_span_streaming( | ||
| sentry_init, aiohttp_client, capture_items, send_pii | ||
| ): | ||
| sentry_init( | ||
| integrations=[AioHttpIntegration()], | ||
| traces_sample_rate=1.0, | ||
| send_default_pii=send_pii, | ||
| _experiments={"trace_lifecycle": "stream"}, | ||
| ) | ||
|
|
||
|
|
@@ -1184,13 +1188,25 @@ | |
|
|
||
| # Request attributes derived directly from the aiohttp request. | ||
| assert server_span["attributes"]["http.request.method"] == "GET" | ||
| # client.address and user.ip_address is gated on send_default_pii (default False), so it must | ||
| # not be captured here. | ||
| assert "client.address" not in server_span["attributes"] | ||
| assert "user.ip_address" not in server_span["attributes"] | ||
| url_full = server_span["attributes"]["url.full"] | ||
| assert url_full.startswith("http://127.0.0.1:") | ||
| assert url_full.endswith("/") | ||
|
|
||
| if send_pii: | ||
| assert "client.address" in server_span["attributes"] | ||
| assert "user.ip_address" in server_span["attributes"] | ||
|
|
||
| url_full = server_span["attributes"]["url.full"] | ||
| assert url_full.startswith("http://127.0.0.1:") | ||
| assert url_full.endswith("/") | ||
|
|
||
| url_path = server_span["attributes"]["url.path"] | ||
| assert url_path == "/" | ||
| else: | ||
| assert "url.full" not in server_span["attributes"] | ||
| assert "url.path" not in server_span["attributes"] | ||
| assert "url.query" not in server_span["attributes"] | ||
|
sentry-warden[bot] marked this conversation as resolved.
|
||
|
|
||
| assert "client.address" not in server_span["attributes"] | ||
| assert "user.ip_address" not in server_span["attributes"] | ||
|
|
||
| # aiohttp's test client always sends a Host header; we assert it propagates | ||
| # into the span attributes via _filter_headers. | ||
| assert "http.request.header.host" in server_span["attributes"] | ||
|
|
@@ -1280,12 +1296,14 @@ | |
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("send_pii", [True, False]) | ||
| async def test_url_query_attribute_span_streaming( | ||
| sentry_init, aiohttp_client, capture_items | ||
| sentry_init, aiohttp_client, capture_items, send_pii | ||
| ): | ||
| sentry_init( | ||
| integrations=[AioHttpIntegration()], | ||
| traces_sample_rate=1.0, | ||
| send_default_pii=send_pii, | ||
| _experiments={"trace_lifecycle": "stream"}, | ||
| ) | ||
|
|
||
|
|
@@ -1306,7 +1324,10 @@ | |
| assert len(items) == 2 | ||
| server_segment, client_segment = [item.payload for item in items] | ||
|
|
||
| assert server_segment["attributes"]["url.query"] == "foo=bar&baz=qux" | ||
| if send_pii: | ||
| assert server_segment["attributes"]["url.query"] == "foo=bar&baz=qux" | ||
| else: | ||
| assert "url.query" not in server_segment["attributes"] | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
|
|
@@ -1486,15 +1507,17 @@ | |
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("send_pii", [True, False]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parametrized The Evidence
Also found at 1 additional location
Identified by Warden code-review · Q2F-VZM |
||
| async def test_outgoing_client_span_span_streaming( | ||
| sentry_init, aiohttp_raw_server, aiohttp_client, capture_items | ||
| sentry_init, aiohttp_raw_server, aiohttp_client, capture_items, send_pii | ||
| ): | ||
| sentry_init( | ||
| integrations=[AioHttpIntegration()], | ||
| traces_sample_rate=1.0, | ||
| send_default_pii=send_pii, | ||
| _experiments={"trace_lifecycle": "stream"}, | ||
| ) | ||
|
|
||
|
Check warning on line 1520 in tests/integrations/aiohttp/test_aiohttp.py
|
||
| async def handler(request): | ||
| return web.Response(text="OK") | ||
|
|
||
|
|
@@ -1536,16 +1559,21 @@ | |
| assert inner_client_span["attributes"]["sentry.origin"] == "auto.http.aiohttp" | ||
| assert inner_client_span["attributes"]["http.request.method"] == "GET" | ||
| assert inner_client_span["attributes"]["http.response.status_code"] == 200 | ||
| assert inner_client_span["attributes"]["url.query"] == "foo=bar" | ||
| assert inner_client_span["status"] == "ok" | ||
|
|
||
| url_full = inner_client_span["attributes"]["url.full"] | ||
| # parse_url() splits the URL — url.full is the base URL only, with the | ||
| # query string captured separately on url.query. | ||
| assert url_full.startswith("http://127.0.0.1:") | ||
| assert url_full.endswith("/") | ||
| if send_pii: | ||
| assert inner_client_span["attributes"]["url.query"] == "foo=bar" | ||
|
|
||
| url_full = inner_client_span["attributes"]["url.full"] | ||
|
|
||
| # parse_url() splits the URL — url.full is the base URL only, with the | ||
| # query string captured separately on url.query. | ||
| assert url_full.startswith("http://127.0.0.1:") | ||
| assert url_full.endswith("/") | ||
|
|
||
| assert inner_client_span["attributes"]["url.path"] == "/" | ||
|
|
||
|
|
||
|
Check warning on line 1576 in tests/integrations/aiohttp/test_aiohttp.py
|
||
| @pytest.mark.asyncio | ||
| async def test_outgoing_trace_headers_span_streaming( | ||
| sentry_init, aiohttp_raw_server, aiohttp_client, capture_items | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.