-
Notifications
You must be signed in to change notification settings - Fork 547
CXX-2517 Add support for Range Explicit Encryption #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
kevinAlbs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of RAII types seems helpful and less error prone. TIL about DYNAMIC_SECTION.
LGTM with minor comments addressed.
|
Latest changes verified by this patch. Realized I missed the addition of a clause specifying |
Description
Resolves CXX-2517. Verified by this patch.
Test Spec Files
Relevant legacy CSE test files are already synced as part of #953.
Files under https://github.com/mongodb/specifications/tree/c94fefe3e14d163bedcab75a761bc14a77ec689f/source/client-side-encryption/etc/data required by Range Explicit Encryption prose tests were added to the
data/client_side_encryption/explicit_encryptiondirectory. TheencryptedFields-Range-<Type>.jsonare not required (used to generate other test files) and were thus excluded.Interface Changes
ClientEncryption.encryptExpression()
A straightforward addition to the
client_encryptionclass' interface as required by CXX-2517.RangeOpts
A new
options::rangeclass was added corresponding to the new RangeOpts class.RangePreview Options
The
options::encrypt::encryption_algorithmandoptions::encrypt::encryption_query_typewere updated to support the Range algorithm.EncryptOpts.rangeOpts
Added
range_opts()accessors tooptions::encryptthat depend on the newoptions::rangeclass.The
options::encrypt::convert()function was updated to call relevantclient_encryption_encrypt_range_opts_*()functions for the appropriate options inoptions::range.Note a new potential
error_code::k_invalid_parameterexception was introduced to validate thatminandmaxare either both set or both unset to satisfymongoc_client_encryption_encrypt_range_opts_set_min_max. This may be removed once CDRIVER-4610 is resolved.Range Explicit Encryption Prose Tests
A new test case was added corresponding to Prose Test 22: Range Explicit Encryption. The structure of the test is as follows (pseudocode):
The
RangeFieldTypeenumeration is used to define and iterate over the supported types to be tested while ensuring fields and values have the appropriate corresponding types (e.g. viato_type_str,to_field_value, andto_range_opts).The
range_explicit_encryption_setupfunction is used to encapsulate common setup routines, returningrange_explicit_encryption_objectscontaining the entities required by the following test cases.The
field_type_valuesstruct is used to define common field values (0, 6, 30, and 200 with the appropriate type corresponding to theRangeFieldTypebeing tested) used by multiple test cases as a convenience.Miscellaneous
Public Technical Preview Warnings
Documentation was updated to mark Public Technical Preview notes for Queryable Encryption as Doxygen warnings. Their scope (entities which the warning is being applied to) was also reduced to only the relevant entities as applicable.
fprintf in run_encryption_tests_in_file
Some stray
fprintfthat were being unconditionally printed byrun_encryption_tests_in_filewere replaced withUNSCOPED_INFOso they are only emitted when necessary.file.is_open()
A minor change to improve context should the
REQUIRESassertion fail.Member Order in options::encrypt
The
key_idfunction was relocated (both in header and source) to match the pattern of the rest of the member functions.RAII Helpers
The options/encrypt.cpp and private/client_encryption.hh files were refactored to remove all instances of raw owning pointers in the implementation.
Notable patterns include:
scoped_bson_value
A helper class similar to
scoped_bson_tthat wrapsbson_value_t. Given its limited use, it is currently defined (note: twice) inoptions/encrypt.cppandprivate/client_encryption.hh. It may be worth eventually extracting this helper into a proper a proper component (probably undersrc/mongocxx/private?), but that work has been deferred for now.Deleter and std::unique_ptr
Raw owning pointers with corresponding
cleanuproutines replaced withstd::unique_ptrthat define custom deleters. This fixes potential leaks when unexpected exceptions may be thrown by sub-operations (e.g. by calls tomake_document()ordoc.get_<type>()) beforecleanupis invoked.Temporary Objects
Thanks to
scoped_bson_value(as well asscoped_bson_t), the following frequent pattern:has been refactored to: