mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds support to MATCHED_VAR variable
This commit is contained in:
11
src/assay.cc
11
src/assay.cc
@@ -1128,6 +1128,17 @@ void Assay::store_variable(std::string key, const std::string &value) {
|
||||
this->m_variables_strings.emplace(key, value);
|
||||
}
|
||||
|
||||
bool Assay::update_variable_first(std::string var, const std::string &value) {
|
||||
auto range = m_variables_strings.equal_range(var);
|
||||
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
it->second = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::list<std::pair<std::string, std::string>>
|
||||
Assay::resolve_variable(std::string var) {
|
||||
|
@@ -115,7 +115,13 @@ bool Rule::evaluate(Assay *assay) {
|
||||
}
|
||||
|
||||
if (this->chained && this->chainedRule != NULL) {
|
||||
assay->debug(4, "Executing chained rule.");
|
||||
if (assay->update_variable_first("MATCHED_VAR",
|
||||
value) == false) {
|
||||
assay->store_variable("MATCHED_VAR", value);
|
||||
}
|
||||
this->chainedRule->evaluate(assay);
|
||||
assay->update_variable_first("MATCHED_VAR", "");
|
||||
}
|
||||
} else {
|
||||
assay->debug(4, "Rule returned 0.");
|
||||
|
Reference in New Issue
Block a user