Adds support for @fuzzyHash

Issue #997
This commit is contained in:
Felipe Zimmerle
2017-10-25 19:11:09 -03:00
parent 4ecfed3163
commit 7622866f97
20 changed files with 1234 additions and 719 deletions

View File

@@ -18,20 +18,38 @@
#include <string>
#include "src/operators/operator.h"
#ifdef WITH_SSDEEP
#include "fuzzy.h"
#endif
#include "src/operators/operator.h"
namespace modsecurity {
namespace operators {
struct fuzzy_hash_chunk {
const char *data;
struct fuzzy_hash_chunk *next;
};
class FuzzyHash : public Operator {
public:
/** @ingroup ModSecurity_Operator */
FuzzyHash(std::string o, std::string p, bool n)
: Operator(o, p, n) { }
: Operator(o, p, n),
m_head(NULL),
m_threshold(0) { }
explicit FuzzyHash(std::string param)
: Operator("FuzzyHash", param) { }
: Operator("FuzzyHash", param),
m_head(NULL),
m_threshold(0) { }
bool evaluate(Transaction *transaction, const std::string &std) override;
bool init(const std::string &param, std::string *error) override;
private:
int m_threshold;
struct fuzzy_hash_chunk *m_head;
};
} // namespace operators