mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Refactoring on the operators parsers (2/2)
This is the first step towards remove the memory leaks in the parser
This commit is contained in:
committed by
Felipe Zimmerle
parent
9cda4c0be0
commit
59114dd598
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,13 +29,14 @@ class BeginsWith : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
BeginsWith(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
explicit BeginsWith(std::string param)
|
||||
: Operator("BeginsWith", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_BEGINS_WITH_H_
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -31,13 +31,13 @@ class Contains : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Contains(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit Contains(std::string param)
|
||||
: Operator("Contains", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_CONTAINS_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,7 +29,8 @@ class ContainsWord : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
ContainsWord(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit ContainsWord(std::string param)
|
||||
: Operator("ContainsWord", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str);
|
||||
|
||||
bool acceptableChar(const std::string& a, size_t pos);
|
||||
@@ -38,7 +39,5 @@ class ContainsWord : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_CONTAINS_WORD_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,14 +29,14 @@ class EndsWith : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
EndsWith(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit EndsWith(std::string param)
|
||||
: Operator("EndsWith", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_ENDS_WITH_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,13 +29,13 @@ class Eq : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Eq(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit Eq(std::string param)
|
||||
: Operator("Eq", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_EQ_H_
|
||||
|
@@ -31,12 +31,5 @@ bool FuzzyHash::evaluate(Transaction *transaction, const std::string &str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
FuzzyHash::FuzzyHash(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,21 +20,22 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
class FuzzyHash : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
FuzzyHash(std::string o, std::string p, bool i);
|
||||
FuzzyHash(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit FuzzyHash(std::string param)
|
||||
: Operator("FuzzyHash", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &std) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_FUZZY_HASH_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,13 +29,13 @@ class Ge : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Ge(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit Ge(std::string param)
|
||||
: Operator("Ge", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_GE_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,14 +29,15 @@ class GeoLookup : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
GeoLookup(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
GeoLookup(std::string param)
|
||||
explicit GeoLookup(std::string param)
|
||||
: Operator("GeoLookup", param) { }
|
||||
GeoLookup()
|
||||
: Operator("GeoLookup") { }
|
||||
bool evaluate(Transaction *transaction, const std::string &exp) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_GEO_LOOKUP_H_
|
||||
|
@@ -22,6 +22,7 @@
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool GsbLookup::evaluate(Transaction *transaction, const std::string &str) {
|
||||
/**
|
||||
* @todo Implement the operator GeoLookup.
|
||||
@@ -31,12 +32,5 @@ bool GsbLookup::evaluate(Transaction *transaction, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
GsbLookup::GsbLookup(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,21 +20,22 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
class GsbLookup : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
GsbLookup(std::string o, std::string p, bool i);
|
||||
GsbLookup(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit GsbLookup(std::string param)
|
||||
: Operator("GsbLookup", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &str);
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_GSBLOOKUP_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,12 +29,13 @@ class Gt : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Gt(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
explicit Gt(std::string param)
|
||||
: Operator("Gt", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_GT_H_
|
||||
|
@@ -31,12 +31,5 @@ bool InspectFile::evaluate(Transaction *transaction, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
InspectFile::InspectFile(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,20 +20,23 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
class InspectFile : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
InspectFile(std::string o, std::string p, bool i);
|
||||
InspectFile(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit InspectFile(std::string param)
|
||||
: Operator("InspectFile", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_INSPECT_FILE_H_
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/ip_tree.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -30,7 +29,10 @@ class IpMatch : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
IpMatch(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
IpMatch(std::string op, std::string param)
|
||||
: Operator(op, param) { }
|
||||
explicit IpMatch(std::string param)
|
||||
: Operator("IpMatch", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
|
||||
bool init(const std::string &file, std::string *error) override;
|
||||
@@ -41,7 +43,6 @@ class IpMatch : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_IP_MATCH_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/ip_match_from_file.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -28,11 +28,12 @@ class IpMatchF : public IpMatchFromFile {
|
||||
public:
|
||||
IpMatchF(std::string op, std::string param, bool negation)
|
||||
: IpMatchFromFile(op, param, negation) { }
|
||||
explicit IpMatchF(std::string param)
|
||||
: IpMatchFromFile("IpMatchFromFile", param) { }
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_IP_MATCH_F_H_
|
||||
|
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "src/operators/ip_match.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -28,13 +27,14 @@ class IpMatchFromFile : public IpMatch {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
IpMatchFromFile(std::string op, std::string param, bool negation)
|
||||
: IpMatch(op, param, negation) { }
|
||||
IpMatchFromFile(std::string op, std::string param)
|
||||
: IpMatch(op, param) { }
|
||||
|
||||
bool init(const std::string& file, std::string *error) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_IP_MATCH_FROM_FILE_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,6 +29,8 @@ class Le : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Le(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
explicit Le(std::string param)
|
||||
: Operator("Le", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
@@ -37,7 +39,5 @@ class Le : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_LE_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,6 +29,8 @@ class Lt : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Lt(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
explicit Lt(std::string param)
|
||||
: Operator("Lt", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
@@ -36,7 +38,5 @@ class Lt : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_LT_H_
|
||||
|
@@ -13,9 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#ifndef SRC_OPERATORS_OPERATOR_H__
|
||||
#define SRC_OPERATORS_OPERATOR_H__
|
||||
@@ -23,7 +21,7 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -48,7 +46,7 @@ class Operator {
|
||||
m_op(opName),
|
||||
m_param(param) { }
|
||||
|
||||
Operator(std::string opName)
|
||||
explicit Operator(std::string opName)
|
||||
: m_match_message(""),
|
||||
m_negation(false),
|
||||
m_op(opName),
|
||||
@@ -82,7 +80,6 @@ class Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_OPERATOR_H__
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/acmp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -34,6 +34,14 @@ class Pm : public Operator {
|
||||
: Operator(op, param, negation) {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
Pm(std::string op, std::string param)
|
||||
: Operator(op, param) {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
explicit Pm(std::string param)
|
||||
: Operator("Pm", param) {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
~Pm();
|
||||
bool evaluate(Transaction *transaction, Rule *rule,
|
||||
const std::string &input) override;
|
||||
@@ -53,7 +61,6 @@ class Pm : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_PM_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/pm_from_file.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -35,7 +35,6 @@ class PmF : public PmFromFile {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_PM_F_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/pm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -30,7 +30,8 @@ class PmFromFile : public Pm {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
PmFromFile(std::string op, std::string param, bool negation)
|
||||
: Pm(op, param, negation) { }
|
||||
|
||||
explicit PmFromFile(std::string param)
|
||||
: Pm("PmFromFile", param) { }
|
||||
bool init(const std::string &file, std::string *error) override;
|
||||
};
|
||||
|
||||
@@ -38,7 +39,5 @@ class PmFromFile : public Pm {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_PM_FROM_FILE_H_
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
@@ -74,7 +73,20 @@ class Rbl : public Operator {
|
||||
m_provider = RblProvider::httpbl;
|
||||
}
|
||||
}
|
||||
|
||||
explicit Rbl(std::string param)
|
||||
: Operator("Rbl", param),
|
||||
m_service(param),
|
||||
m_demandsPassword(false) {
|
||||
m_provider = RblProvider::UnknownProvider;
|
||||
if (m_service == "httpbl.org") {
|
||||
m_demandsPassword = true;
|
||||
m_provider = RblProvider::httpbl;
|
||||
} else if (m_service == "uribl.com") {
|
||||
m_provider = RblProvider::httpbl;
|
||||
} else if (m_service == "spamhaus.org") {
|
||||
m_provider = RblProvider::httpbl;
|
||||
}
|
||||
}
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
|
||||
std::string mapIpToAddress(std::string ipStr, Transaction *trans);
|
||||
@@ -95,7 +107,6 @@ class Rbl : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_RBL_H_
|
||||
|
@@ -22,6 +22,7 @@
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool Rsub::evaluate(Transaction *transaction, const std::string &str) {
|
||||
/**
|
||||
* @todo Implement the operator Rsub.
|
||||
@@ -31,11 +32,5 @@ bool Rsub::evaluate(Transaction *transaction, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
Rsub::Rsub(std::string op, std::string param, bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,19 +20,24 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
class Rsub : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Rsub(std::string o, std::string p, bool i);
|
||||
Rsub(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit Rsub(std::string param)
|
||||
: Operator("Rsub", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_RSUB_H_
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/regex.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
using Utils::SMatch;
|
||||
using Utils::regex_search;
|
||||
@@ -42,6 +42,10 @@ class Rx : public Operator {
|
||||
: Operator(name, param) {
|
||||
m_re = new Regex(param);
|
||||
}
|
||||
explicit Rx(std::string param)
|
||||
: Operator("Rx", param) {
|
||||
m_re = new Regex(param);
|
||||
}
|
||||
|
||||
~Rx() {
|
||||
delete m_re;
|
||||
@@ -61,7 +65,5 @@ class Rx : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_RX_H_
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#define SRC_OPERATORS_STR_EQ_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -32,6 +31,8 @@ class StrEq : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
StrEq(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
explicit StrEq(std::string param)
|
||||
: Operator("StrEq", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
@@ -39,7 +40,5 @@ class StrEq : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_STR_EQ_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,13 +29,14 @@ class StrMatch : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
StrMatch(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
explicit StrMatch(std::string param)
|
||||
: Operator("StrMatch", param) { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_STR_MATCH_H_
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -33,7 +33,10 @@ class ValidateByteRange : public Operator {
|
||||
: Operator(op, param, negation) {
|
||||
std::memset(table, '\0', sizeof(char) * 32);
|
||||
}
|
||||
|
||||
explicit ValidateByteRange(std::string param)
|
||||
: Operator("ValidadeByteRange", param) {
|
||||
std::memset(table, '\0', sizeof(char) * 32);
|
||||
}
|
||||
~ValidateByteRange() override { }
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &input) override;
|
||||
@@ -47,7 +50,5 @@ class ValidateByteRange : public Operator {
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -36,6 +36,8 @@ class ValidateDTD : public Operator {
|
||||
ValidateDTD(std::string o, std::string p, bool i)
|
||||
: Operator(o, p, i),
|
||||
m_dtd(NULL) { }
|
||||
explicit ValidateDTD(std::string param)
|
||||
: Operator("ValidateDTD", param) { }
|
||||
~ValidateDTD() {
|
||||
if (m_dtd != NULL) {
|
||||
xmlFreeDtd(m_dtd);
|
||||
@@ -91,7 +93,6 @@ class ValidateDTD : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VALIDATE_DTD_H_
|
||||
|
@@ -31,11 +31,5 @@ bool ValidateHash::evaluate(Transaction *transaction, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
ValidateHash::ValidateHash(std::string op, std::string param, bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,20 +20,22 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
class ValidateHash : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
ValidateHash(std::string o, std::string p, bool i);
|
||||
ValidateHash(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit ValidateHash(std::string param)
|
||||
: Operator("ValidateHash", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VALIDATE_HASH_H_
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -38,6 +38,11 @@ class ValidateSchema : public Operator {
|
||||
m_parserCtx(NULL),
|
||||
m_validCtx(NULL),
|
||||
m_schema(NULL) { }
|
||||
explicit ValidateSchema(std::string param)
|
||||
: Operator("ValidateSchema", param),
|
||||
m_parserCtx(NULL),
|
||||
m_validCtx(NULL),
|
||||
m_schema(NULL) { }
|
||||
~ValidateSchema() {
|
||||
/*
|
||||
if (m_schema != NULL) {
|
||||
@@ -131,7 +136,6 @@ class ValidateSchema : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VALIDATE_SCHEMA_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -38,7 +38,6 @@ class ValidateUrlEncoding : public Operator {
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VALIDATE_URL_ENCODING_H_
|
||||
|
@@ -31,6 +31,10 @@ class VerifyCC : public Operator {
|
||||
: Operator(op, param, negation),
|
||||
m_pc(NULL),
|
||||
m_pce(NULL) { }
|
||||
explicit VerifyCC(std::string param)
|
||||
: Operator("VerifyCC", param),
|
||||
m_pc(NULL),
|
||||
m_pce(NULL) { }
|
||||
~VerifyCC();
|
||||
|
||||
int luhnVerify(const char *ccnumber, int len);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool VerifyCPF::evaluate(Transaction *transaction, const std::string &str) {
|
||||
/**
|
||||
* @todo Implement the operator VerifyCPF.
|
||||
@@ -31,11 +32,5 @@ bool VerifyCPF::evaluate(Transaction *transaction, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
VerifyCPF::VerifyCPF(std::string op, std::string param, bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,21 +20,24 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
class VerifyCPF : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
VerifyCPF(std::string o, std::string p, bool i);
|
||||
VerifyCPF(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit VerifyCPF(std::string param)
|
||||
: Operator("VerifyCPF", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VERIFY_CPF_H_
|
||||
|
@@ -22,6 +22,7 @@
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
bool VerifySSN::evaluate(Transaction *transaction, const std::string &str) {
|
||||
/**
|
||||
* @todo Implement the operator VerifySSN.
|
||||
@@ -30,11 +31,6 @@ bool VerifySSN::evaluate(Transaction *transaction, const std::string &str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
VerifySSN::VerifySSN(std::string op, std::string param, bool negation)
|
||||
: Operator() {
|
||||
this->m_op = op;
|
||||
this->m_param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
|
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
@@ -28,13 +27,15 @@ namespace operators {
|
||||
class VerifySSN : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
VerifySSN(std::string o, std::string p, bool i);
|
||||
VerifySSN(std::string o, std::string p, bool n)
|
||||
: Operator(o, p, n) { }
|
||||
explicit VerifySSN(std::string param)
|
||||
: Operator("VerifySSN", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_VERIFY_SSN_H_
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
@@ -29,13 +29,13 @@ class Within : public Operator {
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Within(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
explicit Within(std::string param)
|
||||
: Operator("Within", param) { }
|
||||
bool evaluate(Transaction *transaction, const std::string &str);
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SRC_OPERATORS_WITHIN_H_
|
||||
|
Reference in New Issue
Block a user