mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 03:57:47 +03:00
Adds first PoC for the operator offset feature
This commit is contained in:
committed by
Felipe Zimmerle
parent
9a8fc3116a
commit
ecbf292f6d
@@ -530,6 +530,7 @@ int acmp_process_quick(ACMPT *acmpt, const char **match, const char *data, size_
|
||||
ACMP *parser;
|
||||
acmp_node_t *node, *go_to;
|
||||
const char *end;
|
||||
int offset = 0;
|
||||
|
||||
if (acmpt->parser->is_failtree_done == 0) {
|
||||
acmp_prepare(acmpt->parser);
|
||||
@@ -551,7 +552,7 @@ int acmp_process_quick(ACMPT *acmpt, const char **match, const char *data, size_
|
||||
if (go_to != NULL) {
|
||||
if (go_to->is_last) {
|
||||
*match = go_to->text;
|
||||
return 1;
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
if (node == parser->root_node) break;
|
||||
@@ -562,8 +563,9 @@ int acmp_process_quick(ACMPT *acmpt, const char **match, const char *data, size_
|
||||
/* If node has o_match, then we found a pattern */
|
||||
if (node->o_match != NULL) {
|
||||
*match = node->text;
|
||||
return 1;
|
||||
return offset;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
acmpt->ptr = node;
|
||||
return 0;
|
||||
|
@@ -91,6 +91,8 @@ std::list<SMatch> Regex::searchAll(const std::string& s) {
|
||||
continue;
|
||||
}
|
||||
match.match = std::string(tmpString, start, len);
|
||||
match.m_offset = start;
|
||||
match.m_length = len;
|
||||
retList.push_front(match);
|
||||
}
|
||||
|
||||
|
@@ -31,11 +31,16 @@ namespace Utils {
|
||||
|
||||
class SMatch {
|
||||
public:
|
||||
SMatch() : size_(0) { }
|
||||
SMatch() : size_(0),
|
||||
m_offset(0),
|
||||
m_length(0),
|
||||
match("") { }
|
||||
size_t size() const { return size_; }
|
||||
std::string str() const { return match; }
|
||||
int size_;
|
||||
std::string match;
|
||||
int size_;
|
||||
int m_offset;
|
||||
int m_length;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user