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