From ab88708acfc839ce51ec74ee67c3c7809c27bddb Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:04:33 +0100 Subject: [PATCH 1/2] fix(pii): Enable PII scrubbing in logentry.params --- relay-event-schema/src/protocol/logentry.rs | 2 +- relay-pii/src/processor.rs | 53 ++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/relay-event-schema/src/protocol/logentry.rs b/relay-event-schema/src/protocol/logentry.rs index 6b22f55c506..4b71d883e8e 100644 --- a/relay-event-schema/src/protocol/logentry.rs +++ b/relay-event-schema/src/protocol/logentry.rs @@ -50,7 +50,7 @@ pub struct LogEntry { /// Parameters to be interpolated into the log message. This can be an array of positional /// parameters as well as a mapping of named arguments to their values. - #[metastructure(bag_size = "medium")] + #[metastructure(bag_size = "medium", pii = "true")] pub params: Annotated, /// Additional arbitrary fields for forwards compatibility. diff --git a/relay-pii/src/processor.rs b/relay-pii/src/processor.rs index a562df9c168..f7d6675da40 100644 --- a/relay-pii/src/processor.rs +++ b/relay-pii/src/processor.rs @@ -469,10 +469,12 @@ mod tests { use insta::assert_debug_snapshot; use relay_event_schema::processor::process_value; use relay_event_schema::protocol::{ - Addr, Breadcrumb, DebugImage, DebugMeta, Event, ExtraValue, Headers, LogEntry, + Addr, Breadcrumb, DebugImage, DebugMeta, Event, ExtraValue, Headers, LogEntry, Message, NativeDebugImage, Request, Span, TagEntry, Tags, TraceContext, }; - use relay_protocol::{assert_annotated_snapshot, Annotated, FromValue, Object, Value}; + use relay_protocol::{ + assert_annotated_snapshot, get_value, Annotated, FromValue, Object, Value, + }; use super::*; use crate::{DataScrubbingConfig, PiiConfig, ReplaceRedaction}; @@ -1525,4 +1527,51 @@ mod tests { assert_debug_snapshot!(&data); } + + #[test] + fn test_logentry_params_scrubbed() { + let config = serde_json::from_str::( + r##" + { + "applications": { + "$string": ["@anything:remove"] + } + } + "##, + ) + .unwrap(); + + let mut event = Annotated::new(Event { + logentry: Annotated::new(LogEntry { + message: Annotated::new(Message::from("failed to parse report id=%s".to_owned())), + formatted: Annotated::new("failed to parse report id=1".to_string().into()), + params: Annotated::new(Value::Array(vec![Annotated::new(Value::String( + "12345".to_owned(), + ))])), + ..Default::default() + }), + ..Default::default() + }); + + let mut processor = PiiProcessor::new(config.compiled()); + process_value(&mut event, &mut processor, ProcessingState::root()).unwrap(); + + let params = get_value!(event.logentry.params!); + assert_debug_snapshot!(params, @r#"Array( + [ + Meta { + remarks: [ + Remark { + ty: Removed, + rule_id: "@anything:remove", + range: None, + }, + ], + errors: [], + original_length: None, + original_value: None, + }, + ], +)"#); + } } From 33e488c75354a4effa56cf92a2f31bb7d89e692f Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:11:32 +0100 Subject: [PATCH 2/2] update changelogs --- CHANGELOG.md | 6 ++++++ py/CHANGELOG.md | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 300388e51e7..e2f4244c97a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +**Bug Fixes**: + +- Add automatic PII scrubbing to `logentry.params`. ([#2956](https://github.com/getsentry/relay/pull/2956)) + ## 24.1.0 **Features**: diff --git a/py/CHANGELOG.md b/py/CHANGELOG.md index a636bf1df88..5bcc541a4cd 100644 --- a/py/CHANGELOG.md +++ b/py/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Add automatic PII scrubbing to `logentry.params`. ([#2956](https://github.com/getsentry/relay/pull/2956)) + ## 0.8.41 - This release requires Python 3.9 or later. There are no intentionally breaking changes included in this release, but we stopped testing against Python 3.8.