Forces disruptive to be first-rule-only

ModSecurity version 3 is capable to handle disruptive actions in different
rules from the chain. However, lets get it working in the same fashion that
we have in version 2.
This commit is contained in:
Felipe Zimmerle
2017-04-24 21:02:50 -03:00
parent 7e59250068
commit 6421ff087a
9 changed files with 71 additions and 37 deletions

View File

@@ -70,22 +70,33 @@ int Driver::addSecRule(Rule *rule) {
return false;
}
if (lastRule && lastRule->m_chained && lastRule->m_chainedRule == NULL) {
rule->m_phase = lastRule->m_phase;
lastRule->m_chainedRule = rule;
return true;
if (lastRule && lastRule->m_chained) {
if (lastRule->m_chainedRule == NULL) {
rule->m_phase = lastRule->m_phase;
lastRule->m_chainedRule = rule;
if (rule->containsDisruptiveAction()) {
m_parserError << "Disruptive actions can only be specified by";
m_parserError << " chain starter rules.";
return false;
}
return true;
} else {
Rule *a = lastRule->m_chainedRule;
while (a->m_chained && a->m_chainedRule != NULL) {
a = a->m_chainedRule;
}
if (a->m_chained && a->m_chainedRule == NULL) {
a->m_chainedRule = rule;
if (a->containsDisruptiveAction()) {
m_parserError << "Disruptive actions can only be ";
m_parserError << "specified by chain starter rules.";
return false;
}
return true;
}
}
}
if (lastRule && lastRule->m_chained && lastRule->m_chainedRule != NULL) {
Rule *a = lastRule->m_chainedRule;
while (a->m_chained && a->m_chainedRule != NULL) {
a = a->m_chainedRule;
}
if (a->m_chained && a->m_chainedRule == NULL) {
a->m_chainedRule = rule;
return true;
}
}
/*
* Checking if the rule has an ID and also checking if this ID is not used