Skip to content

issue #3895 Show all fingerprints for recipient - #4003

Merged
rrrooommmaaa merged 90 commits into
masterfrom
issue-3895-show-all-fingerprints
Oct 10, 2021
Merged

issue #3895 Show all fingerprints for recipient#4003
rrrooommmaaa merged 90 commits into
masterfrom
issue-3895-show-all-fingerprints

Conversation

@IvanPizhenko

Copy link
Copy Markdown
Contributor

This PR introduces showing all recepient's public key fingerprints

close#3985


Tests(delete all except exactly one):

  • Difficult to test (explain why) - not sure at the moment how to do it.

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

@IvanPizhenko
IvanPizhenkoforce-pushed the issue-3895-show-all-fingerprints branch from a4b19d4 to 3ab5d6cCompareSeptember 26, 2021 10:04
@IvanPizhenko
IvanPizhenkoforce-pushed the issue-3895-show-all-fingerprints branch from 59d8ebc to fc28f41CompareSeptember 26, 2021 10:09
@IvanPizhenko

IvanPizhenko commented Sep 26, 2021

Copy link
Copy Markdown
ContributorAuthor

@tomholub@rrrooommmaaa I think I basically did it, but some CI test got broken, and from what I see in the CI logs I absolutely don't get any ideas what needs to be fixed. Please have a look on this.

@tomholub

Copy link
Copy Markdown
Collaborator

@IvanPizhenko I think you're missing local ci secrets? To run tests locally. See https://github.com/FlowCrypt/flowcrypt-browser/wiki/Writing-and-running-tests meanwhile I'll send them over email.

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

You're right that this is basically it. The broken tests could be that some behavior has changed (maybe for the better?) and the tests will need to be updated. Or a bug caused by this change, or a combination of both - that has to be investigated.

Comment threadextension/chrome/elements/compose-modules/compose-recipients-module.ts Outdated
Comment threadextension/chrome/elements/compose-modules/compose-recipients-module.ts Outdated
Comment threadextension/chrome/elements/compose-modules/compose-storage-module.ts Outdated
@IvanPizhenkoIvanPizhenko mentioned this pull request Sep 26, 2021
@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

@IvanPizhenko I think you're missing local ci secrets? To run tests locally. See https://github.com/FlowCrypt/flowcrypt-browser/wiki/Writing-and-running-tests meanwhile I'll send them over email.

Thanks Tom, yes, I really wasn't even thinking that secrets are needed to run tests locally, but now I see.

@IvanPizhenko
IvanPizhenko marked this pull request as ready for review September 26, 2021 21:19
@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

@tomholub I made it passing tests

@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

Now should I add some UI for this?

@IvanPizhenko

IvanPizhenko commented Sep 27, 2021

Copy link
Copy Markdown
ContributorAuthor

@tomholub@rrrooommmaaa Ready for review

@tomholub

Copy link
Copy Markdown
Collaborator

Now should I add some UI for this?

I suppose you could modify an existing test. You won't be able to test the hover but you could extract the title attribute in a test that has a green recipient (most of them) and in a test that has an expired one. I think that's enough.

public lookupPubkeyFromKeyserversThenOptionallyFetchExpiredByFingerprintAndUpsertDb = async (
email: string, name: string | undefined
): Promise<Contact | "fail"> => {
): Promise<Contact[] | "fail"> => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @IvanPizhenko
Contact isn't stored in the database

  • test/source/platform/store/contact-store.ts -- this is a mock database used only in tests, so it is implemented to the extent required for tests to run -- it doesn't fully mimick the real store's behaviour.
  • extension/js/common/platform/store/contact-store.ts -- this is the real one.
    As you can see, only Pubkey, Email and Revocation entities are stored there. Contact type is only left for some consumer classes that we haven't refactored yet -- it emulates the older storage by picking the best candidate pubkey for emal and including it in the Contact. If consumer class needs more data then the best pubkey, it shouldn't use Contact type nor ContactStore.get. We will remove these type and method when no more consumers are left (updating the mock contact-store.ts in due course).

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

Which of them "doesn't require the results" and why? I assumed the second one,

Yes, the second one only needs to warn in a situation when 1) lookup resulted in network failure or 2) saving to the store caused an exception. These are the situations when lookupPubkeyFromKeyserversAndUpsertDb returns false.
We can refactor it to (re-)throw an exception and rewrite the second call with .catch(...) as Tom suggested.
If lookup yielded no keys -- that's not an error, that's the NO_PGP situation.

The first call extracts the keys from the storage if no error happens.

 // re-query the storage
return (await ContactStore.getOneWithAllPubkeys(undefined, email))?.sortedPubkeys ?? [];

If no keys, it will return an empty set (this is not 'fail').
Previously, re-quering was done in lookupPubkeyFromKeyserversAndUpsertDb after all updates to return the sorted keys, but this is not required for the second case, so I made this method lighter, removed re-querying.
And one more thing -- it may look like lookupPubkeyFromKeyserversAndUpsertDb can format PubkeyInfo[] out of Key[] it obtained, right? That's not good, because in the storage we have the table Revocations that stores fingerprints of revoked keys that may not exist in the database (Pubkeys table) -- that is pre-emptive external revocation. So (in a rare case) the lookup method receives a valid key, saves it to the storage, and after re-querying the storage, this key maybe returned as revoked. This is why PubkeyInfo has revoked property regardless of the fact that Key itself also has it.

@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

This is why PubkeyInfo has revoked property regardless of the fact that Key itself also has it.

Maybe this should be documented via some comments in the code.

@IvanPizhenko

IvanPizhenko commented Oct 5, 2021

Copy link
Copy Markdown
ContributorAuthor

@rrrooommmaaa I'm thinking about how to refactor lookupPubkeyFromKeyserversAndUpsertDb() and I have 2 questions:

  1. Why it has this check:
constlookupResult=awaitthis.view.pubLookup.lookupEmail(email);if(lookupResult&&email){

i.e. is it ever possible that lookupEmail (if it didn't threw) would return undefined?

  1. Why also check email here? It seems to be non-nullable parameter. Why at all check it after calling lookupEmail() and not before?

Comment threadtest/source/tests/util.ts Outdated
@@ -0,0 +1,33 @@
/* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess these methods should go to test/source/tests/page-recipe/compose-page-recipe.ts

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Moved them.

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

is it ever possible that lookupEmail (if it didn't threw) would return undefined?

It's not possible. Maybe it was done to trick the linter or something. Feel free to refactor.

Why also check email here? It seems to be non-nullable parameter. Why at all check it after calling lookupEmail() and not before?

email can be ''. The order should be refactored, I guess.

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

Maybe this should be documented via some comments in the code.

Sure. Where would the appropriate place be, in your opinion?

@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

Maybe this should be documented via some comments in the code.

Sure. Where would the appropriate place be, in your opinion?

I've added, in the PubKeyInfo type declaration.

@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

@rrrooommmaaa So I've tried to implement all the notes above. Are there any other improvements to be done here?

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

@rrrooommmaaa So I've tried to implement all the notes above. Are there any other improvements to be done here?

The list looks badly formatted to me.
image

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

Should look like

Valid public key fingerprints:
FF5E C310 4388 CA0F 4014 EBC9 2B6A C469 03E7 16E4 (openpgp)
6FE1 16D2 759F 0FFA C562 3E7E 10D6 E379 41EA A0BB (x509)
Expired public key fingerprints:
whatever (openpgp)
Revoked public key fingerprints:
D666 2C5F B9BD E9DA 01F3 994A AA1E F832 D8CC A4F2 (openpgp)

@rrrooommmaaa

Copy link
Copy Markdown
Contributor

I suggest to display x509 instead of s/mime as we do on other pages, e.g. Contacts.

@rrrooommmaaa

rrrooommmaaa commented Oct 7, 2021

Copy link
Copy Markdown
Contributor

you can import as many keys as needed to the same "contact" from https://github.com/FlowCrypt/flowcrypt-browser/blob/master/test/source/tests/tooling/consts.ts
(e.g. 6FE1 16D2 759F 0FFA C562 3E7E 10D6 E379 41EA A0BB (x509) is smimeCert).
by overwriting the extracted email before pressing "import"
image

@IvanPizhenko

Copy link
Copy Markdown
ContributorAuthor

@rrrooommmaaa Fixed it

@rrrooommmaaa
rrrooommmaaa merged commit e4973b4 into masterOct 10, 2021
@rrrooommmaaa
rrrooommmaaa deleted the issue-3895-show-all-fingerprints branch October 10, 2021 09:01
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.

show all fingerprints when hovering over recipient

3 participants

@IvanPizhenko@tomholub@rrrooommmaaa