mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Refactoring: renames Rule to RuleWithOperator
This commit is contained in:
parent
8eb7b8fe6c
commit
59d4268882
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
class RuleWithActions;
|
class RuleWithActions;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
@ -229,7 +229,7 @@ namespace modsecurity {
|
|||||||
namespace actions {
|
namespace actions {
|
||||||
class Action;
|
class Action;
|
||||||
}
|
}
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -216,16 +216,16 @@ class RuleWithActions : public RuleBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Rule : public RuleWithActions {
|
class RuleWithOperator : public RuleWithActions {
|
||||||
public:
|
public:
|
||||||
Rule(operators::Operator *op,
|
RuleWithOperator(operators::Operator *op,
|
||||||
variables::Variables *variables,
|
variables::Variables *variables,
|
||||||
std::vector<actions::Action *> *actions,
|
std::vector<actions::Action *> *actions,
|
||||||
Transformations *transformations,
|
Transformations *transformations,
|
||||||
std::unique_ptr<std::string> fileName,
|
std::unique_ptr<std::string> fileName,
|
||||||
int lineNumber);
|
int lineNumber);
|
||||||
|
|
||||||
virtual ~Rule();
|
virtual ~RuleWithOperator();
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction,
|
bool evaluate(Transaction *transaction,
|
||||||
std::shared_ptr<RuleMessage> rm) override;
|
std::shared_ptr<RuleMessage> rm) override;
|
||||||
@ -250,8 +250,8 @@ class Rule : public RuleWithActions {
|
|||||||
return std::to_string(m_ruleId);
|
return std::to_string(m_ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Rule> m_chainedRuleChild;
|
std::unique_ptr<RuleWithOperator> m_chainedRuleChild;
|
||||||
Rule *m_chainedRuleParent;
|
RuleWithOperator *m_chainedRuleParent;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
modsecurity::variables::Variables *m_variables;
|
modsecurity::variables::Variables *m_variables;
|
||||||
|
@ -41,7 +41,7 @@ class RuleMessage {
|
|||||||
ClientLogMessageInfo = 4
|
ClientLogMessageInfo = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit RuleMessage(Rule *rule, Transaction *trans) :
|
explicit RuleMessage(RuleWithOperator *rule, Transaction *trans) :
|
||||||
m_accuracy(rule->m_accuracy),
|
m_accuracy(rule->m_accuracy),
|
||||||
m_clientIpAddress(trans->m_clientIpAddress),
|
m_clientIpAddress(trans->m_clientIpAddress),
|
||||||
m_data(""),
|
m_data(""),
|
||||||
@ -103,7 +103,7 @@ class RuleMessage {
|
|||||||
int m_phase;
|
int m_phase;
|
||||||
std::string m_reference;
|
std::string m_reference;
|
||||||
std::string m_rev;
|
std::string m_rev;
|
||||||
Rule *m_rule;
|
RuleWithOperator *m_rule;
|
||||||
std::shared_ptr<std::string> m_ruleFile;
|
std::shared_ptr<std::string> m_ruleFile;
|
||||||
int m_ruleId;
|
int m_ruleId;
|
||||||
int m_ruleLine;
|
int m_ruleLine;
|
||||||
|
@ -48,7 +48,7 @@ class Rules {
|
|||||||
int append(Rules *from, const std::vector<int64_t> &ids, std::ostringstream *err) {
|
int append(Rules *from, const std::vector<int64_t> &ids, std::ostringstream *err) {
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (; j < from->size(); j++) {
|
for (; j < from->size(); j++) {
|
||||||
Rule *rule = dynamic_cast<Rule *>(from->at(j).get());
|
RuleWithOperator *rule = dynamic_cast<RuleWithOperator *>(from->at(j).get());
|
||||||
if (rule && std::binary_search(ids.begin(), ids.end(), rule->m_ruleId)) {
|
if (rule && std::binary_search(ids.begin(), ids.end(), rule->m_ruleId)) {
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
*err << "Rule id: " << std::to_string(rule->m_ruleId) \
|
*err << "Rule id: " << std::to_string(rule->m_ruleId) \
|
||||||
@ -66,8 +66,8 @@ class Rules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool insert(std::shared_ptr<RuleBase> rule, const std::vector<int64_t> *ids, std::ostringstream *err) {
|
bool insert(std::shared_ptr<RuleBase> rule, const std::vector<int64_t> *ids, std::ostringstream *err) {
|
||||||
Rule *r = dynamic_cast<Rule *>(rule.get());
|
RuleWithOperator *r = dynamic_cast<RuleWithOperator *>(rule.get());
|
||||||
if (ids != nullptr && std::binary_search(ids->begin(), ids->end(), r->m_ruleId)) {
|
if (r && ids != nullptr && std::binary_search(ids->begin(), ids->end(), r->m_ruleId)) {
|
||||||
if (err != nullptr) {
|
if (err != nullptr) {
|
||||||
*err << "Rule id: " << std::to_string(r->m_ruleId) \
|
*err << "Rule id: " << std::to_string(r->m_ruleId) \
|
||||||
<< " is duplicated" << std::endl;
|
<< " is duplicated" << std::endl;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
namespace Parser {
|
namespace Parser {
|
||||||
class Driver;
|
class Driver;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,10 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
namespace Parser {
|
||||||
|
class Driver;
|
||||||
|
}
|
||||||
|
|
||||||
/** @ingroup ModSecurity_CPP_API */
|
/** @ingroup ModSecurity_CPP_API */
|
||||||
class RulesSetPhases {
|
class RulesSetPhases {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Transaction;
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Transaction;
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
namespace disruptive {
|
namespace disruptive {
|
||||||
|
@ -25,7 +25,7 @@ class Transaction;
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Transaction;
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class Transaction;
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ bool SetVar::evaluate(RuleWithActions *rule, Transaction *t) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
std::vector<const VariableValue *> l;
|
std::vector<const VariableValue *> l;
|
||||||
Rule *rr = dynamic_cast<Rule *>(rule);
|
RuleWithOperator *rr = dynamic_cast<RuleWithOperator *>(rule);
|
||||||
m_variable->evaluate(t, rr, &l);
|
m_variable->evaluate(t, rr, &l);
|
||||||
if (l.size() == 0) {
|
if (l.size() == 0) {
|
||||||
value = 0;
|
value = 0;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
class Transaction;
|
class Transaction;
|
||||||
class Rule;
|
class RuleWithOperator;
|
||||||
|
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
bool BeginsWith::evaluate(Transaction *transaction, Rule *rule,
|
bool BeginsWith::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BeginsWith : public Operator {
|
|||||||
explicit BeginsWith(std::unique_ptr<RunTimeString> param)
|
explicit BeginsWith(std::unique_ptr<RunTimeString> param)
|
||||||
: Operator("BeginsWith", std::move(param)) { }
|
: Operator("BeginsWith", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule, const std::string &str,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule, const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
bool Contains::evaluate(Transaction *transaction, Rule *rule,
|
bool Contains::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
size_t offset = input.find(p);
|
size_t offset = input.find(p);
|
||||||
|
@ -34,7 +34,7 @@ class Contains : public Operator {
|
|||||||
/** @ingroup ModSecurity_Operator */
|
/** @ingroup ModSecurity_Operator */
|
||||||
explicit Contains(std::unique_ptr<RunTimeString> param)
|
explicit Contains(std::unique_ptr<RunTimeString> param)
|
||||||
: Operator("Contains", std::move(param)) { }
|
: Operator("Contains", std::move(param)) { }
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str,
|
const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ bool ContainsWord::acceptableChar(const std::string& a, size_t pos) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContainsWord::evaluate(Transaction *transaction, Rule *rule,
|
bool ContainsWord::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::string paramTarget(m_string->evaluate(transaction));
|
std::string paramTarget(m_string->evaluate(transaction));
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class ContainsWord : public Operator {
|
|||||||
explicit ContainsWord(std::unique_ptr<RunTimeString> param)
|
explicit ContainsWord(std::unique_ptr<RunTimeString> param)
|
||||||
: Operator("ContainsWord", std::move(param)) { }
|
: Operator("ContainsWord", std::move(param)) { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str,
|
const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
bool DetectSQLi::evaluate(Transaction *t, Rule *rule,
|
bool DetectSQLi::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
char fingerprint[8];
|
char fingerprint[8];
|
||||||
int issqli;
|
int issqli;
|
||||||
|
@ -32,7 +32,7 @@ class DetectSQLi : public Operator {
|
|||||||
m_match_message.assign("detected SQLi using libinjection.");
|
m_match_message.assign("detected SQLi using libinjection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *t, Rule *rule,
|
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
bool DetectXSS::evaluate(Transaction *t, Rule *rule,
|
bool DetectXSS::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
int is_xss;
|
int is_xss;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class DetectXSS : public Operator {
|
|||||||
m_match_message.assign("detected XSS using libinjection.");
|
m_match_message.assign("detected XSS using libinjection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *t, Rule *rule,
|
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
bool EndsWith::evaluate(Transaction *transaction, Rule *rule,
|
bool EndsWith::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
std::string p(m_string->evaluate(transaction));
|
std::string p(m_string->evaluate(transaction));
|
||||||
|
@ -33,7 +33,7 @@ class EndsWith : public Operator {
|
|||||||
: Operator("EndsWith", std::move(param)) {
|
: Operator("EndsWith", std::move(param)) {
|
||||||
m_couldContainsMacro = true;
|
m_couldContainsMacro = true;
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str,
|
const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ namespace operators {
|
|||||||
|
|
||||||
|
|
||||||
bool Operator::evaluateInternal(Transaction *transaction,
|
bool Operator::evaluateInternal(Transaction *transaction,
|
||||||
Rule *rule, const std::string& a, std::shared_ptr<RuleMessage> rm) {
|
RuleWithOperator *rule, const std::string& a, std::shared_ptr<RuleMessage> rm) {
|
||||||
bool res = evaluate(transaction, rule, a, rm);
|
bool res = evaluate(transaction, rule, a, rm);
|
||||||
|
|
||||||
if (m_negation) {
|
if (m_negation) {
|
||||||
@ -81,7 +81,7 @@ bool Operator::evaluateInternal(Transaction *transaction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Operator::evaluateInternal(Transaction *transaction,
|
bool Operator::evaluateInternal(Transaction *transaction,
|
||||||
Rule *rule, const std::string& a) {
|
RuleWithOperator *rule, const std::string& a) {
|
||||||
bool res = evaluate(transaction, rule, a);
|
bool res = evaluate(transaction, rule, a);
|
||||||
|
|
||||||
if (m_negation) {
|
if (m_negation) {
|
||||||
|
@ -111,18 +111,18 @@ class Operator {
|
|||||||
std::string key, std::string value);
|
std::string key, std::string value);
|
||||||
|
|
||||||
bool evaluateInternal(Transaction *t, const std::string& a);
|
bool evaluateInternal(Transaction *t, const std::string& a);
|
||||||
bool evaluateInternal(Transaction *t, Rule *rule,
|
bool evaluateInternal(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& a);
|
const std::string& a);
|
||||||
bool evaluateInternal(Transaction *t, Rule *rule,
|
bool evaluateInternal(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& a, std::shared_ptr<RuleMessage> ruleMessage);
|
const std::string& a, std::shared_ptr<RuleMessage> ruleMessage);
|
||||||
|
|
||||||
|
|
||||||
virtual bool evaluate(Transaction *transaction, const std::string &str);
|
virtual bool evaluate(Transaction *transaction, const std::string &str);
|
||||||
virtual bool evaluate(Transaction *transaction, Rule *rule,
|
virtual bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str) {
|
const std::string &str) {
|
||||||
return evaluate(transaction, str);
|
return evaluate(transaction, str);
|
||||||
}
|
}
|
||||||
virtual bool evaluate(Transaction *transaction, Rule *rule,
|
virtual bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
return evaluate(transaction, str);
|
return evaluate(transaction, str);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void Pm::postOrderTraversal(acmp_btree_node_t *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Pm::evaluate(Transaction *transaction, Rule *rule,
|
bool Pm::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
int rc;
|
int rc;
|
||||||
ACMPT pt;
|
ACMPT pt;
|
||||||
|
@ -41,7 +41,7 @@ class Pm : public Operator {
|
|||||||
m_p = acmp_create(0);
|
m_p = acmp_create(0);
|
||||||
}
|
}
|
||||||
~Pm();
|
~Pm();
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str,
|
const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void Rbl::furtherInfo(struct sockaddr_in *sin, const std::string &ipStr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Rbl::evaluate(Transaction *t, Rule *rule,
|
bool Rbl::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& ipStr,
|
const std::string& ipStr,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) {
|
std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
struct addrinfo *info = NULL;
|
struct addrinfo *info = NULL;
|
||||||
|
@ -76,7 +76,7 @@ class Rbl : public Operator {
|
|||||||
m_provider = RblProvider::httpbl;
|
m_provider = RblProvider::httpbl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ bool Rx::init(const std::string &arg, std::string *error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Rx::evaluate(Transaction *transaction, Rule *rule,
|
bool Rx::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
Regex *re;
|
Regex *re;
|
||||||
|
@ -49,7 +49,7 @@ class Rx : public Operator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input, NULL);
|
return evaluate(transaction, NULL, input, NULL);
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ class Rx : public Operator {
|
|||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input);
|
return evaluate(transaction, NULL, input);
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ bool ValidateByteRange::init(const std::string &file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ValidateByteRange::evaluate(Transaction *transaction, Rule *rule,
|
bool ValidateByteRange::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ValidateByteRange : public Operator {
|
|||||||
}
|
}
|
||||||
~ValidateByteRange() override { }
|
~ValidateByteRange() override { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input,
|
const std::string &input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
bool getRange(const std::string &rangeRepresentation, std::string *error);
|
bool getRange(const std::string &rangeRepresentation, std::string *error);
|
||||||
|
@ -68,7 +68,7 @@ int ValidateUrlEncoding::validate_url_encoding(const char *input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ValidateUrlEncoding::evaluate(Transaction *transaction, Rule *rule,
|
bool ValidateUrlEncoding::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
@ -31,7 +31,7 @@ class ValidateUrlEncoding : public Operator {
|
|||||||
ValidateUrlEncoding()
|
ValidateUrlEncoding()
|
||||||
: Operator("ValidateUrlEncoding") { }
|
: Operator("ValidateUrlEncoding") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input,
|
const std::string &input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ int ValidateUtf8Encoding::detect_utf8_character(
|
|||||||
return unicode_len;
|
return unicode_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateUtf8Encoding::evaluate(Transaction *transaction, Rule *rule,
|
bool ValidateUtf8Encoding::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
unsigned int i, bytes_left;
|
unsigned int i, bytes_left;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class ValidateUtf8Encoding : public Operator {
|
|||||||
ValidateUtf8Encoding()
|
ValidateUtf8Encoding()
|
||||||
: Operator("ValidateUtf8Encoding") { }
|
: Operator("ValidateUtf8Encoding") { }
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str,
|
const std::string &str,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ bool VerifyCC::init(const std::string ¶m2, std::string *error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VerifyCC::evaluate(Transaction *t, Rule *rule,
|
bool VerifyCC::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& i, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& i, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int target_length = i.length();
|
int target_length = i.length();
|
||||||
|
@ -35,7 +35,7 @@ class VerifyCC : public Operator {
|
|||||||
m_pce(NULL) { }
|
m_pce(NULL) { }
|
||||||
~VerifyCC();
|
~VerifyCC();
|
||||||
|
|
||||||
bool evaluate(Transaction *t, Rule *rule,
|
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
bool init(const std::string ¶m, std::string *error) override;
|
bool init(const std::string ¶m, std::string *error) override;
|
||||||
|
@ -108,7 +108,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
|
bool VerifyCPF::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
bool is_cpf = false;
|
bool is_cpf = false;
|
||||||
|
@ -46,7 +46,7 @@ class VerifyCPF : public Operator {
|
|||||||
bool operator=(const VerifyCPF &a) = delete;
|
bool operator=(const VerifyCPF &a) = delete;
|
||||||
VerifyCPF(const VerifyCPF &a) = delete;
|
VerifyCPF(const VerifyCPF &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input, NULL);
|
return evaluate(transaction, NULL, input, NULL);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ class VerifyCPF : public Operator {
|
|||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input);
|
return evaluate(transaction, NULL, input);
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ invalid:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VerifySSN::evaluate(Transaction *t, Rule *rule,
|
bool VerifySSN::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
bool is_ssn = false;
|
bool is_ssn = false;
|
||||||
|
@ -46,7 +46,7 @@ class VerifySSN : public Operator {
|
|||||||
bool operator=(const VerifySSN &a) = delete;
|
bool operator=(const VerifySSN &a) = delete;
|
||||||
VerifySSN(const VerifySSN &a) = delete;
|
VerifySSN(const VerifySSN &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input, NULL);
|
return evaluate(transaction, NULL, input, NULL);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ class VerifySSN : public Operator {
|
|||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input);
|
return evaluate(transaction, NULL, input);
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ bool VerifySVNR::verify(const char *svnrnumber, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool VerifySVNR::evaluate(Transaction *t, Rule *rule,
|
bool VerifySVNR::evaluate(Transaction *t, RuleWithOperator *rule,
|
||||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
std::list<SMatch> matches;
|
std::list<SMatch> matches;
|
||||||
bool is_svnr = false;
|
bool is_svnr = false;
|
||||||
|
@ -32,7 +32,7 @@ class VerifySVNR : public Operator {
|
|||||||
bool operator=(const VerifySVNR &a) = delete;
|
bool operator=(const VerifySVNR &a) = delete;
|
||||||
VerifySVNR(const VerifySVNR &a) = delete;
|
VerifySVNR(const VerifySVNR &a) = delete;
|
||||||
|
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input, NULL);
|
return evaluate(transaction, NULL, input, NULL);
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ class VerifySVNR : public Operator {
|
|||||||
const std::string &input) override {
|
const std::string &input) override {
|
||||||
return evaluate(transaction, NULL, input);
|
return evaluate(transaction, NULL, input);
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string& input,
|
const std::string& input,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
|||||||
namespace operators {
|
namespace operators {
|
||||||
|
|
||||||
|
|
||||||
bool Within::evaluate(Transaction *transaction, Rule *rule,
|
bool Within::evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
@ -33,7 +33,7 @@ class Within : public Operator {
|
|||||||
: Operator("Within", std::move(param)) {
|
: Operator("Within", std::move(param)) {
|
||||||
m_couldContainsMacro = true;
|
m_couldContainsMacro = true;
|
||||||
}
|
}
|
||||||
bool evaluate(Transaction *transaction, Rule *rule,
|
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||||
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) override;
|
const std::string &str, std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "modsecurity/audit_log.h"
|
#include "modsecurity/audit_log.h"
|
||||||
|
|
||||||
using modsecurity::audit_log::AuditLog;
|
using modsecurity::audit_log::AuditLog;
|
||||||
using modsecurity::Rule;
|
using modsecurity::RuleWithOperator;
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace Parser {
|
namespace Parser {
|
||||||
@ -53,7 +53,7 @@ int Driver::addSecMarker(std::string marker, std::unique_ptr<std::string> fileNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Driver::addSecAction(std::unique_ptr<Rule> rule) {
|
int Driver::addSecAction(std::unique_ptr<RuleWithOperator> rule) {
|
||||||
if (rule->getPhase() >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
if (rule->getPhase() >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||||
m_parserError << "Unknown phase: " << std::to_string(rule->getPhase());
|
m_parserError << "Unknown phase: " << std::to_string(rule->getPhase());
|
||||||
m_parserError << std::endl;
|
m_parserError << std::endl;
|
||||||
@ -72,7 +72,7 @@ int Driver::addSecRuleScript(std::unique_ptr<RuleScript> rule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Driver::addSecRule(std::unique_ptr<Rule> r) {
|
int Driver::addSecRule(std::unique_ptr<RuleWithOperator> r) {
|
||||||
if (r->getPhase() >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
if (r->getPhase() >= modsecurity::Phases::NUMBER_OF_PHASES) {
|
||||||
m_parserError << "Unknown phase: " << std::to_string(r->getPhase());
|
m_parserError << "Unknown phase: " << std::to_string(r->getPhase());
|
||||||
m_parserError << std::endl;
|
m_parserError << std::endl;
|
||||||
@ -93,7 +93,7 @@ int Driver::addSecRule(std::unique_ptr<Rule> r) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Rule> rule(std::move(r));
|
std::shared_ptr<RuleWithOperator> rule(std::move(r));
|
||||||
/*
|
/*
|
||||||
* Checking if the rule has an ID and also checking if this ID is not used
|
* Checking if the rule has an ID and also checking if this ID is not used
|
||||||
* by other rule
|
* by other rule
|
||||||
@ -108,7 +108,7 @@ int Driver::addSecRule(std::unique_ptr<Rule> r) {
|
|||||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||||
Rules *rules = m_rulesSetPhases[i];
|
Rules *rules = m_rulesSetPhases[i];
|
||||||
for (int j = 0; j < rules->size(); j++) {
|
for (int j = 0; j < rules->size(); j++) {
|
||||||
Rule *lr = dynamic_cast<Rule *>(rules->at(j).get());
|
RuleWithOperator *lr = dynamic_cast<RuleWithOperator *>(rules->at(j).get());
|
||||||
if (lr && lr->m_ruleId == rule->m_ruleId) {
|
if (lr && lr->m_ruleId == rule->m_ruleId) {
|
||||||
m_parserError << "Rule id: " << std::to_string(rule->m_ruleId) \
|
m_parserError << "Rule id: " << std::to_string(rule->m_ruleId) \
|
||||||
<< " is duplicated" << std::endl;
|
<< " is duplicated" << std::endl;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "src/parser/seclang-parser.hh"
|
#include "src/parser/seclang-parser.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using modsecurity::Rule;
|
using modsecurity::RuleWithOperator;
|
||||||
using modsecurity::RulesSet;
|
using modsecurity::RulesSet;
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ class Driver : public RulesSetProperties {
|
|||||||
Driver();
|
Driver();
|
||||||
virtual ~Driver();
|
virtual ~Driver();
|
||||||
|
|
||||||
int addSecRule(std::unique_ptr<Rule> rule);
|
int addSecRule(std::unique_ptr<RuleWithOperator> rule);
|
||||||
int addSecAction(std::unique_ptr<Rule> rule);
|
int addSecAction(std::unique_ptr<RuleWithOperator> rule);
|
||||||
int addSecMarker(std::string marker, std::unique_ptr<std::string> fileName, int lineNumber);
|
int addSecMarker(std::string marker, std::unique_ptr<std::string> fileName, int lineNumber);
|
||||||
int addSecRuleScript(std::unique_ptr<RuleScript> rule);
|
int addSecRuleScript(std::unique_ptr<RuleScript> rule);
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class Driver : public RulesSetProperties {
|
|||||||
std::list<yy::location *> loc;
|
std::list<yy::location *> loc;
|
||||||
|
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
Rule *m_lastRule;
|
RuleWithOperator *m_lastRule;
|
||||||
|
|
||||||
RulesSetPhases m_rulesSetPhases;
|
RulesSetPhases m_rulesSetPhases;
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -295,7 +295,6 @@ class Driver;
|
|||||||
#include "src/variables/session.h"
|
#include "src/variables/session.h"
|
||||||
#include "src/variables/status.h"
|
#include "src/variables/status.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace modsecurity;
|
using namespace modsecurity;
|
||||||
using namespace modsecurity::variables;
|
using namespace modsecurity::variables;
|
||||||
using namespace modsecurity::Utils;
|
using namespace modsecurity::Utils;
|
||||||
@ -348,7 +347,7 @@ using namespace modsecurity::operators;
|
|||||||
a = std::move(c);
|
a = std::move(c);
|
||||||
|
|
||||||
|
|
||||||
#line 352 "seclang-parser.hh"
|
#line 351 "seclang-parser.hh"
|
||||||
|
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# include <cstdlib> // std::abort
|
# include <cstdlib> // std::abort
|
||||||
@ -482,7 +481,7 @@ using namespace modsecurity::operators;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yy {
|
namespace yy {
|
||||||
#line 486 "seclang-parser.hh"
|
#line 485 "seclang-parser.hh"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -8112,7 +8111,7 @@ switch (yytype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // yy
|
} // yy
|
||||||
#line 8116 "seclang-parser.hh"
|
#line 8115 "seclang-parser.hh"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +257,6 @@ class Driver;
|
|||||||
#include "src/variables/session.h"
|
#include "src/variables/session.h"
|
||||||
#include "src/variables/status.h"
|
#include "src/variables/status.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace modsecurity;
|
using namespace modsecurity;
|
||||||
using namespace modsecurity::variables;
|
using namespace modsecurity::variables;
|
||||||
using namespace modsecurity::Utils;
|
using namespace modsecurity::Utils;
|
||||||
@ -1081,7 +1080,7 @@ expression:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Operator *op = $3.release();
|
Operator *op = $3.release();
|
||||||
std::unique_ptr<Rule> rule(new Rule(
|
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||||
/* op */ op,
|
/* op */ op,
|
||||||
/* variables */ v,
|
/* variables */ v,
|
||||||
/* actions */ a,
|
/* actions */ a,
|
||||||
@ -1101,7 +1100,7 @@ expression:
|
|||||||
v->push_back(i.release());
|
v->push_back(i.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Rule> rule(new Rule(
|
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||||
/* op */ $3.release(),
|
/* op */ $3.release(),
|
||||||
/* variables */ v,
|
/* variables */ v,
|
||||||
/* actions */ NULL,
|
/* actions */ NULL,
|
||||||
@ -1124,7 +1123,7 @@ expression:
|
|||||||
a->push_back(i.release());
|
a->push_back(i.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<Rule> rule(new Rule(
|
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||||
/* op */ NULL,
|
/* op */ NULL,
|
||||||
/* variables */ NULL,
|
/* variables */ NULL,
|
||||||
/* actions */ a,
|
/* actions */ a,
|
||||||
|
21
src/rule.cc
21
src/rule.cc
@ -384,7 +384,7 @@ std::string RuleWithActions::msg(Transaction *t) { return m_msg->data(t); }
|
|||||||
int RuleWithActions::severity() const { return m_severity->m_severity; }
|
int RuleWithActions::severity() const { return m_severity->m_severity; }
|
||||||
|
|
||||||
|
|
||||||
Rule::Rule(Operator *op,
|
RuleWithOperator::RuleWithOperator(Operator *op,
|
||||||
variables::Variables *_variables,
|
variables::Variables *_variables,
|
||||||
std::vector<Action *> *actions,
|
std::vector<Action *> *actions,
|
||||||
Transformations *transformations,
|
Transformations *transformations,
|
||||||
@ -399,7 +399,7 @@ Rule::Rule(Operator *op,
|
|||||||
m_unconditional(false) { /* */ }
|
m_unconditional(false) { /* */ }
|
||||||
|
|
||||||
|
|
||||||
Rule::~Rule() {
|
RuleWithOperator::~RuleWithOperator() {
|
||||||
if (m_operator != NULL) {
|
if (m_operator != NULL) {
|
||||||
delete m_operator;
|
delete m_operator;
|
||||||
}
|
}
|
||||||
@ -416,7 +416,7 @@ Rule::~Rule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Rule::updateMatchedVars(Transaction *trans, const std::string &key,
|
void RuleWithOperator::updateMatchedVars(Transaction *trans, const std::string &key,
|
||||||
const std::string &value) {
|
const std::string &value) {
|
||||||
ms_dbg_a(trans, 9, "Matched vars updated.");
|
ms_dbg_a(trans, 9, "Matched vars updated.");
|
||||||
trans->m_variableMatchedVar.set(value, trans->m_variableOffset);
|
trans->m_variableMatchedVar.set(value, trans->m_variableOffset);
|
||||||
@ -427,7 +427,7 @@ void Rule::updateMatchedVars(Transaction *trans, const std::string &key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Rule::cleanMatchedVars(Transaction *trans) {
|
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();
|
||||||
@ -436,7 +436,8 @@ void Rule::cleanMatchedVars(Transaction *trans) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Rule::executeOperatorAt(Transaction *trans, const std::string &key,
|
|
||||||
|
bool RuleWithOperator::executeOperatorAt(Transaction *trans, const std::string &key,
|
||||||
std::string value, std::shared_ptr<RuleMessage> ruleMessage) {
|
std::string value, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
#if MSC_EXEC_CLOCK_ENABLED
|
#if MSC_EXEC_CLOCK_ENABLED
|
||||||
clock_t begin = clock();
|
clock_t begin = clock();
|
||||||
@ -465,7 +466,7 @@ bool Rule::executeOperatorAt(Transaction *trans, const std::string &key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Rule::getVariablesExceptions(Transaction *t,
|
void RuleWithOperator::getVariablesExceptions(Transaction *t,
|
||||||
variables::Variables *exclusion, variables::Variables *addition) {
|
variables::Variables *exclusion, variables::Variables *addition) {
|
||||||
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) {
|
||||||
@ -511,10 +512,9 @@ void Rule::getVariablesExceptions(Transaction *t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Rule::getFinalVars(variables::Variables *vars,
|
inline void RuleWithOperator::getFinalVars(variables::Variables *vars,
|
||||||
variables::Variables *exclusion, Transaction *trans) {
|
variables::Variables *exclusion, Transaction *trans) {
|
||||||
variables::Variables addition;
|
variables::Variables addition;
|
||||||
|
|
||||||
getVariablesExceptions(trans, exclusion, &addition);
|
getVariablesExceptions(trans, exclusion, &addition);
|
||||||
|
|
||||||
for (int i = 0; i < m_variables->size(); i++) {
|
for (int i = 0; i < m_variables->size(); i++) {
|
||||||
@ -578,7 +578,7 @@ void RuleWithActions::executeAction(Transaction *trans,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Rule::evaluate(Transaction *trans,
|
bool RuleWithOperator::evaluate(Transaction *trans,
|
||||||
std::shared_ptr<RuleMessage> ruleMessage) {
|
std::shared_ptr<RuleMessage> ruleMessage) {
|
||||||
bool globalRet = false;
|
bool globalRet = false;
|
||||||
variables::Variables *variables = this->m_variables;
|
variables::Variables *variables = this->m_variables;
|
||||||
@ -812,6 +812,7 @@ std::vector<actions::Action *> RuleWithActions::getActionsByName(const std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Rule::getOperatorName() const { return m_operator->m_op; }
|
std::string RuleWithOperator::getOperatorName() const { return m_operator->m_op; }
|
||||||
|
|
||||||
|
|
||||||
} // namespace modsecurity
|
} // namespace modsecurity
|
||||||
|
@ -42,14 +42,14 @@ namespace modsecurity {
|
|||||||
using actions::Action;
|
using actions::Action;
|
||||||
|
|
||||||
/** @ingroup ModSecurity_CPP_API */
|
/** @ingroup ModSecurity_CPP_API */
|
||||||
class RuleScript : public Rule {
|
class RuleScript : public RuleWithOperator {
|
||||||
public:
|
public:
|
||||||
RuleScript(const std::string &name,
|
RuleScript(const std::string &name,
|
||||||
std::vector<Action *> *actions,
|
std::vector<Action *> *actions,
|
||||||
Transformations *t,
|
Transformations *t,
|
||||||
std::unique_ptr<std::string> fileName,
|
std::unique_ptr<std::string> fileName,
|
||||||
int lineNumber)
|
int lineNumber)
|
||||||
: Rule(NULL, NULL, actions, t, std::move(fileName), lineNumber),
|
: RuleWithOperator(NULL, NULL, actions, t, std::move(fileName), lineNumber),
|
||||||
m_name(name) { }
|
m_name(name) { }
|
||||||
|
|
||||||
bool init(std::string *err);
|
bool init(std::string *err);
|
||||||
|
@ -153,7 +153,7 @@ int RulesSet::evaluate(int phase, Transaction *t) {
|
|||||||
+ "' as request trough the utilization of an `allow' action.");
|
+ "' as request trough the utilization of an `allow' action.");
|
||||||
} else {
|
} else {
|
||||||
RuleBase *base = rule.get();
|
RuleBase *base = rule.get();
|
||||||
Rule *ruleWithOperator = dynamic_cast<Rule *>(base);
|
RuleWithOperator *ruleWithOperator = dynamic_cast<RuleWithOperator *>(base);
|
||||||
if (m_exceptions.contains(ruleWithOperator->m_ruleId)) {
|
if (m_exceptions.contains(ruleWithOperator->m_ruleId)) {
|
||||||
ms_dbg_a(t, 9, "Skipped rule id '" + rule->getReference() \
|
ms_dbg_a(t, 9, "Skipped rule id '" + rule->getReference() \
|
||||||
+ "'. Removed by an SecRuleRemove directive.");
|
+ "'. Removed by an SecRuleRemove directive.");
|
||||||
|
@ -46,7 +46,7 @@ int RulesSetPhases::append(RulesSetPhases *from, std::ostringstream *err) {
|
|||||||
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
|
||||||
v.reserve(m_rulesAtPhase[i].size());
|
v.reserve(m_rulesAtPhase[i].size());
|
||||||
for (size_t z = 0; z < m_rulesAtPhase[i].size(); z++) {
|
for (size_t z = 0; z < m_rulesAtPhase[i].size(); z++) {
|
||||||
Rule *rule_ckc = dynamic_cast<Rule *>(m_rulesAtPhase[i].at(z).get());
|
RuleWithOperator *rule_ckc = dynamic_cast<RuleWithOperator *>(m_rulesAtPhase[i].at(z).get());
|
||||||
if (!rule_ckc) {
|
if (!rule_ckc) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ std::string RunTimeString::evaluate(Transaction *t, RuleBase *r) {
|
|||||||
} else if (z->m_var != NULL && t != NULL) {
|
} else if (z->m_var != NULL && t != NULL) {
|
||||||
std::vector<const VariableValue *> l;
|
std::vector<const VariableValue *> l;
|
||||||
// FIXME: This cast should be removed.
|
// FIXME: This cast should be removed.
|
||||||
Rule *rr = dynamic_cast<Rule *>(r);
|
RuleWithOperator *rr = dynamic_cast<RuleWithOperator *>(r);
|
||||||
z->m_var->evaluate(t, rr, &l);
|
z->m_var->evaluate(t, rr, &l);
|
||||||
if (l.size() > 0) {
|
if (l.size() > 0) {
|
||||||
s.append(l[0]->getValue());
|
s.append(l[0]->getValue());
|
||||||
|
@ -28,7 +28,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void Duration::evaluate(Transaction *transaction,
|
void Duration::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
double e = utils::cpu_seconds() - transaction->m_creationTimeStamp;
|
double e = utils::cpu_seconds() - transaction->m_creationTimeStamp;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class Duration : public Variable {
|
|||||||
m_retName("DURATION") { }
|
m_retName("DURATION") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void Env::evaluate(Transaction *transaction,
|
void Env::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
for (char **current = environ; *current; current++) {
|
for (char **current = environ; *current; current++) {
|
||||||
std::string env = std::string(*current);
|
std::string env = std::string(*current);
|
||||||
|
@ -34,7 +34,7 @@ class Env : public Variable {
|
|||||||
: Variable(_name) { }
|
: Variable(_name) { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class Global_DictElement : public Variable {
|
|||||||
m_dictElement("GLOBAL:" + dictElement) { }
|
m_dictElement("GLOBAL:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_global_collection->resolveMultiMatches(
|
t->m_collections.m_global_collection->resolveMultiMatches(
|
||||||
m_name, t->m_collections.m_global_collection_key,
|
m_name, t->m_collections.m_global_collection_key,
|
||||||
@ -56,7 +56,7 @@ class Global_NoDictElement : public Variable {
|
|||||||
: Variable("GLOBAL") { }
|
: Variable("GLOBAL") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_global_collection->resolveMultiMatches("",
|
t->m_collections.m_global_collection->resolveMultiMatches("",
|
||||||
t->m_collections.m_global_collection_key,
|
t->m_collections.m_global_collection_key,
|
||||||
@ -72,7 +72,7 @@ class Global_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_global_collection->resolveRegularExpression(
|
t->m_collections.m_global_collection->resolveRegularExpression(
|
||||||
m_dictElement,
|
m_dictElement,
|
||||||
@ -91,7 +91,7 @@ class Global_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_global_collection->resolveMultiMatches(
|
t->m_collections.m_global_collection->resolveMultiMatches(
|
||||||
|
@ -27,7 +27,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void HighestSeverity::evaluate(Transaction *transaction,
|
void HighestSeverity::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
transaction->m_variableHighestSeverityAction.assign(
|
transaction->m_variableHighestSeverityAction.assign(
|
||||||
std::to_string(transaction->m_highestSeverityAction));
|
std::to_string(transaction->m_highestSeverityAction));
|
||||||
|
@ -35,7 +35,7 @@ class HighestSeverity : public Variable {
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class Ip_DictElement : public Variable {
|
|||||||
m_dictElement("IP:" + dictElement) { }
|
m_dictElement("IP:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_ip_collection->resolveMultiMatches(
|
t->m_collections.m_ip_collection->resolveMultiMatches(
|
||||||
m_name, t->m_collections.m_ip_collection_key,
|
m_name, t->m_collections.m_ip_collection_key,
|
||||||
@ -56,7 +56,7 @@ class Ip_NoDictElement : public Variable {
|
|||||||
: Variable("IP") { }
|
: Variable("IP") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_ip_collection->resolveMultiMatches("",
|
t->m_collections.m_ip_collection->resolveMultiMatches("",
|
||||||
t->m_collections.m_ip_collection_key,
|
t->m_collections.m_ip_collection_key,
|
||||||
@ -72,7 +72,7 @@ class Ip_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_ip_collection->resolveRegularExpression(
|
t->m_collections.m_ip_collection->resolveRegularExpression(
|
||||||
m_dictElement, t->m_collections.m_ip_collection_key,
|
m_dictElement, t->m_collections.m_ip_collection_key,
|
||||||
@ -90,7 +90,7 @@ class Ip_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_ip_collection->resolveMultiMatches(
|
t->m_collections.m_ip_collection->resolveMultiMatches(
|
||||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void ModsecBuild::evaluate(Transaction *transaction,
|
void ModsecBuild::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
|
|
||||||
l->push_back(new VariableValue(&m_retName, &m_build));
|
l->push_back(new VariableValue(&m_retName, &m_build));
|
||||||
|
@ -44,7 +44,7 @@ class ModsecBuild : public Variable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
|
|
||||||
std::string m_build;
|
std::string m_build;
|
||||||
|
@ -37,7 +37,7 @@ namespace variables {
|
|||||||
|
|
||||||
|
|
||||||
void RemoteUser::evaluate(Transaction *transaction,
|
void RemoteUser::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
std::string base64;
|
std::string base64;
|
||||||
|
@ -37,7 +37,7 @@ class RemoteUser : public Variable {
|
|||||||
m_retName("REMOTE_USER") { }
|
m_retName("REMOTE_USER") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ class Resource_DictElement : public Variable {
|
|||||||
m_dictElement("RESOURCE:" + dictElement) { }
|
m_dictElement("RESOURCE:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_resource_collection->resolveMultiMatches(
|
t->m_collections.m_resource_collection->resolveMultiMatches(
|
||||||
m_name, t->m_collections.m_resource_collection_key,
|
m_name, t->m_collections.m_resource_collection_key,
|
||||||
@ -56,7 +56,7 @@ class Resource_NoDictElement : public Variable {
|
|||||||
: Variable("RESOURCE") { }
|
: Variable("RESOURCE") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_resource_collection->resolveMultiMatches(m_name,
|
t->m_collections.m_resource_collection->resolveMultiMatches(m_name,
|
||||||
t->m_collections.m_resource_collection_key,
|
t->m_collections.m_resource_collection_key,
|
||||||
@ -72,7 +72,7 @@ class Resource_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_resource_collection->resolveRegularExpression(
|
t->m_collections.m_resource_collection->resolveRegularExpression(
|
||||||
m_dictElement, t->m_collections.m_resource_collection_key,
|
m_dictElement, t->m_collections.m_resource_collection_key,
|
||||||
@ -90,7 +90,7 @@ class Resource_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_resource_collection->resolveMultiMatches(
|
t->m_collections.m_resource_collection->resolveMultiMatches(
|
||||||
|
@ -38,9 +38,9 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
: VariableDictElement(std::string("RULE"), dictElement) { }
|
: VariableDictElement(std::string("RULE"), dictElement) { }
|
||||||
|
|
||||||
static void id(Transaction *t,
|
static void id(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
Rule *r = rule;
|
RuleWithOperator *r = rule;
|
||||||
|
|
||||||
while (r && r->m_ruleId == 0) {
|
while (r && r->m_ruleId == 0) {
|
||||||
r = r->m_chainedRuleParent;
|
r = r->m_chainedRuleParent;
|
||||||
@ -63,9 +63,9 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
|
|
||||||
|
|
||||||
static void rev(Transaction *t,
|
static void rev(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
Rule *r = rule;
|
RuleWithOperator *r = rule;
|
||||||
|
|
||||||
while (r && r->m_rev.empty()) {
|
while (r && r->m_rev.empty()) {
|
||||||
r = r->m_chainedRuleParent;
|
r = r->m_chainedRuleParent;
|
||||||
@ -89,9 +89,9 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
|
|
||||||
|
|
||||||
static void severity(Transaction *t,
|
static void severity(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
Rule *r = rule;
|
RuleWithOperator *r = rule;
|
||||||
|
|
||||||
while (r && !r->hasSeverity()) {
|
while (r && !r->hasSeverity()) {
|
||||||
r = r->m_chainedRuleParent;
|
r = r->m_chainedRuleParent;
|
||||||
@ -113,9 +113,9 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
|
|
||||||
|
|
||||||
static void logData(Transaction *t,
|
static void logData(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
Rule *r = rule;
|
RuleWithOperator *r = rule;
|
||||||
|
|
||||||
while (r && !r->hasLogData()) {
|
while (r && !r->hasLogData()) {
|
||||||
r = r->m_chainedRuleParent;
|
r = r->m_chainedRuleParent;
|
||||||
@ -136,9 +136,9 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void msg(Transaction *t,
|
static void msg(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
Rule *r = rule;
|
RuleWithOperator *r = rule;
|
||||||
|
|
||||||
while (r && !r->hasMsg()) {
|
while (r && !r->hasMsg()) {
|
||||||
r = r->m_chainedRuleParent;
|
r = r->m_chainedRuleParent;
|
||||||
@ -159,7 +159,7 @@ class Rule_DictElement : public VariableDictElement { \
|
|||||||
}
|
}
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
if (m_dictElement == "id") {
|
if (m_dictElement == "id") {
|
||||||
id(t, rule, l);
|
id(t, rule, l);
|
||||||
@ -198,7 +198,7 @@ class Rule_DictElementRegexp : public VariableRegex {
|
|||||||
: VariableRegex("RULE", regex) { }
|
: VariableRegex("RULE", regex) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
if (Utils::regex_search("id", m_r) > 0) {
|
if (Utils::regex_search("id", m_r) > 0) {
|
||||||
Rule_DictElement::id(t, rule, l);
|
Rule_DictElement::id(t, rule, l);
|
||||||
@ -230,7 +230,7 @@ class Rule_NoDictElement : public Variable {
|
|||||||
: Variable("RULE") { }
|
: Variable("RULE") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
Rule_DictElement::id(t, rule, l);
|
Rule_DictElement::id(t, rule, l);
|
||||||
Rule_DictElement::rev(t, rule, l);
|
Rule_DictElement::rev(t, rule, l);
|
||||||
|
@ -39,7 +39,7 @@ class Session_DictElement : public Variable {
|
|||||||
m_dictElement("SESSION:" + dictElement) { }
|
m_dictElement("SESSION:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_session_collection->resolveMultiMatches(
|
t->m_collections.m_session_collection->resolveMultiMatches(
|
||||||
m_name, t->m_collections.m_session_collection_key,
|
m_name, t->m_collections.m_session_collection_key,
|
||||||
@ -56,7 +56,7 @@ class Session_NoDictElement : public Variable {
|
|||||||
: Variable("SESSION") { }
|
: Variable("SESSION") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_session_collection->resolveMultiMatches("",
|
t->m_collections.m_session_collection->resolveMultiMatches("",
|
||||||
t->m_collections.m_session_collection_key,
|
t->m_collections.m_session_collection_key,
|
||||||
@ -72,7 +72,7 @@ class Session_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_session_collection->resolveRegularExpression(
|
t->m_collections.m_session_collection->resolveRegularExpression(
|
||||||
m_dictElement, t->m_collections.m_session_collection_key,
|
m_dictElement, t->m_collections.m_session_collection_key,
|
||||||
@ -90,7 +90,7 @@ class Session_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_session_collection->resolveMultiMatches(
|
t->m_collections.m_session_collection->resolveMultiMatches(
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void Time::evaluate(Transaction *transaction,
|
void Time::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
|
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
|
@ -36,7 +36,7 @@ class Time : public Variable {
|
|||||||
m_retName("TIME") { }
|
m_retName("TIME") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeDay::evaluate(Transaction *transaction,
|
void TimeDay::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeDay : public Variable {
|
|||||||
m_retName("TIME_DAY") { }
|
m_retName("TIME_DAY") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeEpoch::evaluate(Transaction *transaction,
|
void TimeEpoch::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
transaction->m_variableTimeEpoch.assign(
|
transaction->m_variableTimeEpoch.assign(
|
||||||
std::to_string(std::time(nullptr)));
|
std::to_string(std::time(nullptr)));
|
||||||
|
@ -35,7 +35,7 @@ class TimeEpoch : public Variable {
|
|||||||
m_retName("TIME_EPOCH") { }
|
m_retName("TIME_EPOCH") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeHour::evaluate(Transaction *transaction,
|
void TimeHour::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeHour : public Variable {
|
|||||||
m_retName("TIME_HOUR") { }
|
m_retName("TIME_HOUR") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeMin::evaluate(Transaction *transaction,
|
void TimeMin::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeMin : public Variable {
|
|||||||
m_retName("TIME_MIN") { }
|
m_retName("TIME_MIN") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeMon::evaluate(Transaction *transaction,
|
void TimeMon::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeMon : public Variable {
|
|||||||
m_retName("TIME_MON") { }
|
m_retName("TIME_MON") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeSec::evaluate(Transaction *transaction,
|
void TimeSec::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeSec : public Variable {
|
|||||||
m_retName("TIME_SEC") { }
|
m_retName("TIME_SEC") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeWDay::evaluate(Transaction *transaction,
|
void TimeWDay::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeWDay : public Variable {
|
|||||||
m_retName("TIME_WDAY") { }
|
m_retName("TIME_WDAY") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
|||||||
namespace variables {
|
namespace variables {
|
||||||
|
|
||||||
void TimeYear::evaluate(Transaction *transaction,
|
void TimeYear::evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
char tstr[200];
|
char tstr[200];
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
|
@ -35,7 +35,7 @@ class TimeYear : public Variable {
|
|||||||
m_retName("TIME_YEAR") { }
|
m_retName("TIME_YEAR") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
std::string m_retName;
|
std::string m_retName;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ class Tx_DictElement : public Variable {
|
|||||||
m_dictElement("TX:" + dictElement) { }
|
m_dictElement("TX:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_tx_collection->resolveMultiMatches(
|
t->m_collections.m_tx_collection->resolveMultiMatches(
|
||||||
m_name, l, m_keyExclusion);
|
m_name, l, m_keyExclusion);
|
||||||
@ -55,7 +55,7 @@ class Tx_NoDictElement : public Variable {
|
|||||||
: Variable("TX") { }
|
: Variable("TX") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_tx_collection->resolveMultiMatches("", l,
|
t->m_collections.m_tx_collection->resolveMultiMatches("", l,
|
||||||
m_keyExclusion);
|
m_keyExclusion);
|
||||||
@ -70,7 +70,7 @@ class Tx_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_tx_collection->resolveRegularExpression(
|
t->m_collections.m_tx_collection->resolveRegularExpression(
|
||||||
m_dictElement, l, m_keyExclusion);
|
m_dictElement, l, m_keyExclusion);
|
||||||
@ -87,7 +87,7 @@ class Tx_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_tx_collection->resolveMultiMatches(string, l,
|
t->m_collections.m_tx_collection->resolveMultiMatches(string, l,
|
||||||
|
@ -39,7 +39,7 @@ class User_DictElement : public Variable {
|
|||||||
m_dictElement("USER:" + dictElement) { }
|
m_dictElement("USER:" + dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_user_collection->resolveMultiMatches(
|
t->m_collections.m_user_collection->resolveMultiMatches(
|
||||||
m_name, t->m_collections.m_user_collection_key,
|
m_name, t->m_collections.m_user_collection_key,
|
||||||
@ -56,7 +56,7 @@ class User_NoDictElement : public Variable {
|
|||||||
: Variable("USER") { }
|
: Variable("USER") { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_user_collection->resolveMultiMatches(m_name,
|
t->m_collections.m_user_collection->resolveMultiMatches(m_name,
|
||||||
t->m_collections.m_user_collection_key,
|
t->m_collections.m_user_collection_key,
|
||||||
@ -72,7 +72,7 @@ class User_DictElementRegexp : public VariableRegex {
|
|||||||
m_dictElement(dictElement) { }
|
m_dictElement(dictElement) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
t->m_collections.m_user_collection->resolveRegularExpression(
|
t->m_collections.m_user_collection->resolveRegularExpression(
|
||||||
m_dictElement, t->m_collections.m_user_collection_key,
|
m_dictElement, t->m_collections.m_user_collection_key,
|
||||||
@ -90,7 +90,7 @@ class User_DynamicElement : public Variable {
|
|||||||
m_string(std::move(dictElement)) { }
|
m_string(std::move(dictElement)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::string string = m_string->evaluate(t);
|
std::string string = m_string->evaluate(t);
|
||||||
t->m_collections.m_user_collection->resolveMultiMatches(
|
t->m_collections.m_user_collection->resolveMultiMatches(
|
||||||
|
@ -49,7 +49,7 @@ class n ## _DictElementRegexp : public VariableRegex { \
|
|||||||
: VariableRegex(#N, regex) { } \
|
: VariableRegex(#N, regex) { } \
|
||||||
\
|
\
|
||||||
void evaluate(Transaction *transaction, \
|
void evaluate(Transaction *transaction, \
|
||||||
Rule *rule, \
|
RuleWithOperator *rule, \
|
||||||
std::vector<const VariableValue *> *l) override { \
|
std::vector<const VariableValue *> *l) override { \
|
||||||
transaction-> e .resolveRegularExpression(&m_r, l, \
|
transaction-> e .resolveRegularExpression(&m_r, l, \
|
||||||
m_keyExclusion); \
|
m_keyExclusion); \
|
||||||
@ -64,7 +64,7 @@ class n ## _DictElement : public VariableDictElement { \
|
|||||||
: VariableDictElement(#N, dictElement) { } \
|
: VariableDictElement(#N, dictElement) { } \
|
||||||
\
|
\
|
||||||
void evaluate(Transaction *transaction, \
|
void evaluate(Transaction *transaction, \
|
||||||
Rule *rule, \
|
RuleWithOperator *rule, \
|
||||||
std::vector<const VariableValue *> *l) override { \
|
std::vector<const VariableValue *> *l) override { \
|
||||||
transaction-> e .resolve(m_dictElement, l); \
|
transaction-> e .resolve(m_dictElement, l); \
|
||||||
} \
|
} \
|
||||||
@ -78,7 +78,7 @@ class n ## _NoDictElement : public Variable { \
|
|||||||
: Variable(#N) { } \
|
: Variable(#N) { } \
|
||||||
\
|
\
|
||||||
void evaluate(Transaction *transaction, \
|
void evaluate(Transaction *transaction, \
|
||||||
Rule *rule, \
|
RuleWithOperator *rule, \
|
||||||
std::vector<const VariableValue *> *l) override { \
|
std::vector<const VariableValue *> *l) override { \
|
||||||
transaction-> e .resolve(l, m_keyExclusion); \
|
transaction-> e .resolve(l, m_keyExclusion); \
|
||||||
} \
|
} \
|
||||||
@ -92,7 +92,7 @@ class n : public Variable { \
|
|||||||
: Variable(#N) { } \
|
: Variable(#N) { } \
|
||||||
\
|
\
|
||||||
void evaluate(Transaction *transaction, \
|
void evaluate(Transaction *transaction, \
|
||||||
Rule *rule, \
|
RuleWithOperator *rule, \
|
||||||
std::vector<const VariableValue *> *l) override { \
|
std::vector<const VariableValue *> *l) override { \
|
||||||
transaction-> e .evaluate(l); \
|
transaction-> e .evaluate(l); \
|
||||||
} \
|
} \
|
||||||
@ -550,7 +550,7 @@ class Variable : public VariableMonkeyResolution {
|
|||||||
|
|
||||||
|
|
||||||
virtual void evaluate(Transaction *t,
|
virtual void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) = 0;
|
std::vector<const VariableValue *> *l) = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ class VariableModificatorExclusion : public Variable {
|
|||||||
m_base(std::move(var)) { }
|
m_base(std::move(var)) { }
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
m_base->evaluate(t, rule, l);
|
m_base->evaluate(t, rule, l);
|
||||||
}
|
}
|
||||||
@ -648,7 +648,7 @@ class VariableModificatorCount : public Variable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
std::vector<const VariableValue *> reslIn;
|
std::vector<const VariableValue *> reslIn;
|
||||||
VariableValue *val = NULL;
|
VariableValue *val = NULL;
|
||||||
|
@ -36,7 +36,7 @@ class WebAppId : public Variable {
|
|||||||
: Variable("WEBAPPID") { }
|
: Variable("WEBAPPID") { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
const std::string name("WEBAPPID");
|
const std::string name("WEBAPPID");
|
||||||
const std::string rname = transaction->m_rules->m_secWebAppId.m_value;
|
const std::string rname = transaction->m_rules->m_secWebAppId.m_value;
|
||||||
|
@ -48,12 +48,12 @@ namespace variables {
|
|||||||
|
|
||||||
#ifndef WITH_LIBXML2
|
#ifndef WITH_LIBXML2
|
||||||
void XML::evaluate(Transaction *t,
|
void XML::evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) { }
|
std::vector<const VariableValue *> *l) { }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void XML::evaluate(Transaction *t,
|
void XML::evaluate(Transaction *t,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) {
|
std::vector<const VariableValue *> *l) {
|
||||||
xmlXPathContextPtr xpathCtx;
|
xmlXPathContextPtr xpathCtx;
|
||||||
xmlXPathObjectPtr xpathObj;
|
xmlXPathObjectPtr xpathObj;
|
||||||
|
@ -42,8 +42,8 @@ class XML_NoDictElement : public Variable {
|
|||||||
m_var(&m_name, &m_plain) {
|
m_var(&m_name, &m_plain) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void evaluate(Transaction *t,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override {
|
std::vector<const VariableValue *> *l) override {
|
||||||
l->push_back(new VariableValue(&m_var));
|
l->push_back(new VariableValue(&m_var));
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ class XML : public Variable {
|
|||||||
: Variable(_name) { }
|
: Variable(_name) { }
|
||||||
|
|
||||||
void evaluate(Transaction *transaction,
|
void evaluate(Transaction *transaction,
|
||||||
Rule *rule,
|
RuleWithOperator *rule,
|
||||||
std::vector<const VariableValue *> *l) override;
|
std::vector<const VariableValue *> *l) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user