-
Notifications
You must be signed in to change notification settings - Fork 104
feat(pii): Implement smart PII scrubbing for logentry.formatted
#4985
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
Changes from all commits
339c49b
2dd79fc
bb86615
1523d12
8c06ae9
fd886be
1f0656e
e8bbe64
ae6f30b
6c129a3
106cf34
85b1026
219e225
20cfec5
2971d98
4822fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,23 @@ pub fn to_pii_config( | |
| SENSITIVE_COOKIES.clone(), | ||
| vec!["@anything:filter".to_owned()], | ||
| ); | ||
|
|
||
| let logentry_selector: SelectorSpec = SelectorSpec::Path(vec![ | ||
| SelectorPathItem::Type(ValueType::LogEntry), | ||
| SelectorPathItem::Key("formatted".to_owned()), | ||
| ]); | ||
|
|
||
| // Apply smart scrubbing rules only to logentry.formatted | ||
| applications.insert( | ||
| logentry_selector, | ||
| vec![ | ||
| "@email:replace".to_owned(), | ||
| "@creditcard:replace".to_owned(), | ||
| "@iban:replace".to_owned(), | ||
| "@usssn:replace".to_owned(), | ||
| "@bearer:replace".to_owned(), | ||
| ], | ||
| ); | ||
| } | ||
|
|
||
| if datascrubbing_config.scrub_ip_addresses { | ||
|
|
@@ -282,7 +299,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
|
|
||
| #[test] | ||
| fn test_convert_default_pii_config() { | ||
| insta::assert_json_snapshot!(simple_enabled_pii_config(), @r###" | ||
| insta::assert_json_snapshot!(simple_enabled_pii_config(), @r#" | ||
| { | ||
| "applications": { | ||
| "($string || $number || $array || $object) && !(debug_meta.** || $frame.filename || $frame.abs_path || $logentry.formatted || $error.value || $http.headers.user-agent)": [ | ||
|
|
@@ -294,10 +311,17 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ], | ||
| "*.cookies.sentrysid || *.cookies.sudo || *.cookies.su || *.cookies.session || *.cookies.__session || *.cookies.sessionid || *.cookies.user_session || *.cookies.symfony || *.cookies.phpsessid || *.cookies.fasthttpsessionid || *.cookies.mysession || *.cookies.irissessionid || *.cookies.csrf || *.cookies.xsrf || *.cookies._xsrf || *.cookies._csrf || *.cookies.csrf-token || *.cookies.csrf_token || *.cookies.xsrf-token || *.cookies.xsrf_token || *.cookies.fastcsrf || *.cookies._iris_csrf": [ | ||
| "@anything:filter" | ||
| ], | ||
| "$logentry.formatted": [ | ||
| "@email:replace", | ||
| "@creditcard:replace", | ||
| "@iban:replace", | ||
| "@usssn:replace", | ||
| "@bearer:replace" | ||
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -307,7 +331,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ..simple_enabled_config() | ||
| }); | ||
|
|
||
| insta::assert_json_snapshot!(pii_config, @r###" | ||
| insta::assert_json_snapshot!(pii_config, @r#" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always thought it's another way around, but I will run it and see how changes: 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, it seems like I do not have this option
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, found 😄
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it seems like i was right and running latest version of insta with changes all the tests to single @Dav1dde should be do it in separate PR to match the latest insta and , make that change separate from this PR ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's strange, when I ran it, it did the opposite: https://github.com/getsentry/relay/pull/4908/files
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I am on an older version and they changed behavior in 1.41 -_- yeah let's keep the insta stuff separate 👍 |
||
| { | ||
| "applications": { | ||
| "($string || $number || $array || $object) && !(debug_meta.** || $frame.filename || $frame.abs_path || $logentry.formatted || $error.value || $http.headers.user-agent)": [ | ||
|
|
@@ -319,10 +343,17 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ], | ||
| "*.cookies.sentrysid || *.cookies.sudo || *.cookies.su || *.cookies.session || *.cookies.__session || *.cookies.sessionid || *.cookies.user_session || *.cookies.symfony || *.cookies.phpsessid || *.cookies.fasthttpsessionid || *.cookies.mysession || *.cookies.irissessionid || *.cookies.csrf || *.cookies.xsrf || *.cookies._xsrf || *.cookies._csrf || *.cookies.csrf-token || *.cookies.csrf_token || *.cookies.xsrf-token || *.cookies.xsrf_token || *.cookies.fastcsrf || *.cookies._iris_csrf": [ | ||
| "@anything:filter" | ||
| ], | ||
| "$logentry.formatted": [ | ||
| "@email:replace", | ||
| "@creditcard:replace", | ||
| "@iban:replace", | ||
| "@usssn:replace", | ||
| "@bearer:replace" | ||
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -332,7 +363,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ..simple_enabled_config() | ||
| }); | ||
|
|
||
| insta::assert_json_snapshot!(pii_config, @r###" | ||
| insta::assert_json_snapshot!(pii_config, @r#" | ||
| { | ||
| "rules": { | ||
| "strip-fields": { | ||
|
|
@@ -355,10 +386,17 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ], | ||
| "*.cookies.sentrysid || *.cookies.sudo || *.cookies.su || *.cookies.session || *.cookies.__session || *.cookies.sessionid || *.cookies.user_session || *.cookies.symfony || *.cookies.phpsessid || *.cookies.fasthttpsessionid || *.cookies.mysession || *.cookies.irissessionid || *.cookies.csrf || *.cookies.xsrf || *.cookies._xsrf || *.cookies._csrf || *.cookies.csrf-token || *.cookies.csrf_token || *.cookies.xsrf-token || *.cookies.xsrf_token || *.cookies.fastcsrf || *.cookies._iris_csrf": [ | ||
| "@anything:filter" | ||
| ], | ||
| "$logentry.formatted": [ | ||
| "@email:replace", | ||
| "@creditcard:replace", | ||
| "@iban:replace", | ||
| "@usssn:replace", | ||
| "@bearer:replace" | ||
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -368,7 +406,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ..simple_enabled_config() | ||
| }); | ||
|
|
||
| insta::assert_json_snapshot!(pii_config, @r###" | ||
| insta::assert_json_snapshot!(pii_config, @r#" | ||
| { | ||
| "applications": { | ||
| "($string || $number || $array || $object) && !(debug_meta.** || $frame.filename || $frame.abs_path || $logentry.formatted || $error.value || $http.headers.user-agent) && !foobar": [ | ||
|
|
@@ -380,10 +418,17 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ], | ||
| "*.cookies.sentrysid || *.cookies.sudo || *.cookies.su || *.cookies.session || *.cookies.__session || *.cookies.sessionid || *.cookies.user_session || *.cookies.symfony || *.cookies.phpsessid || *.cookies.fasthttpsessionid || *.cookies.mysession || *.cookies.irissessionid || *.cookies.csrf || *.cookies.xsrf || *.cookies._xsrf || *.cookies._csrf || *.cookies.csrf-token || *.cookies.csrf_token || *.cookies.xsrf-token || *.cookies.xsrf_token || *.cookies.fastcsrf || *.cookies._iris_csrf": [ | ||
| "@anything:filter" | ||
| ], | ||
| "$logentry.formatted": [ | ||
| "@email:replace", | ||
| "@creditcard:replace", | ||
| "@iban:replace", | ||
| "@usssn:replace", | ||
| "@bearer:replace" | ||
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -395,7 +440,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ..Default::default() | ||
| }); | ||
|
|
||
| insta::assert_json_snapshot!(pii_config, @r###" | ||
| insta::assert_json_snapshot!(pii_config, @r#" | ||
| { | ||
| "applications": { | ||
| "($string || $number || $array || $object) && !(debug_meta.** || $frame.filename || $frame.abs_path || $logentry.formatted || $error.value || $http.headers.user-agent)": [ | ||
|
|
@@ -406,7 +451,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -1271,7 +1316,7 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ..simple_enabled_config() | ||
| }); | ||
|
|
||
| insta::assert_json_snapshot!(pii_config, @r###" | ||
| insta::assert_json_snapshot!(pii_config, @r#" | ||
| { | ||
| "rules": { | ||
| "strip-fields": { | ||
|
|
@@ -1294,10 +1339,17 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
| ], | ||
| "*.cookies.sentrysid || *.cookies.sudo || *.cookies.su || *.cookies.session || *.cookies.__session || *.cookies.sessionid || *.cookies.user_session || *.cookies.symfony || *.cookies.phpsessid || *.cookies.fasthttpsessionid || *.cookies.mysession || *.cookies.irissessionid || *.cookies.csrf || *.cookies.xsrf || *.cookies._xsrf || *.cookies._csrf || *.cookies.csrf-token || *.cookies.csrf_token || *.cookies.xsrf-token || *.cookies.xsrf_token || *.cookies.fastcsrf || *.cookies._iris_csrf": [ | ||
| "@anything:filter" | ||
| ], | ||
| "$logentry.formatted": [ | ||
| "@email:replace", | ||
| "@creditcard:replace", | ||
| "@iban:replace", | ||
| "@usssn:replace", | ||
| "@bearer:replace" | ||
| ] | ||
| } | ||
| } | ||
| "###); | ||
| "#); | ||
|
|
||
| let pii_config = pii_config.unwrap(); | ||
| let mut pii_processor = PiiProcessor::new(pii_config.compiled()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.