[JAVA-4236] Test serialization of BSON with embedded null bytes in strings Created: 15/Jul/21  Updated: 28/Oct/23  Resolved: 24/Sep/21

Status: Closed
Project: Java Driver
Component/s: BSON, Test Coverage
Affects Version/s: None
Fix Version/s: 4.4.0

Type: Improvement Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: spec-compliance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
Quarter: FY22Q3
Documentation Changes: Not Needed

 Description   

Downstream changes: drivers should sync BSON corpus spec tests with mongodb/specifications@ff5d91f. Specifically:

  • There are new decodeErrors tests for document.json, regex.json, and top.json
  • There are new parseErrors tests for top.json
  • There are new prose tests for encoding BSON documents and regex types.

Existing language in the spec was also relaxed to no longer require drivers to successfully parse parseErrors tests in binary.json and top.json with a non-Extended JSON parser (to check for general JSON syntax errors). Also, an allowance was made for drivers that parse Extended JSON directly into language types (with regard to evaluating parseErrors).


Per DRIVERS-101, drivers are expected to validate that C strings do not contain embedded null bytes.

We should add spec or prose tests to verify BSON C strings with embedded null bytes are rejected when serialized.



 Comments   
Comment by Githook User [ 24/Sep/21 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Test for null byte in BSON cstring (#786)

The driver already has the necessary checks

One functional change to note though: this commit does remove the null byte check in BsonDocument#put, instead relying on BsonBinaryWriter's null byte checking in cstrings. This is consistent with the lack of null byte checks in org.bson.Document and BsonRegularExpression, as well as other drivers that use plain old dictionaries to represent BSON.

JAVA-4236
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/ee236be80b82c2a1cca27ae6245cfcd0b059e85d

Generated at Thu Feb 08 09:01:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.