summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/object_check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/rpc/object_check.cpp')
-rw-r--r--src/mongo/rpc/object_check.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/mongo/rpc/object_check.cpp b/src/mongo/rpc/object_check.cpp
index 98ddda58697..37a8a8c77a6 100644
--- a/src/mongo/rpc/object_check.cpp
+++ b/src/mongo/rpc/object_check.cpp
@@ -25,14 +25,38 @@
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
-
#include "mongo/platform/basic.h"
#include "mongo/rpc/object_check.h"
#include "mongo/base/status.h"
+#include "mongo/bson/bson_depth.h"
+#include "mongo/db/server_parameters.h"
+#include "mongo/util/stringutils.h"
namespace mongo {
+namespace {
+class MaxBSONDepthParameter
+ : public ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly> {
+public:
+ MaxBSONDepthParameter()
+ : ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly>(
+ ServerParameterSet::getGlobal(), "maxBSONDepth", &BSONDepth::maxAllowableDepth) {}
+
+ virtual Status validate(const std::int32_t& potentialNewValue) {
+ if (potentialNewValue < BSONDepth::kBSONDepthParameterFloor ||
+ potentialNewValue > BSONDepth::kBSONDepthParameterCeiling) {
+ return Status(ErrorCodes::BadValue,
+ str::stream() << "maxBSONDepth must be between "
+ << BSONDepth::kBSONDepthParameterFloor
+ << " and "
+ << BSONDepth::kBSONDepthParameterCeiling
+ << ", inclusive");
+ }
+ return Status::OK();
+ }
+} maxBSONDepthParameter;
+} // namespace
Status Validator<BSONObj>::validateStore(const BSONObj& toStore) {
return Status::OK();