Skip to content

Commit 121733e

Browse files
committed
wip move to communication via sidecar
1 parent a1bb038 commit 121733e

File tree

184 files changed

+2029
-23201
lines changed

Some content is hidden

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

184 files changed

+2029
-23201
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ appsec-trigger:
5757
strategy: depend
5858
variables:
5959
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
60-
GIT_SUBMODULE_PATHS: libdatadog appsec/third_party/cpp-base64 appsec/third_party/libddwaf appsec/third_party/libddwaf-rust appsec/third_party/msgpack-c
60+
GIT_SUBMODULE_PATHS: libdatadog appsec/third_party/libddwaf appsec/third_party/libddwaf-rust
6161

6262
profiler-trigger:
6363
stage: tests
@@ -92,6 +92,6 @@ package-trigger:
9292
strategy: depend
9393
variables:
9494
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
95-
GIT_SUBMODULE_PATHS: libdatadog appsec/third_party/cpp-base64 appsec/third_party/libddwaf appsec/third_party/libddwaf-rust appsec/third_party/msgpack-c
95+
GIT_SUBMODULE_PATHS: libdatadog appsec/third_party/libddwaf appsec/third_party/libddwaf-rust
9696
NIGHTLY_BUILD: $NIGHTLY_BUILD
9797
RELIABILITY_ENV_BRANCH: $RELIABILITY_ENV_BRANCH

.gitlab/build-appsec-helper-rust.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cargo +nightly-"$RUST_TARGET" build \
2222
--target "$RUST_TARGET"
2323

2424
# Remove musl libc dependency using patchelf (makes binary work on both musl and glibc)
25-
BINARY_PATH="/tmp/cargo-target/$RUST_TARGET/release/libddappsec_helper_rust.so"
25+
BINARY_PATH="/tmp/cargo-target/$RUST_TARGET/release/libddappsec_helper.so"
2626
ARCH=$(uname -m)
2727
if [ "$ARCH" = "x86_64" ]; then
2828
patchelf --remove-needed libc.musl-x86_64.so.1 "$BINARY_PATH" 2>/dev/null || true
@@ -31,7 +31,7 @@ elif [ "$ARCH" = "aarch64" ]; then
3131
fi
3232

3333
# Copy to output
34-
cp -v "$BINARY_PATH" "../../appsec_$(uname -m)/libddappsec-helper-rust.so"
34+
cp -v "$BINARY_PATH" "../../appsec_$(uname -m)/libddappsec-helper.so"
3535

3636
# Run tests
3737
cargo +nightly-"$RUST_TARGET" test \

.gitlab/build-appsec-helper.sh

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

.gitlab/build-appsec.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ suffix="${1:-}"
1313
echo "Build nts extension"
1414
switch-php "${PHP_VERSION}"
1515
mkdir -p appsec/build ; cd appsec/build
16-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF \
17-
-DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
16+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
1817
make -j $MAKE_JOBS
1918
cp -v ddappsec.so "../../appsec_$(uname -m)/ddappsec-$PHP_API${suffix}.so"
2019
cd "../../"
2120

2221
echo "Build zts extension"
2322
switch-php "${PHP_VERSION}-zts"
2423
mkdir -p appsec/build-zts ; cd appsec/build-zts
25-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_BUILD_HELPER=OFF \
26-
-DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
24+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDD_APPSEC_TESTING=OFF -DDD_APPSEC_EXTENSION_STATIC_LIBSTDCXX=ON
2725
make -j $MAKE_JOBS
2826
cp -v ddappsec.so "../../appsec_$(uname -m)/ddappsec-$PHP_API${suffix}-zts.so"
2927
cd "../../"

.gitlab/generate-appsec.php

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
- switch-php $SWITCH_PHP_VERSION
8989
- cd appsec/build
9090
- if [[ "$SWITCH_PHP_VERSION" == *"asan"* ]]; then ASAN_FLAG=ON; else ASAN_FLAG=OFF; fi
91-
- "cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_HELPER=OFF
91+
- "cmake .. -DCMAKE_BUILD_TYPE=Debug
9292
-DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_CXX_LINK_FLAGS='-stdlib=libc++'
9393
-DDD_APPSEC_TESTING=ON -DBOOST_CACHE_PREFIX=$CI_PROJECT_DIR/boost-cache
9494
-DENABLE_ASAN=$ASAN_FLAG"
@@ -104,7 +104,6 @@
104104
KUBERNETES_MEMORY_LIMIT: 30Gi
105105
DOCKER_LOOPBACK_SIZE: 30G
106106
ARCH: amd64
107-
HELPER_RUST_FLAG: ""
108107
GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle-home"
109108
DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED: "0"
110109
before_script:
@@ -121,7 +120,7 @@
121120
TERM=dumb ./gradlew loadCaches --info
122121
fi
123122

124-
TERM=dumb ./gradlew $targets --info -Pbuildscan --scan $HELPER_RUST_FLAG
123+
TERM=dumb ./gradlew $targets --info -Pbuildscan --scan
125124
TERM=dumb ./gradlew saveCaches --info
126125
after_script:
127126
- mkdir -p "${CI_PROJECT_DIR}/artifacts"
@@ -168,19 +167,6 @@
168167
- test8.5-release-zts
169168
- test8.5-release-musl
170169

171-
"appsec integration tests (helper-rust)":
172-
extends: .appsec_integration_tests
173-
variables:
174-
HELPER_RUST_FLAG: "-PuseHelperRust"
175-
parallel:
176-
matrix:
177-
- targets:
178-
- test7.4-release
179-
- test8.1-release
180-
- test8.3-debug
181-
- test8.4-release-zts
182-
- test8.5-release-musl
183-
184170
"helper-rust build and test":
185171
stage: test
186172
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
@@ -406,11 +392,6 @@
406392
export PATH=$PATH:$HOME/.cargo/bin
407393
LLVM_PROFILE_FILE="/tmp/cov-ext/%p.profraw" \
408394
VERBOSE=1 make -j 4 xtest
409-
- VERBOSE=1 make -j 4 ddappsec_helper_test
410-
- |
411-
cd ../..
412-
LLVM_PROFILE_FILE="/tmp/cov-helper/%p.profraw" \
413-
./appsec/build/tests/helper/ddappsec_helper_test
414395
- |
415396
cd /tmp/cov-ext
416397
llvm-profdata-17 merge -sparse *.profraw -o default.profdata
@@ -420,15 +401,6 @@
420401
echo "Uploading extension coverage to codecov"
421402
cd "$CI_PROJECT_DIR"
422403
codecov -t "$CODECOV_TOKEN" -n appsec-extension -v -f appsec/build/coverage-ext.lcov
423-
- |
424-
cd /tmp/cov-helper
425-
llvm-profdata-17 merge -sparse *.profraw -o default.profdata
426-
llvm-cov-17 export "$CI_PROJECT_DIR"/appsec/build/tests/helper/ddappsec_helper_test \
427-
-format=lcov -instr-profile=default.profdata \
428-
> "$CI_PROJECT_DIR/appsec/build/coverage-helper.lcov"
429-
echo "Uploading helper coverage to codecov"
430-
cd "$CI_PROJECT_DIR"
431-
codecov -t "$CODECOV_TOKEN" -n appsec-helper -v -f appsec/build/coverage-helper.lcov
432404
- |
433405
echo "Uploading coverage to Datadog"
434406
cd "$CI_PROJECT_DIR"
@@ -502,34 +474,9 @@
502474
-DBOOST_CACHE_PREFIX="$CI_PROJECT_DIR/boost-cache" \
503475
-DCLANG_TIDY=/usr/bin/run-clang-tidy-17 \
504476
-DCLANG_FORMAT=/usr/bin/clang-format-17
505-
- make -j 4 extension ddappsec-helper
477+
- make -j 4 extension
506478
- make format tidy
507479

508-
"test appsec helper asan":
509-
stage: test
510-
extends: .appsec_test
511-
image: registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:bookworm-6
512-
variables:
513-
KUBERNETES_CPU_REQUEST: 3
514-
KUBERNETES_MEMORY_REQUEST: 3Gi
515-
KUBERNETES_MEMORY_LIMIT: 4Gi
516-
parallel:
517-
matrix:
518-
- ARCH: *arch_targets
519-
script:
520-
- cd appsec/build
521-
- |
522-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_EXTENSION=OFF \
523-
-DDD_APPSEC_ENABLE_COVERAGE=OFF -DDD_APPSEC_TESTING=ON \
524-
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -fsanitize=address -fsanitize=leak \
525-
-DASAN_BUILD" -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak \
526-
-DASAN_BUILD" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" \
527-
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" \
528-
-DBOOST_CACHE_PREFIX="$CI_PROJECT_DIR/boost-cache" \
529-
-DCLANG_TIDY=/usr/bin/run-clang-tidy-17
530-
- make -j 4 ddappsec_helper_test
531-
- cd ../..; ./appsec/build/tests/helper/ddappsec_helper_test
532-
533480
### Disabled: "we don't rely on the fuzzer these days as the protocol has been stable for a long time, so feel free to disable those jobs for now"
534481
#"fuzz appsec helper":
535482
# stage: test

.gitlab/generate-package.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -277,24 +277,6 @@
277277
}
278278
?>
279279

280-
"compile appsec helper":
281-
stage: appsec
282-
image: "registry.ddbuild.io/images/mirror/b1o7r7e0/nginx_musl_toolchain"
283-
tags: [ "arch:$ARCH" ]
284-
needs: [ "prepare code" ]
285-
parallel:
286-
matrix:
287-
- ARCH: ["amd64", "arm64" ]
288-
variables:
289-
MAKE_JOBS: 12
290-
KUBERNETES_CPU_REQUEST: 12
291-
KUBERNETES_MEMORY_REQUEST: 4Gi
292-
KUBERNETES_MEMORY_LIMIT: 8Gi
293-
script: .gitlab/build-appsec-helper.sh
294-
artifacts:
295-
paths:
296-
- "appsec_*"
297-
298280
"compile appsec helper rust":
299281
stage: appsec
300282
image: "registry.ddbuild.io/images/mirror/datadog/dd-appsec-php-ci:nginx-fpm-php-8.5-release-musl"
@@ -625,13 +607,6 @@
625607
}
626608
?>
627609

628-
# Compile appsec helper (C++)
629-
- job: "compile appsec helper"
630-
parallel:
631-
matrix:
632-
- ARCH: "<?= $platform['arch'] ?>"
633-
artifacts: true
634-
635610
# Compile appsec helper (Rust)
636611
- job: "compile appsec helper rust"
637612
parallel:
@@ -704,11 +679,6 @@
704679
needs:
705680
- job: "prepare code"
706681
artifacts: true
707-
- job: "compile appsec helper"
708-
parallel:
709-
matrix:
710-
- ARCH: "<?= $arch ?>"
711-
artifacts: true
712682
- job: "compile appsec helper rust"
713683
parallel:
714684
matrix:

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
path = libdatadog
33
url = https://github.com/DataDog/libdatadog
44
branch = main
5-
[submodule "appsec/third_party/cpp-base64"]
6-
path = appsec/third_party/cpp-base64
7-
url = https://github.com/ReneNyffenegger/cpp-base64
8-
[submodule "appsec/third_party/msgpack-c"]
9-
path = appsec/third_party/msgpack-c
10-
url = https://github.com/msgpack/msgpack-c.git
115
[submodule "appsec/third_party/libddwaf"]
126
path = appsec/third_party/libddwaf
137
url = https://github.com/DataDog/libddwaf.git

appsec/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ if(POLICY CMP0153)
3232
cmake_policy(SET CMP0153 OLD) # allow exec_program
3333
endif()
3434

35-
option(DD_APPSEC_BUILD_HELPER "Whether to builder the helper" ON)
3635
option(DD_APPSEC_BUILD_EXTENSION "Whether to builder the extension" ON)
3736
option(DD_APPSEC_ENABLE_COVERAGE "Whether to enable coverage calculation" OFF)
3837
option(DD_APPSEC_TESTING "Whether to enable testing" ON)
@@ -57,10 +56,6 @@ if(DD_APPSEC_BUILD_EXTENSION)
5756
include("cmake/extension.cmake")
5857
endif()
5958

60-
if(DD_APPSEC_BUILD_HELPER)
61-
include ("cmake/helper.cmake")
62-
endif()
63-
6459
if(DD_APPSEC_DDTRACE_ALT)
6560
include(cmake/ddtrace.cmake)
6661
endif()

appsec/README.md

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,11 @@ cd build
7474
cmake ..
7575
make -j
7676
```
77-
This will produce the extension, `ddappsec.so` and the helper library `libddappsec-helper.so`.
77+
This will produce the extension, `ddappsec.so`.
7878
79-
Alternatively, to build the extension but not the helper, you can disable the helper build on the cmake step:
79+
To skip building the extension (e.g. to only run linting), you can disable it on the cmake step:
8080
```
81-
cmake .. -DDD_APPSEC_BUILD_HELPER=OFF
82-
```
83-
Similarly, to build the helper but not the extension:
84-
```
85-
cmake .. DDD_APPSEC_BUILD_EXTENSION=OFF
81+
cmake .. -DDD_APPSEC_BUILD_EXTENSION=OFF
8682
```
8783
8884
#### Testing the extension
@@ -101,27 +97,11 @@ make xtest TESTS="--show-diff --show-mem -m"
10197
```
10298
#### Testing the helper
10399
104-
Helper tests can be located in the `dd-appsec-php/tests/helper` directory, these consist of a set of C++ unit tests written using Google Test and Mock. To build the helper tests, run the following command in the build directory:
105-
```
106-
make ddappsec_helper_test
107-
```
108-
And run the tests by executing the following command, again from the build directory:
109-
```
110-
./tests/helper/ddappsec_helper_test
111-
```
112-
To test the helper with the address and leak sanitizer, you will need to execute the cmake step with a few other options as shown below (note that it's not strictly necessary to disable the extension):
113-
```
114-
cmake .. -DCMAKE_BUILD_TYPE=Debug -DDD_APPSEC_BUILD_EXTENSION=OFF \
115-
-DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=leak -DASAN_BUILD" \
116-
-DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -DASAN_BUILD" \
117-
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" \
118-
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak"
119-
```
120-
After this step has concluded, build and run the helper test as before, if the sanitisers detect anything of relevance, extra output will be produced.
100+
The helper is implemented in Rust and lives in the `helper-rust/` directory. See `helper-rust/CLAUDE.md` for build and test instructions.
121101
122102
### Linting
123103
124-
As part of our workflow, we use `clang-tidy` to lint both the extension and helper, in order to enable it add `-DDD_APPSEC_ENABLE_CLANG_TIDY=ON` to the cmake step and after building you should be able to lint by running `make tidy`.
104+
As part of our workflow, we use `clang-tidy` to lint the extension. To enable it, add `-DDD_APPSEC_ENABLE_CLANG_TIDY=ON` to the cmake step and after building you should be able to lint by running `make tidy`.
125105
126106
## Contributing
127107

appsec/cmake/check_fslib.cpp

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

0 commit comments

Comments
 (0)