Skip to content

Commit 1a7cfc7

Browse files
committed
Add files via upload
Add files via upload Fix AFL fuzzer input handling and null operator check Fix fuzzer API usage for operators and transformations Update fuzzing workflow to use ubuntu-latest Update runtime-sanitizers.yml Update codeql-security.yml
1 parent 0fb4aff commit 1a7cfc7

4 files changed

Lines changed: 422 additions & 43 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CodeQL Security
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 3 * * 1"
9+
10+
permissions:
11+
contents: read
12+
security-events: write
13+
actions: read
14+
15+
jobs:
16+
codeql:
17+
name: CodeQL C/C++
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Detect latest Lua dev package
27+
id: detect_lua
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
sudo apt-get update -y -qq
32+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
33+
34+
if [ -z "$CANDIDATES" ]; then
35+
echo "No libluaX.Y-dev package found"
36+
exit 1
37+
fi
38+
39+
BEST_PKG="$(
40+
printf '%s\n' "$CANDIDATES" \
41+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
42+
| sort -V \
43+
| tail -n1 \
44+
| awk '{print $2}'
45+
)"
46+
47+
echo "lua_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
48+
49+
- name: Install dependencies
50+
run: |
51+
sudo apt-get install -y \
52+
autoconf \
53+
automake \
54+
build-essential \
55+
libtool \
56+
pkg-config \
57+
libyajl-dev \
58+
libcurl4-openssl-dev \
59+
liblmdb-dev \
60+
${{ steps.detect_lua.outputs.lua_pkg }} \
61+
libmaxminddb-dev \
62+
libpcre2-dev \
63+
libxml2-dev \
64+
libfuzzy-dev \
65+
pcre2-utils \
66+
libpcre3-dev \
67+
bison \
68+
flex \
69+
python3 \
70+
python3-venv
71+
72+
- name: Initialize CodeQL
73+
uses: github/codeql-action/init@v4
74+
with:
75+
languages: c-cpp
76+
queries: security-extended,security-and-quality
77+
78+
- name: Build for CodeQL database
79+
run: |
80+
./build.sh
81+
./configure --enable-assertions=yes
82+
make -j"$(nproc)"
83+
84+
- name: Perform CodeQL analysis
85+
uses: github/codeql-action/analyze@v4
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Fuzzing Smoke Test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run_minutes:
7+
description: "How many minutes AFL++ should fuzz"
8+
required: false
9+
default: "10"
10+
fail_on_hangs:
11+
description: "Fail workflow when AFL++ reports hangs"
12+
required: false
13+
default: "false"
14+
type: choice
15+
options:
16+
- "false"
17+
- "true"
18+
schedule:
19+
- cron: "0 2 * * 0"
20+
21+
permissions:
22+
contents: read
23+
24+
concurrency:
25+
group: fuzzing-smoke-${{ github.ref }}
26+
cancel-in-progress: false
27+
28+
jobs:
29+
fuzzing-smoke:
30+
name: AFL++ fuzzing smoke test
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 60
33+
34+
env:
35+
AFL_SKIP_CPUFREQ: "1"
36+
AFL_NO_AFFINITY: "1"
37+
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: "1"
38+
AFL_NO_UI: "1"
39+
AFL_FAST_CAL: "1"
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v6
44+
with:
45+
fetch-depth: 0
46+
submodules: recursive
47+
48+
- name: Detect latest Lua packages
49+
id: detect_lua
50+
shell: bash
51+
run: |
52+
set -euo pipefail
53+
54+
sudo apt-get update -y -qq
55+
56+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
57+
58+
if [ -z "$CANDIDATES" ]; then
59+
echo "No libluaX.Y-dev package found"
60+
exit 1
61+
fi
62+
63+
BEST_PKG="$(
64+
printf '%s\n' "$CANDIDATES" \
65+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
66+
| sort -V \
67+
| tail -n1 \
68+
| awk '{print $2}'
69+
)"
70+
71+
BEST_VER="$(printf '%s\n' "$BEST_PKG" | sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1/')"
72+
LUA_PKG="lua$BEST_VER"
73+
74+
echo "lua_dev_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
75+
echo "lua_pkg=$LUA_PKG" >> "$GITHUB_OUTPUT"
76+
77+
- name: Install dependencies
78+
run: |
79+
sudo apt-get install -y \
80+
autoconf automake build-essential afl++ clang libtool pkg-config \
81+
libyajl-dev libcurl4-openssl-dev liblmdb-dev \
82+
${{ steps.detect_lua.outputs.lua_dev_pkg }} \
83+
${{ steps.detect_lua.outputs.lua_pkg }} \
84+
libmaxminddb-dev libpcre2-dev libxml2-dev libfuzzy-dev \
85+
pcre2-utils libpcre3-dev bison flex python3 python3-venv
86+
87+
- name: Build ModSecurity with AFL++
88+
env:
89+
CC: afl-clang-fast
90+
CXX: afl-clang-fast++
91+
run: |
92+
./build.sh
93+
./configure --enable-afl-fuzz --enable-parser-generation --enable-assertions=yes
94+
make -j"$(nproc)"
95+
96+
- name: Locate AFL target
97+
id: target
98+
run: |
99+
for f in ./test/fuzzer/afl_fuzzer ./test/fuzzer/.libs/afl_fuzzer; do
100+
[ -x "$f" ] && echo "target=$f" >> $GITHUB_OUTPUT && exit 0
101+
done
102+
echo "Fuzzer not found" && exit 1
103+
104+
- name: Create seed corpus
105+
run: |
106+
rm -rf fuzz-in fuzz-out
107+
mkdir -p fuzz-in fuzz-out
108+
printf '' > fuzz-in/empty
109+
printf 'abc' > fuzz-in/plain
110+
111+
- name: Dry-run
112+
run: timeout 10s "${{ steps.target.outputs.target }}" < fuzz-in/plain
113+
114+
- name: Run AFL++
115+
run: |
116+
timeout "${{ github.event.inputs.run_minutes || '10' }}m" \
117+
afl-fuzz -i fuzz-in -o fuzz-out -m none -t 1000+ \
118+
-- "${{ steps.target.outputs.target }}" || true
119+
120+
- name: Summarize
121+
id: summary
122+
run: |
123+
CRASH=$(find fuzz-out -path '*/crashes/id:*' -type f | wc -l)
124+
HANG=$(find fuzz-out -path '*/hangs/id:*' -type f | wc -l)
125+
echo "crash_count=$CRASH" >> $GITHUB_OUTPUT
126+
echo "hang_count=$HANG" >> $GITHUB_OUTPUT
127+
128+
- name: Package results
129+
if: always()
130+
run: |
131+
tar -czf afl-fuzz-results.tar.gz fuzz-in fuzz-out
132+
133+
- name: Upload results
134+
if: always()
135+
uses: actions/upload-artifact@v7
136+
with:
137+
name: afl-fuzz-results-${{ github.run_id }}
138+
path: afl-fuzz-results.tar.gz
139+
140+
- name: Fail on crashes
141+
if: steps.summary.outputs.crash_count != '0'
142+
run: exit 1
143+
144+
- name: Fail on hangs
145+
if: github.event.inputs.fail_on_hangs == 'true' && steps.summary.outputs.hang_count != '0'
146+
run: exit 1
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Runtime Sanitizers
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 4 * * 1"
9+
10+
jobs:
11+
asan-ubsan-linux:
12+
name: ASan/UBSan Linux
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
submodules: recursive
20+
21+
- name: Detect latest Lua dev package
22+
id: detect_lua
23+
shell: bash
24+
run: |
25+
set -euo pipefail
26+
sudo apt-get update -y -qq
27+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
28+
29+
if [ -z "$CANDIDATES" ]; then
30+
echo "No libluaX.Y-dev package found"
31+
exit 1
32+
fi
33+
34+
BEST_PKG="$(
35+
printf '%s\n' "$CANDIDATES" \
36+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
37+
| sort -V \
38+
| tail -n1 \
39+
| awk '{print $2}'
40+
)"
41+
42+
echo "lua_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
43+
44+
- name: Install dependencies
45+
run: |
46+
sudo apt-get install -y \
47+
autoconf \
48+
automake \
49+
build-essential \
50+
clang \
51+
libtool \
52+
pkg-config \
53+
libyajl-dev \
54+
libcurl4-openssl-dev \
55+
liblmdb-dev \
56+
${{ steps.detect_lua.outputs.lua_pkg }} \
57+
libmaxminddb-dev \
58+
libpcre2-dev \
59+
libxml2-dev \
60+
libfuzzy-dev \
61+
pcre2-utils \
62+
libpcre3-dev \
63+
bison \
64+
flex \
65+
python3 \
66+
python3-venv
67+
68+
- name: Build with AddressSanitizer and UndefinedBehaviorSanitizer
69+
env:
70+
CC: clang
71+
CXX: clang++
72+
CFLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer -O1"
73+
CXXFLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer -O1"
74+
LDFLAGS: "-fsanitize=address,undefined"
75+
ASAN_OPTIONS: "detect_leaks=1:abort_on_error=1:strict_string_checks=1"
76+
UBSAN_OPTIONS: "halt_on_error=1:print_stacktrace=1"
77+
run: |
78+
./build.sh
79+
./configure --enable-assertions=yes
80+
make -j"$(nproc)"
81+
timeout 30m make check
82+
83+
valgrind-linux:
84+
name: Valgrind Linux
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- uses: actions/checkout@v6
89+
with:
90+
fetch-depth: 0
91+
submodules: recursive
92+
93+
- name: Detect latest Lua dev package
94+
id: detect_lua
95+
shell: bash
96+
run: |
97+
set -euo pipefail
98+
sudo apt-get update -y -qq
99+
CANDIDATES="$(apt-cache pkgnames | grep -E '^liblua[0-9]+\.[0-9]+-dev$' || true)"
100+
101+
if [ -z "$CANDIDATES" ]; then
102+
echo "No libluaX.Y-dev package found"
103+
exit 1
104+
fi
105+
106+
BEST_PKG="$(
107+
printf '%s\n' "$CANDIDATES" \
108+
| sed -E 's/^liblua([0-9]+\.[0-9]+)-dev$/\1 &/' \
109+
| sort -V \
110+
| tail -n1 \
111+
| awk '{print $2}'
112+
)"
113+
114+
echo "lua_pkg=$BEST_PKG" >> "$GITHUB_OUTPUT"
115+
116+
- name: Install dependencies
117+
run: |
118+
sudo apt-get install -y \
119+
autoconf \
120+
automake \
121+
build-essential \
122+
valgrind \
123+
libtool \
124+
pkg-config \
125+
libyajl-dev \
126+
libcurl4-openssl-dev \
127+
liblmdb-dev \
128+
${{ steps.detect_lua.outputs.lua_pkg }} \
129+
libmaxminddb-dev \
130+
libpcre2-dev \
131+
libxml2-dev \
132+
libfuzzy-dev \
133+
pcre2-utils \
134+
libpcre3-dev \
135+
bison \
136+
flex \
137+
python3 \
138+
python3-venv
139+
140+
- name: Build
141+
run: |
142+
./build.sh
143+
./configure --enable-assertions=yes
144+
make -j"$(nproc)"
145+
146+
- name: Run tests under Valgrind
147+
run: |
148+
timeout 45m valgrind \
149+
--error-exitcode=1 \
150+
--leak-check=full \
151+
--show-leak-kinds=definite,indirect \
152+
make check

0 commit comments

Comments
 (0)