diff --git a/src/anchored_set_variable.cc b/src/anchored_set_variable.cc index 00697747..1f84ae26 100644 --- a/src/anchored_set_variable.cc +++ b/src/anchored_set_variable.cc @@ -127,7 +127,7 @@ std::unique_ptr AnchoredSetVariable::resolveFirst( void AnchoredSetVariable::resolveRegularExpression(regex::Regex *r, std::vector *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 *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; } diff --git a/src/audit_log/audit_log.cc b/src/audit_log/audit_log.cc index 88ba0a66..ca832078 100644 --- a/src/audit_log/audit_log.cc +++ b/src/audit_log/audit_log.cc @@ -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; } diff --git a/src/collection/backend/in_memory-per_process.cc b/src/collection/backend/in_memory-per_process.cc index 27d8f3db..d15700a7 100644 --- a/src/collection/backend/in_memory-per_process.cc +++ b/src/collection/backend/in_memory-per_process.cc @@ -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; } diff --git a/src/collection/backend/lmdb.cc b/src/collection/backend/lmdb.cc index b716e041..a7d0b3e9 100644 --- a/src/collection/backend/lmdb.cc +++ b/src/collection/backend/lmdb.cc @@ -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(key.mv_data); - int ret = regex::regex_search(a, r); + int ret = r.search(a); if (ret <= 0) { continue; } diff --git a/src/operators/rx.h b/src/operators/rx.h index 27c0a762..f7ca7b90 100644 --- a/src/operators/rx.h +++ b/src/operators/rx.h @@ -27,7 +27,6 @@ namespace modsecurity { using regex::RegexMatch; -using regex::regex_search; using regex::Regex; namespace operators { diff --git a/src/operators/verify_cpf.h b/src/operators/verify_cpf.h index ba11a15c..05f4bd79 100644 --- a/src/operators/verify_cpf.h +++ b/src/operators/verify_cpf.h @@ -26,7 +26,6 @@ namespace modsecurity { using regex::RegexMatch; -using regex::regex_search; using regex::Regex; namespace operators { diff --git a/src/operators/verify_ssn.h b/src/operators/verify_ssn.h index 39ffaead..97c5c6f0 100644 --- a/src/operators/verify_ssn.h +++ b/src/operators/verify_ssn.h @@ -26,7 +26,6 @@ namespace modsecurity { using regex::RegexMatch; -using regex::regex_search; using regex::Regex; namespace operators { diff --git a/src/regex/regex.h b/src/regex/regex.h index 6687d35e..dd579a36 100644 --- a/src/regex/regex.h +++ b/src/regex/regex.h @@ -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 diff --git a/src/variables/rule.h b/src/variables/rule.h index ba57a88f..dcde2824 100644 --- a/src/variables/rule.h +++ b/src/variables/rule.h @@ -198,23 +198,23 @@ class Rule_DictElementRegexp : public VariableRegex { void evaluate(Transaction *t, Rule *rule, std::vector *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; } diff --git a/test/regression/custom_debug_log.cc b/test/regression/custom_debug_log.cc index a86911c9..f7279a8e 100644 --- a/test/regression/custom_debug_log.cc +++ b/test/regression/custom_debug_log.cc @@ -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() { diff --git a/test/regression/regression.cc b/test/regression/regression.cc index f245565f..6555a88d 100644 --- a/test/regression/regression.cc +++ b/test/regression/regression.cc @@ -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 *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; diff --git a/test/unit/unit_test.cc b/test/unit/unit_test.cc index ca856f44..cca8c719 100644 --- a/test/unit/unit_test.cc +++ b/test/unit/unit_test.cc @@ -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);