diff options
Diffstat (limited to 'src/tests')
15 files changed, 75 insertions, 11 deletions
diff --git a/src/tests/deny_writable/config/config_disable_writable_simulation.ini b/src/tests/deny_writable/config/config_disable_writable_simulation.ini index 52a43ba..3aafe3f 100644 --- a/src/tests/deny_writable/config/config_disable_writable_simulation.ini +++ b/src/tests/deny_writable/config/config_disable_writable_simulation.ini | |||
| @@ -1 +1 @@ | |||
| sp.readonly_exec.enable().simulation(); | sp.readonly_exec.enable().extended_checks().simulation(); | ||
diff --git a/src/tests/deny_writable/deny_writable_execution_simulation.phpt b/src/tests/deny_writable/deny_writable_execution_simulation.phpt index 1118dc0..d4e4801 100644 --- a/src/tests/deny_writable/deny_writable_execution_simulation.phpt +++ b/src/tests/deny_writable/deny_writable_execution_simulation.phpt | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Readonly execution attempt (simulation mode) | 2 | Readonly execution attempt (simulation mode) |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 5 | <?php | 4 | <?php |
| 6 | if (!extension_loaded("snuffleupagus")) { print "skip"; }; | 5 | if (!extension_loaded("snuffleupagus")) { print "skip"; }; |
| 7 | 6 | ||
| @@ -42,10 +41,14 @@ unlink("$dir/non_writable_file.txt"); | |||
| 42 | unlink("$dir/writable_file.txt"); | 41 | unlink("$dir/writable_file.txt"); |
| 43 | ?> | 42 | ?> |
| 44 | --EXPECTF-- | 43 | --EXPECTF-- |
| 45 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/deny_writable_execution_simulation.php). in %a/deny_writable_execution_simulation.php on line 2 | 44 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/deny_writable_execution_simulation.php) in %a/deny_writable_execution_simulation.php on line 2 |
| 46 | 45 | ||
| 47 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/writable_file.txt). in %a/deny_writable_execution_simulation.php on line 12 | 46 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/writable_file.txt) in %a/deny_writable_execution_simulation.php on line 12 |
| 48 | 47 | ||
| 49 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/writable_file.txt). in %a/writable_file.txt on line 1 | 48 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a writable file (%a/writable_file.txt) in %a/writable_file.txt on line 1 |
| 50 | Code execution within a writable file. | 49 | Code execution within a writable file. |
| 50 | |||
| 51 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a file owned by the PHP process (%s/tests/deny_writable/non_writable_file.txt) in %s/tests/deny_writable/deny_writable_execution_simulation.php on line 13 | ||
| 52 | |||
| 53 | Warning: [snuffleupagus][0.0.0.0][readonly_exec][simulation] Attempted execution of a file owned by the PHP process (%s/tests/deny_writable/non_writable_file.txt) in %src/tests/deny_writable/non_writable_file.txt on line 1 | ||
| 51 | Code execution within a non-writable file. | 54 | Code execution within a non-writable file. |
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 | ||
diff --git a/src/tests/dump_request/dump_eval_blacklist.phpt b/src/tests/dump_request/dump_eval_blacklist.phpt index c9f48e4..a8c1618 100644 --- a/src/tests/dump_request/dump_eval_blacklist.phpt +++ b/src/tests/dump_request/dump_eval_blacklist.phpt | |||
| @@ -38,6 +38,8 @@ if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' \n") { | |||
| 38 | echo "Invalid POST"; | 38 | echo "Invalid POST"; |
| 39 | } elseif ($res[5] != "COOKIE:cookie_a='data_cookie_a&cookie_b=data_cookie_b' \n") { | 39 | } elseif ($res[5] != "COOKIE:cookie_a='data_cookie_a&cookie_b=data_cookie_b' \n") { |
| 40 | echo "Invalid COOKIE"; | 40 | echo "Invalid COOKIE"; |
| 41 | } elseif ($res[6] != "EVAL_CODE: \$a = strtoupper(\"1234\");\n") { | ||
| 42 | echo "Invalid EVAL_CODE"; | ||
| 41 | } | 43 | } |
| 42 | ?> | 44 | ?> |
| 43 | --EXPECTF-- | 45 | --EXPECTF-- |
diff --git a/src/tests/ini/ini_min_policy_drop.phpt b/src/tests/ini/ini_min_policy_drop.phpt index ef40ebc..1ec9f9a 100644 --- a/src/tests/ini/ini_min_policy_drop.phpt +++ b/src/tests/ini/ini_min_policy_drop.phpt | |||
| @@ -10,4 +10,4 @@ var_dump(ini_set("max_execution_time", "29") === false); | |||
| 10 | var_dump(ini_get("max_execution_time")); | 10 | var_dump(ini_get("max_execution_time")); |
| 11 | ?> | 11 | ?> |
| 12 | --EXPECTF-- | 12 | --EXPECTF-- |
| 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value out of range in %a/ini_min_policy_drop.php on line 2 | 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value out of range in %a/ini_min_policy_drop.php on line 2%A |
diff --git a/src/tests/ini/ini_minmax.phpt b/src/tests/ini/ini_minmax.phpt index 4cd6bc4..facb73e 100644 --- a/src/tests/ini/ini_minmax.phpt +++ b/src/tests/ini/ini_minmax.phpt | |||
| @@ -31,4 +31,4 @@ string(3) "300" | |||
| 31 | 31 | ||
| 32 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 11 | 32 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 11 |
| 33 | bool(true) | 33 | bool(true) |
| 34 | string(3) "300" \ No newline at end of file | 34 | string(3) "300"%A |
diff --git a/src/tests/ini/ini_null.phpt b/src/tests/ini/ini_null.phpt index 32a12c1..dfc2555 100644 --- a/src/tests/ini/ini_null.phpt +++ b/src/tests/ini/ini_null.phpt | |||
| @@ -23,4 +23,4 @@ string(0) "" | |||
| 23 | 23 | ||
| 24 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] new INI value must not be NULL or empty in %a/ini_null.php on line 8 | 24 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] new INI value must not be NULL or empty in %a/ini_null.php on line 8 |
| 25 | bool(true) | 25 | bool(true) |
| 26 | string(3) "def" \ No newline at end of file | 26 | string(3) "def"%A |
diff --git a/src/tests/ini/ini_regexp.phpt b/src/tests/ini/ini_regexp.phpt index f6c5198..c7cab35 100644 --- a/src/tests/ini/ini_regexp.phpt +++ b/src/tests/ini/ini_regexp.phpt | |||
| @@ -16,4 +16,4 @@ var_dump(ini_get("highlight.comment")); | |||
| 16 | string(7) "#000aBc" | 16 | string(7) "#000aBc" |
| 17 | 17 | ||
| 18 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value does not match regex in %a/ini_regexp.php on line 5 | 18 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value does not match regex in %a/ini_regexp.php on line 5 |
| 19 | string(7) "#000aBc" | 19 | string(7) "#000aBc"%A |
diff --git a/src/tests/ini/ini_regexp_drop.phpt b/src/tests/ini/ini_regexp_drop.phpt index 9225470..432be8d 100644 --- a/src/tests/ini/ini_regexp_drop.phpt +++ b/src/tests/ini/ini_regexp_drop.phpt | |||
| @@ -10,4 +10,4 @@ var_dump(ini_set("user_agent", "Foo") === false); | |||
| 10 | var_dump(ini_get("user_agent")); | 10 | var_dump(ini_get("user_agent")); |
| 11 | ?> | 11 | ?> |
| 12 | --EXPECTF-- | 12 | --EXPECTF-- |
| 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value does not match regex in %a/ini_regexp_drop.php on line 2 | 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value does not match regex in %a/ini_regexp_drop.php on line 2%A%A%A%A |
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt index 107171c..4a888ed 100644 --- a/src/tests/xxe/disable_xxe_dom_disabled.phpt +++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Disable XXE (feature enabled) | 2 | Disable XXE (feature enabled) |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom") || !extension_loaded("xml")) print("skip"); ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> |
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/disable_xxe.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe.ini |
