Skip to content

Commit 25343be

Browse files
authored
Merge pull request #3456 from airween/v2/regrtestfix
feat: fix regression test, add a new CI workflow
2 parents 6c78df4 + 22a23d1 commit 25343be

5 files changed

Lines changed: 45 additions & 200 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010
strategy:
1111
matrix:
12-
os: [ubuntu-22.04]
12+
os: [ubuntu-24.04]
1313
platform: [x32, x64]
1414
compiler: [gcc, clang]
1515
configure:
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup Dependencies
2828
run: |
2929
sudo apt-get update -y -qq
30-
sudo apt-get install -y apache2-dev libxml2-dev liblua5.1-0-dev libcurl4-gnutls-dev libpcre2-dev pkg-config libyajl-dev apache2 apache2-bin apache2-data
30+
sudo apt-get install -y apache2-dev libxml2-dev liblua5.1-0-dev libcurl4-gnutls-dev libpcre2-dev libpcre3-dev libpcre3 pkg-config libyajl-dev apache2 apache2-bin apache2-data
3131
- uses: actions/checkout@v2
3232
- name: autogen.sh
3333
run: ./autogen.sh
@@ -79,7 +79,7 @@ jobs:
7979
runs-on: ${{ matrix.os }}
8080
strategy:
8181
matrix:
82-
os: [ubuntu-22.04]
82+
os: [ubuntu-24.04]
8383
platform: [x32, x64]
8484
compiler: [gcc, clang]
8585
configure:
@@ -97,7 +97,7 @@ jobs:
9797
- name: Setup Dependencies
9898
run: |
9999
sudo apt-get update -y -qq
100-
sudo apt-get install -y --no-install-recommends apache2-dev libxml2-dev liblua5.1-0-dev libcurl4-gnutls-dev libpcre2-dev pkg-config libyajl-dev apache2 apache2-bin apache2-data
100+
sudo apt-get install -y --no-install-recommends apache2-dev libxml2-dev liblua5.1-0-dev libcurl4-gnutls-dev libpcre2-dev libpcre3-dev libpcre3 pkg-config libyajl-dev apache2 apache2-bin apache2-data
101101
- uses: actions/checkout@v2
102102
- name: autogen.sh
103103
run: ./autogen.sh
@@ -110,3 +110,30 @@ jobs:
110110
run: sudo make install
111111
- name: run tests
112112
run: make test
113+
114+
test-regression-linux:
115+
runs-on: ${{ matrix.os }}
116+
strategy:
117+
matrix:
118+
os: [ubuntu-24.04]
119+
platform: [x64]
120+
compiler: [gcc]
121+
configure:
122+
- {label: "with pcre2, with study, with jit", opt: "--enable-pcre-study=yes --enable-pcre-jit" }
123+
steps:
124+
- name: Setup Dependencies
125+
run: |
126+
sudo apt-get update -y -qq
127+
sudo apt-get install -y --no-install-recommends apache2-dev libxml2-dev liblua5.1-0-dev libcurl4-gnutls-dev libpcre2-dev libpcre3-dev libpcre3 pkg-config libyajl-dev apache2 apache2-bin apache2-data perl libwww-perl ssdeep libfuzzy-dev libfuzzy2
128+
- uses: actions/checkout@v2
129+
- name: autogen.sh
130+
run: ./autogen.sh
131+
- name: configure ${{ matrix.configure.label }}
132+
run: ./configure ${{ matrix.configure.opt }} 'CFLAGS=-Werror=format-security'
133+
- uses: ammaraskar/gcc-problem-matcher@0f9c86f9e693db67dacf53986e1674de5f2e5f28 #v0.3.0
134+
- name: make
135+
run: make -j `nproc`
136+
- name: install module
137+
run: sudo make install
138+
- name: run regression tests
139+
run: make test-regression

apache2/msc_lua.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
433433
#else
434434

435435
/* Create new state. */
436-
#if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504 || LUA_VERSION_NUM == 501
436+
#if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504 || LUA_VERSION_NUM == 505 || LUA_VERSION_NUM == 501
437437
L = luaL_newstate();
438438
#elif LUA_VERSION_NUM == 500
439439
L = lua_open();
440440
#else
441-
#error We are only tested under Lua 5.0, 5.1, 5.2, 5.3, or 5.4.
441+
#error We are only tested under Lua 5.0, 5.1, 5.2, 5.3, 5.4 or 5.5.
442442
#endif
443443
luaL_openlibs(L);
444444

@@ -463,10 +463,10 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
463463
/* Register functions. */
464464
#if LUA_VERSION_NUM == 500 || LUA_VERSION_NUM == 501
465465
luaL_register(L, "m", mylib);
466-
#elif LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504
466+
#elif LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504 || LUA_VERSION_NUM == 505
467467
luaL_setfuncs(L, mylib, 0);
468468
#else
469-
#error We are only tested under Lua 5.0, 5.1, 5.2, 5.3, or 5.4.
469+
#error We are only tested under Lua 5.0, 5.1, 5.2, 5.3, 5.4 or 5.5.
470470
#endif
471471

472472
lua_setglobal(L, "m");

tests/regression/config/10-request-directives.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@
501501
SecRequestBodyLimit 20
502502
),
503503
match_log => {
504-
debug => [ qr/Request body is larger than the configured limit \(20\).. Deny with code \(413\)/, 1 ],
504+
debug => [ qr/Request body is larger than the configured limit \(20\)./, 1 ],
505505
},
506506
match_response => {
507507
status => qr/^413$/,

tests/regression/misc/10-tfn-cache.t

Lines changed: 0 additions & 187 deletions
This file was deleted.

tests/run-regression-tests.pl.in

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,12 @@ sub match_log {
476476
$rc = $&;
477477
last;
478478
}
479-
# TODO: Use select()/poll()
480-
sleep 0.1 unless ($nbytes == $BUFSIZ);
479+
unless ($nbytes == $BUFSIZ) {
480+
# wait until we can read from the file but max 0.1 secs
481+
my $rin = '';
482+
vec($rin, fileno($fh), 1) = 1;
483+
select($rin, undef, undef, 0.1);
484+
}
481485
if ($graph and $opt{d}) {
482486
$i++;
483487
if ($i == 10) {
@@ -532,7 +536,8 @@ sub dbg {
532536
my $out = join "", map {
533537
(ref $_ ne "" ? Dumper($_) : $_)
534538
} @_;
535-
$out =~ s/^/DBG: /mg;
539+
my $t = gettimeofday;
540+
$out =~ s/^/DBG\[$t\]: /mg;
536541
print STDOUT "$out\n";
537542
}
538543

@@ -632,7 +637,7 @@ sub httpd_stop {
632637
-d => $opt{S},
633638
-f => $opt{C},
634639
(map { (-c => $_) } ("Listen localhost:$opt{p}", @_)),
635-
-k => "stop",
640+
-k => "graceful-stop",
636641
);
637642

638643
my $httpd_out;

0 commit comments

Comments
 (0)