Fix SecRuleUpdateTargetByTag with regular expressions

This commit is contained in:
Felipe Zimmerle
2019-05-31 01:02:31 -03:00
parent b5823d4e0c
commit 5472362313
2 changed files with 128 additions and 4 deletions

View File

@@ -106,7 +106,7 @@ namespace variables {
class KeyExclusion {
public:
virtual bool match(std::string &a) = 0;
virtual bool match(const std::string &a) = 0;
virtual ~KeyExclusion() { }
};
@@ -121,7 +121,7 @@ class KeyExclusionRegex : public KeyExclusion {
~KeyExclusionRegex() override { }
bool match(std::string &a) override {
bool match(const std::string &a) override {
return m_re.searchAll(a).size() > 0;
}
@@ -136,7 +136,7 @@ class KeyExclusionString : public KeyExclusion {
~KeyExclusionString() override { }
bool match(std::string &a) override {
bool match(const std::string &a) override {
return a.size() == m_key.size() && std::equal(a.begin(), a.end(),
m_key.begin(),
[](char aa, char bb) {
@@ -608,6 +608,10 @@ class Variables : public std::vector<Variable *> {
bool contains(const std::string &v) {
return std::find_if(begin(), end(),
[v](Variable *m) -> bool {
VariableRegex *r = dynamic_cast<VariableRegex *>(m);
if (r) {
return r->m_r.searchAll(v).size() > 0;
}
return v == *m->m_fullName.get();
}) != end();
};