diff --git a/headers/modsecurity/anchored_set_variable_translation_proxy.h b/headers/modsecurity/anchored_set_variable_translation_proxy.h index da0601bf..f90b9f24 100644 --- a/headers/modsecurity/anchored_set_variable_translation_proxy.h +++ b/headers/modsecurity/anchored_set_variable_translation_proxy.h @@ -47,7 +47,7 @@ class AnchoredSetVariableTranslationProxy { VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey()); const VariableValue *oldVariableValue = l->at(i); l->at(i) = newVariableValue; - for (auto &oldOrigin : oldVariableValue->getOrigin()) { + for (const auto &oldOrigin : oldVariableValue->getOrigin()) { std::unique_ptr newOrigin(new VariableOrigin); newOrigin->m_length = oldVariableValue->getKey().size(); newOrigin->m_offset = oldOrigin->m_offset - oldVariableValue->getKey().size() - 1; diff --git a/headers/modsecurity/variable_value.h b/headers/modsecurity/variable_value.h index f7871776..a9a15a7b 100644 --- a/headers/modsecurity/variable_value.h +++ b/headers/modsecurity/variable_value.h @@ -62,7 +62,7 @@ class VariableValue { m_keyWithCollection(o->m_keyWithCollection), m_value(o->m_value) { - for (auto &i : o->m_orign) { + for (const auto &i : o->m_orign) { std::unique_ptr origin(new VariableOrigin()); origin->m_offset = i->m_offset; origin->m_length = i->m_length; diff --git a/src/actions/ctl/rule_remove_by_id.cc b/src/actions/ctl/rule_remove_by_id.cc index e76a3119..eaaef220 100644 --- a/src/actions/ctl/rule_remove_by_id.cc +++ b/src/actions/ctl/rule_remove_by_id.cc @@ -30,7 +30,7 @@ bool RuleRemoveById::init(std::string *error) { std::string what(m_parser_payload, 15, m_parser_payload.size() - 15); bool added = false; std::vector toRemove = utils::string::ssplit(what, ' '); - for (std::string &a : toRemove) { + for (const std::string &a : toRemove) { std::string b = modsecurity::utils::string::parserSanitizer(a); if (b.size() == 0) { continue; diff --git a/src/audit_log/audit_log.cc b/src/audit_log/audit_log.cc index 307819f0..1be8a47b 100644 --- a/src/audit_log/audit_log.cc +++ b/src/audit_log/audit_log.cc @@ -289,7 +289,7 @@ bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) { return true; } - for (RuleMessage &i : transaction->m_rulesMessages) { + for (const RuleMessage &i : transaction->m_rulesMessages) { if (i.m_noAuditLog == false) { saveAnyway = true; break; diff --git a/src/rule_message.cc b/src/rule_message.cc index 496fe7ca..97d8f8b1 100644 --- a/src/rule_message.cc +++ b/src/rule_message.cc @@ -38,7 +38,7 @@ std::string RuleMessage::_details(const RuleMessage *rm) { msg.append(" [maturity \"" + std::to_string(rm->m_maturity) + "\"]"); msg.append(" [accuracy \"" + std::to_string(rm->m_accuracy) + "\"]"); - for (auto &a : rm->m_tags) { + for (const auto &a : rm->m_tags) { msg.append(" [tag \"" + utils::string::toHexIfNeeded(a, true) + "\"]"); } diff --git a/src/rule_with_operator.cc b/src/rule_with_operator.cc index d218f14b..94d0f9a4 100644 --- a/src/rule_with_operator.cc +++ b/src/rule_with_operator.cc @@ -228,7 +228,7 @@ bool RuleWithOperator::evaluate(Transaction *trans, // FIXME: Make a class runTimeException to handle this cases. - for (auto &i : trans->m_ruleRemoveById) { + for (const auto &i : trans->m_ruleRemoveById) { if (m_ruleId != i) { continue; } @@ -236,7 +236,7 @@ bool RuleWithOperator::evaluate(Transaction *trans, " was skipped due to a ruleRemoveById action..."); return true; } - for (auto &i : trans->m_ruleRemoveByIdRange) { + for (const auto &i : trans->m_ruleRemoveByIdRange) { if (!(i.first <= m_ruleId && i.second >= m_ruleId)) { continue; } diff --git a/src/rules_exceptions.cc b/src/rules_exceptions.cc index 2c22d16f..68ded8b6 100644 --- a/src/rules_exceptions.cc +++ b/src/rules_exceptions.cc @@ -122,7 +122,7 @@ bool RulesExceptions::loadUpdateTargetById(double id, bool RulesExceptions::load(const std::string &a, std::string *error) { bool added = false; std::vector toRemove = utils::string::ssplit(a, ' '); - for (std::string &r : toRemove) { + for (const std::string &r : toRemove) { std::string b = modsecurity::utils::string::parserSanitizer(r); if (b.size() == 0) { continue; diff --git a/src/rules_set.cc b/src/rules_set.cc index 40f1f950..84e7974e 100644 --- a/src/rules_set.cc +++ b/src/rules_set.cc @@ -162,7 +162,7 @@ int RulesSet::evaluate(int phase, Transaction *t) { } bool remove_rule = false; if (ruleWithActions && m_exceptions.m_remove_rule_by_msg.empty() == false) { - for (auto &z : m_exceptions.m_remove_rule_by_msg) { + for (const auto &z : m_exceptions.m_remove_rule_by_msg) { if (ruleWithActions->containsMsg(z, t) == true) { ms_dbg_a(t, 9, "Skipped rule id '" \ + ruleWithActions->getReference() \ @@ -177,7 +177,7 @@ int RulesSet::evaluate(int phase, Transaction *t) { } if (ruleWithActions && m_exceptions.m_remove_rule_by_tag.empty() == false) { - for (auto &z : m_exceptions.m_remove_rule_by_tag) { + for (const auto &z : m_exceptions.m_remove_rule_by_tag) { if (ruleWithActions->containsTag(z, t) == true) { ms_dbg_a(t, 9, "Skipped rule id '" \ + ruleWithActions->getReference() \ @@ -193,7 +193,7 @@ int RulesSet::evaluate(int phase, Transaction *t) { if (ruleWithActions) { - for (auto &z : t->m_ruleRemoveByTag) { + for (const auto &z : t->m_ruleRemoveByTag) { if (ruleWithActions->containsTag(z, t) == true) { ms_dbg_a(t, 9, "Skipped rule id '" \ + ruleWithActions->getReference() \ diff --git a/src/transaction.cc b/src/transaction.cc index c294d7f3..0c98b49c 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -1242,7 +1242,7 @@ int Transaction::processResponseBody() { return true; } - std::set &bi = \ + const std::set &bi = \ m_rules->m_responseBodyTypeToBeInspected.m_value; auto t = bi.find(m_variableResponseContentType.m_value); if (t == bi.end() diff --git a/src/variables/remote_user.cc b/src/variables/remote_user.cc index a6c6816b..078a88fb 100644 --- a/src/variables/remote_user.cc +++ b/src/variables/remote_user.cc @@ -69,7 +69,7 @@ void RemoteUser::evaluate(Transaction *transaction, var = new VariableValue(&l2->at(0)->getKeyWithCollection(), &transaction->m_variableRemoteUser); - for (auto &i : l2->at(0)->getOrigin()) { + for (const auto &i : l2->at(0)->getOrigin()) { std::unique_ptr origin(new VariableOrigin()); origin->m_offset = i->m_offset; origin->m_length = i->m_length; diff --git a/src/variables/variable.cc b/src/variables/variable.cc index 0a50d322..740548cb 100644 --- a/src/variables/variable.cc +++ b/src/variables/variable.cc @@ -83,7 +83,7 @@ std::string operator+(const std::string &a, Variable *v) { std::string operator+(const std::string &a, Variables *v) { std::string test; - for (auto &b : *v) { + for (const auto &b : *v) { if (test.empty()) { test = std::string("") + b; } else {