Skip to content

Instantly share code, notes, and snippets.

@kevinAlbs
Created May 4, 2019 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinAlbs/94535c37c53e26fd5b485004bcab3d9e to your computer and use it in GitHub Desktop.
Save kevinAlbs/94535c37c53e26fd5b485004bcab3d9e to your computer and use it in GitHub Desktop.
mongocryptd should fail if query has $jsonSchema, but doesn't.
/*
* start mongocryptd, then do:
* mongo --port 27020 repro.js
*/
var schema = {
properties: {
ssn: {
encrypt: {
keyId: [
BinData(4, "AAAAAAAAAAAAAAAAAAAAAA==")
],
bsonType: "string",
algorithm: "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic",
initializationVector: BinData(0, "aWlpaWlpaWlpaWlpaWlpaQ==")
}
}
},
bsonType: "object"
};
var cmd = {
find: "coll",
/* specifying $jsonSchema in filter should error. */
filter: { $jsonSchema: { properties: {} } },
jsonSchema: schema
};
printjson(db.runCommand(cmd))
/* prints:
{
"hasEncryptionPlaceholders" : false,
"schemaRequiresEncryption" : true,
"result" : {
"find" : "coll",
"filter" : {
"$and" : [
{
}
]
},
"$db" : "test"
},
"ok" : 1
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment