From 7b4554216e95191e52f2a2a527450088dcd9e8d0 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Mon, 27 Jul 2015 16:19:26 -0300 Subject: [PATCH] Adds support to the operator le --- src/operators/le.cc | 20 ++++++++------------ src/operators/le.h | 6 ++++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/operators/le.cc b/src/operators/le.cc index f5c8a2dd..cfa33b6d 100644 --- a/src/operators/le.cc +++ b/src/operators/le.cc @@ -22,20 +22,16 @@ namespace ModSecurity { namespace operators { -bool Le::evaluate(Assay *assay) { - /** - * @todo Implement the operator Le. - * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#le - */ - return true; +bool Le::evaluate(Assay *assay, const std::string &input) { + bool le = atoll(input.c_str()) <= atoll(param.c_str()); + + if (negation) { + return !le; + } + + return le; } -Le::Le(std::string op, std::string param, bool negation) - : Operator() { - this->op = op; - this->param = param; -} - } // namespace operators } // namespace ModSecurity diff --git a/src/operators/le.h b/src/operators/le.h index 18fb084c..63d23011 100644 --- a/src/operators/le.h +++ b/src/operators/le.h @@ -27,8 +27,10 @@ namespace operators { class Le : public Operator { public: /** @ingroup ModSecurity_Operator */ - Le(std::string o, std::string p, bool i); - bool evaluate(Assay *assay); + Le(std::string op, std::string param, bool negation) + : Operator(op, param, negation) { } + + bool evaluate(Assay *assay, const std::string &input) override; };