Removes unecessary static methods from regex class

This commit is contained in:
Felipe Zimmerle
2019-01-18 18:24:26 -03:00
parent 57fc3b5084
commit 686b6ffff7
12 changed files with 15 additions and 30 deletions

View File

@@ -127,7 +127,7 @@ std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r,
std::vector<const VariableValue *> *l) {
for (const auto& x : *this) {
int ret = regex::regex_search(x.first, *r);
int ret = r->search(x.first);
if (ret <= 0) {
continue;
}
@@ -140,7 +140,7 @@ void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r,
std::vector<const VariableValue *> *l,
Variables::KeyExclusions &ke) {
for (const auto& x : *this) {
int ret = regex::regex_search(x.first, *r);
int ret = r->search(x.first);
if (ret <= 0) {
continue;
}

View File

@@ -279,8 +279,7 @@ bool AuditLog::isRelevant(int status) {
return true;
}
return regex::regex_search(sstatus,
regex::Regex(m_relevant)) != 0;
return regex::Regex(m_relevant).search(sstatus) != 0;
}

View File

@@ -148,7 +148,7 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
//}
//std::string content = std::string(x.first, keySize + 1,
// x.first.size() - keySize - 1);
int ret = regex::regex_search(x.first, r);
int ret = r.search(x.first);
if (ret <= 0) {
continue;
}

View File

@@ -560,7 +560,7 @@ void LMDB::resolveRegularExpression(const std::string& var,
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
char *a = reinterpret_cast<char *>(key.mv_data);
int ret = regex::regex_search(a, r);
int ret = r.search(a);
if (ret <= 0) {
continue;
}

View File

@@ -27,7 +27,6 @@
namespace modsecurity {
using regex::RegexMatch;
using regex::regex_search;
using regex::Regex;
namespace operators {

View File

@@ -26,7 +26,6 @@
namespace modsecurity {
using regex::RegexMatch;
using regex::regex_search;
using regex::Regex;
namespace operators {

View File

@@ -26,7 +26,6 @@
namespace modsecurity {
using regex::RegexMatch;
using regex::regex_search;
using regex::Regex;
namespace operators {

View File

@@ -69,16 +69,6 @@ class Regex {
};
static inline int regex_search(const std::string& s, RegexMatch *match, const Regex& regex) {
return regex.search(s, match);
}
static inline int regex_search(const std::string& s, const Regex& regex) {
return regex.search(s);
}
} // namespace regex
} // namespace modsecurity

View File

@@ -198,23 +198,23 @@ class Rule_DictElementRegexp : public VariableRegex {
void evaluate(Transaction *t,
Rule *rule,
std::vector<const VariableValue *> *l) override {
if (regex::regex_search("id", m_r) > 0) {
if (m_r.search("id") > 0) {
Rule_DictElement::id(t, rule, l);
return;
}
if (regex::regex_search("rev", m_r) > 0) {
if (m_r.search("rev") > 0) {
Rule_DictElement::rev(t, rule, l);
return;
}
if (regex::regex_search("severity", m_r) > 0) {
if (m_r.search("severity") > 0) {
Rule_DictElement::severity(t, rule, l);
return;
}
if (regex::regex_search("logdata", m_r) > 0) {
if (m_r.search("logdata") > 0) {
Rule_DictElement::logData(t, rule, l);
return;
}
if (regex::regex_search("msg", m_r) > 0) {
if (m_r.search("msg") > 0) {
Rule_DictElement::msg(t, rule, l);
return;
}

View File

@@ -39,7 +39,7 @@ void CustomDebugLog::write(int level, const std::string &id,
bool CustomDebugLog::contains(const std::string& pattern) {
modsecurity::regex::Regex re(pattern);
std::string s = m_log.str();
return modsecurity::regex::regex_search(s, re);
return re.search(s);
}
std::string CustomDebugLog::log_messages() {

View File

@@ -39,7 +39,6 @@ using modsecurity_test::ModSecurityTestResults;
using modsecurity_test::RegressionTest;
using modsecurity_test::RegressionTestResult;
using modsecurity::regex::regex_search;
using modsecurity::regex::RegexMatch;
using modsecurity::regex::Regex;
@@ -55,7 +54,7 @@ void print_help() {
bool contains(const std::string &s, const std::string &pattern) {
bool ret;
modsecurity::regex::Regex re(pattern);
ret = modsecurity::regex::regex_search(s, re);
ret = re.search(s);
return ret;
}
@@ -210,7 +209,7 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
RegexMatch match;
std::string s = modsec_rules->getParserError();
if (regex_search(s, &match, re)) {
if (re.search(s, &match)) {
if (test->m_automake_output) {
std::cout << ":test-result: PASS " << filename \
<< ":" << t->name << std::endl;

View File

@@ -62,7 +62,7 @@ void json2bin(std::string *str) {
modsecurity::regex::Regex re2("\\\\u([a-z0-9A-Z]{4})");
modsecurity::regex::RegexMatch match;
while (modsecurity::regex::regex_search(*str, &match, re)) {
while (re.search(*str, &match)) {
unsigned int p;
std::string toBeReplaced = match.str();
toBeReplaced.erase(0, 2);
@@ -70,7 +70,7 @@ void json2bin(std::string *str) {
replaceAll(str, match.str(), p);
}
while (modsecurity::regex::regex_search(*str, &match, re2)) {
while (re2.search(*str, &match)) {
unsigned int p;
std::string toBeReplaced = match.str();
toBeReplaced.erase(0, 2);