Skip to content

Commit

Permalink
feat(pii): Scrub arrays of 2 elements as key-value pairs (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo authored Jun 10, 2024
1 parent 91d869d commit 962c91f
Show file tree
Hide file tree
Showing 7 changed files with 559 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Internal**:

- Treat arrays of pairs as key-value mappings during PII scrubbing. ([#3639](https://github.com/getsentry/relay/pull/3639))

## 24.5.1

**Bug fixes**:
Expand Down
88 changes: 88 additions & 0 deletions relay-pii/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,4 +1656,92 @@ THd+9FBxiHLGXNKhG/FRSyREXEt+NyYIf/0cyByc9tNksat794ddUqnLOg0vwSkv
process_value(&mut data, &mut pii_processor, ProcessingState::root()).unwrap();
assert_annotated_snapshot!(data);
}

#[test]
fn test_pairlist_scrubbed_with_matching_keys() {
let mut data = Event::from_value(
serde_json::json!({
"threads": {
"values": [
{
"stacktrace": {
"frames": [
{
"vars": {
"request": {
"headers": [
[
"secret",
// Should be filtered because of key `secret`.
"A1BBC234QWERTY0987MNBV012765HJKL"
],
[
"passwd",
// Should be filtered because of key `passwd`.
"my_password"
]
]
}
}
}

]
}
}
]
}
})
.into(),
);

let pii_config = simple_enabled_pii_config();
let mut pii_processor = PiiProcessor::new(pii_config.compiled());
process_value(&mut data, &mut pii_processor, ProcessingState::root()).unwrap();
assert_annotated_snapshot!(data);
}

#[test]
fn test_pairlist_scrubbed_with_matching_values() {
let mut data = Event::from_value(
serde_json::json!({
"threads": {
"values": [
{
"stacktrace": {
"frames": [
{
"vars": {
"request": {
"headers": [
[
"some_random_value",
// Should be filtered because it's treated
// as individual value.
"my_password"
],
[
"some_random_value_2",
// Should not be filtered because the value
// is scraped by default.
"abc"
]
]
}
}
}

]
}
}
]
}
})
.into(),
);

let pii_config = simple_enabled_pii_config();
let mut pii_processor = PiiProcessor::new(pii_config.compiled());
process_value(&mut data, &mut pii_processor, ProcessingState::root()).unwrap();
assert_annotated_snapshot!(data);
}
}
Loading

0 comments on commit 962c91f

Please sign in to comment.