-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: Strip username from uploaded logs #412
feat: Strip username from uploaded logs #412
Conversation
Debating on if this should be more sophisticated, perhaps only replacing the username if it falls between forward/backslashes to avoid false positives in case a username is similar to a common word. |
That sounds like a good idea to me! |
src/back/responses.ts
Outdated
// Filter entries | ||
const username = os.userInfo().username; | ||
const entries = state.log.filter(e => e !== undefined).map(e => { | ||
e.content = e.content.replace(new RegExp(username, 'g'), '***'); |
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.
Try this:
const slashMatch = '([\/\\\\])'
e.content = e.content.replace(new RegExp(slashMatch + username + slashMatch, 'g'), '$1***$2');
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.
LGTM. Made the second slash optional for the rare case that the path ends with the user folder. Technically allows for a few fringe false positives, but I think that's alright.
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.
If the second slash is optional, then I'm pretty sure there's no reason to include it in the regex, and you could get an equivalent result by just matching sepMatch + username
and replacing with $1***
.
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.
Of course... because there's no more to the pattern after that. Woops XD.
Revised.
cdeddfe
to
98ab96b
Compare
98ab96b
to
8744c79
Compare
Closes #405.