From 6bb67e1cc7da9127108ff916b46ec0d59aec973a Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Thu, 4 Sep 2025 15:45:15 -0400 Subject: [PATCH 1/7] Remove usage of trace logging in mongocrypt internals --- src/mongocrypt-ctx-decrypt.c | 14 ---------- src/mongocrypt-ctx-encrypt.c | 23 --------------- src/mongocrypt-ctx.c | 54 +----------------------------------- src/mongocrypt-kms-ctx.c | 10 ------- src/mongocrypt-opts.c | 6 ---- src/mongocrypt.c | 27 ------------------ 6 files changed, 1 insertion(+), 133 deletions(-) diff --git a/src/mongocrypt-ctx-decrypt.c b/src/mongocrypt-ctx-decrypt.c index b20170d4b..c6da592e5 100644 --- a/src/mongocrypt-ctx-decrypt.c +++ b/src/mongocrypt-ctx-decrypt.c @@ -778,14 +778,6 @@ bool mongocrypt_ctx_explicit_decrypt_init(mongocrypt_ctx_t *ctx, mongocrypt_bina return _mongocrypt_ctx_fail_w_msg(ctx, "invalid msg"); } - if (ctx->crypt->log.trace_enabled) { - char *msg_val; - msg_val = _mongocrypt_new_json_string_from_binary(msg); - _mongocrypt_log(&ctx->crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "msg", msg_val); - - bson_free(msg_val); - } - /* Expect msg to be the BSON a document of the form: { "v" : (BSON BINARY value of subtype 6) } */ @@ -866,12 +858,6 @@ bool mongocrypt_ctx_decrypt_init(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *doc return _mongocrypt_ctx_fail_w_msg(ctx, "invalid doc"); } - if (ctx->crypt->log.trace_enabled) { - char *doc_val; - doc_val = _mongocrypt_new_json_string_from_binary(doc); - _mongocrypt_log(&ctx->crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "doc", doc_val); - bson_free(doc_val); - } dctx = (_mongocrypt_ctx_decrypt_t *)ctx; ctx->type = _MONGOCRYPT_TYPE_DECRYPT; ctx->vtable.finalize = _finalize; diff --git a/src/mongocrypt-ctx-encrypt.c b/src/mongocrypt-ctx-encrypt.c index 40a816530..81c8c713b 100644 --- a/src/mongocrypt-ctx-encrypt.c +++ b/src/mongocrypt-ctx-encrypt.c @@ -2026,13 +2026,6 @@ static bool explicit_encrypt_init(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *ms return _mongocrypt_ctx_fail_w_msg(ctx, "msg must be bson"); } - if (ctx->crypt->log.trace_enabled) { - char *cmd_val; - cmd_val = _mongocrypt_new_json_string_from_binary(msg); - _mongocrypt_log(&ctx->crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "msg", cmd_val); - bson_free(cmd_val); - } - if (!bson_iter_init_find(&iter, &as_bson, "v")) { return _mongocrypt_ctx_fail_w_msg(ctx, "invalid msg, must contain 'v'"); } @@ -2577,22 +2570,6 @@ bool mongocrypt_ctx_encrypt_init(mongocrypt_ctx_t *ctx, const char *db, int32_t return _mongocrypt_ctx_fail_w_msg(ctx, "algorithm must not be set for auto encryption"); } - if (ctx->crypt->log.trace_enabled) { - char *cmd_val; - cmd_val = _mongocrypt_new_json_string_from_binary(cmd); - _mongocrypt_log(&ctx->crypt->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%s\", %s=%d, %s=\"%s\")", - BSON_FUNC, - "db", - ectx->cmd_db, - "db_len", - db_len, - "cmd", - cmd_val); - bson_free(cmd_val); - } - // Check if an isMaster request to mongocryptd is needed to detect feature support: if (needs_ismaster_check(ctx)) { ectx->ismaster.needed = true; diff --git a/src/mongocrypt-ctx.c b/src/mongocrypt-ctx.c index db17584da..ccbc3ed2e 100644 --- a/src/mongocrypt-ctx.c +++ b/src/mongocrypt-ctx.c @@ -76,21 +76,7 @@ bool mongocrypt_ctx_setopt_key_id(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *ke if (!ctx) { return false; } - - if (ctx->crypt->log.trace_enabled && key_id && key_id->data) { - char *key_id_val; - /* this should never happen, so assert rather than return false */ - BSON_ASSERT(key_id->len <= INT_MAX); - key_id_val = _mongocrypt_new_string_from_bytes(key_id->data, (int)key_id->len); - _mongocrypt_log(&ctx->crypt->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%s\")", - BSON_FUNC, - "key_id", - key_id_val); - bson_free(key_id_val); - } - + return _set_binary_opt(ctx, key_id, &ctx->opts.key_id, BSON_SUBTYPE_UUID); } @@ -241,15 +227,6 @@ bool mongocrypt_ctx_setopt_algorithm(mongocrypt_ctx_t *ctx, const char *algorith } const size_t calculated_len = len == -1 ? strlen(algorithm) : (size_t)len; - if (ctx->crypt->log.trace_enabled) { - _mongocrypt_log(&ctx->crypt->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%.*s\")", - BSON_FUNC, - "algorithm", - calculated_len <= (size_t)INT_MAX ? (int)calculated_len : INT_MAX, - algorithm); - } mstr_view algo_str = mstrv_view_data(algorithm, calculated_len); if (mstr_eq_ignore_case(algo_str, mstrv_lit(MONGOCRYPT_ALGORITHM_DETERMINISTIC_STR))) { @@ -443,14 +420,6 @@ bool mongocrypt_ctx_mongo_feed(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *in) { return _mongocrypt_ctx_fail_w_msg(ctx, "invalid NULL input"); } - if (ctx->crypt->log.trace_enabled) { - char *in_val; - - in_val = _mongocrypt_new_json_string_from_binary(in); - _mongocrypt_log(&ctx->crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "in", in_val); - bson_free(in_val); - } - switch (ctx->state) { case MONGOCRYPT_CTX_NEED_MONGO_COLLINFO_WITH_DB: case MONGOCRYPT_CTX_NEED_MONGO_COLLINFO: CHECK_AND_CALL(mongo_feed_collinfo, ctx, in); @@ -729,21 +698,6 @@ bool mongocrypt_ctx_setopt_masterkey_aws(mongocrypt_ctx_t *ctx, mongocrypt_binary_destroy(bin); bson_destroy(&as_bson); - if (ctx->crypt->log.trace_enabled) { - _mongocrypt_log(&ctx->crypt->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%s\", %s=%d, %s=\"%s\", %s=%d)", - BSON_FUNC, - "region", - ctx->opts.kek.provider.aws.region, - "region_len", - region_len, - "cmk", - ctx->opts.kek.provider.aws.cmk, - "cmk_len", - cmk_len); - } - return ret; } @@ -1012,12 +966,6 @@ bool mongocrypt_ctx_setopt_key_encryption_key(mongocrypt_ctx_t *ctx, mongocrypt_ return _mongocrypt_ctx_fail(ctx); } - if (ctx->crypt->log.trace_enabled) { - char *bin_str = bson_as_canonical_extended_json(&as_bson, NULL); - _mongocrypt_log(&ctx->crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "bin", bin_str); - bson_free(bin_str); - } - return true; } diff --git a/src/mongocrypt-kms-ctx.c b/src/mongocrypt-kms-ctx.c index 6e18df16a..02a8e2463 100644 --- a/src/mongocrypt-kms-ctx.c +++ b/src/mongocrypt-kms-ctx.c @@ -1194,16 +1194,6 @@ bool mongocrypt_kms_ctx_feed(mongocrypt_kms_ctx_t *kms, mongocrypt_binary_t *byt return false; } - if (kms->log && kms->log->trace_enabled) { - _mongocrypt_log(kms->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%.*s\")", - BSON_FUNC, - "bytes", - mongocrypt_binary_len(bytes), - mongocrypt_binary_data(bytes)); - } - if (!kms_response_parser_feed(kms->parser, bytes->data, bytes->len)) { if (is_kms(kms->req_type)) { /* The KMIP response parser does not suport kms_response_parser_status. diff --git a/src/mongocrypt-opts.c b/src/mongocrypt-opts.c index 43d6c4993..38bf46392 100644 --- a/src/mongocrypt-opts.c +++ b/src/mongocrypt-opts.c @@ -988,11 +988,5 @@ bool _mongocrypt_parse_kms_providers(mongocrypt_binary_t *kms_providers_definiti } } - if (log && log->trace_enabled) { - char *as_str = bson_as_relaxed_extended_json(&as_bson, NULL); - _mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "kms_providers", as_str); - bson_free(as_str); - } - return true; } diff --git a/src/mongocrypt.c b/src/mongocrypt.c index 7f6df751f..42379d16b 100644 --- a/src/mongocrypt.c +++ b/src/mongocrypt.c @@ -203,20 +203,6 @@ bool mongocrypt_setopt_kms_provider_aws(mongocrypt_t *crypt, return false; } - if (crypt->log.trace_enabled) { - _mongocrypt_log(&crypt->log, - MONGOCRYPT_LOG_LEVEL_TRACE, - "%s (%s=\"%s\", %s=%d, %s=\"%s\", %s=%d)", - BSON_FUNC, - "aws_access_key_id", - kms_providers->aws_mut.access_key_id, - "aws_access_key_id_len", - aws_access_key_id_len, - "aws_secret_access_key", - kms_providers->aws_mut.secret_access_key, - "aws_secret_access_key_len", - aws_secret_access_key_len); - } kms_providers->configured_providers |= MONGOCRYPT_KMS_PROVIDER_AWS; return true; } @@ -360,15 +346,6 @@ bool mongocrypt_setopt_kms_provider_local(mongocrypt_t *crypt, mongocrypt_binary return false; } - if (crypt->log.trace_enabled) { - char *key_val; - BSON_ASSERT(key->len <= (uint32_t)INT_MAX); - key_val = _mongocrypt_new_string_from_bytes(key->data, (int)key->len); - - _mongocrypt_log(&crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "%s (%s=\"%s\")", BSON_FUNC, "key", key_val); - bson_free(key_val); - } - _mongocrypt_buffer_copy_from_binary(&kms_providers->local_mut.key, key); kms_providers->configured_providers |= MONGOCRYPT_KMS_PROVIDER_LOCAL; return true; @@ -409,9 +386,6 @@ static _loaded_csfle _try_load_csfle(const char *filepath, mongocrypt_status_t * return (_loaded_csfle){.okay = false}; } - // Successfully opened DLL - _mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "Loading crypt_shared dynamic library [%s]", filepath); - // Construct the library vtable _mongo_crypt_v1_vtable vtable = {.okay = true}; #define X_FUNC(Name, RetType, ...) \ @@ -796,7 +770,6 @@ static bool _csfle_replace_or_take_validate_singleton(mongocrypt_t *crypt, _load // Reset the library in the caller so they can't unload the DLL. The DLL // is now managed in the global variable. found->lib = MCR_DLL_NULL; - _mongocrypt_log(&crypt->log, MONGOCRYPT_LOG_LEVEL_TRACE, "Loading new csfle library for the application."); have_csfle = true; break; case LIB_CREATE_FAILED: From 3bbd0219e1be52b41cc6c7eeb40ab7fbc3e669e6 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Thu, 4 Sep 2025 16:00:57 -0400 Subject: [PATCH 2/7] Remove from tests --- test/example-state-machine.c | 1 - test/test-mongocrypt-log.c | 31 ------------------------------- test/util/util.c | 1 - 3 files changed, 33 deletions(-) diff --git a/test/example-state-machine.c b/test/example-state-machine.c index 2445121b9..4f61bfbd1 100644 --- a/test/example-state-machine.c +++ b/test/example-state-machine.c @@ -28,7 +28,6 @@ static void _log_to_stderr(mongocrypt_log_level_t level, const char *message, ui case MONGOCRYPT_LOG_LEVEL_ERROR: fprintf(stderr, "ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: fprintf(stderr, "WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: fprintf(stderr, "INFO"); break; - case MONGOCRYPT_LOG_LEVEL_TRACE: fprintf(stderr, "TRACE"); break; default: fprintf(stderr, "UNKNOWN"); break; } fprintf(stderr, " %s\n", message); diff --git a/test/test-mongocrypt-log.c b/test/test-mongocrypt-log.c index 78b54d80d..6b7a33729 100644 --- a/test/test-mongocrypt-log.c +++ b/test/test-mongocrypt-log.c @@ -56,36 +56,6 @@ static void _test_log(_mongocrypt_tester_t *tester) { mongocrypt_destroy(crypt); } -static void _test_trace_log(_mongocrypt_tester_t *tester) { - log_test_ctx_t log_ctx = {0}; - mongocrypt_t *crypt; - mongocrypt_status_t *status; - uint32_t expected_int = -1; - const char *expected_string = "_test_trace_log_test_str"; - bool original_trace; - - status = mongocrypt_status_new(); - crypt = mongocrypt_new(); - - _mongocrypt_log_set_fn(&crypt->log, _test_log_fn, &log_ctx); - original_trace = crypt->log.trace_enabled; - crypt->log.trace_enabled = true; - log_ctx.expected_level = MONGOCRYPT_LOG_LEVEL_TRACE; - - log_ctx.message = "mongocrypt_setopt_kms_provider_aws " - "(aws_access_key_id=\"_test\", " - "aws_access_key_id_len=5, " - "aws_secret_access_key=\"_test_trace_log_test_str\", " - "aws_secret_access_key_len=-1)"; - - /* 'expected_string' is truncated to test for non-null terminated strings */ - mongocrypt_setopt_kms_provider_aws(crypt, expected_string, 5, expected_string, expected_int); - crypt->log.trace_enabled = original_trace; - - mongocrypt_status_destroy(status); - mongocrypt_destroy(crypt); -} - #if defined(__GLIBC__) || defined(__APPLE__) static void _test_no_log(_mongocrypt_tester_t *tester) { mongocrypt_t *crypt; @@ -115,7 +85,6 @@ static void _test_no_log(_mongocrypt_tester_t *tester) { void _mongocrypt_tester_install_log(_mongocrypt_tester_t *tester) { INSTALL_TEST(_test_log); - INSTALL_TEST(_test_trace_log); #if defined(__GLIBC__) || defined(__APPLE__) INSTALL_TEST(_test_no_log); #endif diff --git a/test/util/util.c b/test/util/util.c index e94df3280..42904e658 100644 --- a/test/util/util.c +++ b/test/util/util.c @@ -60,7 +60,6 @@ void _log_to_stdout(mongocrypt_log_level_t level, const char *message, uint32_t case MONGOCRYPT_LOG_LEVEL_ERROR: printf("ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: printf("WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: printf("INFO"); break; - case MONGOCRYPT_LOG_LEVEL_TRACE: printf("TRACE"); break; default: printf("?????"); break; } printf(" %s\n", message); From ff37f6804caeb0638254819d1cdd1e71e5d76232 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Thu, 4 Sep 2025 16:09:24 -0400 Subject: [PATCH 3/7] Remove trace implementation --- CMakeLists.txt | 6 ----- bindings/python/pymongocrypt/binding.py | 1 - integrating.md | 2 -- src/mongocrypt-config.h.in | 10 -------- src/mongocrypt-log-private.h | 32 ------------------------- src/mongocrypt-log.c | 8 ------- src/mongocrypt.h | 1 - 7 files changed, 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17a488bf6..d43082c02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,12 +184,6 @@ else () message (FATAL_ERROR "Unknown crypto provider ${MONGOCRYPT_CRYPTO}") endif () -set (MONGOCRYPT_ENABLE_TRACE 0) -if (ENABLE_TRACE) - message (WARNING "Building with trace logging. This is highly insecure. Do not use in a production environment") - set (MONGOCRYPT_ENABLE_TRACE 1) -endif () - set (BUILD_VERSION "0.0.0" CACHE STRING "Library version") if (BUILD_VERSION STREQUAL "0.0.0") if (EXISTS ${CMAKE_BINARY_DIR}/VERSION_CURRENT) diff --git a/bindings/python/pymongocrypt/binding.py b/bindings/python/pymongocrypt/binding.py index ba451e21f..919ad49de 100644 --- a/bindings/python/pymongocrypt/binding.py +++ b/bindings/python/pymongocrypt/binding.py @@ -260,7 +260,6 @@ def _parse_version(version): MONGOCRYPT_LOG_LEVEL_ERROR = 1, MONGOCRYPT_LOG_LEVEL_WARNING = 2, MONGOCRYPT_LOG_LEVEL_INFO = 3, - MONGOCRYPT_LOG_LEVEL_TRACE = 4 } mongocrypt_log_level_t; /** diff --git a/integrating.md b/integrating.md index 1773e0ce5..7b2ee3773 100644 --- a/integrating.md +++ b/integrating.md @@ -72,8 +72,6 @@ executable included with libmongocrypt. It uses mock responses from mongod, mongocryptd, and KMS. Reimplement the state machine loop (`_run_state_machine`) in example-state-machine with your binding. -To debug, configure with the cmake option `-DENABLE_TRACE=ON`, and set the environment variable `MONGOCRYPT_TRACE=ON` to log the arguments to mongocrypt functions. Note, this is insecure and should only be used for debugging. - Seek help in the slack channel \#drivers-fle. ## Part 2: Integrate into Driver ## diff --git a/src/mongocrypt-config.h.in b/src/mongocrypt-config.h.in index af4fbf2c7..8b0e7b948 100644 --- a/src/mongocrypt-config.h.in +++ b/src/mongocrypt-config.h.in @@ -72,16 +72,6 @@ #endif -/* - * MONGOCRYPT_ENABLE_TRACE is set from configure to determine if we are - * compiled with tracing support. - */ -#define MONGOCRYPT_ENABLE_TRACE @MONGOCRYPT_ENABLE_TRACE@ - -#if MONGOCRYPT_ENABLE_TRACE != 1 -# undef MONGOCRYPT_ENABLE_TRACE -#endif - /* clang-format on */ #endif /* MONGOCRYPT_CONFIG_H */ diff --git a/src/mongocrypt-log-private.h b/src/mongocrypt-log-private.h index a0e5f7022..2f1902fa9 100644 --- a/src/mongocrypt-log-private.h +++ b/src/mongocrypt-log-private.h @@ -24,7 +24,6 @@ typedef struct { mongocrypt_mutex_t mutex; /* protects fn and ctx. */ mongocrypt_log_fn_t fn; void *ctx; - bool trace_enabled; } _mongocrypt_log_t; void _mongocrypt_stdout_log_fn(mongocrypt_log_level_t level, const char *message, uint32_t message_len, void *ctx); @@ -38,35 +37,6 @@ void _mongocrypt_log_cleanup(_mongocrypt_log_t *log); void _mongocrypt_log_set_fn(_mongocrypt_log_t *log, mongocrypt_log_fn_t fn, void *ctx); -#ifdef MONGOCRYPT_ENABLE_TRACE - -#define CRYPT_TRACEF(log, fmt, ...) \ - _mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "(%s:%d) " fmt, BSON_FUNC, __LINE__, __VA_ARGS__) - -#define CRYPT_TRACE(log, msg) CRYPT_TRACEF(crypt, "%s", msg) - -#define CRYPT_ENTRY(log) _mongocrypt_log(crypt, MONGOCRYPT_LOG_LEVEL_TRACE, "entry (%s:%d)", BSON_FUNC, __LINE__) - -#define CRYPT_EXIT(log) \ - do { \ - _mongocrypt_log(crypt, MONGOCRYPT_LOG_LEVEL_TRACE, "exit (%s:%d)", BSON_FUNC, __LINE__); \ - return; \ - } while (0) - -#define CRYPT_RETURN(log, x) \ - do { \ - _mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "return (%s:%d)", BSON_FUNC, __LINE__); \ - return (x); \ - } while (0) - -#define CRYPT_GOTO(log, x) \ - do { \ - _mongocrypt_log(log, MONGOCRYPT_LOG_LEVEL_TRACE, "goto (%s:%d)", BSON_FUNC, __LINE__); \ - goto x; \ - } while (0) - -#else - #define CRYPT_TRACEF(log, fmt, ...) #define CRYPT_TRACE(log, msg) #define CRYPT_ENTRY(log) @@ -74,6 +44,4 @@ void _mongocrypt_log_set_fn(_mongocrypt_log_t *log, mongocrypt_log_fn_t fn, void #define CRYPT_RETURN(log, x) return (x); #define CRYPT_GOTO(log, x) goto x; -#endif /* MONGOCRYPT_ENABLE_TRACE */ - #endif /* MONGOCRYPT_LOG_PRIVATE_H */ diff --git a/src/mongocrypt-log.c b/src/mongocrypt-log.c index 072104aba..310ffb9e5 100644 --- a/src/mongocrypt-log.c +++ b/src/mongocrypt-log.c @@ -26,9 +26,6 @@ void _mongocrypt_log_init(_mongocrypt_log_t *log) { _mongocrypt_mutex_init(&log->mutex); /* Initially, no log function is set. */ _mongocrypt_log_set_fn(log, NULL, NULL); -#ifdef MONGOCRYPT_ENABLE_TRACE - log->trace_enabled = (getenv("MONGOCRYPT_TRACE") != NULL); -#endif } void _mongocrypt_log_cleanup(_mongocrypt_log_t *log) { @@ -47,7 +44,6 @@ void _mongocrypt_stdout_log_fn(mongocrypt_log_level_t level, const char *message case MONGOCRYPT_LOG_LEVEL_ERROR: printf("ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: printf("WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: printf("INFO"); break; - case MONGOCRYPT_LOG_LEVEL_TRACE: printf("TRACE"); break; default: printf("UNKNOWN"); break; } printf(" %s\n", message); @@ -69,10 +65,6 @@ void _mongocrypt_log(_mongocrypt_log_t *log, mongocrypt_log_level_t level, const BSON_ASSERT_PARAM(log); BSON_ASSERT_PARAM(format); - if (level == MONGOCRYPT_LOG_LEVEL_TRACE && !log->trace_enabled) { - return; - } - va_start(args, format); message = bson_strdupv_printf(format, args); va_end(args); diff --git a/src/mongocrypt.h b/src/mongocrypt.h index 6a3f12ad5..5e972f84f 100644 --- a/src/mongocrypt.h +++ b/src/mongocrypt.h @@ -255,7 +255,6 @@ typedef enum { MONGOCRYPT_LOG_LEVEL_ERROR = 1, MONGOCRYPT_LOG_LEVEL_WARNING = 2, MONGOCRYPT_LOG_LEVEL_INFO = 3, - MONGOCRYPT_LOG_LEVEL_TRACE = 4 } mongocrypt_log_level_t; /** From 18d7ca57a9f5935cb13acaa242616a101ebd58f5 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Fri, 5 Sep 2025 10:43:32 -0400 Subject: [PATCH 4/7] Formatting fix --- src/mongocrypt-ctx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mongocrypt-ctx.c b/src/mongocrypt-ctx.c index ccbc3ed2e..8853933f2 100644 --- a/src/mongocrypt-ctx.c +++ b/src/mongocrypt-ctx.c @@ -76,7 +76,7 @@ bool mongocrypt_ctx_setopt_key_id(mongocrypt_ctx_t *ctx, mongocrypt_binary_t *ke if (!ctx) { return false; } - + return _set_binary_opt(ctx, key_id, &ctx->opts.key_id, BSON_SUBTYPE_UUID); } From 4592e58345b0b57485039cbfd5021dd65e087221 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Fri, 5 Sep 2025 11:08:49 -0400 Subject: [PATCH 5/7] Keep ENABLE_TRACE defined as 0 --- src/mongocrypt-config.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mongocrypt-config.h.in b/src/mongocrypt-config.h.in index 8b0e7b948..e123c6214 100644 --- a/src/mongocrypt-config.h.in +++ b/src/mongocrypt-config.h.in @@ -72,6 +72,12 @@ #endif +/* + * MONGOCRYPT_ENABLE_TRACE is automatically disabled as + * trace logging is no longer supported. + */ +#define MONGOCRYPT_ENABLE_TRACE 0 + /* clang-format on */ #endif /* MONGOCRYPT_CONFIG_H */ From 3c4ae9af31ef3cb5c027058a91989cd2bd317294 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Fri, 5 Sep 2025 11:35:03 -0400 Subject: [PATCH 6/7] Keep LOG_LEVEL_TRACE in public API --- src/mongocrypt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mongocrypt.h b/src/mongocrypt.h index 5e972f84f..6a3f12ad5 100644 --- a/src/mongocrypt.h +++ b/src/mongocrypt.h @@ -255,6 +255,7 @@ typedef enum { MONGOCRYPT_LOG_LEVEL_ERROR = 1, MONGOCRYPT_LOG_LEVEL_WARNING = 2, MONGOCRYPT_LOG_LEVEL_INFO = 3, + MONGOCRYPT_LOG_LEVEL_TRACE = 4 } mongocrypt_log_level_t; /** From df71018117041a60abab2df51c953eb8daedab31 Mon Sep 17 00:00:00 2001 From: Julia-Garland Date: Fri, 5 Sep 2025 11:53:53 -0400 Subject: [PATCH 7/7] Keep LOG_LEVEL_TRACE in switch stmnts --- src/mongocrypt-log.c | 1 + test/example-state-machine.c | 1 + test/util/util.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/mongocrypt-log.c b/src/mongocrypt-log.c index 310ffb9e5..3b635f322 100644 --- a/src/mongocrypt-log.c +++ b/src/mongocrypt-log.c @@ -44,6 +44,7 @@ void _mongocrypt_stdout_log_fn(mongocrypt_log_level_t level, const char *message case MONGOCRYPT_LOG_LEVEL_ERROR: printf("ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: printf("WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: printf("INFO"); break; + case MONGOCRYPT_LOG_LEVEL_TRACE: printf("TRACE"); break; /* UNUSED */ default: printf("UNKNOWN"); break; } printf(" %s\n", message); diff --git a/test/example-state-machine.c b/test/example-state-machine.c index 4f61bfbd1..16b3f2f3d 100644 --- a/test/example-state-machine.c +++ b/test/example-state-machine.c @@ -28,6 +28,7 @@ static void _log_to_stderr(mongocrypt_log_level_t level, const char *message, ui case MONGOCRYPT_LOG_LEVEL_ERROR: fprintf(stderr, "ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: fprintf(stderr, "WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: fprintf(stderr, "INFO"); break; + case MONGOCRYPT_LOG_LEVEL_TRACE: fprintf(stderr, "TRACE"); break; /* UNUSED */ default: fprintf(stderr, "UNKNOWN"); break; } fprintf(stderr, " %s\n", message); diff --git a/test/util/util.c b/test/util/util.c index 42904e658..ee21cf7c2 100644 --- a/test/util/util.c +++ b/test/util/util.c @@ -60,6 +60,7 @@ void _log_to_stdout(mongocrypt_log_level_t level, const char *message, uint32_t case MONGOCRYPT_LOG_LEVEL_ERROR: printf("ERROR"); break; case MONGOCRYPT_LOG_LEVEL_WARNING: printf("WARNING"); break; case MONGOCRYPT_LOG_LEVEL_INFO: printf("INFO"); break; + case MONGOCRYPT_LOG_LEVEL_TRACE: printf("TRACE"); break; /* UNUSED */ default: printf("?????"); break; } printf(" %s\n", message);