-
Notifications
You must be signed in to change notification settings - Fork 0
463 lines (438 loc) · 20 KB
/
Copy pathci.yml
File metadata and controls
463 lines (438 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
name: CI
on:
push:
pull_request:
workflow_dispatch:
# Cache-key convention: keys carry a trailing `-vN`. Bump that suffix in EVERY
# affected job whenever you change CMake flags / configure commands / compiler
# for the cached artifact, or a stale build from a different config is restored.
jobs:
format-check:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format
- name: Check formatting
run: |
fail=0
while IFS= read -r f; do
if ! clang-format --dry-run --Werror "$f" 2>/dev/null; then
echo "needs formatting: $f"; fail=1
fi
done < <(find src cli tests -type f \( -name '*.c' -o -name '*.h' \))
if [ "$fail" -ne 0 ]; then
echo "Fix: find src cli tests -name '*.c' -o -name '*.h' | xargs clang-format -i"
exit 1
fi
build:
# gcc Release: build + full unit suite. e2e_multipath self-skips (exit 77,
# SKIP_RETURN_CODE) on the unprivileged runner — no tc/netem needed.
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libevent-dev libcurl4-openssl-dev libnghttp2-dev golang
- name: Compute xquic SHA
id: xqsha
run: echo "sha=$(git submodule status third_party/xquic | awk '{print $1}' | tr -d '+-')" >> "$GITHUB_OUTPUT"
- name: Cache BoringSSL (gcc fPIC)
id: bssl-cache
uses: actions/cache@v5
with:
path: third_party/xquic/third_party/boringssl
key: bssl-9c95ec7-linux-gcc-fpic-v1
- name: Clone + build BoringSSL (pinned)
if: steps.bssl-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/google/boringssl.git third_party/xquic/third_party/boringssl
cd third_party/xquic/third_party/boringssl
git checkout 9c95ec797c65fde9e8ddffc3888f0b8c1460fe4c
mkdir -p build && cd build
cmake -DBUILD_SHARED_LIBS=0 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j"$(nproc)" ssl crypto
- name: Cache xquic (gcc Release, EVENT_LOG)
id: xquic-cache
uses: actions/cache@v5
with:
# xqc_configure.h is generated INTO the source tree (not the build
# dir); cache it too or a restored lib pairs with a stale header.
path: |
third_party/xquic/build
third_party/xquic/include/xquic/xqc_configure.h
key: xquic-${{ steps.xqsha.outputs.sha }}-linux-gcc-release-eventlog-bssl-9c95ec7-v1
- name: Build xquic
if: steps.xquic-cache.outputs.cache-hit != 'true'
run: |
cd third_party/xquic
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSSL_TYPE=boringssl \
-DXQC_ENABLE_EVENT_LOG=ON \
-DXQC_ENABLE_BBR2=ON -DXQC_ENABLE_UNLIMITED=ON \
-DXQC_ENABLE_FEC=ON -DXQC_ENABLE_XOR=ON \
-DCMAKE_C_FLAGS="-Wno-dangling-pointer" ..
make -j"$(nproc)"
- name: Build mqproxy (Release)
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DXQUIC_BUILD_DIR="$PWD/third_party/xquic/build"
cmake --build build -j"$(nproc)"
- name: Unit tests (ctest)
run: ctest --test-dir build --output-on-failure
packaging:
# Static-link (xquic+BoringSSL) packaging build: verify the install layout +
# self-containment, then a REAL `systemctl start` of the hardened unit (the only
# check that exercises MemoryDenyWriteExecute / @system-service / RestrictAddressFamilies
# / ProtectHome against a live process — systemd-analyze cannot). Self-contained:
# rebuilds BoringSSL+xquic from the same caches as `build` (no artifact to depend on).
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libevent-dev libcurl4-openssl-dev libnghttp2-dev golang
- name: Compute xquic SHA
id: xqsha
run: echo "sha=$(git submodule status third_party/xquic | awk '{print $1}' | tr -d '+-')" >> "$GITHUB_OUTPUT"
- name: Cache BoringSSL (gcc fPIC)
id: bssl-cache
uses: actions/cache@v5
with:
path: third_party/xquic/third_party/boringssl
key: bssl-9c95ec7-linux-gcc-fpic-v1
- name: Clone + build BoringSSL (pinned)
if: steps.bssl-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/google/boringssl.git third_party/xquic/third_party/boringssl
cd third_party/xquic/third_party/boringssl
git checkout 9c95ec797c65fde9e8ddffc3888f0b8c1460fe4c
mkdir -p build && cd build
cmake -DBUILD_SHARED_LIBS=0 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j"$(nproc)" ssl crypto
- name: Cache xquic (gcc Release, EVENT_LOG)
id: xquic-cache
uses: actions/cache@v5
with:
path: |
third_party/xquic/build
third_party/xquic/include/xquic/xqc_configure.h
key: xquic-${{ steps.xqsha.outputs.sha }}-linux-gcc-release-eventlog-bssl-9c95ec7-v1
- name: Build xquic
if: steps.xquic-cache.outputs.cache-hit != 'true'
run: |
cd third_party/xquic
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSSL_TYPE=boringssl \
-DXQC_ENABLE_EVENT_LOG=ON \
-DXQC_ENABLE_BBR2=ON -DXQC_ENABLE_UNLIMITED=ON \
-DXQC_ENABLE_FEC=ON -DXQC_ENABLE_XOR=ON \
-DCMAKE_C_FLAGS="-Wno-dangling-pointer" ..
make -j"$(nproc)"
- name: Configure (static, prefix=/usr)
run: |
cmake -S . -B build-pkg -DCMAKE_BUILD_TYPE=Release \
-DXQUIC_BUILD_DIR="$PWD/third_party/xquic/build" \
-DMQPROXY_STATIC_XQUIC=ON -DCMAKE_INSTALL_PREFIX=/usr
- name: Build CLI
run: cmake --build build-pkg --target mqproxy_cli -j"$(nproc)"
- name: Verify packaging (layout + self-containment)
run: ctest --test-dir build-pkg -R packaging_install_static --output-on-failure
- name: Install + provision + live start smoke
run: |
sudo cmake --install build-pkg
sudo systemd-sysusers
sudo systemd-tmpfiles --create
sudo install -d -o mqproxy -g mqproxy -m 0750 /etc/mqproxy
# Cert/key MUST be readable by the hardened unit: the compiled-in default
# cert path is under /home (blocked by ProtectHome=yes), so copy the repo
# test cert into /etc/mqproxy (readable under ProtectSystem=strict).
sudo install -o mqproxy -g mqproxy -m 0644 tests/certs/test.crt /etc/mqproxy/test.crt
sudo install -o mqproxy -g mqproxy -m 0600 tests/certs/test.key /etc/mqproxy/test.key
printf '[Interface]\nListen = 127.0.0.1:4433\n[TLS]\nCert = /etc/mqproxy/test.crt\nKey = /etc/mqproxy/test.key\n[Auth]\nKey = citoken\n' \
| sudo tee /etc/mqproxy/test.conf >/dev/null
sudo chown mqproxy:mqproxy /etc/mqproxy/test.conf
sudo chmod 0600 /etc/mqproxy/test.conf
sudo systemctl daemon-reload
sudo systemctl start mqproxy-server@test
sleep 2
sudo journalctl -u mqproxy-server@test --no-pager | tail -30
sudo systemctl is-active mqproxy-server@test # fails the job if the unit died
sudo systemctl stop mqproxy-server@test
- name: Client unit live start smoke
run: |
# Client unit: dummy unreachable server + a local SOCKS5 ingress. Reconnect is
# on by default, so it binds the ingress and stays up retrying — is-active holds.
# No TLS cert needed (client side). Proves the client ExecStart/path + ingress
# bind work under the same hardening sandbox as the server.
printf '[Server]\nAddress = 127.0.0.1:14999\n[Auth]\nKey = citoken\n[Ingress]\nSocks5 = 127.0.0.1:1080\n' \
| sudo tee /etc/mqproxy/testclient.conf >/dev/null
sudo chown mqproxy:mqproxy /etc/mqproxy/testclient.conf
sudo chmod 0600 /etc/mqproxy/testclient.conf
sudo systemctl daemon-reload
sudo systemctl start mqproxy-client@testclient
sleep 2
sudo journalctl -u mqproxy-client@testclient --no-pager | tail -30
sudo systemctl is-active mqproxy-client@testclient # fails the job if the unit died
sudo systemctl stop mqproxy-client@testclient
sanitizer:
# ASan/UBSan build + unit suite (the configuration the proxy was developed
# under). Same non-ASan Release xquic; only mqproxy gets the sanitizers.
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libevent-dev libcurl4-openssl-dev libnghttp2-dev golang
- name: Compute xquic SHA
id: xqsha
run: echo "sha=$(git submodule status third_party/xquic | awk '{print $1}' | tr -d '+-')" >> "$GITHUB_OUTPUT"
- name: Cache BoringSSL (gcc fPIC)
id: bssl-cache
uses: actions/cache@v5
with:
path: third_party/xquic/third_party/boringssl
key: bssl-9c95ec7-linux-gcc-fpic-v1
- name: Clone + build BoringSSL (pinned)
if: steps.bssl-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/google/boringssl.git third_party/xquic/third_party/boringssl
cd third_party/xquic/third_party/boringssl
git checkout 9c95ec797c65fde9e8ddffc3888f0b8c1460fe4c
mkdir -p build && cd build
cmake -DBUILD_SHARED_LIBS=0 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j"$(nproc)" ssl crypto
- name: Cache xquic (gcc Release, EVENT_LOG)
id: xquic-cache
uses: actions/cache@v5
with:
path: |
third_party/xquic/build
third_party/xquic/include/xquic/xqc_configure.h
key: xquic-${{ steps.xqsha.outputs.sha }}-linux-gcc-release-eventlog-bssl-9c95ec7-v1
- name: Build xquic
if: steps.xquic-cache.outputs.cache-hit != 'true'
run: |
cd third_party/xquic
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSSL_TYPE=boringssl \
-DXQC_ENABLE_EVENT_LOG=ON \
-DXQC_ENABLE_BBR2=ON -DXQC_ENABLE_UNLIMITED=ON \
-DXQC_ENABLE_FEC=ON -DXQC_ENABLE_XOR=ON \
-DCMAKE_C_FLAGS="-Wno-dangling-pointer" ..
make -j"$(nproc)"
- name: Build mqproxy (ASan/UBSan)
run: |
cmake -S . -B build-asan -DMQPROXY_SANITIZE=ON \
-DXQUIC_BUILD_DIR="$PWD/third_party/xquic/build"
cmake --build build-asan -j"$(nproc)"
- name: Unit tests (ASan/UBSan)
env:
ASAN_OPTIONS: detect_leaks=1
# Without halt_on_error, UBSan prints a diagnostic but exits 0, so
# ctest would pass despite a UB finding — make UBSan actually gate.
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: ctest --test-dir build-asan --output-on-failure
perf:
# NET_ADMIN e2e tests (multipath aggregation, tproxy, MITM, UDP multipath
# sub-cases) that cannot run on the unprivileged default runner. Runs inside
# a Docker container with CAP_NET_ADMIN so tc/netem/nft work. The multipath
# aggregation test (e2e_multipath) is the perf regression gate: it asserts
# >=1.5x throughput over two shaped paths. All other NET_ADMIN-gated e2e
# sub-cases (e2e_gateway case 8, e2e_tproxy, e2e_mitm_h2, e2e_udp case 6)
# exercise their full codepath here instead of being SKIPPED.
runs-on: ubuntu-latest
timeout-minutes: 25
container:
image: ubuntu:24.04
options: --cap-add=NET_ADMIN
steps:
- name: Install git (needed before checkout for submodules)
run: apt-get update && apt-get install -y git
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: |
apt-get install -y \
cmake gcc g++ make \
libevent-dev libcurl4-openssl-dev libnghttp2-dev golang \
iproute2 nftables curl python3 openssl sudo \
ca-certificates
- name: Compute xquic SHA
id: xqsha
run: echo "sha=$(git submodule status third_party/xquic | awk '{print $1}' | tr -d '+-')" >> "$GITHUB_OUTPUT"
- name: Cache BoringSSL (gcc fPIC)
id: bssl-cache
uses: actions/cache@v5
with:
path: third_party/xquic/third_party/boringssl
key: bssl-9c95ec7-linux-gcc-fpic-v1
- name: Clone + build BoringSSL (pinned)
if: steps.bssl-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/google/boringssl.git third_party/xquic/third_party/boringssl
cd third_party/xquic/third_party/boringssl
git checkout 9c95ec797c65fde9e8ddffc3888f0b8c1460fe4c
mkdir -p build && cd build
cmake -DBUILD_SHARED_LIBS=0 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j"$(nproc)" ssl crypto
- name: Cache xquic (gcc Release, EVENT_LOG)
id: xquic-cache
uses: actions/cache@v5
with:
path: |
third_party/xquic/build
third_party/xquic/include/xquic/xqc_configure.h
key: xquic-${{ steps.xqsha.outputs.sha }}-linux-gcc-release-eventlog-bssl-9c95ec7-v1
- name: Build xquic
if: steps.xquic-cache.outputs.cache-hit != 'true'
run: |
cd third_party/xquic
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSSL_TYPE=boringssl \
-DXQC_ENABLE_EVENT_LOG=ON \
-DXQC_ENABLE_BBR2=ON -DXQC_ENABLE_UNLIMITED=ON \
-DXQC_ENABLE_FEC=ON -DXQC_ENABLE_XOR=ON \
-DCMAKE_C_FLAGS="-Wno-dangling-pointer" ..
make -j"$(nproc)"
- name: Build mqproxy (Release)
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DXQUIC_BUILD_DIR="$PWD/third_party/xquic/build"
cmake --build build -j"$(nproc)"
- name: E2E tests (ctest, with NET_ADMIN)
run: ctest --test-dir build -V
- name: Upload e2e logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: perf-e2e-logs
path: /tmp/mqproxy_e2e_*
if-no-files-found: ignore
h3-curl:
# OPTIONAL / NON-BLOCKING h3-libcurl build (Phase 6 origin-protocol h3).
# Builds ngtcp2 + nghttp3 + libcurl on the pinned BoringSSL via
# scripts/build-h3-curl.sh, then builds + tests mqproxy linked against it
# (-DMQPROXY_H3_CURL). This is heavy (clones + compiles a QUIC+TLS+curl
# stack) and version-pin-sensitive (ngtcp2 vs BoringSSL QUIC-API), so it
# runs ONLY on manual dispatch and is continue-on-error: it must never block
# the default-build CI. The DEFAULT mqproxy build does NOT use this.
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 60
continue-on-error: true
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libevent-dev libnghttp2-dev golang pkg-config
- name: Compute xquic SHA
id: xqsha
run: echo "sha=$(git submodule status third_party/xquic | awk '{print $1}' | tr -d '+-')" >> "$GITHUB_OUTPUT"
- name: Cache BoringSSL (gcc fPIC)
id: bssl-cache
uses: actions/cache@v5
with:
path: third_party/xquic/third_party/boringssl
key: bssl-9c95ec7-linux-gcc-fpic-v1
- name: Clone + build BoringSSL (pinned)
if: steps.bssl-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/google/boringssl.git third_party/xquic/third_party/boringssl
cd third_party/xquic/third_party/boringssl
git checkout 9c95ec797c65fde9e8ddffc3888f0b8c1460fe4c
mkdir -p build && cd build
cmake -DBUILD_SHARED_LIBS=0 -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make -j"$(nproc)" ssl crypto
- name: Cache xquic (gcc Release, EVENT_LOG)
id: xquic-cache
uses: actions/cache@v5
with:
path: |
third_party/xquic/build
third_party/xquic/include/xquic/xqc_configure.h
key: xquic-${{ steps.xqsha.outputs.sha }}-linux-gcc-release-eventlog-bssl-9c95ec7-v1
- name: Build xquic
if: steps.xquic-cache.outputs.cache-hit != 'true'
run: |
cd third_party/xquic
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSSL_TYPE=boringssl \
-DXQC_ENABLE_EVENT_LOG=ON \
-DXQC_ENABLE_BBR2=ON -DXQC_ENABLE_UNLIMITED=ON \
-DXQC_ENABLE_FEC=ON -DXQC_ENABLE_XOR=ON \
-DCMAKE_C_FLAGS="-Wno-dangling-pointer" ..
make -j"$(nproc)"
- name: Build h3-libcurl (ngtcp2 + nghttp3 + curl on BoringSSL)
run: scripts/build-h3-curl.sh
- name: Build mqproxy (MQPROXY_H3_CURL)
run: |
cmake -S . -B build-h3 -DCMAKE_BUILD_TYPE=Release \
-DXQUIC_BUILD_DIR="$PWD/third_party/xquic/build" \
-DMQPROXY_H3_CURL="$PWD/third_party/h3-curl/install"
cmake --build build-h3 -j"$(nproc)"
- name: Verify RPATH resolves the vendored libcurl
run: |
bin="$(find build-h3 -type f -name mqproxy | head -1)"
echo "binary: $bin"
readelf -d "$bin" | grep -iE 'r(un)?path' || { echo "no RPATH/RUNPATH"; exit 1; }
readelf -d "$bin" | grep -iE 'r(un)?path' | grep -q "third_party/h3-curl/install/lib" \
|| { echo "vendored libcurl dir NOT in RPATH"; exit 1; }
- name: Unit tests (ctest)
run: ctest --test-dir build-h3 --output-on-failure
fuzz:
# libFuzzer harnesses over the wire/ingress parse surface. Self-contained:
# the parsers depend only on libc, so NO submodules / NO boringssl+xquic
# build / NO cache are needed (see fuzz/CMakeLists.txt).
runs-on: ubuntu-latest
timeout-minutes: 20
env:
FUZZ_SECONDS: 30 # per-target exploration budget (tune here)
steps:
- uses: actions/checkout@v6
# no submodules: fuzz harnesses compile only src/wire + src/ingress
- name: Install clang
run: sudo apt-get update && sudo apt-get install -y clang cmake
- name: Configure + build harnesses
run: |
cmake -S fuzz -B build-fuzz -DCMAKE_C_COMPILER=clang
cmake --build build-fuzz -j"$(nproc)"
- name: Replay committed corpus (deterministic gate)
run: |
set -e
for t in build-fuzz/fuzz_*; do
name=$(basename "$t"); dir="fuzz/corpus/${name#fuzz_}"
if [ -d "$dir" ] && [ -n "$(ls -A "$dir" 2>/dev/null)" ]; then
echo "== replay $name =="; "$t" "$dir"/*
else
echo "== $name: no corpus, skipping replay =="
fi
done
- name: Short exploration (best-effort, fails on any new crash)
run: |
set -e
for t in build-fuzz/fuzz_*; do
name=$(basename "$t"); dir="fuzz/corpus/${name#fuzz_}"; mkdir -p "$dir"
echo "== explore $name (${FUZZ_SECONDS}s) =="
"$t" "$dir" -max_total_time="${FUZZ_SECONDS}" -print_final_stats=1
done
- name: Upload crashes on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes
path: |
crash-*
leak-*
timeout-*
oom-*
if-no-files-found: ignore