mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Refactor: replaced 3 declarations with 3 structured binding declarations.
This syntax is far more expressive and easier to understand than the old one. Refactor: flipped the conditions in "if (contains[Tag|Msg|Id]( ... " statements for clearer code. Refactor: moved "Variable *b" as an init-statement inside "if()" statements for stricter scope. Reference: https://sonarcloud.io/project/issues?open=AY8-ff1vm_fzkWiCOtCt&id=owasp-modsecurity_ModSecurity
This commit is contained in:
parent
e8db92ebb0
commit
35e825d643
@ -133,45 +133,33 @@ bool RuleWithOperator::executeOperatorAt(Transaction *trans, const std::string &
|
||||
|
||||
void RuleWithOperator::getVariablesExceptions(Transaction *t,
|
||||
variables::Variables *exclusion, variables::Variables *addition) {
|
||||
for (const auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) { // cppcheck-suppress ctunullpointer
|
||||
if (containsTag(*a.first.get(), t) == false) {
|
||||
continue;
|
||||
}
|
||||
Variable *b = a.second.get();
|
||||
if (dynamic_cast<variables::VariableModificatorExclusion*>(b)) {
|
||||
exclusion->push_back(
|
||||
dynamic_cast<variables::VariableModificatorExclusion*>(
|
||||
b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
for (const auto &[tag, v] : t->m_rules->m_exceptions.m_variable_update_target_by_tag) { // cppcheck-suppress ctunullpointer
|
||||
if (containsTag(*tag.get(), t)) {
|
||||
if (Variable *b{v.get()};dynamic_cast<variables::VariableModificatorExclusion*>(b)) {
|
||||
exclusion->push_back(dynamic_cast<variables::VariableModificatorExclusion*>(b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_msg) {
|
||||
if (containsMsg(*a.first.get(), t) == false) {
|
||||
continue;
|
||||
}
|
||||
Variable *b = a.second.get();
|
||||
if (dynamic_cast<variables::VariableModificatorExclusion*>(b)) {
|
||||
exclusion->push_back(
|
||||
dynamic_cast<variables::VariableModificatorExclusion*>(
|
||||
b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
for (const auto &[msg, v] : t->m_rules->m_exceptions.m_variable_update_target_by_msg) {
|
||||
if (containsMsg(*msg.get(), t)) {
|
||||
if (Variable *b{v.get()}; dynamic_cast<variables::VariableModificatorExclusion *>(b)) {
|
||||
exclusion->push_back(dynamic_cast<variables::VariableModificatorExclusion *>(b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_id) {
|
||||
if (m_ruleId != a.first) {
|
||||
continue;
|
||||
}
|
||||
Variable *b = a.second.get();
|
||||
if (dynamic_cast<variables::VariableModificatorExclusion*>(b)) {
|
||||
exclusion->push_back(
|
||||
dynamic_cast<variables::VariableModificatorExclusion*>(
|
||||
b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
for (const auto &[id, v] : t->m_rules->m_exceptions.m_variable_update_target_by_id) {
|
||||
if (m_ruleId == id) {
|
||||
if (Variable *b{v.get()};dynamic_cast<variables::VariableModificatorExclusion *>(b)) {
|
||||
exclusion->push_back(dynamic_cast<variables::VariableModificatorExclusion *>(b)->m_base.get());
|
||||
} else {
|
||||
addition->push_back(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user