feat(document): add optional sync client via get_mongodb_sync#8
Conversation
shreyas-lyzr
left a comment
There was a problem hiding this comment.
Three issues before merge: a security vulnerability in the pinned minimum version (blocking), a missing dev dependency that will break CI (blocking), and a routing edge case worth a docstring warning or test. Full details in inline comments.
| aws = [ | ||
| "aioboto3>=13.0.0", # native async S3 / SQS / SNS / Secrets Manager / SES | ||
| "motor>=3.3.0", # async MongoDB driver for DocumentDB | ||
| "pymongo>=4.5.0", # sync MongoDB driver (optional sync client) |
There was a problem hiding this comment.
Security — blocking: pymongo>=4.5.0 allows any version up to (but not including) the fix, so an install could land on 4.5.x or 4.6.0–4.6.2, all of which carry CVE-2024-5629 (GHSA-m87m-mmvp-v9qm, CVSS 6.1). The vulnerability is an out-of-bounds read in the bson module: a server-crafted BSON document can cause the parser to read past the buffer. Fixed in 4.6.3. Bump all three occurrences of this lower bound (aws extra line 39, azure extra line 50, all extra line 62):
| "pymongo>=4.5.0", # sync MongoDB driver (optional sync client) | |
| "pymongo>=4.6.3", # sync MongoDB driver (optional sync client) |
Reference: https://osv.dev/vulnerability/GHSA-m87m-mmvp-v9qm
| "azure-eventgrid>=4.9.0", | ||
| "azure-communication-email>=1.0.0", | ||
| "motor>=3.3.0", # Cosmos DB via MongoDB API | ||
| "pymongo>=4.5.0", # sync MongoDB driver (optional sync client) |
There was a problem hiding this comment.
Same CVE-2024-5629 issue here — azure extra should also pin pymongo>=4.6.3.
| "pymongo>=4.5.0", # sync MongoDB driver (optional sync client) | |
| "pymongo>=4.6.3", # sync MongoDB driver (optional sync client) |
| all = [ | ||
| "aioboto3>=13.0.0", | ||
| "motor>=3.3.0", | ||
| "pymongo>=4.5.0", |
There was a problem hiding this comment.
Same CVE-2024-5629 fix needed in the all extra:
| "pymongo>=4.5.0", | |
| "pymongo>=4.6.3", |
|
Two additional notes not easily attached as inline comments: pymongo missing from dev extra (blocking for CI) The dev extra (pyproject.toml lines 72–85) does not list pymongo. The new test file imports it directly ( Routing edge case: uri + tls_cert_key_file together (suggestion) In both |
|




Closes #7
Mirror the Motor-based async factories with a synchronous variant for
services that don't run an event loop. get_mongodb_sync returns a raw
pymongo.MongoClient (the sync driver Motor wraps) with provider and
auth routing identical to get_mongodb:
documentdb_sync.py: connect_uri / connect_credentials / connect_tls_cert
cosmos_sync.py: connect_connection_string / connect_account_key
(MongoDB API, keys-only — same constraints as the async path)
No wrappers, consistent with the v0.2.0 document refactor: the caller
uses PyMongo's native API directly and manages client.close(). pymongo
is now explicit in the aws/azure/all extras (already transitive via
motor). Tests mirror the async suite's recording-client style.