From e1946af7761758c4ef3cb2e644e09aec562e8d3c Mon Sep 17 00:00:00 2001 From: Tudor TIMCU Date: Wed, 18 Dec 2024 11:44:24 +0000 Subject: [PATCH 1/2] Fix CLI tests for include, include_once, etc... --- tests/cli/bait_file.txt | 0 tests/cli/path_traversal/test_path_traversal_include.phpt | 6 ++++-- .../path_traversal/test_path_traversal_include_once.phpt | 6 ++++-- tests/cli/path_traversal/test_path_traversal_require.phpt | 6 ++++-- .../path_traversal/test_path_traversal_require_once.phpt | 6 ++++-- 5 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 tests/cli/bait_file.txt diff --git a/tests/cli/bait_file.txt b/tests/cli/bait_file.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/cli/path_traversal/test_path_traversal_include.phpt b/tests/cli/path_traversal/test_path_traversal_include.phpt index c608bb9e..ccb2a95d 100644 --- a/tests/cli/path_traversal/test_path_traversal_include.phpt +++ b/tests/cli/path_traversal/test_path_traversal_include.phpt @@ -8,9 +8,11 @@ AIKIDO_BLOCK=1 --FILE-- Date: Wed, 18 Dec 2024 15:37:04 +0000 Subject: [PATCH 2/2] Revert --- lib/php-extension/Hooks.cpp | 4 ---- .../test_path_traversal_include.phpt | 22 ------------------- .../test_path_traversal_include_once.phpt | 22 ------------------- .../test_path_traversal_require.phpt | 22 ------------------- .../test_path_traversal_require_once.phpt | 22 ------------------- 5 files changed, 92 deletions(-) delete mode 100644 tests/cli/path_traversal/test_path_traversal_include.phpt delete mode 100644 tests/cli/path_traversal/test_path_traversal_include_once.phpt delete mode 100644 tests/cli/path_traversal/test_path_traversal_require.phpt delete mode 100644 tests/cli/path_traversal/test_path_traversal_require_once.phpt diff --git a/lib/php-extension/Hooks.cpp b/lib/php-extension/Hooks.cpp index bf704763..4fc67b21 100644 --- a/lib/php-extension/Hooks.cpp +++ b/lib/php-extension/Hooks.cpp @@ -37,10 +37,6 @@ unordered_map HOOKED_FUNCTIONS = { AIKIDO_REGISTER_FUNCTION_HANDLER_EX(symlink, handle_pre_file_path_access_2), AIKIDO_REGISTER_FUNCTION_HANDLER_EX(touch, handle_pre_file_path_access), AIKIDO_REGISTER_FUNCTION_HANDLER_EX(unlink, handle_pre_file_path_access), - AIKIDO_REGISTER_FUNCTION_HANDLER_EX(require, handle_pre_file_path_access), - AIKIDO_REGISTER_FUNCTION_HANDLER_EX(require_once, handle_pre_file_path_access), - AIKIDO_REGISTER_FUNCTION_HANDLER_EX(include, handle_pre_file_path_access), - AIKIDO_REGISTER_FUNCTION_HANDLER_EX(include_once, handle_pre_file_path_access), }; unordered_map HOOKED_METHODS = { diff --git a/tests/cli/path_traversal/test_path_traversal_include.phpt b/tests/cli/path_traversal/test_path_traversal_include.phpt deleted file mode 100644 index ccb2a95d..00000000 --- a/tests/cli/path_traversal/test_path_traversal_include.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test path traversal (include) - ---ENV-- -AIKIDO_LOG_LEVEL=INFO -AIKIDO_BLOCK=1 - ---FILE-- - - ---EXPECTREGEX-- -.*Fatal error: Uncaught Exception: Aikido firewall has blocked a path traversal attack.* diff --git a/tests/cli/path_traversal/test_path_traversal_include_once.phpt b/tests/cli/path_traversal/test_path_traversal_include_once.phpt deleted file mode 100644 index 175fc5c7..00000000 --- a/tests/cli/path_traversal/test_path_traversal_include_once.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test path traversal (include_once) - ---ENV-- -AIKIDO_LOG_LEVEL=INFO -AIKIDO_BLOCK=1 - ---FILE-- - - ---EXPECTREGEX-- -.*Fatal error: Uncaught Exception: Aikido firewall has blocked a path traversal attack.* diff --git a/tests/cli/path_traversal/test_path_traversal_require.phpt b/tests/cli/path_traversal/test_path_traversal_require.phpt deleted file mode 100644 index 69b2a373..00000000 --- a/tests/cli/path_traversal/test_path_traversal_require.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test path traversal (require) - ---ENV-- -AIKIDO_LOG_LEVEL=INFO -AIKIDO_BLOCK=1 - ---FILE-- - - ---EXPECTREGEX-- -.*Fatal error: Uncaught Exception: Aikido firewall has blocked a path traversal attack.* diff --git a/tests/cli/path_traversal/test_path_traversal_require_once.phpt b/tests/cli/path_traversal/test_path_traversal_require_once.phpt deleted file mode 100644 index 51c62196..00000000 --- a/tests/cli/path_traversal/test_path_traversal_require_once.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test path traversal (require_once) - ---ENV-- -AIKIDO_LOG_LEVEL=INFO -AIKIDO_BLOCK=1 - ---FILE-- - - ---EXPECTREGEX-- -.*Fatal error: Uncaught Exception: Aikido firewall has blocked a path traversal attack.*