mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Revert "Adds experimental operator cache"
This reverts commit 326696976fe0bb0f536a910d0038e8fe8bbdaa34.
This commit is contained in:
parent
4dcefa104d
commit
47233adf3b
13
src/rule.cc
13
src/rule.cc
@ -257,13 +257,9 @@ bool Rule::evaluate(Assay *assay) {
|
|||||||
return evaluateActions(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
|
#ifndef NO_LOGS
|
||||||
|
std::string eparam = MacroExpansion::expand(this->op->param, assay);
|
||||||
|
|
||||||
if (this->op->param != eparam) {
|
if (this->op->param != eparam) {
|
||||||
eparam = "\"" + eparam + "\" Was: \"" + this->op->param + "\"";
|
eparam = "\"" + eparam + "\" Was: \"" + this->op->param + "\"";
|
||||||
} else {
|
} else {
|
||||||
@ -494,11 +490,6 @@ bool Rule::evaluate(Assay *assay) {
|
|||||||
}
|
}
|
||||||
//delete e;
|
//delete e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
RuleInstantCache::getInstance().cache(cache_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
src/rule.h
18
src/rule.h
@ -29,24 +29,6 @@
|
|||||||
|
|
||||||
namespace ModSecurity {
|
namespace ModSecurity {
|
||||||
|
|
||||||
class RuleInstantCache : public std::unordered_map<std::string, int> {
|
|
||||||
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 {
|
class Rule {
|
||||||
public:
|
public:
|
||||||
Rule(operators::Operator *_op,
|
Rule(operators::Operator *_op,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user