Bug fix: variable resolution inside global collections

Collections were being resolved as transient variables.
This commit is contained in:
Felipe Zimmerle
2016-07-07 10:32:48 -03:00
parent 20689145dd
commit 7bcc9cf0d9
2 changed files with 51 additions and 10 deletions

View File

@@ -22,6 +22,7 @@
#include "modsecurity/transaction.h"
#include "variations/exclusion.h"
#include "src/utils.h"
using modsecurity::Variables::Variations::Exclusion;
@@ -37,12 +38,32 @@ Variable::Variable(std::string name)
if (m_name.at(0) == '\\') {
m_type = RegularExpression;
} else if (m_name.find(":") != std::string::npos) {
std::string col = toupper(std::string(m_name, 0, m_name.find(":")));
if (col == "TX" || col == "IP" || col == "GLOBAL"
|| col == "RESOURCE" || col == "SESSION") {
m_collectionName = col;
}
m_type = SingleMatch;
} else {
m_type = MultipleMatches;
}
if (m_name.find(".") != std::string::npos) {
if (tolower(m_name) == "tx") {
m_collectionName = "TX";
m_type = MultipleMatches;
} else if (tolower(m_name) == "ip") {
m_collectionName = "IP";
m_type = MultipleMatches;
} else if (tolower(m_name) == "global") {
m_collectionName = "GLOBAL";
m_type = MultipleMatches;
} else if (tolower(m_name) == "resource") {
m_collectionName = "RESOURCE";
m_type = MultipleMatches;
} else if (tolower(m_name) == "session") {
m_collectionName = "SESSION";
m_type = MultipleMatches;
} else if (m_name.find(".") != std::string::npos) {
m_kind = CollectionVarible;
m_collectionName = std::string(m_name, 0, m_name.find("."));
} else {
@@ -60,12 +81,32 @@ Variable::Variable(std::string name, VariableKind kind)
if (m_name.at(0) == '\\') {
m_type = RegularExpression;
} else if (m_name.find(":") != std::string::npos) {
std::string col = toupper(std::string(m_name, 0, m_name.find(":")));
if (col == "TX" || col == "IP" || col == "GLOBAL"
|| col == "RESOURCE" || col == "SESSION") {
m_collectionName = col;
}
m_type = SingleMatch;
} else {
m_type = MultipleMatches;
}
if (m_name.find(".") != std::string::npos) {
if (tolower(m_name) == "tx") {
m_collectionName = "TX";
m_type = MultipleMatches;
} else if (tolower(m_name) == "ip") {
m_collectionName = "IP";
m_type = MultipleMatches;
} else if (tolower(m_name) == "global") {
m_collectionName = "GLOBAL";
m_type = MultipleMatches;
} else if (tolower(m_name) == "resource") {
m_collectionName = "RESOURCE";
m_type = MultipleMatches;
} else if (tolower(m_name) == "session") {
m_collectionName = "SESSION";
m_type = MultipleMatches;
} else if (m_name.find(".") != std::string::npos) {
m_collectionName = std::string(m_name, 0, m_name.find("."));
}
}