Skip to content

Commit e60de64

Browse files
authored
Merge branch 'master' into levi/fix-zai-ini-zts-refcount-race
2 parents 940690f + 7a66ef9 commit e60de64

96 files changed

Lines changed: 905 additions & 250 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.

.gitlab/generate-appsec.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
EOT;
2828
?>
2929
variables:
30+
FF_ENABLE_BASH_EXIT_CODE_CHECK: "true"
31+
FF_USE_NEW_BASH_EVAL_STRATEGY: "true"
3032
CI_REGISTRY_USER:
3133
value: ""
3234
description: "Your docker hub username"

.gitlab/generate-common.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ function windows_git_setup_with_packages() {
100100
}
101101

102102
?>
103+
variables:
104+
FF_ENABLE_BASH_EXIT_CODE_CHECK: "true"
105+
FF_USE_NEW_BASH_EVAL_STRATEGY: "true"
106+
103107
default:
104108
retry:
105109
max: 2

.gitlab/generate-package.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
- release
9090

9191
variables:
92+
FF_ENABLE_BASH_EXIT_CODE_CHECK: "true"
93+
FF_USE_NEW_BASH_EVAL_STRATEGY: "true"
9294
CARGO_HOME: "${CI_PROJECT_DIR}/.cache/cargo"
9395

9496
# One pipeline injection package size ratchet
@@ -905,7 +907,7 @@
905907
script:
906908
- php datadog-setup.php --php-bin all --file $(ls packages/dd-library-php-*-x86_64-linux-gnu.tar.gz)
907909
- sed -i 's/datadog.trace.sources_path/\;datadog.trace.sources_path/' /etc/php/8.1/cli/conf.d/98-ddtrace.ini
908-
- DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=0 DD_TRACE_GIT_METADATA_ENABLED=0 pecl run-tests --showdiff --ini=" -d datadog.trace.cli_enabled=1" $(find tests/ext -type d)
910+
- DD_TRACE_GIT_METADATA_ENABLED=0 pecl run-tests --showdiff --ini=" -d datadog.trace.cli_enabled=1" $(find tests/ext -type d)
909911

910912
"framework test":
911913
stage: verify
@@ -1174,7 +1176,7 @@
11741176
- pecl install datadog_trace.tgz
11751177
- echo "extension=ddtrace.so" | sudo tee $(php -i | awk -F"=> " '/Scan this dir for additional .ini files/ {print $2}')/ddtrace.ini
11761178
- php --ri=ddtrace
1177-
- TERM=dumb HTTPBIN_HOSTNAME=httpbin-integration HTTPBIN_PORT=8080 DATADOG_HAVE_DEV_ENV=1 DD_TRACE_GIT_METADATA_ENABLED=0 DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=0 pecl run-tests --showdiff --ini=" -d datadog.trace.sources_path=" -p datadog_trace
1179+
- TERM=dumb HTTPBIN_HOSTNAME=httpbin-integration HTTPBIN_PORT=8080 DATADOG_HAVE_DEV_ENV=1 DD_TRACE_GIT_METADATA_ENABLED=0 pecl run-tests --showdiff --ini=" -d datadog.trace.sources_path=" -p datadog_trace
11781180
after_script:
11791181
- mkdir artifacts
11801182
- find $(pecl config-get test_dir) -type f -name '*.diff' -exec cp --parents '{}' artifacts \;

.gitlab/generate-profiler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@
5656
- mkdir -p "${CI_PROJECT_DIR}/artifacts/profiler-tests"
5757

5858
- '# NTS'
59-
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}"
59+
- '# Use if/then instead of `command -v switch-php && switch-php` — the && form exits 1 when switch-php is absent, which FF_ENABLE_BASH_EXIT_CODE_CHECK treats as a job failure'
60+
- if command -v switch-php > /dev/null 2>&1; then switch-php "${PHP_MAJOR_MINOR}"; fi
6061
- cargo build --profile profiler-release --all-features
6162
- (cd ../; TEST_PHP_JUNIT="${CI_PROJECT_DIR}/artifacts/profiler-tests/nts-results.xml" php profiling/tests/run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "profiling/tests/phpt")
6263

6364
- touch build.rs #make sure `build.rs` gets executed after `switch-php` call
6465

6566
- '# ZTS'
66-
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}-zts"
67+
- if command -v switch-php > /dev/null 2>&1; then switch-php "${PHP_MAJOR_MINOR}-zts"; fi
6768
- cargo build --profile profiler-release --all-features
6869
- (cd ../; TEST_PHP_JUNIT="${CI_PROJECT_DIR}/artifacts/profiler-tests/zts-results.xml" php profiling/tests/run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "profiling/tests/phpt")
6970
after_script:

.gitlab/generate-tracer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function before_script_steps($with_docker_auth = false) {
140140
docker exec ${CONTAINER_NAME} powershell.exe "cd app; switch-php nts; C:\php\SDK\phpize.bat; .\configure.bat --enable-debug-pack; nmake"
141141

142142
# Set test environment variables
143-
docker exec ${CONTAINER_NAME} powershell.exe "setx DD_AUTOLOAD_NO_COMPILE true; setx DATADOG_HAVE_DEV_ENV 1; setx DD_TRACE_GIT_METADATA_ENABLED 0; setx DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED 0"
143+
docker exec ${CONTAINER_NAME} powershell.exe "setx DD_AUTOLOAD_NO_COMPILE true; setx DATADOG_HAVE_DEV_ENV 1; setx DD_TRACE_GIT_METADATA_ENABLED 0"
144144

145145
# Run extension tests
146146
docker exec ${CONTAINER_NAME} powershell.exe 'cd app; $env:_DD_DEBUG_SIDECAR_LOG_LEVEL=trace; $env:_DD_DEBUG_SIDECAR_LOG_METHOD="""file://${pwd}\sidecar.log"""; C:\php\php.exe -n -d memory_limit=-1 -d output_buffering=0 run-tests.php -g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP --show-diff -p C:\php\php.exe -d "extension=${pwd}\x64\Release\php_ddtrace.dll" "${pwd}\tests\ext"'
@@ -615,7 +615,7 @@ function before_script_steps($with_docker_auth = false) {
615615
<?php if ($sapi): ?>
616616
DD_TRACE_TEST_SAPI: "<?= $sapi ?>"
617617
<?php endif; ?>
618-
<?php if (str_contains($target, "kafk")): ?>
618+
<?php if (str_contains($target, "kafka")): ?>
619619
WAIT_FOR: zookeeper:2181 kafka-integration:9092
620620
CI_DEBUG_SERVICES: "true"
621621
<?php endif; ?>

Cargo.lock

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUST_DEBUG_BUILD ?= $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo 1)
3333
EXTRA_CONFIGURE_OPTIONS ?=
3434
ASSUME_COMPILED := ${DD_TRACE_ASSUME_COMPILED}
3535
MAX_TEST_PARALLELISM ?= $(shell nproc)
36-
ALL_TEST_ENV_OVERRIDE := $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1) DD_TRACE_GIT_METADATA_ENABLED=0 DD_CRASHTRACKER_RECEIVER_TIMEOUT_MS=15000 DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=0
36+
ALL_TEST_ENV_OVERRIDE := $(shell [ -n "${DD_TRACE_DOCKER_DEBUG}" ] && echo DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1) DD_TRACE_GIT_METADATA_ENABLED=0 DD_CRASHTRACKER_RECEIVER_TIMEOUT_MS=15000
3737

3838
VERSION := $(shell cat VERSION)
3939

@@ -548,7 +548,7 @@ cores:
548548
########################################################################################################################
549549
# TESTS
550550
########################################################################################################################
551-
ENV_OVERRIDE := $(shell ([ -n "${DD_TRACE_DOCKER_DEBUG}" ] && [ -z "${DD_TRACE_AUTOLOAD_NO_COMPILE}" ]) || ([ -n "${DD_TRACE_AUTOLOAD_NO_COMPILE}" ] && [ "${DD_TRACE_AUTOLOAD_NO_COMPILE}" != "0" ]) && [ -z "${DD_TRACE_SOURCES_PATH}" ] && echo DD_AUTOLOAD_NO_COMPILE=true DD_TRACE_SOURCES_PATH=$(TRACER_SOURCE_DIR)) DD_DOGSTATSD_URL=http://request-replayer:80 $(ALL_TEST_ENV_OVERRIDE)
551+
ENV_OVERRIDE := $(shell ([ -n "${DD_TRACE_DOCKER_DEBUG}" ] && [ -z "${DD_TRACE_AUTOLOAD_NO_COMPILE}" ]) || ([ -n "${DD_TRACE_AUTOLOAD_NO_COMPILE}" ] && [ "${DD_TRACE_AUTOLOAD_NO_COMPILE}" != "0" ]) && [ -z "${DD_TRACE_SOURCES_PATH}" ] && echo DD_AUTOLOAD_NO_COMPILE=true DD_TRACE_SOURCES_PATH=$(TRACER_SOURCE_DIR)) DD_DOGSTATSD_URL=http://request-replayer:80 $(ALL_TEST_ENV_OVERRIDE) DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=0
552552
TEST_EXTRA_INI ?=
553553
TEST_EXTRA_ENV ?=
554554

appsec/helper-rust/src/client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ mod metrics;
4141
pub mod protocol;
4242

4343
/// Smart pointer that tracks worker count for a service.
44-
/// Increments on creation/clone, decrements on drop.
45-
#[derive(Clone)]
44+
/// Increments on creation, decrements on drop.
4645
struct TrackedService {
4746
service: Arc<Service>,
4847
}

appsec/helper-rust/src/client/log.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,47 @@ macro_rules! error {
182182
}
183183
pub(crate) use error;
184184

185+
#[macro_export]
186+
macro_rules! error_once {
187+
($fmt:literal $(, $($arg:expr),* $(,)?)?) => {{
188+
static __ERROR_ONCE: ::std::sync::atomic::AtomicBool =
189+
::std::sync::atomic::AtomicBool::new(false);
190+
if ::log::log_enabled!(::log::Level::Error)
191+
&& !__ERROR_ONCE.swap(true, ::std::sync::atomic::Ordering::Relaxed)
192+
{
193+
#[allow(unused_imports)]
194+
use $crate::client::log::TryGetBacktrace;
195+
let mut __msg = ::std::format!($fmt $(, $($arg),*)?);
196+
__msg.push_str(" (this error will only be logged once)");
197+
198+
let mut __found = false;
199+
$(
200+
if !__found {
201+
if let Some(bt) = (&$arg).try_get_backtrace() {
202+
$crate::client::log::log_error_with_backtrace_at(
203+
file!(),
204+
line!(),
205+
module_path!(),
206+
&__msg,
207+
Some(bt),
208+
);
209+
__found = true;
210+
}
211+
}
212+
)*
213+
if !__found {
214+
$crate::client::log::log_error_with_backtrace_at(
215+
file!(),
216+
line!(),
217+
module_path!(),
218+
&__msg,
219+
None,
220+
);
221+
}
222+
}
223+
}};
224+
}
225+
185226
pub async fn with_scoped_client_id<F>(client_id: u64, fut: F)
186227
where
187228
F: Future,

appsec/helper-rust/src/client/metrics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ impl WafMetrics {
122122

123123
let entry = self.rasp_per_rule.entry(rule_type.to_string()).or_default();
124124
entry.evals += 1;
125-
126125
if run_output.has_events() {
127126
entry.matches += 1;
128127
}
128+
if run_output.timeout() {
129+
entry.timeouts += 1;
130+
}
129131
if run_output.is_blocking() {
130132
self.request_blocked = true;
131133
}

0 commit comments

Comments
 (0)