-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor: mask emails with random strings instead of *** #53527
refactor: mask emails with random strings instead of *** #53527
Conversation
Reviewer Checklist
Screenshots/VideosiOS: Native0-ios.mp4MacOS: Chrome / Safari0-web.mp4MacOS: Desktop0-desktop.mp4 |
src/libs/ExportOnyxState/common.ts
Outdated
let maskedEmail = ''; | ||
if (!emailMap.has(item)) { | ||
maskedEmail = randomizeEmail(item); | ||
emailMap.set(item, maskedEmail); | ||
} else { | ||
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | ||
maskedEmail = emailMap.get(item) as string; | ||
} | ||
return maskedEmail; |
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 think we can wrap these lines in a new method getMarkedEmail
and reuse it, like
const getMarkedEmail = (email: string): string => {
let maskedEmail = '';
if (!emailMap.has(email)) {
maskedEmail = randomizeEmail(email);
emailMap.set(email, maskedEmail);
} else {
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
maskedEmail = emailMap.get(email) as string;
}
return maskedEmail;
};
src/libs/ExportOnyxState/common.ts
Outdated
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | ||
propertyName = emailMap.get(key) as string; | ||
} else { | ||
const maskedEmail = randomizeEmail(key); |
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.
We should save it to emailMap
right?
@@ -3,6 +3,35 @@ import ONYXKEYS from '@src/ONYXKEYS'; | |||
import type {Session} from '@src/types/onyx'; | |||
|
|||
const MASKING_PATTERN = '***'; | |||
const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/; | |||
|
|||
const emailMap = new Map<string, string>(); |
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.
Do we need to do cleanup before the return of method maskOnyxState
?
@eh2077 thanks, addressed all your comments 👍 |
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.
Thanks for the update! Just a few more comments to get the code neater.
src/libs/ExportOnyxState/common.ts
Outdated
if (emailMap.has(key)) { | ||
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | ||
propertyName = emailMap.get(key) as string; | ||
} else { | ||
const maskedEmail = maskEmail(key); | ||
propertyName = maskedEmail; | ||
} |
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 (emailMap.has(key)) { | |
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | |
propertyName = emailMap.get(key) as string; | |
} else { | |
const maskedEmail = maskEmail(key); | |
propertyName = maskedEmail; | |
} | |
propertyName = maskEmail(key); |
src/libs/ExportOnyxState/common.ts
Outdated
const maskedEmail = maskEmail(value); | ||
maskedData[propertyName] = maskedEmail; |
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.
const maskedEmail = maskEmail(value); | |
maskedData[propertyName] = maskedEmail; | |
maskedData[propertyName] = maskEmail(value); |
src/libs/ExportOnyxState/common.ts
Outdated
let maskedEmailString = value; | ||
const email = extractEmail(value) ?? ''; | ||
|
||
if (!emailMap.has(email)) { | ||
const randomEmail = randomizeEmail(email); | ||
emailMap.set(email, randomEmail); | ||
maskedEmailString = replaceEmailInString(value, randomEmail); | ||
} else { | ||
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | ||
maskedEmailString = replaceEmailInString(value, emailMap.get(email) as string); | ||
} | ||
maskedData[propertyName] = maskedEmailString; |
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.
let maskedEmailString = value; | |
const email = extractEmail(value) ?? ''; | |
if (!emailMap.has(email)) { | |
const randomEmail = randomizeEmail(email); | |
emailMap.set(email, randomEmail); | |
maskedEmailString = replaceEmailInString(value, randomEmail); | |
} else { | |
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style | |
maskedEmailString = replaceEmailInString(value, emailMap.get(email) as string); | |
} | |
maskedData[propertyName] = maskedEmailString; | |
maskedData[propertyName] = replaceEmailInString(value, maskEmail(extractEmail(value) ?? '')); |
thanks for catching it, updated 👍 |
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
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Gonals in version: 9.0.74-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.0.74-8 🚀
|
Explanation of Change
When exporting Onyx state with masking option enabled, every email address and message is replaced with
***
. While this ensures data anonymity, it also makes it difficult to analyze and reproduce bugs related to participants-related features and possibly impacts reliability when measuring performance. This PR generates random email address instead of***
.Fixed Issues
$ #53060
PROPOSAL:
Tests
Offline tests
n/a
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov