Skip to content

Conversation

mdimjasevic
Copy link
Contributor

@mdimjasevic mdimjasevic commented Oct 13, 2022

The PR introduces basic support for external commits in MLS. Note that this does not resubmit external pending proposals submitted by the backend; this is to be done in https://wearezeta.atlassian.net/browse/FS-920.

Tracked by https://wearezeta.atlassian.net/browse/FS-919.

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@mdimjasevic mdimjasevic temporarily deployed to cachix October 13, 2022 11:13 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 13, 2022 11:13 Inactive
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Oct 13, 2022
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from 2db5319 to 70a607f Compare October 13, 2022 11:15
@mdimjasevic mdimjasevic temporarily deployed to cachix October 13, 2022 11:16 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 13, 2022 11:16 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 14, 2022 13:16 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 14, 2022 13:16 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from d0f0b69 to 9a1c4c4 Compare October 14, 2022 15:00
@mdimjasevic mdimjasevic temporarily deployed to cachix October 14, 2022 15:00 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 14, 2022 15:00 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 19, 2022 12:02 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 20, 2022 09:02 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 20, 2022 15:00 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 24, 2022 15:01 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 06:01 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from a3ff2ce to bc0b9af Compare October 25, 2022 07:37
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 07:37 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from bc0b9af to 937f13a Compare October 25, 2022 08:11
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 08:11 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from 937f13a to 62e5bdf Compare October 25, 2022 08:15
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 08:15 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from 62e5bdf to 61b5bab Compare October 25, 2022 14:47
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 14:47 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from 61b5bab to e6beea8 Compare October 25, 2022 14:59
@mdimjasevic mdimjasevic temporarily deployed to cachix October 25, 2022 14:59 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from e6beea8 to 38ae3ef Compare October 26, 2022 07:15
@mdimjasevic mdimjasevic temporarily deployed to cachix October 26, 2022 07:15 Inactive
@mdimjasevic mdimjasevic force-pushed the fs-919/external-commits branch from 38ae3ef to c69966d Compare October 26, 2022 09:13
@mdimjasevic mdimjasevic temporarily deployed to cachix October 26, 2022 09:13 Inactive
@mdimjasevic mdimjasevic marked this pull request as ready for review October 26, 2022 09:16
Just cli -> pure $ updateKeyPackageMapping lconv qusr cli (Just senderRef) updatedRef
Nothing -> pure $ pure ()
(_, Nothing) -> pure $ pure () -- ignore commits without update path
Just cli -> pure (updateKeyPackageMapping lconv qusr cli (Just senderRef) updatedRef, action)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would moving pure outside of the case match work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it would. At first it looked weird to me as well. All the branches of the bigger pattern-match have to have the same type. As far as my understanding goes, this block is written this way so it can be executed later, but then I suppose the same could have been achieved if at the top we had a let binding instead of monadic binding and using one level of monads less.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine either way, more of a nitpick :D

paRemove :: ClientMap,
-- The backend does not process external init proposals, but still it needs
-- to know if a commit has one when processing external commits
paExternalInit :: Maybe ()
Copy link
Contributor

Choose a reason for hiding this comment

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

This Maybe () is pretty weird. Can we use Any instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done in commit 20162df. But aren't these two types isomorphic as well, i.e., don't the same arguments you had yesterday in the call apply to Any as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

What arguments? My only argument here is that Maybe () is a circuitous way to express a boolean, while Any is more direct. Using Bool there is also fine. It's a minor thing, anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I see your point.

throwS @'MLSRemovalUserMismatch
pure (Just r)

updateKeyPackageMapping lconv qusr (ciClient cid) remRef newRef
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you validate the key package first? See for example applyProposal.

Copy link
Contributor Author

@mdimjasevic mdimjasevic Oct 28, 2022

Choose a reason for hiding this comment

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

Your observation has seemed valid and with that in mind, I looked at other cases when a key package is updated or mapped and then some of them seemed equally wrong because they also just call updateKeyPackageMapping. For example, in the case of an existing member updating their key package via the update path we blindly accept the new key package without checking if it is for the same protocol, same cipher suite, etc., but this seems wrong, doesn't it?

I realized updateKeyPackageMapping does validation (the ciphersuite, identity matching, signature scheme, etc.) if the old key package is non-existent (i.e., we pass in Nothing to updateKeyPackageMapping), by calling an internal endpoint in Brig, for which there's a handler upsertKeyPackage.

So before making a call to updateKeyPackageMapping in the case of a NewMemberSender, I just added a call to addKeyPackageRef, which calls upsertKeyPackage in Brig and validates it before inserting into the database.

Does that seem OK?

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as validation is happening.

@mdimjasevic mdimjasevic temporarily deployed to cachix October 28, 2022 08:03 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 28, 2022 08:12 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 28, 2022 08:15 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 28, 2022 08:19 Inactive
@mdimjasevic mdimjasevic temporarily deployed to cachix October 28, 2022 11:26 Inactive
@mdimjasevic mdimjasevic merged commit 6ea9e19 into develop Oct 31, 2022
@mdimjasevic mdimjasevic deleted the fs-919/external-commits branch October 31, 2022 05:20
elland pushed a commit that referenced this pull request Nov 2, 2022
* Check external commit criteria
- Extract the key package from the update path
- Validate key package before replacing the old one
* Fix the serialiseMLS instance for `Sender 'MLSPlainText`
* Update the mls-test-cli reference
* Integration tests for external commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants