[CXX-618] scons install does not copy mongo/bson/bson_validate.h Created: 06/Jul/15  Updated: 06/Dec/16  Resolved: 06/Jul/15

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: legacy-1.0.3
Fix Version/s: legacy-1.0.4

Type: Bug Priority: Minor - P4
Reporter: Martin Sucha Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

This header is not copied into include path during scons install, which means mongo::validateBSON(const char*, uint64) can't be used from client applications.

I'm setting priority Minor since this affects only a single function and the workaround is to copy the header to the correct place manually after installing.



 Comments   
Comment by Martin Sucha [ 07/Jul/15 ]

Thank you!

Comment by Githook User [ 06/Jul/15 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: CXX-618 Export validateBSON method
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/a34b0a8140723d2d2e7357603214791644b8ac70

Comment by Andrew Morrow (Inactive) [ 06/Jul/15 ]

https://github.com/mongodb/mongo-cxx-driver/pull/299

Comment by Andrew Morrow (Inactive) [ 06/Jul/15 ]

I think that is a reasonable use case. The alternative would be to use a non-owning BSONObj and then call its ::valid method, which would in turn call validateBSON, but that is somewhat sketchy because there is no way to specify a maximum valid memory region when using the BSONObj constructor.

If you are interested, please send us a github pull request. The steps to fix this should be fairly easy:

  • Add the bson_validate.h header to the list of published headers
  • Add the necessary export macro to the declaration of validateBSON.
  • Add bson_validate.h to the bson.h facade header.
  • Write (or extend) a client example that uses validateBSON, to ensure that consumers of the driver can see the header and link against the symbol.

Otherwise we will try to get this done for the next release.

Comment by Martin Sucha [ 06/Jul/15 ]

Thank you for quick response.

In addition to querying MongoDB, we need to be able to process BSON objects encoded in a network stream using another network protocol. For this to work, we need to be able to validate BSON objects in arbitrary memory buffer.

Comment by Andrew Morrow (Inactive) [ 06/Jul/15 ]

Thanks for the report.

No export macro is attached to the declaration of validateBSON, so copying the header alone is insufficient when mongoclient is compiled as a shared library. When separating the driver from the server repository, headers were added to the install target (and annotated with export macros as needed) only if they were reachable from either the bson.h or dbclient.h facade headers, since these headers represent the user facing interface to the library. The bson_validate.h header is not reachable from either bson.h or dbclient.h, so it was never annotated or added to the install target.

Our default position is to not expand the public interface of the driver without a compelling use case. Could you please describe why you need to call validateBSON directly? Please note that you can configure the driver to automatically do validation of BSON returned from the server by way of the mongo::client::Options::setValidateObjects API call.

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