Skip to content

Commit 3c90bf0

Browse files
committed
Merge remote-tracking branch 'origin/master' into glopes/sidecar-comm
2 parents b4cf9f1 + 39b0b10 commit 3c90bf0

757 files changed

Lines changed: 17875 additions & 12917 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/ci/appsec-gradle-integration.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ file.
88

99
| CI Job | Image | What it does |
1010
|--------|-------|-------------|
11-
| `appsec integration tests: [{target}]` | `docker:29.4.0-noble` | Gradle integration tests with C++ helper (release/zts variants) |
12-
| `appsec integration tests (helper-rust): [{target}]` | same | Same tests with Rust helper (`-PuseHelperRust`); includes `debug` variant |
13-
| `appsec integration tests (ssi): [{target}]` | same | SSI mode (PHP 8.3 only) |
11+
| `appsec integration tests: [{target}]` | `docker:29.4.0-noble` | Gradle integration tests with Rust helper by default (release/zts/musl variants) |
12+
| `appsec integration tests (ssi): [{target}]` | same | SSI mode (PHP 8.3 only), Rust helper by default |
1413
| `helper-rust build and test` | same | `cargo fmt --check` + build + unit tests |
1514
| `helper-rust code coverage` | same | Unit test coverage via `cargo-llvm-cov` |
1615
| `helper-rust integration coverage` | same | Integration coverage collection (not needed locally) |
@@ -60,18 +59,17 @@ The `--tests` filter accepts:
6059
- Class only: `"*Apache2FpmTests*"` or `"com.datadog.appsec.php.integration.Apache2FpmTests"`
6160
- Wildcard: `"*FpmTests*"`
6261

63-
### With helper-rust (instead of C++ helper)
62+
### Rust helper (default)
6463

6564
```bash
66-
./gradlew test8.3-debug -PuseHelperRust --info \
65+
./gradlew test8.3-debug --info \
6766
--tests "com.datadog.appsec.php.integration.Apache2FpmTests.Pool environment"
6867
```
6968

70-
This builds the Rust helper via the `buildHelperRust` task (musl build, works on both glibc and musl targets) and stores the binary in the `php-helper-rust` Docker volume.
71-
72-
### C++ helper (default)
73-
74-
Omit `-PuseHelperRust` and `-PhelperBinary`. The C++ helper is built via the `buildAppsec-*` task.
69+
This builds the Rust helper via the `buildHelperRust` task (musl build,
70+
works on both glibc and musl targets), stores the binary in the
71+
`php-helper-rust` Docker volume, and mounts it as
72+
`/helper-rust/libddappsec-helper.so`.
7573

7674
## Image Tags
7775

@@ -135,7 +133,8 @@ Start a test container without running tests (for manual debugging):
135133
./gradlew runMain8.3-release -PtestClass=com.datadog.appsec.php.integration.Apache2FpmTests
136134
```
137135

138-
The `-PtestClass` property is required (the task is not created without it). Add `-PuseHelperRust` or `-PhelperBinary=...` as needed.
136+
The `-PtestClass` property is required (the task is not created without
137+
it). Add `-PhelperBinary=...` to bind-mount an explicit helper binary.
139138

140139
SSI variant:
141140

@@ -158,22 +157,18 @@ build/test-logs/com.datadog.appsec.php.integration.Apache2FpmTests-8.3-debug/
158157
├── access.log
159158
├── appsec.log # PHP extension appsec log
160159
├── error.log # Apache error log
161-
├── helper.log # Helper process log (C++ or Rust)
160+
├── helper.log # Rust helper process log
162161
├── php_error.log
163162
├── php_fpm_error.log
164163
└── sidecar.log
165164
```
166165

167-
To distinguish which helper ran, check `helper.log`:
168-
- Rust: starts with `[INFO] AppSec helper starting`
169-
- C++: starts with `[info]` lines like `Started listening on abstract socket`
170-
171166
## Musl/Alpine Target
172167

173168
The `test8.5-release-musl` target uses an Alpine-based nginx+fpm image. Tests tagged with `@Tag("musl")` are included; untagged tests are excluded.
174169

175170
```bash
176-
./gradlew test8.5-release-musl -PuseHelperRust --info
171+
./gradlew test8.5-release-musl --info
177172
```
178173

179174
The `buildHelperRust` task already produces a musl-linked binary (built on Alpine with `cargo +nightly`, using LLVM libunwind). The `patchelf --remove-needed libc.musl-*` step makes it load on both musl and glibc systems.
@@ -183,7 +178,6 @@ The `buildHelperRust` task already produces a musl-linked binary (built on Alpin
183178
| CI Job | Gradle Command |
184179
|---|---|
185180
| `appsec integration tests: [test8.3-release]` | `./gradlew test8.3-release` |
186-
| `appsec integration tests (helper-rust): [test8.3-debug]` | `./gradlew test8.3-debug -PuseHelperRust` |
187181
| `appsec integration tests (ssi): [test8.3-release-ssi]` | `./gradlew test8.3-release-ssi` |
188182
| `helper-rust build and test` | `./gradlew testHelperRust` |
189183
| `helper-rust code coverage` | `./gradlew coverageHelperRust` |
@@ -199,7 +193,7 @@ Gradle uses named Docker volumes for build artifacts and caches. Key volumes:
199193
|---|---|
200194
| `php-helper-rust` | `libddappsec-helper.so` (Rust helper binary) |
201195
| `php-tracer-{v}-{var}` | Built `ddtrace.so` |
202-
| `php-appsec-{v}-{var}` | Built `ddappsec.so` + C++ helper |
196+
| `php-appsec-{v}-{var}` | Built `ddappsec.so` |
203197
| `php-tracer-cargo-cache` | Cargo registry cache |
204198
| `php-tracer-cargo-cache-git` | Cargo git cache |
205199
| `php-appsec-boost-cache` | Boost build cache |

.claude/ci/appsec-native-tests.md

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ file.
1111
| `test appsec extension: [{ver}, {arch}, debug]` | `datadog/dd-trace-ci:php-{ver}_bookworm-6` | Builds appsec PHP extension + runs phpunit `.phpt` tests |
1212
| `test appsec extension: [{ver}, {arch}, debug-zts]` | same | ZTS variant |
1313
| `test appsec extension: [{ver}, {arch}, debug-zts-asan]` | same | ASAN variant (PHP 7.4+) |
14-
| `test appsec helper asan` | `datadog/dd-trace-ci:bookworm-6` | Builds C++ helper with ASAN, runs gtest suite |
1514
| `appsec lint` | `datadog/dd-trace-ci:php-8.3_bookworm-6` | clang-format + clang-tidy |
1615
| `appsec code coverage` | `datadog/dd-trace-ci:php-8.3_bookworm-6` | Coverage instrumented build (not needed locally) |
1716

@@ -143,77 +142,6 @@ reuse it. To force a full rebuild:
143142
docker volume rm php-appsec-8.3-debug php-tracer-8.3-debug
144143
```
145144

146-
## Helper tests (C++ ASAN)
147-
148-
The C++ helper tests use the `bookworm-6` image (no PHP needed). The
149-
binary is a gtest executable. With `--overlayfs --root`, all writes
150-
(including `appsec/build-helper`) persist in the Docker volume
151-
automatically — no manual bind mount needed.
152-
153-
### Full suite
154-
155-
```bash
156-
.claude/ci/dockerh --cache appsec-helper --overlayfs --root \
157-
datadog/dd-trace-ci:bookworm-6 -- bash -c '
158-
set -e
159-
apt-get update -qq && apt-get install -y -qq \
160-
libc++-17-dev libc++abi-17-dev > /dev/null 2>&1
161-
# Required: libddwaf submodule dir may trigger git's safe.directory check.
162-
git config --global --add safe.directory \
163-
/project/dd-trace-php/appsec/third_party/libddwaf
164-
mkdir -p appsec/build-helper
165-
cd appsec/build-helper
166-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_EXTENSION=OFF \
167-
-DDD_APPSEC_ENABLE_COVERAGE=OFF -DDD_APPSEC_TESTING=ON \
168-
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -fsanitize=address -fsanitize=leak -DASAN_BUILD" \
169-
-DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -DASAN_BUILD" \
170-
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" \
171-
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak"
172-
make -j$(nproc) ddappsec_helper_test
173-
cd /project/dd-trace-php
174-
./appsec/build-helper/tests/helper/ddappsec_helper_test
175-
'
176-
```
177-
178-
`clang-tidy-17` is not needed here — omitting it saves ~5–8 seconds of
179-
apt time. CI installs it via a shared `before_script` template.
180-
181-
CI also passes `-DBOOST_CACHE_PREFIX=$CI_PROJECT_DIR/boost-cache` and
182-
`-DCLANG_TIDY=/usr/bin/run-clang-tidy-17` to cmake. The first only
183-
affects where the Boost cache lands (not a correctness issue locally).
184-
The second means CI silently runs clang-tidy checks during the helper
185-
build that are skipped locally.
186-
187-
### Single test
188-
189-
Once built, the pre-built binary can be re-run without rebuilding, but
190-
the `libc++` runtime must still be installed (container rootfs is not
191-
persisted by `--overlayfs`):
192-
193-
```bash
194-
.claude/ci/dockerh --cache appsec-helper --overlayfs --root \
195-
datadog/dd-trace-ci:bookworm-6 -- bash -c '
196-
apt-get update -qq && apt-get install -y -qq libc++1-17 libc++abi1-17 > /dev/null 2>&1
197-
./appsec/build-helper/tests/helper/ddappsec_helper_test \
198-
--gtest_filter="WafTest.TraceAttributesAreSent"
199-
'
200-
```
201-
202-
The filter supports wildcards: `--gtest_filter="WafTest.*"` runs all
203-
tests in the `WafTest` suite. Use `--gtest_list_tests` to see available
204-
tests.
205-
206-
### Without ASAN
207-
208-
For a faster non-ASAN build (useful when debugging test logic rather than
209-
memory issues), drop the sanitizer flags:
210-
211-
```bash
212-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_EXTENSION=OFF \
213-
-DDD_APPSEC_TESTING=ON \
214-
-DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_LINK_FLAGS="-stdlib=libc++"
215-
```
216-
217145
## Appsec lint
218146

219147
This can easily run locally:

.claude/ci/building-locally.md

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ Before any build, ensure the relevant submodules are initialised
2828
# Tracer extension (ddtrace.so) — needs libdatadog
2929
git submodule update --init libdatadog
3030

31-
# Appsec extension or helper — needs these additionally
32-
git submodule update --init \
33-
appsec/third_party/libddwaf \
34-
appsec/third_party/msgpack-c \
35-
appsec/third_party/cpp-base64
36-
37-
# Appsec helper rust — needs libddwaf-rust
31+
# Appsec extension/helper — needs libddwaf-rust
3832
git submodule update --init --recursive \
3933
appsec/third_party/libddwaf-rust
4034
```
@@ -181,15 +175,14 @@ make -j$(nproc) xtest
181175
For ASAN, add `-DENABLE_ASAN=ON` to cmake. See
182176
[appsec-native-tests.md](appsec-native-tests.md) for full details.
183177

184-
## Appsec Helpers
178+
## Appsec Helper
185179

186-
The tarball needs two helper binaries in `appsec_$(uname -m)/`:
187-
`libddappsec-helper.so` (C++) and `libddappsec-helper-rust.so`
188-
(Rust), plus `appsec/recommended.json`.
180+
The tarball needs the Rust helper binary in `appsec_$(uname -m)/` as
181+
`libddappsec-helper.so`, plus `appsec/recommended.json`.
189182

190183
### Rust helper
191184

192-
Image is on Docker Hub. Output: `appsec_$(uname -m)/libddappsec-helper-rust.so`.
185+
Image is on Docker Hub. Output: `appsec_$(uname -m)/libddappsec-helper.so`.
193186

194187
```bash
195188
git submodule update --init --recursive \
@@ -202,27 +195,6 @@ git submodule update --init --recursive \
202195
-- bash .gitlab/build-appsec-helper-rust.sh
203196
```
204197

205-
### C++ helper
206-
207-
The CI image (`nginx_musl_toolchain`) lives at
208-
`registry.ddbuild.io/images/mirror/b1o7r7e0/nginx_musl_toolchain`
209-
(not on Docker Hub). Transfer it via
210-
`docker save ... | ssh HOST docker load` if needed. Output:
211-
`appsec_$(uname -m)/libddappsec-helper.so` + `recommended.json`.
212-
213-
```bash
214-
git submodule update --init \
215-
appsec/third_party/libddwaf \
216-
appsec/third_party/msgpack-c \
217-
appsec/third_party/cpp-base64
218-
219-
.claude/ci/dockerh --cache compile-appsec-helper-cpp --overlayfs \
220-
registry.ddbuild.io/images/mirror/b1o7r7e0/nginx_musl_toolchain \
221-
-e CI_COMMIT_SHA=$(git rev-parse HEAD) \
222-
-e CI_COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
223-
-- bash .gitlab/build-appsec-helper.sh
224-
```
225-
226198
## Profiler Extension
227199

228200
### For correctness tests (bookworm)
@@ -313,8 +285,7 @@ compiled `.so` files:
313285
- `extensions_$(uname -m)/` — ddtrace extensions
314286
(`ddtrace-{API}[-zts|-debug|-debug-zts].so`)
315287
- `appsec_$(uname -m)/` — appsec extensions (`ddappsec-{API}[-zts].so`) +
316-
helpers (`libddappsec-helper.so` and `libddappsec-helper-rust.so`) +
317-
`recommended.json`
288+
Rust helper (`libddappsec-helper.so`) + `recommended.json`
318289
- `datadog-profiling/{triplet}/lib/php/{API}/` — profiler
319290
extensions
320291

0 commit comments

Comments
 (0)