mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Cosmetics: Fix coding style
This commit is contained in:
parent
f6e0b447b3
commit
b497091017
@ -104,7 +104,6 @@ class ModSecurityStringVar {
|
||||
class ModSecurityStringVariables :
|
||||
public std::unordered_multimap<std::string, std::string> {
|
||||
public:
|
||||
|
||||
ModSecurityStringVariables() {
|
||||
this->reserve(1000);
|
||||
}
|
||||
@ -140,7 +139,6 @@ class ModSecurityStringVariables :
|
||||
std::list<ModSecurityStringVar *>
|
||||
resolveVariable(const std::string& key,
|
||||
std::list<ModSecurityStringVar *> *l) {
|
||||
|
||||
auto range = this->equal_range(key);
|
||||
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
@ -159,11 +157,11 @@ class ModSecurityStringVariables :
|
||||
if (x.first.compare(0, keySize, key + ":") != 0) {
|
||||
continue;
|
||||
}
|
||||
//auto range = this->equal_range(x.first);
|
||||
// auto range = this->equal_range(x.first);
|
||||
|
||||
//for (auto it = range.first; it != range.second; ++it) {
|
||||
// for (auto it = range.first; it != range.second; ++it) {
|
||||
l->push_back(new ModSecurityStringVar(x.first, x.second));
|
||||
//}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,6 +291,7 @@ class Assay {
|
||||
|
||||
std::list<std::pair<int, std::string>> auditLogModifier;
|
||||
std::string m_marker;
|
||||
|
||||
private:
|
||||
std::ofstream myfile;
|
||||
ModSecurity *m_ms;
|
||||
|
@ -74,8 +74,10 @@ class RulesProperties {
|
||||
delete m_debugLog;
|
||||
}
|
||||
|
||||
std::vector<Rule *> rules[7]; // ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
std::vector<actions::Action *> defaultActions[7]; // ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
std::vector<Rule *> rules[7];
|
||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
std::vector<actions::Action *> defaultActions[7];
|
||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -25,8 +25,7 @@ namespace actions {
|
||||
|
||||
CtlAuditLogParts::CtlAuditLogParts(std::string action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
mPartsAction(0)
|
||||
{
|
||||
mPartsAction(0) {
|
||||
std::string what(action, 18, 1);
|
||||
mParts = std::string(action, 19, action.length()-19);
|
||||
if (what == "+") {
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/assay.h"
|
||||
|
||||
#ifndef SRC_CLT_ACTIONS_AUDIT_LOG_PARTS_H_
|
||||
#define SRC_CLT_ACTIONS_AUDIT_LOG_PARTS_H_
|
||||
#ifndef SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
||||
#define SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace actions {
|
||||
@ -37,4 +37,4 @@ class CtlAuditLogParts : public Action {
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
||||
#endif // SRC_CLT_ACTIONS_AUDIT_LOG_PARTS_H_
|
||||
#endif // SRC_ACTIONS_CTL_AUDIT_LOG_PARTS_H_
|
||||
|
@ -36,9 +36,6 @@ bool Pass::evaluate(Rule *rule, Assay *assay) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Pass::fill_intervention(ModSecurityIntervention *i) {
|
||||
|
||||
}
|
||||
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
@ -30,7 +30,6 @@ class Pass : public Action {
|
||||
explicit Pass(std::string action);
|
||||
|
||||
bool evaluate(Rule *rule, Assay *assay) override;
|
||||
void fill_intervention(ModSecurityIntervention *i) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,8 @@ Phase::Phase(std::string action)
|
||||
} catch (...) {
|
||||
this->phase = 0;
|
||||
if (tolower(a) == "request") {
|
||||
this->phase = this->phase + ModSecurity::Phases::RequestHeadersPhase;
|
||||
this->phase = this->phase +
|
||||
ModSecurity::Phases::RequestHeadersPhase;
|
||||
m_secRulesPhase = 2;
|
||||
}
|
||||
if (tolower(a) == "response") {
|
||||
|
@ -36,14 +36,16 @@ bool RuleId::init(std::string *error) {
|
||||
m_ruleId = std::stod(a);
|
||||
} catch (...) {
|
||||
m_ruleId = 0;
|
||||
error->assign("The input \"" + a + "\" does not seems to be a valid rule id.");
|
||||
error->assign("The input \"" + a + "\" does not " \
|
||||
"seems to be a valid rule id.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << std::setprecision(40) << m_ruleId;
|
||||
if (a != oss.str() || m_ruleId < 0) {
|
||||
error->assign("The input \"" + a + "\" does not seems to be a valid rule id.");
|
||||
error->assign("The input \"" + a + "\" does not seems " \
|
||||
"to be a valid rule id.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -38,7 +38,7 @@ class RuleId : public Action {
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(Rule *rule, Assay *assay) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
double m_ruleId;
|
||||
};
|
||||
|
||||
|
25
src/assay.cc
25
src/assay.cc
@ -1084,29 +1084,33 @@ int Assay::processLogging(int returned_code) {
|
||||
/* If relevant, save this assay information at the audit_logs */
|
||||
if (m_rules != NULL && m_rules->audit_log != NULL) {
|
||||
#ifndef NO_LOGS
|
||||
debug(8, "Checking if this request is suitable to be saved as an audit log.");
|
||||
debug(8, "Checking if this request is suitable to be " \
|
||||
"saved as an audit log.");
|
||||
#endif
|
||||
int parts = -1;
|
||||
|
||||
if (this->auditLogModifier.size() > 0)
|
||||
{
|
||||
if (this->auditLogModifier.size() > 0) {
|
||||
#ifndef NO_LOGS
|
||||
debug(4, "There was an audit log modifier for this transaction.");
|
||||
#endif
|
||||
std::list<std::pair<int, std::string>>::iterator it;
|
||||
parts = this->m_rules->audit_log->m_parts;
|
||||
for (it = auditLogModifier.begin(); it != auditLogModifier.end(); ++it) {
|
||||
for (it = auditLogModifier.begin();
|
||||
it != auditLogModifier.end(); ++it) {
|
||||
std::pair <int, std::string> p = *it;
|
||||
if (p.first == 0) { // Add
|
||||
parts = this->m_rules->audit_log->addParts(parts, p.second);
|
||||
} else { // Remove
|
||||
parts = this->m_rules->audit_log->removeParts(parts, p.second);
|
||||
if (p.first == 0) { // Add
|
||||
parts = this->m_rules->audit_log->addParts(parts,
|
||||
p.second);
|
||||
} else { // Remove
|
||||
parts = this->m_rules->audit_log->removeParts(parts,
|
||||
p.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
if (save_in_auditlog) {
|
||||
debug(8, "This request was marked to be saved via auditlog action.");
|
||||
debug(8, "This request was marked to be " \
|
||||
"saved via auditlog action.");
|
||||
}
|
||||
|
||||
bool saved = this->m_rules->audit_log->saveIfRelevant(this, parts);
|
||||
@ -1489,7 +1493,8 @@ void Assay::resolve_variable(const std::string& var,
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Assay::resolve_variable(const std::string& var) {
|
||||
std::list<ModSecurityStringVar *> *l = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *l =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
resolve_variable(var, l);
|
||||
|
||||
|
@ -239,8 +239,7 @@ bool AuditLog::saveIfRelevant(Assay *assay, int parts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parts == -1)
|
||||
{
|
||||
if (parts == -1) {
|
||||
parts = m_parts;
|
||||
}
|
||||
m_writer->write(assay, parts);
|
||||
|
@ -169,7 +169,7 @@ class AuditLog {
|
||||
|
||||
int m_parts;
|
||||
|
||||
private:
|
||||
private:
|
||||
AuditLogStatus m_status;
|
||||
|
||||
|
||||
|
@ -70,9 +70,10 @@ int DebugLog::getDebugLogLevel() {
|
||||
|
||||
void DebugLog::write(int level, const std::string &msg) {
|
||||
if (level <= m_debugLevel) {
|
||||
DebugLogWriter::getInstance().write(m_fileName, "[" + std::to_string(level) + "] " + msg);
|
||||
DebugLogWriter::getInstance().write(m_fileName, "[" \
|
||||
+ std::to_string(level) + "] " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace ModSecurity
|
||||
} // namespace ModSecurity
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SRC_DEBUG_LOG_WRITER_H_
|
||||
#define SRC_DEBUG_LOG_WRITER_H_
|
||||
|
||||
#include "debug_log_writer_agent.h"
|
||||
#include "src/debug_log_writer_agent.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
@ -37,7 +37,7 @@ class DebugLogWriter {
|
||||
void close(const std::string& m_fileName);
|
||||
void open(const std::string& m_fileName);
|
||||
private:
|
||||
DebugLogWriter() {};
|
||||
DebugLogWriter() {}
|
||||
|
||||
// C++ 03
|
||||
// ========
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "debug_log_writer.h"
|
||||
|
||||
#include "src/debug_log_writer.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
|
@ -25,7 +25,7 @@ namespace ModSecurity {
|
||||
/** @ingroup ModSecurity_CPP_API */
|
||||
class DebugLogWriterAgent : public std::ofstream {
|
||||
public:
|
||||
DebugLogWriterAgent(const std::string& fileName);
|
||||
explicit DebugLogWriterAgent(const std::string& fileName);
|
||||
~DebugLogWriterAgent() {
|
||||
if (is_open()) {
|
||||
close();
|
||||
|
@ -32,7 +32,8 @@ class MacroExpansion {
|
||||
MacroExpansion();
|
||||
|
||||
static std::string expand(const std::string& input, Assay *assay);
|
||||
static std::string expandKeepOriginal(const std::string& input, Assay *assay);
|
||||
static std::string expandKeepOriginal(const std::string& input,
|
||||
Assay *assay);
|
||||
};
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define SRC_OPERATORS_CONTAINS_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "operators/operator.h"
|
||||
|
@ -59,9 +59,10 @@ void Pm::postOrderTraversal(acmp_btree_node_t *node) {
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
void Pm::replaceAll(std::string& str, const std::string& from, const std::string& to) {
|
||||
void Pm::replaceAll(std::string str, const std::string& from,
|
||||
const std::string& to) {
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||
size_t end_pos = start_pos + from.length();
|
||||
str.replace(start_pos, end_pos, to);
|
||||
start_pos += to.length();
|
||||
|
@ -35,7 +35,8 @@ class Pm : public Operator {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
~Pm();
|
||||
void replaceAll(std::string& str, const std::string& from, const std::string& to);
|
||||
void replaceAll(std::string str, const std::string& from,
|
||||
const std::string& to);
|
||||
bool evaluate(Assay *assay, const std::string &input);
|
||||
|
||||
virtual bool init(const char **error);
|
||||
|
@ -30,7 +30,7 @@ bool Rx::evaluate(Assay *assay, const std::string& input) {
|
||||
SMatch match;
|
||||
|
||||
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
|
||||
//this->matched.push_back(match.match);
|
||||
// this->matched.push_back(match.match);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,8 @@ int Driver::addSecRule(Rule *rule) {
|
||||
std::vector<Rule *> rules = this->rules[i];
|
||||
for (int j = 0; j < rules.size(); j++) {
|
||||
if (rules[j]->rule_id == rule->rule_id) {
|
||||
parserError << "Rule id: " << std::to_string(rule->rule_id) << " is duplicated" << std::endl;
|
||||
parserError << "Rule id: " << std::to_string(rule->rule_id) \
|
||||
<< " is duplicated" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -126,7 +127,8 @@ int Driver::parse(const std::string &f, const std::string &ref) {
|
||||
scan_end();
|
||||
|
||||
if (audit_log->init() == false) {
|
||||
parserError << "Problems while initializing the audit logs" << std::endl;
|
||||
parserError << "Problems while initializing the audit logs" \
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -224,9 +224,9 @@ bool Multipart::process(std::string data) {
|
||||
|
||||
checkForCrlfLf(block);
|
||||
|
||||
//if (this->crlf) {
|
||||
// block.erase(0, 1);
|
||||
//}
|
||||
// if (this->crlf) {
|
||||
// block.erase(0, 1);
|
||||
// }
|
||||
|
||||
blobs.push_back(block);
|
||||
lastValidBoundary = end;
|
||||
|
@ -50,6 +50,7 @@ class Multipart {
|
||||
m_assay->debug(a, str);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::string m_boundary;
|
||||
std::string m_header;
|
||||
|
33
src/rule.cc
33
src/rule.cc
@ -82,7 +82,7 @@ Rule::Rule(std::string marker)
|
||||
m_unconditional(false),
|
||||
m_secmarker(true),
|
||||
m_marker(marker),
|
||||
m_referenceCount(0) { };
|
||||
m_referenceCount(0) { }
|
||||
|
||||
Rule::Rule(Operator *_op,
|
||||
std::vector<Variable *> *_variables,
|
||||
@ -319,7 +319,8 @@ bool Rule::evaluate(Assay *assay) {
|
||||
// on the target rule.
|
||||
if (none == 0) {
|
||||
for (Action *a : assay->m_rules->defaultActions[this->phase]) {
|
||||
if (a->action_kind == actions::Action::RunTimeBeforeMatchAttemptKind) {
|
||||
if (a->action_kind ==
|
||||
actions::Action::RunTimeBeforeMatchAttemptKind) {
|
||||
value = a->evaluate(value, assay);
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "(SecDefaultAction) T (" + \
|
||||
@ -348,8 +349,8 @@ bool Rule::evaluate(Assay *assay) {
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(9, "Target value: \"" + limitTo(80, toHexIfNeeded(value)) + \
|
||||
"\" (Variable: " + v->m_key + ")");
|
||||
assay->debug(9, "Target value: \"" + limitTo(80,
|
||||
toHexIfNeeded(value)) + "\" (Variable: " + v->m_key + ")");
|
||||
#endif
|
||||
|
||||
ret = this->op->evaluate(assay, value);
|
||||
@ -374,7 +375,8 @@ bool Rule::evaluate(Assay *assay) {
|
||||
this->actions_runtime_pos) {
|
||||
if (a->isDisruptive() == false) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Running (_non_ disruptive) action: " + a->action);
|
||||
assay->debug(4, "Running (_non_ disruptive) action: " \
|
||||
+ a->action);
|
||||
#endif
|
||||
a->evaluate(this, assay);
|
||||
} else {
|
||||
@ -410,14 +412,17 @@ bool Rule::evaluate(Assay *assay) {
|
||||
assay->delete_variable("MATCHED_VARS_NAME");
|
||||
}
|
||||
if (this->chained && chainResult == true || !this->chained) {
|
||||
for (Action *a : assay->m_rules->defaultActions[this->phase]) {
|
||||
if (a->action_kind == actions::Action::RunTimeOnlyIfMatchKind) {
|
||||
for (Action *a :
|
||||
assay->m_rules->defaultActions[this->phase]) {
|
||||
if (a->action_kind
|
||||
== actions::Action::RunTimeOnlyIfMatchKind) {
|
||||
if (a->isDisruptive()) {
|
||||
if (containsDisruptive) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "(SecDefaultAction) " \
|
||||
"_ignoring_ action: " + a->action + \
|
||||
" (rule contains a disruptive action)");
|
||||
"_ignoring_ action: " + a->action \
|
||||
+ " (rule contains " \
|
||||
+ "a disruptive action)");
|
||||
#endif
|
||||
} else {
|
||||
if (assay->m_rules->secRuleEngine
|
||||
@ -432,16 +437,18 @@ bool Rule::evaluate(Assay *assay) {
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "(SecDefaultAction) " \
|
||||
"_Not_ running action: " + a->action + \
|
||||
". Rule _does not_ contains a " \
|
||||
"disruptive action, but SecRuleEngine is not On.");
|
||||
"_Not_ running action: " \
|
||||
+ a->action + ". Rule _does not_" \
|
||||
+ " contains a disruptive action,"\
|
||||
+ " but SecRuleEngine is not On.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "(SecDefaultAction) Running " \
|
||||
"action: " + a->action + "!!" + std::to_string(a->isDisruptive()));
|
||||
"action: " + a->action + "!!" \
|
||||
+ std::to_string(a->isDisruptive()));
|
||||
#endif
|
||||
a->evaluate(this, assay);
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ class Rule {
|
||||
|
||||
std::string m_marker;
|
||||
bool m_secmarker;
|
||||
|
||||
private:
|
||||
bool m_unconditional;
|
||||
int m_referenceCount;
|
||||
|
@ -175,7 +175,8 @@ int Rules::evaluate(int phase, Assay *assay) {
|
||||
if (assay->m_marker.empty()) {
|
||||
rule->evaluate(assay);
|
||||
} else {
|
||||
debug(9, "Skipped rule id '" + std::to_string(rule->rule_id) + "' due to a SecMarker: " + assay->m_marker);
|
||||
debug(9, "Skipped rule id '" + std::to_string(rule->rule_id) \
|
||||
+ "' due to a SecMarker: " + assay->m_marker);
|
||||
m_secmarker_skipped++;
|
||||
debug(9, "Rule: " + rule->m_marker);
|
||||
if (rule->m_secmarker && rule->m_marker == assay->m_marker) {
|
||||
|
@ -50,7 +50,7 @@
|
||||
namespace ModSecurity {
|
||||
|
||||
std::string phase_name(int x) {
|
||||
switch(x) {
|
||||
switch (x) {
|
||||
case ModSecurity::Phases::ConnectionPhase:
|
||||
return "Connection Phase";
|
||||
break;
|
||||
|
@ -40,19 +40,22 @@ Regex::Regex(const std::string& pattern_)
|
||||
pattern.assign(".*");
|
||||
}
|
||||
|
||||
m_pc = pcre_compile(pattern.c_str(), PCRE_DOTALL|PCRE_MULTILINE, &errptr, &erroffset, NULL);
|
||||
m_pc = pcre_compile(pattern.c_str(), PCRE_DOTALL|PCRE_MULTILINE,
|
||||
&errptr, &erroffset, NULL);
|
||||
m_pce = pcre_study(m_pc, PCRE_STUDY_JIT_COMPILE, &errptr);
|
||||
}
|
||||
|
||||
int regex_search(const std::string& s, SMatch *match,
|
||||
const Regex& regex) {
|
||||
int ovector[OVECCOUNT];
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
|
||||
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
}
|
||||
|
||||
int regex_search(const std::string& s, const Regex& regex) {
|
||||
int ovector[OVECCOUNT];
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
|
||||
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@ -13,10 +13,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <pcre.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <pcre.h>
|
||||
|
||||
#ifndef SRC_UTILS_REGEX_H_
|
||||
#define SRC_UTILS_REGEX_H_
|
||||
|
@ -29,7 +29,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Duration::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
std::string res;
|
||||
|
||||
double e = cpu_seconds() - assay->start;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Env::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
std::map<std::string, std::string> envs;
|
||||
for (char **current = environ; *current; current++) {
|
||||
|
@ -28,7 +28,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
HighestSeverity::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
resl->push_back(new ModSecurityStringVar("HIGHEST_SEVERITY",
|
||||
std::to_string(assay->highest_severity)));
|
||||
|
@ -29,7 +29,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
ModsecBuild::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << std::setw(2) << std::setfill('0') << MODSECURITY_MAJOR;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Time::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeDay::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,9 +35,11 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeEpoch::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
resl->push_back(new ModSecurityStringVar("TIME_EPOCH", std::to_string(std::time(nullptr))));
|
||||
resl->push_back(new ModSecurityStringVar("TIME_EPOCH",
|
||||
std::to_string(std::time(nullptr))));
|
||||
|
||||
return resl;
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeHour::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeMin::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeMon::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeSec::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeWDay::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
TimeYear::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Tx::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *resl = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *resl =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
|
||||
resl->push_back(new ModSecurityStringVar("TX:0", "teste"));
|
||||
|
||||
|
@ -30,7 +30,8 @@ namespace Variables {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Variable::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *l = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *l =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
assay->resolve_variable(this->name, l);
|
||||
return l;
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ namespace Variations {
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Count::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *reslIn;
|
||||
std::list<ModSecurityStringVar *> *reslOut = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *reslOut =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
int count = 0;
|
||||
|
||||
reslIn = var->evaluate(assay);
|
||||
|
@ -31,7 +31,8 @@ namespace Variations {
|
||||
|
||||
std::list<ModSecurityStringVar *> *
|
||||
Exclusion::evaluate(Assay *assay) {
|
||||
std::list<ModSecurityStringVar *> *l = new std::list<ModSecurityStringVar *>();
|
||||
std::list<ModSecurityStringVar *> *l =
|
||||
new std::list<ModSecurityStringVar *>();
|
||||
assay->resolve_variable(this->name, l);
|
||||
return l;
|
||||
}
|
||||
|
@ -110,8 +110,10 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
|
||||
|
||||
if (modsec_rules->load(t->rules.c_str(), filename) < 0) {
|
||||
if (t->parser_error.empty() == true) {
|
||||
testRes->reason << KRED << "parse failed." << RESET << std::endl;
|
||||
testRes->reason << modsec_rules->getParserError() << std::endl;
|
||||
testRes->reason << KRED << "parse failed." << RESET \
|
||||
<< std::endl;
|
||||
testRes->reason << modsec_rules->getParserError() \
|
||||
<< std::endl;
|
||||
testRes->passed = false;
|
||||
return;
|
||||
}
|
||||
@ -294,12 +296,13 @@ int main(int argc, char **argv) {
|
||||
int passed = 0;
|
||||
int failed = 0;
|
||||
for (RegressionTestResult *r : res) {
|
||||
if (r->passed) {
|
||||
if (r->passed) {
|
||||
passed++;
|
||||
} else {
|
||||
std::cout << KRED << "Test failed." << RESET << KWHT << " From: " \
|
||||
<< RESET << r->test->filename << "." << std::endl;
|
||||
std::cout << KWHT << "Test name: " << RESET << r->test->name << "." << std::endl;
|
||||
<< RESET << r->test->filename << "." << std::endl;
|
||||
std::cout << KWHT << "Test name: " << RESET << r->test->name \
|
||||
<< "." << std::endl;
|
||||
std::cout << KWHT << "Reason: " << RESET << std::endl;
|
||||
std::cout << r->reason.str() << std::endl;
|
||||
failed++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user