mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Use 'equal_range' instead of full scan for rule exceptions
The original author was @WGH-, this change was proposed at #2370
This commit is contained in:
parent
904fd030f9
commit
0f1d3bfc3e
@ -223,12 +223,9 @@ void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) const {
|
|||||||
* FIXME: SecRuleUpdateActionBy should be runtime
|
* FIXME: SecRuleUpdateActionBy should be runtime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
for (auto &b :
|
auto range = trans->m_rules->m_exceptions.m_action_pos_update_target_by_id.equal_range(m_ruleId);
|
||||||
trans->m_rules->m_exceptions.m_action_pos_update_target_by_id) {
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
if (m_ruleId != b.first) {
|
ActionWithExecution *a = dynamic_cast<ActionWithExecution*>(it->second.get());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ActionWithExecution *a = dynamic_cast<ActionWithExecution*>(b.second.get());
|
|
||||||
if (dynamic_cast<ActionDisruptive *>(a)) {
|
if (dynamic_cast<ActionDisruptive *>(a)) {
|
||||||
trans->messageGetLast()->setRule(this);
|
trans->messageGetLast()->setRule(this);
|
||||||
}
|
}
|
||||||
@ -328,23 +325,16 @@ void RuleWithActions::executeTransformations(
|
|||||||
|
|
||||||
// FIXME: It can't be something different from transformation. Sort this
|
// FIXME: It can't be something different from transformation. Sort this
|
||||||
// on rules compile time.
|
// on rules compile time.
|
||||||
for (auto &b :
|
auto range = trans->m_rules->m_exceptions.m_action_transformation_update_target_by_id.equal_range(m_ruleId);
|
||||||
trans->m_rules->m_exceptions.m_action_transformation_update_target_by_id) {
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
if (m_ruleId != b.first) {
|
Transformation *t = it->second.get();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Transformation *t = b.second.get();
|
|
||||||
if (dynamic_cast<actions::transformations::None *>(t)) {
|
if (dynamic_cast<actions::transformations::None *>(t)) {
|
||||||
none++;
|
none++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &b :
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
trans->m_rules->m_exceptions.m_action_transformation_update_target_by_id) {
|
Transformation *t = it->second.get();
|
||||||
if (m_ruleId != b.first) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Transformation *t = b.second.get();
|
|
||||||
if (none == 0) {
|
if (none == 0) {
|
||||||
executeTransformation(trans, &results, t);
|
executeTransformation(trans, &results, t);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user