Renames collection::Variable to VariableValue

This commit is contained in:
Felipe Zimmerle
2018-02-02 18:50:04 -03:00
parent de7c5c89bb
commit eeec7efb68
137 changed files with 304 additions and 361 deletions

View File

@@ -29,7 +29,7 @@
#include <memory>
#endif
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#ifndef HEADERS_MODSECURITY_ANCHORED_SET_VARIABLE_H_
#define HEADERS_MODSECURITY_ANCHORED_SET_VARIABLE_H_
@@ -66,7 +66,7 @@ struct MyHash{
class AnchoredSetVariable : public std::unordered_multimap<std::string,
collection::Variable *, MyHash, MyEqual> {
VariableValue *, MyHash, MyEqual> {
public:
AnchoredSetVariable(Transaction *t, std::string name);
~AnchoredSetVariable();
@@ -81,13 +81,13 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string,
void setCopy(std::string key, std::string value, size_t offset);
void resolve(std::vector<const collection::Variable *> *l);
void resolve(std::vector<const VariableValue *> *l);
void resolve(const std::string &key,
std::vector<const collection::Variable *> *l);
std::vector<const VariableValue *> *l);
void resolveRegularExpression(Utils::Regex *r,
std::vector<const collection::Variable *> *l);
std::vector<const VariableValue *> *l);
std::unique_ptr<std::string> resolveFirst(const std::string &key);

View File

@@ -28,7 +28,7 @@
#include <memory>
#endif
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#ifndef HEADERS_MODSECURITY_ANCHORED_VARIABLE_H_
#define HEADERS_MODSECURITY_ANCHORED_VARIABLE_H_
@@ -53,7 +53,7 @@ class AnchoredVariable {
void append(const std::string &a, size_t offset,
bool spaceSeparator, int size);
void evaluate(std::vector<const collection::Variable *> *l);
void evaluate(std::vector<const VariableValue *> *l);
std::string * evaluate();
std::unique_ptr<std::string> resolveFirst();
@@ -63,7 +63,7 @@ class AnchoredVariable {
std::string m_value;
private:
collection::Variable *m_var;
VariableValue *m_var;
};
} // namespace modsecurity

View File

@@ -25,7 +25,8 @@
#endif
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#ifndef HEADERS_MODSECURITY_COLLECTION_COLLECTION_H_
#define HEADERS_MODSECURITY_COLLECTION_COLLECTION_H_
@@ -56,11 +57,11 @@ class Collection {
const std::string& var) = 0;
virtual void resolveSingleMatch(const std::string& var,
std::vector<const Variable *> *l) = 0;
std::vector<const VariableValue *> *l) = 0;
virtual void resolveMultiMatches(const std::string& var,
std::vector<const Variable *> *l) = 0;
std::vector<const VariableValue *> *l) = 0;
virtual void resolveRegularExpression(const std::string& var,
std::vector<const Variable *> *l) = 0;
std::vector<const VariableValue *> *l) = 0;
/* store */
@@ -140,7 +141,7 @@ class Collection {
/* resolveSingleMatch */
virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::vector<const Variable *> *l) {
std::string compartment, std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + var;
resolveSingleMatch(nkey, l);
}
@@ -148,7 +149,7 @@ class Collection {
virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<const Variable *> *l) {
std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveSingleMatch(nkey, l);
}
@@ -156,7 +157,7 @@ class Collection {
/* resolveMultiMatches */
virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::vector<const Variable *> *l) {
std::string compartment, std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + var;
resolveMultiMatches(nkey, l);
}
@@ -164,7 +165,7 @@ class Collection {
virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<const Variable *> *l) {
std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveMultiMatches(nkey, l);
}
@@ -172,7 +173,7 @@ class Collection {
/* resolveRegularExpression */
virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::vector<const Variable *> *l) {
std::string compartment, std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + var;
resolveRegularExpression(nkey, l);
}
@@ -180,7 +181,7 @@ class Collection {
virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<const Variable *> *l) {
std::vector<const VariableValue *> *l) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveRegularExpression(nkey, l);
}

View File

@@ -29,7 +29,7 @@
#endif
#include "modsecurity/collection/collection.h"
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#ifndef HEADERS_MODSECURITY_COLLECTION_COLLECTIONS_H_
#define HEADERS_MODSECURITY_COLLECTION_COLLECTIONS_H_

View File

@@ -26,7 +26,7 @@
#define HEADERS_MODSECURITY_RULE_H_
#include "modsecurity/transaction.h"
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#ifdef __cplusplus
@@ -55,7 +55,7 @@ class Rule {
virtual bool evaluate(Transaction *transaction,
std::shared_ptr<RuleMessage> rm);
bool evaluateActions(Transaction *transaction);
std::vector<std::unique_ptr<collection::Variable>>
std::vector<std::unique_ptr<VariableValue>>
getFinalVars(Transaction *trasn);
void executeActionsAfterFullMatch(Transaction *trasn,
bool containsDisruptive, std::shared_ptr<RuleMessage> ruleMessage);

View File

@@ -40,11 +40,11 @@ typedef struct Transaction_t Transaction;
typedef struct Rules_t Rules;
#endif
#include "modsecurity/anchored_set_variable.h"
#include "modsecurity/anchored_variable.h"
#include "anchored_set_variable.h"
#include "anchored_variable.h"
#include "modsecurity/intervention.h"
#include "modsecurity/collection/collections.h"
#include "modsecurity/collection/variable.h"
#include "modsecurity/variable_value.h"
#include "modsecurity/collection/collection.h"
#include "modsecurity/variable_origin.h"

View File

@@ -24,28 +24,27 @@
#include "modsecurity/variable_origin.h"
#ifndef HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
#define HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
#ifndef HEADERS_MODSECURITY_VARIABLE_H_
#define HEADERS_MODSECURITY_VARIABLE_H_
#ifndef __cplusplus
typedef struct Variable_t Variable;
typedef struct Variable_t VariableValue;
#endif
#ifdef __cplusplus
namespace modsecurity {
namespace collection {
class Collection;
class Variable {
class VariableValue {
public:
explicit Variable(const std::string *key) :
explicit VariableValue(const std::string *key) :
m_key(""),
m_value("") {
m_key.assign(*key);
m_keyWithCollection = std::make_shared<std::string>(*key);
}
Variable(const std::string *key, const std::string *value) :
VariableValue(const std::string *key, const std::string *value) :
m_key(""),
m_value("") {
m_key.assign(*key);
@@ -53,26 +52,26 @@ class Variable {
m_keyWithCollection = std::make_shared<std::string>(*key);
}
Variable() :
VariableValue() :
m_key(""),
m_value("") {
m_keyWithCollection = std::make_shared<std::string>(m_key);
}
Variable(const std::string *a, const std::string *b, const std::string *c) :
VariableValue(const std::string *a, const std::string *b, const std::string *c) :
m_key(*a + ":" + *b),
m_value(*c) {
m_keyWithCollection = std::make_shared<std::string>(*a + ":" + *b);
}
Variable(std::shared_ptr<std::string> fullName) :
VariableValue(std::shared_ptr<std::string> fullName) :
m_key(""),
m_value("") {
m_keyWithCollection = fullName;
m_key.assign(*fullName.get());
}
Variable(std::shared_ptr<std::string> fullName, const std::string *value) :
VariableValue(std::shared_ptr<std::string> fullName, const std::string *value) :
m_key(""),
m_value("") {
m_value.assign(*value);
@@ -81,7 +80,7 @@ class Variable {
}
explicit Variable(const Variable *o) :
explicit VariableValue(const VariableValue *o) :
m_key(""),
m_value("") {
m_key.assign(o->m_key);
@@ -104,8 +103,7 @@ class Variable {
std::list<std::unique_ptr<VariableOrigin>> m_orign;
};
} // namespace collection
} // namespace modsecurity
#endif
#endif // HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
#endif // HEADERS_MODSECURITY_VARIABLE_H_