mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-03 21:13:50 +03:00
Adds initial support to chained rules
This commit is contained in:
@@ -34,9 +34,33 @@ int Driver::addSecRule(ModSecurity::Rule *rule) {
|
||||
/** TODO: return an error message */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int size = this->rules[rule->phase].size();
|
||||
|
||||
if (size == 0) {
|
||||
this->rules[rule->phase].push_back(rule);
|
||||
return true;
|
||||
}
|
||||
|
||||
ModSecurity::Rule *lastRule = this->rules[rule->phase][size-1];
|
||||
if (lastRule->chained && lastRule->chainedRule == NULL) {
|
||||
lastRule->chainedRule = rule;
|
||||
return true;
|
||||
}
|
||||
if (lastRule->chained && lastRule->chainedRule != NULL) {
|
||||
ModSecurity::Rule *a = lastRule->chainedRule;
|
||||
while (a->chained && a->chainedRule != NULL) {
|
||||
a = a->chainedRule;
|
||||
}
|
||||
if (a->chained && a->chainedRule == NULL) {
|
||||
a->chainedRule = rule;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
this->rules[rule->phase].push_back(rule);
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user