mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds support to the operator @ipMatchFromFile and @ipMatchF
This commit is contained in:
@@ -33,9 +33,9 @@ class IpMatch : public Operator {
|
||||
|
||||
bool evaluate(Assay *assay, const std::string &input);
|
||||
|
||||
bool init(const char **error);
|
||||
virtual bool init(const char **error);
|
||||
|
||||
private:
|
||||
protected:
|
||||
Utils::IpTree m_tree;
|
||||
};
|
||||
|
||||
|
@@ -22,21 +22,6 @@
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
bool IpMatchF::evaluate(Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the operator IpMatchF.
|
||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatchf
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IpMatchF::IpMatchF(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->op = op;
|
||||
this->param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace ModSecurity
|
||||
|
@@ -18,17 +18,16 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "operators/operator.h"
|
||||
#include "operators/ip_match_from_file.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
class IpMatchF : public Operator {
|
||||
class IpMatchF : public IpMatchFromFile {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
IpMatchF(std::string p, std::string o, bool i);
|
||||
bool evaluate(Assay *assay);
|
||||
IpMatchF(std::string op, std::string param, bool negation)
|
||||
: IpMatchFromFile(op, param, negation) { }
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
@@ -22,21 +22,24 @@
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
bool IpMatchFromFile::evaluate(Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the operator IpMatchFromFile.
|
||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatchfromfile
|
||||
*/
|
||||
return true;
|
||||
|
||||
bool IpMatchFromFile::init(const char **error) {
|
||||
std::string e("");
|
||||
bool res = false;
|
||||
|
||||
if (param.compare(0, 8, "https://") == 0) {
|
||||
res = m_tree.addFromUrl(param, &e);
|
||||
} else {
|
||||
res = m_tree.addFromFile(param, &e);
|
||||
}
|
||||
|
||||
if (res == false) {
|
||||
*error = e.c_str();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
IpMatchFromFile::IpMatchFromFile(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->op = op;
|
||||
this->param = param;
|
||||
}
|
||||
|
||||
} // namespace operators
|
||||
} // namespace ModSecurity
|
||||
|
@@ -17,17 +17,19 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "operators/operator.h"
|
||||
#include "operators/ip_match.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
class IpMatchFromFile : public Operator {
|
||||
class IpMatchFromFile : public IpMatch {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
IpMatchFromFile(std::string o, std::string p, bool i);
|
||||
bool evaluate(Assay *assay);
|
||||
IpMatchFromFile(std::string op, std::string param, bool negation)
|
||||
: IpMatch(op, param, negation) { }
|
||||
|
||||
bool init(const char **error) override;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
Reference in New Issue
Block a user