Skip to content

Commit 4aad8e0

Browse files
committed
Inline cppcheck suppressions
1 parent 0c38023 commit 4aad8e0

File tree

11 files changed

+18
-32
lines changed

11 files changed

+18
-32
lines changed

headers/modsecurity/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class Transaction : public TransactionAnchoredVariables, public TransactionSecMa
405405
size_t getRequestBodyLength();
406406

407407
#ifndef NO_LOGS
408-
void debug(int, const std::string&) const;
408+
void debug(int, const std::string &) const; // cppcheck-suppress functionStatic
409409
#endif
410410
void serverLog(std::shared_ptr<RuleMessage> rm);
411411

src/engine/lua.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class Lua {
6767
public:
6868
Lua() { }
6969

70-
bool load(const std::string &script, std::string *err);
71-
int run(Transaction *t, const std::string &str="");
70+
bool load(const std::string &script, std::string *err); // cppcheck-suppress functionStatic ; triggered when compiling without LUA
71+
int run(Transaction *t, const std::string &str = ""); // cppcheck-suppress functionStatic ; triggered when compiling without LUA
7272
static bool isCompatible(const std::string &script, Lua *l, std::string *error);
7373

7474
#ifdef WITH_LUA

src/operators/geo_lookup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GeoLookup : public Operator {
3232
bool evaluate(Transaction *transaction, const std::string &exp) override;
3333

3434
protected:
35+
// cppcheck-suppress functionStatic
3536
bool debug(Transaction *transaction, int x, const std::string &a) {
3637
ms_dbg_a(transaction, x, a);
3738
return true;

src/operators/rbl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ class Rbl : public Operator {
6666
m_demandsPassword(false),
6767
m_provider(RblProvider::UnknownProvider),
6868
Operator("Rbl", std::move(param)) {
69-
m_service = m_string->evaluate();
70-
if (m_service.find("httpbl.org") != std::string::npos) {
71-
m_demandsPassword = true;
72-
m_provider = RblProvider::httpbl;
69+
m_service = m_string->evaluate(); // cppcheck-suppress useInitializationList
70+
if (m_service.find("httpbl.org") != std::string::npos)
71+
{
72+
m_demandsPassword = true;
73+
m_provider = RblProvider::httpbl;
7374
} else if (m_service.find("uribl.com") != std::string::npos) {
7475
m_provider = RblProvider::uribl;
7576
} else if (m_service.find("spamhaus.org") != std::string::npos) {

src/operators/validate_url_encoding.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool ValidateUrlEncoding::evaluate(Transaction *transaction, RuleWithActions *ru
7474
bool res = false;
7575

7676
if (input.empty() == true) {
77-
return res;
77+
return res; // cppcheck-suppress knownConditionTrueFalse
7878
}
7979

8080
int rc = validate_url_encoding(input.c_str(), input.size(), &offset);

src/operators/verify_cpf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
7474
c = cpf_len;
7575

7676
for (i = 0; i < 9; i++) {
77-
sum += (cpf[i] * --c);
77+
sum += (cpf[i] * --c); // cppcheck-suppress uninitvar
7878
}
7979

8080
factor = (sum % cpf_len);

src/operators/verify_svnr.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool VerifySVNR::verify(const char *svnrnumber, int len) {
6464
}
6565
//Laufnummer mit 3, 7, 9
6666
//Geburtsdatum mit 5, 8, 4, 2, 1, 6
67-
sum = svnr[0] * 3 + svnr[1] * 7 + svnr[2] * 9 + svnr[4] * 5 + svnr[5] * 8 + svnr[6] * 4 + svnr[7] * 2 + svnr[8] * 1 + svnr[9] * 6;
67+
sum = svnr[0] * 3 + svnr[1] * 7 + svnr[2] * 9 + svnr[4] * 5 + svnr[5] * 8 + svnr[6] * 4 + svnr[7] * 2 + svnr[8] * 1 + svnr[9] * 6; // cppcheck-suppress uninitvar
6868
sum %= 11;
6969
if(sum == 10){
7070
sum = 0;
@@ -84,7 +84,7 @@ bool VerifySVNR::evaluate(Transaction *t, RuleWithActions *rule,
8484
int i;
8585

8686
if (m_param.empty()) {
87-
return is_svnr;
87+
return is_svnr; // cppcheck-suppress knownConditionTrueFalse
8888
}
8989

9090
for (i = 0; i < input.size() - 1 && is_svnr == false; i++) {

src/rule_with_actions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans,
241241
bool containsBlock, std::shared_ptr<RuleMessage> ruleMessage) {
242242
bool disruptiveAlreadyExecuted = false;
243243

244-
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) {
244+
for (auto &a : trans->m_rules->m_defaultActions[getPhase()]) { // cppcheck-suppress ctunullpointer
245245
if (a.get()->action_kind != actions::Action::RunTimeOnlyIfMatchKind) {
246246
continue;
247247
}

src/rule_with_operator.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void RuleWithOperator::updateMatchedVars(Transaction *trans, const std::string &
9292

9393
void RuleWithOperator::cleanMatchedVars(Transaction *trans) {
9494
ms_dbg_a(trans, 9, "Matched vars cleaned.");
95+
// cppcheck-suppress ctunullpointer
9596
trans->m_variableMatchedVar.unset();
9697
trans->m_variableMatchedVars.unset();
9798
trans->m_variableMatchedVarName.unset();
@@ -132,7 +133,7 @@ bool RuleWithOperator::executeOperatorAt(Transaction *trans, const std::string &
132133

133134
void RuleWithOperator::getVariablesExceptions(Transaction *t,
134135
variables::Variables *exclusion, variables::Variables *addition) {
135-
for (auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) {
136+
for (auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) { // cppcheck-suppress ctunullpointer
136137
if (containsTag(*a.first.get(), t) == false) {
137138
continue;
138139
}

src/rules_set_properties.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ void ConfigUnicodeMap::loadConfig(std::string f, double configCodePage,
9898

9999
if (mapping != NULL) {
100100
ucode = strtok_r(mapping, ":", &hmap);
101-
sscanf(ucode, "%x", &code);
102-
sscanf(hmap, "%x", &Map);
101+
sscanf(ucode, "%x", &code); // cppcheck-suppress invalidScanfArgType_int
102+
sscanf(hmap, "%x", &Map); // cppcheck-suppress invalidScanfArgType_int
103103
if (code >= 0 && code <= 65535) {
104104
driver->m_unicodeMapTable.m_unicodeMapTable->change(code, Map);
105105
}

0 commit comments

Comments
 (0)