summaryrefslogtreecommitdiff
path: root/src/mongo/crypto
diff options
context:
space:
mode:
authorDavis Haupt <davis.haupt@mongodb.com>2022-08-03 15:31:22 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-03 17:18:53 +0000
commit301f931aff01aad1352b6dd725bfbcae807450ef (patch)
treed4fe1f780aec22d0d62f117f7656e557e3f2e52c /src/mongo/crypto
parent32372d5f837bab5cf8a9abd312d28b5a7071b6fa (diff)
downloadmongo-301f931aff01aad1352b6dd725bfbcae807450ef.tar.gz
SERVER-68334 indicate difference between inclusive/exclusive bounds in range intent-to-encrypt marking
Diffstat (limited to 'src/mongo/crypto')
-rw-r--r--src/mongo/crypto/fle_field_schema.idl17
-rw-r--r--src/mongo/crypto/fle_fields_util.cpp17
-rw-r--r--src/mongo/crypto/fle_fields_util.h2
3 files changed, 31 insertions, 5 deletions
diff --git a/src/mongo/crypto/fle_field_schema.idl b/src/mongo/crypto/fle_field_schema.idl
index 0e07ddd606e..84555174cc8 100644
--- a/src/mongo/crypto/fle_field_schema.idl
+++ b/src/mongo/crypto/fle_field_schema.idl
@@ -261,3 +261,20 @@ structs:
description: "Encrypted value"
type: bindata_generic
+ FLE2RangeSpec:
+ description: "Range specification that is encoded inside of a FLE2EncryptionPlaceholder."
+ strict: true
+ cpp_validator_func: "validateIDLFLE2RangeSpec"
+ fields:
+ min:
+ description: "The minimum value for an encrypted range query."
+ type: IDLAnyType
+ minIncluded:
+ description: "Indicates if the lower bound should be included in the range."
+ type: bool
+ max:
+ description: "The maximum value for an encrypted range query."
+ type: IDLAnyType
+ maxIncluded:
+ description: "Indicates if the upper bound should be included in the range."
+ type: bool
diff --git a/src/mongo/crypto/fle_fields_util.cpp b/src/mongo/crypto/fle_fields_util.cpp
index 96c49c1a7f5..545c59d788e 100644
--- a/src/mongo/crypto/fle_fields_util.cpp
+++ b/src/mongo/crypto/fle_fields_util.cpp
@@ -37,12 +37,19 @@ namespace mongo {
void validateIDLFLE2EncryptionPlaceholder(const FLE2EncryptionPlaceholder* placeholder) {
if (placeholder->getAlgorithm() == Fle2AlgorithmInt::kRange) {
auto val = placeholder->getValue().getElement();
- uassert(6720200, "Range placeholder must be an array.", val.isABSONObj());
+ uassert(6720200, "Range placeholder value must be an object.", val.isABSONObj());
auto obj = val.Obj();
- uassert(6720201, "Range placeholder must be an array.", obj.couldBeArray());
- uassert(6720202,
- "Range placeholder must hold an array with a min and max value.",
- obj.nFields() == 2);
+ FLE2RangeSpec::parse(IDLParserContext("v"), obj);
}
}
+void validateIDLFLE2RangeSpec(const FLE2RangeSpec* placeholder) {
+ auto min = placeholder->getMin().getElement();
+ auto max = placeholder->getMax().getElement();
+ uassert(6833400,
+ str::stream() << "Minimum element in a range must be numeric, not: " << min.type(),
+ min.isNumber() || min.type() == BSONType::MinKey);
+ uassert(6833401,
+ str::stream() << "Maximum element in a range must be numeric, not: " << max.type(),
+ max.isNumber() || max.type() == BSONType::MaxKey);
+}
} // namespace mongo
diff --git a/src/mongo/crypto/fle_fields_util.h b/src/mongo/crypto/fle_fields_util.h
index dc4b60f0342..37184c681bc 100644
--- a/src/mongo/crypto/fle_fields_util.h
+++ b/src/mongo/crypto/fle_fields_util.h
@@ -31,10 +31,12 @@
namespace mongo {
class FLE2EncryptionPlaceholder;
+class FLE2RangeSpec;
/**
* Extra validation for the placeholder struct to verify that range placeholders have min/max
* endpoints. Will throw a uassert if the placeholder does not pass validation.
*/
void validateIDLFLE2EncryptionPlaceholder(const FLE2EncryptionPlaceholder* placeholder);
+void validateIDLFLE2RangeSpec(const FLE2RangeSpec* placeholder);
} // namespace mongo