From 9e55722e6f9043d866de2b1e29f09e980ea5c0eb Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 3 Feb 2025 11:01:29 -0500 Subject: [PATCH 1/3] remove check for `$jsonSchema` siblings --- src/mongocrypt-ctx-encrypt.c | 12 +----------- src/mongocrypt-ctx-private.h | 3 --- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/mongocrypt-ctx-encrypt.c b/src/mongocrypt-ctx-encrypt.c index ac48d2c7c..1867a31eb 100644 --- a/src/mongocrypt-ctx-encrypt.c +++ b/src/mongocrypt-ctx-encrypt.c @@ -426,8 +426,7 @@ static bool _set_schema_from_collinfo(mongocrypt_ctx_t *ctx, bson_t *collinfo) { return _mongocrypt_ctx_fail_w_msg(ctx, "malformed $jsonSchema"); } found_jsonschema = true; - } else { - ectx->collinfo_has_siblings = true; + break; } } } @@ -800,15 +799,6 @@ static bool _mongo_feed_markings(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *in) "local schema used but does not have encryption specifiers"); } return true; - } else { - /* if the schema requires encryption, but has sibling validators, error. - */ - if (ectx->collinfo_has_siblings) { - return _mongocrypt_ctx_fail_w_msg(ctx, - "schema requires encryption, " - "but collection JSON schema " - "validator has siblings"); - } } if (bson_iter_init_find(&iter, &as_bson, "hasEncryptedPlaceholders") && !bson_iter_as_bool(&iter)) { diff --git a/src/mongocrypt-ctx-private.h b/src/mongocrypt-ctx-private.h index 688db865d..fcbe9fd7d 100644 --- a/src/mongocrypt-ctx-private.h +++ b/src/mongocrypt-ctx-private.h @@ -178,9 +178,6 @@ typedef struct { _mongocrypt_buffer_t encrypted_cmd; _mongocrypt_buffer_t key_id; bool used_local_schema; - /* collinfo_has_siblings is true if the schema came from a remote JSON - * schema, and there were siblings. */ - bool collinfo_has_siblings; /* encrypted_field_config is set when: * 1. `target_ns` is present in an encrypted_field_config_map. * 2. (TODO MONGOCRYPT-414) The collection has encryptedFields in the From 287ae6c62c296bb36a0eff09a6e7462f85d29c3c Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 3 Feb 2025 11:01:35 -0500 Subject: [PATCH 2/3] update test --- test/test-mongocrypt-ctx-encrypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test-mongocrypt-ctx-encrypt.c b/test/test-mongocrypt-ctx-encrypt.c index 71822125b..c7ffdc605 100644 --- a/test/test-mongocrypt-ctx-encrypt.c +++ b/test/test-mongocrypt-ctx-encrypt.c @@ -1004,9 +1004,8 @@ static void _test_encrypt_invalid_siblings(_mongocrypt_tester_t *tester) { ASSERT_OK(mongocrypt_ctx_mongo_done(ctx), ctx); BSON_ASSERT(MONGOCRYPT_CTX_NEED_MONGO_MARKINGS == mongocrypt_ctx_state(ctx)); - ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/mongocryptd-reply.json")), - ctx, - "JSON schema validator has siblings"); + // MONGOCRYPT-771 removes checks for sibling validators. + ASSERT_OK(mongocrypt_ctx_mongo_feed(ctx, TEST_FILE("./test/example/mongocryptd-reply.json")), ctx); mongocrypt_ctx_destroy(ctx); mongocrypt_destroy(crypt); From b22edf87fdd850de32a54455ca73e1d2496827f9 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 3 Feb 2025 12:29:05 -0500 Subject: [PATCH 3/3] remove `_test_encrypt_dupe_jsonschema` Remove the test. A `validator` with duplicate fields on the server is not expected. --- test/test-mongocrypt-ctx-encrypt.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/test/test-mongocrypt-ctx-encrypt.c b/test/test-mongocrypt-ctx-encrypt.c index c7ffdc605..b5f697e74 100644 --- a/test/test-mongocrypt-ctx-encrypt.c +++ b/test/test-mongocrypt-ctx-encrypt.c @@ -1011,25 +1011,6 @@ static void _test_encrypt_invalid_siblings(_mongocrypt_tester_t *tester) { mongocrypt_destroy(crypt); } -static void _test_encrypt_dupe_jsonschema(_mongocrypt_tester_t *tester) { - mongocrypt_t *crypt; - mongocrypt_ctx_t *ctx; - - crypt = _mongocrypt_tester_mongocrypt(TESTER_MONGOCRYPT_DEFAULT); - ctx = mongocrypt_ctx_new(crypt); - ASSERT_OK(mongocrypt_ctx_encrypt_init(ctx, "test", -1, TEST_FILE("./test/example/cmd.json")), ctx); - - BSON_ASSERT(MONGOCRYPT_CTX_NEED_MONGO_COLLINFO == mongocrypt_ctx_state(ctx)); - ASSERT_FAILS(mongocrypt_ctx_mongo_feed(ctx, - TEST_BSON("{'options': {'validator': { '$jsonSchema': {}, " - "'$jsonSchema': {} } } }")), - ctx, - "duplicate $jsonSchema"); - - mongocrypt_ctx_destroy(ctx); - mongocrypt_destroy(crypt); -} - static void _test_encrypting_with_explicit_encryption(_mongocrypt_tester_t *tester) { /* Test that we do not strip existing ciphertexts when automatically * encrypting a document. */ @@ -4689,7 +4670,6 @@ void _mongocrypt_tester_install_ctx_encrypt(_mongocrypt_tester_t *tester) { INSTALL_TEST(_test_encrypt_is_remote_schema); INSTALL_TEST(_test_encrypt_init_each_cmd); INSTALL_TEST(_test_encrypt_invalid_siblings); - INSTALL_TEST(_test_encrypt_dupe_jsonschema); INSTALL_TEST(_test_encrypting_with_explicit_encryption); INSTALL_TEST(_test_explicit_encryption); INSTALL_TEST(_test_encrypt_empty_aws);