Skip to content

Commit 36adc58

Browse files
committed
const-ify some references (satisfy cppcheck)
1 parent b9836bc commit 36adc58

11 files changed

+14
-14
lines changed

Diff for: headers/modsecurity/anchored_set_variable_translation_proxy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AnchoredSetVariableTranslationProxy {
4747
VariableValue *newVariableValue = new VariableValue(name, &l->at(i)->getKey(), &l->at(i)->getKey());
4848
const VariableValue *oldVariableValue = l->at(i);
4949
l->at(i) = newVariableValue;
50-
for (auto &oldOrigin : oldVariableValue->getOrigin()) {
50+
for (const auto &oldOrigin : oldVariableValue->getOrigin()) {
5151
std::unique_ptr<VariableOrigin> newOrigin(new VariableOrigin);
5252
newOrigin->m_length = oldVariableValue->getKey().size();
5353
newOrigin->m_offset = oldOrigin->m_offset - oldVariableValue->getKey().size() - 1;

Diff for: headers/modsecurity/variable_value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class VariableValue {
6262
m_keyWithCollection(o->m_keyWithCollection),
6363
m_value(o->m_value)
6464
{
65-
for (auto &i : o->m_orign) {
65+
for (const auto &i : o->m_orign) {
6666
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
6767
origin->m_offset = i->m_offset;
6868
origin->m_length = i->m_length;

Diff for: src/actions/ctl/rule_remove_by_id.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool RuleRemoveById::init(std::string *error) {
3030
std::string what(m_parser_payload, 15, m_parser_payload.size() - 15);
3131
bool added = false;
3232
std::vector<std::string> toRemove = utils::string::ssplit(what, ' ');
33-
for (std::string &a : toRemove) {
33+
for (const std::string &a : toRemove) {
3434
std::string b = modsecurity::utils::string::parserSanitizer(a);
3535
if (b.size() == 0) {
3636
continue;

Diff for: src/audit_log/audit_log.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ bool AuditLog::saveIfRelevant(Transaction *transaction, int parts) {
289289
return true;
290290
}
291291

292-
for (RuleMessage &i : transaction->m_rulesMessages) {
292+
for (const RuleMessage &i : transaction->m_rulesMessages) {
293293
if (i.m_noAuditLog == false) {
294294
saveAnyway = true;
295295
break;

Diff for: src/rule_message.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string RuleMessage::_details(const RuleMessage *rm) {
3838
msg.append(" [maturity \"" + std::to_string(rm->m_maturity) + "\"]");
3939
msg.append(" [accuracy \"" + std::to_string(rm->m_accuracy) + "\"]");
4040

41-
for (auto &a : rm->m_tags) {
41+
for (const auto &a : rm->m_tags) {
4242
msg.append(" [tag \"" + utils::string::toHexIfNeeded(a, true) + "\"]");
4343
}
4444

Diff for: src/rule_with_operator.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ bool RuleWithOperator::evaluate(Transaction *trans,
228228

229229

230230
// FIXME: Make a class runTimeException to handle this cases.
231-
for (auto &i : trans->m_ruleRemoveById) {
231+
for (const auto &i : trans->m_ruleRemoveById) {
232232
if (m_ruleId != i) {
233233
continue;
234234
}
235235
ms_dbg_a(trans, 9, "Rule id: " + std::to_string(m_ruleId) +
236236
" was skipped due to a ruleRemoveById action...");
237237
return true;
238238
}
239-
for (auto &i : trans->m_ruleRemoveByIdRange) {
239+
for (const auto &i : trans->m_ruleRemoveByIdRange) {
240240
if (!(i.first <= m_ruleId && i.second >= m_ruleId)) {
241241
continue;
242242
}

Diff for: src/rules_exceptions.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool RulesExceptions::loadUpdateTargetById(double id,
122122
bool RulesExceptions::load(const std::string &a, std::string *error) {
123123
bool added = false;
124124
std::vector<std::string> toRemove = utils::string::ssplit(a, ' ');
125-
for (std::string &r : toRemove) {
125+
for (const std::string &r : toRemove) {
126126
std::string b = modsecurity::utils::string::parserSanitizer(r);
127127
if (b.size() == 0) {
128128
continue;

Diff for: src/rules_set.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
162162
}
163163
bool remove_rule = false;
164164
if (ruleWithActions && m_exceptions.m_remove_rule_by_msg.empty() == false) {
165-
for (auto &z : m_exceptions.m_remove_rule_by_msg) {
165+
for (const auto &z : m_exceptions.m_remove_rule_by_msg) {
166166
if (ruleWithActions->containsMsg(z, t) == true) {
167167
ms_dbg_a(t, 9, "Skipped rule id '" \
168168
+ ruleWithActions->getReference() \
@@ -177,7 +177,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
177177
}
178178

179179
if (ruleWithActions && m_exceptions.m_remove_rule_by_tag.empty() == false) {
180-
for (auto &z : m_exceptions.m_remove_rule_by_tag) {
180+
for (const auto &z : m_exceptions.m_remove_rule_by_tag) {
181181
if (ruleWithActions->containsTag(z, t) == true) {
182182
ms_dbg_a(t, 9, "Skipped rule id '" \
183183
+ ruleWithActions->getReference() \
@@ -193,7 +193,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
193193

194194

195195
if (ruleWithActions) {
196-
for (auto &z : t->m_ruleRemoveByTag) {
196+
for (const auto &z : t->m_ruleRemoveByTag) {
197197
if (ruleWithActions->containsTag(z, t) == true) {
198198
ms_dbg_a(t, 9, "Skipped rule id '" \
199199
+ ruleWithActions->getReference() \

Diff for: src/transaction.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ int Transaction::processResponseBody() {
12421242
return true;
12431243
}
12441244

1245-
std::set<std::string> &bi = \
1245+
const std::set<std::string> &bi = \
12461246
m_rules->m_responseBodyTypeToBeInspected.m_value;
12471247
auto t = bi.find(m_variableResponseContentType.m_value);
12481248
if (t == bi.end()

Diff for: src/variables/remote_user.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void RemoteUser::evaluate(Transaction *transaction,
6969
var = new VariableValue(&l2->at(0)->getKeyWithCollection(),
7070
&transaction->m_variableRemoteUser);
7171

72-
for (auto &i : l2->at(0)->getOrigin()) {
72+
for (const auto &i : l2->at(0)->getOrigin()) {
7373
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
7474
origin->m_offset = i->m_offset;
7575
origin->m_length = i->m_length;

Diff for: src/variables/variable.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ std::string operator+(const std::string &a, Variable *v) {
8383

8484
std::string operator+(const std::string &a, Variables *v) {
8585
std::string test;
86-
for (auto &b : *v) {
86+
for (const auto &b : *v) {
8787
if (test.empty()) {
8888
test = std::string("") + b;
8989
} else {

0 commit comments

Comments
 (0)