mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Makes RuleWithActions const in run time operations
This commit is contained in:
parent
6a5ff56c8e
commit
bf98e3424f
@ -63,7 +63,7 @@ class Rule {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction) = 0;
|
virtual bool evaluate(Transaction *transaction) const = 0;
|
||||||
|
|
||||||
std::shared_ptr<std::string> getFileName() const {
|
std::shared_ptr<std::string> getFileName() const {
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
@ -76,11 +76,11 @@ class Rule {
|
|||||||
int getPhase() const { return m_phase; }
|
int getPhase() const { return m_phase; }
|
||||||
void setPhase(int phase) { m_phase = phase; }
|
void setPhase(int phase) { m_phase = phase; }
|
||||||
|
|
||||||
virtual std::string getReference() {
|
virtual std::string getReference() const {
|
||||||
return *m_fileName + ":" + std::to_string(m_lineNumber);
|
return *m_fileName + ":" + std::to_string(m_lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dump(std::stringstream &out) {
|
virtual void dump(std::stringstream &out) const {
|
||||||
out << getOriginInTextFormat() << std::endl;
|
out << getOriginInTextFormat() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ class RuleMessage {
|
|||||||
static std::string _details(const RuleMessage *rm);
|
static std::string _details(const RuleMessage *rm);
|
||||||
static std::string _errorLogTail(const RuleMessage *rm);
|
static std::string _errorLogTail(const RuleMessage *rm);
|
||||||
|
|
||||||
RuleWithActions *getRule() const;
|
const RuleWithActions *getRule() const;
|
||||||
void setRule(RuleWithActions *rule);
|
void setRule(const RuleWithActions *rule);
|
||||||
bool isSettle() const;
|
bool isSettle() const;
|
||||||
int getRuleId() const;
|
int getRuleId() const;
|
||||||
int getPhase() const;
|
int getPhase() const;
|
||||||
@ -144,7 +144,7 @@ class RuleMessage {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Transaction *m_transaction;
|
Transaction *m_transaction;
|
||||||
RuleWithActions *m_rule;
|
const RuleWithActions *m_rule;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ class TransactionRuleMessageManagement {
|
|||||||
RuleMessage *messageGetLast();
|
RuleMessage *messageGetLast();
|
||||||
void messageNew();
|
void messageNew();
|
||||||
|
|
||||||
void logMatchLastRuleOnTheChain(RuleWithActions *rule);
|
void logMatchLastRuleOnTheChain(const RuleWithActions *rule);
|
||||||
|
|
||||||
std::list<RuleMessage *> messageGetAll();
|
std::list<RuleMessage *> messageGetAll();
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ class LuaScriptBlob {
|
|||||||
public:
|
public:
|
||||||
LuaScriptBlob() :
|
LuaScriptBlob() :
|
||||||
m_data(NULL),
|
m_data(NULL),
|
||||||
m_len(0) { }
|
m_len(0)
|
||||||
|
{ }
|
||||||
|
|
||||||
~LuaScriptBlob() {
|
~LuaScriptBlob() {
|
||||||
if (m_data) {
|
if (m_data) {
|
||||||
|
@ -25,7 +25,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool BeginsWith::evaluate(Transaction *transaction,
|
bool BeginsWith::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -33,7 +33,7 @@ class BeginsWith : public Operator {
|
|||||||
: Operator("BeginsWith", std::move(param)) { }
|
: Operator("BeginsWith", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Contains::evaluate(Transaction *transaction,
|
bool Contains::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -36,7 +36,7 @@ class Contains : public Operator {
|
|||||||
: Operator("Contains", std::move(param)) { };
|
: Operator("Contains", std::move(param)) { };
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ bool ContainsWord::acceptableChar(const bpstd::string_view &a, size_t pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ContainsWord::evaluate(Transaction *transaction,
|
bool ContainsWord::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &inputView,
|
const bpstd::string_view &inputView,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string paramTarget(m_string->evaluate(transaction));
|
std::string paramTarget(m_string->evaluate(transaction));
|
||||||
|
@ -33,7 +33,7 @@ class ContainsWord : public Operator {
|
|||||||
: Operator("ContainsWord", std::move(param)) { }
|
: Operator("ContainsWord", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool DetectSQLi::evaluate(Transaction *transaction,
|
bool DetectSQLi::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
char fingerprint[8];
|
char fingerprint[8];
|
||||||
|
@ -33,7 +33,7 @@ class DetectSQLi : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool DetectXSS::evaluate(Transaction *transaction,
|
bool DetectXSS::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
int is_xss;
|
int is_xss;
|
||||||
|
@ -32,7 +32,7 @@ class DetectXSS : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool EndsWith::evaluate(Transaction *transaction,
|
bool EndsWith::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
@ -35,7 +35,7 @@ class EndsWith : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool Eq::evaluate(Transaction *transaction,
|
bool Eq::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
@ -33,7 +33,7 @@ class Eq : public Operator {
|
|||||||
: Operator("Eq", std::move(param)) { }
|
: Operator("Eq", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -97,7 +97,7 @@ FuzzyHash::~FuzzyHash() {
|
|||||||
|
|
||||||
|
|
||||||
bool FuzzyHash::evaluate(Transaction *transaction,
|
bool FuzzyHash::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
#ifdef WITH_SSDEEP
|
#ifdef WITH_SSDEEP
|
||||||
|
@ -45,7 +45,7 @@ class FuzzyHash : public Operator {
|
|||||||
~FuzzyHash();
|
~FuzzyHash();
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Ge::evaluate(Transaction *transaction,
|
bool Ge::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -34,7 +34,7 @@ class Ge : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool GeoLookup::evaluate(Transaction *transaction,
|
bool GeoLookup::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
|
@ -31,7 +31,7 @@ class GeoLookup : public Operator {
|
|||||||
: Operator("GeoLookup") { }
|
: Operator("GeoLookup") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool GsbLookup::evaluate(Transaction *transaction,
|
bool GsbLookup::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ class GsbLookup : public Operator {
|
|||||||
: Operator("GsbLookup", std::move(param)) { }
|
: Operator("GsbLookup", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Gt::evaluate(Transaction *transaction,
|
bool Gt::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -35,7 +35,7 @@ class Gt : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -50,7 +50,7 @@ bool InspectFile::init(const std::string ¶m2, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool InspectFile::evaluate(Transaction *transaction,
|
bool InspectFile::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
if (m_isScript) {
|
if (m_isScript) {
|
||||||
|
@ -38,7 +38,7 @@ class InspectFile : public Operator {
|
|||||||
bool init(const std::string &file, std::string *error) override;
|
bool init(const std::string &file, std::string *error) override;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ bool IpMatch::init(const std::string &file, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool IpMatch::evaluate(Transaction *transaction,
|
bool IpMatch::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
return m_tree.contains(str.c_str());
|
return m_tree.contains(str.c_str());
|
||||||
|
@ -35,7 +35,7 @@ class IpMatch : public Operator {
|
|||||||
: Operator(n, std::move(param)) { }
|
: Operator(n, std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Le::evaluate(Transaction *transaction,
|
bool Le::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -35,7 +35,7 @@ class Le : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Lt::evaluate(Transaction *transaction,
|
bool Lt::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -35,7 +35,7 @@ class Lt : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool NoMatch::evaluate(Transaction *transaction,
|
bool NoMatch::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,7 +33,7 @@ class NoMatch : public Operator {
|
|||||||
: Operator("NoMatch") { }
|
: Operator("NoMatch") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool Operator::evaluateInternal(Transaction *transaction,
|
bool Operator::evaluateInternal(Transaction *transaction,
|
||||||
RuleWithActions *rule, const bpstd::string_view &a, RuleMessage *rm) {
|
const RuleWithActions *rule, const bpstd::string_view &a, RuleMessage *rm) {
|
||||||
bool res = evaluate(transaction, rule, a, rm);
|
bool res = evaluate(transaction, rule, a, rm);
|
||||||
|
|
||||||
if (m_negation) {
|
if (m_negation) {
|
||||||
@ -111,7 +111,7 @@ std::string Operator::resolveMatchMessage(Transaction *t,
|
|||||||
|
|
||||||
|
|
||||||
bool Operator::evaluate(Transaction *transaction,
|
bool Operator::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
ms_dbg_a(transaction, 2, "Operator: " + m_op + \
|
ms_dbg_a(transaction, 2, "Operator: " + m_op + \
|
||||||
|
@ -109,12 +109,12 @@ class Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluateInternal(Transaction *transaction,
|
bool evaluateInternal(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view& a,
|
const bpstd::string_view& a,
|
||||||
RuleMessage *ruleMessage);
|
RuleMessage *ruleMessage);
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction,
|
virtual bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage);
|
RuleMessage *ruleMessage);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void Pm::postOrderTraversal(acmp_btree_node_t *node) {
|
|||||||
|
|
||||||
|
|
||||||
bool Pm::evaluate(Transaction *transaction,
|
bool Pm::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
@ -43,7 +43,7 @@ class Pm : public Operator {
|
|||||||
~Pm();
|
~Pm();
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void Rbl::furtherInfo(struct sockaddr_in *sin, const std::string &ipStr,
|
|||||||
|
|
||||||
|
|
||||||
bool Rbl::evaluate(Transaction *transaction,
|
bool Rbl::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
struct addrinfo *info = NULL;
|
struct addrinfo *info = NULL;
|
||||||
|
@ -78,7 +78,7 @@ class Rbl : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool Rsub::evaluate(Transaction *transaction,
|
bool Rsub::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ class Rsub : public Operator {
|
|||||||
: Operator("Rsub", std::move(param)) { }
|
: Operator("Rsub", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ bool Rx::init(const std::string &file, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool Rx::evaluate(Transaction *transaction,
|
bool Rx::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
Regex *re;
|
Regex *re;
|
||||||
|
@ -50,7 +50,7 @@ class Rx : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ bool RxGlobal::init(const std::string &arg, std::string *error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RxGlobal::evaluate(Transaction *transaction, RuleWithActions *rule,
|
bool RxGlobal::evaluate(Transaction *transaction, const RuleWithActions *rule,
|
||||||
const bpstd::string_view& input, RuleMessage *ruleMessage) {
|
const bpstd::string_view& input, RuleMessage *ruleMessage) {
|
||||||
Regex *re;
|
Regex *re;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class RxGlobal : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view& input,
|
const bpstd::string_view& input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool StrEq::evaluate(Transaction *transaction,
|
bool StrEq::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string pt(m_string->evaluate(transaction));
|
std::string pt(m_string->evaluate(transaction));
|
||||||
|
@ -35,7 +35,7 @@ class StrEq : public Operator {
|
|||||||
: Operator("StrEq", std::move(param)) { }
|
: Operator("StrEq", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool StrMatch::evaluate(Transaction *transaction,
|
bool StrMatch::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -35,7 +35,7 @@ class StrMatch : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool UnconditionalMatch::evaluate(Transaction *transaction,
|
bool UnconditionalMatch::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -32,7 +32,7 @@ class UnconditionalMatch : public Operator {
|
|||||||
: Operator("UnconditionalMatch") { }
|
: Operator("UnconditionalMatch") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -112,7 +112,7 @@ bool ValidateByteRange::init(const std::string &file,
|
|||||||
|
|
||||||
|
|
||||||
bool ValidateByteRange::evaluate(Transaction *transaction,
|
bool ValidateByteRange::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
@ -38,7 +38,7 @@ class ValidateByteRange : public Operator {
|
|||||||
~ValidateByteRange() override { }
|
~ValidateByteRange() override { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ bool ValidateDTD::init(const std::string &file, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool ValidateDTD::evaluate(Transaction *transaction,
|
bool ValidateDTD::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
xmlValidCtxtPtr cvp;
|
xmlValidCtxtPtr cvp;
|
||||||
|
@ -47,7 +47,7 @@ class ValidateDTD : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool ValidateHash::evaluate(Transaction *transaction,
|
bool ValidateHash::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +33,7 @@ class ValidateHash : public Operator {
|
|||||||
: Operator("ValidateHash", std::move(param)) { }
|
: Operator("ValidateHash", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ bool ValidateSchema::init(const std::string &file, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool ValidateSchema::evaluate(Transaction *transaction,
|
bool ValidateSchema::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -59,7 +59,7 @@ class ValidateSchema : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ int ValidateUrlEncoding::validate_url_encoding(const char *input,
|
|||||||
|
|
||||||
|
|
||||||
bool ValidateUrlEncoding::evaluate(Transaction *transaction,
|
bool ValidateUrlEncoding::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
@ -32,7 +32,7 @@ class ValidateUrlEncoding : public Operator {
|
|||||||
: Operator("ValidateUrlEncoding") { }
|
: Operator("ValidateUrlEncoding") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ int ValidateUtf8Encoding::detect_utf8_character(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateUtf8Encoding::evaluate(Transaction *transaction,
|
bool ValidateUtf8Encoding::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
unsigned int i, bytes_left;
|
unsigned int i, bytes_left;
|
||||||
|
@ -39,7 +39,7 @@ class ValidateUtf8Encoding : public Operator {
|
|||||||
: Operator("ValidateUtf8Encoding") { }
|
: Operator("ValidateUtf8Encoding") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ bool VerifyCC::init(const std::string ¶m2, std::string *error) {
|
|||||||
|
|
||||||
|
|
||||||
bool VerifyCC::evaluate(Transaction *transaction,
|
bool VerifyCC::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &i,
|
const bpstd::string_view &i,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
@ -38,7 +38,7 @@ class VerifyCC : public Operator {
|
|||||||
bool init(const std::string ¶m, std::string *error) override;
|
bool init(const std::string ¶m, std::string *error) override;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
|||||||
|
|
||||||
|
|
||||||
bool VerifyCPF::evaluate(Transaction *transaction,
|
bool VerifyCPF::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
|
@ -47,7 +47,7 @@ class VerifyCPF : public Operator {
|
|||||||
VerifyCPF(const VerifyCPF &a) = delete;
|
VerifyCPF(const VerifyCPF &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ invalid:
|
|||||||
|
|
||||||
|
|
||||||
bool VerifySSN::evaluate(Transaction *transaction,
|
bool VerifySSN::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
|
@ -47,7 +47,7 @@ class VerifySSN : public Operator {
|
|||||||
VerifySSN(const VerifySSN &a) = delete;
|
VerifySSN(const VerifySSN &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ bool VerifySVNR::verify(const char *svnrnumber, int len) {
|
|||||||
|
|
||||||
|
|
||||||
bool VerifySVNR::evaluate(Transaction *t,
|
bool VerifySVNR::evaluate(Transaction *t,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage* ruleMessage) {
|
RuleMessage* ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
|
@ -33,7 +33,7 @@ class VerifySVNR : public Operator {
|
|||||||
VerifySVNR(const VerifySVNR &a) = delete;
|
VerifySVNR(const VerifySVNR &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool Within::evaluate(Transaction *transaction,
|
bool Within::evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &str,
|
const bpstd::string_view &str,
|
||||||
RuleMessage *ruleMessage) {
|
RuleMessage *ruleMessage) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
@ -35,7 +35,7 @@ class Within : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
RuleWithActions *rule,
|
const RuleWithActions *rule,
|
||||||
const bpstd::string_view &input,
|
const bpstd::string_view &input,
|
||||||
RuleMessage *ruleMessage) override;
|
RuleMessage *ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,7 @@ class RuleMarker : public Rule {
|
|||||||
m_name(std::move(r.m_name))
|
m_name(std::move(r.m_name))
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction) override {
|
virtual bool evaluate(Transaction *transaction) const override {
|
||||||
if (transaction->isInsideAMarker()) {
|
if (transaction->isInsideAMarker()) {
|
||||||
if (*transaction->getCurrentMarker() == *m_name) {
|
if (*transaction->getCurrentMarker() == *m_name) {
|
||||||
transaction->removeMarker();
|
transaction->removeMarker();
|
||||||
@ -71,7 +71,7 @@ class RuleMarker : public Rule {
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dump(std::stringstream &out) override {
|
virtual void dump(std::stringstream &out) const override {
|
||||||
Rule::dump(out);
|
Rule::dump(out);
|
||||||
out << "SecMarker \"" << *getName() << "\"" << std::endl;
|
out << "SecMarker \"" << *getName() << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ std::string RuleMessage::log(const RuleMessage *rm, int props, int code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RuleWithActions *RuleMessage::getRule() const {
|
const RuleWithActions *RuleMessage::getRule() const {
|
||||||
return m_rule;
|
return m_rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RuleMessage::setRule(RuleWithActions *rule) {
|
void RuleMessage::setRule(const RuleWithActions *rule) {
|
||||||
m_rule = rule;
|
m_rule = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ bool RuleScript::init(std::string *err) {
|
|||||||
return m_lua->load(m_name, err);
|
return m_lua->load(m_name, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RuleScript::evaluate(Transaction *trans) {
|
bool RuleScript::evaluate(Transaction *trans) const {
|
||||||
|
|
||||||
ms_dbg_a(trans, 4, " Executing script: " + m_name + ".");
|
ms_dbg_a(trans, 4, " Executing script: " + m_name + ".");
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class RuleScript : public RuleWithActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool init(std::string *err);
|
bool init(std::string *err);
|
||||||
bool evaluate(Transaction *trans) override;
|
bool evaluate(Transaction *trans) const override;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::shared_ptr<engine::Lua> m_lua;
|
std::shared_ptr<engine::Lua> m_lua;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
|
|
||||||
|
|
||||||
bool RuleUnconditional::evaluate(Transaction *trans) {
|
bool RuleUnconditional::evaluate(Transaction *trans) const {
|
||||||
RuleWithActions::evaluate(trans);
|
RuleWithActions::evaluate(trans);
|
||||||
|
|
||||||
ms_dbg_a(trans, 4, "(Rule: " + std::to_string(getId()) \
|
ms_dbg_a(trans, 4, "(Rule: " + std::to_string(getId()) \
|
||||||
|
@ -50,7 +50,7 @@ class RuleUnconditional : public RuleWithActions {
|
|||||||
: RuleWithActions(r)
|
: RuleWithActions(r)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction) override;
|
virtual bool evaluate(Transaction *transaction) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -190,7 +190,7 @@ void RuleWithActions::addAction(actions::Action *a) {
|
|||||||
RuleWithActions::~RuleWithActions() { }
|
RuleWithActions::~RuleWithActions() { }
|
||||||
|
|
||||||
|
|
||||||
bool RuleWithActions::evaluate(Transaction *transaction) {
|
bool RuleWithActions::evaluate(Transaction *transaction) const {
|
||||||
/* Matched vars needs to be clear at every new rule execution */
|
/* Matched vars needs to be clear at every new rule execution */
|
||||||
transaction->m_matched.clear();
|
transaction->m_matched.clear();
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ bool RuleWithActions::evaluate(Transaction *transaction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *trans) {
|
void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *trans) const {
|
||||||
|
|
||||||
for (actions::SetVar *a : getSetVarsActionsPtr()) {
|
for (actions::SetVar *a : getSetVarsActionsPtr()) {
|
||||||
ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \
|
ms_dbg_a(trans, 4, "Running [independent] (non-disruptive) " \
|
||||||
@ -209,7 +209,7 @@ void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) {
|
void RuleWithActions::executeActionsAfterFullMatch(Transaction *trans) const {
|
||||||
bool disruptiveAlreadyExecuted = false;
|
bool disruptiveAlreadyExecuted = false;
|
||||||
|
|
||||||
for (actions::Tag *a : getTagsActionPtr()) {
|
for (actions::Tag *a : getTagsActionPtr()) {
|
||||||
@ -276,7 +276,7 @@ void RuleWithActions::executeAction(Transaction *trans,
|
|||||||
|
|
||||||
|
|
||||||
void RuleWithActions::executeAction(Transaction *trans,
|
void RuleWithActions::executeAction(Transaction *trans,
|
||||||
ActionDisruptive *a, bool defaultContext) {
|
ActionDisruptive *a, bool defaultContext) const {
|
||||||
if (defaultContext && !hasBlockAction()) {
|
if (defaultContext && !hasBlockAction()) {
|
||||||
ms_dbg_a(trans, 4, "Ignoring action: " + *a->getName() + \
|
ms_dbg_a(trans, 4, "Ignoring action: " + *a->getName() + \
|
||||||
" (rule does not cotains block)");
|
" (rule does not cotains block)");
|
||||||
@ -299,7 +299,7 @@ void RuleWithActions::executeAction(Transaction *trans,
|
|||||||
void RuleWithActions::executeTransformations(
|
void RuleWithActions::executeTransformations(
|
||||||
Transaction *trans,
|
Transaction *trans,
|
||||||
const std::string &in,
|
const std::string &in,
|
||||||
TransformationsResults &results) {
|
TransformationsResults &results) const {
|
||||||
int none = 0;
|
int none = 0;
|
||||||
|
|
||||||
ModSecString ssin;
|
ModSecString ssin;
|
||||||
@ -401,7 +401,7 @@ bool RuleWithActions::containsTag(const std::string& name, Transaction *t) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RuleWithActions::containsMsg(const std::string& name, Transaction *t) {
|
bool RuleWithActions::containsMsg(const std::string& name, Transaction *t) const {
|
||||||
return m_msg && m_msg->getEvaluatedRunTimeString(t) == name;
|
return m_msg && m_msg->getEvaluatedRunTimeString(t) == name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,22 +222,22 @@ class RuleWithActions : public Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction) override;
|
virtual bool evaluate(Transaction *transaction) const override;
|
||||||
|
|
||||||
|
|
||||||
void executeActionsIndependentOfChainedRuleResult(
|
void executeActionsIndependentOfChainedRuleResult(
|
||||||
Transaction *trasn);
|
Transaction *trasn) const;
|
||||||
|
|
||||||
void executeActionsAfterFullMatch(
|
void executeActionsAfterFullMatch(
|
||||||
Transaction *trasn);
|
Transaction *trasn) const;
|
||||||
|
|
||||||
void executeAction(Transaction *trans,
|
static void executeAction(Transaction *trans,
|
||||||
ActionWithExecution *a,
|
ActionWithExecution *a,
|
||||||
bool context);
|
bool context);
|
||||||
|
|
||||||
void executeAction(Transaction *trans,
|
void executeAction(Transaction *trans,
|
||||||
ActionDisruptive *a,
|
ActionDisruptive *a,
|
||||||
bool context);
|
bool context) const;
|
||||||
|
|
||||||
static void executeTransformation(
|
static void executeTransformation(
|
||||||
Transaction *transaction,
|
Transaction *transaction,
|
||||||
@ -253,7 +253,7 @@ class RuleWithActions : public Rule {
|
|||||||
void executeTransformations(
|
void executeTransformations(
|
||||||
Transaction *transaction,
|
Transaction *transaction,
|
||||||
const std::string &value,
|
const std::string &value,
|
||||||
TransformationsResults &results);
|
TransformationsResults &results) const;
|
||||||
|
|
||||||
void addAction(actions::Action *a);
|
void addAction(actions::Action *a);
|
||||||
void addTransformation(std::shared_ptr<actions::transformations::Transformation> t) {
|
void addTransformation(std::shared_ptr<actions::transformations::Transformation> t) {
|
||||||
@ -268,7 +268,7 @@ class RuleWithActions : public Rule {
|
|||||||
std::vector<actions::Action *> getActionsByName(const std::string& name,
|
std::vector<actions::Action *> getActionsByName(const std::string& name,
|
||||||
Transaction *t);
|
Transaction *t);
|
||||||
bool containsTag(const std::string& name, Transaction *t) const;
|
bool containsTag(const std::string& name, Transaction *t) const;
|
||||||
bool containsMsg(const std::string& name, Transaction *t);
|
bool containsMsg(const std::string& name, Transaction *t) const;
|
||||||
|
|
||||||
|
|
||||||
void clearDefaultActions() {
|
void clearDefaultActions() {
|
||||||
@ -525,7 +525,7 @@ class RuleWithActions : public Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void dump(std::stringstream &out) override {
|
virtual void dump(std::stringstream &out) const override {
|
||||||
out << "RuleWithActions" << std::endl;
|
out << "RuleWithActions" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void RuleWithOperator::updateMatchedVars(Transaction *trans,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RuleWithOperator::cleanMatchedVars(Transaction *trans) {
|
inline void RuleWithOperator::cleanMatchedVars(Transaction *trans) {
|
||||||
ms_dbg_a(trans, 9, "Matched vars cleaned.");
|
ms_dbg_a(trans, 9, "Matched vars cleaned.");
|
||||||
trans->m_variableMatchedVar.unset();
|
trans->m_variableMatchedVar.unset();
|
||||||
trans->m_variableMatchedVars.unset();
|
trans->m_variableMatchedVars.unset();
|
||||||
@ -101,7 +101,7 @@ void RuleWithOperator::cleanMatchedVars(Transaction *trans) {
|
|||||||
|
|
||||||
bool RuleWithOperator::executeOperatorAt(Transaction *trans,
|
bool RuleWithOperator::executeOperatorAt(Transaction *trans,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
const bpstd::string_view &value) {
|
const bpstd::string_view &value) const {
|
||||||
#if MSC_EXEC_CLOCK_ENABLED
|
#if MSC_EXEC_CLOCK_ENABLED
|
||||||
clock_t begin = clock();
|
clock_t begin = clock();
|
||||||
clock_t end;
|
clock_t end;
|
||||||
@ -128,7 +128,7 @@ bool RuleWithOperator::executeOperatorAt(Transaction *trans,
|
|||||||
|
|
||||||
|
|
||||||
void RuleWithOperator::getVariablesExceptions(Transaction *t,
|
void RuleWithOperator::getVariablesExceptions(Transaction *t,
|
||||||
variables::Variables *exclusion, variables::Variables *addition) {
|
variables::Variables *exclusion, variables::Variables *addition) const {
|
||||||
for (auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) {
|
for (auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) {
|
||||||
if (containsTag(*a.first.get(), t) == false) {
|
if (containsTag(*a.first.get(), t) == false) {
|
||||||
continue;
|
continue;
|
||||||
@ -174,7 +174,7 @@ void RuleWithOperator::getVariablesExceptions(Transaction *t,
|
|||||||
|
|
||||||
|
|
||||||
inline void RuleWithOperator::getFinalVars(variables::Variables *vars,
|
inline void RuleWithOperator::getFinalVars(variables::Variables *vars,
|
||||||
variables::Variables *exclusion, Transaction *trans) {
|
variables::Variables *exclusion, Transaction *trans) const {
|
||||||
variables::Variables addition;
|
variables::Variables addition;
|
||||||
getVariablesExceptions(trans, exclusion, &addition);
|
getVariablesExceptions(trans, exclusion, &addition);
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ inline void RuleWithOperator::getFinalVars(variables::Variables *vars,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RuleWithOperator::evaluate(Transaction *trans) {
|
bool RuleWithOperator::evaluate(Transaction *trans) const {
|
||||||
bool globalRet = false;
|
bool globalRet = false;
|
||||||
variables::Variables *variables = m_variables.get();
|
variables::Variables *variables = m_variables.get();
|
||||||
bool recursiveGlobalRet;
|
bool recursiveGlobalRet;
|
||||||
|
@ -70,16 +70,16 @@ class RuleWithOperator : public RuleWithActions {
|
|||||||
|
|
||||||
virtual ~RuleWithOperator();
|
virtual ~RuleWithOperator();
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction) override;
|
bool evaluate(Transaction *transaction) const override;
|
||||||
|
|
||||||
void getVariablesExceptions(Transaction *t,
|
void getVariablesExceptions(Transaction *t,
|
||||||
variables::Variables *exclusion, variables::Variables *addition);
|
variables::Variables *exclusion, variables::Variables *addition) const;
|
||||||
inline void getFinalVars(variables::Variables *vars,
|
inline void getFinalVars(variables::Variables *vars,
|
||||||
variables::Variables *eclusion, Transaction *trans);
|
variables::Variables *eclusion, Transaction *trans) const;
|
||||||
|
|
||||||
bool executeOperatorAt(Transaction *transaction,
|
bool executeOperatorAt(Transaction *transaction,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
const bpstd::string_view &value);
|
const bpstd::string_view &value) const;
|
||||||
|
|
||||||
static void updateMatchedVars(Transaction *transaction,
|
static void updateMatchedVars(Transaction *transaction,
|
||||||
const std::string &key,
|
const std::string &key,
|
||||||
@ -87,14 +87,13 @@ class RuleWithOperator : public RuleWithActions {
|
|||||||
|
|
||||||
static void cleanMatchedVars(Transaction *trasn);
|
static void cleanMatchedVars(Transaction *trasn);
|
||||||
|
|
||||||
|
|
||||||
std::string getOperatorName() const;
|
std::string getOperatorName() const;
|
||||||
|
|
||||||
virtual std::string getReference() override {
|
virtual std::string getReference() const override {
|
||||||
return std::to_string(getId());
|
return std::to_string(getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dump(std::stringstream &out) override {
|
virtual void dump(std::stringstream &out) const override {
|
||||||
Rule::dump(out);
|
Rule::dump(out);
|
||||||
out << "# RuleWithOperator" << std::endl;
|
out << "# RuleWithOperator" << std::endl;
|
||||||
out << "SecRule ";
|
out << "SecRule ";
|
||||||
|
@ -67,7 +67,7 @@ RuleMessage *TransactionRuleMessageManagement::messageGetLast() {
|
|||||||
return m_rulesMessages.back();
|
return m_rulesMessages.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionRuleMessageManagement::logMatchLastRuleOnTheChain(RuleWithActions *rule) {
|
void TransactionRuleMessageManagement::logMatchLastRuleOnTheChain(const RuleWithActions *rule) {
|
||||||
RuleMessage *rm = m_rulesMessages.back();
|
RuleMessage *rm = m_rulesMessages.back();
|
||||||
|
|
||||||
rm->setRule(rule);
|
rm->setRule(rule);
|
||||||
|
@ -46,8 +46,8 @@ functionStatic:headers/modsecurity/transaction.h:437
|
|||||||
duplicateBranch:src/audit_log/audit_log.cc:223
|
duplicateBranch:src/audit_log/audit_log.cc:223
|
||||||
unreadVariable:src/request_body_processor/multipart.cc:435
|
unreadVariable:src/request_body_processor/multipart.cc:435
|
||||||
stlcstrParam:src/audit_log/writer/parallel.cc:145
|
stlcstrParam:src/audit_log/writer/parallel.cc:145
|
||||||
functionStatic:src/engine/lua.h:78
|
|
||||||
functionStatic:src/engine/lua.h:79
|
functionStatic:src/engine/lua.h:79
|
||||||
|
functionStatic:src/engine/lua.h:80
|
||||||
functionConst:src/utils/geo_lookup.h:49
|
functionConst:src/utils/geo_lookup.h:49
|
||||||
useInitializationList:src/operators/rbl.h:69
|
useInitializationList:src/operators/rbl.h:69
|
||||||
constStatement:test/common/modsecurity_test.cc:82
|
constStatement:test/common/modsecurity_test.cc:82
|
||||||
|
Loading…
x
Reference in New Issue
Block a user