mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-17 01:51:52 +03:00
Refactoring: Makes transformations to work with new execute signature
This commit is contained in:
@@ -291,15 +291,22 @@ bool RuleWithOperator::evaluate(Transaction *trans) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TransformationResults values;
|
||||
TransformationsResults transformationsResults;
|
||||
|
||||
executeTransformations(trans, value, values);
|
||||
executeTransformations(trans, value, transformationsResults);
|
||||
|
||||
for (const auto &valueTemp : values) {
|
||||
auto iter = transformationsResults.begin();
|
||||
if (!hasMultimatchAction()) {
|
||||
iter = transformationsResults.end();
|
||||
std::advance(iter, -1);
|
||||
}
|
||||
while (iter != transformationsResults.end()) {
|
||||
bool ret;
|
||||
std::string valueAfterTrans = std::move(*valueTemp.first);
|
||||
auto &valueTemp = *iter;
|
||||
// FIXME: this copy is not necessary.
|
||||
std::string *valueAfterTrans = new std::string(valueTemp.getAfter()->c_str());
|
||||
|
||||
ret = executeOperatorAt(trans, key, valueAfterTrans);
|
||||
ret = executeOperatorAt(trans, key, *valueAfterTrans);
|
||||
|
||||
if (ret == true) {
|
||||
trans->messageGetLast()->m_match = m_operator->resolveMatchMessage(trans,
|
||||
@@ -308,14 +315,28 @@ bool RuleWithOperator::evaluate(Transaction *trans) {
|
||||
for (auto &i : v->getOrigin()) {
|
||||
trans->messageGetLast()->m_reference.append(i->toText());
|
||||
}
|
||||
auto iter2 = transformationsResults.begin();
|
||||
while (iter2 != transformationsResults.end()) {
|
||||
if (iter2->getTransformationName()) {
|
||||
trans->messageGetLast()->m_reference.append(*iter2->getTransformationName());
|
||||
}
|
||||
/*
|
||||
if (iter == iter2) {
|
||||
break;
|
||||
} else {
|
||||
trans->messageGetLast()->m_reference.append("--");
|
||||
}
|
||||
*/
|
||||
iter2++;
|
||||
}
|
||||
|
||||
trans->messageGetLast()->m_reference.append(*valueTemp.second);
|
||||
|
||||
updateMatchedVars(trans, key, valueAfterTrans);
|
||||
updateMatchedVars(trans, key, *valueAfterTrans);
|
||||
executeActionsIndependentOfChainedRuleResult(trans);
|
||||
|
||||
globalRet = true;
|
||||
}
|
||||
delete valueAfterTrans;
|
||||
iter++;
|
||||
}
|
||||
delete v;
|
||||
v = NULL;
|
||||
|
||||
Reference in New Issue
Block a user