The following issues were found
src/mongo/dbtests/replica_set_tests.cpp
1 issues
Line: 98
std::unique_ptr<repl::ReplicationProcess> _replicationProcess;
};
TEST_F(ReplicaSetTest, ReplCoordExternalStateStoresLastVoteWithNewTerm) {
auto opCtx = makeOpCtx();
// Methods that do writes as part of elections expect Flow Control to be disabled.
opCtx->setShouldParticipateInFlowControl(false);
auto replCoordExternalState = getReplCoordExternalState();
Reported by Cppcheck.
src/mongo/dbtests/wildcard_access_method_test.cpp
1 issues
Line: 57
.isOK());
}
TEST(WildcardAccessMethodTest, FieldGeneratesExpectedMultikeyPathBounds) {
assertCorrectMultikeyMetadataPathBoundsGenerated("foo",
fromjson("{'': [['foo','foo',true,true]]}"));
assertCorrectMultikeyMetadataPathBoundsGenerated(
"foo.bar", fromjson("{'': [['foo','foo',true,true], ['foo.bar','foo.bar',true,true]]}"));
assertCorrectMultikeyMetadataPathBoundsGenerated(
Reported by Cppcheck.
src/mongo/dbtests/wildcard_multikey_persistence_test.cpp
1 issues
Line: 265
int _id{1};
};
TEST_F(WildcardMultikeyPersistenceTestFixture, RecordMultikeyPathsInBulkIndexBuild) {
// Create the test collection, add some initial documents, and build a foreground $** index.
assertSetupEnvironment(false, makeDocs({"{a: 1, b: [{c: 2}, {d: {e: [3]}}]}"}));
// Verify that the data and multikey path keys are present in the expected order.
std::vector<IndexKeyEntry> expectedKeys = {{fromjson("{'': 1, '': 'b'}"), kMetadataId},
Reported by Cppcheck.
src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
1 issues
Line: 85
}
try {
new CAPI();
} catch (Throwable t) {
throw new MongoEmbeddedCAPIException(
format("Unable to load the Mongo Embedded Library.%n"
+ "Please either: Set the libraryPath when calling MongoEmbeddedCAPI.create or %n"
+ "Ensure the library is set on the jna.library.path or the java.library.path system property."
), t
Reported by PMD.
src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java
1 issues
Line: 37
class SLF4JLogger implements Logger {
private final org.slf4j.Logger delegate;
SLF4JLogger(final String name) {
this.delegate = LoggerFactory.getLogger(name);
}
Reported by PMD.
src/mongo/embedded/mongo_embedded/mongo_embedded.cpp
1 issues
Line: 425
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
auto sep = client->parent_db->serviceContext->getServiceEntryPoint();
auto sb = SharedBuffer::allocate(input_size);
memcpy(sb.get(), input, input_size);
Message msg(std::move(sb));
client->response = sep->handleRequest(opCtx.get(), msg).get();
Reported by FlawFinder.
src/mongo/embedded/mongoc_embedded/mongoc_embedded_test.cpp
1 issues
Line: 198
mongoc_collection_t* cd_collection;
};
TEST_F(MongodbEmbeddedTransportLayerTest, CreateAndDestroyDB) {
// Test the setUp() and tearDown() test fixtures
}
TEST_F(MongodbEmbeddedTransportLayerTest, InsertAndExplain) {
auto client = getClient();
auto collection = getCollection();
Reported by Cppcheck.
src/mongo/embedded/stitch_support/stitch_support.cpp
1 issues
Line: 118
Column: 5
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
using StitchSupportException = ExceptionForAPI<stitch_support_v1_error>;
ServiceContext* initialize() {
srand(static_cast<unsigned>(curTimeMicros64()));
// The global initializers can take arguments, which would normally be supplied on the command
// line, but we assume that clients of this library will never want anything other than the
// defaults for all configuration that would be controlled by these parameters.
Status status = mongo::runGlobalInitializers(std::vector<std::string>{});
Reported by FlawFinder.
src/mongo/embedded/stitch_support/stitch_support_test.cpp
1 issues
Line: 355
stitch_support_v1_update_details* updateDetails = nullptr;
};
TEST_F(StitchSupportTest, InitializationIsSuccessful) {
ASSERT_EQ(STITCH_SUPPORT_V1_SUCCESS, stitch_support_v1_status_get_error(status));
ASSERT(lib);
}
TEST_F(StitchSupportTest, DoubleInitializationFails) {
Reported by Cppcheck.
src/mongo/executor/cancelable_executor_test.cpp
1 issues
Line: 76
// Just check that a CancelableExecutor correctly schedules & runs work
// in the uncanceled case.
TEST(CancelableExecutor, SchedulesWorkCorrectly) {
auto exec = InlineQueuedCountingExecutor::make();
auto [promise, future] = makePromiseFuture<void>();
CancellationSource source;
auto fut2 =
std::move(future).thenRunOn(CancelableExecutor::make(exec, source.token())).then([] {
Reported by Cppcheck.