Adds support to @ipMatch operator

This commit is contained in:
Felipe Zimmerle
2015-07-30 20:57:23 -03:00
parent bf0169b528
commit f811ec6518
8 changed files with 1402 additions and 14 deletions

View File

@@ -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

View File

@@ -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