[Corehttp] Add tracing query param sanitization#46657
Merged
pvaneck merged 1 commit intoAzure:mainfrom May 8, 2026
Merged
Conversation
a6741fa to
556f4c0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes corehttp tracing safer by default by sanitizing URL query parameter values before recording them as span attributes, while still allowing users to opt-in specific query parameters to remain visible.
Changes:
- Add
sanitize_urlutility to redact non-allowlisted query parameter values (default placeholderREDACTED). - Introduce
additional_allowed_query_paramsonDistributedHttpTracingPolicy, with a default allowlist includingapi-version. - Add
CaseInsensitiveSetto support case-insensitive allowlist checks and expand/update tests and changelog accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/core/corehttp/corehttp/runtime/policies/_distributed_tracing.py | Sanitizes url.full span attribute and adds allowlist configuration via additional_allowed_query_params. |
| sdk/core/corehttp/corehttp/runtime/policies/_utils.py | Adds sanitize_url helper used by tracing to redact query parameter values. |
| sdk/core/corehttp/corehttp/utils/_utils.py | Adds CaseInsensitiveSet used for case-insensitive allowlist membership checks. |
| sdk/core/corehttp/tests/test_utils.py | Adds unit tests for sanitize_url and CaseInsensitiveSet. |
| sdk/core/corehttp/tests/test_tracing_policy.py | Updates existing tracing assertions and adds new tests validating default/custom sanitization behavior. |
| sdk/core/corehttp/CHANGELOG.md | Documents the new tracing allowlist knob and the default sanitization behavior change. |
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
kashifkhan
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds sanitization to URL query parameters that are set as span attributes.
Port of: #46482