mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 03:34:29 +03:00
Adds support to @ipMatch operator
This commit is contained in:
@@ -15,29 +15,32 @@
|
||||
|
||||
#include "operators/ip_match.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "utils/msc_tree.h"
|
||||
#include "operators/operator.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
bool IpMatch::evaluate(Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the operator IpMatch.
|
||||
* Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ipmatch
|
||||
*/
|
||||
|
||||
return true;
|
||||
bool IpMatch::init(const char **error) {
|
||||
std::string e("");
|
||||
bool res = m_tree.addFromBuffer(param, &e);
|
||||
|
||||
if (res == false) {
|
||||
*error = e.c_str();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
IpMatch::IpMatch(std::string op, std::string param,
|
||||
bool negation)
|
||||
: Operator() {
|
||||
this->op = op;
|
||||
this->param = param;
|
||||
bool IpMatch::evaluate(Assay *assay, const std::string &input) {
|
||||
return m_tree.contains(input);
|
||||
}
|
||||
|
||||
|
||||
} // namespace operators
|
||||
} // namespace ModSecurity
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "operators/operator.h"
|
||||
#include "utils/ip_tree.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace ModSecurity {
|
||||
@@ -27,8 +28,15 @@ namespace operators {
|
||||
class IpMatch : public Operator {
|
||||
public:
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
IpMatch(std::string o, std::string p, bool i);
|
||||
bool evaluate(Assay *assay);
|
||||
IpMatch(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation) { }
|
||||
|
||||
bool evaluate(Assay *assay, const std::string &input);
|
||||
|
||||
bool init(const char **error);
|
||||
|
||||
private:
|
||||
Utils::IpTree m_tree;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
Reference in New Issue
Block a user