Skip to content

Commit f2996d6

Browse files
authored
Merge pull request #3383 from airween/v2/pcre2default
chore: refactor build system to use PCRE2
2 parents 9bc3300 + 854906d commit f2996d6

14 files changed

+105
-106
lines changed

.github/workflows/ci.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ jobs:
1313
platform: [x32, x64]
1414
compiler: [gcc, clang]
1515
configure:
16-
- {label: "with pcre, no study, no jit", opt: "--enable-pcre-study=no" }
17-
- {label: "with pcre, with study, no jit", opt: "--enable-pcre-study=yes" }
18-
- {label: "with pcre, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
19-
- {label: "with pcre, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
20-
- {label: "with pcre2", opt: "--with-pcre2 --enable-pcre-study=no" }
21-
- {label: "with pcre2, with study, no jit", opt: "--with-pcre2 --enable-pcre-study=yes" }
22-
- {label: "with pcre2, no study, with jit", opt: "--with-pcre2 --enable-pcre-study=no --enable-pcre-jit" }
23-
- {label: "with pcre2, with study, with jit", opt: "--with-pcre2 --enable-pcre-study=yes --enable-pcre-jit" }
24-
- {label: "with lua", opt: "--with-lua" }
25-
- {label: "wo lua", opt: "--without-lua" }
16+
- {label: "with pcre2, no study, no jit", opt: "--enable-pcre-study=no" }
17+
- {label: "with pcre2, with study, no jit", opt: "--enable-pcre-study=yes" }
18+
- {label: "with pcre2, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
19+
- {label: "with pcre2, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
20+
- {label: "with pcre", opt: "--with-pcre --enable-pcre-study=no" }
21+
- {label: "with pcre, with study, no jit", opt: "--with-pcre --enable-pcre-study=yes" }
22+
- {label: "with pcre, no study, with jit", opt: "--with-pcre --enable-pcre-study=no --enable-pcre-jit" }
23+
- {label: "with pcre, with study, with jit", opt: "--with-pcre --enable-pcre-study=yes --enable-pcre-jit" }
24+
- {label: "with lua", opt: "--with-lua" }
25+
- {label: "wo lua", opt: "--without-lua" }
2626
steps:
2727
- name: Setup Dependencies
2828
run: |
@@ -83,16 +83,16 @@ jobs:
8383
platform: [x32, x64]
8484
compiler: [gcc, clang]
8585
configure:
86-
- {label: "with pcre, no study, no jit", opt: "--enable-pcre-study=no" }
87-
- {label: "with pcre, with study, no jit", opt: "--enable-pcre-study=yes" }
88-
- {label: "with pcre, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
89-
- {label: "with pcre, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
90-
- {label: "with pcre2", opt: "--with-pcre2 --enable-pcre-study=no" }
91-
- {label: "with pcre2, with study, no jit", opt: "--with-pcre2 --enable-pcre-study=yes" }
92-
- {label: "with pcre2, no study, with jit", opt: "--with-pcre2 --enable-pcre-study=no --enable-pcre-jit" }
93-
- {label: "with pcre2, with study, with jit", opt: "--with-pcre2 --enable-pcre-study=yes --enable-pcre-jit" }
94-
- {label: "with lua", opt: "--with-lua" }
95-
- {label: "wo lua", opt: "--without-lua" }
86+
- {label: "with pcre2, no study, no jit", opt: "--enable-pcre-study=no" }
87+
- {label: "with pcre2, with study, no jit", opt: "--enable-pcre-study=yes" }
88+
- {label: "with pcre2, no study, with jit", opt: "--enable-pcre-study=no --enable-pcre-jit" }
89+
- {label: "with pcre2, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
90+
- {label: "with pcre", opt: "--with-pcre --enable-pcre-study=no" }
91+
- {label: "with pcre, with study, no jit", opt: "--with-pcre --enable-pcre-study=yes" }
92+
- {label: "with pcre, no study, with jit", opt: "--with-pcre --enable-pcre-study=no --enable-pcre-jit" }
93+
- {label: "with pcre, with study, with jit", opt: "--with-pcre --enable-pcre-study=yes --enable-pcre-jit" }
94+
- {label: "with lua", opt: "--with-lua" }
95+
- {label: "wo lua", opt: "--without-lua" }
9696
steps:
9797
- name: Setup Dependencies
9898
run: |

apache2/apache2_config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ static const char *cmd_audit_log_relevant_status(cmd_parms *cmd, void *_dcfg,
13431343
assert(p1 != NULL);
13441344
directory_config *dcfg = _dcfg;
13451345

1346-
#ifdef WITH_PCRE2
1346+
#ifndef WITH_PCRE
13471347
dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE2_DOTALL, NULL, NULL);
13481348
#else
13491349
dcfg->auditlog_relevant_regex = msc_pregcomp(cmd->pool, p1, PCRE_DOTALL, NULL, NULL);

apache2/mod_security2.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void version(apr_pool_t *mp, server_rec* s) {
116116
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, "ModSecurity: Loaded APR do not match with compiled!");
117117
}
118118

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

128128
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL,
129-
#ifdef WITH_PCRE2
129+
#ifndef WITH_PCRE
130130
"ModSecurity: PCRE2 compiled version=\"%s\"; "
131131
#else
132132
"ModSecurity: PCRE compiled version=\"%s\"; "

apache2/modsecurity.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static int is_response_status_relevant(modsec_rec *msr, int status) {
584584

585585
rc = msc_regexec(msr->txcfg->auditlog_relevant_regex, buf, strlen(buf), &my_error_msg);
586586
if (rc >= 0) return 1;
587-
#ifdef WITH_PCRE2
587+
#ifndef WITH_PCRE
588588
if (rc == PCRE2_ERROR_NOMATCH) return 0;
589589
#else
590590
if (rc == PCRE_ERROR_NOMATCH) return 0;

apache2/msc_crypt.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
388388
case HASH_URL_HREF_HASH_RX:
389389
if(em[i]->type == HASH_URL_HREF_HASH_RX) {
390390
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
391-
#ifdef WITH_PCRE2
391+
#ifndef WITH_PCRE
392392
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
393393
#else
394394
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
@@ -421,7 +421,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
421421
msr_log(msr, 4, "%s.", error_msg);
422422
return -1;
423423
}
424-
#ifdef WITH_PCRE2
424+
#ifndef WITH_PCRE
425425
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
426426
#else
427427
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
@@ -451,7 +451,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
451451
case HASH_URL_FACTION_HASH_RX:
452452
if(em[i]->type == HASH_URL_FACTION_HASH_RX) {
453453
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
454-
#ifdef WITH_PCRE2
454+
#ifndef WITH_PCRE
455455
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
456456
#else
457457
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
@@ -484,7 +484,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
484484
msr_log(msr, 4, "%s.", error_msg);
485485
return -1;
486486
}
487-
#ifdef WITH_PCRE2
487+
#ifndef WITH_PCRE
488488
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
489489
#else
490490
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
@@ -514,7 +514,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
514514
case HASH_URL_LOCATION_HASH_RX:
515515
if(em[i]->type == HASH_URL_LOCATION_HASH_RX) {
516516
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
517-
#ifdef WITH_PCRE2
517+
#ifndef WITH_PCRE
518518
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
519519
#else
520520
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
@@ -547,7 +547,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
547547
msr_log(msr, 4, "%s.", error_msg);
548548
return -1;
549549
}
550-
#ifdef WITH_PCRE2
550+
#ifndef WITH_PCRE
551551
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
552552
#else
553553
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
@@ -577,7 +577,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
577577
case HASH_URL_IFRAMESRC_HASH_RX:
578578
if(em[i]->type == HASH_URL_IFRAMESRC_HASH_RX) {
579579
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
580-
#ifdef WITH_PCRE2
580+
#ifndef WITH_PCRE
581581
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
582582
#else
583583
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
@@ -610,7 +610,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
610610
msr_log(msr, 4, "%s.", error_msg);
611611
return -1;
612612
}
613-
#ifdef WITH_PCRE2
613+
#ifndef WITH_PCRE
614614
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
615615
#else
616616
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */
@@ -640,7 +640,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
640640
case HASH_URL_FRAMESRC_HASH_RX:
641641
if(em[i]->type == HASH_URL_FRAMESRC_HASH_RX) {
642642
rc = msc_regexec_capture(em[i]->param_data, link, strlen(link), ovector, 30, &my_error_msg);
643-
#ifdef WITH_PCRE2
643+
#ifndef WITH_PCRE
644644
if ((rc == PCRE2_ERROR_MATCHLIMIT) || (rc == PCRE2_ERROR_RECURSIONLIMIT)) {
645645
#else
646646
if ((rc == PCRE_ERROR_MATCHLIMIT) || (rc == PCRE_ERROR_RECURSIONLIMIT)) {
@@ -673,7 +673,7 @@ int do_hash_method(modsec_rec *msr, char *link, int type) {
673673
msr_log(msr, 4, "%s.", error_msg);
674674
return -1;
675675
}
676-
#ifdef WITH_PCRE2
676+
#ifndef WITH_PCRE
677677
if (rc != PCRE2_ERROR_NOMATCH) { /* Match. */
678678
#else
679679
if (rc != PCRE_ERROR_NOMATCH) { /* Match. */

apache2/msc_pcre.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) {
2222
if (regex != NULL) {
23-
#ifdef WITH_PCRE2
23+
#ifndef WITH_PCRE
2424
if (regex->match_context != NULL) {
2525
pcre2_match_context_free(regex->match_context);
2626
regex->match_context = NULL;
@@ -55,7 +55,7 @@ static apr_status_t msc_pcre_cleanup(msc_regex_t *regex) {
5555
void *msc_pregcomp_ex(apr_pool_t *pool, const char *pattern, int options,
5656
const char **_errptr, int *_erroffset,
5757
int match_limit, int match_limit_recursion)
58-
#ifdef WITH_PCRE2
58+
#ifndef WITH_PCRE
5959
{
6060
msc_regex_t *regex = NULL;
6161
PCRE2_SPTR pcre2_pattern;
@@ -239,7 +239,7 @@ int msc_regexec_ex(msc_regex_t *regex, const char *s, unsigned int slen,
239239
if (error_msg == NULL) return -1000; /* To differentiate from PCRE as it already uses -1. */
240240
*error_msg = NULL;
241241

242-
#ifdef WITH_PCRE2
242+
#ifndef WITH_PCRE
243243
{
244244
PCRE2_SPTR pcre2_s;
245245
int pcre2_ret;
@@ -319,7 +319,7 @@ int msc_regexec(msc_regex_t *regex, const char *s, unsigned int slen,
319319
*/
320320
int msc_fullinfo(msc_regex_t *regex, int what, void *where)
321321
{
322-
#ifdef WITH_PCRE2
322+
#ifndef WITH_PCRE
323323
return pcre2_pattern_info(regex->re, (uint32_t)what, where);
324324
#else
325325
return pcre_fullinfo(regex->re, regex->pe, what, where);

apache2/msc_pcre.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
typedef struct msc_regex_t msc_regex_t;
1919

20-
#ifdef WITH_PCRE2
20+
#ifndef WITH_PCRE
2121
#define PCRE2_CODE_UNIT_WIDTH 8
2222
#include "pcre2.h"
2323
#else
@@ -42,7 +42,7 @@ typedef struct msc_regex_t msc_regex_t;
4242
#include "modsecurity.h"
4343

4444
struct msc_regex_t {
45-
#ifdef WITH_PCRE2
45+
#ifndef WITH_PCRE
4646
pcre2_code *re;
4747
pcre2_match_context *match_context;
4848
#ifdef WITH_PCRE_JIT

apache2/msc_status_engine.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ int DSOLOCAL msc_beacon_string (char *beacon_string, int beacon_string_max_len)
349349

350350
apr = APR_VERSION_STRING;
351351
apr_loaded = apr_version_string();
352-
#ifdef WITH_PCRE2
352+
#ifndef WITH_PCRE
353353
apr_snprintf(pcre, 7, "%d.%d", PCRE2_MAJOR, PCRE2_MINOR);
354354
pcre_loaded = ""; /* complete this if/when status reactivated */
355355
#else

0 commit comments

Comments
 (0)