The following issues were found

src/mongo/db/index/index_descriptor.cpp
1 issues
equal - Function does not check the second iterator for over-read conditions
Security

Line: 216 Column: 14 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                  auto existingIndexOptionsMap = populateOptionsMapForEqualityCheck(existingIndexDesc->infoObj());

    const bool optsIdentical = thisOptionsMap.size() == existingIndexOptionsMap.size() &&
        std::equal(thisOptionsMap.begin(),
                   thisOptionsMap.end(),
                   existingIndexOptionsMap.begin(),
                   [](const std::pair<StringData, BSONElement>& lhs,
                      const std::pair<StringData, BSONElement>& rhs) {
                       return lhs.first == rhs.first &&

            

Reported by FlawFinder.

src/mongo/db/index/sort_key_generator_test.cpp
1 issues
syntax error
Error

Line: 54

                  return std::make_unique<SortKeyGenerator>(std::move(sortPattern), collator);
}

TEST(SortKeyGeneratorTest, ExtractNumberKeyForNonCompoundSortNonNested) {
    auto sortKeyGen = makeSortKeyGen(BSON("a" << 1), nullptr);
    auto sortKey = sortKeyGen->computeSortKeyFromDocument(Document{{"_id", 5}, {"a", 5}});
    ASSERT_VALUE_EQ(sortKey, Value{5});
}


            

Reported by Cppcheck.

src/mongo/db/index_builds_coordinator_mongod_test.cpp
1 issues
syntax error
Error

Line: 115

                  return indexSpecs;
}

TEST_F(IndexBuildsCoordinatorMongodTest, AttemptBuildSameIndexReturnsImmediateSuccess) {
    _indexBuildsCoord->sleepIndexBuilds_forTestOnly(true);

    // Register an index build on _testFooNss.
    auto testFoo1Future =
        assertGet(_indexBuildsCoord->startIndexBuild(operationContext(),

            

Reported by Cppcheck.

src/mongo/db/key_generator_update_test.cpp
1 issues
syntax error
Error

Line: 69

                  std::unique_ptr<KeysCollectionClient> _catalogClient;
};

TEST_F(KeyGeneratorUpdateTest, ShouldCreate2KeysFromEmpty) {
    KeyGenerator generator("dummy", catalogClient(), Seconds(5));

    const LogicalTime currentTime(LogicalTime(Timestamp(100, 2)));
    VectorClockMutable::get(operationContext())->tickClusterTimeTo(currentTime);


            

Reported by Cppcheck.

src/mongo/db/keypattern_test.cpp
1 issues
syntax error
Error

Line: 38

              
using namespace mongo;

TEST(KeyPattern, ExtendRangeBound) {
    BSONObj bound = BSON("a" << 55);
    BSONObj longBound = BSON("a" << 55 << "b" << 66);

    // test keyPattern shorter than bound, should fail
    {

            

Reported by Cppcheck.

src/mongo/db/keys_collection_cache_test.cpp
1 issues
syntax error
Error

Line: 125

                  std::unique_ptr<KeysCollectionClient> _directClient;
};

TEST_F(CacheTest, GetInternalKeyErrorsIfInternalKeysCacheIsEmpty) {
    KeysCollectionCache cache("test", catalogClient());
    auto status = cache.getInternalKey(LogicalTime(Timestamp(1, 0))).getStatus();
    ASSERT_EQ(ErrorCodes::KeyNotFound, status.code());
    ASSERT_FALSE(status.reason().empty());
}

            

Reported by Cppcheck.

src/mongo/db/keys_collection_document_test.cpp
1 issues
syntax error
Error

Line: 65

                  ASSERT_EQ(expiresAt.asTimestamp(), parsedKey.getExpiresAt().asTimestamp());
}

TEST(KeysCollectionDocument, MissingKeyIdShouldFailToParse) {
    std::string purpose("signLogicalTime");

    SHA1Block::HashType keyHash;
    keyHash.fill(0);
    TimeProofService::Key key(keyHash);

            

Reported by Cppcheck.

src/mongo/db/keys_collection_manager_sharding_test.cpp
1 issues
syntax error
Error

Line: 79

                  std::unique_ptr<KeysCollectionManager> _keyManager;
};

TEST_F(KeysManagerShardedTest, GetKeyForValidationTimesOutIfRefresherIsNotRunning) {
    operationContext()->setDeadlineAfterNowBy(Microseconds(250 * 1000),
                                              ErrorCodes::ExceededTimeLimit);

    ASSERT_THROWS(
        keyManager()->getKeysForValidation(operationContext(), 1, LogicalTime(Timestamp(100, 0))),

            

Reported by Cppcheck.

src/mongo/db/logical_session_cache_test.cpp
1 issues
syntax error
Error

Line: 126

                  RAIIServerParameterControllerForTest _controller{"featureFlagInternalTransactions", true};
};

TEST_F(LogicalSessionCacheTest, ParentAndChildSessionsHaveEqualLogicalSessionRecord) {
    auto parentLsid = makeLogicalSessionIdForTest();
    auto lastUse = Date_t::now();
    auto parentSessionRecord = makeLogicalSessionRecord(parentLsid, lastUse);

    auto childSessionRecord0 =

            

Reported by Cppcheck.

src/mongo/db/logical_session_id_test.cpp
1 issues
syntax error
Error

Line: 134

                  }
};

TEST_F(LogicalSessionIdTest, ConstructorFromClientWithoutPassedUid) {
    auto id = UUID::gen();
    User* user = addSimpleUser(UserName("simple", "test"));

    LogicalSessionFromClient req;
    req.setId(id);

            

Reported by Cppcheck.