diff options
author | Arun Banala <arun.banala@mongodb.com> | 2020-11-23 17:32:44 +0530 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-02 10:27:44 +0000 |
commit | 6cf43fbc5c296c26ec03193c70c5fc3ba742c942 (patch) | |
tree | da64ea032d6a9025986ae721a0c03c0502e15aab /src/mongo/db/commands.h | |
parent | 8f4b2d598b492b10f3eee35e5401098f8aeb79de (diff) | |
download | mongo-6cf43fbc5c296c26ec03193c70c5fc3ba742c942.tar.gz |
SERVER-51653 Ban uses of unstable command parameters with apiStrict:true
Diffstat (limited to 'src/mongo/db/commands.h')
-rw-r--r-- | src/mongo/db/commands.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 7cbdf08defb..6014017e7b6 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -39,6 +39,7 @@ #include "mongo/base/init.h" #include "mongo/base/status.h" #include "mongo/base/status_with.h" +#include "mongo/db/api_parameters.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/auth/resource_pattern.h" #include "mongo/db/client.h" @@ -971,10 +972,12 @@ class TypedCommand<Derived>::InvocationBaseInternal : public CommandInvocation { public: using RequestType = typename Derived::Request; - InvocationBaseInternal(OperationContext*, + InvocationBaseInternal(OperationContext* opCtx, const Command* command, const OpMsgRequest& opMsgRequest) - : CommandInvocation(command), _request{_parseRequest(command->getName(), opMsgRequest)} {} + : CommandInvocation(command), + + _request{_parseRequest(opCtx, command->getName(), opMsgRequest)} {} protected: const RequestType& request() const { @@ -982,8 +985,12 @@ protected: } private: - static RequestType _parseRequest(StringData name, const OpMsgRequest& opMsgRequest) { - return RequestType::parse(IDLParserErrorContext(name), opMsgRequest); + static RequestType _parseRequest(OperationContext* opCtx, + StringData name, + const OpMsgRequest& opMsgRequest) { + return RequestType::parse( + IDLParserErrorContext(name, APIParameters::get(opCtx).getAPIStrict().value_or(false)), + opMsgRequest); } RequestType _request; |