summaryrefslogtreecommitdiff
path: root/src/mongo/s/query/cluster_aggregate.cpp
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2020-12-16 17:47:49 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-12 02:05:04 +0000
commit466467f1d0bbe80ea15fded0750908cf57a9c463 (patch)
treea66e68b4296ee43796dd3859888f5eaf54c89ce3 /src/mongo/s/query/cluster_aggregate.cpp
parent3b8ae3847dc7021ed231c96a891d14fc6ed7d1a6 (diff)
downloadmongo-466467f1d0bbe80ea15fded0750908cf57a9c463.tar.gz
SERVER-51618 Disallow pipeline stages that are not part of API version 1 with apiStrict:true
Diffstat (limited to 'src/mongo/s/query/cluster_aggregate.cpp')
-rw-r--r--src/mongo/s/query/cluster_aggregate.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp
index 4c80fb988d0..bdbcd306c5e 100644
--- a/src/mongo/s/query/cluster_aggregate.cpp
+++ b/src/mongo/s/query/cluster_aggregate.cpp
@@ -35,6 +35,7 @@
#include <boost/intrusive_ptr.hpp>
+#include "mongo/db/api_parameters.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
@@ -203,6 +204,15 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx,
const LiteParsedPipeline& liteParsedPipeline,
const PrivilegeVector& privileges,
BSONObjBuilder* result) {
+ // If 'apiStrict: true', validates that the pipeline does not contain stages which are not in
+ // this API version.
+ auto apiParameters = APIParameters::get(opCtx);
+ if (apiParameters.getAPIStrict().value_or(false)) {
+ auto apiVersion = apiParameters.getAPIVersion().value_or("");
+ if (!apiVersion.empty())
+ liteParsedPipeline.validatePipelineStagesIfAPIStrict(apiVersion);
+ }
+
uassert(51028, "Cannot specify exchange option to a mongos", !request.getExchange());
uassert(51143,
"Cannot specify runtime constants option to a mongos",