The following issues were found
src/mongo/crypto/aead_encryption_test.cpp
1 issues
Line: 54
ASSERT_EQ(cipherLen, size_t(64));
}
TEST(AEAD, EncryptAndDecrypt) {
// Test case from RFC:
// https://tools.ietf.org/html/draft-mcgrew-aead-aes-cbc-hmac-sha2-05#section-5.4
const uint8_t aesAlgorithm = 0x1;
Reported by Cppcheck.
src/mongo/crypto/mechanism_scram_test.cpp
1 issues
Line: 75
ASSERT_TRUE(secrets.verifyServerSignature(authMessage, base64::decode(generatedSig)));
}
TEST(MechanismScram, BasicVectors) {
testBasicVectors<SHA1Block>("531aYHrF581Skow4E0gCWLw/Ibo=",
"wiHbIsPcvJo230S6Qf5xYCDrhb0=",
"SjXiaB2hLRr8aMUyXMVEw7H1jSI=",
"FilAoFIclBukd3xZxBvYMXTU3HM=",
"y+cpoAm0YlN30GuNgN4B9xghi4E=",
Reported by Cppcheck.
src/mongo/crypto/sha256_block_test.cpp
1 issues
Line: 66
0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}}};
TEST(CryptoVectors, SHA256) {
size_t numTests = sizeof(sha256Tests) / sizeof(sha256Tests[0]);
SHA256Block::Secure resultSec;
for (size_t i = 0; i < numTests; i++) {
// Normal allocator.
SHA256Block result = SHA256Block::computeHash(sha256Tests[i].msg);
Reported by Cppcheck.
src/mongo/crypto/symmetric_crypto_windows.cpp
1 issues
Line: 119
Column: 54
CWE codes:
126
status = BCryptSetProperty(algo.algo,
BCRYPT_CHAINING_MODE,
reinterpret_cast<PUCHAR>(const_cast<wchar_t*>(chainingMode)),
sizeof(wchar_t) * wcslen(chainingMode),
0);
invariant(status == STATUS_SUCCESS);
DWORD cbOutput = sizeof(algo.keyBlobSize);
status = BCryptGetProperty(algo.algo,
Reported by FlawFinder.
src/mongo/db/auth/action_set_test.cpp
1 issues
Line: 85
ASSERT_TRUE(unrecognized.front() == "INVALID INPUT");
}
TEST(ActionSetTest, ToString) {
ActionSet actionSet;
ASSERT_EQUALS("", actionSet.toString());
actionSet.addAction(ActionType::find);
ASSERT_EQUALS("find", actionSet.toString());
Reported by Cppcheck.
src/mongo/db/auth/address_restriction_test.cpp
1 issues
Line: 73
}
}
TEST(AddressRestrictionTest, toAndFromStringVector) {
const struct {
std::vector<std::string> input;
std::string output;
} tests[] = {
{{"127.0.0.1", "169.254.0.0/16", "::1"},
Reported by Cppcheck.
src/mongo/db/auth/auth_op_observer_test.cpp
1 issues
Line: 90
}
};
TEST_F(AuthOpObserverTest, OnRollbackInvalidatesAuthCacheWhenAuthNamespaceRolledBack) {
AuthOpObserver opObserver;
auto opCtx = cc().makeOperationContext();
auto authMgr = AuthorizationManager::get(getServiceContext());
auto initCacheGen = authMgr->getCacheGeneration();
Reported by Cppcheck.
src/mongo/db/auth/authorization_contract_test.cpp
1 issues
Line: 77
ASSERT_TRUE(ac.contains(ac));
}
TEST(AuthContractTest, SimpleAccessCheck) {
AuthorizationContract ac;
ac.addAccessCheck(AccessCheckEnum::kIsAuthenticated);
ac.addAccessCheck(AccessCheckEnum::kIsCoAuthorized);
Reported by Cppcheck.
src/mongo/db/auth/authorization_manager_test.cpp
1 issues
Line: 115
ServiceContext::UniqueOperationContext opCtx;
};
TEST_F(AuthorizationManagerTest, testAcquireV2User) {
ASSERT_OK(externalState->insertPrivilegeDocument(opCtx.get(),
BSON("_id"
<< "admin.v2read"
<< "user"
<< "v2read"
Reported by Cppcheck.
src/mongo/db/auth/authorization_session_test.cpp
1 issues
Line: 160
const ResourcePattern thirdProfileCollResource(
ResourcePattern::forExactNamespace(NamespaceString("third.system.profile")));
TEST_F(AuthorizationSessionTest, AddUserAndCheckAuthorization) {
authzSession->startContractTracking();
// Check that disabling auth checks works
ASSERT_FALSE(
authzSession->isAuthorizedForActionsOnResource(testFooCollResource, ActionType::insert));
Reported by Cppcheck.