-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement LFI #2770
Open
estringana
wants to merge
29
commits into
master
Choose a base branch
from
estringana/implement-lfi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Implement LFI #2770
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8053833
Wrap lfi functions
estringana 8c0f445
Test LFi functions
estringana 343c85b
Avoid unnecesary new zvals
estringana b51f550
Add rasp duration tag
estringana f5c1b77
Add optional rasp metrics
estringana 82bbd97
Add duration_ext tag
estringana d626280
Add DD_APPSEC_RASP_ENABLED configuration
estringana b22eca9
Add lfi capability
estringana 2f0c6ca
Amend issue with rasp events tags
estringana f8b2a57
Move rasp.duration_ext to appsec extension
estringana e9b4496
Ensure rasp tags are created
estringana efb6de9
Ensure duration_ext is added
estringana 59a82c9
Avoid loaded wrappers when appsec no loaded
estringana 1bb6228
Change comment
estringana 0e7fb90
Disable rasp by default
estringana 844fdf8
Fix error loading filesytem integration on test_c tests
estringana 77c40e7
Add more rasp tests
estringana 8d8c184
Stop creating not needed spans
estringana 785db5e
Lint
estringana e85757b
Lint
estringana 21e3338
Enable rasp manually on integration tests
estringana 9bd9682
Amend test
estringana 7d253e0
Lint
estringana fc21135
Change approach to calculate elapsed
estringana a0944a9
Reduce calls to waf on LFI functions
estringana 1f898e6
Changes suggested on PR
estringana 2b8b6de
Remove stat and lstat
estringana 6249b87
Return not loaded when filesytem integration is wrapping no functions
estringana fdbbb12
Avoid reporting filesytem integration on telemetry
estringana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,105 @@ | ||
--TEST-- | ||
Filesystem integration depends on RASP. If RASP enabled, integration is enabled | ||
--SKIPIF-- | ||
<?php | ||
if (getenv('PHP_PEAR_RUNTESTS') === '1') die("skip: pecl run-tests does not support {PWD}"); | ||
if (PHP_OS === "WINNT" && PHP_VERSION_ID < 70400) die("skip: Windows on PHP 7.2 and 7.3 have permission issues with synchronous access to telemetry"); | ||
if (getenv('USE_ZEND_ALLOC') === '0' && !getenv("SKIP_ASAN")) die('skip timing sensitive test - valgrind is too slow'); | ||
require __DIR__ . '/../includes/clear_skipif_telemetry.inc' | ||
?> | ||
--ENV-- | ||
DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
_DD_LOAD_TEST_INTEGRATIONS=1 | ||
DD_INSTRUMENTATION_TELEMETRY_ENABLED=1 | ||
DD_APPSEC_RASP_ENABLED=1 | ||
--INI-- | ||
datadog.trace.agent_url="file://{PWD}/integration-telemetry.out" | ||
--FILE-- | ||
<?php | ||
|
||
namespace DDTrace\Test | ||
{ | ||
class TestSandboxedIntegration implements \DDTrace\Integration | ||
{ | ||
function init(): int | ||
{ | ||
dd_trace_method("Test", "public_static_method", function() { | ||
echo "test_access hook" . PHP_EOL; | ||
}); | ||
return self::LOADED; | ||
} | ||
} | ||
} | ||
|
||
namespace | ||
{ | ||
class Test | ||
{ | ||
public static function public_static_method() | ||
{ | ||
echo "PUBLIC STATIC METHOD\n"; | ||
} | ||
} | ||
|
||
Test::public_static_method(); | ||
|
||
dd_trace_internal_fn("finalize_telemetry"); | ||
|
||
for ($i = 0; $i < 100; ++$i) { | ||
usleep(100000); | ||
if (file_exists(__DIR__ . '/integration-telemetry.out')) { | ||
foreach (file(__DIR__ . '/integration-telemetry.out') as $l) { | ||
if ($l) { | ||
$json = json_decode($l, true); | ||
$batch = $json["request_type"] == "message-batch" ? $json["payload"] : [$json]; | ||
foreach ($batch as $json) { | ||
if ($json["request_type"] == "app-integrations-change") { | ||
var_dump($json["payload"]); | ||
break 3; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
PUBLIC STATIC METHOD | ||
test_access hook | ||
array(1) { | ||
["integrations"]=> | ||
array(2) { | ||
[0]=> | ||
array(5) { | ||
["name"]=> | ||
string(37) "ddtrace\test\testsandboxedintegration" | ||
["enabled"]=> | ||
bool(true) | ||
["version"]=> | ||
NULL | ||
["compatible"]=> | ||
NULL | ||
["auto_enabled"]=> | ||
NULL | ||
} | ||
[1]=> | ||
array(5) { | ||
["name"]=> | ||
string(4) "logs" | ||
["enabled"]=> | ||
bool(false) | ||
["version"]=> | ||
string(0) "" | ||
["compatible"]=> | ||
NULL | ||
["auto_enabled"]=> | ||
NULL | ||
} | ||
} | ||
} | ||
--CLEAN-- | ||
<?php | ||
|
||
@unlink(__DIR__ . '/integration-telemetry.out'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this one. What it shows enabled is your
TestSandboxedIntegration