mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-16 01:22:18 +03:00
Renames SMatch to RegexMatch
This commit is contained in:
@@ -228,9 +228,9 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
|
||||
const unsigned char *buf;
|
||||
size_t jsonSize;
|
||||
|
||||
std::list<regex::SMatch> vars = variables.searchAll(matchString);
|
||||
std::list<regex::SMatch> ops = operators.searchAll(matchString);
|
||||
std::list<regex::SMatch> trans = transformations.searchAll(matchString);
|
||||
std::list<regex::RegexMatch> vars = variables.searchAll(matchString);
|
||||
std::list<regex::RegexMatch> ops = operators.searchAll(matchString);
|
||||
std::list<regex::RegexMatch> trans = transformations.searchAll(matchString);
|
||||
|
||||
g = yajl_gen_alloc(NULL);
|
||||
if (g == NULL) {
|
||||
|
||||
@@ -38,7 +38,7 @@ bool Rx::init(const std::string &arg, std::string *error) {
|
||||
|
||||
bool Rx::evaluate(Transaction *transaction, Rule *rule,
|
||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
std::list<SMatch> matches;
|
||||
std::list<RegexMatch> matches;
|
||||
Regex *re;
|
||||
|
||||
if (m_param.empty() && !m_string->m_containsMacro) {
|
||||
@@ -56,7 +56,7 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
|
||||
if (rule && rule->m_containsCaptureAction && transaction) {
|
||||
int i = 0;
|
||||
matches.reverse();
|
||||
for (const SMatch& a : matches) {
|
||||
for (const RegexMatch& a : matches) {
|
||||
transaction->m_collections.m_tx_collection->storeOrUpdateFirst(
|
||||
std::to_string(i), a.str());
|
||||
ms_dbg_a(transaction, 7, "Added regex subexpression TX." +
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
using regex::SMatch;
|
||||
using regex::RegexMatch;
|
||||
using regex::regex_search;
|
||||
using regex::Regex;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
|
||||
bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
|
||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
std::list<SMatch> matches;
|
||||
std::list<RegexMatch> matches;
|
||||
bool is_cpf = false;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
using regex::SMatch;
|
||||
using regex::RegexMatch;
|
||||
using regex::regex_search;
|
||||
using regex::Regex;
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ invalid:
|
||||
|
||||
bool VerifySSN::evaluate(Transaction *t, Rule *rule,
|
||||
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
|
||||
std::list<SMatch> matches;
|
||||
std::list<RegexMatch> matches;
|
||||
bool is_ssn = false;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
using regex::SMatch;
|
||||
using regex::RegexMatch;
|
||||
using regex::regex_search;
|
||||
using regex::Regex;
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ Regex::~Regex() {
|
||||
}
|
||||
|
||||
|
||||
std::list<SMatch> Regex::searchAll(const std::string& s) const {
|
||||
std::list<RegexMatch> Regex::searchAll(const std::string& s) const {
|
||||
const char *subject = s.c_str();
|
||||
const std::string tmpString = std::string(s.c_str(), s.size());
|
||||
int ovector[OVECCOUNT];
|
||||
int rc, i, offset = 0;
|
||||
std::list<SMatch> retList;
|
||||
std::list<RegexMatch> retList;
|
||||
|
||||
do {
|
||||
rc = pcre_exec(m_pc, m_pce, subject,
|
||||
@@ -87,7 +87,7 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
|
||||
}
|
||||
std::string match = std::string(tmpString, start, len);
|
||||
offset = start + len;
|
||||
retList.push_front(SMatch(match, start));
|
||||
retList.push_front(RegexMatch(match, start));
|
||||
|
||||
if (len == 0) {
|
||||
rc = 0;
|
||||
@@ -99,13 +99,13 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
|
||||
return retList;
|
||||
}
|
||||
|
||||
int Regex::search(const std::string& s, SMatch *match) const {
|
||||
int Regex::search(const std::string& s, RegexMatch *match) const {
|
||||
int ovector[OVECCOUNT];
|
||||
int ret = pcre_exec(m_pc, m_pce, s.c_str(),
|
||||
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
|
||||
if (ret > 0) {
|
||||
*match = SMatch(
|
||||
*match = RegexMatch(
|
||||
std::string(s, ovector[ret-1], ovector[ret] - ovector[ret-1]),
|
||||
0);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ namespace regex {
|
||||
|
||||
#define OVECCOUNT 30
|
||||
|
||||
class SMatch {
|
||||
class RegexMatch {
|
||||
public:
|
||||
SMatch() :
|
||||
RegexMatch() :
|
||||
m_match(),
|
||||
m_offset(0) { }
|
||||
|
||||
SMatch(const std::string &match, size_t offset) :
|
||||
RegexMatch(const std::string &match, size_t offset) :
|
||||
m_match(match),
|
||||
m_offset(offset) { }
|
||||
|
||||
@@ -58,8 +58,8 @@ class Regex {
|
||||
Regex(const Regex&) = delete;
|
||||
Regex& operator=(const Regex&) = delete;
|
||||
|
||||
std::list<SMatch> searchAll(const std::string& s) const;
|
||||
int search(const std::string &s, SMatch *m) const;
|
||||
std::list<RegexMatch> searchAll(const std::string& s) const;
|
||||
int search(const std::string &s, RegexMatch *m) const;
|
||||
int search(const std::string &s) const;
|
||||
|
||||
const std::string pattern;
|
||||
@@ -69,7 +69,7 @@ class Regex {
|
||||
};
|
||||
|
||||
|
||||
static inline int regex_search(const std::string& s, SMatch *match, const Regex& regex) {
|
||||
static inline int regex_search(const std::string& s, RegexMatch *match, const Regex& regex) {
|
||||
return regex.search(s, match);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ using modsecurity_test::RegressionTest;
|
||||
using modsecurity_test::RegressionTestResult;
|
||||
|
||||
using modsecurity::regex::regex_search;
|
||||
using modsecurity::regex::SMatch;
|
||||
using modsecurity::regex::RegexMatch;
|
||||
using modsecurity::regex::Regex;
|
||||
|
||||
std::string default_test_path = "test-cases/regression";
|
||||
@@ -207,7 +207,7 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
}
|
||||
|
||||
Regex re(t->parser_error);
|
||||
SMatch match;
|
||||
RegexMatch match;
|
||||
std::string s = modsec_rules->getParserError();
|
||||
|
||||
if (regex_search(s, &match, re)) {
|
||||
|
||||
@@ -60,7 +60,7 @@ void replaceAll(std::string *s, const std::string &search,
|
||||
void json2bin(std::string *str) {
|
||||
modsecurity::regex::Regex re("\\\\x([a-z0-9A-Z]{2})");
|
||||
modsecurity::regex::Regex re2("\\\\u([a-z0-9A-Z]{4})");
|
||||
modsecurity::regex::SMatch match;
|
||||
modsecurity::regex::RegexMatch match;
|
||||
|
||||
while (modsecurity::regex::regex_search(*str, &match, re)) {
|
||||
unsigned int p;
|
||||
|
||||
Reference in New Issue
Block a user