From 170cb60c8285140f92819c4e1a4ff89757294fb6 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Mon, 27 Jul 2015 16:12:04 -0300 Subject: [PATCH] Adds support to the @streq operator --- src/operators/str_eq.cc | 18 +++++++----------- src/operators/str_eq.h | 4 +++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/operators/str_eq.cc b/src/operators/str_eq.cc index 96a83889..2b6494aa 100644 --- a/src/operators/str_eq.cc +++ b/src/operators/str_eq.cc @@ -21,19 +21,15 @@ namespace ModSecurity { namespace operators { bool StrEq::evaluate(Assay *assay, const std::string &str) { - /** - * @todo Implement the operator StrEq. - * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#streq - */ - return !this->param.compare(str); + bool eq = !this->param.compare(str); + + if (negation) { + return !eq; + } + + return eq; } -StrEq::StrEq(std::string op, std::string param, bool negation) - : Operator() { - this->op = op; - this->param = param; -} - } // namespace operators } // namespace ModSecurity diff --git a/src/operators/str_eq.h b/src/operators/str_eq.h index 550a159f..b1fa5461 100644 --- a/src/operators/str_eq.h +++ b/src/operators/str_eq.h @@ -30,7 +30,9 @@ namespace operators { class StrEq : public Operator { public: /** @ingroup ModSecurity_Operator */ - StrEq(std::string o, std::string p, bool i); + StrEq(std::string op, std::string param, bool negation) + : Operator(op, param, negation) { } + bool evaluate(Assay *assay, const std::string &str) override; };