From 7b2076591e5e50c4b799766ae1a282d7a0e4594f Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Tue, 1 Aug 2023 12:13:58 -0700 Subject: [PATCH 1/2] PYTHON-3893 Add BSON Binary Data subtype Sensitive --- bson/binary.py | 7 +++++++ doc/api/bson/binary.rst | 1 + test/bson_corpus/binary.json | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/bson/binary.py b/bson/binary.py index 9a0c061382..f8405f9074 100644 --- a/bson/binary.py +++ b/bson/binary.py @@ -183,6 +183,13 @@ class UuidRepresentation: .. versionadded:: 4.0 """ +SENSITIVE_SUBTYPE = 8 +"""BSON binary subtype for sensitive data. + +.. versionadded:: 7.0 +""" + + USER_DEFINED_SUBTYPE = 128 """BSON binary subtype for any user defined structure. """ diff --git a/doc/api/bson/binary.rst b/doc/api/bson/binary.rst index b9673d70d9..c933a687b9 100644 --- a/doc/api/bson/binary.rst +++ b/doc/api/bson/binary.rst @@ -15,6 +15,7 @@ .. autodata:: CSHARP_LEGACY .. autodata:: MD5_SUBTYPE .. autodata:: COLUMN_SUBTYPE + .. autodata:: SENSITIVE_SUBTYPE .. autodata:: USER_DEFINED_SUBTYPE .. autoclass:: UuidRepresentation diff --git a/test/bson_corpus/binary.json b/test/bson_corpus/binary.json index beb2e07a70..20aaef743b 100644 --- a/test/bson_corpus/binary.json +++ b/test/bson_corpus/binary.json @@ -55,6 +55,11 @@ "canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400", "canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}" }, + { + "description": "subtype 0x08", + "canonical_bson": "1D000000057800100000000873FFD26444B34C6990E8E7D1DFC035D400", + "canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"08\"}}}" + }, { "description": "subtype 0x80", "canonical_bson": "0F0000000578000200000080FFFF00", From 9a82e845c859ede2dcececb676155b998f3ff4a2 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Tue, 1 Aug 2023 14:23:26 -0700 Subject: [PATCH 2/2] Use correct pymongo version --- bson/binary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bson/binary.py b/bson/binary.py index f8405f9074..0727bd17c0 100644 --- a/bson/binary.py +++ b/bson/binary.py @@ -186,7 +186,7 @@ class UuidRepresentation: SENSITIVE_SUBTYPE = 8 """BSON binary subtype for sensitive data. -.. versionadded:: 7.0 +.. versionadded:: 4.5 """