diff options
| author | BeF | 2022-07-20 12:15:07 +0200 |
|---|---|---|
| committer | GitHub | 2022-07-20 12:15:07 +0200 |
| commit | 2aed4220c2d019cc9b46fec70cfd79d249498e14 (patch) | |
| tree | e7cc3d1d4db617fc5ab1dbcc60f2366407eb5da5 /src/tests/disable_function | |
| parent | 72109c9bf016145364b19162a5ff998fc5858a9c (diff) | |
| parent | 75595945d1d868fbd6db743809ca8a3eb5de3113 (diff) | |
Merge pull request #1 from jvoisin/pr1
pr for fetching upstream
Diffstat (limited to 'src/tests/disable_function')
6 files changed, 59 insertions, 0 deletions
diff --git a/src/tests/disable_function/config/config_disabled_functions_eval_param.ini b/src/tests/disable_function/config/config_disabled_functions_eval_param.ini new file mode 100644 index 0000000..b43faf1 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_eval_param.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("eval").param("code").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_name_type_php8.ini b/src/tests/disable_function/config/config_disabled_functions_name_type_php8.ini new file mode 100644 index 0000000..0f521e7 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_name_type_php8.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function_r("^strcmp$").param("string1").param_type("array").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_str_representation_php8.ini b/src/tests/disable_function/config/config_disabled_functions_param_str_representation_php8.ini new file mode 100644 index 0000000..710ddb3 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_str_representation_php8.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("var_export").param("value").value("bla").drop(); | |||
diff --git a/src/tests/disable_function/disabled_functions_eval_param.phpt b/src/tests/disable_function/disabled_functions_eval_param.phpt new file mode 100644 index 0000000..4f3f1ef --- /dev/null +++ b/src/tests/disable_function/disabled_functions_eval_param.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - eval, on matching parameter | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_eval_param.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $var = 123456789; | ||
| 10 | eval('$var = 1337 + 1337;'); | ||
| 11 | print("Variable: $var\n"); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'eval', because its argument 'code' content ($var = 1337 + 1337;) matched a rule in %s/tests/disable_function/disabled_functions_eval_param.php(3) : eval()'d code on line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_name_type_php8.phpt b/src/tests/disable_function/disabled_functions_name_type_php8.phpt new file mode 100644 index 0000000..8670b4d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_name_type_php8.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/config_disabled_functions_name_type_php8.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo strcmp("pouet", "pouet") . "\n"; | ||
| 11 | echo strcmp([1,23], "pouet") . "\n"; | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'strcmp', because its argument '$string1' content (?) matched a rule in %s/disabled_functions_name_type_php8.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_param_str_representation_php8.phpt b/src/tests/disable_function/disabled_functions_param_str_representation_php8.phpt new file mode 100644 index 0000000..aa5782b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_str_representation_php8.phpt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - casting various types to string internally in php8 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/config_disabled_functions_param_str_representation_php8.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo var_export(true) . "\n"; | ||
| 11 | echo var_export(false) . "\n"; | ||
| 12 | echo var_export(null) . "\n"; | ||
| 13 | echo var_export(1) . "\n"; | ||
| 14 | echo var_export(1.0) . "\n"; | ||
| 15 | function f(&$a) { | ||
| 16 | echo var_export($a) . "\n"; | ||
| 17 | } | ||
| 18 | $a = 123; f($a); | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | true | ||
| 22 | false | ||
| 23 | NULL | ||
| 24 | 1 | ||
| 25 | 1.0 | ||
| 26 | 123 | ||
