Skip to content
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

fix(pii): Don't redact already redacted text [INGEST-109] #1177

Closed
wants to merge 3 commits into from

Conversation

iker-barriocanal
Copy link
Contributor

@iker-barriocanal iker-barriocanal commented Feb 8, 2022

If one relay redacts the whole text chunk and forwards it to the next relay
they don't have to re-redact the text again, so we can early exit when there's
no text to redact. This is causing an assertion to fail cases where the whole
text has already been redacted.

Without this patch, the method correctly returns the chunks, but there's
unnecessary work done, and the last assertion (replacement_chunks.is_empty())
fails. This patch makes that method exit as early as possible removing that
unnecessary work, including not even reaching the failing assertion.

Fixes #1095.

If one relay redacts the whole text chunk and forwards it to the next relay
they don't have to re-redact the text again, so we can early exit when there's
no text to redact. This is causing an assertion to failin cases where the whole
text has already been redacted.

Without this patch, the method correctly returns the chunks, but there's
unnecessary work done and the last assertion (`replacement_chunks.is_empty()`)
fails. This patch makes that method to exit as early as possible removing that
unnecessary work, including not even reaching the failing assertion.
@iker-barriocanal iker-barriocanal self-assigned this Feb 8, 2022
@iker-barriocanal iker-barriocanal requested a review from a team February 8, 2022 11:18
@@ -945,3 +954,27 @@ fn test_ip_address_hashing_does_not_overwrite_id() {

assert_eq!(user.id.value().unwrap().as_str(), "123");
}

#[test]
fn test_replace_replaced_text() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It might be nice to have an additional test with an actual payload example (something like this):

fn test_authorization_scrubbing() {
let mut data = Event::from_value(
serde_json::json!({
"extra": {
"authorization": "foobar",
"auth": "foobar",
"auXth": "foobar",
}
})
.into(),
);
to prove that the issue is now fixed.

@iker-barriocanal iker-barriocanal marked this pull request as draft February 9, 2022 08:21
@iker-barriocanal
Copy link
Contributor Author

Closing in favor of #1180.

@iker-barriocanal iker-barriocanal deleted the iker/fix/pii-proc-repl branch February 14, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error processing envelope: could not schedule project fetch caused by: Mailbox has closed
2 participants