PYTHON-4468 Hide the value of sensitive subtype binary objects (#1649)

Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
This commit is contained in:
Terry Patterson 2024-05-30 17:44:06 -04:00 committed by GitHub
parent 49987e6a8a
commit ac66c9dfd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View File

@ -364,4 +364,7 @@ class Binary(bytes):
return not self == other
def __repr__(self) -> str:
return f"Binary({bytes.__repr__(self)}, {self.__subtype})"
if self.__subtype == SENSITIVE_SUBTYPE:
return f"<Binary(REDACTED, {self.__subtype})>"
else:
return f"Binary({bytes.__repr__(self)}, {self.__subtype})"

View File

@ -6,6 +6,8 @@ Changes in Version 4.8.0
The handshake metadata for "os.name" on Windows has been simplified to "Windows" to improve import time.
The repr of ``bson.binary.Binary`` is now redacted when the subtype is SENSITIVE_SUBTYPE(8).
.. warning:: PyMongo 4.8 drops support for Python 3.7 and PyPy 3.8: Python 3.8+ or PyPy 3.9+ is now required.
Changes in Version 4.7.3

View File

@ -100,3 +100,4 @@ The following is a list of people who have contributed to
- Stephan Hof (stephan-hof)
- Casey Clements (caseyclements)
- Ivan Lukyanchikov (ilukyanchikov)
- Terry Patterson