-
Notifications
You must be signed in to change notification settings - Fork 703
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
base: main
Are you sure you want to change the base?
WIP - Redact specific url query string values and url credentials in instrumentations #3508
Conversation
…t in instrumentations
util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py
Outdated
Show resolved
Hide resolved
Please update the changelog to include these changes |
…m/rads-1996/opentelemetry-python-contrib into rads-1996/redact-sensitive-params
…m/rads-1996/opentelemetry-python-contrib into rads-1996/redact-sensitive-params
@@ -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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
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 theusername: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: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.
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
remove_url_credentials
andredact_query_parameters
methods.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.