mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
const-ify some references (satisfy cppcheck)
This commit is contained in:
parent
b9836bcaa4
commit
36adc58ea3
@ -47,7 +47,7 @@ class AnchoredSetVariableTranslationProxy {
|
|||||||
VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey());
|
VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey());
|
||||||
const VariableValue *oldVariableValue = l->at(i);
|
const VariableValue *oldVariableValue = l->at(i);
|
||||||
l->at(i) = newVariableValue;
|
l->at(i) = newVariableValue;
|
||||||
for (auto &oldOrigin : oldVariableValue->getOrigin()) {
|
for (const auto &oldOrigin : oldVariableValue->getOrigin()) {
|
||||||
std::unique_ptr<VariableOrigin> newOrigin(new VariableOrigin);
|
std::unique_ptr<VariableOrigin> newOrigin(new VariableOrigin);
|
||||||
newOrigin->m_length = oldVariableValue->getKey().size();
|
newOrigin->m_length = oldVariableValue->getKey().size();
|
||||||
newOrigin->m_offset = oldOrigin->m_offset - oldVariableValue->getKey().size() - 1;
|
newOrigin->m_offset = oldOrigin->m_offset - oldVariableValue->getKey().size() - 1;
|
||||||
|
@ -62,7 +62,7 @@ class VariableValue {
|
|||||||
m_keyWithCollection(o->m_keyWithCollection),
|
m_keyWithCollection(o->m_keyWithCollection),
|
||||||
m_value(o->m_value)
|
m_value(o->m_value)
|
||||||
{
|
{
|
||||||
for (auto &i : o->m_orign) {
|
for (const auto &i : o->m_orign) {
|
||||||
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
|
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
|
||||||
origin->m_offset = i->m_offset;
|
origin->m_offset = i->m_offset;
|
||||||
origin->m_length = i->m_length;
|
origin->m_length = i->m_length;
|
||||||
|
@ -30,7 +30,7 @@ bool RuleRemoveById::init(std::string *error) {
|
|||||||
std::string what(m_parser_payload, 15, m_parser_payload.size() - 15);
|
std::string what(m_parser_payload, 15, m_parser_payload.size() - 15);
|
||||||
bool added = false;
|
bool added = false;
|
||||||
std::vector<std::string> toRemove = utils::string::ssplit(what, ' ');
|
std::vector<std::string> toRemove = utils::string::ssplit(what, ' ');
|
||||||
for (std::string &a : toRemove) {
|
for (const std::string &a : toRemove) {
|
||||||
std::string b = modsecurity::utils::string::parserSanitizer(a);
|
std::string b = modsecurity::utils::string::parserSanitizer(a);
|
||||||
if (b.size() == 0) {
|
if (b.size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -289,7 +289,7 @@ bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RuleMessage &i : transaction->m_rulesMessages) {
|
for (const RuleMessage &i : transaction->m_rulesMessages) {
|
||||||
if (i.m_noAuditLog == false) {
|
if (i.m_noAuditLog == false) {
|
||||||
saveAnyway = true;
|
saveAnyway = true;
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,7 @@ std::string RuleMessage::_details(const RuleMessage *rm) {
|
|||||||
msg.append(" [maturity \"" + std::to_string(rm->m_maturity) + "\"]");
|
msg.append(" [maturity \"" + std::to_string(rm->m_maturity) + "\"]");
|
||||||
msg.append(" [accuracy \"" + std::to_string(rm->m_accuracy) + "\"]");
|
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) + "\"]");
|
msg.append(" [tag \"" + utils::string::toHexIfNeeded(a, true) + "\"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ bool RuleWithOperator::evaluate(Transaction *trans,
|
|||||||
|
|
||||||
|
|
||||||
// FIXME: Make a class runTimeException to handle this cases.
|
// 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) {
|
if (m_ruleId != i) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ bool RuleWithOperator::evaluate(Transaction *trans,
|
|||||||
" was skipped due to a ruleRemoveById action...");
|
" was skipped due to a ruleRemoveById action...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (auto &i : trans->m_ruleRemoveByIdRange) {
|
for (const auto &i : trans->m_ruleRemoveByIdRange) {
|
||||||
if (!(i.first <= m_ruleId && i.second >= m_ruleId)) {
|
if (!(i.first <= m_ruleId && i.second >= m_ruleId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ bool RulesExceptions::loadUpdateTargetById(double id,
|
|||||||
bool RulesExceptions::load(const std::string &a, std::string *error) {
|
bool RulesExceptions::load(const std::string &a, std::string *error) {
|
||||||
bool added = false;
|
bool added = false;
|
||||||
std::vector<std::string> toRemove = utils::string::ssplit(a, ' ');
|
std::vector<std::string> toRemove = utils::string::ssplit(a, ' ');
|
||||||
for (std::string &r : toRemove) {
|
for (const std::string &r : toRemove) {
|
||||||
std::string b = modsecurity::utils::string::parserSanitizer(r);
|
std::string b = modsecurity::utils::string::parserSanitizer(r);
|
||||||
if (b.size() == 0) {
|
if (b.size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -162,7 +162,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
|
|||||||
}
|
}
|
||||||
bool remove_rule = false;
|
bool remove_rule = false;
|
||||||
if (ruleWithActions && m_exceptions.m_remove_rule_by_msg.empty() == 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) {
|
if (ruleWithActions->containsMsg(z, t) == true) {
|
||||||
ms_dbg_a(t, 9, "Skipped rule id '" \
|
ms_dbg_a(t, 9, "Skipped rule id '" \
|
||||||
+ ruleWithActions->getReference() \
|
+ ruleWithActions->getReference() \
|
||||||
@ -177,7 +177,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ruleWithActions && m_exceptions.m_remove_rule_by_tag.empty() == false) {
|
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) {
|
if (ruleWithActions->containsTag(z, t) == true) {
|
||||||
ms_dbg_a(t, 9, "Skipped rule id '" \
|
ms_dbg_a(t, 9, "Skipped rule id '" \
|
||||||
+ ruleWithActions->getReference() \
|
+ ruleWithActions->getReference() \
|
||||||
@ -193,7 +193,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
|
|||||||
|
|
||||||
|
|
||||||
if (ruleWithActions) {
|
if (ruleWithActions) {
|
||||||
for (auto &z : t->m_ruleRemoveByTag) {
|
for (const auto &z : t->m_ruleRemoveByTag) {
|
||||||
if (ruleWithActions->containsTag(z, t) == true) {
|
if (ruleWithActions->containsTag(z, t) == true) {
|
||||||
ms_dbg_a(t, 9, "Skipped rule id '" \
|
ms_dbg_a(t, 9, "Skipped rule id '" \
|
||||||
+ ruleWithActions->getReference() \
|
+ ruleWithActions->getReference() \
|
||||||
|
@ -1242,7 +1242,7 @@ int Transaction::processResponseBody() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> &bi = \
|
const std::set<std::string> &bi = \
|
||||||
m_rules->m_responseBodyTypeToBeInspected.m_value;
|
m_rules->m_responseBodyTypeToBeInspected.m_value;
|
||||||
auto t = bi.find(m_variableResponseContentType.m_value);
|
auto t = bi.find(m_variableResponseContentType.m_value);
|
||||||
if (t == bi.end()
|
if (t == bi.end()
|
||||||
|
@ -69,7 +69,7 @@ void RemoteUser::evaluate(Transaction *transaction,
|
|||||||
var = new VariableValue(&l2->at(0)->getKeyWithCollection(),
|
var = new VariableValue(&l2->at(0)->getKeyWithCollection(),
|
||||||
&transaction->m_variableRemoteUser);
|
&transaction->m_variableRemoteUser);
|
||||||
|
|
||||||
for (auto &i : l2->at(0)->getOrigin()) {
|
for (const auto &i : l2->at(0)->getOrigin()) {
|
||||||
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
|
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
|
||||||
origin->m_offset = i->m_offset;
|
origin->m_offset = i->m_offset;
|
||||||
origin->m_length = i->m_length;
|
origin->m_length = i->m_length;
|
||||||
|
@ -83,7 +83,7 @@ std::string operator+(const std::string &a, Variable *v) {
|
|||||||
|
|
||||||
std::string operator+(const std::string &a, Variables *v) {
|
std::string operator+(const std::string &a, Variables *v) {
|
||||||
std::string test;
|
std::string test;
|
||||||
for (auto &b : *v) {
|
for (const auto &b : *v) {
|
||||||
if (test.empty()) {
|
if (test.empty()) {
|
||||||
test = std::string("") + b;
|
test = std::string("") + b;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user