feat(appsec): collect security-testing headers on HTTP entry spans#3925
feat(appsec): collect security-testing headers on HTTP entry spans#3925christophe-papazian wants to merge 7 commits into
Conversation
|
Benchmarks [ tracer ]Benchmark execution time: 2026-06-03 10:21:30 Comparing candidate commit 7f3ca82 in PR branch Found 1 performance improvements and 1 performance regressions! Performance is the same for 191 metrics, 1 unstable metrics.
|
Benchmarks [ appsec ]Benchmark execution time: 2026-05-29 14:34:32 Comparing candidate commit abd3a53 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. |
374fb58 to
abd3a53
Compare
|
LGTM. @bwoebi do you mind to review it as well? |
…PPSEC-62412) Unconditionally collect x-datadog-endpoint-scan and x-datadog-security-test HTTP request headers as http.request.headers.* tags on the service entry span, independent of DD_TRACE_HEADER_TAGS and AppSec enablement. Also forwarded to the inferred proxy span. Covers all PHP SAPIs (Apache/fpm, CLI, FrankenPHP, RoadRunner) via the C extension and Swoole via its PHP integration. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Move x-datadog-endpoint-scan and x-datadog-security-test collection to appsec/src/extension/tags.c via _relevant_basic_headers, following the existing pattern for http.request.headers.* tags - Remove duplicate logic from ext/serializer.c (keep transfer_meta_data calls for inferred proxy span forwarding) - Replace tracer phpt tests with an AppSec extension test using add_all/add_basic_ancillary_tags - Remove CHANGELOG entry (added at release time) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Add DD_TAG_HTTP_REQH_ENDPOINT_SCAN / DD_TAG_HTTP_REQH_SECURITY_TEST constants so tag-name strings are not duplicated across the sec_headers table and the transfer_meta_data calls - Add DD_UNCONDITIONAL_SERVER_HEADER macro to reduce verbosity of the struct initializer, following reviewer suggestion - Restore serializer.c collection (unconditional, per RFC) alongside tags.c which covers the AppSec-loaded path - Remove CHANGELOG entry (added at release time per reviewer) - Remove --GET-- from phpt tests (unnecessary) - Add AppSec extension test using add_all/add_basic_ancillary_tags - Update ancillary_tags.phpt canonical test to include the two new headers Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Since the headers are already collected unconditionally by ext/serializer.c (always loaded), adding them to AppSec's _relevant_basic_headers is unnecessary. Remove both the tags.c addition and its dedicated test. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The x-datadog headers were removed from tags.c _relevant_basic_headers, so ancillary_tags.phpt no longer expects them in the output. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Remove reference to appsec/src/extension/tags.c that was reverted. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
a99f53e to
7f3ca82
Compare
Instead of two dedicated zend_hash_str_find calls per request, inject x-datadog-endpoint-scan and x-datadog-security-test into the DD_TRACE_HEADER_TAGS hash table at module startup. They then ride the existing HTTP_* header loop in dd_add_header_to_meta with zero extra per-request overhead, and also scale automatically to any future SAPI integration that honours DD_TRACE_HEADER_TAGS. - Remove ddtrace_alter_DD_TRACE_HEADER_TAGS from INI_CHANGE_DYNAMIC_CONFIG and implement it manually so it re-injects the headers after any runtime config change (ini_set / remote config) - Remove the sec_headers block and DD_UNCONDITIONAL_SERVER_HEADER macro from serializer.c; keep DD_TAG_HTTP_REQH_* constants and the transfer_meta_data calls for the inferred proxy span - Remove the explicit isset checks from SwooleIntegration.php; the existing DD_TRACE_HEADER_TAGS loop now covers the Swoole path too Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
APPSEC-67550
Unconditionally collect
x-datadog-endpoint-scanandx-datadog-security-testHTTP request headers ashttp.request.headers.*span tags on the service entry span, independent ofDD_TRACE_HEADER_TAGSand AppSec enablement. Also forwarded to the inferred proxy span.Covers all PHP SAPIs (Apache/fpm, CLI, FrankenPHP, RoadRunner) via the C extension and Swoole via its PHP integration.
RFC: Security Testing: Trace Attribution for Inventory Enrichment and Pollution Prevention
Test plan
tests/ext/root_span_security_testing_headers.phpt— headers captured, independent ofDD_TRACE_HEADER_TAGStests/ext/root_span_security_testing_headers_absent.phpt— tags absent when headers not senttests/ext/inferred_proxy/security_headers_forwarded.phpt— both spans carry the tagstests/Integrations/Swoole/SecurityTestingHeadersTest.php— Swoole path: present + absent