Skip to content

WIP - Redact specific url query string values and url credentials in instrumentations #3508

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

rads-1996
Copy link

@rads-1996 rads-1996 commented May 16, 2025

Description

This pull request provides an implementation for issue #2992 which points to a specification which states that specific URL query string values should now be redacted by default. This PR also aligns with the semantic conventions for HTTP spans which states that sensitive content provided in url.full SHOULD be scrubbed when instrumentations can identify it, in such case username and password SHOULD be redacted (https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md).

The existing method remove_url_credentials (PR: #538), which previously removed the username:password portion from a URL if present, has been updated to replace the credentials with the string REDACTED.

The new method redact_query_parameters removes the values of query string parameters for the following keys by default:

  - AWSAccessKeyId

  - Signature

  - sig

  - X-Goog-Signature

Note: This is not an exhaustive list and is subject to change over time.

These methods have been absorbed in the following instrumentations - httpx, requests, urllib, urllib3, aiohttp, tornado, asgi, wsgi.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests have been added to validate the functionality of both remove_url_credentials and redact_query_parameters methods.

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@rads-1996 rads-1996 requested a review from a team as a code owner May 16, 2025 14:36
@hectorhdzg
Copy link
Member

Please update the changelog to include these changes

@github-actions github-actions bot requested a review from shalevr May 20, 2025 16:33
@rads-1996 rads-1996 changed the title Redact specific url query string values and url credentials in instrumentations WIP - Redact specific url query string values and url credentials in instrumentations May 20, 2025
@@ -232,7 +233,8 @@ def get_or_create_headers():
method = request.method
span_name = get_default_span_name(method)

url = remove_url_credentials(request.url)
url = redact_query_parameters(remove_url_credentials(request.url))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think on creating a redact_url function that calls both instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that does make sense. I will make changes for it.

parsed.fragment,
)
)
except ValueError: # an unparsable url was passed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just for urlparse, maybe do an early return instead so we save one indentation level?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants