diff --git a/src/collection/backend/in_memory-per_process.cc b/src/collection/backend/in_memory-per_process.cc index 486655a1..65e3371d 100644 --- a/src/collection/backend/in_memory-per_process.cc +++ b/src/collection/backend/in_memory-per_process.cc @@ -105,9 +105,10 @@ void InMemoryPerProcess::resolveMultiMatches(const std::string& var, l->insert(l->begin(), new VariableValue(&m_name, &i.first, &i.second)); } } else { - auto range = this->equal_range(var); - for (auto it = range.first; it != range.second; ++it) { - l->insert(l->begin(), new VariableValue(&m_name, &var, &it->second)); + for (auto &a : *this) { + if (a.first.compare(0, var.size(), var) == 0) { + l->insert(l->begin(), new VariableValue(&m_name, &var, &a.second)); + } } } } @@ -116,7 +117,6 @@ void InMemoryPerProcess::resolveMultiMatches(const std::string& var, void InMemoryPerProcess::resolveRegularExpression(const std::string& var, std::vector *l) { - //if (var.find(":") == std::string::npos) { // return; //} diff --git a/src/variables/global.h b/src/variables/global.h index 0d396df6..5e6c16ed 100644 --- a/src/variables/global.h +++ b/src/variables/global.h @@ -34,14 +34,15 @@ namespace Variables { class Global_DictElement : public Variable { public: explicit Global_DictElement(std::string dictElement) - : Variable("GLOBAL"), - m_dictElement(dictElement) { } + : Variable("GLOBAL:" + dictElement), + m_dictElement("GLOBAL:" + dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { t->m_collections.m_global_collection->resolveMultiMatches( - m_dictElement, t->m_collections.m_global_collection_key, l); + m_name, t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } std::string m_dictElement; @@ -56,8 +57,9 @@ class Global_NoDictElement : public Variable { void evaluate(Transaction *t, Rule *rule, std::vector *l) override { - t->m_collections.m_global_collection->resolveMultiMatches(m_name, - t->m_collections.m_global_collection_key, l); + t->m_collections.m_global_collection->resolveMultiMatches("", + t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } }; @@ -73,7 +75,9 @@ class Global_DictElementRegexp : public Variable { Rule *rule, std::vector *l) override { t->m_collections.m_global_collection->resolveRegularExpression( - m_dictElement, t->m_collections.m_global_collection_key, l); + m_dictElement, + t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } Utils::Regex m_r; @@ -92,19 +96,24 @@ class Global_DynamicElement : public Variable { std::vector *l) override { std::string string = m_string->evaluate(t); t->m_collections.m_global_collection->resolveMultiMatches( - string, t->m_collections.m_global_collection_key, l); + string, + t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } void del(Transaction *t, std::string k) { t->m_collections.m_global_collection->del(k, - t->m_collections.m_global_collection_key); + t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value); } void storeOrUpdateFirst(Transaction *t, std::string var, std::string value) { t->m_collections.m_global_collection->storeOrUpdateFirst( - var, t->m_collections.m_global_collection_key, value); + var, t->m_collections.m_global_collection_key, + t->m_rules->m_secWebAppId.m_value, + value); } std::unique_ptr m_string; diff --git a/src/variables/ip.h b/src/variables/ip.h index 92cded8e..cc6041d8 100644 --- a/src/variables/ip.h +++ b/src/variables/ip.h @@ -40,9 +40,9 @@ class Ip_DictElement : public Variable { void evaluate(Transaction *t, Rule *rule, std::vector *l) override { - t->m_collections.m_ip_collection->resolveMultiMatches(m_dictElement, - t->m_collections.m_ip_collection_key, l); - + t->m_collections.m_ip_collection->resolveMultiMatches( + m_name, t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } std::string m_dictElement; @@ -57,8 +57,9 @@ class Ip_NoDictElement : public Variable { void evaluate(Transaction *t, Rule *rule, std::vector *l) override { - t->m_collections.m_ip_collection->resolveMultiMatches(m_name, - t->m_collections.m_ip_collection_key, l); + t->m_collections.m_ip_collection->resolveMultiMatches("", + t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } }; @@ -68,13 +69,14 @@ class Ip_DictElementRegexp : public Variable { explicit Ip_DictElementRegexp(std::string dictElement) : Variable("IP:regex(" + dictElement + ")"), m_r(dictElement), - m_dictElement("IP:" + dictElement) { } + m_dictElement(dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { t->m_collections.m_ip_collection->resolveRegularExpression(m_dictElement, - t->m_collections.m_ip_collection_key, l); + t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } Utils::Regex m_r; @@ -92,19 +94,24 @@ class Ip_DynamicElement : public Variable { Rule *rule, std::vector *l) override { std::string string = m_string->evaluate(t); - t->m_collections.m_ip_collection->resolveMultiMatches("IP:" + string, - t->m_collections.m_ip_collection_key, l); + t->m_collections.m_ip_collection->resolveMultiMatches( + string, + t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } void del(Transaction *t, std::string k) { t->m_collections.m_ip_collection->del(k, - t->m_collections.m_ip_collection_key); + t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value); } void storeOrUpdateFirst(Transaction *t, std::string var, std::string value) { t->m_collections.m_ip_collection->storeOrUpdateFirst( - var, t->m_collections.m_ip_collection_key, value); + var, t->m_collections.m_ip_collection_key, + t->m_rules->m_secWebAppId.m_value, + value); } std::unique_ptr m_string; diff --git a/src/variables/resource.h b/src/variables/resource.h index f0bacb10..bec9c753 100644 --- a/src/variables/resource.h +++ b/src/variables/resource.h @@ -35,13 +35,13 @@ class Resource_DictElement : public Variable { public: explicit Resource_DictElement(std::string dictElement) : Variable("RESOURCE:" + dictElement), - m_dictElement(dictElement) { } + m_dictElement("RESOURCE:" + dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { - t->m_collections.m_resource_collection->resolveMultiMatches(m_dictElement, - t->m_collections.m_resource_collection_key, + t->m_collections.m_resource_collection->resolveMultiMatches( + m_name, t->m_collections.m_resource_collection_key, t->m_rules->m_secWebAppId.m_value, l); } @@ -102,14 +102,14 @@ class Resource_DynamicElement : public Variable { void del(Transaction *t, std::string k) { t->m_collections.m_resource_collection->del(k, - t->m_collections.m_resource_collection_key); + t->m_collections.m_resource_collection_key, + t->m_rules->m_secWebAppId.m_value); } void storeOrUpdateFirst(Transaction *t, std::string var, std::string value) { t->m_collections.m_resource_collection->storeOrUpdateFirst( - var, - t->m_collections.m_resource_collection_key, + var, t->m_collections.m_resource_collection_key, t->m_rules->m_secWebAppId.m_value, value); } diff --git a/src/variables/session.h b/src/variables/session.h index 0a3f8a7a..6b35ce1f 100644 --- a/src/variables/session.h +++ b/src/variables/session.h @@ -34,14 +34,14 @@ namespace Variables { class Session_DictElement : public Variable { public: explicit Session_DictElement(std::string dictElement) - : Variable("SESSION"), - m_dictElement(dictElement) { } + : Variable("SESSION:" + dictElement), + m_dictElement("SESSION:" + dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { t->m_collections.m_session_collection->resolveMultiMatches( - m_dictElement, t->m_collections.m_session_collection_key, + m_name, t->m_collections.m_session_collection_key, t->m_rules->m_secWebAppId.m_value, l); } @@ -57,7 +57,7 @@ class Session_NoDictElement : public Variable { void evaluate(Transaction *t, Rule *rule, std::vector *l) override { - t->m_collections.m_session_collection->resolveMultiMatches(m_name, + t->m_collections.m_session_collection->resolveMultiMatches("", t->m_collections.m_session_collection_key, t->m_rules->m_secWebAppId.m_value, l); } @@ -96,18 +96,21 @@ class Session_DynamicElement : public Variable { std::string string = m_string->evaluate(t); t->m_collections.m_session_collection->resolveMultiMatches( string, - t->m_collections.m_session_collection_key, l); + t->m_collections.m_session_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } void del(Transaction *t, std::string k) { t->m_collections.m_session_collection->del(k, - t->m_collections.m_session_collection_key); + t->m_collections.m_session_collection_key, + t->m_collections.m_ip_collection_key); } void storeOrUpdateFirst(Transaction *t, std::string var, std::string value) { t->m_collections.m_session_collection->storeOrUpdateFirst( var, t->m_collections.m_session_collection_key, + t->m_rules->m_secWebAppId.m_value, value); } diff --git a/src/variables/tx.h b/src/variables/tx.h index 73de5eaa..02b5265d 100644 --- a/src/variables/tx.h +++ b/src/variables/tx.h @@ -35,13 +35,13 @@ class Tx_DictElement : public Variable { public: explicit Tx_DictElement(std::string dictElement) : Variable("TX:" + dictElement), - m_dictElement(dictElement) { } + m_dictElement("TX:" + dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { t->m_collections.m_tx_collection->resolveMultiMatches( - m_dictElement, l); + m_name, l); } std::string m_dictElement; diff --git a/src/variables/user.h b/src/variables/user.h index abd4e5c6..a752be53 100644 --- a/src/variables/user.h +++ b/src/variables/user.h @@ -34,14 +34,14 @@ namespace Variables { class User_DictElement : public Variable { public: explicit User_DictElement(std::string dictElement) - : Variable("USER"), - m_dictElement(dictElement) { } + : Variable("USER:" + dictElement), + m_dictElement("USER:" + dictElement) { } void evaluate(Transaction *t, Rule *rule, std::vector *l) override { t->m_collections.m_user_collection->resolveMultiMatches( - m_dictElement, t->m_collections.m_user_collection_key, + m_name, t->m_collections.m_user_collection_key, t->m_rules->m_secWebAppId.m_value, l); } @@ -95,18 +95,22 @@ class User_DynamicElement : public Variable { std::vector *l) override { std::string string = m_string->evaluate(t); t->m_collections.m_user_collection->resolveMultiMatches( - string, t->m_collections.m_user_collection_key, l); + string, + t->m_collections.m_user_collection_key, + t->m_rules->m_secWebAppId.m_value, l); } void del(Transaction *t, std::string k) { t->m_collections.m_user_collection->del(k, - t->m_collections.m_user_collection_key); + t->m_collections.m_user_collection_key, + t->m_rules->m_secWebAppId.m_value); } void storeOrUpdateFirst(Transaction *t, std::string var, std::string value) { t->m_collections.m_user_collection->storeOrUpdateFirst( var, t->m_collections.m_user_collection_key, + t->m_rules->m_secWebAppId.m_value, value); }