Cosmetics: Using VariableValues instead of std::vector<...>

Making the code more readable.
This commit is contained in:
Felipe Zimmerle 2020-08-24 12:57:47 -03:00
parent 6c79e716e7
commit 759fc1eabe
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
54 changed files with 123 additions and 119 deletions

View File

@ -92,18 +92,18 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string,
void setCopy(std::string key, std::string value, size_t offset); void setCopy(std::string key, std::string value, size_t offset);
void resolve(std::vector<std::shared_ptr<const VariableValue>> *l); void resolve(VariableValues *l);
void resolve(std::vector<std::shared_ptr<const VariableValue>> *l, void resolve(VariableValues *l,
variables::KeyExclusions &ke); variables::KeyExclusions &ke);
void resolve(const std::string &key, void resolve(const std::string &key,
std::vector<std::shared_ptr<const VariableValue>> *l); VariableValues *l);
void resolveRegularExpression(Utils::Regex *r, void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l); VariableValues *l);
void resolveRegularExpression(Utils::Regex *r, void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke); variables::KeyExclusions &ke);
std::unique_ptr<std::string> resolveFirst(const std::string &key); std::unique_ptr<std::string> resolveFirst(const std::string &key);

View File

@ -69,7 +69,7 @@ class AnchoredVariable {
void append(const std::string &a, size_t offset, void append(const std::string &a, size_t offset,
bool spaceSeparator, int size); bool spaceSeparator, int size);
void evaluate(std::vector<std::shared_ptr<const VariableValue>> *l); void evaluate(VariableValues *l);
std::string * evaluate(); std::string * evaluate();
std::unique_ptr<std::string> resolveFirst(); std::unique_ptr<std::string> resolveFirst();

View File

@ -60,12 +60,12 @@ class Collection {
const std::string& var) = 0; const std::string& var) = 0;
virtual void resolveSingleMatch(const std::string& var, virtual void resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) = 0; VariableValues *l) = 0;
virtual void resolveMultiMatches(const std::string& var, virtual void resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) = 0; variables::KeyExclusions &ke) = 0;
virtual void resolveRegularExpression(const std::string& var, virtual void resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) = 0; variables::KeyExclusions &ke) = 0;
@ -146,7 +146,7 @@ class Collection {
/* resolveSingleMatch */ /* resolveSingleMatch */
virtual void resolveSingleMatch(const std::string& var, virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l) { std::string compartment, VariableValues *l) {
std::string nkey = compartment + "::" + var; std::string nkey = compartment + "::" + var;
resolveSingleMatch(nkey, l); resolveSingleMatch(nkey, l);
} }
@ -154,7 +154,7 @@ class Collection {
virtual void resolveSingleMatch(const std::string& var, virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::string compartment2, std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
std::string nkey = compartment + "::" + compartment2 + "::" + var; std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveSingleMatch(nkey, l); resolveSingleMatch(nkey, l);
} }
@ -162,7 +162,7 @@ class Collection {
/* resolveMultiMatches */ /* resolveMultiMatches */
virtual void resolveMultiMatches(const std::string& var, virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l, std::string compartment, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + var; std::string nkey = compartment + "::" + var;
resolveMultiMatches(nkey, l, ke); resolveMultiMatches(nkey, l, ke);
@ -171,7 +171,7 @@ class Collection {
virtual void resolveMultiMatches(const std::string& var, virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::string compartment2, std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + compartment2 + "::" + var; std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveMultiMatches(nkey, l, ke); resolveMultiMatches(nkey, l, ke);
@ -180,7 +180,7 @@ class Collection {
/* resolveRegularExpression */ /* resolveRegularExpression */
virtual void resolveRegularExpression(const std::string& var, virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l, std::string compartment, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + var; std::string nkey = compartment + "::" + var;
resolveRegularExpression(nkey, l, ke); resolveRegularExpression(nkey, l, ke);
@ -189,7 +189,7 @@ class Collection {
virtual void resolveRegularExpression(const std::string& var, virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::string compartment2, std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l, variables::KeyExclusions &ke) { VariableValues *l, variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + compartment2 + "::" + var; std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveRegularExpression(nkey, l, ke); resolveRegularExpression(nkey, l, ke);
} }

View File

@ -34,10 +34,14 @@ typedef struct Variable_t VariableValue;
#ifdef __cplusplus #ifdef __cplusplus
namespace modsecurity { namespace modsecurity {
class VariableValue;
using VariableValues = std::vector<std::shared_ptr<const VariableValue>>;
using Origins = std::vector<VariableOrigin>;
class Collection; class Collection;
class VariableValue { class VariableValue {
public: public:
using Origins = std::vector<VariableOrigin>;
explicit VariableValue(const std::string *key, explicit VariableValue(const std::string *key,
const std::string *value = nullptr) const std::string *value = nullptr)

View File

@ -108,7 +108,7 @@ bool SetVar::execute(Transaction *t) const noexcept {
} }
try { try {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
m_variable->evaluate(t, &l); m_variable->evaluate(t, &l);
if (l.size() == 0) { if (l.size() == 0) {
value = 0; value = 0;

View File

@ -96,7 +96,7 @@ void AnchoredSetVariable::set(const std::string &key,
void AnchoredSetVariable::resolve( void AnchoredSetVariable::resolve(
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
for (const auto& x : *this) { for (const auto& x : *this) {
l->insert(l->begin(), x.second); l->insert(l->begin(), x.second);
} }
@ -104,7 +104,7 @@ void AnchoredSetVariable::resolve(
void AnchoredSetVariable::resolve( void AnchoredSetVariable::resolve(
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
for (const auto& x : *this) { for (const auto& x : *this) {
if (!ke.toOmit(x.first)) { if (!ke.toOmit(x.first)) {
@ -118,7 +118,7 @@ void AnchoredSetVariable::resolve(
void AnchoredSetVariable::resolve(const std::string &key, void AnchoredSetVariable::resolve(const std::string &key,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
auto range = this->equal_range(key); auto range = this->equal_range(key);
for (auto it = range.first; it != range.second; ++it) { for (auto it = range.first; it != range.second; ++it) {
l->push_back(it->second); l->push_back(it->second);
@ -139,7 +139,7 @@ std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r, void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
for (const auto& x : *this) { for (const auto& x : *this) {
int ret = Utils::regex_search(x.first, *r); int ret = Utils::regex_search(x.first, *r);
if (ret <= 0) { if (ret <= 0) {
@ -151,7 +151,7 @@ void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r, void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
for (const auto& x : *this) { for (const auto& x : *this) {
int ret = Utils::regex_search(x.first, *r); int ret = Utils::regex_search(x.first, *r);

View File

@ -117,7 +117,7 @@ void AnchoredVariable::append(const std::string &a, size_t offset,
} }
void AnchoredVariable::evaluate(std::vector<std::shared_ptr<const VariableValue>> *l) { void AnchoredVariable::evaluate(VariableValues *l) {
if (m_name.empty()) { if (m_name.empty()) {
return; return;
} }

View File

@ -86,7 +86,7 @@ void InMemoryPerProcess::del(const std::string& key) {
void InMemoryPerProcess::resolveSingleMatch(const std::string& var, void InMemoryPerProcess::resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
auto range = this->equal_range(var); auto range = this->equal_range(var);
for (auto it = range.first; it != range.second; ++it) { for (auto it = range.first; it != range.second; ++it) {
@ -96,7 +96,7 @@ void InMemoryPerProcess::resolveSingleMatch(const std::string& var,
void InMemoryPerProcess::resolveMultiMatches(const std::string& var, void InMemoryPerProcess::resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, variables::KeyExclusions &ke) { VariableValues *l, variables::KeyExclusions &ke) {
size_t keySize = var.size(); size_t keySize = var.size();
l->reserve(15); l->reserve(15);
@ -120,7 +120,7 @@ void InMemoryPerProcess::resolveMultiMatches(const std::string& var,
void InMemoryPerProcess::resolveRegularExpression(const std::string& var, void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, variables::KeyExclusions &ke) { VariableValues *l, variables::KeyExclusions &ke) {
//if (var.find(":") == std::string::npos) { //if (var.find(":") == std::string::npos) {
// return; // return;

View File

@ -87,12 +87,12 @@ class InMemoryPerProcess :
std::unique_ptr<std::string> resolveFirst(const std::string& var) override; std::unique_ptr<std::string> resolveFirst(const std::string& var) override;
void resolveSingleMatch(const std::string& var, void resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
void resolveMultiMatches(const std::string& var, void resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) override; variables::KeyExclusions &ke) override;
void resolveRegularExpression(const std::string& var, void resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) override; variables::KeyExclusions &ke) override;
private: private:

View File

@ -262,7 +262,7 @@ end_txn:
void LMDB::resolveSingleMatch(const std::string& var, void LMDB::resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
int rc; int rc;
MDB_txn *txn; MDB_txn *txn;
MDB_dbi dbi; MDB_dbi dbi;
@ -465,7 +465,7 @@ end_txn:
void LMDB::resolveMultiMatches(const std::string& var, void LMDB::resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
MDB_val key, data; MDB_val key, data;
MDB_txn *txn = NULL; MDB_txn *txn = NULL;
@ -527,7 +527,7 @@ end_txn:
void LMDB::resolveRegularExpression(const std::string& var, void LMDB::resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) { variables::KeyExclusions &ke) {
MDB_val key, data; MDB_val key, data;
MDB_txn *txn = NULL; MDB_txn *txn = NULL;

View File

@ -66,12 +66,12 @@ class LMDB :
std::unique_ptr<std::string> resolveFirst(const std::string& var) override; std::unique_ptr<std::string> resolveFirst(const std::string& var) override;
void resolveSingleMatch(const std::string& var, void resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
void resolveMultiMatches(const std::string& var, void resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) override; variables::KeyExclusions &ke) override;
void resolveRegularExpression(const std::string& var, void resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l, VariableValues *l,
variables::KeyExclusions &ke) override; variables::KeyExclusions &ke) override;
private: private:

View File

@ -286,7 +286,7 @@ int Lua::getvars(lua_State *L) {
const char *varname(NULL); const char *varname(NULL);
Transaction *t(NULL); Transaction *t(NULL);
void *z(NULL); void *z(NULL);
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
int idx = 1; int idx = 1;
/* Retrieve parameters. */ /* Retrieve parameters. */

View File

@ -265,7 +265,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const {
getFinalVars(&vars, &exclusion, trans); getFinalVars(&vars, &exclusion, trans);
std::vector<std::shared_ptr<const VariableValue>> e; VariableValues e;
for (auto &var : vars) { for (auto &var : vars) {
if (!var) { if (!var) {
continue; continue;

View File

@ -124,7 +124,7 @@ class RunTimeString {
void appendValueTo(/* const */ Transaction *transaction, std::string &v) const noexcept { void appendValueTo(/* const */ Transaction *transaction, std::string &v) const noexcept {
if (m_variable && transaction) { if (m_variable && transaction) {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
m_variable->evaluate(transaction, &l); m_variable->evaluate(transaction, &l);
if (!l.empty()) { if (!l.empty()) {
v.append(l[0]->getValue()); v.append(l[0]->getValue());

View File

@ -961,7 +961,7 @@ int Transaction::processRequestBody() {
* computationally intensive. * computationally intensive.
*/ */
std::string fullRequest; std::string fullRequest;
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
m_variableRequestHeaders.resolve(&l); m_variableRequestHeaders.resolve(&l);
for (const auto &h : l) { for (const auto &h : l) {
fullRequest = fullRequest + h->getKey() + ": " + h->getValue() + "\n"; fullRequest = fullRequest + h->getKey() + ": " + h->getValue() + "\n";
@ -1490,7 +1490,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
ss << utils::string::dash_if_empty(this->m_clientIpAddress->c_str()) << " "; ss << utils::string::dash_if_empty(this->m_clientIpAddress->c_str()) << " ";
/** TODO: Check variable */ /** TODO: Check variable */
variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER"); variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER");
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
r->evaluate(this, &l); r->evaluate(this, &l);
delete r; delete r;
@ -1553,7 +1553,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
audit_log << std::endl; audit_log << std::endl;
if (parts & audit_log::AuditLog::BAuditLogPart) { if (parts & audit_log::AuditLog::BAuditLogPart) {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
audit_log << "--" << trailer << "-" << "B--" << std::endl; audit_log << "--" << trailer << "-" << "B--" << std::endl;
audit_log << utils::string::dash_if_empty( audit_log << utils::string::dash_if_empty(
m_variableRequestMethod.evaluate()); m_variableRequestMethod.evaluate());
@ -1592,7 +1592,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
audit_log << std::endl; audit_log << std::endl;
} }
if (parts & audit_log::AuditLog::FAuditLogPart) { if (parts & audit_log::AuditLog::FAuditLogPart) {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
audit_log << "--" << trailer << "-" << "F--" << std::endl; audit_log << "--" << trailer << "-" << "F--" << std::endl;
audit_log << "HTTP/" << m_httpVersion.c_str() << " "; audit_log << "HTTP/" << m_httpVersion.c_str() << " ";
@ -1693,7 +1693,7 @@ std::string Transaction::toJSON(int parts) {
/* request headers */ /* request headers */
if (parts & audit_log::AuditLog::BAuditLogPart) { if (parts & audit_log::AuditLog::BAuditLogPart) {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
yajl_gen_string(g, reinterpret_cast<const unsigned char*>("headers"), yajl_gen_string(g, reinterpret_cast<const unsigned char*>("headers"),
strlen("headers")); strlen("headers"));
yajl_gen_map_open(g); yajl_gen_map_open(g);
@ -1722,7 +1722,7 @@ std::string Transaction::toJSON(int parts) {
/* response headers */ /* response headers */
if (parts & audit_log::AuditLog::FAuditLogPart) { if (parts & audit_log::AuditLog::FAuditLogPart) {
std::vector<std::shared_ptr<const VariableValue>> l; VariableValues l;
yajl_gen_string(g, reinterpret_cast<const unsigned char*>("headers"), yajl_gen_string(g, reinterpret_cast<const unsigned char*>("headers"),
strlen("headers")); strlen("headers"));
yajl_gen_map_open(g); yajl_gen_map_open(g);

View File

@ -28,7 +28,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void Duration::evaluate(Transaction *transaction, void Duration::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
double e = utils::cpu_seconds() - transaction->m_creationTimeStamp; double e = utils::cpu_seconds() - transaction->m_creationTimeStamp;
transaction->m_variableDuration.assign(std::to_string(e)); transaction->m_variableDuration.assign(std::to_string(e));

View File

@ -35,7 +35,7 @@ class Duration : public Variable {
m_retName("DURATION") { } m_retName("DURATION") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -33,7 +33,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void Env::evaluate(Transaction *transaction, void Env::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
for (char **current = environ; *current; current++) { for (char **current = environ; *current; current++) {
std::string env = std::string(*current); std::string env = std::string(*current);
size_t pos = env.find_first_of("="); size_t pos = env.find_first_of("=");

View File

@ -34,7 +34,7 @@ class Env : public Variable {
: Variable(_name) { } : Variable(_name) { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
}; };
} // namespace variables } // namespace variables

View File

@ -40,7 +40,7 @@ class Global_DictElement : public Variable {
m_dictElement("GLOBAL:" + dictElement) { } m_dictElement("GLOBAL:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_global_collection->resolveMultiMatches( t->m_collections.m_global_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_global_collection_key, *getVariableKey(), t->m_collections.m_global_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -56,7 +56,7 @@ class Global_NoDictElement : public Variable {
: Variable("GLOBAL") { } : Variable("GLOBAL") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_global_collection->resolveMultiMatches("", t->m_collections.m_global_collection->resolveMultiMatches("",
t->m_collections.m_global_collection_key, t->m_collections.m_global_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -71,7 +71,7 @@ class Global_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_global_collection->resolveRegularExpression( t->m_collections.m_global_collection->resolveRegularExpression(
m_dictElement, m_dictElement,
t->m_collections.m_global_collection_key, t->m_collections.m_global_collection_key,
@ -92,7 +92,7 @@ class Global_DynamicElement : public VariableWithRunTimeString {
{ }; { };
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_global_collection->resolveMultiMatches( t->m_collections.m_global_collection->resolveMultiMatches(
string, string,

View File

@ -27,7 +27,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void HighestSeverity::evaluate(Transaction *transaction, void HighestSeverity::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
transaction->m_variableHighestSeverityAction.assign( transaction->m_variableHighestSeverityAction.assign(
std::to_string(transaction->m_highestSeverityAction)); std::to_string(transaction->m_highestSeverityAction));
l->push_back(std::make_shared<VariableValue>(getVariableKeyWithCollection().get(), &transaction->m_variableHighestSeverityAction)); l->push_back(std::make_shared<VariableValue>(getVariableKeyWithCollection().get(), &transaction->m_variableHighestSeverityAction));

View File

@ -35,7 +35,7 @@ class HighestSeverity : public Variable {
{ } { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
}; };

View File

@ -40,7 +40,7 @@ class Ip_DictElement : public Variable {
m_dictElement("IP:" + dictElement) { } m_dictElement("IP:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_ip_collection->resolveMultiMatches( t->m_collections.m_ip_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_ip_collection_key, *getVariableKey(), t->m_collections.m_ip_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -56,7 +56,7 @@ class Ip_NoDictElement : public Variable {
: Variable("IP") { } : Variable("IP") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_ip_collection->resolveMultiMatches("", t->m_collections.m_ip_collection->resolveMultiMatches("",
t->m_collections.m_ip_collection_key, t->m_collections.m_ip_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -71,7 +71,7 @@ class Ip_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_ip_collection->resolveRegularExpression( t->m_collections.m_ip_collection->resolveRegularExpression(
m_dictElement, t->m_collections.m_ip_collection_key, m_dictElement, t->m_collections.m_ip_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -91,7 +91,7 @@ class Ip_DynamicElement : public VariableWithRunTimeString {
{ } { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_ip_collection->resolveMultiMatches( t->m_collections.m_ip_collection->resolveMultiMatches(
string, string,

View File

@ -25,7 +25,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void ModsecBuild::evaluate(Transaction *transaction, void ModsecBuild::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
l->push_back(std::make_shared<VariableValue>(&m_retName, &m_build)); l->push_back(std::make_shared<VariableValue>(&m_retName, &m_build));
} }

View File

@ -44,7 +44,7 @@ class ModsecBuild : public Variable {
} }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_build; std::string m_build;
std::string m_retName; std::string m_retName;

View File

@ -37,12 +37,12 @@ namespace variables {
void RemoteUser::evaluate(Transaction *transaction, void RemoteUser::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
size_t pos; size_t pos;
std::string base64; std::string base64;
std::string header; std::string header;
std::vector<std::shared_ptr<const VariableValue>> l2; VariableValues l2;
transaction->m_variableRequestHeaders.resolve("authorization", &l2); transaction->m_variableRequestHeaders.resolve("authorization", &l2);
if (l2.size() < 1) { if (l2.size() < 1) {

View File

@ -37,7 +37,7 @@ class RemoteUser : public Variable {
m_retName("REMOTE_USER") { } m_retName("REMOTE_USER") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -40,7 +40,7 @@ class Resource_DictElement : public Variable {
m_dictElement("RESOURCE:" + dictElement) { } m_dictElement("RESOURCE:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_resource_collection->resolveMultiMatches( t->m_collections.m_resource_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_resource_collection_key, *getVariableKey(), t->m_collections.m_resource_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -56,7 +56,7 @@ class Resource_NoDictElement : public Variable {
: Variable("RESOURCE") { } : Variable("RESOURCE") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_resource_collection->resolveMultiMatches(*getVariableKey(), t->m_collections.m_resource_collection->resolveMultiMatches(*getVariableKey(),
t->m_collections.m_resource_collection_key, t->m_collections.m_resource_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -71,7 +71,7 @@ class Resource_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_resource_collection->resolveRegularExpression( t->m_collections.m_resource_collection->resolveRegularExpression(
m_dictElement, t->m_collections.m_resource_collection_key, m_dictElement, t->m_collections.m_resource_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -91,7 +91,7 @@ class Resource_DynamicElement : public VariableWithRunTimeString {
{ } { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_resource_collection->resolveMultiMatches( t->m_collections.m_resource_collection->resolveMultiMatches(
string, string,

View File

@ -56,7 +56,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
static void id(Transaction *t, static void id(Transaction *t,
const RuleWithActions *rule, const RuleWithActions *rule,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
std::string a = std::to_string(rule->getId()); std::string a = std::to_string(rule->getId());
auto var = std::make_shared<VariableValue>(&m_rule, &m_rule_id, &a); auto var = std::make_shared<VariableValue>(&m_rule, &m_rule_id, &a);
VariableOrigin origin; VariableOrigin origin;
@ -70,7 +70,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
static void rev(Transaction *t, static void rev(Transaction *t,
const RuleWithActions *rule, const RuleWithActions *rule,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
if (rule->hasRevisionAction()) { if (rule->hasRevisionAction()) {
std::string a(rule->getRevision()); std::string a(rule->getRevision());
@ -87,7 +87,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
static void severity(Transaction *t, static void severity(Transaction *t,
const RuleWithActions *rule, const RuleWithActions *rule,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
if (rule->hasSeverityAction()) { if (rule->hasSeverityAction()) {
std::string a(std::to_string(rule->getSeverity())); std::string a(std::to_string(rule->getSeverity()));
@ -103,7 +103,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
static void logData(Transaction *t, static void logData(Transaction *t,
const RuleWithActions *rule, const RuleWithActions *rule,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
if (rule->hasLogDataAction()) { if (rule->hasLogDataAction()) {
std::string a(rule->getLogData(t)); std::string a(rule->getLogData(t));
@ -118,7 +118,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
static void msg(Transaction *t, static void msg(Transaction *t,
const RuleWithActions *rule, const RuleWithActions *rule,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
if (rule->hasMessageAction()) { if (rule->hasMessageAction()) {
std::string a(rule->getMessage(t)); std::string a(rule->getMessage(t));
@ -132,7 +132,7 @@ class Rule_DictElement : public RuleVariable, public VariableDictElement {
} }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
if (m_dictElement == "id") { if (m_dictElement == "id") {
id(t, getRule(), l); id(t, getRule(), l);
@ -180,7 +180,7 @@ class Rule_DictElementRegexp : public RuleVariable, public VariableRegex {
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
if (Utils::regex_search("id", m_r) > 0) { if (Utils::regex_search("id", m_r) > 0) {
Rule_DictElement::id(t, getRule(), l); Rule_DictElement::id(t, getRule(), l);
@ -225,7 +225,7 @@ class Rule_NoDictElement : public RuleVariable, public Variable {
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
Rule_DictElement::id(t, getRule(), l); Rule_DictElement::id(t, getRule(), l);
Rule_DictElement::rev(t, getRule(), l); Rule_DictElement::rev(t, getRule(), l);
Rule_DictElement::severity(t, getRule(), l); Rule_DictElement::severity(t, getRule(), l);

View File

@ -39,7 +39,7 @@ class Session_DictElement : public Variable {
m_dictElement("SESSION:" + dictElement) { } m_dictElement("SESSION:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_session_collection->resolveMultiMatches( t->m_collections.m_session_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_session_collection_key, *getVariableKey(), t->m_collections.m_session_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -55,7 +55,7 @@ class Session_NoDictElement : public Variable {
: Variable("SESSION") { } : Variable("SESSION") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_session_collection->resolveMultiMatches("", t->m_collections.m_session_collection->resolveMultiMatches("",
t->m_collections.m_session_collection_key, t->m_collections.m_session_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -70,7 +70,7 @@ class Session_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_session_collection->resolveRegularExpression( t->m_collections.m_session_collection->resolveRegularExpression(
m_dictElement, t->m_collections.m_session_collection_key, m_dictElement, t->m_collections.m_session_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -90,7 +90,7 @@ class Session_DynamicElement : public VariableWithRunTimeString {
{ } { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_session_collection->resolveMultiMatches( t->m_collections.m_session_collection->resolveMultiMatches(
string, string,

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void Time::evaluate(Transaction *transaction, void Time::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;

View File

@ -36,7 +36,7 @@ class Time : public Variable {
m_retName("TIME") { } m_retName("TIME") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeDay::evaluate(Transaction *transaction, void TimeDay::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeDay : public Variable {
m_retName("TIME_DAY") { } m_retName("TIME_DAY") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeEpoch::evaluate(Transaction *transaction, void TimeEpoch::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
transaction->m_variableTimeEpoch.assign( transaction->m_variableTimeEpoch.assign(
std::to_string(std::time(nullptr))); std::to_string(std::time(nullptr)));
l->push_back(std::make_shared<VariableValue>(&m_retName, &transaction->m_variableTimeEpoch)); l->push_back(std::make_shared<VariableValue>(&m_retName, &transaction->m_variableTimeEpoch));

View File

@ -35,7 +35,7 @@ class TimeEpoch : public Variable {
m_retName("TIME_EPOCH") { } m_retName("TIME_EPOCH") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeHour::evaluate(Transaction *transaction, void TimeHour::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeHour : public Variable {
m_retName("TIME_HOUR") { } m_retName("TIME_HOUR") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeMin::evaluate(Transaction *transaction, void TimeMin::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeMin : public Variable {
m_retName("TIME_MIN") { } m_retName("TIME_MIN") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeMon::evaluate(Transaction *transaction, void TimeMon::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeMon : public Variable {
m_retName("TIME_MON") { } m_retName("TIME_MON") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeSec::evaluate(Transaction *transaction, void TimeSec::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeSec : public Variable {
m_retName("TIME_SEC") { } m_retName("TIME_SEC") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeWDay::evaluate(Transaction *transaction, void TimeWDay::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeWDay : public Variable {
m_retName("TIME_WDAY") { } m_retName("TIME_WDAY") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables { namespace variables {
void TimeYear::evaluate(Transaction *transaction, void TimeYear::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
char tstr[200]; char tstr[200];
struct tm timeinfo; struct tm timeinfo;
time_t timer; time_t timer;

View File

@ -35,7 +35,7 @@ class TimeYear : public Variable {
m_retName("TIME_YEAR") { } m_retName("TIME_YEAR") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
std::string m_retName; std::string m_retName;
}; };

View File

@ -40,7 +40,7 @@ class Tx_DictElement : public Variable {
m_dictElement("TX:" + dictElement) { } m_dictElement("TX:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_tx_collection->resolveMultiMatches( t->m_collections.m_tx_collection->resolveMultiMatches(
*getVariableKey(), l, m_keyExclusion); *getVariableKey(), l, m_keyExclusion);
} }
@ -55,7 +55,7 @@ class Tx_NoDictElement : public Variable {
: Variable("TX") { } : Variable("TX") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_tx_collection->resolveMultiMatches("", l, t->m_collections.m_tx_collection->resolveMultiMatches("", l,
m_keyExclusion); m_keyExclusion);
} }
@ -69,7 +69,7 @@ class Tx_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_tx_collection->resolveRegularExpression( t->m_collections.m_tx_collection->resolveRegularExpression(
m_dictElement, l, m_keyExclusion); m_dictElement, l, m_keyExclusion);
} }
@ -88,7 +88,7 @@ class Tx_DynamicElement : public VariableWithRunTimeString {
{ } { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_tx_collection->resolveMultiMatches(string, l, t->m_collections.m_tx_collection->resolveMultiMatches(string, l,
m_keyExclusion); m_keyExclusion);

View File

@ -40,7 +40,7 @@ class User_DictElement : public Variable {
m_dictElement("USER:" + dictElement) { } m_dictElement("USER:" + dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_user_collection->resolveMultiMatches( t->m_collections.m_user_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_user_collection_key, *getVariableKey(), t->m_collections.m_user_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -56,7 +56,7 @@ class User_NoDictElement : public Variable {
: Variable("USER") { } : Variable("USER") { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_user_collection->resolveMultiMatches(*getVariableKey(), t->m_collections.m_user_collection->resolveMultiMatches(*getVariableKey(),
t->m_collections.m_user_collection_key, t->m_collections.m_user_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -71,7 +71,7 @@ class User_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { } m_dictElement(dictElement) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
t->m_collections.m_user_collection->resolveRegularExpression( t->m_collections.m_user_collection->resolveRegularExpression(
m_dictElement, t->m_collections.m_user_collection_key, m_dictElement, t->m_collections.m_user_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion); t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -91,7 +91,7 @@ class User_DynamicElement : public VariableWithRunTimeString {
{ } { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::string string = m_string->evaluate(t); std::string string = m_string->evaluate(t);
t->m_collections.m_user_collection->resolveMultiMatches( t->m_collections.m_user_collection->resolveMultiMatches(
string, string,

View File

@ -48,7 +48,7 @@ class n ## _DictElementRegexp : public VariableRegex { \
: VariableRegex(#N, regex) { } \ : VariableRegex(#N, regex) { } \
\ \
void evaluate(Transaction *transaction, \ void evaluate(Transaction *transaction, \
std::vector<std::shared_ptr<const VariableValue>> *l) override { \ VariableValues *l) override { \
transaction-> e .resolveRegularExpression(&m_r, l, \ transaction-> e .resolveRegularExpression(&m_r, l, \
m_keyExclusion); \ m_keyExclusion); \
} \ } \
@ -62,7 +62,7 @@ class n ## _DictElement : public VariableDictElement { \
: VariableDictElement(#N, dictElement) { } \ : VariableDictElement(#N, dictElement) { } \
\ \
void evaluate(Transaction *transaction, \ void evaluate(Transaction *transaction, \
std::vector<std::shared_ptr<const VariableValue>> *l) override { \ VariableValues *l) override { \
transaction-> e .resolve(m_dictElement, l); \ transaction-> e .resolve(m_dictElement, l); \
} \ } \
}; };
@ -75,7 +75,7 @@ class n ## _NoDictElement : public Variable { \
: Variable(#N) { } \ : Variable(#N) { } \
\ \
void evaluate(Transaction *transaction, \ void evaluate(Transaction *transaction, \
std::vector<std::shared_ptr<const VariableValue>> *l) override { \ VariableValues *l) override { \
transaction-> e .resolve(l, m_keyExclusion); \ transaction-> e .resolve(l, m_keyExclusion); \
} \ } \
}; };
@ -88,7 +88,7 @@ class n : public Variable { \
: Variable(#N) { } \ : Variable(#N) { } \
\ \
void evaluate(Transaction *transaction, \ void evaluate(Transaction *transaction, \
std::vector<std::shared_ptr<const VariableValue>> *l) override { \ VariableValues *l) override { \
transaction-> e .evaluate(l); \ transaction-> e .evaluate(l); \
} \ } \
}; };
@ -186,7 +186,7 @@ class VariableMonkeyResolution {
static void stringMatchResolveMulti(Transaction *t, static void stringMatchResolveMulti(Transaction *t,
const std::string &variable, const std::string &variable,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
size_t collection = variable.find("."); size_t collection = variable.find(".");
if (collection == std::string::npos) { if (collection == std::string::npos) {
collection = variable.find(":"); collection = variable.find(":");
@ -576,7 +576,7 @@ class Variable : public VariableMonkeyResolution {
virtual void evaluate(Transaction *t, virtual void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) = 0; VariableValues *l) = 0;
bool inline belongsToCollection(Variable *var) const noexcept { bool inline belongsToCollection(Variable *var) const noexcept {
@ -727,7 +727,7 @@ class VariableModificatorExclusion : public Variable {
m_base(std::move(var)) { } m_base(std::move(var)) { }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
m_base->evaluate(t, l); m_base->evaluate(t, l);
} }
@ -744,9 +744,9 @@ class VariableModificatorCount : public Variable {
} }
void evaluate(Transaction *t, void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
std::vector<std::shared_ptr<const VariableValue>> reslIn; VariableValues reslIn;
m_base->evaluate(t, &reslIn); m_base->evaluate(t, &reslIn);
auto count = reslIn.size(); auto count = reslIn.size();

View File

@ -36,7 +36,7 @@ class WebAppId : public Variable {
: Variable("WEBAPPID") { } : Variable("WEBAPPID") { }
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
const std::string rname = transaction->m_rules->m_secWebAppId.m_value; const std::string rname = transaction->m_rules->m_secWebAppId.m_value;
l->push_back(std::make_shared<VariableValue>(getVariableKeyWithCollection().get(), &rname)); l->push_back(std::make_shared<VariableValue>(getVariableKeyWithCollection().get(), &rname));
} }

View File

@ -50,11 +50,11 @@ namespace variables {
#ifndef WITH_LIBXML2 #ifndef WITH_LIBXML2
void XML_WithNSPath::evaluate(Transaction *t, void XML_WithNSPath::evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) { } VariableValues *l) { }
#else #else
void XML_WithNSPath::evaluate(Transaction *t, void XML_WithNSPath::evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) { VariableValues *l) {
xmlXPathContextPtr xpathCtx; xmlXPathContextPtr xpathCtx;
xmlXPathObjectPtr xpathObj; xmlXPathObjectPtr xpathObj;
xmlNodeSetPtr nodes; xmlNodeSetPtr nodes;

View File

@ -51,7 +51,7 @@ class XML_WithoutNSPath : public RuleVariable, public Variable {
{ }; { };
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override { VariableValues *l) override {
l->push_back(m_var); l->push_back(m_var);
} }
@ -76,7 +76,7 @@ class XML_WithNSPath : public RuleVariable, public VariableDictElement {
{ }; { };
void evaluate(Transaction *transaction, void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override; VariableValues *l) override;
virtual Variable *clone() override { virtual Variable *clone() override {
return new XML_WithNSPath(*this); return new XML_WithNSPath(*this);