Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8e62341

Browse files
committed
Moving regex from utils to its own namespace
1 parent 145f2f3 commit 8e62341

File tree

22 files changed

+146
-70
lines changed

22 files changed

+146
-70
lines changed

‎headers/modsecurity/anchored_set_variable.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
namespace modsecurity {
4040
class Transaction;
41-
namespace Utils {
41+
namespace regex {
4242
class Regex;
4343
}
4444
namespace Variables {
@@ -91,10 +91,10 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string,
9191
void resolve(const std::string &key,
9292
std::vector<const VariableValue *> *l);
9393

94-
void resolveRegularExpression(Utils::Regex *r,
94+
void resolveRegularExpression(regex::Regex *r,
9595
std::vector<const VariableValue *> *l);
9696

97-
void resolveRegularExpression(Utils::Regex *r,
97+
void resolveRegularExpression(regex::Regex *r,
9898
std::vector<const VariableValue *> *l,
9999
Variables::KeyExclusions &ke);
100100

‎src/Makefile.am‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,17 @@ UTILS = \
239239
utils/md5.cc \
240240
utils/msc_tree.cc \
241241
utils/random.cc \
242-
utils/regex.cc \
243242
utils/sha1.cc \
244243
utils/string.cc \
245244
utils/system.cc \
246245
utils/shared_files.cc
247246

248247

248+
REGEX = \
249+
regex/regex.cc \
250+
regex/backend/pcre.cc
251+
252+
249253
COLLECTION = \
250254
collection/collections.cc \
251255
collection/backend/in_memory-per_process.cc \
@@ -287,6 +291,7 @@ libmodsecurity_la_SOURCES = \
287291
${COLLECTION} \
288292
${OPERATORS} \
289293
${UTILS} \
294+
${REGEX} \
290295
${VARIABLES}
291296

292297

‎src/anchored_set_variable.cc‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "modsecurity/anchored_set_variable.h"
2323
#include "modsecurity/modsecurity.h"
2424
#include "modsecurity/transaction.h"
25-
#include "src/utils/regex.h"
25+
#include "src/regex/regex.h"
2626
#include "src/variables/variable.h"
2727

2828
namespace modsecurity {
@@ -124,10 +124,10 @@ std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
124124
}
125125

126126

127-
void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
127+
void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r,
128128
std::vector<const VariableValue *> *l) {
129129
for (const auto& x : *this) {
130-
int ret = Utils::regex_search(x.first, *r);
130+
int ret = regex::regex_search(x.first, *r);
131131
if (ret <= 0) {
132132
continue;
133133
}
@@ -136,11 +136,11 @@ void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
136136
}
137137

138138

139-
void AnchoredSetVariable::resolveRegularExpression(Utils::Regex *r,
139+
void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r,
140140
std::vector<const VariableValue *> *l,
141141
Variables::KeyExclusions &ke) {
142142
for (const auto& x : *this) {
143-
int ret = Utils::regex_search(x.first, *r);
143+
int ret = regex::regex_search(x.first, *r);
144144
if (ret <= 0) {
145145
continue;
146146
}

‎src/anchored_variable.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "../headers/modsecurity/anchored_variable.h"
2323
#include "modsecurity/modsecurity.h"
2424
#include "modsecurity/transaction.h"
25-
#include "src/utils/regex.h"
25+
#include "src/regex/regex.h"
2626

2727
namespace modsecurity {
2828

‎src/audit_log/audit_log.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "src/audit_log/writer/parallel.h"
2727
#include "src/audit_log/writer/serial.h"
2828
#include "src/audit_log/writer/writer.h"
29-
#include "src/utils/regex.h"
29+
#include "src/regex/regex.h"
3030

3131
#define PARTS_CONSTAINS(a, c) \
3232
if (new_parts.find(toupper(a)) != std::string::npos \
@@ -279,8 +279,8 @@ bool AuditLog::isRelevant(int status) {
279279
return true;
280280
}
281281

282-
return Utils::regex_search(sstatus,
283-
Utils::Regex(m_relevant)) != 0;
282+
return regex::regex_search(sstatus,
283+
regex::Regex(m_relevant)) != 0;
284284
}
285285

286286

‎src/collection/backend/in_memory-per_process.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <pthread.h>
2828

2929
#include "modsecurity/variable_value.h"
30-
#include "src/utils/regex.h"
30+
#include "src/regex/regex.h"
3131
#include "src/utils/string.h"
3232

3333

@@ -134,7 +134,7 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
134134
//std::string name = std::string(var, var.find(":") + 2,
135135
// var.size() - var.find(":") - 3);
136136
//size_t keySize = col.size();
137-
Utils::Regex r(var);
137+
regex::Regex r(var);
138138

139139
for (const auto& x : *this) {
140140
//if (x.first.size() <= keySize + 1) {
@@ -148,7 +148,7 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
148148
//}
149149
//std::string content = std::string(x.first, keySize + 1,
150150
// x.first.size() - keySize - 1);
151-
int ret = Utils::regex_search(x.first, r);
151+
int ret = regex::regex_search(x.first, r);
152152
if (ret <= 0) {
153153
continue;
154154
}

‎src/collection/backend/lmdb.cc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <memory>
2424

2525
#include "modsecurity/variable_value.h"
26-
#include "src/utils/regex.h"
26+
#include "src/regex/regex.h"
2727
#include "src/variables/variable.h"
2828

2929
#undef LMDB_STDOUT_COUT
@@ -538,7 +538,7 @@ void LMDB::resolveRegularExpression(const std::string& var,
538538
MDB_cursor *cursor;
539539
size_t pos;
540540

541-
Utils::Regex r(var);
541+
regex::Regex r = regex::Regex(var);
542542

543543
rc = mdb_txn_begin(m_env, NULL, 0, &txn);
544544
lmdb_debug(rc, "txn", "resolveRegularExpression");
@@ -560,7 +560,7 @@ void LMDB::resolveRegularExpression(const std::string& var,
560560

561561
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
562562
char *a = reinterpret_cast<char *>(key.mv_data);
563-
int ret = Utils::regex_search(a, r);
563+
int ret = regex::regex_search(a, r);
564564
if (ret <= 0) {
565565
continue;
566566
}

‎src/modsecurity.cc‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "src/collection/backend/in_memory-per_process.h"
3939
#include "src/collection/backend/lmdb.h"
4040
#include "src/unique_id.h"
41-
#include "src/utils/regex.h"
41+
#include "src/regex/regex.h"
4242
#include "src/utils/geo_lookup.h"
4343
#include "src/actions/transformations/transformation.h"
4444

@@ -219,18 +219,18 @@ void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
219219
int ModSecurity::processContentOffset(const char *content, size_t len,
220220
const char *matchString, std::string *json, const char **err) {
221221
#ifdef WITH_YAJL
222-
Utils::Regex variables("v([0-9]+),([0-9]+)");
223-
Utils::Regex operators("o([0-9]+),([0-9]+)");
224-
Utils::Regex transformations("t:(?:(?!t:).)+");
222+
regex::Regex variables("v([0-9]+),([0-9]+)");
223+
regex::Regex operators("o([0-9]+),([0-9]+)");
224+
regex::Regex transformations("t:(?:(?!t:).)+");
225225
yajl_gen g;
226226
std::string varValue;
227227
std::string opValue;
228228
const unsigned char *buf;
229229
size_t jsonSize;
230230

231-
std::list<Utils::SMatch> vars = variables.searchAll(matchString);
232-
std::list<Utils::SMatch> ops = operators.searchAll(matchString);
233-
std::list<Utils::SMatch> trans = transformations.searchAll(matchString);
231+
std::list<regex::SMatch> vars = variables.searchAll(matchString);
232+
std::list<regex::SMatch> ops = operators.searchAll(matchString);
233+
std::list<regex::SMatch> trans = transformations.searchAll(matchString);
234234

235235
g = yajl_gen_alloc(NULL);
236236
if (g == NULL) {

‎src/operators/rx.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include <utility>
2323

2424
#include "src/operators/operator.h"
25-
#include "src/utils/regex.h"
25+
#include "src/regex/regex.h"
2626

2727

2828
namespace modsecurity {
29-
using Utils::SMatch;
30-
using Utils::regex_search;
31-
using Utils::Regex;
29+
using regex::SMatch;
30+
using regex::regex_search;
31+
using regex::Regex;
3232

3333
namespace operators {
3434

‎src/operators/verify_cpf.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include <utility>
2222

2323
#include "src/operators/operator.h"
24-
#include "src/utils/regex.h"
24+
#include "src/regex/regex.h"
2525

2626

2727
namespace modsecurity {
28-
using Utils::SMatch;
29-
using Utils::regex_search;
30-
using Utils::Regex;
28+
using regex::SMatch;
29+
using regex::regex_search;
30+
using regex::Regex;
3131

3232
namespace operators {
3333

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /