The following issues were found
buildscripts/resmokelib/testing/testcases/interface.py
2 issues
Line: 87
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
This method is used by the repport to set the test logger.
"""
assert not self._original_logger, "Logger already overridden"
self._original_logger = self.logger
self.logger = new_logger
def reset_logger(self):
"""Reset this instance's logger to its original value."""
Reported by Bandit.
Line: 93
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def reset_logger(self):
"""Reset this instance's logger to its original value."""
assert self._original_logger, "Logger was not overridden"
self.logger = self._original_logger
self._original_logger = None
def configure(self, fixture, *args, **kwargs): # pylint: disable=unused-argument
"""Store 'fixture' as an attribute for later use during execution."""
Reported by Bandit.
src/third_party/abseil-cpp-master/abseil-cpp/absl/strings/internal/cord_internal.h
2 issues
Line: 183
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
// If tag < FLAT, it represents CordRepKind and indicates the type of node.
// Otherwise, the node type is CordRepFlat and the tag is the encoded size.
uint8_t tag;
char storage[1]; // Starting point for flat array: MUST BE LAST FIELD
inline CordRepRing* ring();
inline const CordRepRing* ring() const;
inline CordRepConcat* concat();
inline const CordRepConcat* concat() const;
Reported by FlawFinder.
Line: 487
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
// Else we store it in a tree and store a pointer to that tree in
// `as_tree_.rep` and store a tag in `tagged_size`.
union {
char as_chars_[kMaxInline + 1];
AsTree as_tree_;
};
};
static_assert(sizeof(InlineData) == kMaxInline + 1, "");
Reported by FlawFinder.
src/mongo/shell/kms_aws.cpp
2 issues
Line: 169
Column: 23
CWE codes:
126
initRequest(request.get(), _server.host(), region);
auto buffer = UniqueKmsCharBuffer(kms_request_get_signed(request.get()));
auto buffer_len = strlen(buffer.get());
KMSNetworkConnection connection(_sslManager.get());
auto response = connection.makeOneRequest(_server, ConstDataRange(buffer.get(), buffer_len));
auto body = kms_response_get_body(response.get(), nullptr);
Reported by FlawFinder.
Line: 231
Column: 23
CWE codes:
126
initRequest(request.get(), _server.host(), awsMasterKey.getRegion());
auto buffer = UniqueKmsCharBuffer(kms_request_get_signed(request.get()));
auto buffer_len = strlen(buffer.get());
KMSNetworkConnection connection(_sslManager.get());
auto response = connection.makeOneRequest(_server, ConstDataRange(buffer.get(), buffer_len));
auto body = kms_response_get_body(response.get(), nullptr);
Reported by FlawFinder.
src/third_party/asio-master/asio/include/asio/detail/winrt_utils.hpp
2 issues
Line: 71
Column: 10
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
inline int integer(Platform::String^ from)
{
return _wtoi(from->Data());
}
template <typename T>
inline Windows::Networking::HostName^ host_name(const T& from)
{
Reported by FlawFinder.
Line: 42
Column: 38
CWE codes:
126
inline Platform::String^ string(const char* from)
{
std::wstring tmp(from, from + std::strlen(from));
return ref new Platform::String(tmp.c_str());
}
inline Platform::String^ string(const std::string& from)
{
Reported by FlawFinder.
src/third_party/asio-master/asio/include/asio/experimental/impl/co_spawn.hpp
2 issues
Line: 121
Column: 30
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
private:
std::size_t ref_count_ = 0;
std::exception_ptr pending_exception_ = nullptr;
alignas(Executor) unsigned char executor_[sizeof(Executor)];
bool has_executor_ = false;
};
// Base promise for coroutines further down the thread-of-execution "stack".
template <typename Executor>
Reported by FlawFinder.
Line: 380
Column: 23
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
}
private:
alignas(T) unsigned char result_[sizeof(T)];
bool has_result_ = false;
};
// Promise object for coroutines further down the thread-of-execution "stack".
template <typename Executor>
Reported by FlawFinder.
src/mongo/db/index/s2_key_generator_test.cpp
2 issues
Line: 147
}
};
TEST_F(S2KeyGeneratorTest, GetS2KeysFromSubobjectWithArrayOfGeoAndNonGeoSubobjects) {
BSONObj keyPattern = fromjson("{'a.b.nongeo': 1, 'a.b.geo': '2dsphere'}");
BSONObj genKeysFrom = fromjson(
"{a: {b: [{nongeo: 1, geo: {type: 'Point', coordinates: [0, 0]}}, "
"{nongeo: 2, geo: {type: 'Point', coordinates: [3, 3]}}]}}");
BSONObj infoObj =
Reported by Cppcheck.
Line: 89
Column: 15
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
return false;
}
if (!std::equal(expectedKeys.begin(), expectedKeys.end(), actualKeys.begin())) {
LOGV2(20694,
"Expected: {dumpKeyset_expectedKeys}, Actual: {dumpKeyset_actualKeys}",
"dumpKeyset_expectedKeys"_attr = dumpKeyset(expectedKeys),
"dumpKeyset_actualKeys"_attr = dumpKeyset(actualKeys));
return false;
Reported by FlawFinder.
src/third_party/abseil-cpp-master/abseil-cpp/absl/strings/internal/memutil_test.cc
2 issues
Line: 53
return nullptr;
}
TEST(MemUtilTest, AllTests) {
// check memutil functions
char a[1000];
absl::strings_internal::memcat(a, 0, "hello", sizeof("hello") - 1);
absl::strings_internal::memcat(a, 5, " there", sizeof(" there") - 1);
Reported by Cppcheck.
Line: 55
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
TEST(MemUtilTest, AllTests) {
// check memutil functions
char a[1000];
absl::strings_internal::memcat(a, 0, "hello", sizeof("hello") - 1);
absl::strings_internal::memcat(a, 5, " there", sizeof(" there") - 1);
EXPECT_EQ(absl::strings_internal::memcasecmp(a, "heLLO there",
sizeof("hello there") - 1),
Reported by FlawFinder.
src/third_party/boost/boost/algorithm/is_palindrome.hpp
2 issues
Line: 120
Column: 37
CWE codes:
126
{
if(!str)
return true;
return is_palindrome(str, str + strlen(str));
}
/// \fn is_palindrome ( const char* str, Predicate p )
/// \return true if the entire sequence is palindrome
///
Reported by FlawFinder.
Line: 137
Column: 37
CWE codes:
126
{
if(!str)
return true;
return is_palindrome(str, str + strlen(str), p);
}
}}
#endif // BOOST_ALGORITHM_IS_PALINDROME_HPP
Reported by FlawFinder.
src/mongo/shell/kms_gcp.cpp
2 issues
Line: 183
Column: 23
CWE codes:
126
_config.opts.get()));
auto buffer = UniqueKmsCharBuffer(kms_request_to_string(request.get()));
auto buffer_len = strlen(buffer.get());
KMSNetworkConnection connection(_sslManager.get());
auto response = connection.makeOneRequest(_server, ConstDataRange(buffer.get(), buffer_len));
auto body = kms_response_get_body(response.get(), nullptr);
Reported by FlawFinder.
Line: 231
Column: 23
CWE codes:
126
_config.opts.get()));
auto buffer = UniqueKmsCharBuffer(kms_request_to_string(request.get()));
auto buffer_len = strlen(buffer.get());
KMSNetworkConnection connection(_sslManager.get());
auto response = connection.makeOneRequest(_server, ConstDataRange(buffer.get(), buffer_len));
auto body = kms_response_get_body(response.get(), nullptr);
Reported by FlawFinder.
src/mongo/db/exec/sbe/stages/project.cpp
2 issues
Line: 71
Column: 20
CWE codes:
362
return _children[0]->getAccessor(ctx, slot);
}
}
void ProjectStage::open(bool reOpen) {
auto optTimer(getOptTimer(_opCtx));
_commonStats.opens++;
_children[0]->open(reOpen);
}
Reported by FlawFinder.
Line: 75
Column: 19
CWE codes:
362
auto optTimer(getOptTimer(_opCtx));
_commonStats.opens++;
_children[0]->open(reOpen);
}
PlanState ProjectStage::getNext() {
auto optTimer(getOptTimer(_opCtx));
Reported by FlawFinder.