mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Saves `MATCHED_VAR' and related before execute the actions
Actions should have access to the MATCHED_VAR.
This commit is contained in:
parent
778db259cf
commit
47a62b98bb
30
src/rule.cc
30
src/rule.cc
@ -400,6 +400,14 @@ bool Rule::evaluate(Transaction *trasn) {
|
|||||||
" variable `" + v->m_key + "' (Value: `" + value + "' )";
|
" variable `" + v->m_key + "' (Value: `" + value + "' )";
|
||||||
#ifndef NO_LOGS
|
#ifndef NO_LOGS
|
||||||
trasn->debug(4, "Rule returned 1.");
|
trasn->debug(4, "Rule returned 1.");
|
||||||
|
trasn->m_collections.storeOrUpdateFirst("MATCHED_VAR",
|
||||||
|
value);
|
||||||
|
trasn->m_collections.storeOrUpdateFirst("MATCHED_VAR_NAME",
|
||||||
|
v->m_key);
|
||||||
|
trasn->m_collections.store("MATCHED_VARS:"
|
||||||
|
+ v->m_key, value);
|
||||||
|
trasn->m_collections.store("MATCHED_VARS_NAMES:"
|
||||||
|
+ v->m_key, v->m_key);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (Action *a :
|
for (Action *a :
|
||||||
@ -419,24 +427,7 @@ bool Rule::evaluate(Transaction *trasn) {
|
|||||||
#ifndef NO_LOGS
|
#ifndef NO_LOGS
|
||||||
trasn->debug(4, "Executing chained rule.");
|
trasn->debug(4, "Executing chained rule.");
|
||||||
#endif
|
#endif
|
||||||
if (trasn->m_collections.storeOrUpdateFirst("MATCHED_VAR",
|
|
||||||
value) == false) {
|
|
||||||
trasn->m_collections.store("MATCHED_VAR", value);
|
|
||||||
}
|
|
||||||
if (trasn->m_collections.storeOrUpdateFirst(
|
|
||||||
"MATCHED_VAR_NAME", v->m_key) == false) {
|
|
||||||
trasn->m_collections.store("MATCHED_VAR_NAME",
|
|
||||||
v->m_key);
|
|
||||||
}
|
|
||||||
trasn->m_collections.store("MATCHED_VARS:"
|
|
||||||
+ v->m_key, value);
|
|
||||||
trasn->m_collections.store("MATCHED_VARS_NAMES:"
|
|
||||||
+ v->m_key, v->m_key);
|
|
||||||
chainResult = this->chainedRule->evaluate(trasn);
|
chainResult = this->chainedRule->evaluate(trasn);
|
||||||
trasn->m_collections.storeOrUpdateFirst("MATCHED_VAR", "");
|
|
||||||
trasn->m_collections.del("MATCHED_VARS:" + v->m_key);
|
|
||||||
trasn->m_collections.del("MATCHED_VARS_NAMES:" + v->m_key);
|
|
||||||
trasn->m_collections.del("MATCHED_VARS_NAME");
|
|
||||||
}
|
}
|
||||||
if ((this->chained && chainResult == true) || !this->chained) {
|
if ((this->chained && chainResult == true) || !this->chained) {
|
||||||
for (Action *a :
|
for (Action *a :
|
||||||
@ -509,6 +500,11 @@ bool Rule::evaluate(Transaction *trasn) {
|
|||||||
} else {
|
} else {
|
||||||
#ifndef NO_LOGS
|
#ifndef NO_LOGS
|
||||||
trasn->debug(4, "Rule returned 0.");
|
trasn->debug(4, "Rule returned 0.");
|
||||||
|
trasn->m_collections.storeOrUpdateFirst("MATCHED_VAR", "");
|
||||||
|
trasn->m_collections.del("MATCHED_VARS:" + v->m_key);
|
||||||
|
trasn->m_collections.del("MATCHED_VARS_NAMES:" + v->m_key);
|
||||||
|
trasn->m_collections.del("MATCHED_VARS_NAME");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user