Adds support to SecDefaultAction configuration directive

This commit is contained in:
Felipe Zimmerle
2015-09-04 10:55:20 -03:00
parent f2ed890ea6
commit 010c18f63f
11 changed files with 428 additions and 2 deletions

View File

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

View File

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

View File

@@ -36,6 +36,7 @@ class Phase : public Action {
bool evaluate(Rule *rule, Assay *assay) override;
int phase;
int m_secRulesPhase;
};
} // namespace actions