mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Correct the usage of modsecurity::Phases::NUMBER_OF_PHASES
This commit is contained in:
parent
ce3abf2626
commit
3b3004d24d
@ -415,7 +415,7 @@ class RulesProperties {
|
|||||||
to->m_responseBodyTypeToBeInspected.m_set = true;
|
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 = \
|
std::vector<actions::Action *> *actions_from = \
|
||||||
from->m_defaultActions+i;
|
from->m_defaultActions+i;
|
||||||
std::vector<actions::Action *> *actions_to = to->m_defaultActions+i;
|
std::vector<actions::Action *> *actions_to = to->m_defaultActions+i;
|
||||||
@ -535,8 +535,8 @@ class RulesProperties {
|
|||||||
ConfigString m_uploadTmpDirectory;
|
ConfigString m_uploadTmpDirectory;
|
||||||
ConfigString m_secArgumentSeparator;
|
ConfigString m_secArgumentSeparator;
|
||||||
ConfigString m_secWebAppId;
|
ConfigString m_secWebAppId;
|
||||||
std::vector<actions::Action *> m_defaultActions[8];
|
std::vector<actions::Action *> m_defaultActions[modsecurity::Phases::NUMBER_OF_PHASES];
|
||||||
std::vector<modsecurity::Rule *> m_rules[8];
|
std::vector<modsecurity::Rule *> m_rules[modsecurity::Phases::NUMBER_OF_PHASES];
|
||||||
ConfigUnicodeMap m_unicodeMapTable;
|
ConfigUnicodeMap m_unicodeMapTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ bool Phase::init(std::string *error) {
|
|||||||
} else if (m_phase == 5) {
|
} else if (m_phase == 5) {
|
||||||
m_phase = modsecurity::Phases::LoggingPhase;
|
m_phase = modsecurity::Phases::LoggingPhase;
|
||||||
m_secRulesPhase = 5;
|
m_secRulesPhase = 5;
|
||||||
|
} else {
|
||||||
|
error->assign("Unknown phase: " + m_parser_payload);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (a == "request") {
|
if (a == "request") {
|
||||||
@ -64,16 +67,6 @@ bool Phase::init(std::string *error) {
|
|||||||
m_secRulesPhase = 5;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ int Driver::addSecMarker(std::string marker) {
|
|||||||
|
|
||||||
|
|
||||||
int Driver::addSecAction(Rule *rule) {
|
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 << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||||
m_parserError << std::endl;
|
m_parserError << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -71,7 +71,7 @@ int Driver::addSecRuleScript(RuleScript *rule) {
|
|||||||
|
|
||||||
|
|
||||||
int Driver::addSecRule(Rule *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 << "Unknown phase: " << std::to_string(rule->m_phase);
|
||||||
m_parserError << std::endl;
|
m_parserError << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -152,7 +152,7 @@ std::string Rules::getParserError() {
|
|||||||
|
|
||||||
|
|
||||||
int Rules::evaluate(int phase, Transaction *t) {
|
int Rules::evaluate(int phase, Transaction *t) {
|
||||||
if (phase > modsecurity::Phases::NUMBER_OF_PHASES) {
|
if (phase >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ void Rules::debug(int level, const std::string &id,
|
|||||||
|
|
||||||
void Rules::dump() {
|
void Rules::dump() {
|
||||||
std::cout << "Rules: " << std::endl;
|
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::vector<Rule *> rules = m_rules[i];
|
||||||
std::cout << "Phase: " << std::to_string(i);
|
std::cout << "Phase: " << std::to_string(i);
|
||||||
std::cout << " (" << std::to_string(rules.size());
|
std::cout << " (" << std::to_string(rules.size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user