From 47233adf3ba603eac1cd833426d18a364dd40722 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Fri, 13 Nov 2015 22:38:09 +0200 Subject: [PATCH] Revert "Adds experimental operator cache" This reverts commit 326696976fe0bb0f536a910d0038e8fe8bbdaa34. --- src/rule.cc | 13 ++----------- src/rule.h | 18 ------------------ 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/rule.cc b/src/rule.cc index 7d626757..f8cb476c 100644 --- a/src/rule.cc +++ b/src/rule.cc @@ -257,13 +257,9 @@ bool Rule::evaluate(Assay *assay) { return evaluateActions(assay); } - std::string eparam = MacroExpansion::expand(this->op->param, assay); - std::string cache_key = eparam + this->op->op + Variable::to_s(variables) + std::to_string(rule_id); - if (RuleInstantCache::getInstance().count(cache_key) > 0) { - return 0; - } - #ifndef NO_LOGS + std::string eparam = MacroExpansion::expand(this->op->param, assay); + if (this->op->param != eparam) { eparam = "\"" + eparam + "\" Was: \"" + this->op->param + "\""; } else { @@ -494,11 +490,6 @@ bool Rule::evaluate(Assay *assay) { } //delete e; } - - if (ret == 0) { - RuleInstantCache::getInstance().cache(cache_key); - } - return ret; } diff --git a/src/rule.h b/src/rule.h index a256b4b6..a7a305a0 100644 --- a/src/rule.h +++ b/src/rule.h @@ -29,24 +29,6 @@ namespace ModSecurity { -class RuleInstantCache : public std::unordered_map { - public: - static RuleInstantCache& getInstance() { - static RuleInstantCache instance; - return instance; - } - - void cache(const std::string& value) { - emplace(value, 1); - if (size() > 1500) { - erase(begin()); - } - } - private: - RuleInstantCache() {}; -}; - - class Rule { public: Rule(operators::Operator *_op,