From 26bcf4ddd7e86885448e981f86aaf51fba0e2539 Mon Sep 17 00:00:00 2001 From: David Storch Date: Mon, 14 Dec 2015 18:22:01 -0500 Subject: SERVER-21407 explicitly disallow $text/$where extensions during MatchExpression parsing --- src/mongo/db/commands/index_filter_commands_test.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mongo/db/commands/index_filter_commands_test.cpp') diff --git a/src/mongo/db/commands/index_filter_commands_test.cpp b/src/mongo/db/commands/index_filter_commands_test.cpp index 5a0d7b6ce07..463f1bb117e 100644 --- a/src/mongo/db/commands/index_filter_commands_test.cpp +++ b/src/mongo/db/commands/index_filter_commands_test.cpp @@ -34,6 +34,7 @@ #include "mongo/db/json.h" +#include "mongo/db/matcher/extensions_callback_disallow_extensions.h" #include "mongo/db/operation_context_noop.h" #include "mongo/db/query/plan_ranker.h" #include "mongo/db/query/query_solution.h" @@ -120,7 +121,8 @@ void addQueryShapeToPlanCache(PlanCache* planCache, BSONObj projectionObj = fromjson(projectionStr); // Create canonical query. - auto statusWithCQ = CanonicalQuery::canonicalize(nss, queryObj, sortObj, projectionObj); + auto statusWithCQ = CanonicalQuery::canonicalize( + nss, queryObj, sortObj, projectionObj, ExtensionsCallbackDisallowExtensions()); ASSERT_OK(statusWithCQ.getStatus()); std::unique_ptr cq = std::move(statusWithCQ.getValue()); @@ -144,7 +146,8 @@ bool planCacheContains(const PlanCache& planCache, BSONObj projectionObj = fromjson(projectionStr); // Create canonical query. - auto statusWithInputQuery = CanonicalQuery::canonicalize(nss, queryObj, sortObj, projectionObj); + auto statusWithInputQuery = CanonicalQuery::canonicalize( + nss, queryObj, sortObj, projectionObj, ExtensionsCallbackDisallowExtensions()); ASSERT_OK(statusWithInputQuery.getStatus()); unique_ptr inputQuery = std::move(statusWithInputQuery.getValue()); @@ -160,7 +163,11 @@ bool planCacheContains(const PlanCache& planCache, // Alternatively, we could add key to PlanCacheEntry but that would be used in one place // only. auto statusWithCurrentQuery = - CanonicalQuery::canonicalize(nss, entry->query, entry->sort, entry->projection); + CanonicalQuery::canonicalize(nss, + entry->query, + entry->sort, + entry->projection, + ExtensionsCallbackDisallowExtensions()); ASSERT_OK(statusWithCurrentQuery.getStatus()); unique_ptr currentQuery = std::move(statusWithCurrentQuery.getValue()); -- cgit v1.2.1