Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Datadog/dd-trace-php into…
Browse files Browse the repository at this point in the history
… bob/windows
  • Loading branch information
bwoebi committed Feb 7, 2024
2 parents 494b753 + d2d9d2f commit 59182b4
Show file tree
Hide file tree
Showing 142 changed files with 4,352 additions and 700 deletions.
6 changes: 5 additions & 1 deletion .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ jobs:
command: |
export DEBIAN_FRONTEND=noninteractive
apt update
apt install -y wget sudo git g++ gcc gcovr cmake make curl libcurl4-gnutls-dev clang clang-tidy clang-format git php-dev php-cgi cargo
apt install -y wget sudo git g++ gcc gcovr cmake make curl libcurl4-gnutls-dev clang clang-tidy clang-format git php-dev php8.2-xml php-cgi cargo
- run: git config --global --add safe.directory /home/circleci/datadog/appsec/third_party/libddwaf
- run:
name: CMake
Expand Down Expand Up @@ -1967,6 +1967,7 @@ jobs:
DD_TRACE_AGENT_PORT: 80
DD_TRACE_AGENT_FLUSH_INTERVAL: 1000
INSTALL_TYPE: << parameters.install_type >>
RUST_BACKTRACE: 1
- <<: *IMAGE_DOCKER_REQUEST_REPLAYER
steps:
- restore_cache:
Expand Down Expand Up @@ -2038,6 +2039,7 @@ jobs:
VERIFY_APACHE: << parameters.verify_apache >>
INSTALL_MODE: << parameters.install_mode >>
INSTALL_TYPE: << parameters.install_type >>
RUST_BACKTRACE: 1
- <<: *IMAGE_DOCKER_REQUEST_REPLAYER
steps:
- restore_cache:
Expand Down Expand Up @@ -2120,6 +2122,8 @@ jobs:
- run:
name: Run tests
command: make -C dockerfiles/verify_packages test_installer
environment:
RUST_BACKTRACE: 1

randomized_tests:
working_directory: ~/datadog
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prof_asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ jobs:
switch-php nts-asan
cd profiling/tests
cp -v $(php-config --prefix)/lib/php/build/run-tests.php .
php run-tests.php --asan -d extension=datadog-profiling.so phpt
php run-tests.php --show-diff --asan -d extension=datadog-profiling.so phpt
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion appsec/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# readability-function-cognitive-complexity temporarily disabled until clang-tidy is fixed
# right now emalloc causes it to misbehave
Checks: '*,-bugprone-reserved-identifier,-hicpp-signed-bitwise,-llvmlibc-restrict-system-libc-headers,-altera-unroll-loops,-hicpp-named-parameter,-cert-dcl37-c,-cert-dcl51-cpp,-read,-cppcoreguidelines-init-variables,-cppcoreguidelines-avoid-non-const-global-variables,-altera-id-dependent-backward-branch,-performance-no-int-to-ptr,-altera-struct-pack-align,-google-readability-casting,-modernize-use-trailing-return-type,-llvmlibc-implementation-in-namespace,-llvmlibc-callee-namespace,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-fuchsia-default-arguments-declarations,-fuchsia-overloaded-operator,-cppcoreguidelines-pro-type-union-access,-fuchsia-default-arguments-calls,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-google-readability-todo,-llvm-header-guard,-readability-function-cognitive-complexity,-readability-identifier-length,-modernize-macro-to-enum,-misc-include-cleaner,-bugprone-empty-catch'
Checks: '*,-bugprone-reserved-identifier,-hicpp-signed-bitwise,-llvmlibc-restrict-system-libc-headers,-altera-unroll-loops,-hicpp-named-parameter,-cert-dcl37-c,-cert-dcl51-cpp,-read,-cppcoreguidelines-init-variables,-cppcoreguidelines-avoid-non-const-global-variables,-altera-id-dependent-backward-branch,-performance-no-int-to-ptr,-altera-struct-pack-align,-google-readability-casting,-modernize-use-trailing-return-type,-llvmlibc-implementation-in-namespace,-llvmlibc-callee-namespace,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-fuchsia-default-arguments-declarations,-fuchsia-overloaded-operator,-cppcoreguidelines-pro-type-union-access,-fuchsia-default-arguments-calls,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-google-readability-todo,-llvm-header-guard,-readability-function-cognitive-complexity,-readability-identifier-length,-modernize-macro-to-enum,-misc-include-cleaner,-bugprone-empty-catch,-cppcoreguidelines-avoid-do-while'
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
Expand Down
20 changes: 20 additions & 0 deletions appsec/cmake/extension.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
configure_file(src/extension/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/extension/version.h)

find_package(PhpConfig REQUIRED)
message(STATUS "Configuring for PHP ${PhpConfig_VERNUM}")

set(EXT_SOURCE_DIR src/extension)

Expand Down Expand Up @@ -57,6 +58,25 @@ target_linker_flag_conditional(extension "-Wl,--version-script=${CMAKE_CURRENT_S
target_linker_flag_conditional(extension -flat_namespace "-undefined suppress")
target_linker_flag_conditional(extension -Wl,-exported_symbol -Wl,_get_module)

find_program(READELF_PROGRAM readelf)
set(ENABLE_ASAN FALSE CACHE BOOL "Enable ASAN")
if(READELF_PROGRAM)
execute_process(COMMAND ${READELF_PROGRAM} -d ${PhpConfig_PHP_BINARY}
COMMAND grep NEEDED
COMMAND grep libasan
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET)
if(result EQUAL 0)
set(ENABLE_ASAN TRUE CACHE BOOL "Enable ASAN" FORCE)
endif()
endif()
if(ENABLE_ASAN)
message(STATUS "Enabling ASAN")
target_compile_options(extension PRIVATE -fsanitize=address)
target_link_options(extension PRIVATE -fsanitize=address)
endif()

patch_away_libc(extension)

if(DD_APPSEC_TESTING)
Expand Down
4 changes: 2 additions & 2 deletions appsec/cmake/run-tests-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export TEST_PHP_EXECUTABLE TEST_PHP_CGI_EXECUTABLE TEST_PHPDBG_EXECUTABLE \
shift 3

function link_extensions {
local extensions=(opcache posix pcntl sockets json)
local extensions=(opcache posix pcntl sockets json xml)
local -r link_ext_dir="${CMAKE_BINARY_DIR}/extensions"
local -r extension_dir=$("$TEST_PHP_EXECUTABLE" -d display_errors=0 -r "echo ini_get('extension_dir');")
mkdir -p "$link_ext_dir"
Expand Down Expand Up @@ -53,7 +53,7 @@ function link_extensions {
EXTRA_FLAGS=()
function set_extra_flags {
local -r link_ext_dir="${CMAKE_BINARY_DIR}/extensions"
local -r always_loaded_extensions=(json)
local -r always_loaded_extensions=(json xml)
for ext in "${always_loaded_extensions[@]}"; do
if [[ -L "$link_ext_dir/$ext.so" ]]; then
EXTRA_FLAGS+=('-d' "extension=$ext.so")
Expand Down
2 changes: 1 addition & 1 deletion appsec/src/extension/commands/request_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dd_result dd_request_exec(dd_conn *nonnull conn, zval *nonnull data)

struct ctx ctx = {.data = data};

return dd_command_exec(conn, &_spec, &ctx);
return dd_command_exec_req_info(conn, &_spec, &ctx.req_info);
}

static dd_result _pack_command(mpack_writer_t *nonnull w, void *nonnull _ctx)
Expand Down
6 changes: 3 additions & 3 deletions appsec/src/extension/commands/request_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include "../configuration.h"
#include "../ddappsec.h"
#include "../ddtrace.h"
#include "../entity_body.h"
#include "../ip_extraction.h"
#include "../logging.h"
#include "../msgpack_helpers.h"
#include "../php_compat.h"
#include "../request_body.h"
#include "../string_helpers.h"
#include "request_init.h"
#include <mpack.h>
Expand Down Expand Up @@ -44,7 +44,7 @@ static const dd_command_spec _spec = {
dd_result dd_request_init(
dd_conn *nonnull conn, struct req_info_init *nonnull ctx)
{
return dd_command_exec(conn, &_spec, ctx);
return dd_command_exec_req_info(conn, &_spec, &ctx->req_info);
}

static dd_result _request_pack(mpack_writer_t *nonnull w, void *nonnull _ctx)
Expand Down Expand Up @@ -126,7 +126,7 @@ static dd_result _request_pack(mpack_writer_t *nonnull w, void *nonnull _ctx)
if (send_raw_body && !ctx->superglob_equiv) {
dd_mpack_write_lstr(w, "server.request.body.raw");
zend_string *nonnull req_body =
dd_request_body_buffered(DD_MAX_REQ_BODY_TO_BUFFER);
dd_request_body_buffered(get_DD_APPSEC_MAX_BODY_BUFF_SIZE());
dd_mpack_write_zstr(w, req_body);
zend_string_release(req_body);
}
Expand Down
Loading

0 comments on commit 59182b4

Please sign in to comment.