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 {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
class RuleWithActions;
|
||||
|
||||
namespace actions {
|
||||
|
@ -229,7 +229,7 @@ namespace modsecurity {
|
||||
namespace actions {
|
||||
class Action;
|
||||
}
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -216,16 +216,16 @@ class RuleWithActions : public RuleBase {
|
||||
};
|
||||
|
||||
|
||||
class Rule : public RuleWithActions {
|
||||
class RuleWithOperator : public RuleWithActions {
|
||||
public:
|
||||
Rule(operators::Operator *op,
|
||||
RuleWithOperator(operators::Operator *op,
|
||||
variables::Variables *variables,
|
||||
std::vector<actions::Action *> *actions,
|
||||
Transformations *transformations,
|
||||
std::unique_ptr<std::string> fileName,
|
||||
int lineNumber);
|
||||
|
||||
virtual ~Rule();
|
||||
virtual ~RuleWithOperator();
|
||||
|
||||
bool evaluate(Transaction *transaction,
|
||||
std::shared_ptr<RuleMessage> rm) override;
|
||||
@ -250,8 +250,8 @@ class Rule : public RuleWithActions {
|
||||
return std::to_string(m_ruleId);
|
||||
}
|
||||
|
||||
std::unique_ptr<Rule> m_chainedRuleChild;
|
||||
Rule *m_chainedRuleParent;
|
||||
std::unique_ptr<RuleWithOperator> m_chainedRuleChild;
|
||||
RuleWithOperator *m_chainedRuleParent;
|
||||
|
||||
private:
|
||||
modsecurity::variables::Variables *m_variables;
|
||||
|
@ -41,7 +41,7 @@ class RuleMessage {
|
||||
ClientLogMessageInfo = 4
|
||||
};
|
||||
|
||||
explicit RuleMessage(Rule *rule, Transaction *trans) :
|
||||
explicit RuleMessage(RuleWithOperator *rule, Transaction *trans) :
|
||||
m_accuracy(rule->m_accuracy),
|
||||
m_clientIpAddress(trans->m_clientIpAddress),
|
||||
m_data(""),
|
||||
@ -103,7 +103,7 @@ class RuleMessage {
|
||||
int m_phase;
|
||||
std::string m_reference;
|
||||
std::string m_rev;
|
||||
Rule *m_rule;
|
||||
RuleWithOperator *m_rule;
|
||||
std::shared_ptr<std::string> m_ruleFile;
|
||||
int m_ruleId;
|
||||
int m_ruleLine;
|
||||
|
@ -48,7 +48,7 @@ class Rules {
|
||||
int append(Rules *from, const std::vector<int64_t> &ids, std::ostringstream *err) {
|
||||
size_t j = 0;
|
||||
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 (err != NULL) {
|
||||
*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) {
|
||||
Rule *r = dynamic_cast<Rule *>(rule.get());
|
||||
if (ids != nullptr && std::binary_search(ids->begin(), ids->end(), r->m_ruleId)) {
|
||||
RuleWithOperator *r = dynamic_cast<RuleWithOperator *>(rule.get());
|
||||
if (r && ids != nullptr && std::binary_search(ids->begin(), ids->end(), r->m_ruleId)) {
|
||||
if (err != nullptr) {
|
||||
*err << "Rule id: " << std::to_string(r->m_ruleId) \
|
||||
<< " is duplicated" << std::endl;
|
||||
|
@ -37,7 +37,7 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
namespace Parser {
|
||||
class Driver;
|
||||
}
|
||||
|
@ -34,7 +34,10 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
namespace Parser {
|
||||
class Driver;
|
||||
}
|
||||
|
||||
/** @ingroup ModSecurity_CPP_API */
|
||||
class RulesSetPhases {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
namespace actions {
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
namespace disruptive {
|
||||
|
@ -25,7 +25,7 @@ class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -25,7 +25,7 @@ class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -112,7 +112,7 @@ bool SetVar::evaluate(RuleWithActions *rule, Transaction *t) {
|
||||
|
||||
try {
|
||||
std::vector<const VariableValue *> l;
|
||||
Rule *rr = dynamic_cast<Rule *>(rule);
|
||||
RuleWithOperator *rr = dynamic_cast<RuleWithOperator *>(rule);
|
||||
m_variable->evaluate(t, rr, &l);
|
||||
if (l.size() == 0) {
|
||||
value = 0;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
class Rule;
|
||||
class RuleWithOperator;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
||||
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) {
|
||||
std::string p(m_string->evaluate(transaction));
|
||||
|
||||
|
@ -32,7 +32,7 @@ class BeginsWith : public Operator {
|
||||
explicit BeginsWith(std::unique_ptr<RunTimeString> 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;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
namespace modsecurity {
|
||||
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) {
|
||||
std::string p(m_string->evaluate(transaction));
|
||||
size_t offset = input.find(p);
|
||||
|
@ -34,7 +34,7 @@ class Contains : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
explicit Contains(std::unique_ptr<RunTimeString> param)
|
||||
: Operator("Contains", std::move(param)) { }
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &str,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ bool ContainsWord::acceptableChar(const std::string& a, size_t pos) {
|
||||
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) {
|
||||
std::string paramTarget(m_string->evaluate(transaction));
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ContainsWord : public Operator {
|
||||
explicit ContainsWord(std::unique_ptr<RunTimeString> param)
|
||||
: Operator("ContainsWord", std::move(param)) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &str,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
||||
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) {
|
||||
char fingerprint[8];
|
||||
int issqli;
|
||||
|
@ -32,7 +32,7 @@ class DetectSQLi : public Operator {
|
||||
m_match_message.assign("detected SQLi using libinjection.");
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *t, Rule *rule,
|
||||
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
||||
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) {
|
||||
int is_xss;
|
||||
|
||||
|
@ -31,7 +31,7 @@ class DetectXSS : public Operator {
|
||||
m_match_message.assign("detected XSS using libinjection.");
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *t, Rule *rule,
|
||||
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ namespace modsecurity {
|
||||
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) {
|
||||
bool ret = false;
|
||||
std::string p(m_string->evaluate(transaction));
|
||||
|
@ -33,7 +33,7 @@ class EndsWith : public Operator {
|
||||
: Operator("EndsWith", std::move(param)) {
|
||||
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;
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ namespace operators {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (m_negation) {
|
||||
@ -81,7 +81,7 @@ 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);
|
||||
|
||||
if (m_negation) {
|
||||
|
@ -111,18 +111,18 @@ class Operator {
|
||||
std::string key, std::string value);
|
||||
|
||||
bool evaluateInternal(Transaction *t, const std::string& a);
|
||||
bool evaluateInternal(Transaction *t, Rule *rule,
|
||||
bool evaluateInternal(Transaction *t, RuleWithOperator *rule,
|
||||
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);
|
||||
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
int rc;
|
||||
ACMPT pt;
|
||||
|
@ -41,7 +41,7 @@ class Pm : public Operator {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
~Pm();
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &str,
|
||||
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,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
struct addrinfo *info = NULL;
|
||||
|
@ -76,7 +76,7 @@ class Rbl : public Operator {
|
||||
m_provider = RblProvider::httpbl;
|
||||
}
|
||||
}
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
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) {
|
||||
std::list<SMatch> matches;
|
||||
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 {
|
||||
return evaluate(transaction, NULL, input, NULL);
|
||||
}
|
||||
@ -57,7 +57,7 @@ class Rx : public Operator {
|
||||
const std::string &input) override {
|
||||
return evaluate(transaction, NULL, input);
|
||||
}
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
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) {
|
||||
bool ret = true;
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ValidateByteRange : public Operator {
|
||||
}
|
||||
~ValidateByteRange() override { }
|
||||
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
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) {
|
||||
size_t offset = 0;
|
||||
bool res = false;
|
||||
|
@ -31,7 +31,7 @@ class ValidateUrlEncoding : public Operator {
|
||||
ValidateUrlEncoding()
|
||||
: Operator("ValidateUrlEncoding") { }
|
||||
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int ValidateUtf8Encoding::detect_utf8_character(
|
||||
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) {
|
||||
unsigned int i, bytes_left;
|
||||
|
||||
|
@ -38,7 +38,7 @@ class ValidateUtf8Encoding : public Operator {
|
||||
ValidateUtf8Encoding()
|
||||
: Operator("ValidateUtf8Encoding") { }
|
||||
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string &str,
|
||||
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) {
|
||||
int offset = 0;
|
||||
int target_length = i.length();
|
||||
|
@ -35,7 +35,7 @@ class VerifyCC : public Operator {
|
||||
m_pce(NULL) { }
|
||||
~VerifyCC();
|
||||
|
||||
bool evaluate(Transaction *t, Rule *rule,
|
||||
bool evaluate(Transaction *t, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) 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) {
|
||||
std::list<SMatch> matches;
|
||||
bool is_cpf = false;
|
||||
|
@ -46,7 +46,7 @@ class VerifyCPF : public Operator {
|
||||
bool operator=(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 {
|
||||
return evaluate(transaction, NULL, input, NULL);
|
||||
}
|
||||
@ -54,7 +54,7 @@ class VerifyCPF : public Operator {
|
||||
const std::string &input) override {
|
||||
return evaluate(transaction, NULL, input);
|
||||
}
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
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) {
|
||||
std::list<SMatch> matches;
|
||||
bool is_ssn = false;
|
||||
|
@ -46,7 +46,7 @@ class VerifySSN : public Operator {
|
||||
bool operator=(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 {
|
||||
return evaluate(transaction, NULL, input, NULL);
|
||||
}
|
||||
@ -54,7 +54,7 @@ class VerifySSN : public Operator {
|
||||
const std::string &input) override {
|
||||
return evaluate(transaction, NULL, input);
|
||||
}
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
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) {
|
||||
std::list<SMatch> matches;
|
||||
bool is_svnr = false;
|
||||
|
@ -32,7 +32,7 @@ class VerifySVNR : public Operator {
|
||||
bool operator=(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 {
|
||||
return evaluate(transaction, NULL, input, NULL);
|
||||
}
|
||||
@ -40,7 +40,7 @@ class VerifySVNR : public Operator {
|
||||
const std::string &input) override {
|
||||
return evaluate(transaction, NULL, input);
|
||||
}
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
bool evaluate(Transaction *transaction, RuleWithOperator *rule,
|
||||
const std::string& input,
|
||||
std::shared_ptr<RuleMessage> ruleMessage) override;
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace modsecurity {
|
||||
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) {
|
||||
bool res = false;
|
||||
size_t pos = 0;
|
||||
|
@ -33,7 +33,7 @@ class Within : public Operator {
|
||||
: Operator("Within", std::move(param)) {
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "modsecurity/audit_log.h"
|
||||
|
||||
using modsecurity::audit_log::AuditLog;
|
||||
using modsecurity::Rule;
|
||||
using modsecurity::RuleWithOperator;
|
||||
|
||||
namespace modsecurity {
|
||||
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) {
|
||||
m_parserError << "Unknown phase: " << std::to_string(rule->getPhase());
|
||||
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) {
|
||||
m_parserError << "Unknown phase: " << std::to_string(r->getPhase());
|
||||
m_parserError << std::endl;
|
||||
@ -93,7 +93,7 @@ int Driver::addSecRule(std::unique_ptr<Rule> r) {
|
||||
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
|
||||
* 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++) {
|
||||
Rules *rules = m_rulesSetPhases[i];
|
||||
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) {
|
||||
m_parserError << "Rule id: " << std::to_string(rule->m_ruleId) \
|
||||
<< " is duplicated" << std::endl;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "src/parser/seclang-parser.hh"
|
||||
#endif
|
||||
|
||||
using modsecurity::Rule;
|
||||
using modsecurity::RuleWithOperator;
|
||||
using modsecurity::RulesSet;
|
||||
|
||||
|
||||
@ -66,8 +66,8 @@ class Driver : public RulesSetProperties {
|
||||
Driver();
|
||||
virtual ~Driver();
|
||||
|
||||
int addSecRule(std::unique_ptr<Rule> rule);
|
||||
int addSecAction(std::unique_ptr<Rule> rule);
|
||||
int addSecRule(std::unique_ptr<RuleWithOperator> rule);
|
||||
int addSecAction(std::unique_ptr<RuleWithOperator> rule);
|
||||
int addSecMarker(std::string marker, std::unique_ptr<std::string> fileName, int lineNumber);
|
||||
int addSecRuleScript(std::unique_ptr<RuleScript> rule);
|
||||
|
||||
@ -89,7 +89,7 @@ class Driver : public RulesSetProperties {
|
||||
std::list<yy::location *> loc;
|
||||
|
||||
std::string buffer;
|
||||
Rule *m_lastRule;
|
||||
RuleWithOperator *m_lastRule;
|
||||
|
||||
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/status.h"
|
||||
|
||||
|
||||
using namespace modsecurity;
|
||||
using namespace modsecurity::variables;
|
||||
using namespace modsecurity::Utils;
|
||||
@ -348,7 +347,7 @@ using namespace modsecurity::operators;
|
||||
a = std::move(c);
|
||||
|
||||
|
||||
#line 352 "seclang-parser.hh"
|
||||
#line 351 "seclang-parser.hh"
|
||||
|
||||
# include <cassert>
|
||||
# include <cstdlib> // std::abort
|
||||
@ -482,7 +481,7 @@ using namespace modsecurity::operators;
|
||||
#endif
|
||||
|
||||
namespace yy {
|
||||
#line 486 "seclang-parser.hh"
|
||||
#line 485 "seclang-parser.hh"
|
||||
|
||||
|
||||
|
||||
@ -8112,7 +8111,7 @@ switch (yytype)
|
||||
}
|
||||
|
||||
} // 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/status.h"
|
||||
|
||||
|
||||
using namespace modsecurity;
|
||||
using namespace modsecurity::variables;
|
||||
using namespace modsecurity::Utils;
|
||||
@ -1081,7 +1080,7 @@ expression:
|
||||
}
|
||||
|
||||
Operator *op = $3.release();
|
||||
std::unique_ptr<Rule> rule(new Rule(
|
||||
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||
/* op */ op,
|
||||
/* variables */ v,
|
||||
/* actions */ a,
|
||||
@ -1101,7 +1100,7 @@ expression:
|
||||
v->push_back(i.release());
|
||||
}
|
||||
|
||||
std::unique_ptr<Rule> rule(new Rule(
|
||||
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||
/* op */ $3.release(),
|
||||
/* variables */ v,
|
||||
/* actions */ NULL,
|
||||
@ -1124,7 +1123,7 @@ expression:
|
||||
a->push_back(i.release());
|
||||
}
|
||||
}
|
||||
std::unique_ptr<Rule> rule(new Rule(
|
||||
std::unique_ptr<RuleWithOperator> rule(new RuleWithOperator(
|
||||
/* op */ NULL,
|
||||
/* variables */ NULL,
|
||||
/* 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; }
|
||||
|
||||
|
||||
Rule::Rule(Operator *op,
|
||||
RuleWithOperator::RuleWithOperator(Operator *op,
|
||||
variables::Variables *_variables,
|
||||
std::vector<Action *> *actions,
|
||||
Transformations *transformations,
|
||||
@ -399,7 +399,7 @@ Rule::Rule(Operator *op,
|
||||
m_unconditional(false) { /* */ }
|
||||
|
||||
|
||||
Rule::~Rule() {
|
||||
RuleWithOperator::~RuleWithOperator() {
|
||||
if (m_operator != NULL) {
|
||||
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) {
|
||||
ms_dbg_a(trans, 9, "Matched vars updated.");
|
||||
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.");
|
||||
trans->m_variableMatchedVar.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) {
|
||||
#if MSC_EXEC_CLOCK_ENABLED
|
||||
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) {
|
||||
for (auto &a : t->m_rules->m_exceptions.m_variable_update_target_by_tag) {
|
||||
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 addition;
|
||||
|
||||
getVariablesExceptions(trans, exclusion, &addition);
|
||||
|
||||
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) {
|
||||
bool globalRet = false;
|
||||
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
|
||||
|
@ -42,14 +42,14 @@ namespace modsecurity {
|
||||
using actions::Action;
|
||||
|
||||
/** @ingroup ModSecurity_CPP_API */
|
||||
class RuleScript : public Rule {
|
||||
class RuleScript : public RuleWithOperator {
|
||||
public:
|
||||
RuleScript(const std::string &name,
|
||||
std::vector<Action *> *actions,
|
||||
Transformations *t,
|
||||
std::unique_ptr<std::string> fileName,
|
||||
int lineNumber)
|
||||
: Rule(NULL, NULL, actions, t, std::move(fileName), lineNumber),
|
||||
: RuleWithOperator(NULL, NULL, actions, t, std::move(fileName), lineNumber),
|
||||
m_name(name) { }
|
||||
|
||||
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.");
|
||||
} else {
|
||||
RuleBase *base = rule.get();
|
||||
Rule *ruleWithOperator = dynamic_cast<Rule *>(base);
|
||||
RuleWithOperator *ruleWithOperator = dynamic_cast<RuleWithOperator *>(base);
|
||||
if (m_exceptions.contains(ruleWithOperator->m_ruleId)) {
|
||||
ms_dbg_a(t, 9, "Skipped rule id '" + rule->getReference() \
|
||||
+ "'. 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++) {
|
||||
v.reserve(m_rulesAtPhase[i].size());
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ std::string RunTimeString::evaluate(Transaction *t, RuleBase *r) {
|
||||
} else if (z->m_var != NULL && t != NULL) {
|
||||
std::vector<const VariableValue *> l;
|
||||
// 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);
|
||||
if (l.size() > 0) {
|
||||
s.append(l[0]->getValue());
|
||||
|
@ -28,7 +28,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void Duration::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
double e = utils::cpu_seconds() - transaction->m_creationTimeStamp;
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Duration : public Variable {
|
||||
m_retName("DURATION") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void Env::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
for (char **current = environ; *current; current++) {
|
||||
std::string env = std::string(*current);
|
||||
|
@ -34,7 +34,7 @@ class Env : public Variable {
|
||||
: Variable(_name) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,7 @@ class Global_DictElement : public Variable {
|
||||
m_dictElement("GLOBAL:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_global_collection->resolveMultiMatches(
|
||||
m_name, t->m_collections.m_global_collection_key,
|
||||
@ -56,7 +56,7 @@ class Global_NoDictElement : public Variable {
|
||||
: Variable("GLOBAL") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_global_collection->resolveMultiMatches("",
|
||||
t->m_collections.m_global_collection_key,
|
||||
@ -72,7 +72,7 @@ class Global_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_global_collection->resolveRegularExpression(
|
||||
m_dictElement,
|
||||
@ -91,7 +91,7 @@ class Global_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_global_collection->resolveMultiMatches(
|
||||
|
@ -27,7 +27,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void HighestSeverity::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
transaction->m_variableHighestSeverityAction.assign(
|
||||
std::to_string(transaction->m_highestSeverityAction));
|
||||
|
@ -35,7 +35,7 @@ class HighestSeverity : public Variable {
|
||||
{ }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,7 @@ class Ip_DictElement : public Variable {
|
||||
m_dictElement("IP:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_ip_collection->resolveMultiMatches(
|
||||
m_name, t->m_collections.m_ip_collection_key,
|
||||
@ -56,7 +56,7 @@ class Ip_NoDictElement : public Variable {
|
||||
: Variable("IP") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_ip_collection->resolveMultiMatches("",
|
||||
t->m_collections.m_ip_collection_key,
|
||||
@ -72,7 +72,7 @@ class Ip_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_ip_collection->resolveRegularExpression(
|
||||
m_dictElement, t->m_collections.m_ip_collection_key,
|
||||
@ -90,7 +90,7 @@ class Ip_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_ip_collection->resolveMultiMatches(
|
||||
|
@ -25,7 +25,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void ModsecBuild::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
|
||||
l->push_back(new VariableValue(&m_retName, &m_build));
|
||||
|
@ -44,7 +44,7 @@ class ModsecBuild : public Variable {
|
||||
}
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
|
||||
std::string m_build;
|
||||
|
@ -37,7 +37,7 @@ namespace variables {
|
||||
|
||||
|
||||
void RemoteUser::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
size_t pos;
|
||||
std::string base64;
|
||||
|
@ -37,7 +37,7 @@ class RemoteUser : public Variable {
|
||||
m_retName("REMOTE_USER") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ class Resource_DictElement : public Variable {
|
||||
m_dictElement("RESOURCE:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_resource_collection->resolveMultiMatches(
|
||||
m_name, t->m_collections.m_resource_collection_key,
|
||||
@ -56,7 +56,7 @@ class Resource_NoDictElement : public Variable {
|
||||
: Variable("RESOURCE") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_resource_collection->resolveMultiMatches(m_name,
|
||||
t->m_collections.m_resource_collection_key,
|
||||
@ -72,7 +72,7 @@ class Resource_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_resource_collection->resolveRegularExpression(
|
||||
m_dictElement, t->m_collections.m_resource_collection_key,
|
||||
@ -90,7 +90,7 @@ class Resource_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_resource_collection->resolveMultiMatches(
|
||||
|
@ -38,9 +38,9 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
: VariableDictElement(std::string("RULE"), dictElement) { }
|
||||
|
||||
static void id(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
Rule *r = rule;
|
||||
RuleWithOperator *r = rule;
|
||||
|
||||
while (r && r->m_ruleId == 0) {
|
||||
r = r->m_chainedRuleParent;
|
||||
@ -63,9 +63,9 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
|
||||
|
||||
static void rev(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
Rule *r = rule;
|
||||
RuleWithOperator *r = rule;
|
||||
|
||||
while (r && r->m_rev.empty()) {
|
||||
r = r->m_chainedRuleParent;
|
||||
@ -89,9 +89,9 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
|
||||
|
||||
static void severity(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
Rule *r = rule;
|
||||
RuleWithOperator *r = rule;
|
||||
|
||||
while (r && !r->hasSeverity()) {
|
||||
r = r->m_chainedRuleParent;
|
||||
@ -113,9 +113,9 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
|
||||
|
||||
static void logData(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
Rule *r = rule;
|
||||
RuleWithOperator *r = rule;
|
||||
|
||||
while (r && !r->hasLogData()) {
|
||||
r = r->m_chainedRuleParent;
|
||||
@ -136,9 +136,9 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
}
|
||||
|
||||
static void msg(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
Rule *r = rule;
|
||||
RuleWithOperator *r = rule;
|
||||
|
||||
while (r && !r->hasMsg()) {
|
||||
r = r->m_chainedRuleParent;
|
||||
@ -159,7 +159,7 @@ class Rule_DictElement : public VariableDictElement { \
|
||||
}
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
if (m_dictElement == "id") {
|
||||
id(t, rule, l);
|
||||
@ -198,7 +198,7 @@ class Rule_DictElementRegexp : public VariableRegex {
|
||||
: VariableRegex("RULE", regex) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
if (Utils::regex_search("id", m_r) > 0) {
|
||||
Rule_DictElement::id(t, rule, l);
|
||||
@ -230,7 +230,7 @@ class Rule_NoDictElement : public Variable {
|
||||
: Variable("RULE") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
Rule_DictElement::id(t, rule, l);
|
||||
Rule_DictElement::rev(t, rule, l);
|
||||
|
@ -39,7 +39,7 @@ class Session_DictElement : public Variable {
|
||||
m_dictElement("SESSION:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_session_collection->resolveMultiMatches(
|
||||
m_name, t->m_collections.m_session_collection_key,
|
||||
@ -56,7 +56,7 @@ class Session_NoDictElement : public Variable {
|
||||
: Variable("SESSION") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_session_collection->resolveMultiMatches("",
|
||||
t->m_collections.m_session_collection_key,
|
||||
@ -72,7 +72,7 @@ class Session_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_session_collection->resolveRegularExpression(
|
||||
m_dictElement, t->m_collections.m_session_collection_key,
|
||||
@ -90,7 +90,7 @@ class Session_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_session_collection->resolveMultiMatches(
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void Time::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
|
||||
char tstr[200];
|
||||
|
@ -36,7 +36,7 @@ class Time : public Variable {
|
||||
m_retName("TIME") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeDay::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeDay : public Variable {
|
||||
m_retName("TIME_DAY") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeEpoch::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
transaction->m_variableTimeEpoch.assign(
|
||||
std::to_string(std::time(nullptr)));
|
||||
|
@ -35,7 +35,7 @@ class TimeEpoch : public Variable {
|
||||
m_retName("TIME_EPOCH") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeHour::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeHour : public Variable {
|
||||
m_retName("TIME_HOUR") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeMin::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeMin : public Variable {
|
||||
m_retName("TIME_MIN") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeMon::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeMon : public Variable {
|
||||
m_retName("TIME_MON") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeSec::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeSec : public Variable {
|
||||
m_retName("TIME_SEC") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeWDay::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeWDay : public Variable {
|
||||
m_retName("TIME_WDAY") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ namespace modsecurity {
|
||||
namespace variables {
|
||||
|
||||
void TimeYear::evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
char tstr[200];
|
||||
struct tm timeinfo;
|
||||
|
@ -35,7 +35,7 @@ class TimeYear : public Variable {
|
||||
m_retName("TIME_YEAR") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
std::string m_retName;
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ class Tx_DictElement : public Variable {
|
||||
m_dictElement("TX:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_tx_collection->resolveMultiMatches(
|
||||
m_name, l, m_keyExclusion);
|
||||
@ -55,7 +55,7 @@ class Tx_NoDictElement : public Variable {
|
||||
: Variable("TX") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_tx_collection->resolveMultiMatches("", l,
|
||||
m_keyExclusion);
|
||||
@ -70,7 +70,7 @@ class Tx_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_tx_collection->resolveRegularExpression(
|
||||
m_dictElement, l, m_keyExclusion);
|
||||
@ -87,7 +87,7 @@ class Tx_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_tx_collection->resolveMultiMatches(string, l,
|
||||
|
@ -39,7 +39,7 @@ class User_DictElement : public Variable {
|
||||
m_dictElement("USER:" + dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_user_collection->resolveMultiMatches(
|
||||
m_name, t->m_collections.m_user_collection_key,
|
||||
@ -56,7 +56,7 @@ class User_NoDictElement : public Variable {
|
||||
: Variable("USER") { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_user_collection->resolveMultiMatches(m_name,
|
||||
t->m_collections.m_user_collection_key,
|
||||
@ -72,7 +72,7 @@ class User_DictElementRegexp : public VariableRegex {
|
||||
m_dictElement(dictElement) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
t->m_collections.m_user_collection->resolveRegularExpression(
|
||||
m_dictElement, t->m_collections.m_user_collection_key,
|
||||
@ -90,7 +90,7 @@ class User_DynamicElement : public Variable {
|
||||
m_string(std::move(dictElement)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::string string = m_string->evaluate(t);
|
||||
t->m_collections.m_user_collection->resolveMultiMatches(
|
||||
|
@ -49,7 +49,7 @@ class n ## _DictElementRegexp : public VariableRegex { \
|
||||
: VariableRegex(#N, regex) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
Rule *rule, \
|
||||
RuleWithOperator *rule, \
|
||||
std::vector<const VariableValue *> *l) override { \
|
||||
transaction-> e .resolveRegularExpression(&m_r, l, \
|
||||
m_keyExclusion); \
|
||||
@ -64,7 +64,7 @@ class n ## _DictElement : public VariableDictElement { \
|
||||
: VariableDictElement(#N, dictElement) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
Rule *rule, \
|
||||
RuleWithOperator *rule, \
|
||||
std::vector<const VariableValue *> *l) override { \
|
||||
transaction-> e .resolve(m_dictElement, l); \
|
||||
} \
|
||||
@ -78,7 +78,7 @@ class n ## _NoDictElement : public Variable { \
|
||||
: Variable(#N) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
Rule *rule, \
|
||||
RuleWithOperator *rule, \
|
||||
std::vector<const VariableValue *> *l) override { \
|
||||
transaction-> e .resolve(l, m_keyExclusion); \
|
||||
} \
|
||||
@ -92,7 +92,7 @@ class n : public Variable { \
|
||||
: Variable(#N) { } \
|
||||
\
|
||||
void evaluate(Transaction *transaction, \
|
||||
Rule *rule, \
|
||||
RuleWithOperator *rule, \
|
||||
std::vector<const VariableValue *> *l) override { \
|
||||
transaction-> e .evaluate(l); \
|
||||
} \
|
||||
@ -550,7 +550,7 @@ class Variable : public VariableMonkeyResolution {
|
||||
|
||||
|
||||
virtual void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) = 0;
|
||||
|
||||
|
||||
@ -630,7 +630,7 @@ class VariableModificatorExclusion : public Variable {
|
||||
m_base(std::move(var)) { }
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
m_base->evaluate(t, rule, l);
|
||||
}
|
||||
@ -648,7 +648,7 @@ class VariableModificatorCount : public Variable {
|
||||
}
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
std::vector<const VariableValue *> reslIn;
|
||||
VariableValue *val = NULL;
|
||||
|
@ -36,7 +36,7 @@ class WebAppId : public Variable {
|
||||
: Variable("WEBAPPID") { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
const std::string name("WEBAPPID");
|
||||
const std::string rname = transaction->m_rules->m_secWebAppId.m_value;
|
||||
|
@ -48,12 +48,12 @@ namespace variables {
|
||||
|
||||
#ifndef WITH_LIBXML2
|
||||
void XML::evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) { }
|
||||
#else
|
||||
|
||||
void XML::evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) {
|
||||
xmlXPathContextPtr xpathCtx;
|
||||
xmlXPathObjectPtr xpathObj;
|
||||
|
@ -42,8 +42,8 @@ class XML_NoDictElement : public Variable {
|
||||
m_var(&m_name, &m_plain) {
|
||||
}
|
||||
|
||||
void evaluate(Transaction *t,
|
||||
Rule *rule,
|
||||
void evaluate(Transaction *transaction,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override {
|
||||
l->push_back(new VariableValue(&m_var));
|
||||
}
|
||||
@ -59,7 +59,7 @@ class XML : public Variable {
|
||||
: Variable(_name) { }
|
||||
|
||||
void evaluate(Transaction *transaction,
|
||||
Rule *rule,
|
||||
RuleWithOperator *rule,
|
||||
std::vector<const VariableValue *> *l) override;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user