From 35901c1ebedbe228e5fe21cfd7e69ba36b8e9870 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Mon, 27 Jul 2015 16:07:39 -0300 Subject: [PATCH] Adds support to the operator ge --- src/operators/ge.cc | 20 +++++++------------- src/operators/ge.h | 6 ++++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/operators/ge.cc b/src/operators/ge.cc index c86578dc..cc254759 100644 --- a/src/operators/ge.cc +++ b/src/operators/ge.cc @@ -22,22 +22,16 @@ namespace ModSecurity { namespace operators { -bool Ge::evaluate(Assay *assay) { - /** - * @todo Implement the operator Ge. - * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#ge - */ +bool Ge::evaluate(Assay *assay, const std::string &input) { + bool ge = atoll(input.c_str()) >= atoll(param.c_str()); - return true; + if (negation) { + return !ge; + } + + return ge; } -Ge::Ge(std::string op, std::string param, - bool negation) - : Operator() { - this->op = op; - this->param = param; -} - } // namespace operators } // namespace ModSecurity diff --git a/src/operators/ge.h b/src/operators/ge.h index 2d491da2..a4571e65 100644 --- a/src/operators/ge.h +++ b/src/operators/ge.h @@ -27,8 +27,10 @@ namespace operators { class Ge : public Operator { public: /** @ingroup ModSecurity_Operator */ - Ge(std::string o, std::string p, bool i); - bool evaluate(Assay *assay); + Ge(std::string op, std::string param, bool negation) + : Operator(op, param, negation) { } + + bool evaluate(Assay *assay, const std::string &input) override; }; } // namespace operators