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): Replace only user in the userpath #2724

Merged
merged 3 commits into from
Nov 16, 2023
Merged

Conversation

olksdr
Copy link
Contributor

@olksdr olksdr commented Nov 15, 2023

Explicitly use only allowed characters for the username.

Currently we replace everything till between the slashes, and if the slash after username is missing we will replace everything till the end of the input string.

fix: #2722

#skip-changelog

@@ -231,7 +231,7 @@ static PATH_REGEX: Lazy<Regex> = Lazy::new(|| {
)
)
(
[^/\\]+
[A–Za-z0–9'\._!\#^~-]+
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would stop at first space? and I believe spaces are allowed in windows usernames. Should it also be in the list of allowed characters?

I checked on regex101 for this

Copy link
Member

@Dav1dde Dav1dde Nov 15, 2023

Choose a reason for hiding this comment

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

Maybe should match anything until \ or newline.

Edit: did this ever work on Windows with backwards slashes for path separators?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TBS1996 Overall it's not advisable to have spaces in the usernames and I'm not sure we want to support it either.
@Dav1dde Also if we remove everything , or just will new line we again end up with a somewhat wrong scrubbing.

See for example changes in relay-server/tests/snapshots/test_fixtures__dotnet__pii_stripping.snap below - it was scrubbed kind of a little bit too much. I do not mind that either, but we have to agree on the final rule 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

included also space in the regex now

@olksdr olksdr requested a review from a team November 15, 2023 13:41
@olksdr olksdr merged commit 01640e3 into master Nov 16, 2023
@olksdr olksdr deleted the fix/userpath-regex branch November 16, 2023 13:20
jjbayer added a commit that referenced this pull request Dec 6, 2024
#2724 silently broke user path
scrubbing in minidumps. The regression was not automatically flagged
because minidump scrubbing [ignores regexes that cannot be compiled with
unicode
disabled](https://github.com/getsentry/relay/blob/63ca425f5eba144cd5b8976b4201cd61084dafb9/relay-pii/src/attachments.rs#L37-L41),
regardless of whether they are user-defined regexes or builtin static
ones.

This PR both fixes the regex and adds an automatic test to each PII
regex, so we can catch similar problems in the future.
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.

Large/Wrong truncation of userpath on PII on some path patterns
4 participants