mongo 2.22.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/mongo_console +0 -1
- data/lib/mongo/active_support.rb +1 -2
- data/lib/mongo/address/ipv4.rb +3 -6
- data/lib/mongo/address/ipv6.rb +6 -10
- data/lib/mongo/address/unix.rb +1 -4
- data/lib/mongo/address/validator.rb +16 -28
- data/lib/mongo/address.rb +30 -40
- data/lib/mongo/auth/aws/conversation.rb +6 -10
- data/lib/mongo/auth/aws/credentials.rb +0 -1
- data/lib/mongo/auth/aws/credentials_cache.rb +0 -1
- data/lib/mongo/auth/aws/credentials_retriever.rb +45 -59
- data/lib/mongo/auth/aws/request.rb +20 -35
- data/lib/mongo/auth/aws.rb +1 -2
- data/lib/mongo/auth/base.rb +20 -29
- data/lib/mongo/auth/conversation_base.rb +14 -18
- data/lib/mongo/auth/cr/conversation.rb +0 -3
- data/lib/mongo/auth/cr.rb +1 -4
- data/lib/mongo/auth/credential_cache.rb +0 -2
- data/lib/mongo/auth/gssapi/conversation.rb +3 -8
- data/lib/mongo/auth/gssapi.rb +1 -4
- data/lib/mongo/auth/ldap/conversation.rb +0 -3
- data/lib/mongo/auth/ldap.rb +1 -4
- data/lib/mongo/auth/roles.rb +16 -19
- data/lib/mongo/auth/sasl_conversation_base.rb +7 -11
- data/lib/mongo/auth/scram/conversation.rb +2 -5
- data/lib/mongo/auth/scram.rb +5 -10
- data/lib/mongo/auth/scram256/conversation.rb +2 -5
- data/lib/mongo/auth/scram256.rb +1 -3
- data/lib/mongo/auth/scram_conversation_base.rb +18 -24
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +17 -18
- data/lib/mongo/auth/stringprep/tables.rb +2209 -2210
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +36 -38
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1142 -1150
- data/lib/mongo/auth/stringprep.rb +9 -12
- data/lib/mongo/auth/user/view.rb +3 -5
- data/lib/mongo/auth/user.rb +14 -24
- data/lib/mongo/auth/x509/conversation.rb +0 -3
- data/lib/mongo/auth/x509.rb +7 -9
- data/lib/mongo/auth.rb +18 -30
- data/lib/mongo/background_thread.rb +9 -17
- data/lib/mongo/bson.rb +0 -2
- data/lib/mongo/bulk_write/combineable.rb +0 -3
- data/lib/mongo/bulk_write/ordered_combiner.rb +1 -3
- data/lib/mongo/bulk_write/result.rb +11 -16
- data/lib/mongo/bulk_write/result_combiner.rb +9 -12
- data/lib/mongo/bulk_write/transformable.rb +16 -19
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -3
- data/lib/mongo/bulk_write/validatable.rb +11 -18
- data/lib/mongo/bulk_write.rb +76 -91
- data/lib/mongo/caching_cursor.rb +2 -7
- data/lib/mongo/client.rb +267 -276
- data/lib/mongo/client_encryption.rb +4 -5
- data/lib/mongo/cluster/periodic_executor.rb +2 -5
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +21 -29
- data/lib/mongo/cluster/reapers/socket_reaper.rb +1 -6
- data/lib/mongo/cluster/sdam_flow.rb +136 -159
- data/lib/mongo/cluster/topology/base.rb +15 -18
- data/lib/mongo/cluster/topology/load_balanced.rb +24 -14
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +3 -6
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +20 -23
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +0 -2
- data/lib/mongo/cluster/topology/sharded.rb +19 -9
- data/lib/mongo/cluster/topology/single.rb +24 -14
- data/lib/mongo/cluster/topology/unknown.rb +20 -10
- data/lib/mongo/cluster/topology.rb +29 -25
- data/lib/mongo/cluster.rb +152 -184
- data/lib/mongo/cluster_time.rb +14 -31
- data/lib/mongo/collection/helpers.rb +5 -8
- data/lib/mongo/collection/view/aggregation/behavior.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +10 -12
- data/lib/mongo/collection/view/builder/aggregation.rb +6 -9
- data/lib/mongo/collection/view/builder/map_reduce.rb +18 -17
- data/lib/mongo/collection/view/builder.rb +0 -1
- data/lib/mongo/collection/view/change_stream/retryable.rb +3 -8
- data/lib/mongo/collection/view/change_stream.rb +59 -58
- data/lib/mongo/collection/view/explainable.rb +11 -20
- data/lib/mongo/collection/view/immutable.rb +1 -3
- data/lib/mongo/collection/view/iterable.rb +44 -35
- data/lib/mongo/collection/view/map_reduce.rb +20 -25
- data/lib/mongo/collection/view/readable.rb +96 -94
- data/lib/mongo/collection/view/writable.rb +104 -114
- data/lib/mongo/collection/view.rb +11 -8
- data/lib/mongo/collection.rb +103 -106
- data/lib/mongo/condition_variable.rb +4 -4
- data/lib/mongo/config/options.rb +0 -3
- data/lib/mongo/config/validators/option.rb +3 -5
- data/lib/mongo/config.rb +6 -4
- data/lib/mongo/crypt/auto_decryption_context.rb +9 -3
- data/lib/mongo/crypt/auto_encrypter.rb +34 -43
- data/lib/mongo/crypt/auto_encryption_context.rb +0 -3
- data/lib/mongo/crypt/binary.rb +5 -9
- data/lib/mongo/crypt/binding.rb +150 -156
- data/lib/mongo/crypt/context.rb +20 -17
- data/lib/mongo/crypt/data_key_context.rb +2 -7
- data/lib/mongo/crypt/encryption_io.rb +29 -39
- data/lib/mongo/crypt/explicit_decryption_context.rb +9 -3
- data/lib/mongo/crypt/explicit_encrypter.rb +1 -1
- data/lib/mongo/crypt/explicit_encryption_context.rb +19 -30
- data/lib/mongo/crypt/explicit_encryption_expression_context.rb +0 -2
- data/lib/mongo/crypt/handle.rb +42 -48
- data/lib/mongo/crypt/hooks.rb +12 -15
- data/lib/mongo/crypt/kms/aws/credentials.rb +12 -16
- data/lib/mongo/crypt/kms/aws/master_document.rb +6 -9
- data/lib/mongo/crypt/kms/aws.rb +0 -2
- data/lib/mongo/crypt/kms/azure/credentials_retriever.rb +2 -7
- data/lib/mongo/crypt/kms/azure/master_document.rb +15 -19
- data/lib/mongo/crypt/kms/azure.rb +0 -1
- data/lib/mongo/crypt/kms/credentials.rb +13 -27
- data/lib/mongo/crypt/kms/gcp/credentials.rb +12 -14
- data/lib/mongo/crypt/kms/gcp/credentials_retriever.rb +7 -9
- data/lib/mongo/crypt/kms/gcp/master_document.rb +12 -16
- data/lib/mongo/crypt/kms/gcp.rb +0 -2
- data/lib/mongo/crypt/kms/kmip/credentials.rb +7 -8
- data/lib/mongo/crypt/kms/kmip/master_document.rb +3 -5
- data/lib/mongo/crypt/kms/kmip.rb +0 -1
- data/lib/mongo/crypt/kms/local/credentials.rb +7 -8
- data/lib/mongo/crypt/kms/local/master_document.rb +2 -6
- data/lib/mongo/crypt/kms/local.rb +0 -1
- data/lib/mongo/crypt/kms/master_key_document.rb +11 -15
- data/lib/mongo/crypt/kms.rb +14 -16
- data/lib/mongo/crypt/kms_context.rb +0 -2
- data/lib/mongo/crypt/rewrap_many_data_key_context.rb +2 -7
- data/lib/mongo/crypt/rewrap_many_data_key_result.rb +2 -4
- data/lib/mongo/crypt/status.rb +12 -14
- data/lib/mongo/crypt.rb +0 -1
- data/lib/mongo/csot_timeout_holder.rb +3 -2
- data/lib/mongo/cursor/kill_spec.rb +7 -10
- data/lib/mongo/cursor.rb +74 -64
- data/lib/mongo/cursor_host.rb +8 -10
- data/lib/mongo/database/view.rb +23 -39
- data/lib/mongo/database.rb +68 -65
- data/lib/mongo/dbref.rb +0 -1
- data/lib/mongo/deprecations.rb +98 -0
- data/lib/mongo/distinguishing_semaphore.rb +0 -1
- data/lib/mongo/error/auth_error.rb +0 -2
- data/lib/mongo/error/bad_load_balancer_target.rb +0 -2
- data/lib/mongo/error/bulk_write_error.rb +7 -10
- data/lib/mongo/error/change_stream_resumable.rb +0 -2
- data/lib/mongo/error/client_closed.rb +0 -2
- data/lib/mongo/error/closed_stream.rb +1 -4
- data/lib/mongo/error/connection_check_out_timeout.rb +3 -6
- data/lib/mongo/error/connection_perished.rb +0 -2
- data/lib/mongo/error/connection_unavailable.rb +0 -2
- data/lib/mongo/error/credential_check_error.rb +0 -2
- data/lib/mongo/error/crypt_error.rb +0 -2
- data/lib/mongo/error/extra_file_chunk.rb +1 -4
- data/lib/mongo/error/failed_string_prep_validation.rb +5 -6
- data/lib/mongo/error/file_not_found.rb +0 -3
- data/lib/mongo/error/handshake_error.rb +0 -2
- data/lib/mongo/error/insufficient_iteration_count.rb +1 -4
- data/lib/mongo/error/internal_driver_error.rb +0 -2
- data/lib/mongo/error/invalid_address.rb +0 -2
- data/lib/mongo/error/invalid_application_name.rb +0 -3
- data/lib/mongo/error/invalid_bulk_operation.rb +1 -4
- data/lib/mongo/error/invalid_bulk_operation_type.rb +1 -4
- data/lib/mongo/error/invalid_collection_name.rb +1 -4
- data/lib/mongo/error/invalid_config_option.rb +0 -3
- data/lib/mongo/error/invalid_cursor_operation.rb +0 -2
- data/lib/mongo/error/invalid_database_name.rb +1 -4
- data/lib/mongo/error/invalid_document.rb +1 -4
- data/lib/mongo/error/invalid_file.rb +0 -3
- data/lib/mongo/error/invalid_file_revision.rb +0 -3
- data/lib/mongo/error/invalid_min_pool_size.rb +0 -3
- data/lib/mongo/error/invalid_nonce.rb +0 -3
- data/lib/mongo/error/invalid_read_concern.rb +2 -4
- data/lib/mongo/error/invalid_read_option.rb +0 -3
- data/lib/mongo/error/invalid_replacement_document.rb +2 -5
- data/lib/mongo/error/invalid_server_auth_host.rb +0 -2
- data/lib/mongo/error/invalid_server_auth_response.rb +0 -2
- data/lib/mongo/error/invalid_server_preference.rb +7 -16
- data/lib/mongo/error/invalid_session.rb +1 -4
- data/lib/mongo/error/invalid_signature.rb +0 -3
- data/lib/mongo/error/invalid_transaction_operation.rb +5 -8
- data/lib/mongo/error/invalid_txt_record.rb +0 -2
- data/lib/mongo/error/invalid_update_document.rb +2 -5
- data/lib/mongo/error/invalid_uri.rb +1 -4
- data/lib/mongo/error/invalid_write_concern.rb +2 -5
- data/lib/mongo/error/kms_error.rb +0 -2
- data/lib/mongo/error/labelable.rb +0 -3
- data/lib/mongo/error/lint_error.rb +0 -2
- data/lib/mongo/error/max_bson_size.rb +8 -11
- data/lib/mongo/error/max_message_size.rb +2 -5
- data/lib/mongo/error/mismatched_domain.rb +0 -2
- data/lib/mongo/error/missing_connection.rb +0 -2
- data/lib/mongo/error/missing_file_chunk.rb +0 -3
- data/lib/mongo/error/missing_password.rb +0 -2
- data/lib/mongo/error/missing_resume_token.rb +1 -4
- data/lib/mongo/error/missing_scram_server_signature.rb +2 -4
- data/lib/mongo/error/missing_service_id.rb +0 -2
- data/lib/mongo/error/mongocryptd_spawn_error.rb +0 -2
- data/lib/mongo/error/multi_index_drop.rb +0 -3
- data/lib/mongo/error/need_primary_server.rb +0 -2
- data/lib/mongo/error/no_server_available.rb +3 -8
- data/lib/mongo/error/no_service_connection_available.rb +1 -3
- data/lib/mongo/error/no_srv_records.rb +0 -2
- data/lib/mongo/error/notable.rb +8 -16
- data/lib/mongo/error/operation_failure.rb +22 -35
- data/lib/mongo/error/parser.rb +33 -75
- data/lib/mongo/error/pool_cleared_error.rb +1 -3
- data/lib/mongo/error/pool_closed_error.rb +0 -3
- data/lib/mongo/error/pool_error.rb +0 -3
- data/lib/mongo/error/pool_paused_error.rb +0 -2
- data/lib/mongo/error/raise_original_error.rb +1 -3
- data/lib/mongo/error/read_write_retryable.rb +14 -17
- data/lib/mongo/error/sdam_error_detection.rb +3 -5
- data/lib/mongo/error/server_api_conflict.rb +0 -2
- data/lib/mongo/error/server_certificate_revoked.rb +0 -2
- data/lib/mongo/error/server_not_usable.rb +0 -2
- data/lib/mongo/error/session_ended.rb +1 -3
- data/lib/mongo/error/session_not_materialized.rb +1 -3
- data/lib/mongo/error/sessions_not_supported.rb +1 -4
- data/lib/mongo/error/snapshot_session_invalid_server_version.rb +1 -4
- data/lib/mongo/error/snapshot_session_transaction_prohibited.rb +1 -4
- data/lib/mongo/error/socket_error.rb +0 -2
- data/lib/mongo/error/socket_timeout_error.rb +0 -2
- data/lib/mongo/error/transactions_not_supported.rb +3 -6
- data/lib/mongo/error/unchangeable_collection_option.rb +1 -4
- data/lib/mongo/error/unexpected_chunk_length.rb +0 -3
- data/lib/mongo/error/unexpected_response.rb +1 -4
- data/lib/mongo/error/unknown_payload_type.rb +0 -3
- data/lib/mongo/error/unmet_dependency.rb +0 -2
- data/lib/mongo/error/unsupported_array_filters.rb +3 -24
- data/lib/mongo/error/unsupported_collation.rb +3 -24
- data/lib/mongo/error/unsupported_features.rb +0 -2
- data/lib/mongo/error/unsupported_message_type.rb +0 -2
- data/lib/mongo/error/unsupported_option.rb +19 -21
- data/lib/mongo/error/write_retryable.rb +0 -2
- data/lib/mongo/error.rb +10 -24
- data/lib/mongo/event/base.rb +0 -2
- data/lib/mongo/event/listeners.rb +0 -3
- data/lib/mongo/event/publisher.rb +0 -3
- data/lib/mongo/event/subscriber.rb +0 -4
- data/lib/mongo/event.rb +4 -6
- data/lib/mongo/grid/file/chunk.rb +7 -10
- data/lib/mongo/grid/file/info.rb +20 -24
- data/lib/mongo/grid/file.rb +7 -8
- data/lib/mongo/grid/fs_bucket.rb +40 -48
- data/lib/mongo/grid/stream/read.rb +25 -35
- data/lib/mongo/grid/stream/write.rb +17 -22
- data/lib/mongo/grid/stream.rb +2 -4
- data/lib/mongo/grid.rb +0 -1
- data/lib/mongo/id.rb +0 -1
- data/lib/mongo/index/view.rb +68 -58
- data/lib/mongo/index.rb +7 -10
- data/lib/mongo/lint.rb +31 -37
- data/lib/mongo/loggable.rb +5 -8
- data/lib/mongo/logger.rb +1 -7
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +0 -2
- data/lib/mongo/monitoring/command_log_subscriber.rb +25 -33
- data/lib/mongo/monitoring/event/cmap/base.rb +0 -2
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +0 -3
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +2 -5
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +0 -3
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +1 -4
- data/lib/mongo/monitoring/event/cmap/pool_ready.rb +1 -4
- data/lib/mongo/monitoring/event/cmap.rb +0 -1
- data/lib/mongo/monitoring/event/command_failed.rb +5 -9
- data/lib/mongo/monitoring/event/command_started.rb +8 -12
- data/lib/mongo/monitoring/event/command_succeeded.rb +7 -15
- data/lib/mongo/monitoring/event/secure.rb +15 -20
- data/lib/mongo/monitoring/event/server_closed.rb +1 -4
- data/lib/mongo/monitoring/event/server_description_changed.rb +4 -8
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +5 -10
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +1 -4
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +3 -8
- data/lib/mongo/monitoring/event/server_opening.rb +1 -4
- data/lib/mongo/monitoring/event/topology_changed.rb +2 -5
- data/lib/mongo/monitoring/event/topology_closed.rb +1 -4
- data/lib/mongo/monitoring/event/topology_opening.rb +1 -4
- data/lib/mongo/monitoring/event.rb +0 -1
- data/lib/mongo/monitoring/publishable.rb +20 -30
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +0 -2
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +0 -3
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +0 -3
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +0 -3
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +5 -8
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +0 -3
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +0 -3
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +1 -3
- data/lib/mongo/monitoring.rb +38 -39
- data/lib/mongo/operation/aggregate/op_msg.rb +0 -2
- data/lib/mongo/operation/aggregate/result.rb +3 -6
- data/lib/mongo/operation/aggregate.rb +0 -2
- data/lib/mongo/operation/collections_info/result.rb +0 -3
- data/lib/mongo/operation/collections_info.rb +0 -2
- data/lib/mongo/operation/command/op_msg.rb +1 -4
- data/lib/mongo/operation/command.rb +0 -2
- data/lib/mongo/operation/context.rb +13 -16
- data/lib/mongo/operation/count/op_msg.rb +2 -4
- data/lib/mongo/operation/count.rb +0 -2
- data/lib/mongo/operation/create/op_msg.rb +2 -5
- data/lib/mongo/operation/create.rb +4 -2
- data/lib/mongo/operation/create_index/op_msg.rb +3 -7
- data/lib/mongo/operation/create_index.rb +0 -2
- data/lib/mongo/operation/create_user/op_msg.rb +2 -4
- data/lib/mongo/operation/create_user.rb +0 -2
- data/lib/mongo/operation/delete/bulk_result.rb +2 -3
- data/lib/mongo/operation/delete/op_msg.rb +3 -10
- data/lib/mongo/operation/delete/result.rb +0 -3
- data/lib/mongo/operation/delete.rb +1 -5
- data/lib/mongo/operation/distinct/op_msg.rb +2 -5
- data/lib/mongo/operation/distinct.rb +0 -2
- data/lib/mongo/operation/drop/op_msg.rb +0 -2
- data/lib/mongo/operation/drop.rb +0 -2
- data/lib/mongo/operation/drop_database/op_msg.rb +0 -2
- data/lib/mongo/operation/drop_database.rb +0 -2
- data/lib/mongo/operation/drop_index/op_msg.rb +4 -6
- data/lib/mongo/operation/drop_index.rb +0 -2
- data/lib/mongo/operation/explain/op_msg.rb +0 -2
- data/lib/mongo/operation/explain/result.rb +0 -3
- data/lib/mongo/operation/explain.rb +0 -2
- data/lib/mongo/operation/find/builder/command.rb +4 -12
- data/lib/mongo/operation/find/builder/flags.rb +9 -15
- data/lib/mongo/operation/find/builder/modifiers.rb +1 -4
- data/lib/mongo/operation/find/builder.rb +0 -1
- data/lib/mongo/operation/find/op_msg.rb +4 -12
- data/lib/mongo/operation/find/result.rb +0 -3
- data/lib/mongo/operation/find.rb +0 -2
- data/lib/mongo/operation/get_more/command_builder.rb +1 -6
- data/lib/mongo/operation/get_more/op_msg.rb +10 -4
- data/lib/mongo/operation/get_more/result.rb +0 -3
- data/lib/mongo/operation/get_more.rb +0 -2
- data/lib/mongo/operation/indexes/op_msg.rb +0 -2
- data/lib/mongo/operation/indexes/result.rb +1 -5
- data/lib/mongo/operation/indexes.rb +0 -2
- data/lib/mongo/operation/insert/bulk_result.rb +2 -6
- data/lib/mongo/operation/insert/op_msg.rb +7 -6
- data/lib/mongo/operation/insert/result.rb +0 -3
- data/lib/mongo/operation/insert.rb +2 -5
- data/lib/mongo/operation/kill_cursors/command_builder.rb +0 -3
- data/lib/mongo/operation/kill_cursors/op_msg.rb +1 -3
- data/lib/mongo/operation/kill_cursors.rb +0 -2
- data/lib/mongo/operation/list_collections/op_msg.rb +4 -6
- data/lib/mongo/operation/list_collections/result.rb +1 -4
- data/lib/mongo/operation/list_collections.rb +0 -2
- data/lib/mongo/operation/map_reduce/op_msg.rb +0 -2
- data/lib/mongo/operation/map_reduce/result.rb +3 -6
- data/lib/mongo/operation/map_reduce.rb +0 -2
- data/lib/mongo/operation/op_msg_base.rb +0 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -5
- data/lib/mongo/operation/parallel_scan/result.rb +2 -5
- data/lib/mongo/operation/parallel_scan.rb +0 -2
- data/lib/mongo/operation/remove_user/op_msg.rb +2 -4
- data/lib/mongo/operation/remove_user.rb +0 -2
- data/lib/mongo/operation/result.rb +38 -48
- data/lib/mongo/operation/shared/bypass_document_validation.rb +3 -7
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +0 -3
- data/lib/mongo/operation/shared/executable.rb +29 -31
- data/lib/mongo/operation/shared/executable_no_validate.rb +0 -3
- data/lib/mongo/operation/shared/executable_transaction_label.rb +0 -2
- data/lib/mongo/operation/shared/idable.rb +3 -6
- data/lib/mongo/operation/shared/limited.rb +0 -3
- data/lib/mongo/operation/shared/object_id_generator.rb +0 -3
- data/lib/mongo/operation/shared/op_msg_executable.rb +0 -2
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +0 -2
- data/lib/mongo/operation/shared/polymorphic_result.rb +2 -4
- data/lib/mongo/operation/shared/read_preference_supported.rb +10 -15
- data/lib/mongo/operation/shared/response_handling.rb +13 -26
- data/lib/mongo/operation/shared/result/aggregatable.rb +12 -13
- data/lib/mongo/operation/shared/sessions_supported.rb +87 -99
- data/lib/mongo/operation/shared/specifiable.rb +37 -59
- data/lib/mongo/operation/shared/write.rb +12 -17
- data/lib/mongo/operation/shared/write_concern_supported.rb +4 -7
- data/lib/mongo/operation/update/bulk_result.rb +13 -17
- data/lib/mongo/operation/update/op_msg.rb +2 -5
- data/lib/mongo/operation/update/result.rb +5 -5
- data/lib/mongo/operation/update.rb +1 -5
- data/lib/mongo/operation/update_user/op_msg.rb +2 -4
- data/lib/mongo/operation/update_user.rb +0 -2
- data/lib/mongo/operation/users_info/op_msg.rb +2 -4
- data/lib/mongo/operation/users_info/result.rb +1 -4
- data/lib/mongo/operation/users_info.rb +0 -2
- data/lib/mongo/operation/write_command/op_msg.rb +2 -10
- data/lib/mongo/operation/write_command.rb +0 -2
- data/lib/mongo/operation.rb +9 -14
- data/lib/mongo/options/mapper.rb +8 -15
- data/lib/mongo/options/redacted.rb +7 -9
- data/lib/mongo/options.rb +0 -1
- data/lib/mongo/protocol/bit_vector.rb +3 -5
- data/lib/mongo/protocol/caching_hash.rb +2 -7
- data/lib/mongo/protocol/compressed.rb +5 -10
- data/lib/mongo/protocol/get_more.rb +2 -8
- data/lib/mongo/protocol/kill_cursors.rb +2 -8
- data/lib/mongo/protocol/message.rb +103 -105
- data/lib/mongo/protocol/msg.rb +48 -63
- data/lib/mongo/protocol/query.rb +32 -41
- data/lib/mongo/protocol/registry.rb +2 -5
- data/lib/mongo/protocol/reply.rb +10 -16
- data/lib/mongo/protocol/serializers.rb +41 -59
- data/lib/mongo/protocol.rb +0 -1
- data/lib/mongo/query_cache.rb +7 -15
- data/lib/mongo/retryable/backpressure.rb +31 -0
- data/lib/mongo/retryable/base_worker.rb +39 -13
- data/lib/mongo/retryable/read_worker.rb +77 -21
- data/lib/mongo/retryable/retry_policy.rb +59 -0
- data/lib/mongo/retryable/write_worker.rb +155 -56
- data/lib/mongo/retryable.rb +70 -9
- data/lib/mongo/search_index/view.rb +30 -10
- data/lib/mongo/semaphore.rb +0 -1
- data/lib/mongo/server/app_metadata/environment.rb +3 -3
- data/lib/mongo/server/app_metadata/platform.rb +17 -4
- data/lib/mongo/server/app_metadata.rb +4 -5
- data/lib/mongo/server/connection.rb +79 -61
- data/lib/mongo/server/connection_base.rb +43 -53
- data/lib/mongo/server/connection_common.rb +41 -64
- data/lib/mongo/server/connection_pool/generation_manager.rb +6 -11
- data/lib/mongo/server/connection_pool/populator.rb +1 -4
- data/lib/mongo/server/connection_pool.rb +195 -167
- data/lib/mongo/server/description/features.rb +51 -59
- data/lib/mongo/server/description/load_balancer.rb +0 -2
- data/lib/mongo/server/description.rb +117 -138
- data/lib/mongo/server/monitor/app_metadata.rb +3 -4
- data/lib/mongo/server/monitor/connection.rb +28 -35
- data/lib/mongo/server/monitor.rb +65 -60
- data/lib/mongo/server/pending_connection.rb +70 -71
- data/lib/mongo/server/push_monitor/connection.rb +0 -3
- data/lib/mongo/server/push_monitor.rb +21 -29
- data/lib/mongo/server/round_trip_time_calculator.rb +11 -17
- data/lib/mongo/server.rb +62 -94
- data/lib/mongo/server_selector/base.rb +133 -157
- data/lib/mongo/server_selector/nearest.rb +2 -5
- data/lib/mongo/server_selector/primary.rb +1 -5
- data/lib/mongo/server_selector/primary_preferred.rb +2 -6
- data/lib/mongo/server_selector/secondary.rb +2 -6
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -5
- data/lib/mongo/server_selector.rb +3 -4
- data/lib/mongo/session/server_session.rb +6 -7
- data/lib/mongo/session/session_pool.rb +20 -34
- data/lib/mongo/session.rb +334 -199
- data/lib/mongo/socket/ocsp_cache.rb +8 -13
- data/lib/mongo/socket/ocsp_verifier.rb +69 -70
- data/lib/mongo/socket/ssl.rb +44 -43
- data/lib/mongo/socket/tcp.rb +5 -8
- data/lib/mongo/socket/unix.rb +0 -4
- data/lib/mongo/socket.rb +80 -102
- data/lib/mongo/srv/monitor.rb +10 -11
- data/lib/mongo/srv/resolver.rb +15 -24
- data/lib/mongo/srv/result.rb +25 -21
- data/lib/mongo/srv.rb +0 -1
- data/lib/mongo/timeout.rb +4 -11
- data/lib/mongo/topology_version.rb +8 -13
- data/lib/mongo/tracing/open_telemetry/command_tracer.rb +320 -0
- data/lib/mongo/tracing/open_telemetry/operation_tracer.rb +227 -0
- data/lib/mongo/tracing/open_telemetry/tracer.rb +236 -0
- data/lib/mongo/{error/server_api_not_supported.rb → tracing/open_telemetry.rb} +10 -10
- data/lib/mongo/tracing.rb +42 -0
- data/lib/mongo/uri/options_mapper.rb +135 -126
- data/lib/mongo/uri/srv_protocol.rb +34 -42
- data/lib/mongo/uri.rb +95 -139
- data/lib/mongo/utils.rb +5 -12
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern/acknowledged.rb +0 -2
- data/lib/mongo/write_concern/base.rb +6 -6
- data/lib/mongo/write_concern/unacknowledged.rb +0 -2
- data/lib/mongo/write_concern.rb +14 -15
- data/lib/mongo.rb +4 -3
- data/mongo.gemspec +17 -17
- metadata +11 -5
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +0 -32
- data/lib/mongo/operation/shared/validatable.rb +0 -87
data/lib/mongo/crypt/binding.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# rubocop:todo all
|
|
3
2
|
|
|
4
3
|
# Copyright (C) 2019-2020 MongoDB Inc.
|
|
5
4
|
#
|
|
@@ -34,9 +33,9 @@ unless ENV['LIBMONGOCRYPT_PATH']
|
|
|
34
33
|
# JRuby 9.3.2.0 replaces a LoadError with our custom message with a
|
|
35
34
|
# generic NameError, when this load is attempted as part of autoloading
|
|
36
35
|
# process. JRuby 9.2.20.0 propagates LoadError as expected.
|
|
37
|
-
raise LoadError,
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
raise LoadError, 'Cannot load Mongo::Crypt::Binding because there is no path ' +
|
|
37
|
+
'to libmongocrypt specified in the LIBMONGOCRYPT_PATH environment variable ' +
|
|
38
|
+
"and libmongocrypt-helper is not installed: #{e.class}: #{e}"
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
@@ -44,7 +43,6 @@ require 'ffi'
|
|
|
44
43
|
|
|
45
44
|
module Mongo
|
|
46
45
|
module Crypt
|
|
47
|
-
|
|
48
46
|
# @api private
|
|
49
47
|
def reset_autoload
|
|
50
48
|
remove_const(:Binding)
|
|
@@ -63,18 +61,18 @@ module Mongo
|
|
|
63
61
|
ffi_lib ENV['LIBMONGOCRYPT_PATH']
|
|
64
62
|
rescue LoadError => e
|
|
65
63
|
Crypt.reset_autoload
|
|
66
|
-
raise LoadError,
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
raise LoadError, 'Cannot load Mongo::Crypt::Binding because the path to ' +
|
|
65
|
+
'libmongocrypt specified in the LIBMONGOCRYPT_PATH environment variable ' +
|
|
66
|
+
"is invalid: #{ENV['LIBMONGOCRYPT_PATH']}\n\n#{e.class}: #{e.message}"
|
|
69
67
|
end
|
|
70
68
|
else
|
|
71
69
|
begin
|
|
72
70
|
ffi_lib LibmongocryptHelper.libmongocrypt_path
|
|
73
71
|
rescue LoadError => e
|
|
74
72
|
Crypt.reset_autoload
|
|
75
|
-
raise LoadError,
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
raise LoadError, 'Cannot load Mongo::Crypt::Binding because the path to ' +
|
|
74
|
+
'libmongocrypt specified in libmongocrypt-helper ' +
|
|
75
|
+
"is invalid: #{LibmongocryptHelper.libmongocrypt_path}\n\n#{e.class}: #{e.message}"
|
|
78
76
|
end
|
|
79
77
|
end
|
|
80
78
|
|
|
@@ -83,7 +81,7 @@ module Mongo
|
|
|
83
81
|
# will cause a `LoadError`.
|
|
84
82
|
#
|
|
85
83
|
# @api private
|
|
86
|
-
MIN_LIBMONGOCRYPT_VERSION = Gem::Version.new(
|
|
84
|
+
MIN_LIBMONGOCRYPT_VERSION = Gem::Version.new('1.12.0')
|
|
87
85
|
|
|
88
86
|
# @!method self.mongocrypt_version(len)
|
|
89
87
|
# @api private
|
|
@@ -92,7 +90,7 @@ module Mongo
|
|
|
92
90
|
# @param [ FFI::Pointer | nil ] len (out param) An optional pointer to a
|
|
93
91
|
# uint8 that will reference the length of the returned string.
|
|
94
92
|
# @return [ String ] A version string for libmongocrypt.
|
|
95
|
-
attach_function :mongocrypt_version, [:pointer], :string
|
|
93
|
+
attach_function :mongocrypt_version, [ :pointer ], :string
|
|
96
94
|
|
|
97
95
|
# Given a string representing a version number, parses it into a
|
|
98
96
|
# Gem::Version object. This handles the case where the string is not
|
|
@@ -108,7 +106,7 @@ module Mongo
|
|
|
108
106
|
def self.parse_version(version)
|
|
109
107
|
Gem::Version.new(version)
|
|
110
108
|
rescue ArgumentError
|
|
111
|
-
match = version.match(/\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?(-[A-Za-z
|
|
109
|
+
match = version.match(/\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?(-[A-Za-z+\d]+)?\z/)
|
|
112
110
|
raise ArgumentError.new("Malformed version number string #{version}") if match.nil?
|
|
113
111
|
|
|
114
112
|
Gem::Version.new(
|
|
@@ -131,7 +129,7 @@ module Mongo
|
|
|
131
129
|
def self.validate_version(lmc_version)
|
|
132
130
|
if (actual_version = parse_version(lmc_version)) < MIN_LIBMONGOCRYPT_VERSION
|
|
133
131
|
raise LoadError, "libmongocrypt version #{MIN_LIBMONGOCRYPT_VERSION} or above is required, " +
|
|
134
|
-
|
|
132
|
+
"but version #{actual_version} was found."
|
|
135
133
|
end
|
|
136
134
|
end
|
|
137
135
|
|
|
@@ -158,7 +156,7 @@ module Mongo
|
|
|
158
156
|
# mongocrypt_binary_t object.
|
|
159
157
|
attach_function(
|
|
160
158
|
:mongocrypt_binary_new_from_data,
|
|
161
|
-
[
|
|
159
|
+
%i[pointer int],
|
|
162
160
|
:pointer
|
|
163
161
|
)
|
|
164
162
|
|
|
@@ -168,7 +166,7 @@ module Mongo
|
|
|
168
166
|
# Get the pointer to the underlying data for the mongocrypt_binary_t.
|
|
169
167
|
# @param [ FFI::Pointer ] binary A pointer to a mongocrypt_binary_t object.
|
|
170
168
|
# @return [ FFI::Pointer ] A pointer to the data array.
|
|
171
|
-
attach_function :mongocrypt_binary_data, [:pointer], :pointer
|
|
169
|
+
attach_function :mongocrypt_binary_data, [ :pointer ], :pointer
|
|
172
170
|
|
|
173
171
|
# @!method self.mongocrypt_binary_len(binary)
|
|
174
172
|
# @api private
|
|
@@ -176,7 +174,7 @@ module Mongo
|
|
|
176
174
|
# Get the length of the underlying data array.
|
|
177
175
|
# @param [ FFI::Pointer ] binary A pointer to a mongocrypt_binary_t object.
|
|
178
176
|
# @return [ Integer ] The length of the data array.
|
|
179
|
-
attach_function :mongocrypt_binary_len, [:pointer], :int
|
|
177
|
+
attach_function :mongocrypt_binary_len, [ :pointer ], :int
|
|
180
178
|
|
|
181
179
|
def self.get_binary_data_direct(mongocrypt_binary_t)
|
|
182
180
|
mongocrypt_binary_t.get_pointer(0)
|
|
@@ -192,7 +190,7 @@ module Mongo
|
|
|
192
190
|
# Destroy the mongocrypt_binary_t object.
|
|
193
191
|
# @param [ FFI::Pointer ] binary A pointer to a mongocrypt_binary_t object.
|
|
194
192
|
# @return [ nil ] Always nil.
|
|
195
|
-
attach_function :mongocrypt_binary_destroy, [:pointer], :void
|
|
193
|
+
attach_function :mongocrypt_binary_destroy, [ :pointer ], :void
|
|
196
194
|
|
|
197
195
|
# Enum labeling different status types
|
|
198
196
|
enum :status_type, [
|
|
@@ -222,7 +220,7 @@ module Mongo
|
|
|
222
220
|
# @return [ nil ] Always nil.
|
|
223
221
|
attach_function(
|
|
224
222
|
:mongocrypt_status_set,
|
|
225
|
-
[
|
|
223
|
+
%i[pointer status_type int string int],
|
|
226
224
|
:void
|
|
227
225
|
)
|
|
228
226
|
|
|
@@ -232,7 +230,7 @@ module Mongo
|
|
|
232
230
|
# Indicates the status type.
|
|
233
231
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t.
|
|
234
232
|
# @return [ Symbol ] The status type (as defined by the status_type enum).
|
|
235
|
-
attach_function :mongocrypt_status_type, [:pointer], :status_type
|
|
233
|
+
attach_function :mongocrypt_status_type, [ :pointer ], :status_type
|
|
236
234
|
|
|
237
235
|
# @!method self.mongocrypt_status_code(status)
|
|
238
236
|
# @api private
|
|
@@ -240,7 +238,7 @@ module Mongo
|
|
|
240
238
|
# Return the status error code.
|
|
241
239
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t.
|
|
242
240
|
# @return [ Integer ] The status code.
|
|
243
|
-
attach_function :mongocrypt_status_code, [:pointer], :int
|
|
241
|
+
attach_function :mongocrypt_status_code, [ :pointer ], :int
|
|
244
242
|
|
|
245
243
|
# @!method self.mongocrypt_status_message(status, len=nil)
|
|
246
244
|
# @api private
|
|
@@ -248,9 +246,9 @@ module Mongo
|
|
|
248
246
|
# Returns the status message.
|
|
249
247
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t.
|
|
250
248
|
# @param [ FFI::Pointer | nil ] len (out param) An optional pointer to a
|
|
251
|
-
# uint32, where the length of the
|
|
249
|
+
# uint32, where the length of the return string will be written.
|
|
252
250
|
# @return [ String ] The status message.
|
|
253
|
-
attach_function :mongocrypt_status_message, [
|
|
251
|
+
attach_function :mongocrypt_status_message, %i[pointer pointer], :string
|
|
254
252
|
|
|
255
253
|
# @!method self.mongocrypt_status_ok(status)
|
|
256
254
|
# @api private
|
|
@@ -258,7 +256,7 @@ module Mongo
|
|
|
258
256
|
# Returns whether the status is ok or an error.
|
|
259
257
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t.
|
|
260
258
|
# @return [ Boolean ] Whether the status is ok.
|
|
261
|
-
attach_function :mongocrypt_status_ok, [:pointer], :bool
|
|
259
|
+
attach_function :mongocrypt_status_ok, [ :pointer ], :bool
|
|
262
260
|
|
|
263
261
|
# @!method self.mongocrypt_status_destroy(status)
|
|
264
262
|
# @api private
|
|
@@ -266,7 +264,7 @@ module Mongo
|
|
|
266
264
|
# Destroys the reference to the mongocrypt_status_t object.
|
|
267
265
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t.
|
|
268
266
|
# @return [ nil ] Always nil.
|
|
269
|
-
attach_function :mongocrypt_status_destroy, [:pointer], :void
|
|
267
|
+
attach_function :mongocrypt_status_destroy, [ :pointer ], :void
|
|
270
268
|
|
|
271
269
|
# Enum labeling the various log levels
|
|
272
270
|
enum :log_level, [
|
|
@@ -293,7 +291,7 @@ module Mongo
|
|
|
293
291
|
#
|
|
294
292
|
# @note This defines a method signature for an FFI callback; it is not
|
|
295
293
|
# an instance method on the Binding class.
|
|
296
|
-
callback :mongocrypt_log_fn_t, [
|
|
294
|
+
callback :mongocrypt_log_fn_t, %i[log_level string int pointer], :void
|
|
297
295
|
|
|
298
296
|
# @!method self.ongocrypt_new
|
|
299
297
|
# @api private
|
|
@@ -314,7 +312,7 @@ module Mongo
|
|
|
314
312
|
# @return [ Boolean ] Whether setting the callback was successful.
|
|
315
313
|
attach_function(
|
|
316
314
|
:mongocrypt_setopt_log_handler,
|
|
317
|
-
[
|
|
315
|
+
%i[pointer mongocrypt_log_fn_t pointer],
|
|
318
316
|
:bool
|
|
319
317
|
)
|
|
320
318
|
|
|
@@ -343,7 +341,7 @@ module Mongo
|
|
|
343
341
|
# @returns [ true | false ] Returns whether the options was set successfully.
|
|
344
342
|
attach_function(
|
|
345
343
|
:mongocrypt_setopt_kms_providers,
|
|
346
|
-
[
|
|
344
|
+
%i[pointer pointer],
|
|
347
345
|
:bool
|
|
348
346
|
)
|
|
349
347
|
|
|
@@ -372,7 +370,7 @@ module Mongo
|
|
|
372
370
|
# @param [ FFI::Pointer ] schema_map A pointer to a mongocrypt_binary_t.
|
|
373
371
|
# object that references the schema map as a BSON binary string.
|
|
374
372
|
# @return [ Boolean ] Returns whether the option was set successfully.
|
|
375
|
-
attach_function :mongocrypt_setopt_schema_map, [
|
|
373
|
+
attach_function :mongocrypt_setopt_schema_map, %i[pointer pointer], :bool
|
|
376
374
|
|
|
377
375
|
# Set schema map on the Mongo::Crypt::Handle object
|
|
378
376
|
#
|
|
@@ -397,7 +395,7 @@ module Mongo
|
|
|
397
395
|
# Initialize the mongocrypt_t object.
|
|
398
396
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object.
|
|
399
397
|
# @return [ Boolean ] Returns whether the crypt was initialized successfully.
|
|
400
|
-
attach_function :mongocrypt_init, [:pointer], :bool
|
|
398
|
+
attach_function :mongocrypt_init, [ :pointer ], :bool
|
|
401
399
|
|
|
402
400
|
# Initialize the Mongo::Crypt::Handle object
|
|
403
401
|
#
|
|
@@ -418,7 +416,7 @@ module Mongo
|
|
|
418
416
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object.
|
|
419
417
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t object.
|
|
420
418
|
# @return [ Boolean ] Whether the status was successfully set.
|
|
421
|
-
attach_function :mongocrypt_status, [
|
|
419
|
+
attach_function :mongocrypt_status, %i[pointer pointer], :bool
|
|
422
420
|
|
|
423
421
|
# @!method self.mongocrypt_destroy(crypt)
|
|
424
422
|
# @api private
|
|
@@ -426,7 +424,7 @@ module Mongo
|
|
|
426
424
|
# Destroy the reference the mongocrypt_t object.
|
|
427
425
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object.
|
|
428
426
|
# @return [ nil ] Always nil.
|
|
429
|
-
attach_function :mongocrypt_destroy, [:pointer], :void
|
|
427
|
+
attach_function :mongocrypt_destroy, [ :pointer ], :void
|
|
430
428
|
|
|
431
429
|
# @!method self.mongocrypt_ctx_new(crypt)
|
|
432
430
|
# @api private
|
|
@@ -435,7 +433,7 @@ module Mongo
|
|
|
435
433
|
# state machine).
|
|
436
434
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object.
|
|
437
435
|
# @return [ FFI::Pointer ] A new mongocrypt_ctx_t object.
|
|
438
|
-
attach_function :mongocrypt_ctx_new, [:pointer], :pointer
|
|
436
|
+
attach_function :mongocrypt_ctx_new, [ :pointer ], :pointer
|
|
439
437
|
|
|
440
438
|
# @!method self.mongocrypt_ctx_status(ctx, status)
|
|
441
439
|
# @api private
|
|
@@ -445,7 +443,7 @@ module Mongo
|
|
|
445
443
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
446
444
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t object.
|
|
447
445
|
# @return [ Boolean ] Whether the status was successfully set.
|
|
448
|
-
attach_function :mongocrypt_ctx_status, [
|
|
446
|
+
attach_function :mongocrypt_ctx_status, %i[pointer pointer], :bool
|
|
449
447
|
|
|
450
448
|
# @!method self.mongocrypt_ctx_setopt_key_id(ctx, key_id)
|
|
451
449
|
# @api private
|
|
@@ -456,7 +454,7 @@ module Mongo
|
|
|
456
454
|
# that references the 16-byte key-id.
|
|
457
455
|
# @note Do not initialize ctx before calling this method.
|
|
458
456
|
# @return [ Boolean ] Whether the option was successfully set.
|
|
459
|
-
attach_function :mongocrypt_ctx_setopt_key_id, [
|
|
457
|
+
attach_function :mongocrypt_ctx_setopt_key_id, %i[pointer pointer], :bool
|
|
460
458
|
|
|
461
459
|
# Sets the key id option on an explicit encryption context.
|
|
462
460
|
#
|
|
@@ -486,7 +484,7 @@ module Mongo
|
|
|
486
484
|
# @note Do not initialize ctx before calling this method.
|
|
487
485
|
attach_function(
|
|
488
486
|
:mongocrypt_ctx_setopt_key_alt_name,
|
|
489
|
-
[
|
|
487
|
+
%i[pointer pointer],
|
|
490
488
|
:bool
|
|
491
489
|
)
|
|
492
490
|
|
|
@@ -499,7 +497,7 @@ module Mongo
|
|
|
499
497
|
# not valid UTF8 strings
|
|
500
498
|
def self.ctx_setopt_key_alt_names(context, key_alt_names)
|
|
501
499
|
key_alt_names.each do |key_alt_name|
|
|
502
|
-
key_alt_name_bson = { :
|
|
500
|
+
key_alt_name_bson = { keyAltName: key_alt_name }.to_bson.to_s
|
|
503
501
|
|
|
504
502
|
Binary.wrap_string(key_alt_name_bson) do |key_alt_name_p|
|
|
505
503
|
check_ctx_status(context) do
|
|
@@ -521,7 +519,7 @@ module Mongo
|
|
|
521
519
|
# @note Do not initialize ctx before calling this method.
|
|
522
520
|
attach_function(
|
|
523
521
|
:mongocrypt_ctx_setopt_key_material,
|
|
524
|
-
[
|
|
522
|
+
%i[pointer pointer],
|
|
525
523
|
:bool
|
|
526
524
|
)
|
|
527
525
|
|
|
@@ -533,7 +531,7 @@ module Mongo
|
|
|
533
531
|
#
|
|
534
532
|
# @raise [ Mongo::Error::CryptError ] If the key material is not 96 bytes.
|
|
535
533
|
def self.ctx_setopt_key_material(context, key_material)
|
|
536
|
-
data = {'keyMaterial' => key_material}.to_bson.to_s
|
|
534
|
+
data = { 'keyMaterial' => key_material }.to_bson.to_s
|
|
537
535
|
Binary.wrap_string(data) do |data_p|
|
|
538
536
|
check_ctx_status(context) do
|
|
539
537
|
mongocrypt_ctx_setopt_key_material(context.ctx_p, data_p)
|
|
@@ -554,7 +552,7 @@ module Mongo
|
|
|
554
552
|
# @return [ Boolean ] Whether the option was successfully set.
|
|
555
553
|
attach_function(
|
|
556
554
|
:mongocrypt_ctx_setopt_algorithm,
|
|
557
|
-
[
|
|
555
|
+
%i[pointer string int],
|
|
558
556
|
:bool
|
|
559
557
|
)
|
|
560
558
|
|
|
@@ -584,7 +582,7 @@ module Mongo
|
|
|
584
582
|
# @return [ Boolean ] Whether the option was successfully set.
|
|
585
583
|
attach_function(
|
|
586
584
|
:mongocrypt_ctx_setopt_key_encryption_key,
|
|
587
|
-
[
|
|
585
|
+
%i[pointer pointer],
|
|
588
586
|
:bool
|
|
589
587
|
)
|
|
590
588
|
|
|
@@ -615,7 +613,7 @@ module Mongo
|
|
|
615
613
|
# and mongocrypt_ctx_setopt_masterkey_aws_endpoint. Set local master
|
|
616
614
|
# key by calling mongocrypt_ctx_setopt_masterkey_local.
|
|
617
615
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
618
|
-
attach_function :mongocrypt_ctx_datakey_init, [:pointer], :bool
|
|
616
|
+
attach_function :mongocrypt_ctx_datakey_init, [ :pointer ], :bool
|
|
619
617
|
|
|
620
618
|
# Initialize the Context to create a data key
|
|
621
619
|
#
|
|
@@ -641,7 +639,7 @@ module Mongo
|
|
|
641
639
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
642
640
|
attach_function(
|
|
643
641
|
:mongocrypt_ctx_rewrap_many_datakey_init,
|
|
644
|
-
[
|
|
642
|
+
%i[pointer pointer],
|
|
645
643
|
:bool
|
|
646
644
|
)
|
|
647
645
|
|
|
@@ -677,7 +675,7 @@ module Mongo
|
|
|
677
675
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
678
676
|
attach_function(
|
|
679
677
|
:mongocrypt_ctx_encrypt_init,
|
|
680
|
-
[
|
|
678
|
+
%i[pointer string int pointer],
|
|
681
679
|
:bool
|
|
682
680
|
)
|
|
683
681
|
|
|
@@ -713,7 +711,7 @@ module Mongo
|
|
|
713
711
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
714
712
|
attach_function(
|
|
715
713
|
:mongocrypt_ctx_explicit_encrypt_init,
|
|
716
|
-
[
|
|
714
|
+
%i[pointer pointer],
|
|
717
715
|
:bool
|
|
718
716
|
)
|
|
719
717
|
|
|
@@ -747,7 +745,7 @@ module Mongo
|
|
|
747
745
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
748
746
|
attach_function(
|
|
749
747
|
:mongocrypt_ctx_explicit_encrypt_expression_init,
|
|
750
|
-
[
|
|
748
|
+
%i[pointer pointer],
|
|
751
749
|
:bool
|
|
752
750
|
)
|
|
753
751
|
|
|
@@ -775,7 +773,7 @@ module Mongo
|
|
|
775
773
|
# @param [ FFI::Pointer ] doc A pointer to a mongocrypt_binary_t object
|
|
776
774
|
# that references the document to be decrypted as a BSON binary string.
|
|
777
775
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
778
|
-
attach_function :mongocrypt_ctx_decrypt_init, [
|
|
776
|
+
attach_function :mongocrypt_ctx_decrypt_init, %i[pointer pointer], :bool
|
|
779
777
|
|
|
780
778
|
# Initialize the Context for auto-decryption
|
|
781
779
|
#
|
|
@@ -803,7 +801,7 @@ module Mongo
|
|
|
803
801
|
# @return [ Boolean ] Whether the initialization was successful.
|
|
804
802
|
attach_function(
|
|
805
803
|
:mongocrypt_ctx_explicit_decrypt_init,
|
|
806
|
-
[
|
|
804
|
+
%i[pointer pointer],
|
|
807
805
|
:bool
|
|
808
806
|
)
|
|
809
807
|
|
|
@@ -842,7 +840,7 @@ module Mongo
|
|
|
842
840
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
843
841
|
# @return [ Symbol ] The current state, will be one of the values defined
|
|
844
842
|
# by the mongocrypt_ctx_state enum.
|
|
845
|
-
attach_function :mongocrypt_ctx_state, [:pointer], :mongocrypt_ctx_state
|
|
843
|
+
attach_function :mongocrypt_ctx_state, [ :pointer ], :mongocrypt_ctx_state
|
|
846
844
|
|
|
847
845
|
# @!method self.mongocrypt_ctx_mongo_op(ctx, op_bson)
|
|
848
846
|
# @api private
|
|
@@ -854,7 +852,7 @@ module Mongo
|
|
|
854
852
|
# mongocrypt_binary_t object that will have a reference to the
|
|
855
853
|
# BSON operation written to it by libmongocrypt.
|
|
856
854
|
# @return [ Boolean ] A boolean indicating the success of the operation.
|
|
857
|
-
attach_function :mongocrypt_ctx_mongo_op, [
|
|
855
|
+
attach_function :mongocrypt_ctx_mongo_op, %i[pointer pointer], :bool
|
|
858
856
|
|
|
859
857
|
# Returns a BSON::Document representing an operation that the
|
|
860
858
|
# driver must perform on behalf of libmongocrypt to get the
|
|
@@ -872,7 +870,7 @@ module Mongo
|
|
|
872
870
|
mongocrypt_ctx_mongo_op(context.ctx_p, binary.ref)
|
|
873
871
|
end
|
|
874
872
|
|
|
875
|
-
# TODO since the binary references a C pointer, and ByteBuffer is
|
|
873
|
+
# TODO: since the binary references a C pointer, and ByteBuffer is
|
|
876
874
|
# written in C in MRI, we could omit a copy of the data by making
|
|
877
875
|
# ByteBuffer reference the string that is owned by libmongocrypt.
|
|
878
876
|
BSON::Document.from_bson(BSON::ByteBuffer.new(binary.to_s), mode: :bson)
|
|
@@ -886,7 +884,7 @@ module Mongo
|
|
|
886
884
|
# @param [ FFI::Pointer ] reply A mongocrypt_binary_t object that
|
|
887
885
|
# references the BSON reply to feed to libmongocrypt.
|
|
888
886
|
# @return [ Boolean ] A boolean indicating the success of the operation.
|
|
889
|
-
attach_function :mongocrypt_ctx_mongo_feed, [
|
|
887
|
+
attach_function :mongocrypt_ctx_mongo_feed, %i[pointer pointer], :bool
|
|
890
888
|
|
|
891
889
|
# Feed a response from the driver back to libmongocrypt
|
|
892
890
|
#
|
|
@@ -910,7 +908,7 @@ module Mongo
|
|
|
910
908
|
# Indicate to libmongocrypt that the driver is done feeding replies.
|
|
911
909
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
912
910
|
# @return [ Boolean ] A boolean indicating the success of the operation.
|
|
913
|
-
attach_function :mongocrypt_ctx_mongo_done, [:pointer], :bool
|
|
911
|
+
attach_function :mongocrypt_ctx_mongo_done, [ :pointer ], :bool
|
|
914
912
|
|
|
915
913
|
# @!method self.mongocrypt_ctx_mongo_next_kms_ctx(ctx)
|
|
916
914
|
# @api private
|
|
@@ -918,7 +916,7 @@ module Mongo
|
|
|
918
916
|
# Return a pointer to a mongocrypt_kms_ctx_t object or NULL.
|
|
919
917
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
920
918
|
# @return [ FFI::Pointer ] A pointer to a mongocrypt_kms_ctx_t object.
|
|
921
|
-
attach_function :mongocrypt_ctx_next_kms_ctx, [:pointer], :pointer
|
|
919
|
+
attach_function :mongocrypt_ctx_next_kms_ctx, [ :pointer ], :pointer
|
|
922
920
|
|
|
923
921
|
# Return a new KmsContext object needed by a Context object.
|
|
924
922
|
#
|
|
@@ -954,7 +952,7 @@ module Mongo
|
|
|
954
952
|
# "kmip".
|
|
955
953
|
attach_function(
|
|
956
954
|
:mongocrypt_kms_ctx_get_kms_provider,
|
|
957
|
-
[
|
|
955
|
+
%i[pointer pointer],
|
|
958
956
|
:pointer
|
|
959
957
|
)
|
|
960
958
|
|
|
@@ -977,13 +975,13 @@ module Mongo
|
|
|
977
975
|
nil
|
|
978
976
|
else
|
|
979
977
|
len = if BSON::Environment.jruby?
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
978
|
+
# JRuby FFI implementation does not have `read(type)` method, but it
|
|
979
|
+
# has this `get_uint32`.
|
|
980
|
+
len_ptr.get_uint32
|
|
981
|
+
else
|
|
982
|
+
# For MRI we use a documented `read` method - https://www.rubydoc.info/github/ffi/ffi/FFI%2FPointer:read
|
|
983
|
+
len_ptr.read(:uint32)
|
|
984
|
+
end
|
|
987
985
|
provider.read_string(len).to_sym
|
|
988
986
|
end
|
|
989
987
|
end
|
|
@@ -997,7 +995,7 @@ module Mongo
|
|
|
997
995
|
# object that will have the location of the message written to it by
|
|
998
996
|
# libmongocrypt.
|
|
999
997
|
# @return [ Boolean ] Whether the operation is successful.
|
|
1000
|
-
attach_function :mongocrypt_kms_ctx_message, [
|
|
998
|
+
attach_function :mongocrypt_kms_ctx_message, %i[pointer pointer], :bool
|
|
1001
999
|
|
|
1002
1000
|
# Get the HTTP message needed to fetch the AWS KMS master key from a
|
|
1003
1001
|
# KmsContext object.
|
|
@@ -1014,7 +1012,7 @@ module Mongo
|
|
|
1014
1012
|
mongocrypt_kms_ctx_message(kms_context.kms_ctx_p, binary.ref)
|
|
1015
1013
|
end
|
|
1016
1014
|
|
|
1017
|
-
|
|
1015
|
+
binary.to_s
|
|
1018
1016
|
end
|
|
1019
1017
|
|
|
1020
1018
|
# @!method self.mongocrypt_kms_ctx_endpoint(kms, endpoint)
|
|
@@ -1026,7 +1024,7 @@ module Mongo
|
|
|
1026
1024
|
# @param [ FFI::Pointer ] endpoint (out param) A pointer to which the
|
|
1027
1025
|
# endpoint string will be written by libmongocrypt.
|
|
1028
1026
|
# @return [ Boolean ] Whether the operation was successful.
|
|
1029
|
-
attach_function :mongocrypt_kms_ctx_endpoint, [
|
|
1027
|
+
attach_function :mongocrypt_kms_ctx_endpoint, %i[pointer pointer], :bool
|
|
1030
1028
|
|
|
1031
1029
|
# Get the hostname with which to connect over TLS to get information
|
|
1032
1030
|
# about the AWS master key.
|
|
@@ -1053,7 +1051,7 @@ module Mongo
|
|
|
1053
1051
|
# Get the number of bytes needed by the KMS context.
|
|
1054
1052
|
# @param [ FFI::Pointer ] kms The mongocrypt_kms_ctx_t object.
|
|
1055
1053
|
# @return [ Integer ] The number of bytes needed.
|
|
1056
|
-
attach_function :mongocrypt_kms_ctx_bytes_needed, [:pointer], :int
|
|
1054
|
+
attach_function :mongocrypt_kms_ctx_bytes_needed, [ :pointer ], :int
|
|
1057
1055
|
|
|
1058
1056
|
# Get the number of bytes needed by the KmsContext.
|
|
1059
1057
|
#
|
|
@@ -1072,7 +1070,7 @@ module Mongo
|
|
|
1072
1070
|
# @param [ FFI::Pointer ] bytes A pointer to a mongocrypt_binary_t
|
|
1073
1071
|
# object that references the response from the KMS.
|
|
1074
1072
|
# @return [ Boolean ] Whether the operation was successful.
|
|
1075
|
-
attach_function :mongocrypt_kms_ctx_feed, [
|
|
1073
|
+
attach_function :mongocrypt_kms_ctx_feed, %i[pointer pointer], :bool
|
|
1076
1074
|
|
|
1077
1075
|
# Feed replies from the KMS back to libmongocrypt.
|
|
1078
1076
|
#
|
|
@@ -1096,7 +1094,7 @@ module Mongo
|
|
|
1096
1094
|
# @param [ FFI::Pointer ] kms A pointer to the mongocrypt_kms_ctx_t object.
|
|
1097
1095
|
# @param [ FFI::Pointer ] status A pointer to a mongocrypt_status_t object.
|
|
1098
1096
|
# @return [ Boolean ] Whether the operation was successful.
|
|
1099
|
-
attach_function :mongocrypt_kms_ctx_status, [
|
|
1097
|
+
attach_function :mongocrypt_kms_ctx_status, %i[pointer pointer], :bool
|
|
1100
1098
|
|
|
1101
1099
|
# If the provided block returns false, raise a CryptError with the
|
|
1102
1100
|
# status information from the provided KmsContext object.
|
|
@@ -1105,12 +1103,12 @@ module Mongo
|
|
|
1105
1103
|
#
|
|
1106
1104
|
# @raise [ Mongo::Error::CryptError ] If the provided block returns false
|
|
1107
1105
|
def self.check_kms_ctx_status(kms_context)
|
|
1108
|
-
|
|
1109
|
-
status = Status.new
|
|
1106
|
+
return if yield
|
|
1110
1107
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1108
|
+
status = Status.new
|
|
1109
|
+
|
|
1110
|
+
mongocrypt_kms_ctx_status(kms_context.kms_ctx_p, status.ref)
|
|
1111
|
+
status.raise_crypt_error(kms: true)
|
|
1114
1112
|
end
|
|
1115
1113
|
|
|
1116
1114
|
# @!method self.mongocrypt_kms_ctx_usleep(ctx)
|
|
@@ -1120,7 +1118,7 @@ module Mongo
|
|
|
1120
1118
|
#
|
|
1121
1119
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
1122
1120
|
# @return [ int64 ] A 64-bit encoded number of microseconds of how long to sleep.
|
|
1123
|
-
attach_function :mongocrypt_kms_ctx_usleep, [:pointer], :int64
|
|
1121
|
+
attach_function :mongocrypt_kms_ctx_usleep, [ :pointer ], :int64
|
|
1124
1122
|
|
|
1125
1123
|
# Returns number of milliseconds to sleep before sending KMS request
|
|
1126
1124
|
# for the given KMS context.
|
|
@@ -1139,7 +1137,7 @@ module Mongo
|
|
|
1139
1137
|
#
|
|
1140
1138
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
1141
1139
|
# @return [ Boolean ] whether the failed request may be retried.
|
|
1142
|
-
attach_function :mongocrypt_kms_ctx_fail, [:pointer], :bool
|
|
1140
|
+
attach_function :mongocrypt_kms_ctx_fail, [ :pointer ], :bool
|
|
1143
1141
|
|
|
1144
1142
|
# Check whether the last failed request for the KMS context may be retried.
|
|
1145
1143
|
#
|
|
@@ -1157,7 +1155,7 @@ module Mongo
|
|
|
1157
1155
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object
|
|
1158
1156
|
# @param [ Boolean ] enable A boolean indicating whether to retry operations.
|
|
1159
1157
|
# @return [ Boolean ] indicating success.
|
|
1160
|
-
attach_function :mongocrypt_setopt_retry_kms, [
|
|
1158
|
+
attach_function :mongocrypt_setopt_retry_kms, %i[pointer bool], :bool
|
|
1161
1159
|
|
|
1162
1160
|
# Enable or disable KMS retry behavior.
|
|
1163
1161
|
#
|
|
@@ -1168,7 +1166,6 @@ module Mongo
|
|
|
1168
1166
|
mongocrypt_setopt_retry_kms(handle.ref, value)
|
|
1169
1167
|
end
|
|
1170
1168
|
|
|
1171
|
-
|
|
1172
1169
|
# @!method self.mongocrypt_kms_ctx_done(ctx)
|
|
1173
1170
|
# @api private
|
|
1174
1171
|
#
|
|
@@ -1176,7 +1173,7 @@ module Mongo
|
|
|
1176
1173
|
# mongocrypt_kms_ctx_t objects.
|
|
1177
1174
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
1178
1175
|
# @return [ Boolean ] Whether the operation was successful.
|
|
1179
|
-
attach_function :mongocrypt_ctx_kms_done, [:pointer], :bool
|
|
1176
|
+
attach_function :mongocrypt_ctx_kms_done, [ :pointer ], :bool
|
|
1180
1177
|
|
|
1181
1178
|
# Indicate to libmongocrypt that it will receive no more KMS replies.
|
|
1182
1179
|
#
|
|
@@ -1198,7 +1195,7 @@ module Mongo
|
|
|
1198
1195
|
# mongocrypt_binary_t object that will have a reference to the
|
|
1199
1196
|
# final encrypted BSON document.
|
|
1200
1197
|
# @return [ Boolean ] A boolean indicating the success of the operation.
|
|
1201
|
-
attach_function :mongocrypt_ctx_finalize, [
|
|
1198
|
+
attach_function :mongocrypt_ctx_finalize, %i[pointer pointer], :void
|
|
1202
1199
|
|
|
1203
1200
|
# Finalize the state machine represented by the Context
|
|
1204
1201
|
#
|
|
@@ -1213,10 +1210,10 @@ module Mongo
|
|
|
1213
1210
|
mongocrypt_ctx_finalize(context.ctx_p, binary.ref)
|
|
1214
1211
|
end
|
|
1215
1212
|
|
|
1216
|
-
# TODO since the binary references a C pointer, and ByteBuffer is
|
|
1213
|
+
# TODO: since the binary references a C pointer, and ByteBuffer is
|
|
1217
1214
|
# written in C in MRI, we could omit a copy of the data by making
|
|
1218
1215
|
# ByteBuffer reference the string that is owned by libmongocrypt.
|
|
1219
|
-
BSON::Document.from_bson(BSON::ByteBuffer.new(binary.to_s), mode:
|
|
1216
|
+
BSON::Document.from_bson(BSON::ByteBuffer.new(binary.to_s), mode: context.bson_mode)
|
|
1220
1217
|
end
|
|
1221
1218
|
|
|
1222
1219
|
# @!method self.mongocrypt_ctx_destroy(ctx)
|
|
@@ -1225,7 +1222,7 @@ module Mongo
|
|
|
1225
1222
|
# Destroy the reference to the mongocrypt_ctx_t object.
|
|
1226
1223
|
# @param [ FFI::Pointer ] ctx A pointer to a mongocrypt_ctx_t object.
|
|
1227
1224
|
# @return [ nil ] Always nil.
|
|
1228
|
-
attach_function :mongocrypt_ctx_destroy, [:pointer], :void
|
|
1225
|
+
attach_function :mongocrypt_ctx_destroy, [ :pointer ], :void
|
|
1229
1226
|
|
|
1230
1227
|
# @!method mongocrypt_crypto_fn(ctx, key, iv, input, output, status)
|
|
1231
1228
|
# @api private
|
|
@@ -1250,7 +1247,7 @@ module Mongo
|
|
|
1250
1247
|
# an instance method on the Binding class.
|
|
1251
1248
|
callback(
|
|
1252
1249
|
:mongocrypt_crypto_fn,
|
|
1253
|
-
[
|
|
1250
|
+
%i[pointer pointer pointer pointer pointer pointer pointer],
|
|
1254
1251
|
:bool
|
|
1255
1252
|
)
|
|
1256
1253
|
|
|
@@ -1275,7 +1272,7 @@ module Mongo
|
|
|
1275
1272
|
# an instance method on the Binding class.
|
|
1276
1273
|
callback(
|
|
1277
1274
|
:mongocrypt_hmac_fn,
|
|
1278
|
-
[
|
|
1275
|
+
%i[pointer pointer pointer pointer pointer],
|
|
1279
1276
|
:bool
|
|
1280
1277
|
)
|
|
1281
1278
|
|
|
@@ -1296,7 +1293,7 @@ module Mongo
|
|
|
1296
1293
|
#
|
|
1297
1294
|
# @note This defines a method signature for an FFI callback; it is not
|
|
1298
1295
|
# an instance method on the Binding class.
|
|
1299
|
-
callback :mongocrypt_hash_fn, [
|
|
1296
|
+
callback :mongocrypt_hash_fn, %i[pointer pointer pointer pointer], :bool
|
|
1300
1297
|
|
|
1301
1298
|
# @!method mongocrypt_random_fn(ctx, output, count, status)
|
|
1302
1299
|
# @api private
|
|
@@ -1314,7 +1311,7 @@ module Mongo
|
|
|
1314
1311
|
#
|
|
1315
1312
|
# @note This defines a method signature for an FFI callback; it is not
|
|
1316
1313
|
# an instance method on the Binding class.
|
|
1317
|
-
callback :mongocrypt_random_fn, [
|
|
1314
|
+
callback :mongocrypt_random_fn, %i[pointer pointer int pointer], :bool
|
|
1318
1315
|
|
|
1319
1316
|
# @!method self.mongocrypt_setopt_crypto_hooks(crypt, aes_enc_fn, aes_dec_fn, random_fn, sha_512_fn, sha_256_fn, hash_fn, ctx=nil)
|
|
1320
1317
|
# @api private
|
|
@@ -1332,15 +1329,15 @@ module Mongo
|
|
|
1332
1329
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1333
1330
|
attach_function(
|
|
1334
1331
|
:mongocrypt_setopt_crypto_hooks,
|
|
1335
|
-
[
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1332
|
+
%i[
|
|
1333
|
+
pointer
|
|
1334
|
+
mongocrypt_crypto_fn
|
|
1335
|
+
mongocrypt_crypto_fn
|
|
1336
|
+
mongocrypt_random_fn
|
|
1337
|
+
mongocrypt_hmac_fn
|
|
1338
|
+
mongocrypt_hmac_fn
|
|
1339
|
+
mongocrypt_hash_fn
|
|
1340
|
+
pointer
|
|
1344
1341
|
],
|
|
1345
1342
|
:bool
|
|
1346
1343
|
)
|
|
@@ -1357,14 +1354,12 @@ module Mongo
|
|
|
1357
1354
|
#
|
|
1358
1355
|
# @raise [ Mongo::Error::CryptError ] If the callbacks aren't set successfully
|
|
1359
1356
|
def self.setopt_crypto_hooks(handle,
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
)
|
|
1357
|
+
aes_encrypt_cb, aes_decrypt_cb, random_cb,
|
|
1358
|
+
hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb)
|
|
1363
1359
|
check_status(handle) do
|
|
1364
1360
|
mongocrypt_setopt_crypto_hooks(handle.ref,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
)
|
|
1361
|
+
aes_encrypt_cb, aes_decrypt_cb, random_cb,
|
|
1362
|
+
hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb, nil)
|
|
1368
1363
|
end
|
|
1369
1364
|
end
|
|
1370
1365
|
|
|
@@ -1379,10 +1374,10 @@ module Mongo
|
|
|
1379
1374
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1380
1375
|
attach_function(
|
|
1381
1376
|
:mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5,
|
|
1382
|
-
[
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1377
|
+
%i[
|
|
1378
|
+
pointer
|
|
1379
|
+
mongocrypt_hmac_fn
|
|
1380
|
+
pointer
|
|
1386
1381
|
],
|
|
1387
1382
|
:bool
|
|
1388
1383
|
)
|
|
@@ -1421,9 +1416,9 @@ module Mongo
|
|
|
1421
1416
|
# @return [ Boolean ] Whether the operation succeeded.
|
|
1422
1417
|
attach_function(
|
|
1423
1418
|
:mongocrypt_setopt_encrypted_field_config_map,
|
|
1424
|
-
[
|
|
1425
|
-
|
|
1426
|
-
|
|
1419
|
+
%i[
|
|
1420
|
+
pointer
|
|
1421
|
+
pointer
|
|
1427
1422
|
],
|
|
1428
1423
|
:bool
|
|
1429
1424
|
)
|
|
@@ -1460,7 +1455,7 @@ module Mongo
|
|
|
1460
1455
|
# - A mongocrypt_ctx_t will never enter the MONGOCRYPT_CTX_NEED_MARKINGS state.
|
|
1461
1456
|
#
|
|
1462
1457
|
# @param [ FFI::Pointer ] crypt A pointer to a mongocrypt_t object.
|
|
1463
|
-
attach_function(:mongocrypt_setopt_bypass_query_analysis, [:pointer], :void)
|
|
1458
|
+
attach_function(:mongocrypt_setopt_bypass_query_analysis, [ :pointer ], :void)
|
|
1464
1459
|
|
|
1465
1460
|
# Opt-into skipping query analysis.
|
|
1466
1461
|
#
|
|
@@ -1486,11 +1481,11 @@ module Mongo
|
|
|
1486
1481
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1487
1482
|
attach_function(
|
|
1488
1483
|
:mongocrypt_setopt_aes_256_ctr,
|
|
1489
|
-
[
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1484
|
+
%i[
|
|
1485
|
+
pointer
|
|
1486
|
+
mongocrypt_crypto_fn
|
|
1487
|
+
mongocrypt_crypto_fn
|
|
1488
|
+
pointer
|
|
1494
1489
|
],
|
|
1495
1490
|
:bool
|
|
1496
1491
|
)
|
|
@@ -1505,8 +1500,7 @@ module Mongo
|
|
|
1505
1500
|
def self.setopt_aes_256_ctr(handle, aes_ctr_encrypt_cb, aes_ctr_decrypt_cb)
|
|
1506
1501
|
check_status(handle) do
|
|
1507
1502
|
mongocrypt_setopt_aes_256_ctr(handle.ref,
|
|
1508
|
-
|
|
1509
|
-
)
|
|
1503
|
+
aes_ctr_encrypt_cb, aes_ctr_decrypt_cb, nil)
|
|
1510
1504
|
end
|
|
1511
1505
|
end
|
|
1512
1506
|
|
|
@@ -1524,9 +1518,9 @@ module Mongo
|
|
|
1524
1518
|
# system's library resolution mechanism to find the crypt_shared library.
|
|
1525
1519
|
attach_function(
|
|
1526
1520
|
:mongocrypt_setopt_append_crypt_shared_lib_search_path,
|
|
1527
|
-
[
|
|
1528
|
-
|
|
1529
|
-
|
|
1521
|
+
%i[
|
|
1522
|
+
pointer
|
|
1523
|
+
string
|
|
1530
1524
|
],
|
|
1531
1525
|
:void
|
|
1532
1526
|
)
|
|
@@ -1553,9 +1547,9 @@ module Mongo
|
|
|
1553
1547
|
# with the directory path containing the executable libmongocrypt module.
|
|
1554
1548
|
attach_function(
|
|
1555
1549
|
:mongocrypt_setopt_set_crypt_shared_lib_path_override,
|
|
1556
|
-
[
|
|
1557
|
-
|
|
1558
|
-
|
|
1550
|
+
%i[
|
|
1551
|
+
pointer
|
|
1552
|
+
string
|
|
1559
1553
|
],
|
|
1560
1554
|
:void
|
|
1561
1555
|
)
|
|
@@ -1669,7 +1663,7 @@ module Mongo
|
|
|
1669
1663
|
# @returns [ true | false ] Returns whether the options was set successfully.
|
|
1670
1664
|
attach_function(
|
|
1671
1665
|
:mongocrypt_ctx_provide_kms_providers,
|
|
1672
|
-
[
|
|
1666
|
+
%i[pointer pointer],
|
|
1673
1667
|
:bool
|
|
1674
1668
|
)
|
|
1675
1669
|
|
|
@@ -1707,10 +1701,10 @@ module Mongo
|
|
|
1707
1701
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1708
1702
|
attach_function(
|
|
1709
1703
|
:mongocrypt_ctx_setopt_query_type,
|
|
1710
|
-
[
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1704
|
+
%i[
|
|
1705
|
+
pointer
|
|
1706
|
+
string
|
|
1707
|
+
int
|
|
1714
1708
|
],
|
|
1715
1709
|
:bool
|
|
1716
1710
|
)
|
|
@@ -1740,9 +1734,9 @@ module Mongo
|
|
|
1740
1734
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1741
1735
|
attach_function(
|
|
1742
1736
|
:mongocrypt_ctx_setopt_contention_factor,
|
|
1743
|
-
[
|
|
1744
|
-
|
|
1745
|
-
|
|
1737
|
+
%i[
|
|
1738
|
+
pointer
|
|
1739
|
+
int64
|
|
1746
1740
|
],
|
|
1747
1741
|
:bool
|
|
1748
1742
|
)
|
|
@@ -1775,9 +1769,9 @@ module Mongo
|
|
|
1775
1769
|
# @return [ Boolean ] Whether setting this option succeeded.
|
|
1776
1770
|
attach_function(
|
|
1777
1771
|
:mongocrypt_ctx_setopt_algorithm_range,
|
|
1778
|
-
[
|
|
1779
|
-
|
|
1780
|
-
|
|
1772
|
+
%i[
|
|
1773
|
+
pointer
|
|
1774
|
+
pointer
|
|
1781
1775
|
],
|
|
1782
1776
|
:bool
|
|
1783
1777
|
)
|
|
@@ -1806,12 +1800,12 @@ module Mongo
|
|
|
1806
1800
|
#
|
|
1807
1801
|
# @return [ nil ] Always nil.
|
|
1808
1802
|
def self.check_status(handle)
|
|
1809
|
-
|
|
1810
|
-
status = Status.new
|
|
1803
|
+
return if yield
|
|
1811
1804
|
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1805
|
+
status = Status.new
|
|
1806
|
+
|
|
1807
|
+
mongocrypt_status(handle.ref, status.ref)
|
|
1808
|
+
status.raise_crypt_error
|
|
1815
1809
|
end
|
|
1816
1810
|
|
|
1817
1811
|
# Raise a Mongo::Error::CryptError based on the status of the underlying
|
|
@@ -1819,18 +1813,18 @@ module Mongo
|
|
|
1819
1813
|
#
|
|
1820
1814
|
# @return [ nil ] Always nil.
|
|
1821
1815
|
def self.check_ctx_status(context)
|
|
1822
|
-
if block_given?
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1816
|
+
do_raise = if block_given?
|
|
1817
|
+
!yield
|
|
1818
|
+
else
|
|
1819
|
+
true
|
|
1820
|
+
end
|
|
1827
1821
|
|
|
1828
|
-
|
|
1829
|
-
status = Status.new
|
|
1822
|
+
return unless do_raise
|
|
1830
1823
|
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1824
|
+
status = Status.new
|
|
1825
|
+
|
|
1826
|
+
mongocrypt_ctx_status(context.ctx_p, status.ref)
|
|
1827
|
+
status.raise_crypt_error
|
|
1834
1828
|
end
|
|
1835
1829
|
|
|
1836
1830
|
# Checks that the specified data is a Hash before serializing
|
|
@@ -1844,13 +1838,13 @@ module Mongo
|
|
|
1844
1838
|
def self.validate_document(data)
|
|
1845
1839
|
return if data.is_a?(Hash)
|
|
1846
1840
|
|
|
1847
|
-
if data.nil?
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1841
|
+
message = if data.nil?
|
|
1842
|
+
'Attempted to pass nil data to libmongocrypt. ' +
|
|
1843
|
+
'Data must be a Hash'
|
|
1844
|
+
else
|
|
1845
|
+
"Attempted to pass invalid data to libmongocrypt: #{data} " +
|
|
1846
|
+
'Data must be a Hash'
|
|
1847
|
+
end
|
|
1854
1848
|
|
|
1855
1849
|
raise Error::CryptError.new(message)
|
|
1856
1850
|
end
|