Skip to content

Removing keys if absent on EKM#4646

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

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

Conversation

@rrrooommmaaa
Copy link
Contributor

@rrrooommmaaa rrrooommmaaa commented Aug 26, 2022

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

@rrrooommmaaa
Copy link
Contributor Author

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
Contributor Author

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

Copy link
Collaborator

@tomholub tomholub left a comment

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.

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
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.

@rrrooommmaaa rrrooommmaaa marked this pull request as ready for review September 18, 2022 07:47
@tomholub
Copy link
Collaborator

tomholub commented Sep 19, 2022

@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
Copy link
Contributor Author

rrrooommmaaa commented Sep 19, 2022

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.

@FlowCrypt FlowCrypt deleted a comment from gitguardian bot Sep 19, 2022
@gitguardian
Copy link

gitguardian bot commented Sep 19, 2022

⚠️ 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 id Secret Commit Filename
4313719 Google OAuth2 Keys c355519 extension/js/common/api/email-provider/gmail/google-auth.ts View 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!

Copy link
Collaborator

@tomholub tomholub left a comment

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
Contributor Author

There's something still going on with tests

Some tests are acting flaky indeed

tomholub
tomholub previously approved these changes Sep 19, 2022
Copy link
Collaborator

@tomholub tomholub left a comment

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

Copy link
Collaborator

@tomholub tomholub left a comment

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
Collaborator

Ah, GitGuardian

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