Skip to content

chore: refactor build system to use PCRE2 #3383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v2/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
platform: [x32, x64]
compiler: [gcc, clang]
configure:
- {label: "with pcre, no study, no jit", opt: "--enable-pcre-study=no" }
- {label: "with pcre, with study, no jit", opt: "--enable-pcre-study=yes" }
- {label: "with pcre, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with pcre2", opt: "--with-pcre2 --enable-pcre-study=no" }
- {label: "with pcre2, with study, no jit", opt: "--with-pcre2 --enable-pcre-study=yes" }
- {label: "with pcre2, no study, with jit", opt: "--with-pcre2 --enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre2, with study, with jit", opt: "--with-pcre2 --enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with lua", opt: "--with-lua" }
- {label: "wo lua", opt: "--without-lua" }
- {label: "with pcre2, no study, no jit", opt: "--enable-pcre-study=no" }
- {label: "with pcre2, with study, no jit", opt: "--enable-pcre-study=yes" }
- {label: "with pcre2, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre2, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with pcre", opt: "--with-pcre --enable-pcre-study=no" }
- {label: "with pcre, with study, no jit", opt: "--with-pcre --enable-pcre-study=yes" }
- {label: "with pcre, no study, with jit", opt: "--with-pcre --enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre, with study, with jit", opt: "--with-pcre --enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with lua", opt: "--with-lua" }
- {label: "wo lua", opt: "--without-lua" }
steps:
- name: Setup Dependencies
run: |
Expand Down Expand Up @@ -83,16 +83,16 @@ jobs:
platform: [x32, x64]
compiler: [gcc, clang]
configure:
- {label: "with pcre, no study, no jit", opt: "--enable-pcre-study=no" }
- {label: "with pcre, with study, no jit", opt: "--enable-pcre-study=yes" }
- {label: "with pcre, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with pcre2", opt: "--with-pcre2 --enable-pcre-study=no" }
- {label: "with pcre2, with study, no jit", opt: "--with-pcre2 --enable-pcre-study=yes" }
- {label: "with pcre2, no study, with jit", opt: "--with-pcre2 --enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre2, with study, with jit", opt: "--with-pcre2 --enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with lua", opt: "--with-lua" }
- {label: "wo lua", opt: "--without-lua" }
- {label: "with pcre2, no study, no jit", opt: "--enable-pcre-study=no" }
- {label: "with pcre2, with study, no jit", opt: "--enable-pcre-study=yes" }
- {label: "with pcre2, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre2, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with pcre", opt: "--with-pcre --enable-pcre-study=no" }
- {label: "with pcre, with study, no jit", opt: "--with-pcre --enable-pcre-study=yes" }
- {label: "with pcre, no study, with jit", opt: "--with-pcre --enable-pcre-study=no --enable-pcre-jit" }
- {label: "with pcre, with study, with jit", opt: "--with-pcre --enable-pcre-study=yes --enable-pcre-jit" }
- {label: "with lua", opt: "--with-lua" }
- {label: "wo lua", opt: "--without-lua" }
steps:
- name: Setup Dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion apache2/apache2_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ static const char *cmd_audit_log_relevant_status(cmd_parms *cmd, void *_dcfg,
assert(p1 != NULL);
directory_config *dcfg = _dcfg;

#ifdef WITH_PCRE2
#ifndef WITH_PCRE
dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE2_DOTALL, NULL, NULL);
#else
dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE_DOTALL, NULL, NULL);
Expand Down
4 changes: 2 additions & 2 deletions apache2/mod_security2.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void version(apr_pool_t *mp, server_rec* s) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, "ModSecurity: Loaded APR do not match with compiled!");
}

#ifdef WITH_PCRE2
#ifndef WITH_PCRE
pcre_vrs = apr_psprintf(mp,"%d.%d ", PCRE2_MAJOR, PCRE2_MINOR);
pcre_loaded_vrs = pcre2_loaded_vrs_buffer;
pcre2_config(PCRE2_CONFIG_VERSION, pcre2_loaded_vrs_buffer);
Expand All @@ -126,7 +126,7 @@ static void version(apr_pool_t *mp, server_rec* s) {
#endif

ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
"ModSecurity: PCRE2 compiled version=\"%s\"; "
#else
"ModSecurity: PCRE compiled version=\"%s\"; "
Expand Down
2 changes: 1 addition & 1 deletion apache2/modsecurity.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static int is_response_status_relevant(modsec_rec *msr, int status) {

rc = msc_regexec(msr->txcfg->auditlog_relevant_regex, buf, strlen(buf), &my_error_msg);
if (rc >= 0) return 1;
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc == PCRE2_ERROR_NOMATCH) return 0;
#else
if (rc == PCRE_ERROR_NOMATCH) return 0;
Expand Down
20 changes: 10 additions & 10 deletions apache2/msc_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
case HASH_URL_HREF_HASH_RX:
if(em[i]->type == HASH_URL_HREF_HASH_RX) {
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
Expand Down Expand Up @@ -421,7 +421,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
msr_log(msr, 4, "%s.", error_msg);
return -1;
}
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
Expand Down Expand Up @@ -451,7 +451,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
case HASH_URL_FACTION_HASH_RX:
if(em[i]->type == HASH_URL_FACTION_HASH_RX) {
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
Expand Down Expand Up @@ -484,7 +484,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
msr_log(msr, 4, "%s.", error_msg);
return -1;
}
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
Expand Down Expand Up @@ -514,7 +514,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
case HASH_URL_LOCATION_HASH_RX:
if(em[i]->type == HASH_URL_LOCATION_HASH_RX) {
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
Expand Down Expand Up @@ -547,7 +547,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
msr_log(msr, 4, "%s.", error_msg);
return -1;
}
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
Expand Down Expand Up @@ -577,7 +577,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
case HASH_URL_IFRAMESRC_HASH_RX:
if(em[i]->type == HASH_URL_IFRAMESRC_HASH_RX) {
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
Expand Down Expand Up @@ -610,7 +610,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
msr_log(msr, 4, "%s.", error_msg);
return -1;
}
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
Expand Down Expand Up @@ -640,7 +640,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
case HASH_URL_FRAMESRC_HASH_RX:
if(em[i]->type == HASH_URL_FRAMESRC_HASH_RX) {
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
#else
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
Expand Down Expand Up @@ -673,7 +673,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
msr_log(msr, 4, "%s.", error_msg);
return -1;
}
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
#else
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
Expand Down
8 changes: 4 additions & 4 deletions apache2/msc_pcre.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) {
if (regex != NULL) {
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
if (regex->match_context != NULL) {
pcre2_match_context_free(regex->match_context);
regex->match_context = NULL;
Expand Down Expand Up @@ -55,7 +55,7 @@ static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) {
void *msc_pregcomp_ex(apr_pool_t *pool, const char *pattern, int options,
const char **_errptr, int *_erroffset,
int match_limit, int match_limit_recursion)
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
{
msc_regex_t *regex = NULL;
PCRE2_SPTR pcre2_pattern;
Expand Down Expand Up @@ -239,7 +239,7 @@ int msc_regexec_ex(msc_regex_t *regex, const char *s, unsigned int slen,
if (error_msg == NULL) return -1000; /* To differentiate from PCRE as it already uses -1. */
*error_msg = NULL;

#ifdef WITH_PCRE2
#ifndef WITH_PCRE
{
PCRE2_SPTR pcre2_s;
int pcre2_ret;
Expand Down Expand Up @@ -319,7 +319,7 @@ int msc_regexec(msc_regex_t *regex, const char *s, unsigned int slen,
*/
int msc_fullinfo(msc_regex_t *regex, int what, void *where)
{
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
return pcre2_pattern_info(regex->re, (uint32_t)what, where);
#else
return pcre_fullinfo(regex->re, regex->pe, what, where);
Expand Down
4 changes: 2 additions & 2 deletions apache2/msc_pcre.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

typedef struct msc_regex_t msc_regex_t;

#ifdef WITH_PCRE2
#ifndef WITH_PCRE
#define PCRE2_CODE_UNIT_WIDTH 8
#include "pcre2.h"
#else
Expand All @@ -42,7 +42,7 @@ typedef struct msc_regex_t msc_regex_t;
#include "modsecurity.h"

struct msc_regex_t {
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
pcre2_code *re;
pcre2_match_context *match_context;
#ifdef WITH_PCRE_JIT
Expand Down
2 changes: 1 addition & 1 deletion apache2/msc_status_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ int DSOLOCAL msc_beacon_string (char *beacon_string, int beacon_string_max_len)

apr = APR_VERSION_STRING;
apr_loaded = apr_version_string();
#ifdef WITH_PCRE2
#ifndef WITH_PCRE
apr_snprintf(pcre, 7, "%d.%d", PCRE2_MAJOR, PCRE2_MINOR);
pcre_loaded = ""; /* complete this if/when status reactivated */
#else
Expand Down
Loading