mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
cosmetics: Having the parser in a better shape regarding operators 1/2
This commit is contained in:
committed by
Felipe Zimmerle
parent
3a413080f9
commit
9cda4c0be0
@@ -31,6 +31,10 @@ class DetectSQLi : public Operator {
|
||||
: Operator(op, param, negation) {
|
||||
m_match_message.assign("detected SQLi using libinjection.");
|
||||
}
|
||||
DetectSQLi()
|
||||
: Operator("DetectSQLi") {
|
||||
m_match_message.assign("detected SQLi using libinjection.");
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
};
|
||||
|
@@ -30,6 +30,10 @@ class DetectXSS : public Operator {
|
||||
: Operator(op, param, negation) {
|
||||
m_match_message.assign("detected XSS using libinjection.");
|
||||
}
|
||||
DetectXSS()
|
||||
: Operator("DetectXSS") {
|
||||
m_match_message.assign("detected XSS using libinjection.");
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input);
|
||||
};
|
||||
|
@@ -93,12 +93,6 @@ bool GeoLookup::evaluate(Transaction *trans, const std::string &exp) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
GeoLookup::GeoLookup(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -27,7 +27,10 @@ namespace operators {
|
||||
class GeoLookup : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
GeoLookup(std::string o, std::string p, bool i);
|
||||
GeoLookup(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
GeoLookup(std::string param)
|
||||
: Operator("GeoLookup", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
};
|
||||
|
||||
|
@@ -35,12 +35,25 @@ class Operator {
|
||||
m_negation(false),
|
||||
m_op(""),
|
||||
m_param("") { }
|
||||
Operator(std::string op, std::string param, bool negation)
|
||||
|
||||
Operator(std::string opName, std::string param, bool negation)
|
||||
: m_match_message(""),
|
||||
m_negation(negation),
|
||||
m_op(op),
|
||||
m_op(opName),
|
||||
m_param(param) { }
|
||||
|
||||
Operator(std::string opName, std::string param)
|
||||
: m_match_message(""),
|
||||
m_negation(false),
|
||||
m_op(opName),
|
||||
m_param(param) { }
|
||||
|
||||
Operator(std::string opName)
|
||||
: m_match_message(""),
|
||||
m_negation(false),
|
||||
m_op(opName),
|
||||
m_param() { }
|
||||
|
||||
virtual ~Operator() { }
|
||||
static Operator *instantiate(std::string opName);
|
||||
|
||||
|
@@ -38,6 +38,10 @@ class Rx : public Operator {
|
||||
: Operator(op, param, negation) {
|
||||
m_re = new Regex(param);
|
||||
}
|
||||
Rx(std::string name, std::string param)
|
||||
: Operator(name, param) {
|
||||
m_re = new Regex(param);
|
||||
}
|
||||
|
||||
~Rx() {
|
||||
delete m_re;
|
||||
|
@@ -20,9 +20,7 @@ namespace operators {
|
||||
|
||||
bool UnconditionalMatch::evaluate(Transaction *transaction,
|
||||
const std::string &input) {
|
||||
bool contains = true;
|
||||
|
||||
return contains;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -31,13 +30,14 @@ class UnconditionalMatch : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
UnconditionalMatch(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
UnconditionalMatch()
|
||||
: Operator("UnconditionalMatch") { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_UNCONDITIONAL_MATCH_H_
|
||||
|
@@ -29,6 +29,8 @@ class ValidateUrlEncoding : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
ValidateUrlEncoding(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
ValidateUrlEncoding()
|
||||
: Operator("ValidateUrlEncoding") { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
int validate_url_encoding(const char *input, uint64_t input_length);
|
||||
|
@@ -36,6 +36,8 @@ class ValidateUtf8Encoding : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
ValidateUtf8Encoding(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
ValidateUtf8Encoding()
|
||||
: Operator("ValidateUtf8Encoding") { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
|
||||
|
Reference in New Issue
Block a user