mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +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);
|
ret.assign(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
HtmlEntityDecodeInstantCache::getInstance().emplace(value, ret);
|
HtmlEntityDecodeInstantCache::getInstance().cache(value, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,12 @@ class HtmlEntityDecodeInstantCache : public std::unordered_map<std::string, std:
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cache(const std::string& value, const std::string& out) {
|
||||||
|
emplace(value, out);
|
||||||
|
if (size() > 100) {
|
||||||
|
erase(begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
HtmlEntityDecodeInstantCache() {};
|
HtmlEntityDecodeInstantCache() {};
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,7 @@ std::string LowerCase::evaluate(std::string value,
|
|||||||
value[i] = std::tolower(value[i], loc);
|
value[i] = std::tolower(value[i], loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
LowerCaseInstantCache::getInstance().emplace(orig_value, value);
|
LowerCaseInstantCache::getInstance().cache(orig_value, value);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,12 @@ class LowerCaseInstantCache : public std::unordered_map<std::string, std::string
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cache(const std::string& value, const std::string& out) {
|
||||||
|
emplace(value, out);
|
||||||
|
if (size() > 100) {
|
||||||
|
erase(begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
LowerCaseInstantCache() {};
|
LowerCaseInstantCache() {};
|
||||||
};
|
};
|
||||||
|
@ -116,7 +116,7 @@ std::string UrlDecode::evaluate(std::string value,
|
|||||||
|
|
||||||
free(val);
|
free(val);
|
||||||
|
|
||||||
UrlDecodeInstantCache::getInstance().emplace(value, out);
|
UrlDecodeInstantCache::getInstance().cache(value, out);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,12 @@ class UrlDecodeInstantCache : public std::unordered_map<std::string, std::string
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cache(const std::string& value, const std::string& out) {
|
||||||
|
emplace(value, out);
|
||||||
|
if (size() > 100) {
|
||||||
|
erase(begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
UrlDecodeInstantCache() {};
|
UrlDecodeInstantCache() {};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user