feat(encryption) [12/N] write encrypted manifest list#2677
feat(encryption) [12/N] write encrypted manifest list#2677aarushigupta132 wants to merge 8 commits into
Conversation
|
|
||
| /// Construct a v3 [`ManifestListWriter`] that writes to an [`EncryptedOutputFile`]. | ||
| /// See [`Self::v1_from_encrypted`] for the key-metadata contract. | ||
| pub async fn v3_from_encrypted( |
There was a problem hiding this comment.
I don’t think we need these new constructors, manifest list writer was refactored to take a FileWrite so we can just construct with the correct encrypting file writer
There was a problem hiding this comment.
thank you for the review 🙏 , i have addressed this in the latest commit
38ef25d to
1f644ce
Compare
09df745 to
19fc82d
Compare
| .new_output(manifest_list_path.clone())?; | ||
|
|
||
| let (writer, encrypted) = if let Some(em) = self.table.encryption_manager() { | ||
| let enc = em.encrypt(raw_output); |
There was a problem hiding this comment.
| let enc = em.encrypt(raw_output); | |
| let encrypted_output = em.encrypt(raw_output); |
| let encryption_key_id = match encrypted { | ||
| Some((em, enc)) => { | ||
| let key_id = em | ||
| .encrypt_manifest_list_key_metadata(enc.key_metadata()) | ||
| .await?; | ||
|
|
||
| updates.extend(em.with_encryption_keys(|keys| { | ||
| keys.values() | ||
| .filter(|k| self.table.metadata().encryption_key(k.key_id()).is_none()) | ||
| .map(|k| TableUpdate::AddEncryptionKey { | ||
| encryption_key: k.clone(), | ||
| }) | ||
| .collect::<Vec<_>>() | ||
| })); | ||
|
|
||
| Some(key_id) | ||
| } | ||
| None => None, | ||
| }; |
There was a problem hiding this comment.
Consider moving this to a function and unit testing it.
|
|
||
| let (writer, encrypted) = if let Some(em) = self.table.encryption_manager() { | ||
| let enc = em.encrypt(raw_output); | ||
| (enc.writer().await?, Some((em, enc))) |
There was a problem hiding this comment.
Rather than returning a tuple of tuples, can we just return the key metadata and the writer?
3627509 to
c7ecd37
Compare
c7ecd37 to
4b67ed5
Compare
xanderbailey
left a comment
There was a problem hiding this comment.
This is looking good to me, requested a test
| } | ||
|
|
||
| /// Finished building the action and return the [`ActionCommit`] to the transaction. | ||
| pub(crate) async fn commit<OP: SnapshotProduceOperation, MP: ManifestProcess>( |
There was a problem hiding this comment.
Is it possible to add a commit test to show that we add the correct updates?
Which issue does this PR close?
What changes are included in this PR?
Adds encrypted manifest-list writing and wires it into SnapshotProducer::commit. When the table has an EncryptionManager, the manifest list is encrypted, its key is KEK-wrapped, the wrapped key id is stored on the snapshot.
Are these changes tested?
Encrypted round-trip unit test on the manifest-list writer