mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 03:57:47 +03:00
Adds support for update target by message
This commit is contained in:
34
src/rule.cc
34
src/rule.cc
@@ -433,6 +433,7 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
|
||||
Transaction *trans) {
|
||||
std::list<std::string> exclusions;
|
||||
std::list<std::string> exclusions_update_by_tag_remove;
|
||||
std::list<std::string> exclusions_update_by_msg_remove;
|
||||
std::list<std::string> exclusions_update_by_id_remove;
|
||||
std::vector<Variables::Variable *> variables;
|
||||
std::vector<std::unique_ptr<collection::Variable>> finalVars;
|
||||
@@ -458,6 +459,25 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &a : trans->m_rules->m_exceptions.m_variable_update_target_by_msg) {
|
||||
if (containsMsg(*a.first.get(), trans) == false) {
|
||||
continue;
|
||||
}
|
||||
if (a.second->m_isExclusion) {
|
||||
std::vector<const collection::Variable *> z;
|
||||
a.second->evaluateInternal(trans, this, &z);
|
||||
for (auto &y : z) {
|
||||
exclusions_update_by_msg_remove.push_back(std::string(y->m_key));
|
||||
delete y;
|
||||
}
|
||||
exclusions_update_by_msg_remove.push_back(std::string(a.second->m_name));
|
||||
|
||||
} else {
|
||||
Variable *b = a.second.get();
|
||||
variables.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &a : trans->m_rules->m_exceptions.m_variable_update_target_by_id) {
|
||||
if (m_ruleId != a.first) {
|
||||
continue;
|
||||
@@ -527,6 +547,20 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::find_if(exclusions_update_by_msg_remove.begin(),
|
||||
exclusions_update_by_msg_remove.end(),
|
||||
[key](std::string m) -> bool { return key == m; })
|
||||
!= exclusions_update_by_msg_remove.end()) {
|
||||
#ifndef NO_LOGS
|
||||
trans->debug(9, "Variable: " + key +
|
||||
" is part of the exclusion list (from update by msg" +
|
||||
"), skipping...");
|
||||
#endif
|
||||
delete v;
|
||||
v = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::find_if(exclusions_update_by_id_remove.begin(),
|
||||
exclusions_update_by_id_remove.end(),
|
||||
[key](std::string m) -> bool { return key == m; })
|
||||
|
Reference in New Issue
Block a user