Skip to content

Commit eeec7ef

Browse files
author
Felipe Zimmerle
committed
Renames collection::Variable to VariableValue
1 parent de7c5c8 commit eeec7ef

File tree

137 files changed

+304
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+304
-361
lines changed

headers/modsecurity/anchored_set_variable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <memory>
3030
#endif
3131

32-
#include "modsecurity/collection/variable.h"
32+
#include "modsecurity/variable_value.h"
3333

3434
#ifndef HEADERS_MODSECURITY_ANCHORED_SET_VARIABLE_H_
3535
#define HEADERS_MODSECURITY_ANCHORED_SET_VARIABLE_H_
@@ -66,7 +66,7 @@ struct MyHash{
6666

6767

6868
class AnchoredSetVariable : public std::unordered_multimap<std::string,
69-
collection::Variable *, MyHash, MyEqual> {
69+
VariableValue *, MyHash, MyEqual> {
7070
public:
7171
AnchoredSetVariable(Transaction *t, std::string name);
7272
~AnchoredSetVariable();
@@ -81,13 +81,13 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string,
8181

8282
void setCopy(std::string key, std::string value, size_t offset);
8383

84-
void resolve(std::vector<const collection::Variable *> *l);
84+
void resolve(std::vector<const VariableValue *> *l);
8585

8686
void resolve(const std::string &key,
87-
std::vector<const collection::Variable *> *l);
87+
std::vector<const VariableValue *> *l);
8888

8989
void resolveRegularExpression(Utils::Regex *r,
90-
std::vector<const collection::Variable *> *l);
90+
std::vector<const VariableValue *> *l);
9191

9292
std::unique_ptr<std::string> resolveFirst(const std::string &key);
9393

headers/modsecurity/anchored_variable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <memory>
2929
#endif
3030

31-
#include "modsecurity/collection/variable.h"
31+
#include "modsecurity/variable_value.h"
3232

3333
#ifndef HEADERS_MODSECURITY_ANCHORED_VARIABLE_H_
3434
#define HEADERS_MODSECURITY_ANCHORED_VARIABLE_H_
@@ -53,7 +53,7 @@ class AnchoredVariable {
5353
void append(const std::string &a, size_t offset,
5454
bool spaceSeparator, int size);
5555

56-
void evaluate(std::vector<const collection::Variable *> *l);
56+
void evaluate(std::vector<const VariableValue *> *l);
5757
std::string * evaluate();
5858
std::unique_ptr<std::string> resolveFirst();
5959

@@ -63,7 +63,7 @@ class AnchoredVariable {
6363
std::string m_value;
6464

6565
private:
66-
collection::Variable *m_var;
66+
VariableValue *m_var;
6767
};
6868

6969
} // namespace modsecurity

headers/modsecurity/collection/collection.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#endif
2626

2727

28-
#include "modsecurity/collection/variable.h"
28+
#include "modsecurity/variable_value.h"
29+
2930

3031
#ifndef HEADERS_MODSECURITY_COLLECTION_COLLECTION_H_
3132
#define HEADERS_MODSECURITY_COLLECTION_COLLECTION_H_
@@ -56,11 +57,11 @@ class Collection {
5657
const std::string& var) = 0;
5758

5859
virtual void resolveSingleMatch(const std::string& var,
59-
std::vector<const Variable *> *l) = 0;
60+
std::vector<const VariableValue *> *l) = 0;
6061
virtual void resolveMultiMatches(const std::string& var,
61-
std::vector<const Variable *> *l) = 0;
62+
std::vector<const VariableValue *> *l) = 0;
6263
virtual void resolveRegularExpression(const std::string& var,
63-
std::vector<const Variable *> *l) = 0;
64+
std::vector<const VariableValue *> *l) = 0;
6465

6566

6667
/* store */
@@ -140,47 +141,47 @@ class Collection {
140141

141142
/* resolveSingleMatch */
142143
virtual void resolveSingleMatch(const std::string& var,
143-
std::string compartment, std::vector<const Variable *> *l) {
144+
std::string compartment, std::vector<const VariableValue *> *l) {
144145
std::string nkey = compartment + "::" + var;
145146
resolveSingleMatch(nkey, l);
146147
}
147148

148149

149150
virtual void resolveSingleMatch(const std::string& var,
150151
std::string compartment, std::string compartment2,
151-
std::vector<const Variable *> *l) {
152+
std::vector<const VariableValue *> *l) {
152153
std::string nkey = compartment + "::" + compartment2 + "::" + var;
153154
resolveSingleMatch(nkey, l);
154155
}
155156

156157

157158
/* resolveMultiMatches */
158159
virtual void resolveMultiMatches(const std::string& var,
159-
std::string compartment, std::vector<const Variable *> *l) {
160+
std::string compartment, std::vector<const VariableValue *> *l) {
160161
std::string nkey = compartment + "::" + var;
161162
resolveMultiMatches(nkey, l);
162163
}
163164

164165

165166
virtual void resolveMultiMatches(const std::string& var,
166167
std::string compartment, std::string compartment2,
167-
std::vector<const Variable *> *l) {
168+
std::vector<const VariableValue *> *l) {
168169
std::string nkey = compartment + "::" + compartment2 + "::" + var;
169170
resolveMultiMatches(nkey, l);
170171
}
171172

172173

173174
/* resolveRegularExpression */
174175
virtual void resolveRegularExpression(const std::string& var,
175-
std::string compartment, std::vector<const Variable *> *l) {
176+
std::string compartment, std::vector<const VariableValue *> *l) {
176177
std::string nkey = compartment + "::" + var;
177178
resolveRegularExpression(nkey, l);
178179
}
179180

180181

181182
virtual void resolveRegularExpression(const std::string& var,
182183
std::string compartment, std::string compartment2,
183-
std::vector<const Variable *> *l) {
184+
std::vector<const VariableValue *> *l) {
184185
std::string nkey = compartment + "::" + compartment2 + "::" + var;
185186
resolveRegularExpression(nkey, l);
186187
}

headers/modsecurity/collection/collections.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#endif
3030

3131
#include "modsecurity/collection/collection.h"
32-
#include "modsecurity/collection/variable.h"
32+
#include "modsecurity/variable_value.h"
3333

3434
#ifndef HEADERS_MODSECURITY_COLLECTION_COLLECTIONS_H_
3535
#define HEADERS_MODSECURITY_COLLECTION_COLLECTIONS_H_

headers/modsecurity/rule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define HEADERS_MODSECURITY_RULE_H_
2727

2828
#include "modsecurity/transaction.h"
29-
#include "modsecurity/collection/variable.h"
29+
#include "modsecurity/variable_value.h"
3030

3131

3232
#ifdef __cplusplus
@@ -55,7 +55,7 @@ class Rule {
5555
virtual bool evaluate(Transaction *transaction,
5656
std::shared_ptr<RuleMessage> rm);
5757
bool evaluateActions(Transaction *transaction);
58-
std::vector<std::unique_ptr<collection::Variable>>
58+
std::vector<std::unique_ptr<VariableValue>>
5959
getFinalVars(Transaction *trasn);
6060
void executeActionsAfterFullMatch(Transaction *trasn,
6161
bool containsDisruptive, std::shared_ptr<RuleMessage> ruleMessage);

headers/modsecurity/transaction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ typedef struct Transaction_t Transaction;
4040
typedef struct Rules_t Rules;
4141
#endif
4242

43-
#include "modsecurity/anchored_set_variable.h"
44-
#include "modsecurity/anchored_variable.h"
43+
#include "anchored_set_variable.h"
44+
#include "anchored_variable.h"
4545
#include "modsecurity/intervention.h"
4646
#include "modsecurity/collection/collections.h"
47-
#include "modsecurity/collection/variable.h"
47+
#include "modsecurity/variable_value.h"
4848
#include "modsecurity/collection/collection.h"
4949
#include "modsecurity/variable_origin.h"
5050

headers/modsecurity/collection/variable.h renamed to headers/modsecurity/variable_value.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,54 @@
2424

2525
#include "modsecurity/variable_origin.h"
2626

27-
#ifndef HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
28-
#define HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
27+
#ifndef HEADERS_MODSECURITY_VARIABLE_H_
28+
#define HEADERS_MODSECURITY_VARIABLE_H_
2929

3030
#ifndef __cplusplus
31-
typedef struct Variable_t Variable;
31+
typedef struct Variable_t VariableValue;
3232
#endif
3333

3434
#ifdef __cplusplus
3535
namespace modsecurity {
36-
namespace collection {
3736

3837
class Collection;
39-
class Variable {
38+
class VariableValue {
4039
public:
41-
explicit Variable(const std::string *key) :
40+
explicit VariableValue(const std::string *key) :
4241
m_key(""),
4342
m_value("") {
4443
m_key.assign(*key);
4544
m_keyWithCollection = std::make_shared<std::string>(*key);
4645
}
4746

48-
Variable(const std::string *key, const std::string *value) :
47+
VariableValue(const std::string *key, const std::string *value) :
4948
m_key(""),
5049
m_value("") {
5150
m_key.assign(*key);
5251
m_value.assign(*value);
5352
m_keyWithCollection = std::make_shared<std::string>(*key);
5453
}
5554

56-
Variable() :
55+
VariableValue() :
5756
m_key(""),
5857
m_value("") {
5958
m_keyWithCollection = std::make_shared<std::string>(m_key);
6059
}
6160

62-
Variable(const std::string *a, const std::string *b, const std::string *c) :
61+
VariableValue(const std::string *a, const std::string *b, const std::string *c) :
6362
m_key(*a + ":" + *b),
6463
m_value(*c) {
6564
m_keyWithCollection = std::make_shared<std::string>(*a + ":" + *b);
6665
}
6766

68-
Variable(std::shared_ptr<std::string> fullName) :
67+
VariableValue(std::shared_ptr<std::string> fullName) :
6968
m_key(""),
7069
m_value("") {
7170
m_keyWithCollection = fullName;
7271
m_key.assign(*fullName.get());
7372
}
7473

75-
Variable(std::shared_ptr<std::string> fullName, const std::string *value) :
74+
VariableValue(std::shared_ptr<std::string> fullName, const std::string *value) :
7675
m_key(""),
7776
m_value("") {
7877
m_value.assign(*value);
@@ -81,7 +80,7 @@ class Variable {
8180
}
8281

8382

84-
explicit Variable(const Variable *o) :
83+
explicit VariableValue(const VariableValue *o) :
8584
m_key(""),
8685
m_value("") {
8786
m_key.assign(o->m_key);
@@ -104,8 +103,7 @@ class Variable {
104103
std::list<std::unique_ptr<VariableOrigin>> m_orign;
105104
};
106105

107-
} // namespace collection
108106
} // namespace modsecurity
109107
#endif
110108

111-
#endif // HEADERS_MODSECURITY_COLLECTION_VARIABLE_H_
109+
#endif // HEADERS_MODSECURITY_VARIABLE_H_

src/Makefile.am

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ pkginclude_HEADERS = \
4747
../headers/modsecurity/rules_exceptions.h \
4848
../headers/modsecurity/rules_properties.h \
4949
../headers/modsecurity/transaction.h \
50-
../headers/modsecurity/variable_origin.h
50+
../headers/modsecurity/variable_origin.h \
51+
../headers/modsecurity/variable_value.h
5152

5253

5354

5455
libmodsecurity_includesub_collection_HEADERS = \
5556
../headers/modsecurity/collection/collection.h \
56-
../headers/modsecurity/collection/collections.h \
57-
../headers/modsecurity/collection/variable.h
57+
../headers/modsecurity/collection/collections.h
58+
5859

5960

6061
libmodsecurity_includesub_actions_HEADERS = \

src/actions/set_var.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool SetVar::evaluate(Rule *rule, Transaction *t) {
4949
}
5050

5151
std::string m_variableNameExpanded;
52-
std::vector<const collection::Variable *> l;
52+
std::vector<const VariableValue *> l;
5353

5454
auto *v = m_variable.get();
5555
Variables::Tx_DynamicElement *tx = dynamic_cast<Variables::Tx_DynamicElement *> (v);
@@ -106,7 +106,7 @@ bool SetVar::evaluate(Rule *rule, Transaction *t) {
106106
}
107107

108108
try {
109-
std::vector<const collection::Variable *> l;
109+
std::vector<const VariableValue *> l;
110110
m_variable->evaluate(t, rule, &l);
111111
if (l.size() == 0) {
112112
value = 0;

src/anchored_set_variable.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
*
1414
*/
1515

16-
#include "modsecurity/anchored_set_variable.h"
17-
1816
#include <ctime>
1917
#include <iostream>
2018
#include <fstream>
2119
#include <string>
2220
#include <vector>
2321

22+
#include "modsecurity/anchored_set_variable.h"
2423
#include "modsecurity/modsecurity.h"
2524
#include "modsecurity/transaction.h"
2625
#include "src/utils/regex.h"
@@ -42,7 +41,7 @@ AnchoredSetVariable::~AnchoredSetVariable() {
4241

4342
void AnchoredSetVariable::unset() {
4443
for (const auto& x : *this) {
45-
collection::Variable *var = x.second;
44+
VariableValue *var = x.second;
4645
delete var;
4746
}
4847
clear();
@@ -53,7 +52,7 @@ void AnchoredSetVariable::set(const std::string &key,
5352
const std::string &value, size_t offset, size_t len) {
5453
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
5554
std::string *v = new std::string(value);
56-
collection::Variable *var = new collection::Variable(std::make_shared<std::string>(m_name + ":" + key), v);
55+
VariableValue *var = new VariableValue(std::make_shared<std::string>(m_name + ":" + key), v);
5756
delete v;
5857

5958
origin->m_offset = offset;
@@ -68,7 +67,7 @@ void AnchoredSetVariable::set(const std::string &key,
6867
const std::string &value, size_t offset) {
6968
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
7069
std::string *v = new std::string(value);
71-
collection::Variable *var = new collection::Variable(std::make_shared<std::string>(m_name + ":" + key), v);
70+
VariableValue *var = new VariableValue(std::make_shared<std::string>(m_name + ":" + key), v);
7271
delete v;
7372

7473
origin->m_offset = offset;
@@ -80,18 +79,18 @@ void AnchoredSetVariable::set(const std::string &key,
8079

8180

8281
void AnchoredSetVariable::resolve(
83-
std::vector<const collection::Variable *> *l) {
82+
std::vector<const VariableValue *> *l) {
8483
for (const auto& x : *this) {
85-
l->insert(l->begin(), new collection::Variable(x.second));
84+
l->insert(l->begin(), new VariableValue(x.second));
8685
}
8786
}
8887

8988

9089
void AnchoredSetVariable::resolve(const std::string &key,
91-
std::vector<const collection::Variable *> *l) {
90+
std::vector<const VariableValue *> *l) {
9291
auto range = this->equal_range(key);
9392
for (auto it = range.first; it != range.second; ++it) {
94-
l->push_back(new collection::Variable(it->second));
93+
l->push_back(new VariableValue(it->second));
9594
}
9695
}
9796

@@ -109,13 +108,13 @@ std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
109108

110109

111110
void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
112-
std::vector<const collection::Variable *> *l) {
111+
std::vector<const VariableValue *> *l) {
113112
for (const auto& x : *this) {
114113
int ret = Utils::regex_search(x.first, *r);
115114
if (ret <= 0) {
116115
continue;
117116
}
118-
l->insert(l->begin(), new collection::Variable(x.second));
117+
l->insert(l->begin(), new VariableValue(x.second));
119118
}
120119
}
121120

0 commit comments

Comments
 (0)