[CDRIVER-1341] Driver should validate BSON documents before insert and update Created: 22/Jun/16  Updated: 07/Sep/17  Resolved: 20/Jan/17

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.6.0

Type: Improvement Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by PHPC-712 Driver should validate BSON documents... Closed
is depended on by DRIVERS-308 BSON Key Validation in Drivers Closed
Duplicate
is duplicated by CDRIVER-1111 Provide error feedback for invalid ne... Closed
Related
related to CDRIVER-2017 Inconsistent error reporting for inse... Closed
related to CDRIVER-1932 mongoc_collection_update() omits vali... Closed
related to CDRIVER-2265 Overly validating documents in bulk i... Closed
related to CDRIVER-2016 Report offending field name in BSON v... Closed
related to PHPC-579 Throw exception for invalid BulkWrite... Closed

 Description   

Currently libmongoc's bulk write API does not validate BSON keys in documents when doing update/insert.

No keys starting with "$" or containing ".":

  • mongoc_collection_insert - tested in test_insert
  • mongoc_collection_insert_bulk - test_insert_bulk
  • mongoc_bulk_operation_insert - test_insert_check_keys
  • mongoc_collection_save - test_save
  • "document" param to mongoc_bulk_operation_replace_one - test_replace_one_check_keys
  • "document" param to mongoc_bulk_operation_replace_one_with_opts - test_replace_one_with_opts_check_keys

All keys must start with "$":

  • "document" param to mongoc_bulk_operation_update - test_update_check_keys
  • "document" param to mongoc_bulk_operation_update_many_with_opts - test_update_many_with_opts_check_keys
  • "document" param to mongoc_bulk_operation_update_one - test_update_one_check_keys
  • "document" param to mongoc_bulk_operation_update_one_with_opts - test_update_one_with_opts_check_keys


 Comments   
Comment by Githook User [ 08/May/17 ]

Author:

{u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

Message: PHPC-579: Regression test mixing update/replacement with BulkWrite::update()

CDRIVER-1341 implemented client-side detection of the invalid newObj argument.
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/e30a90668fb203daa0c066d0491ec36eaf34eef1

Comment by Githook User [ 20/Jan/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1341 proper UTF-8 strings in tests
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/4382859be07d7a3ceb3f59755a86765ceea6601e

Comment by Githook User [ 20/Jan/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1341 validate keys for insert and update

Keys in documents for insert, save, or replace must not contain "." or start with "$". Keys in documents for update must all start with "$".
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/4b37e655ac066514350d08c882d385c881c7a438

Comment by Bernie Hackett [ 18/Oct/16 ]

No need to wait for a spec. '$' and '.' are invalid for insert and upsert. Make it so.

Generated at Wed Feb 07 21:12:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.