The following issues were found

src/mongo/db/query/query_request_test.cpp
1 issues
syntax error
Error

Line: 55

              
static const NamespaceString testns("testdb.testcoll");

TEST(QueryRequestTest, LimitWithNToReturn) {
    FindCommandRequest findCommand(testns);
    findCommand.setLimit(1);
    findCommand.setNtoreturn(0);
    ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}

            

Reported by Cppcheck.

src/mongo/db/query/query_settings_test.cpp
1 issues
syntax error
Error

Line: 85

                  ASSERT_FALSE(filter.allows(ab_idx));
}

TEST(QuerySettingsTest, AllowedIndicesFilterAllowsIndexesByKeyPattern) {
    SimpleBSONObjComparator bsonCmp;
    AllowedIndicesFilter filter(bsonCmp.makeBSONObjSet({fromjson("{a:1}")}), {"a"});
    auto keyPat_a = fromjson("{a:1}");
    IndexEntry a_idx(keyPat_a,
                     mongo::IndexNames::nameToType(mongo::IndexNames::findPluginName(keyPat_a)),

            

Reported by Cppcheck.

src/mongo/db/query/query_solution_test.cpp
1 issues
syntax error
Error

Line: 71

              // Index: {a: 1, b: 1, c: 1, d: 1, e: 1}
// Min: {a: 1, b: 1, c: 1, d: 1, e: 1}
// Max: {a: 1, b: 1, c: 1, d: 1, e: 1}
TEST(QuerySolutionTest, SimpleRangeAllEqual) {
    IndexScanNode node{
        buildSimpleIndexEntry(BSON("a" << 1 << "b" << 1 << "c" << 1 << "d" << 1 << "e" << 1))};
    node.bounds.isSimpleRange = true;
    node.bounds.startKey = BSON("a" << 1 << "b" << 1 << "c" << 1 << "d" << 1 << "e" << 1);
    node.bounds.endKey = BSON("a" << 1 << "b" << 1 << "c" << 1 << "d" << 1 << "e" << 1);

            

Reported by Cppcheck.

src/mongo/db/query/sbe_and_hash_test.cpp
1 issues
syntax error
Error

Line: 80

                  }
};

TEST_F(SbeAndHashTest, TestTwoIndexIntersection) {
    auto docs = std::vector<std::vector<BSONArray>>{
        {BSON_ARRAY(1 << BSON("_id" << 1 << "a" << 1 << "b" << 2)),
         BSON_ARRAY(2 << BSON("_id" << 2 << "a" << 2 << "b" << 2)),
         BSON_ARRAY(3 << BSON("_id" << 3 << "a" << 3 << "b" << 2))},
        {BSON_ARRAY(2 << BSON("_id" << 2 << "a" << 2 << "b" << 2)),

            

Reported by Cppcheck.

src/mongo/db/query/sbe_and_sorted_test.cpp
1 issues
syntax error
Error

Line: 78

                  }
};

TEST_F(SbeAndSortedTest, TestTwoIndexIntersection) {
    auto docs = std::vector<std::vector<BSONArray>>{{BSON_ARRAY(1 << BSON("a" << 1 << "b" << 1)),
                                                     BSON_ARRAY(2 << BSON("a" << 1 << "b" << 2)),
                                                     BSON_ARRAY(3 << BSON("a" << 1 << "b" << 3))},
                                                    {BSON_ARRAY(2 << BSON("a" << 1 << "b" << 2)),
                                                     BSON_ARRAY(3 << BSON("a" << 1 << "b" << 3)),

            

Reported by Cppcheck.

src/mongo/db/query/sbe_cached_solution_planner.cpp
1 issues
open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 114 Column: 25 CWE codes: 362

                              candidate.root->getStats(true /* includeDebugInfo  */);
        }
        candidate.root->close();
        candidate.root->open(false);
        // Clear the results queue.
        candidate.results = decltype(candidate.results){};
    }

    return candidate;

            

Reported by FlawFinder.

src/mongo/db/query/sbe_multi_planner.cpp
1 issues
open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 111 Column: 22 CWE codes: 362

                          winner.data.savedStatsOnEarlyExit = winner.root->getStats(true /* includeDebugInfo  */);
        }
        winner.root->close();
        winner.root->open(false);
        // Clear the results queue.
        winner.results = decltype(winner.results){};
    }

    // Writes a cache entry for the winning plan to the plan cache if possible.

            

Reported by FlawFinder.

src/mongo/db/query/sbe_runtime_planner.cpp
1 issues
open - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 105 Column: 15 CWE codes: 362

              
    auto exitedEarly{false};
    try {
        root->open(false);
    } catch (const ExceptionFor<ErrorCodes::QueryTrialRunCompleted>&) {
        exitedEarly = true;
    } catch (const ExceptionFor<ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed>& ex) {
        root->close();
        return ex.toStatus();

            

Reported by FlawFinder.

src/mongo/db/query/sbe_shard_filter_test.cpp
1 issues
syntax error
Error

Line: 124

                  }
};

TEST_F(SbeShardFilterTest, AlwaysPassFilter) {
    auto docs = std::vector<BSONArray>{BSON_ARRAY(BSON("a" << 1 << "b" << 2)),
                                       BSON_ARRAY(BSON("a" << 2 << "b" << 2)),
                                       BSON_ARRAY(BSON("a" << 3 << "b" << 2))};
    auto expected = BSON_ARRAY(BSON("a" << 1 << "b" << 2)
                               << BSON("a" << 2 << "b" << 2) << BSON("a" << 3 << "b" << 2));

            

Reported by Cppcheck.

src/mongo/db/query/sbe_stage_builder_accumulator_test.cpp
1 issues
syntax error
Error

Line: 253

                  sbe::value::SpoolIdGenerator _spoolIdGenerator;
};

TEST_F(SbeAccumulatorBuilderTest, MinAccumulatorTranslationBasic) {
    auto docs = std::vector<BSONArray>{BSON_ARRAY(BSON("a" << 1 << "b" << 100ll)),
                                       BSON_ARRAY(BSON("a" << 1 << "b" << Decimal128(10.0))),
                                       BSON_ARRAY(BSON("a" << 1 << "b" << 1.0))};
    runAggregationWithNoGroupByTest("{x: {$min: '$b'}}", docs, BSON_ARRAY(1.0));
}

            

Reported by Cppcheck.