mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Check for disruptive action on SecDefaultAction
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1145,6 +1145,7 @@ expression:
|
||||
}
|
||||
| CONFIG_DIR_SEC_DEFAULT_ACTION actions
|
||||
{
|
||||
bool hasDisruptive = false;
|
||||
std::vector<actions::Action *> *actions = new std::vector<actions::Action *>();
|
||||
for (auto &i : *$2.get()) {
|
||||
actions->push_back(i.release());
|
||||
@@ -1154,6 +1155,9 @@ expression:
|
||||
int secRuleDefinedPhase = -1;
|
||||
for (actions::Action *a : *actions) {
|
||||
actions::Phase *phase = dynamic_cast<actions::Phase *>(a);
|
||||
if (a->isDisruptive() == true && dynamic_cast<actions::disruptive::Block *>(a) == NULL) {
|
||||
hasDisruptive = true;
|
||||
}
|
||||
if (phase != NULL) {
|
||||
definedPhase = phase->m_phase;
|
||||
secRuleDefinedPhase = phase->m_secRulesPhase;
|
||||
@@ -1175,6 +1179,11 @@ expression:
|
||||
definedPhase = modsecurity::Phases::RequestHeadersPhase;
|
||||
}
|
||||
|
||||
if (hasDisruptive == false) {
|
||||
driver.error(@0, "SecDefaultAction must specify a disruptive action.");
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
if (!driver.m_defaultActions[definedPhase].empty()) {
|
||||
std::stringstream ss;
|
||||
ss << "SecDefaultActions can only be placed once per phase and configuration context. Phase ";
|
||||
@@ -1184,6 +1193,10 @@ expression:
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
for (actions::Action *a : checkedActions) {
|
||||
|
||||
}
|
||||
|
||||
for (actions::Action *a : checkedActions) {
|
||||
driver.m_defaultActions[definedPhase].push_back(a);
|
||||
}
|
||||
|
Reference in New Issue
Block a user