Skip to content

feat: Sanitize http info from breadcrumbs, spans and events #3094

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 15 commits into from
Jun 15, 2023

Conversation

brustolin
Copy link
Contributor

📜 Description

Sanitizing http request info from breadcrumbs, spans and events.

  • User and password are filtered out
  • Query and fragment will be send in the data bag to be clean in the server
  • Some security related headers are removed

💡 Motivation and Context

close #2943

💚 How did you test it?

Unit test

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@brustolin brustolin changed the title fix: Sanitize http info from breadcrumbs, spans and events feat: Sanitize http info from breadcrumbs, spans and events Jun 13, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 13, 2023

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

Generated by 🚫 dangerJS against 4f9c618

getsentry-bot and others added 3 commits June 13, 2023 09:34

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@github-actions
Copy link
Contributor

github-actions bot commented Jun 13, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1227.24 ms 1244.46 ms 17.22 ms
Size 20.76 KiB 399.17 KiB 378.41 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
dc0db9e 1222.10 ms 1240.90 ms 18.80 ms
dacf894 1232.32 ms 1236.34 ms 4.02 ms
98752f3 1240.61 ms 1259.80 ms 19.18 ms
e1eed6b 1259.08 ms 1270.57 ms 11.49 ms
6943de0 1235.98 ms 1246.88 ms 10.90 ms
60dd0f5 1247.35 ms 1267.59 ms 20.24 ms
904d7fa 1225.73 ms 1249.22 ms 23.49 ms
3a01b17 1212.12 ms 1221.80 ms 9.68 ms
3a31fc9 1237.35 ms 1249.02 ms 11.67 ms
ecd9ecd 1241.28 ms 1260.35 ms 19.07 ms

App size

Revision Plain With Sentry Diff
dc0db9e 20.76 KiB 419.62 KiB 398.86 KiB
dacf894 20.76 KiB 426.34 KiB 405.58 KiB
98752f3 20.76 KiB 435.09 KiB 414.33 KiB
e1eed6b 20.76 KiB 432.17 KiB 411.41 KiB
6943de0 20.76 KiB 393.33 KiB 372.57 KiB
60dd0f5 20.76 KiB 393.37 KiB 372.60 KiB
904d7fa 20.76 KiB 432.87 KiB 412.11 KiB
3a01b17 20.76 KiB 436.33 KiB 415.57 KiB
3a31fc9 20.76 KiB 414.45 KiB 393.69 KiB
ecd9ecd 20.76 KiB 420.23 KiB 399.47 KiB

Previous results on branch: fix/Sanitize-URLs

Startup times

Revision Plain With Sentry Diff
4a85594 1217.27 ms 1230.36 ms 13.09 ms
bb40ad1 1243.30 ms 1261.18 ms 17.88 ms
a88a206 1190.36 ms 1234.18 ms 43.83 ms
0bc305e 1229.04 ms 1248.98 ms 19.94 ms
9407ca7 1245.31 ms 1258.58 ms 13.28 ms

App size

Revision Plain With Sentry Diff
4a85594 20.76 KiB 396.33 KiB 375.57 KiB
bb40ad1 20.76 KiB 399.13 KiB 378.37 KiB
a88a206 20.76 KiB 396.33 KiB 375.57 KiB
0bc305e 20.76 KiB 396.33 KiB 375.57 KiB
9407ca7 20.76 KiB 396.35 KiB 375.59 KiB

@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #3094 (99156fe) into main (60dd0f5) will decrease coverage by 0.037%.
The diff coverage is 95.364%.

❗ Current head 99156fe differs from pull request most recent head 4f9c618. Consider uploading reports for the commit 4f9c618 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #3094       +/-   ##
=============================================
- Coverage   88.958%   88.922%   -0.037%     
=============================================
  Files          495       498        +3     
  Lines        53464     53579      +115     
  Branches     19139     19183       +44     
=============================================
+ Hits         47561     47644       +83     
- Misses        4944      4973       +29     
- Partials       959       962        +3     
Impacted Files Coverage Δ
Sources/Swift/Tools/UrlSanitized.swift 91.666% <91.666%> (ø)
...erformance/Network/SentryNetworkTrackerTests.swift 97.785% <92.682%> (-0.621%) ⬇️
Sources/Sentry/SentryNetworkTracker.m 91.054% <100.000%> (+0.356%) ⬆️
Sources/Sentry/SentryRequest.m 100.000% <100.000%> (ø)
Sources/Swift/Tools/HTTPHeaderSanitizer.swift 100.000% <100.000%> (ø)
Tests/SentryTests/UrlSanitizedTests.swift 100.000% <100.000%> (ø)

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60dd0f5...4f9c618. Read the comment docs.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@brustolin
Copy link
Contributor Author

brustolin commented Jun 13, 2023

We can close #2393 after merging this PR

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks for doing this, @brustolin 💪 . A few comments

brustolin and others added 7 commits June 13, 2023 15:44

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -5,20 +5,34 @@ import XCTest
class SentryNetworkTrackerTests: XCTestCase {

private static let dsnAsString = TestConstants.dsnAsString(username: "SentrySessionTrackerTests")
private static let testURL = URL(string: "https://www.domain.com/api")!
private static let testUrl = "https://www.domain.com/api"
private static let fullUrl = URL(string: "https://www.domain.com/api?query=value&query2=value2#fragment")!
Copy link
Member

Choose a reason for hiding this comment

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

💯

import Foundation

@objcMembers
public class HTTPHeaderSanitizer: NSObject {
Copy link
Member

Choose a reason for hiding this comment

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

More Swift 🥇, fuiyoh 👑 !

import SentryPrivate
import XCTest

class UrlSanitizedTests: XCTestCase {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for these tests 👍

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.

Sanitize sensitive data from URLs
3 participants