Add cppcheck suppressions for false positives

This commit is contained in:
Eduardo Arias 2024-08-21 08:32:28 -07:00 committed by Eduardo Arias
parent c2b86ddc49
commit d053ec6de6
6 changed files with 7 additions and 6 deletions

View File

@ -22,7 +22,7 @@ namespace modsecurity::actions::transformations {
static inline bool inplace(std::string &value) { static inline bool inplace(std::string &value) {
if (value.empty()) return false; if (value.empty()) return false;
for(auto &c : value) { for(auto &c : value) { // cppcheck-suppress constVariableReference ; false positive
((unsigned char&)c) &= 0x7f; ((unsigned char&)c) &= 0x7f;
} }

View File

@ -14,6 +14,7 @@
#define pclose _pclose #define pclose _pclose
inline tm* localtime_r(const time_t* tin, tm* tout) { inline tm* localtime_r(const time_t* tin, tm* tout) {
// cppcheck-suppress[uninitvar, ctuuninitvar]
if (!localtime_s(tout, tin)) return tout; if (!localtime_s(tout, tin)) return tout;
return nullptr; return nullptr;

View File

@ -102,9 +102,9 @@ RuleWithActions::RuleWithActions(
delete a; delete a;
} else if (auto sa = dynamic_cast<actions::Severity *>(a)) { } else if (auto sa = dynamic_cast<actions::Severity *>(a)) {
m_severity = sa; m_severity = sa;
} else if (auto lda = dynamic_cast<actions::LogData *>(a)) { } else if (auto lda = dynamic_cast<actions::LogData *>(a)) { // cppcheck-suppress unreadVariable ; false positive
m_logData = lda; m_logData = lda;
} else if (auto ma = dynamic_cast<actions::Msg *>(a)) { } else if (auto ma = dynamic_cast<actions::Msg *>(a)) { // cppcheck-suppress unreadVariable ; false positive
m_msg = ma; m_msg = ma;
} else if (auto sva = dynamic_cast<actions::SetVar *>(a)) { } else if (auto sva = dynamic_cast<actions::SetVar *>(a)) {
m_actionsSetVar.push_back(sva); m_actionsSetVar.push_back(sva);

View File

@ -24,7 +24,7 @@
#include "mbedtls/base64.h" #include "mbedtls/base64.h"
template<typename Operation> template<typename Operation>
inline std::string base64Helper(const char *data, const unsigned int len, Operation op) { inline std::string base64Helper(const char *data, const unsigned int len, Operation op) { // cppcheck-suppress syntaxError ; false positive
size_t out_len = 0; size_t out_len = 0;
op(nullptr, 0, &out_len, op(nullptr, 0, &out_len,

View File

@ -257,7 +257,7 @@ inline std::string string_to_hex(std::string_view input) {
template<typename Operation> template<typename Operation>
inline std::string toCaseHelper(std::string str, Operation op) { inline std::string toCaseHelper(std::string str, Operation op) { // cppcheck-suppress syntaxError ; false positive
std::transform(str.begin(), std::transform(str.begin(),
str.end(), str.end(),
str.begin(), str.begin(),

View File

@ -105,7 +105,7 @@ struct TransformationTest {
template<typename TestType> template<typename TestType>
UnitTestResult perform_unit_test_once(const UnitTest &t, modsecurity::Transaction &transaction) { UnitTestResult perform_unit_test_once(const UnitTest &t, modsecurity::Transaction &transaction) { // cppcheck-suppress constParameterReference ; transaction can be const for transformations but not for operators
std::unique_ptr<typename TestType::ItemType> item(TestType::init(t)); std::unique_ptr<typename TestType::ItemType> item(TestType::init(t));
assert(item.get() != nullptr); assert(item.get() != nullptr);