mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Adds support to SecDefaultAction configuration directive
This commit is contained in:
@@ -88,6 +88,7 @@ class Action {
|
||||
Assay *assay);
|
||||
virtual bool evaluate(Rule *rule, Assay *assay);
|
||||
virtual bool init(std::string *error) { return true; }
|
||||
virtual bool isDisruptive() { return false; }
|
||||
|
||||
static Action *instantiate(const std::string& name);
|
||||
|
||||
|
@@ -27,7 +27,9 @@ namespace ModSecurity {
|
||||
namespace actions {
|
||||
|
||||
Phase::Phase(std::string action)
|
||||
: Action(action) {
|
||||
: Action(action),
|
||||
m_secRulesPhase(0),
|
||||
phase(0) {
|
||||
this->action_kind = ConfigurationKind;
|
||||
std::string a = action;
|
||||
a.erase(0, 6);
|
||||
@@ -42,20 +44,25 @@ Phase::Phase(std::string action)
|
||||
this->phase = 0;
|
||||
if (tolower(a) == "request") {
|
||||
this->phase = this->phase + ModSecurity::Phases::RequestHeadersPhase;
|
||||
m_secRulesPhase = 2;
|
||||
}
|
||||
if (tolower(a) == "response") {
|
||||
this->phase = this->phase + ModSecurity::Phases::ResponseBodyPhase;
|
||||
m_secRulesPhase = 4;
|
||||
}
|
||||
if (tolower(a) == "logging") {
|
||||
this->phase = this->phase + ModSecurity::Phases::LoggingPhase;
|
||||
m_secRulesPhase = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->phase == 0) {
|
||||
/* Phase 0 is something new, we want to use as ConnectionPhase */
|
||||
this->phase = ModSecurity::Phases::ConnectionPhase;
|
||||
m_secRulesPhase = 2;
|
||||
} else {
|
||||
/* Otherwise we want to shift the rule to the correct phase */
|
||||
m_secRulesPhase = phase;
|
||||
this->phase = phase + ModSecurity::Phases::RequestHeadersPhase - 1;
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ class Phase : public Action {
|
||||
|
||||
bool evaluate(Rule *rule, Assay *assay) override;
|
||||
int phase;
|
||||
int m_secRulesPhase;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
|
Reference in New Issue
Block a user