Skip to content

Commit 310fe43

Browse files
RUBY-3160 Fix all parse errors except bson-tutorials (#2672) (#2765) (#2767)
Co-authored-by: Neil Shweky <neilshweky@gmail.com>
1 parent eb9c811 commit 310fe43

7 files changed

+124
-50
lines changed

docs/contribute.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Contribute Code
5858
The MongoDB Ruby driver source is located
5959
`at GitHub <https://github.com/mongodb/mongo-ruby-driver>`_.
6060

61-
The list of known issues in the driver is available
61+
The list of known issues in the driver is available
6262
`in JIRA <https://jira.mongodb.org/browse/RUBY>`_.
6363

6464
We recommend creating a JIRA ticket before starting work on a bug fix or
@@ -73,7 +73,7 @@ the changes to the stable branches, if needed.
7373
A MongoDB deployment is required to run the tests. Setup procedures and
7474
recommendations for various deployments, as well as how to configure the
7575
driver's test suite for the deployments, are covered in the `spec
76-
readme <https://github.com/mongodb/mongo-ruby-driver/blob/master/spec/README.md>`.
76+
readme <https://github.com/mongodb/mongo-ruby-driver/blob/master/spec/README.md>`__.
7777

7878
The driver is tested on `Evergreen <https://github.com/evergreen-ci/evergreen>`_,
7979
MongoDB's in-house continuous integration platform. After a pull request

docs/tutorials/client-side-encryption.txt

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ enterprise-only feature. If you only intend to use explicit encryption, you may
7474
skip this step.
7575

7676
Mongocryptd comes pre-packaged with enterprise builds of the MongoDB server
77-
(versions 4.2 and newer). For installation instructions, see
78-
`the MongoDB manual <https://docs.mongodb.com/manual/reference/security-client-side-encryption-appendix/#installation>`_.
77+
(versions 4.2 and newer). For installation instructions, see the
78+
`MongoDB manual <https://mongodb.com/docs/manual/reference/security-client-side-encryption-appendix/#installation>`_.
7979

8080
In order to configure mongocryptd (for example, which port it listens on or the
8181
path used to spawn the daemon), it is necessary to pass different options to the
82-
``Mongo::Client`` performing automatic encryption. See the `:extra_options`_
82+
``Mongo::Client`` performing automatic encryption. See the :ref:`:extra_options <cse-extra-options>`
8383
section of this tutorial for more information.
8484

8585
Automatic Encryption
@@ -202,11 +202,12 @@ The example above demonstrates using automatic encryption with a local master ke
202202
For more information about using the AWS Key Management Service to create a
203203
master key and create data keys, see the following sections of this tutorial:
204204

205-
- `Creating A Master Key`_
206-
- `Creating A Data Key`_
205+
- :ref:`Creating A Master Key <creating-a-master-key>`
206+
- :ref:`Creating A Data Key <creating-a-data-key>`
207207

208208
Explicit Encryption
209209
===================
210+
210211
Explicit encryption is a feature that allows users to encrypt and decrypt
211212
individual pieces of data such as strings, integers, or symbols. Explicit
212213
encryption is a community feature and does not require an enterprise build
@@ -296,8 +297,8 @@ The example above demonstrates using explicit encryption with a local master key
296297
For more information about using the AWS Key Management Service to create a
297298
master key and create data keys, see the following sections of this tutorial:
298299

299-
- `Creating A Master Key`_,
300-
- `Creating A Data Key`_,
300+
- :ref:`Creating A Master Key <creating-a-master-key>`
301+
- :ref:`Creating A Data Key <creating-a-data-key>`
301302

302303
Creating a Master Key
303304
=====================
@@ -307,8 +308,11 @@ user data. The master key can be generated in one of two ways: by creating a
307308
local key, or by creating a key in the Amazon Web Services Key Management
308309
Service (AWS KMS).
309310

311+
.. _local-master-key:
312+
310313
Local Master Key
311314
~~~~~~~~~~~~~~~~
315+
312316
A local master key is a 96-byte binary string. It should be persisted
313317
on your machine as an environment variable or in a text file.
314318

@@ -329,14 +333,25 @@ AWS Master Key
329333
It is recommended that you use Amazon's Key Management Service to create and
330334
store your master key. To do so, follow steps 1 and 2 of the
331335
:drivers:`"Convert to a Remote Master Key" section</security/client-side-field-level-encryption-local-key-to-kms/#convert-to-a-remote-master-key>`
336+
.. _remote-master-key:
337+
338+
Remote Master Key
339+
~~~~~~~~~~~~~~~~~
340+
It is recommended that you use a remote Key Management Service to create and
341+
store your master key. To do so, follow steps of the
342+
`"Set up a Remote Master Key" <https://www.mongodb.com/docs/manual/core/csfle/tutorials/#set-up-a-remote-master-key>`_
332343
in the MongoDB Client-Side Encryption documentation.
333344

334345
For more information about creating a master key, see the
335346
:drivers:`Create a Master Key </security/client-side-field-level-encryption-guide/#a-create-a-master-key>`
347+
`Create a Master Key <https://www.mongodb.com/docs/manual/core/csfle/#a.-create-a-master-key>`_
336348
section of the MongoDB manual.
337349

350+
.. _creating-a-data-key:
351+
338352
Creating a Data Key
339353
===================
354+
340355
Once you have created a master key, create a data key by calling the
341356
``#create_data_key`` method on an instance of the ``Mongo::ClientEncryption``
342357
class. This method generates a new data key and inserts it into the key vault
@@ -376,8 +391,8 @@ key with the following code snippet:
376391
data_key_id = client_encryption.create_data_key('local')
377392
# => <BSON::Binary... type=ciphertext...>
378393

379-
See the `Local Master Key`_ section for more information about generating a new
380-
local master key.
394+
See the :ref:`Local Master Key <local-master-key>` section for more information
395+
about generating a new local master key.
381396

382397
Create a Data Key Using an AWS Master Key
383398
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -423,18 +438,20 @@ generating a new master key on AWS and finding the information you need to
423438
create data keys.
424439

425440
For more information about creating a data key, see the
426-
:drivers:`Create a Data Encryption Key </security/client-side-field-level-encryption-guide/#b-create-a-data-encryption-key>`
441+
`Create a Data Encryption Key <https://www.mongodb.com/docs/manual/core/csfle/#b.-create-a-data-encryption-key>`_
427442
section of the MongoDB manual.
428443

429444
Auto-Encryption Options
430445
=======================
446+
431447
Automatic encryption can be configured on a ``Mongo::Client`` using the
432448
``auto_encryption_options`` option ``Hash``. This section provides an overview
433449
of the fields inside ``auto_encryption_options`` and explains how to choose their
434450
values.
435451

436452
``:key_vault_client``
437453
~~~~~~~~~~~~~~~~~~~~~
454+
438455
The key vault client is a ``Mongo::Client`` instance that will be used to connect
439456
to the MongoDB collection containing your encryption data keys. For example, if
440457
your key vault was hosted on a MongoDB instance at ``localhost:30000``:
@@ -456,6 +473,7 @@ to insert and fetch data keys.
456473

457474
``:key_vault_namespace``
458475
~~~~~~~~~~~~~~~~~~~~~~~~
476+
459477
The key vault namespace is a ``String`` in the format ``"database_name.collection_name"``,
460478
where ``database_name`` and ``collection_name`` are the name of the database and
461479
collection in which you would like to store your data keys. For example, if your data
@@ -474,6 +492,7 @@ There is no default key vault namespace, and this option must be provided.
474492

475493
``:schema_map``
476494
~~~~~~~~~~~~~~~
495+
477496
A schema map is a Hash with information about which fields to automatically
478497
encrypt and decrypt.
479498

@@ -549,11 +568,12 @@ When you intend to use your schema map, convert it to a Ruby ``Hash`` using the
549568

550569
.. seealso::
551570

552-
:drivers:`Specify Encrypted Fields Using JSON Schema</security/client-side-field-level-encryption-guide/#c-specify-encrypted-fields-using-json-schema>`,
571+
`Specify Encrypted Fields Using JSON Schema <https://www.mongodb.com/docs/manual/core/csfle/#c-specify-encrypted-fields-using-json-schema>`_,
553572
:manual:`Automatic Encryption Rules</reference/security-client-side-automatic-json-schema/>`
554573

555574
``:bypass_auto_encryption``
556575
~~~~~~~~~~~~~~~~~~~~~~~~~~~
576+
557577
The ``:bypass_auto_encryption`` option is a ``Boolean`` that specifies whether the
558578
``Mongo::Client`` should skip encryption when writing to the database. If
559579
``:bypass_auto_encryption`` is ``true``, the client will still perform automatic
@@ -568,8 +588,11 @@ decryption of any previously-encrypted data.
568588
}
569589
)
570590

591+
.. _cse-extra-options:
592+
571593
``:extra_options``
572594
~~~~~~~~~~~~~~~~~~
595+
573596
``:extra_options`` is a ``Hash`` of options related to spawning mongocryptd.
574597
Every option in this ``Hash`` has a default value, so it is only necessary to
575598
provide the options whose defaults you want to override.

docs/tutorials/common-errors.txt

Whitespace-only changes.

docs/tutorials/ruby-driver-create-client.txt

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ to connect to; if no database name is specified, the client will use the
2929
.. code-block:: ruby
3030

3131
Mongo::Client.new([ '127.0.0.1:27017' ], database: 'mydb')
32-
32+
3333
# Or using the URI syntax:
3434
Mongo::Client.new("mongodb://127.0.0.1:27017/mydb")
3535

@@ -82,7 +82,7 @@ The database can be specified during ``Client`` construction:
8282

8383
# Using Ruby client options:
8484
client = Mongo::Client.new(['localhost'], database: 'mydb')
85-
85+
8686
# Using a MongoDB URI:
8787
client = Mongo::Client.new('mongodb://localhost/mydb')
8888

@@ -92,9 +92,9 @@ new ``Client`` instance configured with the specified database:
9292
.. code-block:: ruby
9393

9494
client = Mongo::Client.new(['localhost'], database: 'mydb')
95-
95+
9696
admin_client = client.use('admin')
97-
97+
9898
# Issue an administrative command
9999
admin_client.database.command(replSetGetConfig: 1).documents.first
100100

@@ -125,7 +125,7 @@ To force all operations to be performed on the designated server, specify the
125125
.. code-block:: ruby
126126

127127
Mongo::Client.new([ '1.2.3.4:27017' ], database: 'mydb', direct_connection: true)
128-
128+
129129
# Or using the URI syntax:
130130
Mongo::Client.new("mongodb://1.2.3.4:27017/mydb?directConnection=true")
131131

@@ -153,7 +153,7 @@ connect to the replica set.
153153

154154
Mongo::Client.new([ '127.0.0.1:27017', '127.0.0.1:27018' ],
155155
:database => 'mydb', replica_set: 'myapp')
156-
156+
157157
# Or using the URI syntax:
158158
Mongo::Client.new("mongodb://127.0.0.1:27017,127.0.0.1:27018/mydb?replicaSet=myapp")
159159

@@ -186,7 +186,7 @@ spread the operation load accordingly.
186186
.. code-block:: ruby
187187

188188
Mongo::Client.new([ '1.2.3.4:27017', '1.2.3.5:27017' ], :database => 'mydb')
189-
189+
190190
Mongo::Client.new("mongodb://1.2.3.4:27017,1.2.3.5:27017/mydb")
191191

192192

@@ -270,7 +270,7 @@ Ruby Options
270270

271271
* - ``:auth_mech_properties``
272272
- Provides additional authentication mechanism properties.
273-
273+
274274
The keys in properties are interpreted case-insensitively.
275275
When the client is created, keys are lowercased.
276276

@@ -319,8 +319,8 @@ Ruby Options
319319
- none
320320

321321
* - ``:compressors``
322-
- A list of potential compressors to use, in order of preference. The driver chooses the first
323-
compressor that is also supported by the server. Currently the driver only supports 'zlib'.
322+
- A list of potential compressors to use, in order of preference.
323+
Please see below for details on how the driver implements compression.
324324
- ``Array<String>``
325325
- none
326326

@@ -436,11 +436,11 @@ Ruby Options
436436
max_staleness: 5,
437437
}
438438
}
439-
439+
440440
If tag sets are provided, they must be an array of hashes. A server
441441
satisfies the read preference if its tags match any one hash in the
442442
provided tag sets.
443-
443+
444444
Each tag set must be a hash, and will be converted internally to
445445
a ``BSON::Document`` instance prior to being used for server selection.
446446
Hash keys can be strings or symbols. The keys are case sensitive.
@@ -480,12 +480,12 @@ Ruby Options
480480
subscriber not receiving some of the SDAM events. The ``:sdam_proc``
481481
option permits adding event subscribers on the client being constructed
482482
before any SDAM events are published.
483-
483+
484484
Pass a ``Proc`` which will be called with the ``Client`` as the argument
485485
after the client's event subscription mechanism has been initialized
486486
but before any of the servers are added to the client. Use this
487487
``Proc`` to set up SDAM event subscribers on the client.
488-
488+
489489
Note: the client is not fully constructed when the ``Proc`` provided in
490490
``:sdam_proc is invoked, in particular the cluster is nil at this time.
491491
``:sdam_proc`` procedure should limit itself to calling
@@ -696,6 +696,7 @@ URI options are explained in detail in the :manual:`Connection URI reference
696696
</reference/connection-string/>`.
697697

698698
.. note::
699+
699700
Options that are set in **milliseconds** in the URI are
700701
represented as a ``float`` in Ruby and the units are **seconds**.
701702

@@ -1090,6 +1091,53 @@ file and both must be stored in the same file. Example usage:
10901091
URI option values must be properly URI escaped. This applies, for example, to
10911092
slashes in the paths.
10921093

1094+
1095+
.. _modifying-tls-context:
1096+
1097+
Modifying ``SSLContext``
1098+
------------------------
1099+
It may be desirable to further configure TLS options in the driver, for example
1100+
by enabling or disabling certain ciphers. Currently, the Ruby driver does not
1101+
provide a way to do this when initializing a ``Mongo::Client``.
1102+
1103+
However, the Ruby driver provides a way to set global "TLS context hooks" --
1104+
these are user-provided ``Proc``s that will be invoked before any TLS socket
1105+
connection and can be used to modify the underlying ``OpenSSL::SSL::SSLContext``
1106+
object used by the socket.
1107+
1108+
To set the TLS context hooks, add ``Proc``s to the ``Mongo.tls_context_hooks``
1109+
array. This should be done before creating any Mongo::Client instances.
1110+
For example, in a Rails application this code could be placed in an initializer.
1111+
1112+
.. code-block:: ruby
1113+
1114+
Mongo.tls_context_hooks.push(
1115+
Proc.new { |context|
1116+
context.ciphers = ["AES256-SHA"]
1117+
}
1118+
)
1119+
1120+
# Only the AES256-SHA cipher will be enabled from this point forward
1121+
1122+
Every ``Proc`` in ``Mongo.tls_context_hooks`` will be passed an
1123+
``OpenSSL::SSL::SSLContext`` object as its sole argument. These ``Proc``s will
1124+
be executed sequentially during the creation of every ``Mongo::Socket::SSL`` object.
1125+
1126+
It is possible to assign the entire array of hooks calling ``Mongo.tls_context_hooks=``,
1127+
but doing so will remove any previously assigned hooks. It is recommended to use
1128+
the ``Array#push`` or ``Array#unshift`` methods to add new hooks.
1129+
1130+
It is also possible to remove hooks from ``Mongo.tls_context_hooks`` by storing
1131+
a reference to the Procs somewhere else in the application, and then using
1132+
``Array#delete_if`` to remove the desired hooks.
1133+
1134+
.. warning::
1135+
1136+
TLS context hooks are global and will affect every instance of ``Mongo::Client``.
1137+
Any library that allows applications to enable these hooks should expose methods to
1138+
modify the hooks (which can be called by the application) rather than
1139+
automatically enabling the hooks when the library is loaded.
1140+
10931141
Further information on configuring MongoDB server for TLS is available in the
10941142
:manual:`MongoDB manual </tutorial/configure-ssl/>`.
10951143

@@ -1162,10 +1210,13 @@ The ``:ssl_ca_cert_string`` option supports specifying only one CA certificate.
11621210
CA certificate options. Doing so would elevate the intermediate certificates
11631211
to the status of root certificates, rather than verifying intermediate
11641212
certificates against the root certificates.
1165-
1213+
11661214
If intermediate certificates need to be used, specify them as part of the
11671215
client or server TLS certificate files.
11681216

1217+
1218+
.. _ocsp-verification:
1219+
11691220
OCSP Verification
11701221
-----------------
11711222

@@ -1300,7 +1351,7 @@ Usage with Forking Servers
13001351
==========================
13011352

13021353
.. note::
1303-
1354+
13041355
Applications using Mongoid should follow `Mongoid's forking guidance
13051356
<https://docs.mongodb.com/mongoid/current/tutorials/mongoid-configuration/#usage-with-forking-servers>`_.
13061357
The guidance and sample code below is provided for applications using the
@@ -1316,7 +1367,7 @@ This is because:
13161367
2. File descriptors like network sockets are shared between parent and
13171368
child processes.
13181369

1319-
The driver attempts to detect client use from forked processes and
1370+
The driver attempts to detect client use from forked processes and
13201371
reestablish network connections when such use is detected, alleviating
13211372
the issue of file descriptor sharing.
13221373

docs/tutorials/ruby-driver-crud-operations.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ underscore one that Ruby driver uses.
900900
A Note about the BSON Symbol type
901901
=================================
902902

903-
Because the BSON specification deprecated the BSON symbol type, the `bson` gem
903+
Because the BSON specification deprecated the BSON symbol type, the ``bson`` gem
904904
will serialize Ruby symbols into BSON strings when used on its own. However, in
905905
order to maintain backwards compatibility with older datasets, the Ruby driver
906906
overrides this behavior to serialize Ruby symbols as BSON symbols. This is

docs/tutorials/ruby-driver-gridfs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ by default into the ``fs.chunks`` collection and file metadata is inserted into
252252

253253
client.database.fs.insert_one(file)
254254

255-
To insert into collections with a name prefix other than `fs`, access the
255+
To insert into collections with a name prefix other than ``fs``, access the
256256
filesystem with a ``:fs_name`` option.
257257

258258
.. code-block:: ruby

0 commit comments

Comments
 (0)