Skip to content

feat: filter username and password in URLs #864

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

Merged
merged 7 commits into from
Jul 28, 2025
Merged

Conversation

lcian
Copy link
Member

@lcian lcian commented Jul 18, 2025

Close #516

Copy link

github-actions bot commented Jul 18, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f6bca12

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.03%. Comparing base (f247ac0) to head (f6bca12).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #864      +/-   ##
==========================================
- Coverage   73.06%   73.03%   -0.03%     
==========================================
  Files          64       64              
  Lines        7207     7266      +59     
==========================================
+ Hits         5266     5307      +41     
- Misses       1941     1959      +18     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +24 to +27
let _ = url.set_username(PII_REPLACEMENT);
}
if url.password().is_some() {
let _ = url.set_password(Some(PII_REPLACEMENT));
Copy link
Member Author

Choose a reason for hiding this comment

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

The cases in which these can fail are documented as follows:

If this URL is cannot-be-a-base or does not have a host, do nothing and return `Err`.

This happens for instance if the URL is relative. In these cases we just ignore the errors.

Copy link
Member

Choose a reason for hiding this comment

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

Please add this information as a code comment, as it could be helpful for future developers

@lcian lcian requested a review from szokeasaurusrex July 24, 2025 13:33
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Mostly looks good, please address my inline comments before merging.

Also, we discussed this offline: as a further improvement (so not blocking this PR), I would suggest enforcing the URL stripping via the type system, by creating a new type called something like SafeUrl or StrippedUrl, which would wrap the existing Url type, and requiring the SafeUrl to be used when sending URLs to Sentry. This SafeUrl would ensure via the constructor that any URLs it is wrapping are stripped. This avoids the possibility of a future SDK dev forgetting to strip the URL

Comment on lines +24 to +27
let _ = url.set_username(PII_REPLACEMENT);
}
if url.password().is_some() {
let _ = url.set_password(Some(PII_REPLACEMENT));
Copy link
Member

Choose a reason for hiding this comment

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

Please add this information as a code comment, as it could be helpful for future developers

@lcian lcian merged commit 03ae06a into master Jul 28, 2025
19 checks passed
@lcian lcian deleted the lcian/feat/filter-urls branch July 28, 2025 16:02
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.

Prevent PII leak for http requests
2 participants