Skip to content

Commit b4bb9c3

Browse files
authored
Merge pull request #335 from cipherstash/refactor/move-remaining-eql-bits-to-cipherstash-client
refactor: move EQL encryption logic to cipherstash-client
2 parents edf6c3d + 9f5c6f8 commit b4bb9c3

File tree

5 files changed

+112
-320
lines changed

5 files changed

+112
-320
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ debug = true
4343

4444
[workspace.dependencies]
4545
sqltk = { version = "0.10.0" }
46-
cipherstash-client = "0.30.0"
46+
cipherstash-client = { version = "0.31.0" }
4747
cts-common = { version = "0.4.0" }
4848

4949
thiserror = "2.0.9"

packages/cipherstash-proxy/src/error.rs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub enum EncryptError {
268268

269269
/// This should in practice be unreachable
270270
#[error("Missing encrypt configuration for column type `{plaintext_type}`. For help visit {}#encrypt-missing-encrypt-configuration", ERROR_DOC_BASE_URL)]
271-
MissingEncryptConfiguration { plaintext_type: String },
271+
MissingEncryptConfiguration { plaintext_type: &'static str },
272272

273273
#[error("Decrypted column could not be encoded as the expected type. For help visit {}#encrypt-plaintext-could-not-be-encoded", ERROR_DOC_BASE_URL)]
274274
PlaintextCouldNotBeEncoded,
@@ -308,6 +308,78 @@ pub enum EncryptError {
308308

309309
#[error("Unknown Index Term for column '{}' in table '{}'. For help visit {}#encrypt-unknown-index-term", _0.column(), _0.table(), ERROR_DOC_BASE_URL)]
310310
UnknownIndexTerm(Identifier),
311+
312+
#[error("ZeroKMS error: `{}`", _0)]
313+
ZeroKMS(String),
314+
}
315+
316+
// This impl is very boilerplatey but we can't simply re-export the `cipherstash-client` version of the error
317+
// because Proxy currently manages the documentation links.
318+
impl From<cipherstash_client::eql::EncryptError> for EncryptError {
319+
fn from(value: cipherstash_client::eql::EncryptError) -> Self {
320+
match value {
321+
cipherstash_client::eql::EncryptError::CiphertextCouldNotBeSerialised(error) => {
322+
Self::CiphertextCouldNotBeSerialised(error)
323+
}
324+
cipherstash_client::eql::EncryptError::ColumnCouldNotBeParsed => {
325+
Self::ColumnCouldNotBeParsed
326+
}
327+
cipherstash_client::eql::EncryptError::ColumnIsNull => Self::ColumnIsNull,
328+
cipherstash_client::eql::EncryptError::ColumnCouldNotBeDeserialised {
329+
table,
330+
column,
331+
} => Self::ColumnCouldNotBeDeserialised { table, column },
332+
cipherstash_client::eql::EncryptError::ColumnCouldNotBeEncrypted { table, column } => {
333+
Self::ColumnCouldNotBeEncrypted { table, column }
334+
}
335+
cipherstash_client::eql::EncryptError::ColumnConfigurationMismatch {
336+
table,
337+
column,
338+
} => Self::ColumnConfigurationMismatch { table, column },
339+
cipherstash_client::eql::EncryptError::CouldNotDecryptDataForKeyset { keyset_id } => {
340+
Self::CouldNotDecryptDataForKeyset { keyset_id }
341+
}
342+
cipherstash_client::eql::EncryptError::InvalidIndexTerm => Self::InvalidIndexTerm,
343+
cipherstash_client::eql::EncryptError::KeysetIdCouldNotBeParsed { id } => {
344+
Self::KeysetIdCouldNotBeParsed { id }
345+
}
346+
cipherstash_client::eql::EncryptError::KeysetIdCouldNotBeSet => {
347+
Self::KeysetIdCouldNotBeSet
348+
}
349+
cipherstash_client::eql::EncryptError::KeysetNameCouldNotBeSet => {
350+
Self::KeysetNameCouldNotBeSet
351+
}
352+
cipherstash_client::eql::EncryptError::MissingEncryptConfiguration {
353+
plaintext_type,
354+
} => Self::MissingEncryptConfiguration { plaintext_type },
355+
cipherstash_client::eql::EncryptError::PlaintextCouldNotBeEncoded => {
356+
Self::PlaintextCouldNotBeEncoded
357+
}
358+
cipherstash_client::eql::EncryptError::Pipeline(encryption_error) => {
359+
Self::Pipeline(encryption_error)
360+
}
361+
cipherstash_client::eql::EncryptError::PlaintextCouldNotBeDecoded(type_parse_error) => {
362+
Self::PlaintextCouldNotBeDecoded(type_parse_error)
363+
}
364+
cipherstash_client::eql::EncryptError::MissingKeysetIdentifier => {
365+
Self::MissingKeysetIdentifier
366+
}
367+
cipherstash_client::eql::EncryptError::UnexpectedSetKeyset => Self::UnexpectedSetKeyset,
368+
cipherstash_client::eql::EncryptError::UnknownColumn { table, column } => {
369+
Self::UnknownColumn { table, column }
370+
}
371+
cipherstash_client::eql::EncryptError::UnknownKeysetIdentifier { keyset } => {
372+
Self::UnknownKeysetIdentifier { keyset }
373+
}
374+
cipherstash_client::eql::EncryptError::UnknownTable { table } => {
375+
Self::UnknownTable { table }
376+
}
377+
cipherstash_client::eql::EncryptError::UnknownIndexTerm(identifier) => {
378+
Self::UnknownIndexTerm(identifier)
379+
}
380+
cipherstash_client::eql::EncryptError::ZeroKMS(message) => Self::ZeroKMS(message),
381+
}
382+
}
311383
}
312384

313385
#[derive(Error, Debug)]

0 commit comments

Comments
 (0)