summaryrefslogtreecommitdiff
path: root/src/tests/disable_function
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-02-18 15:59:41 +0100
committerBen Fuhrmannek2021-02-18 15:59:41 +0100
commitfb9b3787246dff3e9b76e75f698ff7131ea5403d (patch)
tree919b4ba77dcfc5487a3906851c24e71f4d25ad82 /src/tests/disable_function
parent01528718850c8528ef6d2ed5296e244d4aa7b675 (diff)
rewrote parameter matching logic. breaks compatibility with previous versions.
Diffstat (limited to 'src/tests/disable_function')
-rw-r--r--src/tests/disable_function/config/disabled_function_excess_args.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_named_args.ini12
-rw-r--r--src/tests/disable_function/config/disabled_functions_pos.ini2
-rw-r--r--src/tests/disable_function/disabled_function_excess_args.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_ooo_param.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_param.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_pos.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_skip_param.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_named_args_skip_pos.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_name_type.phpt2
-rw-r--r--src/tests/disable_function/disabled_functions_param_pos.phpt2
-rw-r--r--src/tests/disable_function/disabled_functions_pos_type.phpt4
15 files changed, 141 insertions, 8 deletions
diff --git a/src/tests/disable_function/config/disabled_function_excess_args.ini b/src/tests/disable_function/config/disabled_function_excess_args.ini
new file mode 100644
index 0000000..289dc33
--- /dev/null
+++ b/src/tests/disable_function/config/disabled_function_excess_args.ini
@@ -0,0 +1 @@
sp.disable_function.function("foo_excess_args").pos("3").value("blubb").drop()
diff --git a/src/tests/disable_function/config/disabled_function_named_args.ini b/src/tests/disable_function/config/disabled_function_named_args.ini
new file mode 100644
index 0000000..094bc0d
--- /dev/null
+++ b/src/tests/disable_function/config/disabled_function_named_args.ini
@@ -0,0 +1,12 @@
1sp.disable_function.function("foo_named_args_pos").pos("0").value("bob").drop()
2sp.disable_function.function("foo_named_args_param").param("name").value("bob").drop()
3
4sp.disable_function.function("foo_named_args_ooo_pos").pos("0").value("bob").drop()
5sp.disable_function.function("foo_named_args_ooo_param").param("name").value("bob").drop()
6
7sp.disable_function.function("foo_named_args_ooo_opt_pos").pos("2").value("green").drop()
8sp.disable_function.function("foo_named_args_ooo_opt_param").param("color").value("green").drop()
9
10sp.disable_function.function("foo_named_args_skip_pos").pos("2").value("green").drop()
11sp.disable_function.function("foo_named_args_skip_param").param("color").value("green").drop()
12
diff --git a/src/tests/disable_function/config/disabled_functions_pos.ini b/src/tests/disable_function/config/disabled_functions_pos.ini
index f4c1e05..8b12fc6 100644
--- a/src/tests/disable_function/config/disabled_functions_pos.ini
+++ b/src/tests/disable_function/config/disabled_functions_pos.ini
@@ -1,4 +1,4 @@
1sp.disable_function.function("system").pos("1337").value("id").drop(); 1sp.disable_function.function("system").pos("1337").value("id").drop();
2sp.disable_function.function("system").pos("0").value("id").drop(); 2sp.disable_function.function("system").pos("0").value("id").drop();
3sp.disable_function.function("system").pos("1").param_type("ARRAY").alias("1").drop(); 3sp.disable_function.function("system").pos("0").param_type("ARRAY").alias("1").drop();
4sp.disable_function.function("strtoupper").pos("0").value("id").alias("strlen array").drop(); 4sp.disable_function.function("strtoupper").pos("0").value("id").alias("strlen array").drop();
diff --git a/src/tests/disable_function/disabled_function_excess_args.phpt b/src/tests/disable_function/disabled_function_excess_args.phpt
new file mode 100644
index 0000000..31b3f33
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_excess_args.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with excess arguments
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_excess_args.ini
7--FILE--
8<?php
9function foo_excess_args($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_excess_args("bob", "hi", "green", "blubb");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_excess_args' in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt
new file mode 100644
index 0000000..6ca49d4
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with out-of-order named optional arguments by matching argument name
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_ooo_opt_param($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_ooo_opt_param("bob", color: "green", greeting: "xxx");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_opt_param', because its argument '$color'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt
new file mode 100644
index 0000000..86abbee
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with out-of-order named optional arguments by matching argument position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_ooo_opt_pos($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_ooo_opt_pos("bob", color: "green", greeting: "xxx");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_opt_pos', because its argument 'color'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt
new file mode 100644
index 0000000..a77fc09
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with out-of-order named arguments by matching argument name
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_ooo_param($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_ooo_param(greeting: "hello!", name: "bob");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_param', because its argument '$name'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt
new file mode 100644
index 0000000..ab7cc00
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with out-of-order named arguments by matching argument position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_ooo_pos($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_ooo_pos(greeting: "hello!", name: "bob");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_pos', because its argument 'name'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_param.phpt b/src/tests/disable_function/disabled_function_named_args_param.phpt
new file mode 100644
index 0000000..f07e736
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_param.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with named arguments by matching argument name
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_param($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_param(name: "bob", greeting: "hello!");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_param', because its argument '$name'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_pos.phpt b/src/tests/disable_function/disabled_function_named_args_pos.phpt
new file mode 100644
index 0000000..c0189fe
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_pos.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with named arguments by matching argument position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_pos($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_pos(name: "bob", greeting: "hello!");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_pos', because its argument 'name'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_skip_param.phpt b/src/tests/disable_function/disabled_function_named_args_skip_param.phpt
new file mode 100644
index 0000000..86b1a5e
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_skip_param.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with named arguments (skipping opt. args) by matching argument name
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_skip_param($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_skip_param("bob", color: "green");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_skip_param', because its argument '$color'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt b/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt
new file mode 100644
index 0000000..ce85241
--- /dev/null
+++ b/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt
@@ -0,0 +1,14 @@
1--TEST--
2Disable functions with named arguments (skipping opt. args) by matching argument position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_named_args.ini
7--FILE--
8<?php
9function foo_named_args_skip_pos($name, $greeting='HI!', $color='red') {
10 echo "boo\n";
11}
12foo_named_args_skip_pos("bob", color: "green");
13--EXPECTF--
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_skip_pos', because its argument 'color'%s matched a rule in %s.php on line %d \ No newline at end of file
diff --git a/src/tests/disable_function/disabled_functions_name_type.phpt b/src/tests/disable_function/disabled_functions_name_type.phpt
index 8d70eaa..62a6328 100644
--- a/src/tests/disable_function/disabled_functions_name_type.phpt
+++ b/src/tests/disable_function/disabled_functions_name_type.phpt
@@ -13,4 +13,4 @@ echo strcmp([1,23], "pouet") . "\n";
13--EXPECTF-- 13--EXPECTF--
140 140
15 15
16Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'strcmp', because its argument '$str1' content (ARRAY) matched a rule in %a/disabled_functions_name_type.php on line 3 16Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'strcmp', because its argument '$str1'%smatched a rule in %s/disabled_functions_name_type.php on line 3
diff --git a/src/tests/disable_function/disabled_functions_param_pos.phpt b/src/tests/disable_function/disabled_functions_param_pos.phpt
index bacca62..4204548 100644
--- a/src/tests/disable_function/disabled_functions_param_pos.phpt
+++ b/src/tests/disable_function/disabled_functions_param_pos.phpt
@@ -9,6 +9,4 @@ sp.configuration_file={PWD}/config/disabled_functions_pos.ini
9system("id"); 9system("id");
10?> 10?>
11--EXPECTF-- 11--EXPECTF--
12Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1337th argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_param_pos.php on line 2
13
14Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (id) matched a rule in %a/disabled_functions_param_pos.php on line %d 12Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (id) matched a rule in %a/disabled_functions_param_pos.php on line %d
diff --git a/src/tests/disable_function/disabled_functions_pos_type.phpt b/src/tests/disable_function/disabled_functions_pos_type.phpt
index ba134ad..29944c0 100644
--- a/src/tests/disable_function/disabled_functions_pos_type.phpt
+++ b/src/tests/disable_function/disabled_functions_pos_type.phpt
@@ -9,8 +9,4 @@ sp.configuration_file={PWD}/config/disabled_functions_pos.ini
9system([123, 456]); 9system([123, 456]);
10?> 10?>
11--EXPECTF-- 11--EXPECTF--
12Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1337th argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_pos_type.php on line %d
13
14Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1st argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_pos_type.php on line %d
15
16Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (?) matched the rule '1' in %a/disabled_functions_pos_type.php on line %d 12Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (?) matched the rule '1' in %a/disabled_functions_pos_type.php on line %d