From 7eebdd58b727231e8655f28718bcf42e21914e9a Mon Sep 17 00:00:00 2001 From: martgil <46025304+martgil@users.noreply.github.com> Date: Thu, 22 May 2025 10:42:41 +0800 Subject: [PATCH 1/5] feat: add fingerprint on private key backup render --- extension/chrome/elements/backup.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extension/chrome/elements/backup.ts b/extension/chrome/elements/backup.ts index fe3675e49ef..c154841cc2b 100644 --- a/extension/chrome/elements/backup.ts +++ b/extension/chrome/elements/backup.ts @@ -48,10 +48,15 @@ View.run( } [this.storedPrvWithMatchingLongid] = await KeyStore.get(this.acctEmail, [fingerprint]); if (this.storedPrvWithMatchingLongid) { - $('.line .private_key_status').text('This Private Key is already imported.'); + $('.line .private_key_status').html( + `This private key with fingerprint ${Str.spaced(fingerprint)} has already been imported.` + ); } else { $('.line .private_key_status') - .text('This private key was not imported yet. We suggest to import all backups so that you can read all incoming encrypted emails.') + .html( + `The private key ${Str.spaced(fingerprint)} has not been imported yet. \n` + + `We recommend importing all backups to ensure you can read all incoming encrypted emails.` + ) .after('
'); // xss-direct } this.sendResizeMsg(); From e5474dc02b04cd5f661e703646cd56e9af5d931e Mon Sep 17 00:00:00 2001 From: martgil <46025304+martgil@users.noreply.github.com> Date: Thu, 22 May 2025 10:44:52 +0800 Subject: [PATCH 2/5] feat: escape fingerprint --- extension/chrome/elements/backup.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extension/chrome/elements/backup.ts b/extension/chrome/elements/backup.ts index c154841cc2b..ad1e38bd7fe 100644 --- a/extension/chrome/elements/backup.ts +++ b/extension/chrome/elements/backup.ts @@ -11,6 +11,7 @@ import { Url, Str } from '../../js/common/core/common.js'; import { View } from '../../js/common/view.js'; import { initPassphraseToggle } from '../../js/common/ui/passphrase-ui.js'; import { KeyStore } from '../../js/common/platform/store/key-store.js'; +import { Xss } from '../../js/common/platform/xss.js'; View.run( class BackupView extends View { @@ -49,12 +50,12 @@ View.run( [this.storedPrvWithMatchingLongid] = await KeyStore.get(this.acctEmail, [fingerprint]); if (this.storedPrvWithMatchingLongid) { $('.line .private_key_status').html( - `This private key with fingerprint ${Str.spaced(fingerprint)} has already been imported.` + `This private key with fingerprint ${Xss.escape(Str.spaced(fingerprint))} has already been imported.` ); } else { $('.line .private_key_status') .html( - `The private key ${Str.spaced(fingerprint)} has not been imported yet. \n` + + `The private key ${Xss.escape(Str.spaced(fingerprint))} has not been imported yet. \n` + `We recommend importing all backups to ensure you can read all incoming encrypted emails.` ) .after('
'); // xss-direct From 94e8cd3970fa7b0731db94daf04f184d10629c0a Mon Sep 17 00:00:00 2001 From: martgil <46025304+martgil@users.noreply.github.com> Date: Thu, 22 May 2025 13:50:22 +0800 Subject: [PATCH 3/5] test: fix failing test --- test/source/tests/decrypt.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/source/tests/decrypt.ts b/test/source/tests/decrypt.ts index 809571c6b9c..cabaf0b83ef 100644 --- a/test/source/tests/decrypt.ts +++ b/test/source/tests/decrypt.ts @@ -72,11 +72,21 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te const { acctEmail, authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); const inboxPage = await browser.newExtensionPage(t, `chrome/settings/inbox/inbox.htm?acctEmail=${acctEmail}&threadId=${threadId}`); await inboxPage.waitForSelTestState('ready'); - await (await inboxPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.'); + await ( + await inboxPage.getFrame(['backup.htm']) + ).waitForContent( + '@private-key-status', + 'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.' + ); await inboxPage.close(); const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/${threadId}`, undefined, authHdr); await gmailPage.waitAll('iframe'); - await (await gmailPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.'); + await ( + await gmailPage.getFrame(['backup.htm']) + ).waitForContent( + '@private-key-status', + 'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.' + ); await gmailPage.close(); }) ); From 760eab1b08a91f3bc44911bfc6da19927f4d904e Mon Sep 17 00:00:00 2001 From: martgil <46025304+martgil@users.noreply.github.com> Date: Thu, 22 May 2025 13:54:17 +0800 Subject: [PATCH 4/5] test: fix failing test --- test/source/tests/decrypt.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/source/tests/decrypt.ts b/test/source/tests/decrypt.ts index cabaf0b83ef..d12ff9ffc6c 100644 --- a/test/source/tests/decrypt.ts +++ b/test/source/tests/decrypt.ts @@ -98,11 +98,21 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te const { acctEmail, authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility'); const inboxPage = await browser.newExtensionPage(t, `chrome/settings/inbox/inbox.htm?acctEmail=${acctEmail}&threadId=${threadId}`); await inboxPage.waitForSelTestState('ready'); - await (await inboxPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.'); + await ( + await inboxPage.getFrame(['backup.htm']) + ).waitForContent( + '@private-key-status', + 'This private key with fingerprint E8F0 517B A6D7 DAB6 081C 96E4 ADAC 279C 9509 3207 has already been imported.' + ); await inboxPage.close(); const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/${threadId}`, undefined, authHdr); await gmailPage.waitAll('iframe'); - await (await gmailPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.'); + await ( + await gmailPage.getFrame(['backup.htm']) + ).waitForContent( + '@private-key-status', + 'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.' + ); await gmailPage.close(); }) ); From b1dce423457f2c9cba10697826a3f5480de24a66 Mon Sep 17 00:00:00 2001 From: martgil <46025304+martgil@users.noreply.github.com> Date: Thu, 22 May 2025 14:37:23 +0800 Subject: [PATCH 5/5] test: fix failing test --- test/source/tests/decrypt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/source/tests/decrypt.ts b/test/source/tests/decrypt.ts index d12ff9ffc6c..2157f69bd92 100644 --- a/test/source/tests/decrypt.ts +++ b/test/source/tests/decrypt.ts @@ -111,7 +111,7 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te await gmailPage.getFrame(['backup.htm']) ).waitForContent( '@private-key-status', - 'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.' + 'This private key with fingerprint E8F0 517B A6D7 DAB6 081C 96E4 ADAC 279C 9509 3207 has already been imported.' ); await gmailPage.close(); })