mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Using libpcre instead of c++11 regex
This commit is contained in:
@@ -27,6 +27,7 @@ unit_tests_LDADD = \
|
||||
$(top_builddir)/src/.libs/libmodsecurity.a \
|
||||
$(CURL_LDADD) \
|
||||
$(GEOIP_LDADD) \
|
||||
$(PCRE_LDADD) \
|
||||
$(YAJL_LDADD)
|
||||
|
||||
unit_tests_CPPFLAGS = \
|
||||
@@ -37,6 +38,7 @@ unit_tests_CPPFLAGS = \
|
||||
-I$(top_builddir)/headers \
|
||||
$(CURL_CFLAGS) \
|
||||
$(GEOIP_CFLAGS) \
|
||||
$(PCRE_CPPFLAGS) \
|
||||
$(YAJL_CFLAGS)
|
||||
|
||||
|
||||
@@ -51,6 +53,7 @@ regression_tests_LDADD = \
|
||||
$(top_builddir)/src/.libs/libmodsecurity.a \
|
||||
$(CURL_LDADD) \
|
||||
$(GEOIP_LDADD) \
|
||||
$(PCRE_LDADD) \
|
||||
$(YAJL_LDADD)
|
||||
|
||||
regression_tests_CPPFLAGS = \
|
||||
@@ -61,4 +64,5 @@ regression_tests_CPPFLAGS = \
|
||||
-I$(top_builddir)/headers \
|
||||
$(CURL_CFLAGS) \
|
||||
$(GEOIP_CFLAGS) \
|
||||
$(PCRE_CPPFLAGS) \
|
||||
$(YAJL_CFLAGS)
|
||||
|
@@ -9,11 +9,14 @@ benchmark_LDADD = \
|
||||
$(top_builddir)/src/.libs/libmodsecurity.a \
|
||||
$(CURL_LDADD) \
|
||||
$(GEOIP_LDADD) \
|
||||
$(PCRE_LDADD) \
|
||||
$(YAJL_LDADD)
|
||||
|
||||
benchmark_CPPFLAGS = \
|
||||
-std=c++11 \
|
||||
-I$(top_builddir)/headers
|
||||
-I$(top_builddir)/headers \
|
||||
$(PCRE_CPPFLAGS)
|
||||
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in
|
||||
|
@@ -17,9 +17,9 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
#include "modsecurity/debug_log.h"
|
||||
#include "utils/regex.h"
|
||||
|
||||
namespace modsecurity_test {
|
||||
|
||||
@@ -34,10 +34,11 @@ bool CustomDebugLog::write_log(int level, const std::string& message) {
|
||||
|
||||
|
||||
bool CustomDebugLog::contains(const std::string& pattern) {
|
||||
std::regex re(pattern);
|
||||
std::smatch match;
|
||||
ModSecurity::Utils::Regex re(pattern);
|
||||
ModSecurity::Utils::SMatch match;
|
||||
std::string s = m_log.str();
|
||||
return (std::regex_search(s, match, re) && match.size() >= 1);
|
||||
return (ModSecurity::Utils::regex_search(s, &match, re)
|
||||
&& match.size() >= 1);
|
||||
}
|
||||
|
||||
std::string CustomDebugLog::log_messages() {
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <regex>
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "modsecurity/rules.h"
|
||||
@@ -28,12 +27,17 @@
|
||||
#include "regression/regression_test.h"
|
||||
#include "common/modsecurity_test_results.h"
|
||||
#include "regression/custom_debug_log.h"
|
||||
#include "utils/regex.h"
|
||||
|
||||
using modsecurity_test::CustomDebugLog;
|
||||
using modsecurity_test::ModSecurityTest;
|
||||
using modsecurity_test::ModSecurityTestResults;
|
||||
using modsecurity_test::RegressionTest;
|
||||
|
||||
using ModSecurity::Utils::regex_search;
|
||||
using ModSecurity::Utils::SMatch;
|
||||
using ModSecurity::Utils::Regex;
|
||||
|
||||
std::string default_test_path = "test-cases/regression";
|
||||
|
||||
void print_help() {
|
||||
@@ -100,11 +104,11 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
|
||||
return;
|
||||
}
|
||||
|
||||
std::regex re(t->parser_error);
|
||||
std::smatch match;
|
||||
Regex re(t->parser_error);
|
||||
SMatch match;
|
||||
std::string s = modsec_rules->getParserError();
|
||||
|
||||
if (std::regex_search(s, match, re) && match.size() >= 1) {
|
||||
if (regex_search(s, &match, re) && match.size() >= 1) {
|
||||
std::cout << "passed!" << std::endl;
|
||||
return;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user