diff options
Diffstat (limited to 'src/tests')
18 files changed, 244 insertions, 0 deletions
diff --git a/src/tests/disable_function/config/disabled_functions_extra.ini b/src/tests/disable_function/config/disabled_functions_extra.ini new file mode 100644 index 0000000..305c4b3 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_extra.ini | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | sp.disable_function.function("shell_exec").pos("0").value("ls").drop(); | ||
| 2 | sp.disable_function.function("exec").drop(); | ||
| 3 | sp.disable_function.function("passthru").drop(); | ||
| 4 | #sp.disable_function.function("system").drop(); | ||
| 5 | sp.disable_function.function("proc_open").drop(); | ||
| 6 | sp.disable_function.function("popen").drop(); | ||
| 7 | sp.disable_function.function("phpinfo").drop(); | ||
diff --git a/src/tests/disable_function/disabled_functions_exec.phpt b/src/tests/disable_function/disabled_functions_exec.phpt new file mode 100644 index 0000000..d49ea58 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_exec.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - exec | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo exec('ls -l'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'exec' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_passthru.phpt b/src/tests/disable_function/disabled_functions_passthru.phpt new file mode 100644 index 0000000..27eb8f8 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_passthru.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - passthru | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo passthru('ls -l'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'passthru' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt b/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt new file mode 100644 index 0000000..347101e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - phpinfo via header_register_callback | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | header_register_callback('phpinfo'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'phpinfo' in Unknown on line 0 | ||
diff --git a/src/tests/disable_function/disabled_functions_popen.phpt b/src/tests/disable_function/disabled_functions_popen.phpt new file mode 100644 index 0000000..d027aed --- /dev/null +++ b/src/tests/disable_function/disabled_functions_popen.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - popen | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo popen('ls -l', 'r'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'popen' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_proc_open.phpt b/src/tests/disable_function/disabled_functions_proc_open.phpt new file mode 100644 index 0000000..7c8c7eb --- /dev/null +++ b/src/tests/disable_function/disabled_functions_proc_open.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - proc_open | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $descriptorspec = array( | ||
| 10 | 0 => array("pipe", "r"), | ||
| 11 | 1 => array("pipe", "w"), | ||
| 12 | 2 => array("pipe", "w") | ||
| 13 | ); | ||
| 14 | echo proc_open('ls', $descriptorspec, $pipes); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'proc_open' in %a.php on line 7 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt new file mode 100644 index 0000000..aeb64c2 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo `ls`; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt new file mode 100644 index 0000000..a312acf --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator in context of a var name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo ${`ls`}; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt new file mode 100644 index 0000000..ea77a7d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator in context of a var name in a string | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo "{${`ls`}}"; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt new file mode 100644 index 0000000..fd9343b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via closure | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $x = Closure::fromCallable('shell_exec'); | ||
| 10 | echo $x('ls'); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt b/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt new file mode 100644 index 0000000..fac6031 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via 1st class closure | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80100) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | $x = shell_exec(...); | ||
| 11 | echo $x('ls'); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt b/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt new file mode 100644 index 0000000..8a18d9b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via filter_input callback | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --GET-- | ||
| 8 | cmd=ls | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | echo filter_input(INPUT_GET, 'cmd', FILTER_CALLBACK, array('options' => 'shell_exec')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt b/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt new file mode 100644 index 0000000..4c13db6 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via include(data://) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | allow_url_include=1 | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | include('data://text/plain,'.urlencode('<?php shell_exec("ls");')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in data%a line 1 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt b/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt new file mode 100644 index 0000000..941d168 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via include(php://filter) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | allow_url_include=1 | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | include('php://filter//resource=data://text/plain,'.urlencode('<?php shell_exec("ls");')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in php%a line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt b/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt new file mode 100644 index 0000000..3e43a14 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via opcache.preload | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | opcache | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 10 | allow_url_include=1 | ||
| 11 | opcache.enable=1 | ||
| 12 | opcache.enable_cli=1 | ||
| 13 | opcache.preload=data://text/plain,%3C%3Fphp+shell_exec%28%22ls%22%29%3B | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in data%a line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt b/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt new file mode 100644 index 0000000..8dcc40e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via register_shutdown_function | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | register_shutdown_function('shell_exec', 'ls'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in Unknown on line 0 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt b/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt new file mode 100644 index 0000000..f99b423 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via signal handler | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70100) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | pcntl | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 10 | pcntl.async_signals=1 | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | declare(ticks=1); | ||
| 14 | ini_set("pcntl.async_signals", "1"); | ||
| 15 | pcntl_signal(SIGALRM, function($signo) { shell_exec("ls"); }); | ||
| 16 | system("kill -14 " . getmypid()); | ||
| 17 | sleep(5); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 4 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_var.phpt b/src/tests/disable_function/disabled_functions_shell_exec_var.phpt new file mode 100644 index 0000000..e5a6a4e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_var.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via var call | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $x = 'shell_exec'; | ||
| 10 | echo $x('ls'); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
