Skip to content

Commit 52d9e75

Browse files
Easton97-Jensjens
authored andcommitted
Clean up CI and libinjection integration changes
- update adapter and detection sources - improve multithreaded unit tests - add SQLi/XSS logging changes - hide test override symbols - fix linker visibility for test hooks - consolidate CI workflow updates - update libinjection integration files - improve tests and build configuration - add regression coverage for SQLi/XSS detection - fix Windows test include path handling - update libinjection adapter - consolidate CI workflow changes
1 parent 9e66822 commit 52d9e75

File tree

17 files changed

+597
-54
lines changed

17 files changed

+597
-54
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ name: Quality Assurance
33
on:
44
push:
55
pull_request:
6-
6+
77
jobs:
88
build-linux:
99
name: Linux (${{ matrix.platform.label }}, ${{ matrix.compiler.label }}, ${{ matrix.configure.label }})
1010
runs-on: ${{ matrix.os }}
1111
strategy:
12+
fail-fast: false
1213
matrix:
1314
os: [ubuntu-22.04]
1415
platform:
@@ -33,18 +34,49 @@ jobs:
3334
- platform: {label: "x32"}
3435
configure: {label: "wo ssdeep"}
3536
steps:
37+
- name: Detect latest Lua dev package
38+
id: detect_lua
39+
shell: bash
40+
run: |
41+
set -euo pipefail
42+
43+
sudo apt-get update -y -qq
44+
45+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
46+
47+
if [ -z "$CANDIDATES" ]; then
48+
echo "No libluaX.Y-dev package found"
49+
exit 1
50+
fi
51+
52+
BEST_PKG="$(
53+
printf '%s\n' "$CANDIDATES" \
54+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
55+
| sort -V \
56+
| tail -n1 \
57+
| awk '{print $2}'
58+
)"
59+
60+
if [ -z "$BEST_PKG" ]; then
61+
echo "Failed to determine Lua package"
62+
exit 1
63+
fi
64+
65+
echo "lua_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
66+
echo "Using $BEST_PKG"
67+
3668
- name: Setup Dependencies (common)
3769
run: |
3870
sudo dpkg --add-architecture ${{ matrix.platform.arch }}
3971
sudo apt-get update -y -qq
4072
sudo apt-get install -y libyajl-dev:${{ matrix.platform.arch }} \
4173
libcurl4-openssl-dev:${{ matrix.platform.arch }} \
4274
liblmdb-dev:${{ matrix.platform.arch }} \
43-
liblua5.2-dev:${{ matrix.platform.arch }} \
75+
${{ steps.detect_lua.outputs.lua_pkg }}:${{ matrix.platform.arch }} \
4476
libmaxminddb-dev:${{ matrix.platform.arch }} \
4577
libpcre2-dev:${{ matrix.platform.arch }} \
4678
pcre2-utils:${{ matrix.platform.arch }} \
47-
bison flex
79+
bison flex python3 python3-venv
4880
- name: Setup Dependencies (x32)
4981
if: ${{ matrix.platform.label == 'x32' }}
5082
run: |
@@ -54,11 +86,11 @@ jobs:
5486
- name: Setup Dependencies (x64)
5587
if: ${{ matrix.platform.label == 'x64' }}
5688
run: |
57-
sudo apt-get install -y libgeoip-dev:${{ matrix.platform.arch }} \
58-
libfuzzy-dev:${{ matrix.platform.arch }}
59-
- uses: actions/checkout@v4
89+
sudo apt-get install -y libfuzzy-dev:${{ matrix.platform.arch }}
90+
91+
- uses: actions/checkout@v6
6092
with:
61-
submodules: true
93+
submodules: recursive
6294
fetch-depth: 0
6395
- name: build.sh
6496
run: ./build.sh
@@ -77,6 +109,7 @@ jobs:
77109
name: macOS (${{ matrix.configure.label }})
78110
runs-on: ${{ matrix.os }}
79111
strategy:
112+
fail-fast: false
80113
matrix:
81114
os: [macos-14]
82115
configure:
@@ -105,21 +138,12 @@ jobs:
105138
ssdeep \
106139
pcre \
107140
bison \
108-
flex
109-
- uses: actions/checkout@v4
141+
flex
142+
143+
- uses: actions/checkout@v6
110144
with:
111-
submodules: true
145+
submodules: recursive
112146
fetch-depth: 0
113-
- name: Build GeoIP
114-
run: |
115-
git clone --depth 1 --no-checkout https://github.com/maxmind/geoip-api-c.git
116-
cd geoip-api-c
117-
git fetch --tags
118-
# Check out the last release, v1.6.12
119-
git checkout 4b526e7331ca1d692b74a0509ddcc725622ed31a
120-
autoreconf --install
121-
./configure --disable-dependency-tracking --disable-silent-rules --prefix=/opt/homebrew
122-
make install
123147
- name: build.sh
124148
run: ./build.sh
125149
- name: configure
@@ -134,6 +158,7 @@ jobs:
134158
name: Windows (${{ matrix.platform.label }}, ${{ matrix.configure.label }})
135159
runs-on: ${{ matrix.os }}
136160
strategy:
161+
fail-fast: false
137162
matrix:
138163
os: [windows-2022]
139164
platform:
@@ -147,9 +172,9 @@ jobs:
147172
- {label: "wo libxml", opt: "-DWITH_LIBXML2=OFF" }
148173
- {label: "with lmdb", opt: "-DWITH_LMDB=ON" }
149174
steps:
150-
- uses: actions/checkout@v4
175+
- uses: actions/checkout@v6
151176
with:
152-
submodules: true
177+
submodules: recursive
153178
fetch-depth: 0
154179
- name: Install Conan
155180
run: |
@@ -195,9 +220,10 @@ jobs:
195220
automake \
196221
libtool \
197222
cppcheck
198-
- uses: actions/checkout@v4
223+
224+
- uses: actions/checkout@v6
199225
with:
200-
submodules: true
226+
submodules: recursive
201227
fetch-depth: 0
202228
- name: configure
203229
run: |

.github/workflows/ci_new.yml

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,45 @@ jobs:
4040
fetch-depth: 0
4141
submodules: recursive
4242

43-
- name: Install dependencies
43+
- name: Detect latest Lua dev package
44+
id: detect_lua
45+
shell: bash
4446
run: |
47+
set -euo pipefail
48+
4549
sudo apt-get update -y -qq
50+
51+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
52+
53+
if [ -z "$CANDIDATES" ]; then
54+
echo "No libluaX.Y-dev package found"
55+
exit 1
56+
fi
57+
58+
BEST_PKG="$(
59+
printf '%s\n' "$CANDIDATES" \
60+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
61+
| sort -V \
62+
| tail -n1 \
63+
| awk '{print $2}'
64+
)"
65+
66+
if [ -z "$BEST_PKG" ]; then
67+
echo "Failed to determine Lua package"
68+
exit 1
69+
fi
70+
71+
echo "lua_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
72+
echo "Using $BEST_PKG"
73+
74+
75+
- name: Install dependencies
76+
run: |
4677
sudo apt-get install -y \
4778
libyajl-dev \
4879
libcurl4-openssl-dev \
4980
liblmdb-dev \
50-
liblua5.2-dev \
81+
${{ steps.detect_lua.outputs.lua_pkg }} \
5182
libmaxminddb-dev \
5283
libpcre2-dev \
5384
libxml2-dev \
@@ -56,8 +87,15 @@ jobs:
5687
libpcre3-dev \
5788
bison \
5889
flex \
59-
pkg-config
90+
pkg-config \
91+
python3 \
92+
python3-venv
6093
94+
- name: Show Lua installation
95+
run: |
96+
which lua || true
97+
lua -v || true
98+
dpkg -l | grep lua || true
6199
62100
- name: Run build preparation script
63101
run: ./build.sh
@@ -78,11 +116,12 @@ jobs:
78116

79117
build-macos:
80118
name: macOS (${{ matrix.configure.label }})
81-
runs-on: macos-15
119+
runs-on: ${{ matrix.os }}
82120

83121
strategy:
84122
fail-fast: false
85123
matrix:
124+
os: [macos-15, macos-26]
86125
configure:
87126
- { label: "with parser generation", opt: "--enable-parser-generation" }
88127
- { label: "without curl", opt: "--without-curl" }
@@ -196,7 +235,7 @@ jobs:
196235

197236
cppcheck:
198237
name: Static analysis (cppcheck)
199-
runs-on: macos-15
238+
runs-on: macos-26
200239

201240
steps:
202241
- uses: actions/checkout@v6
@@ -234,11 +273,47 @@ jobs:
234273
with:
235274
fetch-depth: 0
236275
submodules: recursive
276+
277+
- name: Detect latest Lua packages
278+
id: detect_lua
279+
shell: bash
280+
run: |
281+
set -euo pipefail
282+
283+
apt-get update
284+
285+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
286+
287+
if [ -z "$CANDIDATES" ]; then
288+
echo "No libluaX.Y-dev package found"
289+
exit 1
290+
fi
291+
292+
BEST_PKG="$(
293+
printf '%s\n' "$CANDIDATES" \
294+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
295+
| sort -V \
296+
| tail -n1 \
297+
| awk '{print $2}'
298+
)"
299+
300+
if [ -z "$BEST_PKG" ]; then
301+
echo "Failed to determine Lua dev package"
302+
printf '%s\n' "$CANDIDATES"
303+
exit 1
304+
fi
237305
306+
BEST_VER="$(printf '%s\n' "$BEST_PKG" | sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1/')"
307+
LUA_PKG="lua$BEST_VER"
308+
309+
echo "lua_dev_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
310+
echo "lua_pkg=$LUA_PKG" >> "$GITHUB_OUTPUT"
311+
312+
echo "Using dev package: $BEST_PKG"
313+
echo "Using interpreter: $LUA_PKG"
238314
239315
- name: Install dependencies (v2 style)
240316
run: |
241-
apt-get update
242317
apt-get install -y \
243318
autoconf \
244319
automake \
@@ -249,15 +324,24 @@ jobs:
249324
libyajl-dev \
250325
libcurl4-openssl-dev \
251326
liblmdb-dev \
252-
liblua5.2-dev \
327+
${{ steps.detect_lua.outputs.lua_dev_pkg }} \
328+
${{ steps.detect_lua.outputs.lua_pkg }} \
253329
libmaxminddb-dev \
254330
libpcre2-dev \
255331
libxml2-dev \
256332
libfuzzy-dev \
257333
pcre2-utils \
258334
bison \
259-
flex
260-
335+
flex \
336+
python3 \
337+
python3-venv
338+
339+
- name: Show Lua installation
340+
run: |
341+
which lua || true
342+
lua -v || true
343+
dpkg -l | grep lua || true
344+
261345
- name: Run build preparation script
262346
run: ./build.sh
263347

build/win32/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ project(libModSecurityTests)
164164

165165
function(setTestTargetProperties executable)
166166
target_compile_definitions(${executable} PRIVATE WITH_PCRE2)
167-
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers)
167+
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others)
168168
target_link_libraries(${executable} PRIVATE libModSecurity pcre2::pcre2 dirent::dirent)
169169
add_package_dependency(${executable} WITH_YAJL yajl::yajl HAVE_YAJL)
170170
endfunction()
@@ -239,7 +239,7 @@ setTestTargetProperties(rules_optimization)
239239
project(libModSecurityExamples)
240240

241241
function(setExampleTargetProperties executable)
242-
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers)
242+
target_include_directories(${executable} PRIVATE ${BASE_DIR} ${BASE_DIR}/headers ${BASE_DIR}/others)
243243
target_link_libraries(${executable} PRIVATE libModSecurity)
244244
endfunction()
245245

others/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ noinst_HEADERS = \
1515
libinjection/src/libinjection_sqli.h \
1616
libinjection/src/libinjection_sqli_data.h \
1717
libinjection/src/libinjection_xss.h \
18+
libinjection/src/libinjection_error.h \
1819
mbedtls/include/mbedtls/base64.h \
1920
mbedtls/include/mbedtls/check_config.h \
2021
mbedtls/include/mbedtls/mbedtls_config.h \

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ OPERATORS = \
187187
operators/contains_word.cc \
188188
operators/detect_sqli.cc \
189189
operators/detect_xss.cc \
190+
operators/libinjection_adapter.cc \
190191
operators/ends_with.cc \
191192
operators/eq.cc \
192193
operators/fuzzy_hash.cc \

0 commit comments

Comments
 (0)