-
Notifications
You must be signed in to change notification settings - Fork 53
#6199 Improve user backup detection #6202
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
base: master
Are you sure you want to change the base?
Changes from all commits
7b276ce
85ce281
31e8216
ade6d9e
d7518b0
bf28a35
b4baa75
ab21f3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,17 @@ View.run( | |
| private readonly parentTabId: string; | ||
| private readonly frameId: string; | ||
| private readonly armoredPrvBackup: string; | ||
| private readonly fromEmail: string; | ||
| private storedPrvWithMatchingLongid: KeyInfoWithIdentity | undefined; | ||
|
|
||
| public constructor() { | ||
| super(); | ||
| const uncheckedUrlParams = Url.parse(['acctEmail', 'armoredPrvBackup', 'parentTabId', 'frameId']); | ||
| const uncheckedUrlParams = Url.parse(['acctEmail', 'armoredPrvBackup', 'parentTabId', 'frameId', 'fromEmail']); | ||
| this.acctEmail = Assert.urlParamRequire.string(uncheckedUrlParams, 'acctEmail'); | ||
| this.parentTabId = Assert.urlParamRequire.string(uncheckedUrlParams, 'parentTabId'); | ||
| this.frameId = Assert.urlParamRequire.string(uncheckedUrlParams, 'frameId'); | ||
| this.armoredPrvBackup = Assert.urlParamRequire.string(uncheckedUrlParams, 'armoredPrvBackup'); | ||
| this.fromEmail = Assert.urlParamRequire.string(uncheckedUrlParams, 'fromEmail'); | ||
| } | ||
|
|
||
| public render = async () => { | ||
|
|
@@ -53,12 +55,22 @@ View.run( | |
| `This private key with fingerprint <span class="green">${Xss.escape(Str.spaced(fingerprint))}</span> has already been imported.` | ||
| ); | ||
| } else { | ||
| const notUserOwnedPrvKey = this.fromEmail !== this.acctEmail; | ||
| const recommendation = notUserOwnedPrvKey ? '' : 'We recommend importing all backups to ensure you can read all incoming encrypted emails.'; | ||
| if (notUserOwnedPrvKey) { | ||
| if (notUserOwnedPrvKey) { | ||
|
Comment on lines
60
to
+61
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. duplicated |
||
| $('.backup_message_text') | ||
| .html( | ||
| `⚠️ This message contains a private key received from ${Xss.escape(this.fromEmail)}. Import only if you intentionally sent this to yourself or received it from your administrator.` | ||
| ) | ||
| .addClass('orange_label'); // xss-safe-value | ||
| } | ||
| } | ||
| $('.line .private_key_status') | ||
| .html( | ||
| `The private key <span class="green">${Xss.escape(Str.spaced(fingerprint))}</span> has not been imported yet. \n` + | ||
| `We recommend importing all backups to ensure you can read all incoming encrypted emails.` | ||
| ) | ||
| .after('<div class="line"><button class="button green" id="action_import_key">Import Missing Private Key</button></div>'); // xss-direct | ||
| .html(`The private key <span class="green">${Xss.escape(Str.spaced(fingerprint))}</span> has not been imported yet. \n` + recommendation) // xss-safe-value | ||
| .after( | ||
| `<div class="line"><button class="button green" id="action_import_key">${notUserOwnedPrvKey ? 'Import Private Key' : 'Import Missing Private Key'}</button></div>` | ||
| ); // xss-direct | ||
| } | ||
| this.sendResizeMsg(); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,15 +60,15 @@ export class XssSafeFactory { | |
| * | ||
| * When edited, REQUEST A SECOND SET OF EYES TO REVIEW CHANGES | ||
| */ | ||
| public static renderableMsgBlock = (factory: XssSafeFactory, block: MsgBlock, isOutgoing?: boolean) => { | ||
| public static renderableMsgBlock = (factory: XssSafeFactory, block: MsgBlock, isOutgoing?: boolean, senderEmail?: string) => { | ||
| if (block.type === 'plainText') { | ||
| return XssSafeFactory.renderPlainContent(block.content); | ||
| } else if (block.type === 'plainHtml') { | ||
| return Xss.htmlSanitizeAndStripAllTags(Str.with(block.content), '<br>') + '<br><br>'; | ||
| } else if (block.type === 'publicKey') { | ||
| return factory.embeddedPubkey(PgpArmor.normalize(Str.with(block.content), 'publicKey'), isOutgoing); | ||
| } else if (block.type === 'privateKey') { | ||
| return factory.embeddedBackup(PgpArmor.normalize(Str.with(block.content), 'privateKey')); | ||
| return factory.embeddedBackup(PgpArmor.normalize(Str.with(block.content), 'privateKey'), senderEmail); | ||
| } else if (block.type === 'certificate') { | ||
| return factory.embeddedPubkey(Str.with(block.content), isOutgoing); | ||
| } else if (['encryptedAttachment', 'plainAttachment'].includes(block.type)) { | ||
|
|
@@ -163,8 +163,8 @@ export class XssSafeFactory { | |
| }); | ||
| }; | ||
|
|
||
| public srcBackupIframe = (armoredPrvBackup: string) => { | ||
| return this.frameSrc(this.extUrl('chrome/elements/backup.htm'), { frameId: this.newId(), armoredPrvBackup }); | ||
| public srcBackupIframe = (armoredPrvBackup: string, fromEmail?: string) => { | ||
| return this.frameSrc(this.extUrl('chrome/elements/backup.htm'), { frameId: this.newId(), armoredPrvBackup, fromEmail }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }; | ||
|
|
||
| public srcReplyMsgIframe = (convoParams: FactoryReplyParams, skipClickPrompt: boolean, ignoreDraft: boolean) => { | ||
|
|
@@ -229,8 +229,8 @@ export class XssSafeFactory { | |
| return this.iframe(this.srcPgpPubkeyIframe(armoredPubkey, isOutgoing), ['pgp_block', 'publicKey']); | ||
| }; | ||
|
|
||
| public embeddedBackup = (armoredPrvBackup: string) => { | ||
| return this.iframe(this.srcBackupIframe(armoredPrvBackup), ['backup_block']); | ||
| public embeddedBackup = (armoredPrvBackup: string, fromEmail?: string) => { | ||
martgil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return this.iframe(this.srcBackupIframe(armoredPrvBackup, fromEmail), ['backup_block']); | ||
| }; | ||
|
|
||
| public embeddedReply = (convoParams: FactoryReplyParams, skipClickPrompt: boolean, ignoreDraft = false) => { | ||
|
|
||
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 user email aliases? here we check only main user email, but email aliases will probably show warning message. in
MessageRendererwe haveisOutgoingmethod which checks array of sendAs aliases, I think we should use similar check here too:flowcrypt-browser/extension/js/common/message-renderer.ts
Line 292 in 085ab4b