Skip to content

Removing keys if absent on EKM - #4646

Merged
tomholub merged 27 commits into
masterfrom
issue-4596-remove-keys-on-ekm-sync
Sep 20, 2022
Merged

Removing keys if absent on EKM#4646
tomholub merged 27 commits into
masterfrom
issue-4596-remove-keys-on-ekm-sync

Conversation

@rrrooommmaaa

@rrrooommmaaarrrooommmaaa commented Aug 26, 2022

Copy link
Copy Markdown
Contributor

This PR removes keys not present on EKM, redirects to setup page in case no keys are in the storage,
or silently generates a new key in case PASS_PHRASE_QUIET_AUTOGEN flag is present.
Also, correctly sets up passphrases for newly added keys (based on the location of an existing key's pass phrase)

close#4596


Tests(delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

Comment threadextension/js/common/helpers.ts Outdated
Comment threadtest/source/tests/setup.ts
Comment threadtest/source/tests/setup.ts Outdated
Comment threadtest/source/tests/setup.ts Outdated
Comment threadtest/source/tests/setup.ts
@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

Most of the scenarios are covered now.
It'd be interesting to emulate a situation when EKM supplies 2 instances of a key with the same identity --
two versions of the same key at once. We should handle this situation gracefully, right? It makes sense to store only one copy of the key -- but which one?

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

Ping @tomholub
Can you comment on what strategy on removing passphrases I should adhere to?

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - various comments that will help me with code comprehension. Many apply already to the original code but this PR highlighted the need to rename them.

Comment threadextension/js/common/helpers.ts Outdated
Comment threadextension/js/common/helpers.ts
Comment threadextension/js/common/helpers.ts Outdated
Comment threadextension/chrome/settings/setup/setup-key-manager-autogen.ts Outdated
Comment threadextension/js/common/helpers.ts Outdated
const clientConfiguration = await ClientConfiguration.newInstance(acctEmail);
if (replaceKeys) {
await KeyStore.set(acctEmail, await Promise.all(prvs.map(KeyUtil.keyInfoObj))); // todo: duplicate identities
// todo: should we delete passphrases matching the deleted keys?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, especially for stored ones. But anyway also removing the memory ones is the same amount of work.

Comment threadextension/js/common/helpers.ts Outdated
Comment threadextension/js/common/helpers.ts Outdated
Comment threadextension/js/common/helpers.ts Outdated
Comment threadextension/js/common/helpers.ts Outdated
Comment threadtest/source/tests/setup.ts
Comment threadtest/source/tests/setup.ts
Comment threadextension/chrome/settings/modules/add_key.ts
@rrrooommmaaa
rrrooommmaaa marked this pull request as ready for review September 18, 2022 07:47
@tomholub

tomholub commented Sep 19, 2022

Copy link
Copy Markdown
Collaborator

@rrrooommmaaa is it ready for final review? There's something still going on with tests, and it looks like a git merge is in order.

@rrrooommmaaa

rrrooommmaaa commented Sep 19, 2022

Copy link
Copy Markdown
ContributorAuthor

is it ready for final review? There's something still going on with tests, and it looks like a git merge is in order.

Yes, it is ready. I think it's reacting to client_secret from master probably because this change was merged, not rebased.

Comment threadextension/js/common/platform/store/in-memory-store.ts Outdated
@FlowCryptFlowCrypt deleted a comment from gitguardianBotSep 19, 2022
@gitguardian

gitguardianBot commented Sep 19, 2022

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian idSecretCommitFilename
4313719Google OAuth2 Keysc355519extension/js/common/api/email-provider/gmail/google-auth.tsView secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far good, still some reviewing to do.

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

There's something still going on with tests

Some tests are acting flaky indeed

tomholub
tomholub previously approved these changes Sep 19, 2022

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a comment - please see below

Comment threadtest/source/tests/setup.ts Outdated

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me, good to merge once tests are passing

@tomholub

Copy link
Copy Markdown
Collaborator

Ah, GitGuardian

@tomholub
tomholub merged commit 5f2eb8c into masterSep 20, 2022
@tomholub
tomholub deleted the issue-4596-remove-keys-on-ekm-sync branch September 20, 2022 18:36
Sign up for freeto 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.

add support for removing private keys during EKM sync (and possibly recovering when syncing from 0 keys)

2 participants

@rrrooommmaaa@tomholub