Repository navigation
fix(gql): Remove credentials and query values from the transport URL - #8227
Mohil-Ahuja wants to merge 2 commits into
Conversation
The integration copied transport.url into event["request"]["url"] unchanged, so credentials and query tokens in the URL were sent with every event, whatever send_default_pii was set to. Sanitize it with parse_url and send the filtered query in query_string.
sentrivana
left a comment
There was a problem hiding this comment.
Hey @Mohil-Ahuja, thanks for the PR. One thing that I'm missing is support for data_collection -- that's an SDK option that will supersede send_default_pii in the next major. At the moment, we need to support both data_collection and send_default_pii (data_collection takes precedence, if provided).
There are two places where I'm missing data_collection support:
- In the integration itself, when attaching
query_string.data_collectionhas a setting calledurl_query_params(https://docs.sentry.io/platforms/python/data-management/data-collected/#request-query-string) which controls whether to attach the query and if so, what to omit from it. - In the test, we only parametrize based on
send_default_pii; we need to parametrize based on differentdata_collectionoptions as well. Check out similar tests for inspiration.
Also, I believe we just need one test case, parametrized on the different send_default_pii and data_collection configs, based on test_transport_url_is_sanitized; no need for the other test cases.
|
@sentrivana thanks, updated in cfb50c6. When The other test cases are gone. |
Description
The gql integration copied
transport.urlintoevent["request"]["url"]unchanged, so credentials and query tokens in the URL were sent with every event, whateversend_default_piiwas set to.The URL now goes through
parse_url. The authority is filtered inurl, and the query goes toquery_string.One change from what I suggested in the issue: I kept
parse_url's default sanitizing instead ofsanitize=False. Withsanitize=False, a token such asaccess_token=...would only move fromurltoquery_stringand still be sent. Query values are now always[Filtered], with the keys kept, even withsend_default_pii=True. If you'd rather keep the values when PII is enabled, that's a small change.The URL is passed through
str()because some transports accept a URL object as well as a string. If parsing fails,urlis left out of the event.I ran
tests/integrations/gqlthrough tox onpy3.10-gql-v3.4.1,py3.14-gql-v4.4.0andpy3.14-gql-latest, plus ruff and mypy. Without the change, the new sanitizing tests fail.Issues