-
Notifications
You must be signed in to change notification settings - Fork 104
ref(logs): Change logic for scrubbing attributes #5095
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
Conversation
| #[allow(clippy::needless_option_as_deref)] | ||
| for rule in rules { | ||
| let reborrowed_value = value.as_deref_mut(); | ||
| apply_rule_to_value(meta, rule, state.path().key(), reborrowed_value)?; | ||
| apply_rule_to_value(meta, rule, state.path().key(), value.as_deref_mut())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incidental change.
| }, | ||
| }, | ||
| "applications": { | ||
| "$log.attributes.remove_this_string_abc123.value": ["remove_abc123"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this selector working on master is a bug. As I understand it a path starting with $log should not match the top-level object. The test_scrub_log_deep_wild_cards test below fails for a similar reason and is not so easily fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it a path starting with $log should not match the top-level object
Why not? Don't we also have $minidump as a selector on the top level object?
| }, | ||
| }, | ||
| "applications": { | ||
| "$log.attributes.remove_this_string_abc123.value": ["remove_abc123"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it a path starting with $log should not match the top-level object
Why not? Don't we also have $minidump as a selector on the top level object?
| match self.attribute_mode { | ||
| AttributeMode::Object => { | ||
| // Treat the attribute as an object and recurse into its children. | ||
| value.process_child_values(self, state) | ||
| } | ||
| AttributeMode::ValueOnly => { | ||
| // Identify the attribute with its value and apply rules there directly. | ||
| let value_state = | ||
| state.enter_nothing(Some(Cow::Owned(FieldAttrs::new().pii(Pii::True)))); | ||
| processor::process_value(&mut value.value.value, self, &value_state) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
This is an alternative to #5061.
Instead of hooking into scrubbing
Attributes(via a newprocess_attributesmethod), we do it at the level of individualAttributevalues (via a newprocess_attributemethod). For common scrubbing rules, we just apply them to the attribute's value. For advanced scrubbing rules, we treat attributes as objects and delegate to their fields.The differentiation between the two ways to treat attributes is controlled by a field
attribute_modeof typeAttributeModeonPiiProcessor. This decouples the logic from logs and makes it explicit what is happening.TODO: Handle
otherinValueOnlymode.ref: #5096 ref: RELAY-152