diff --git a/.evergreen/config_generator/components/funcs/install_c_driver.py b/.evergreen/config_generator/components/funcs/install_c_driver.py index cd5899b499..b1e5bfa507 100644 --- a/.evergreen/config_generator/components/funcs/install_c_driver.py +++ b/.evergreen/config_generator/components/funcs/install_c_driver.py @@ -12,7 +12,9 @@ # - the version of pkg:github/mongodb/mongo-c-driver in etc/purls.txt # - the default value of --c-driver-build-ref in etc/make_release.py # Only LIBMONGOC_DOWNLOAD_VERSION needs to be updated when pinning to an unreleased commit. -MONGOC_VERSION_MINIMUM = '1.28.0' +# If pinning to an unreleased commit, create a "Blocked" JIRA ticket with +# a "depends on" link to the appropriate C Driver version release ticket. +MONGOC_VERSION_MINIMUM = '1.29.0' class InstallCDriver(Function): diff --git a/.evergreen/generated_configs/functions.yml b/.evergreen/generated_configs/functions.yml index a98ac23d5b..b98a419381 100644 --- a/.evergreen/generated_configs/functions.yml +++ b/.evergreen/generated_configs/functions.yml @@ -307,7 +307,7 @@ functions: type: setup params: updates: - - { key: mongoc_version_minimum, value: 1.28.0 } + - { key: mongoc_version_minimum, value: 1.29.0 } - command: subprocess.exec type: setup params: diff --git a/CHANGELOG.md b/CHANGELOG.md index fab05a10a3..0a9e744b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu ## Changed +- Bump the minimum required C Driver version to [1.29.0](https://github.com/mongodb/mongo-c-driver/releases/tag/1.29.0). - CMake option `ENABLE_TESTS` is now `OFF` by default. - Set `ENABLE_TEST=ON` to re-enable building test targets. - Set `BUILD_TESTING=ON` to include test targets in the "all" target when `ENABLE_TESTS=ON` (since 3.9.0, `OFF` by default). diff --git a/CMakeLists.txt b/CMakeLists.txt index e7ab622e3f..d2af682b4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,12 +49,12 @@ else() endif() # Also update etc/purls.txt. -set(LIBBSON_REQUIRED_VERSION 1.28.0) +set(LIBBSON_REQUIRED_VERSION 1.29.0) set(LIBBSON_REQUIRED_ABI_VERSION 1.0) # Also update etc/purls.txt. -set(LIBMONGOC_REQUIRED_VERSION 1.28.0) -set(LIBMONGOC_DOWNLOAD_VERSION d934cd5de55af65220816e4fd01ce3f9c0ef1cd4) # TODO: update to 1.29.0 once it is released. +set(LIBMONGOC_REQUIRED_VERSION 1.29.0) +set(LIBMONGOC_DOWNLOAD_VERSION 1.29.0) set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) diff --git a/etc/augmented.sbom.json b/etc/augmented.sbom.json index 16efc9eed8..073dbceff4 100644 --- a/etc/augmented.sbom.json +++ b/etc/augmented.sbom.json @@ -1,16 +1,16 @@ { "components": [ { - "bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0", + "bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0", "copyright": "Copyright 2009-present MongoDB, Inc.", "externalReferences": [ { "type": "distribution", - "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz" + "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz" }, { "type": "website", - "url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0" + "url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0" } ], "group": "mongodb", @@ -22,18 +22,18 @@ } ], "name": "mongo-c-driver", - "purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0", + "purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0", "type": "library", - "version": "v1.28.0" + "version": "v1.29.0" } ], "dependencies": [ { - "ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0" + "ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0" } ], "metadata": { - "timestamp": "2024-11-04T17:45:42.970888+00:00", + "timestamp": "2024-11-19T18:14:12.160074+00:00", "tools": [ { "externalReferences": [ @@ -77,7 +77,7 @@ ] }, "serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301", - "version": 4, + "version": 5, "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", "bomFormat": "CycloneDX", "specVersion": "1.5", diff --git a/etc/cyclonedx.sbom.json b/etc/cyclonedx.sbom.json index 16efc9eed8..073dbceff4 100644 --- a/etc/cyclonedx.sbom.json +++ b/etc/cyclonedx.sbom.json @@ -1,16 +1,16 @@ { "components": [ { - "bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0", + "bom-ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0", "copyright": "Copyright 2009-present MongoDB, Inc.", "externalReferences": [ { "type": "distribution", - "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.28.0.tar.gz" + "url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.29.0.tar.gz" }, { "type": "website", - "url": "https://github.com/mongodb/mongo-c-driver/tree/v1.28.0" + "url": "https://github.com/mongodb/mongo-c-driver/tree/v1.29.0" } ], "group": "mongodb", @@ -22,18 +22,18 @@ } ], "name": "mongo-c-driver", - "purl": "pkg:github/mongodb/mongo-c-driver@v1.28.0", + "purl": "pkg:github/mongodb/mongo-c-driver@v1.29.0", "type": "library", - "version": "v1.28.0" + "version": "v1.29.0" } ], "dependencies": [ { - "ref": "pkg:github/mongodb/mongo-c-driver@v1.28.0" + "ref": "pkg:github/mongodb/mongo-c-driver@v1.29.0" } ], "metadata": { - "timestamp": "2024-11-04T17:45:42.970888+00:00", + "timestamp": "2024-11-19T18:14:12.160074+00:00", "tools": [ { "externalReferences": [ @@ -77,7 +77,7 @@ ] }, "serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301", - "version": 4, + "version": 5, "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json", "bomFormat": "CycloneDX", "specVersion": "1.5", diff --git a/etc/make_release.py b/etc/make_release.py index f2802bfe73..d6cdb6c2f1 100755 --- a/etc/make_release.py +++ b/etc/make_release.py @@ -88,7 +88,7 @@ show_default=True, help='The remote reference which points to the mongodb/mongo-cxx-driver repo') @click.option('--c-driver-build-ref', - default='1.28.0', + default='1.29.0', show_default=True, help='When building the C driver, build at this Git reference') @click.option('--with-c-driver', diff --git a/etc/purls.txt b/etc/purls.txt index 087b355b61..e3f180b5d0 100644 --- a/etc/purls.txt +++ b/etc/purls.txt @@ -6,4 +6,4 @@ # re-generate the SBOM JSON file! # libbson and libmongoc are obtained via cmake/FetchMongoC.cmake. -pkg:github/mongodb/mongo-c-driver@v1.28.0 +pkg:github/mongodb/mongo-c-driver@v1.29.0 diff --git a/etc/releasing.md b/etc/releasing.md index f2035449da..418ab5cdcf 100644 --- a/etc/releasing.md +++ b/etc/releasing.md @@ -160,7 +160,9 @@ Generate an updated Augmented SBOM as described below. Ensure the `silk-check-augmented-sbom` task is passing on Evergreen for the relevant release branch. If it is passing, nothing needs to be done (unless the SBOM Lite was updated as described above). - If the `silk-check-augmented-sbom` task was failing, update the Augmented SBOM document using the following command(s): +#### Regular Update + +Update the Augmented SBOM document using the following command(s): ```bash # Artifactory and Silk credentials. @@ -189,6 +191,44 @@ Update `etc/third_party_vulnerabilities.md` with any updates to new or known vul Commit the latest version of the Augmented SBOM document into the repo as `etc/augmented.sbom.json`. The Augmented SBOM document does not need to be updated if the `silk-check-augmented-sbom` was not failing (in which case the only changes present would a version bump or timestamp update). +#### Instant Update + +If the Augmented SBOM has not yet been updated in time for a release, a temporary Silk Asset Group may be used instead: + +```bash +# Artifactory and Silk credentials. +. $HOME/.secrets/artifactory-creds.txt +. $HOME/.secrets/silk-creds.txt + +# Name of the temporary Silk Asset Group. Do NOT use an existing Silk Asset Group! +asset_group_id="mongo-cxx-driver-X.Y.Z-tmp" + +# Output: "Login succeeded!" +podman login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}" + +# Ensure latest version of SilkBomb is being used. +podman pull artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 + +# Common flags to podman. +silkbomb_flags=( + --env-file "$HOME/.secrets/silk-creds.txt" + -it --rm -v "$(pwd):/pwd" + artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 +) + +# Create a new and temporary Silk Asset Group. +podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd create --silk-asset-group "${asset_group_id:?}" --name "${asset_group_id:?}" + +# Upload the SBOM Lite. +podman run "${silkbomb_flags[@]:?}" upload --silk-asset-group "${asset_group_id:?}" -i /pwd/etc/cyclonedx.sbom.json -o /pwd/etc/cyclonedx.sbom.json + +# Download the Augmented SBOM. +podman run "${silkbomb_flags[@]:?}" download --silk-asset-group "${asset_group_id:?}" -o /pwd/etc/augmented.sbom.json + +# Remove the temporary Silk Asset Group. +podman run "${silkbomb_flags[@]:?}" asset-group --asset-cmd delete --silk-asset-group "${asset_group_id:?}" +``` + ### Check Snyk Inspect the list of projects in the latest report for the `mongodb/mongo-cxx-driver` target in [Snyk](https://app.snyk.io/org/dev-prod/). diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp index 87001ab831..1501068856 100644 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp +++ b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/json.cpp @@ -36,7 +36,7 @@ void bson_free_deleter(std::uint8_t* ptr) { bson_free(ptr); } -std::string to_json_helper(document::view view, decltype(bson_as_json) converter) { +std::string to_json_helper(document::view view, decltype(bson_as_legacy_extended_json) converter) { bson_t bson; if (!bson_init_static(&bson, view.data(), view.length())) { @@ -61,7 +61,7 @@ std::string to_json_helper(document::view view, decltype(bson_as_json) converter std::string to_json(document::view view, ExtendedJsonMode mode) { switch (mode) { case ExtendedJsonMode::k_legacy: - return to_json_helper(view, bson_as_json); + return to_json_helper(view, bson_as_legacy_extended_json); case ExtendedJsonMode::k_relaxed: return to_json_helper(view, bson_as_relaxed_extended_json); @@ -76,7 +76,7 @@ std::string to_json(document::view view, ExtendedJsonMode mode) { std::string to_json(array::view view, ExtendedJsonMode mode) { switch (mode) { case ExtendedJsonMode::k_legacy: - return to_json_helper(view, bson_array_as_json); + return to_json_helper(view, bson_array_as_legacy_extended_json); case ExtendedJsonMode::k_relaxed: return to_json_helper(view, bson_array_as_relaxed_extended_json); diff --git a/src/mongocxx/test/spec/unified_tests/runner.cpp b/src/mongocxx/test/spec/unified_tests/runner.cpp index b2558d6604..d3c024be7d 100644 --- a/src/mongocxx/test/spec/unified_tests/runner.cpp +++ b/src/mongocxx/test/spec/unified_tests/runner.cpp @@ -866,46 +866,59 @@ void assert_error(const mongocxx::operation_exception& exception, } if (const auto is_client_error = expect_error["isClientError"]) { - if (std::strstr(exception.what(), "Snapshot reads require MongoDB 5.0 or later") != - nullptr) { - // Original error: { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE } - // Do not assert a server-side error. - // The C++ driver throws this error as a server-side error operation_exception. - // Remove this special case as part of CXX-2377. - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "The selected server does not support hint for") != - nullptr) { - // Original error: { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION } - // Do not assert a server-side error. - // The C++ driver throws this error as a server-side error operation_exception. - // Remove this special case as part of CXX-2377. - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "Error in KMS response") != nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), - "keyMaterial should have length 96, but has length 84") != nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "expected UTF-8 key") != nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "Unexpected field: 'invalid'") != nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "Failed to resolve kms.invalid.amazonaws.com") != - nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr( - exception.what(), - "The ciphertext refers to a customer master key that does not exist") != - nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), "does not exist") != nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (std::strstr(exception.what(), - "Failed to resolve invalid-vault-csfle.vault.azure.net") != - nullptr) { - REQUIRE(is_client_error.get_bool()); - } else if (is_client_error.get_bool()) { - // An operation_exception represents a server-side error. - REQUIRE(!is_client_error.get_bool()); + // An explicit list of client-side errors. We do not yet have a reliable and consistent + // method to distinguish client-side errors from server-side errors. (CXX-2377) + static const bsoncxx::stdx::string_view patterns[] = { + // { MONGOC_ERROR_CLIENT, MONGOC_ERROR_CLIENT_SESSION_FAILURE } + // mongoc: mongoc_cmd_parts_assemble + "Snapshot reads require MongoDB 5.0 or later", + + // { MONGOC_ERROR_COMMAND, MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION } + // mongoc: mongoc_collection_find_and_modify_with_opts, + // _mongoc_write_command_execute_idl + "The selected server does not support hint for", + + // { MONGOC_ERROR_STREAM, MONGOC_ERROR_STREAM_NAME_RESOLUTION } + // mongoc: mongoc_client_connect_tcp, mongoc_topology_scanner_node_setup_tcp + "Failed to resolve ", + + // { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE } + // libmongocrypt: mongocrypt_kms_ctx_feed + "Error in KMS response", + + // { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE } + // libmongocrypt: mongocrypt_ctx_setopt_key_material + "keyMaterial should have length 96, but has length 84", + + // { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE } + // libmongocrypt: _mongocrypt_parse_optional_utf8, _mongocrypt_parse_required_utf8 + "expected UTF-8 key", + + // { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE } + // libmongocrypt: _mongocrypt_check_allowed_fields + "Unexpected field: 'invalid'", + + // { MONGOCRYPT_STATUS_ERROR_CLIENT, MONGOCRYPT_GENERIC_ERROR_CODE } + // libmongocrypt: _kms_done + "key material not expected length", + }; + + const bsoncxx::stdx::string_view message = exception.what(); + + const auto iter = std::find_if(std::begin(patterns), + std::end(patterns), + [message](bsoncxx::stdx::string_view pattern) { + return message.find(pattern) != message.npos; + }); + + if (iter != std::end(patterns)) { + // Treat this as a client-side error. + const auto pattern = *iter; + CAPTURE(pattern); + REQUIRE(is_client_error.get_bool().value); + } else { + // Treat this as a server-side error. + REQUIRE(!is_client_error.get_bool().value); } }