Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions headers/modsecurity/rules_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class RulesProperties {
to->m_responseBodyTypeToBeInspected.m_set = true;
}

for (int i = 0; i <= modsecurity::Phases::NUMBER_OF_PHASES; i++) {
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
std::vector<actions::Action *> *actions_from = \
from->m_defaultActions+i;
std::vector<actions::Action *> *actions_to = to->m_defaultActions+i;
Expand Down Expand Up @@ -535,8 +535,8 @@ class RulesProperties {
ConfigString m_uploadTmpDirectory;
ConfigString m_secArgumentSeparator;
ConfigString m_secWebAppId;
std::vector<actions::Action *> m_defaultActions[8];
std::vector<modsecurity::Rule *> m_rules[8];
std::vector<actions::Action *> m_defaultActions[modsecurity::Phases::NUMBER_OF_PHASES];
std::vector<modsecurity::Rule *> m_rules[modsecurity::Phases::NUMBER_OF_PHASES];
ConfigUnicodeMap m_unicodeMapTable;
};

Expand Down
13 changes: 3 additions & 10 deletions src/actions/phase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ bool Phase::init(std::string *error) {
} else if (m_phase == 5) {
m_phase = modsecurity::Phases::LoggingPhase;
m_secRulesPhase = 5;
} else {
error->assign("Unknown phase: " + m_parser_payload);
return false;
}
} catch (...) {
if (a == "request") {
Expand All @@ -64,16 +67,6 @@ bool Phase::init(std::string *error) {
m_secRulesPhase = 5;
}
}
if (m_phase == -1) {
error->assign("Not able to associate the given rule to any phase: " + \
m_parser_payload);
return false;
}

if (m_phase > modsecurity::Phases::NUMBER_OF_PHASES) {
error->assign("Unknown phase: " + std::to_string(m_phase));
return false;
}

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int Driver::addSecMarker(std::string marker) {


int Driver::addSecAction(Rule *rule) {
if (rule->m_phase > modsecurity::Phases::NUMBER_OF_PHASES) {
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
m_parserError << "Unknown phase: " << std::to_string(rule->m_phase);
m_parserError << std::endl;
return false;
Expand All @@ -71,7 +71,7 @@ int Driver::addSecRuleScript(RuleScript *rule) {


int Driver::addSecRule(Rule *rule) {
if (rule->m_phase > modsecurity::Phases::NUMBER_OF_PHASES) {
if (rule->m_phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
m_parserError << "Unknown phase: " << std::to_string(rule->m_phase);
m_parserError << std::endl;
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/rules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ std::string Rules::getParserError() {


int Rules::evaluate(int phase, Transaction *t) {
if (phase > modsecurity::Phases::NUMBER_OF_PHASES) {
if (phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
return 0;
}

Expand Down Expand Up @@ -293,7 +293,7 @@ void Rules::debug(int level, const std::string &id,

void Rules::dump() {
std::cout << "Rules: " << std::endl;
for (int i = 0; i <= modsecurity::Phases::NUMBER_OF_PHASES; i++) {
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
std::vector<Rule *> rules = m_rules[i];
std::cout << "Phase: " << std::to_string(i);
std::cout << " (" << std::to_string(rules.size());
Expand Down