-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b6bafc
commit f62483e
Showing
7 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
appsec/tests/extension/rinit_asm_events_propagate_tags.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--TEST-- | ||
Asm events are added as meta tags and also as propagated tags | ||
--INI-- | ||
extension=ddtrace.so | ||
datadog.appsec.log_file=/tmp/php_appsec_test.log | ||
datadog.appsec.log_level=debug | ||
datadog.appsec.enabled=1 | ||
--ENV-- | ||
HTTP_X_DATADOG_TRACE_ID=42 | ||
HTTP_X_DATADOG_PARENT_ID=10 | ||
HTTP_X_DATADOG_ORIGIN=datadog | ||
HTTP_X_DATADOG_TAGS=_dd.p.custom_tag=inherited,_dd.p.second_tag=bar | ||
--FILE-- | ||
<?php | ||
use function datadog\appsec\testing\{rinit,rshutdown,ddtrace_rshutdown,root_span_get_meta}; | ||
include __DIR__ . '/inc/ddtrace_version.php'; | ||
|
||
ddtrace_version_at_least('0.79.0'); | ||
|
||
include __DIR__ . '/inc/mock_helper.php'; | ||
|
||
$helper = Helper::createInitedRun([ | ||
response_list(response_request_init([[['record', []]], ['{"found":"attack"}','{"another":"attack"}']])), | ||
response_list( | ||
response_request_shutdown( | ||
[[['record', []]], ['{"yet another":"attack"}'], false, ["rshutdown_tag" => "rshutdown_value"], ["rshutdown_metric" => 2.1]] | ||
) | ||
), | ||
], ['continuous' => true]); | ||
|
||
echo "rinit\n"; | ||
var_dump(rinit()); | ||
$helper->get_commands(); //ignore | ||
|
||
$context = DDTrace\current_context(); | ||
echo "_dd.p.appsec on distributed propagated tags? "; | ||
echo isset($context['distributed_tracing_propagated_tags']['_dd.p.appsec']) && $context['distributed_tracing_propagated_tags']['_dd.p.appsec'] == 1 ? "Yes": "No"; | ||
echo PHP_EOL; | ||
|
||
echo "rshutdown\n"; | ||
var_dump(rshutdown()); | ||
$helper->get_commands(); //ignore | ||
|
||
echo "ddtrace_rshutdown\n"; | ||
var_dump(ddtrace_rshutdown()); | ||
dd_trace_internal_fn('synchronous_flush'); | ||
|
||
$commands = $helper->get_commands(); | ||
$tags = $commands[0]['payload'][0][0]['meta']; | ||
|
||
echo "_dd.p.appsec? "; | ||
echo isset($tags['_dd.p.appsec']) && $tags['_dd.p.appsec'] === "1" ? "Yes": "No"; | ||
echo PHP_EOL; | ||
|
||
$helper->finished_with_commands(); | ||
|
||
?> | ||
--EXPECTF-- | ||
rinit | ||
bool(true) | ||
_dd.p.appsec on distributed propagated tags? Yes | ||
rshutdown | ||
bool(true) | ||
ddtrace_rshutdown | ||
bool(true) | ||
_dd.p.appsec? Yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters