Skip to content

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 8 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 are currently implemented in isolation. Once this PR is approved, I will integrate them into the relevant instrumentations and raise a follow-up PR for that integration.

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
@@ -160,22 +161,23 @@ def parse_excluded_urls(excluded_urls: str) -> ExcludeList:

def remove_url_credentials(url: str) -> str:
"""Given a string url, remove the username and password only if it is a valid url"""

# Modifying current functionality of removing url credentials and instead replacing the username and password with the keyword "REDACTED" as per the semantic conventions for http-spans (https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Modifying current functionality of removing url credentials and instead replacing the username and password with the keyword "REDACTED" as per the semantic conventions for http-spans (https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md)
""" Given a string url, replace the username and password with the keyword "REDACTED "only if it is a valid url"""

Copy link
Author

Choose a reason for hiding this comment

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

Updated the PR with this modification and updated the change log.

@hectorhdzg
Copy link
Member

Please update the changelog to include these changes

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.

2 participants