mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-16 01:22:18 +03:00
Refactoring the cleaning of MATCHED_VAR* variables
This commit is contained in:
@@ -90,17 +90,6 @@ void RuleWithOperator::updateMatchedVars(Transaction *trans, const std::string &
|
||||
}
|
||||
|
||||
|
||||
void RuleWithOperator::cleanMatchedVars(Transaction *trans) {
|
||||
ms_dbg_a(trans, 9, "Matched vars cleaned.");
|
||||
// cppcheck-suppress ctunullpointer
|
||||
trans->m_variableMatchedVar.unset();
|
||||
trans->m_variableMatchedVars.unset();
|
||||
trans->m_variableMatchedVarName.unset();
|
||||
trans->m_variableMatchedVarsNames.unset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RuleWithOperator::executeOperatorAt(Transaction *trans, const std::string &key,
|
||||
const std::string &value, RuleMessage &ruleMessage) {
|
||||
#if MSC_EXEC_CLOCK_ENABLED
|
||||
@@ -324,7 +313,6 @@ bool RuleWithOperator::evaluate(Transaction *trans,
|
||||
|
||||
if (globalRet == false) {
|
||||
ms_dbg_a(trans, 4, "Rule returned 0.");
|
||||
cleanMatchedVars(trans);
|
||||
goto end_clean;
|
||||
}
|
||||
ms_dbg_a(trans, 4, "Rule returned 1.");
|
||||
|
||||
@@ -105,6 +105,14 @@ std::string RulesSet::getParserError() {
|
||||
return this->m_parserError.str();
|
||||
}
|
||||
|
||||
void RulesSet::cleanMatchedVars(Transaction *trans) {
|
||||
ms_dbg_a(trans, 9, "Matched vars cleaned.");
|
||||
// cppcheck-suppress ctunullpointer
|
||||
trans->m_variableMatchedVar.unset();
|
||||
trans->m_variableMatchedVars.unset();
|
||||
trans->m_variableMatchedVarName.unset();
|
||||
trans->m_variableMatchedVarsNames.unset();
|
||||
}
|
||||
|
||||
int RulesSet::evaluate(int phase, Transaction *t) {
|
||||
if (phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||
@@ -208,6 +216,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
|
||||
}
|
||||
|
||||
rule->evaluate(t);
|
||||
cleanMatchedVars(t);
|
||||
if (t->m_it.disruptive > 0) {
|
||||
|
||||
ms_dbg_a(t, 8, "Skipping this phase as this " \
|
||||
|
||||
Reference in New Issue
Block a user