mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Limit the amount of transformations inside the cache storage
This commit is contained in:
parent
5bef19aa4d
commit
45638ccc91
@ -47,7 +47,7 @@ std::string HtmlEntityDecode::evaluate(std::string value,
|
||||
ret.assign(tmp);
|
||||
free(tmp);
|
||||
|
||||
HtmlEntityDecodeInstantCache::getInstance().emplace(value, ret);
|
||||
HtmlEntityDecodeInstantCache::getInstance().cache(value, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ class HtmlEntityDecodeInstantCache : public std::unordered_map<std::string, std:
|
||||
return instance;
|
||||
}
|
||||
|
||||
void cache(const std::string& value, const std::string& out) {
|
||||
emplace(value, out);
|
||||
if (size() > 100) {
|
||||
erase(begin());
|
||||
}
|
||||
}
|
||||
private:
|
||||
HtmlEntityDecodeInstantCache() {};
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ std::string LowerCase::evaluate(std::string value,
|
||||
value[i] = std::tolower(value[i], loc);
|
||||
}
|
||||
|
||||
LowerCaseInstantCache::getInstance().emplace(orig_value, value);
|
||||
LowerCaseInstantCache::getInstance().cache(orig_value, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -36,6 +36,12 @@ class LowerCaseInstantCache : public std::unordered_map<std::string, std::string
|
||||
return instance;
|
||||
}
|
||||
|
||||
void cache(const std::string& value, const std::string& out) {
|
||||
emplace(value, out);
|
||||
if (size() > 100) {
|
||||
erase(begin());
|
||||
}
|
||||
}
|
||||
private:
|
||||
LowerCaseInstantCache() {};
|
||||
};
|
||||
|
@ -116,7 +116,7 @@ std::string UrlDecode::evaluate(std::string value,
|
||||
|
||||
free(val);
|
||||
|
||||
UrlDecodeInstantCache::getInstance().emplace(value, out);
|
||||
UrlDecodeInstantCache::getInstance().cache(value, out);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -36,6 +36,12 @@ class UrlDecodeInstantCache : public std::unordered_map<std::string, std::string
|
||||
return instance;
|
||||
}
|
||||
|
||||
void cache(const std::string& value, const std::string& out) {
|
||||
emplace(value, out);
|
||||
if (size() > 100) {
|
||||
erase(begin());
|
||||
}
|
||||
}
|
||||
private:
|
||||
UrlDecodeInstantCache() {};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user