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

feat: Strip username from uploaded logs #412

Merged

Conversation

oblivioncth
Copy link
Contributor

Closes #405.

@oblivioncth oblivioncth marked this pull request as draft October 31, 2023 09:46
@oblivioncth
Copy link
Contributor Author

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.

@n0samu
Copy link
Member

n0samu commented Nov 1, 2023

perhaps only replacing the username if it falls between forward/backslashes to avoid false positives

That sounds like a good idea to me!

// 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'), '***');
Copy link
Member

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');

Copy link
Contributor Author

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.

Copy link
Member

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***.

Copy link
Contributor Author

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.

@oblivioncth oblivioncth force-pushed the feature/anonymous_logs branch from cdeddfe to 98ab96b Compare November 1, 2023 14:18
@oblivioncth
Copy link
Contributor Author

oblivioncth commented Nov 1, 2023

Example

@oblivioncth oblivioncth marked this pull request as ready for review November 1, 2023 14:19
@oblivioncth oblivioncth force-pushed the feature/anonymous_logs branch from 98ab96b to 8744c79 Compare November 2, 2023 06:31
@colin969 colin969 changed the base branch from develop to release/12.2.0 November 16, 2023 09:46
@colin969 colin969 merged commit e2f0346 into FlashpointProject:release/12.2.0 Nov 16, 2023
1 check passed
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.

3 participants