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 resolve(std::vector<std::shared_ptr<const VariableValue>> *l);
void resolve(std::vector<std::shared_ptr<const VariableValue>> *l,
void resolve(VariableValues *l);
void resolve(VariableValues *l,
variables::KeyExclusions &ke);
void resolve(const std::string &key,
std::vector<std::shared_ptr<const VariableValue>> *l);
VariableValues *l);
void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l);
VariableValues *l);
void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l,
VariableValues *l,
variables::KeyExclusions &ke);
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,
bool spaceSeparator, int size);
void evaluate(std::vector<std::shared_ptr<const VariableValue>> *l);
void evaluate(VariableValues *l);
std::string * evaluate();
std::unique_ptr<std::string> resolveFirst();

View File

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

View File

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

View File

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

View File

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

View File

@ -86,7 +86,7 @@ void InMemoryPerProcess::del(const std::string& key) {
void InMemoryPerProcess::resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) {
VariableValues *l) {
auto range = this->equal_range(var);
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,
std::vector<std::shared_ptr<const VariableValue>> *l, variables::KeyExclusions &ke) {
VariableValues *l, variables::KeyExclusions &ke) {
size_t keySize = var.size();
l->reserve(15);
@ -120,7 +120,7 @@ void InMemoryPerProcess::resolveMultiMatches(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) {
// return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@ namespace modsecurity {
namespace variables {
void HighestSeverity::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) {
VariableValues *l) {
transaction->m_variableHighestSeverityAction.assign(
std::to_string(transaction->m_highestSeverityAction));
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,
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) { }
void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override {
VariableValues *l) override {
t->m_collections.m_ip_collection->resolveMultiMatches(
*getVariableKey(), t->m_collections.m_ip_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -56,7 +56,7 @@ class Ip_NoDictElement : public Variable {
: Variable("IP") { }
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_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -71,7 +71,7 @@ class Ip_DictElementRegexp : public VariableRegex {
m_dictElement(dictElement) { }
void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override {
VariableValues *l) override {
t->m_collections.m_ip_collection->resolveRegularExpression(
m_dictElement, t->m_collections.m_ip_collection_key,
t->m_rules->m_secWebAppId.m_value, l, m_keyExclusion);
@ -91,7 +91,7 @@ class Ip_DynamicElement : public VariableWithRunTimeString {
{ }
void evaluate(Transaction *t,
std::vector<std::shared_ptr<const VariableValue>> *l) override {
VariableValues *l) override {
std::string string = m_string->evaluate(t);
t->m_collections.m_ip_collection->resolveMultiMatches(
string,

View File

@ -25,7 +25,7 @@ namespace modsecurity {
namespace variables {
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));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ namespace modsecurity {
namespace variables {
void TimeEpoch::evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) {
VariableValues *l) {
transaction->m_variableTimeEpoch.assign(
std::to_string(std::time(nullptr)));
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") { }
void evaluate(Transaction *transaction,
std::vector<std::shared_ptr<const VariableValue>> *l) override;
VariableValues *l) override;
std::string m_retName;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ class WebAppId : public Variable {
: Variable("WEBAPPID") { }
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;
l->push_back(std::make_shared<VariableValue>(getVariableKeyWithCollection().get(), &rname));
}

View File

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

View File

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