summaryrefslogtreecommitdiff
path: root/src/tests/disable_function
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/disable_function')
-rw-r--r--src/tests/disable_function/config/disabled_functions_extra.ini7
-rw-r--r--src/tests/disable_function/disabled_functions_exec.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_passthru.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_popen.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_proc_open.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_closure.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_signal.phpt20
-rw-r--r--src/tests/disable_function/disabled_functions_shell_exec_var.phpt13
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 @@
1sp.disable_function.function("shell_exec").pos("0").value("ls").drop();
2sp.disable_function.function("exec").drop();
3sp.disable_function.function("passthru").drop();
4#sp.disable_function.function("system").drop();
5sp.disable_function.function("proc_open").drop();
6sp.disable_function.function("popen").drop();
7sp.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--
2Disable functions - exec
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo exec('ls -l');
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - passthru
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo passthru('ls -l');
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - phpinfo via header_register_callback
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9header_register_callback('phpinfo');
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - popen
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo popen('ls -l', 'r');
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - proc_open
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.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);
14echo proc_open('ls', $descriptorspec, $pipes);
15?>
16--EXPECTF--
17Fatal 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--
2Disable functions - shell_exec via backtick operator
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo `ls`;
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - shell_exec via backtick operator in context of a var name
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo ${`ls`};
10?>
11--EXPECTF--
12Fatal 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--
2Disable 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--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9echo "{${`ls`}}";
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions - shell_exec via closure
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9$x = Closure::fromCallable('shell_exec');
10echo $x('ls');
11?>
12--EXPECTF--
13Fatal 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--
2Disable 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--
7sp.configuration_file={PWD}/config/disabled_functions_extra.ini
8--FILE--
9<?php
10$x = shell_exec(...);
11echo $x('ls');
12?>
13--EXPECTF--
14Fatal 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--
2Disable functions - shell_exec via filter_input callback
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--GET--
8cmd=ls
9--FILE--
10<?php
11echo filter_input(INPUT_GET, 'cmd', FILTER_CALLBACK, array('options' => 'shell_exec'));
12?>
13--EXPECTF--
14Fatal 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--
2Disable 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--
7sp.configuration_file={PWD}/config/disabled_functions_extra.ini
8allow_url_include=1
9--FILE--
10<?php
11include('data://text/plain,'.urlencode('<?php shell_exec("ls");'));
12?>
13--EXPECTF--
14Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
15
16Fatal 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--
2Disable 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--
7sp.configuration_file={PWD}/config/disabled_functions_extra.ini
8allow_url_include=1
9--FILE--
10<?php
11include('php://filter//resource=data://text/plain,'.urlencode('<?php shell_exec("ls");'));
12?>
13--EXPECTF--
14Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
15
16Fatal 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--
2Disable 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--
7opcache
8--INI--
9sp.configuration_file={PWD}/config/disabled_functions_extra.ini
10allow_url_include=1
11opcache.enable=1
12opcache.enable_cli=1
13opcache.preload=data://text/plain,%3C%3Fphp+shell_exec%28%22ls%22%29%3B
14--FILE--
15<?php
16?>
17--EXPECTF--
18Fatal 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--
2Disable functions - shell_exec via register_shutdown_function
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9register_shutdown_function('shell_exec', 'ls');
10?>
11--EXPECTF--
12Fatal 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--
2Disable 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--
7pcntl
8--INI--
9sp.configuration_file={PWD}/config/disabled_functions_extra.ini
10pcntl.async_signals=1
11--FILE--
12<?php
13declare(ticks=1);
14ini_set("pcntl.async_signals", "1");
15pcntl_signal(SIGALRM, function($signo) { shell_exec("ls"); });
16system("kill -14 " . getmypid());
17sleep(5);
18?>
19--EXPECTF--
20Fatal 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--
2Disable functions - shell_exec via var call
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_extra.ini
7--FILE--
8<?php
9$x = 'shell_exec';
10echo $x('ls');
11?>
12--EXPECTF--
13Fatal 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