The following issues were found
src/mongo/db/auth/builtin_roles_test.cpp
1 issues
Line: 76
ASSERT(!auth::isBuiltinRole(RoleName("MyRole", "admin")));
}
TEST(BuiltinRoles, getBuiltinRolesForDB) {
auto adminRoles = auth::getBuiltinRoleNamesForDB("admin");
ASSERT(adminRoles.contains(RoleName("read", "admin")));
ASSERT(adminRoles.contains(RoleName("readAnyDatabase", "admin")));
for (const auto& role : adminRoles) {
ASSERT_EQ(role.getDB(), "admin");
Reported by Cppcheck.
src/mongo/db/auth/privilege_parser_test.cpp
1 issues
Line: 173
ASSERT_FALSE(parsedPrivilege.isValid(&errmsg));
}
TEST(PrivilegeParserTest, ConvertBetweenPrivilegeTest) {
ParsedPrivilege parsedPrivilege;
Privilege privilege;
std::string errmsg;
std::vector<std::string> actionsVector;
std::vector<std::string> unrecognizedActions;
Reported by Cppcheck.
src/mongo/db/auth/restriction_test.cpp
1 issues
Line: 42
using namespace restriction_detail;
TEST(RestrictionSetTest, EmptyRestrictionSetAllValidates) {
RestrictionEnvironment env{SockAddr(), SockAddr()};
RestrictionSetAll<UnnamedRestriction> set;
Status status = set.validate(env);
ASSERT_OK(status);
}
Reported by Cppcheck.
src/mongo/db/auth/sasl_authentication_session_test.cpp
1 issues
Line: 303
DEFINE_MECHANISM_FIXTURE(CLASS_SUFFIX, MECH_NAME); \
DEFINE_ALL_MECHANISM_TESTS(SaslConversation##CLASS_SUFFIX)
TEST_MECHANISM(SCRAMSHA1, "SCRAM-SHA-1")
TEST_MECHANISM(SCRAMSHA256, "SCRAM-SHA-256")
TEST_MECHANISM(PLAIN, "PLAIN")
TEST_F(SaslIllegalConversation, IllegalClientMechanism) {
client->setParameter(SaslClientSession::parameterServiceName, mockServiceName);
Reported by Cppcheck.
src/mongo/db/auth/sasl_mechanism_registry_test.cpp
1 issues
Line: 49
ASSERT_FALSE(set.hasAllProperties(SecurityPropertySet{SecurityProperty::kNoPlainText}));
}
TEST(SecurityProperty, mutualHasMutalAndEmptyProperties) {
SecurityPropertySet set(SecurityPropertySet{SecurityProperty::kMutualAuth});
ASSERT_TRUE(set.hasAllProperties(SecurityPropertySet{}));
ASSERT_TRUE(set.hasAllProperties(SecurityPropertySet{SecurityProperty::kMutualAuth}));
ASSERT_FALSE(set.hasAllProperties(SecurityPropertySet{SecurityProperty::kNoPlainText}));
}
Reported by Cppcheck.
src/mongo/db/auth/sasl_scram_test.cpp
1 issues
Line: 287
}
};
TEST_F(SCRAMFixture, testServerStep1DoesNotIncludeNonceFromClientStep1) {
ASSERT_OK(authzManagerExternalState->insertPrivilegeDocument(
opCtx.get(), generateSCRAMUserDocument("sajack", "sajack"), BSONObj()));
saslClientSession->setParameter(NativeSaslClientSession::parameterUser, "sajack");
saslClientSession->setParameter(NativeSaslClientSession::parameterPassword,
Reported by Cppcheck.
src/mongo/db/auth/security_key_test.cpp
1 issues
Line: 140
{"abc", {"abc"}, TestCase::FailureMode::SecurityKeyConstraint},
{longKeyMaker(), {longKeyMaker().toString()}, TestCase::FailureMode::SecurityKeyConstraint}};
TEST(SecurityFile, Test) {
for (const auto& testCase : testCases) {
TestFile file(testCase.fileContents, testCase.mode != TestCase::FailureMode::Permissions);
auto swKeys = readSecurityFile(file.path().string());
if (testCase.mode == TestCase::FailureMode::Success ||
Reported by Cppcheck.
src/mongo/db/auth/user_document_parser_test.cpp
1 issues
Line: 78
};
TEST_F(V2UserDocumentParsing, V2DocumentValidation) {
BSONArray emptyArray = BSONArrayBuilder().arr();
// V1 documents don't work
ASSERT_NOT_OK(v2parser.checkValidUserDocument(BSON("user"
<< "spencer"
Reported by Cppcheck.
src/mongo/db/auth/user_set_test.cpp
1 issues
Line: 96
ASSERT_FALSE(iter.more());
}
TEST(UserSetTest, IterateNames) {
UserSet pset;
UserNameIterator iter = pset.getNames();
ASSERT(!iter.more());
UserHandle user(User(UserName("bob", "test")));
Reported by Cppcheck.
src/mongo/db/bson/dotted_path_support.cpp
1 issues
Line: 152
Column: 23
CWE codes:
126
path = p + 1;
} else {
sub = obj.getField(path);
path = path + strlen(path);
}
if (sub.eoo())
return BSONElement();
else if (sub.type() == Array || path[0] == '\0')
Reported by FlawFinder.