-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Mask tokens when exporting onyx state #47996
Mask tokens when exporting onyx state #47996
Conversation
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Asked @TMisiukiewicz to add a unit test so we have another layer of protection in case anyone would remove this |
@mountiny @hoangzinh done ✅ |
src/libs/ExportOnyxState/common.ts
Outdated
if (key !== 'authToken' && key !== 'encryptedAuthToken') { | ||
return; | ||
} | ||
session[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.
what about extracting this pattern to a global constant?
src/libs/ExportOnyxState/common.ts
Outdated
onyxState = maskSessionDetails(data); | ||
// Mask fragile data other than session details if the user has enabled the option | ||
if (isMaskingFragileDataEnabled) { | ||
onyxState = maskFragileData(data); |
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.
The function maskSessionDetails
is also modifying the data
input (we should avoid it). That's why it's weird here, I'm expecting that we should pass onyxState
as input here.
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-31.at.11.04.52.android.mp4iOS: NativeScreen.Recording.2024-08-31.at.14.16.10.ios.mov |
src/libs/ExportOnyxState/common.ts
Outdated
}; | ||
|
||
export default maskOnyxState; |
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.
export default maskOnyxState; | |
export default { | |
maskOnyxState; | |
} |
I think we should export objects here. So we can export other common utils later. What do you think?
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.
good idea, done 👍
@TMisiukiewicz don't forget to add screenshots/recordings according to PR checklist. |
@TMisiukiewicz I'm unable to export Onyx in native apps. It doesn't export any files. Can you check if you can? Thank you |
@hoangzinh seems like a difference between exported file on native platforms and web, the Onyx State file is built in a different shape than on the web/desktop. Do you want to align it while working on this PR or should we address it in a separate PR? From my perspective it's safe to fix this here, as currently on |
I think It's intentional. If it happens in main branch as well, I think we should leave it as it is. Btw, I watched your recording for ios/android. I found that it was exported to a text format. But in my case, it's "shm" & "wall" files |
Hmm I couldn't find any reasoning about it, I think it's was an oversight. Look at the keys from exported Onyx state on mobile: Each key is a number, makes it superhard to extract any Onyx key in an efficient way. On web Onyx keys are assigned correctly: Having in mind we will work on implementing the "import state" feature #47786, I think we should align the export across all platforms to make it work properly regardless of the platform the state was exported from.
I think those files are automatically generated when you make a dump of the database, however my videos are recorded with a fix mentioned above. In your case it creates a dump, but it cannot find the |
Great. cc @mountiny what do you think about @TMisiukiewicz suggestion above? (Ref #47996 (comment)) |
@TMisiukiewicz lets unify it here, no rush on getting the current change out without unified format |
@hoangzinh I unified the exported state and it should work properly on mobiles now, could you please check one more time? |
@TMisiukiewicz |
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
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.
Just small NABs that we can skip for now but lets try to leave space above the comments for better readability.
Thanks!
maskFragileData, | ||
const maskOnyxState = (data: Record<string, unknown>, isMaskingFragileDataEnabled?: boolean) => { | ||
let onyxState = data; | ||
// Mask session details by default |
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.
// Mask session details by default | |
// Mask session details by default |
let onyxState = data; | ||
// Mask session details by default | ||
onyxState = maskSessionDetails(onyxState); | ||
// Mask fragile data other than session details if the user has enabled the option |
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.
// Mask fragile data other than session details if the user has enabled the option | |
// Mask fragile data other than session details if the user has enabled the option |
✋ 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/mountiny in version: 9.0.28-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.28-3 🚀
|
Details
For security reasons,
authToken
andencryptedAuthToken
should be always masked, regardless of whether the "Mask fragile user data" option is enabled.This is a follow up to a discussion here: https://expensify.slack.com/archives/C05LX9D6E07/p1724247139893599
Fixed Issues
$ #47995
PROPOSAL:
Tests
authToken
andencryptedAuthToken
***
valueOffline tests
QA Steps
authToken
andencryptedAuthToken
***
valuePR 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: mWeb Chrome
android-web.mov
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov