Adds initial support to chained rules

This commit is contained in:
Felipe Zimmerle
2015-07-21 10:49:43 -03:00
parent 9c066e3198
commit 4f20f5bf74
8 changed files with 122 additions and 4 deletions

View File

@@ -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;
}