-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pii): Removes legacy special behaviour from safe fields parsing
- Loading branch information
Showing
3 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,7 @@ pub fn to_pii_config( | |
continue; | ||
} | ||
|
||
let spec = match field.parse() { | ||
let spec = match SelectorSpec::parse_non_legacy(field) { | ||
Ok(spec) => spec, | ||
Err(_) => { | ||
// Ideally safe fields should be caught by sentry-side validation, | ||
|
@@ -1559,4 +1559,64 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv | |
} | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_safe_field_legacy_disables_all_string_parsing() { | ||
let mut data = Event::from_value( | ||
serde_json::json!({ | ||
"request": { | ||
"data": { | ||
"email": "[email protected]", | ||
"password": "kkee", | ||
"recaptcha": null, | ||
} | ||
}, | ||
}) | ||
.into(), | ||
); | ||
|
||
let pii_config = to_pii_config(&DataScrubbingConfig { | ||
// this triggered legacy behaviour and disabled scrubbing for all fields | ||
exclude_fields: vec!["email".to_owned()], | ||
scrub_data: true, | ||
scrub_ip_addresses: true, | ||
sensitive_fields: vec!["email".to_owned(), "password".to_owned()], | ||
scrub_defaults: true, | ||
..Default::default() | ||
}) | ||
.unwrap(); | ||
|
||
let mut pii_processor = PiiProcessor::new(pii_config.compiled()); | ||
process_value(&mut data, &mut pii_processor, ProcessingState::root()).unwrap(); | ||
assert_annotated_snapshot!(data, @r###" | ||
{ | ||
"request": { | ||
"data": { | ||
"email": "[email protected]", | ||
"password": "[Filtered]", | ||
"recaptcha": null | ||
} | ||
}, | ||
"_meta": { | ||
"request": { | ||
"data": { | ||
"password": { | ||
"": { | ||
"rem": [ | ||
[ | ||
"@password:filter", | ||
"s", | ||
0, | ||
10 | ||
] | ||
], | ||
"len": 4 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
"###); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters