Skip to content

Commit 09a6f51

Browse files
committed
Removes unecessary static methods from regex class
1 parent 820379b commit 09a6f51

File tree

12 files changed

+15
-30
lines changed

12 files changed

+15
-30
lines changed

src/anchored_set_variable.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
127127
void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r,
128128
std::vector<const VariableValue *> *l) {
129129
for (const auto& x : *this) {
130-
int ret = regex::regex_search(x.first, *r);
130+
int ret = r->search(x.first);
131131
if (ret <= 0) {
132132
continue;
133133
}
@@ -140,7 +140,7 @@ 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 = regex::regex_search(x.first, *r);
143+
int ret = r->search(x.first);
144144
if (ret <= 0) {
145145
continue;
146146
}

src/audit_log/audit_log.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ bool AuditLog::isRelevant(int status) {
279279
return true;
280280
}
281281

282-
return regex::regex_search(sstatus,
283-
regex::Regex(m_relevant)) != 0;
282+
return regex::Regex(m_relevant).search(sstatus) != 0;
284283
}
285284

286285

src/collection/backend/in_memory-per_process.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 = regex::regex_search(x.first, r);
151+
int ret = r.search(x.first);
152152
if (ret <= 0) {
153153
continue;
154154
}

src/collection/backend/lmdb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 = regex::regex_search(a, r);
563+
int ret = r.search(a);
564564
if (ret <= 0) {
565565
continue;
566566
}

src/operators/rx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
namespace modsecurity {
2929
using regex::RegexMatch;
30-
using regex::regex_search;
3130
using regex::Regex;
3231

3332
namespace operators {

src/operators/verify_cpf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
namespace modsecurity {
2828
using regex::RegexMatch;
29-
using regex::regex_search;
3029
using regex::Regex;
3130

3231
namespace operators {

src/operators/verify_ssn.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
namespace modsecurity {
2828
using regex::RegexMatch;
29-
using regex::regex_search;
3029
using regex::Regex;
3130

3231
namespace operators {

src/regex/regex.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ class Regex {
6969
};
7070

7171

72-
static inline int regex_search(const std::string& s, RegexMatch *match, const Regex& regex) {
73-
return regex.search(s, match);
74-
}
75-
76-
77-
static inline int regex_search(const std::string& s, const Regex& regex) {
78-
return regex.search(s);
79-
}
80-
81-
8272
} // namespace regex
8373
} // namespace modsecurity
8474

src/variables/rule.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,23 @@ class Rule_DictElementRegexp : public VariableRegex {
198198
void evaluate(Transaction *t,
199199
Rule *rule,
200200
std::vector<const VariableValue *> *l) override {
201-
if (regex::regex_search("id", m_r) > 0) {
201+
if (m_r.search("id") > 0) {
202202
Rule_DictElement::id(t, rule, l);
203203
return;
204204
}
205-
if (regex::regex_search("rev", m_r) > 0) {
205+
if (m_r.search("rev") > 0) {
206206
Rule_DictElement::rev(t, rule, l);
207207
return;
208208
}
209-
if (regex::regex_search("severity", m_r) > 0) {
209+
if (m_r.search("severity") > 0) {
210210
Rule_DictElement::severity(t, rule, l);
211211
return;
212212
}
213-
if (regex::regex_search("logdata", m_r) > 0) {
213+
if (m_r.search("logdata") > 0) {
214214
Rule_DictElement::logData(t, rule, l);
215215
return;
216216
}
217-
if (regex::regex_search("msg", m_r) > 0) {
217+
if (m_r.search("msg") > 0) {
218218
Rule_DictElement::msg(t, rule, l);
219219
return;
220220
}

test/regression/custom_debug_log.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void CustomDebugLog::write(int level, const std::string &id,
3939
bool CustomDebugLog::contains(const std::string& pattern) {
4040
modsecurity::regex::Regex re(pattern);
4141
std::string s = m_log.str();
42-
return modsecurity::regex::regex_search(s, re);
42+
return re.search(s);
4343
}
4444

4545
std::string CustomDebugLog::log_messages() {

test/regression/regression.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ using modsecurity_test::ModSecurityTestResults;
3939
using modsecurity_test::RegressionTest;
4040
using modsecurity_test::RegressionTestResult;
4141

42-
using modsecurity::regex::regex_search;
4342
using modsecurity::regex::RegexMatch;
4443
using modsecurity::regex::Regex;
4544

@@ -55,7 +54,7 @@ void print_help() {
5554
bool contains(const std::string &s, const std::string &pattern) {
5655
bool ret;
5756
modsecurity::regex::Regex re(pattern);
58-
ret = modsecurity::regex::regex_search(s, re);
57+
ret = re.search(s);
5958
return ret;
6059
}
6160

@@ -210,7 +209,7 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
210209
RegexMatch match;
211210
std::string s = modsec_rules->getParserError();
212211

213-
if (regex_search(s, &match, re)) {
212+
if (re.search(s, &match)) {
214213
if (test->m_automake_output) {
215214
std::cout << ":test-result: PASS " << filename \
216215
<< ":" << t->name << std::endl;

test/unit/unit_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ void json2bin(std::string *str) {
6262
modsecurity::regex::Regex re2("\\\\u([a-z0-9A-Z]{4})");
6363
modsecurity::regex::RegexMatch match;
6464

65-
while (modsecurity::regex::regex_search(*str, &match, re)) {
65+
while (re.search(*str, &match)) {
6666
unsigned int p;
6767
std::string toBeReplaced = match.str();
6868
toBeReplaced.erase(0, 2);
6969
sscanf(toBeReplaced.c_str(), "%x", &p);
7070
replaceAll(str, match.str(), p);
7171
}
7272

73-
while (modsecurity::regex::regex_search(*str, &match, re2)) {
73+
while (re2.search(*str, &match)) {
7474
unsigned int p;
7575
std::string toBeReplaced = match.str();
7676
toBeReplaced.erase(0, 2);

0 commit comments

Comments
 (0)