-
Notifications
You must be signed in to change notification settings - Fork 727
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?
Redact specific url query string values and url credentials in instrumentations #3508
Conversation
util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py
Outdated
Show resolved
Hide resolved
Please update the changelog to include these changes |
...pentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py
Outdated
Show resolved
Hide resolved
@hectorhdzg, @xrmx I observed that in the method - |
I think we should just add the tests |
fa76a1b
to
6c89a56
Compare
@xrmx I've added the test for the |
2a783a4
to
1e91a8d
Compare
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py
Outdated
Show resolved
Hide resolved
1e91a8d
to
1884a1f
Compare
0cafc21
to
b5b5272
Compare
@@ -1373,12 +1376,15 @@ def test_basic_multiple(self): | |||
self.assert_span(num_spans=2) | |||
self.assert_metrics(num_metrics=1) | |||
|
|||
def test_credential_removal(self): | |||
new_url = "http://username:password@mock/status/200" | |||
def test_remove_sensitive_params(self): |
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.
It looks like that for httpx < 0.20, the username:password isn't present in the URL itself, but in headers as basic auth. Maybe we need to implement custom logic here to check that?
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.
@emdneto I did add the logic for checking the auth in the headers. However based on the conversation with @xrmx - #3508 (comment), I removed the logic for it.
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.
I mean in the httpx instrumentation test to make tests pass
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.
I mean in the httpx instrumentation test to make tests pass
I see, sure I will add the logic for it. Thank you for the suggestion.
@@ -73,7 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
### Added | |||
|
|||
- `opentelemetry-instrumentation-aiohttp-client` Add support for HTTP metrics | |||
([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) | |||
([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) |
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.
([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) | |
([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) |
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, 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.