summaryrefslogtreecommitdiff
path: root/src/mongo/logv2
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-12-13 11:21:33 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-13 17:05:29 +0000
commitc8de2a7f419f2486780fed5ae06ade4e78aa2a5d (patch)
tree64e42361aff867f2400f0eafbef5a76f9d0fcb7c /src/mongo/logv2
parentcaa1c89688d523d69001aedc92ed174234e2b7ff (diff)
downloadmongo-c8de2a7f419f2486780fed5ae06ade4e78aa2a5d.tar.gz
SERVER-61846 add redaction test for small fields
Diffstat (limited to 'src/mongo/logv2')
-rw-r--r--src/mongo/logv2/redaction_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/logv2/redaction_test.cpp b/src/mongo/logv2/redaction_test.cpp
index e6feb6de33c..8ab293822c2 100644
--- a/src/mongo/logv2/redaction_test.cpp
+++ b/src/mongo/logv2/redaction_test.cpp
@@ -154,5 +154,18 @@ TEST(RedactBSONTest, BSONWithArrays) {
testBSONCases(testCases);
}
+
+TEST(RedactBSONTest, RedactCausesBSONTooLarge) {
+ logv2::setShouldRedactLogs(true);
+ BSONObjBuilder bob;
+ for (int i = 0; i < 1024 * 1024; i++) {
+ auto fieldName = "abcdefg";
+ // The value of each field is smaller than the size of the kRedactionDefaultMask.
+ bob.append(fieldName, 1);
+ }
+ const auto obj = bob.obj();
+ // Demonstrates it is possible to grow a BSON too large by redacting fields.
+ ASSERT_THROWS_CODE(redact(obj), DBException, ErrorCodes::BSONObjectTooLarge);
+}
} // namespace
} // namespace mongo