diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2019-03-01 16:46:58 +0000 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2019-03-02 03:41:04 +0000 |
commit | 5e09c6eb9f8bcfbb0364ec984e293d51eea9cecf (patch) | |
tree | f09d793e110b66ee39d21cd83bac4dc319d40867 /src/mongo/rpc | |
parent | 0f2b2a4654df2eaaa63d6b39d8320d0c68471998 (diff) | |
download | mongo-5e09c6eb9f8bcfbb0364ec984e293d51eea9cecf.tar.gz |
SERVER-39905 Migrate object_check set param to IDL
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r-- | src/mongo/rpc/SConscript | 5 | ||||
-rw-r--r-- | src/mongo/rpc/object_check.cpp | 25 | ||||
-rw-r--r-- | src/mongo/rpc/object_check.idl | 42 |
3 files changed, 47 insertions, 25 deletions
diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript index f5892449616..9ce0c49fe40 100644 --- a/src/mongo/rpc/SConscript +++ b/src/mongo/rpc/SConscript @@ -51,6 +51,7 @@ env.Library( 'legacy_reply.cpp', 'legacy_reply_builder.cpp', 'reply_builder_interface.cpp', + env.Idlc('object_check.idl')[0], ], LIBDEPS=[ 'metadata', @@ -58,10 +59,12 @@ env.Library( '$BUILD_DIR/mongo/util/net/network', '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/dbmessage', - '$BUILD_DIR/mongo/db/server_parameters', '$BUILD_DIR/mongo/db/server_options_core', '$BUILD_DIR/mongo/s/common_s', ], + LIBDEPS_PRIVATE=[ + '$BUILD_DIR/mongo/idl/server_parameter', + ], ) env.Library( diff --git a/src/mongo/rpc/object_check.cpp b/src/mongo/rpc/object_check.cpp index f28055d3da6..2109d96776d 100644 --- a/src/mongo/rpc/object_check.cpp +++ b/src/mongo/rpc/object_check.cpp @@ -31,32 +31,9 @@ #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/platform/compiler.h" -#include "mongo/util/stringutils.h" +#include "mongo/bson/bsonobj.h" namespace mongo { -namespace { - -MONGO_COMPILER_VARIABLE_UNUSED auto _exportedMaxBSONDepth = - (new ExportedServerParameter<std::int32_t, ServerParameterType::kStartupOnly>( - ServerParameterSet::getGlobal(), "maxBSONDepth", &BSONDepth::maxAllowableDepth)) - -> withValidator([](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(); - }); - -} // namespace - Status Validator<BSONObj>::validateStore(const BSONObj& toStore) { return Status::OK(); } diff --git a/src/mongo/rpc/object_check.idl b/src/mongo/rpc/object_check.idl new file mode 100644 index 00000000000..59b5803b31b --- /dev/null +++ b/src/mongo/rpc/object_check.idl @@ -0,0 +1,42 @@ +# Copyright (C) 2019-present MongoDB, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the Server Side Public License, version 1, +# as published by MongoDB, Inc. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Server Side Public License for more details. +# +# You should have received a copy of the Server Side Public License +# along with this program. If not, see +# <http://www.mongodb.com/licensing/server-side-public-license>. +# +# As a special exception, the copyright holders give permission to link the +# code of portions of this program with the OpenSSL library under certain +# conditions as described in each individual source file and distribute +# linked combinations including the program with the OpenSSL library. You +# must comply with the Server Side Public License in all respects for +# all of the code used other than as permitted herein. If you modify file(s) +# with this exception, you may extend this exception to your version of the +# file(s), but you are not obligated to do so. If you do not wish to do so, +# delete this exception statement from your version. If you delete this +# exception statement from all source files in the program, then also delete +# it in the license file. +# + +global: + cpp_namespace: "mongo" + cpp_includes: + - "mongo/bson/bson_depth.h" + +server_parameters: + maxBSONDepth: + description: 'Maximum nesting depth of BSON objects' + set_at: startup + cpp_varname: 'BSONDepth::maxAllowableDepth' + validator: + gte: { expr: 'BSONDepth::kBSONDepthParameterFloor' } + lte: { expr: 'BSONDepth::kBSONDepthParameterCeiling' } + |