diff options
Diffstat (limited to 'src/tests/disable_function')
191 files changed, 2518 insertions, 0 deletions
diff --git a/src/tests/disable_function/config/config_disabled_functions_callback_called_file_r.ini b/src/tests/disable_function/config/config_disabled_functions_callback_called_file_r.ini new file mode 100644 index 0000000..daaee36 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_callback_called_file_r.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("test_callback").filename_r("callback\\.php$").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_called_file_r.ini b/src/tests/disable_function/config/config_disabled_functions_called_file_r.ini new file mode 100644 index 0000000..17b019a --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_called_file_r.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function_r("test").filename_r("file_r\\.php$").drop(); \ No newline at end of file | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_chain.ini b/src/tests/disable_function/config/config_disabled_functions_chain.ini new file mode 100644 index 0000000..d5d9b62 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_chain.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("outer>inner>other").drop(); | ||
| 2 | sp.disable_function.function("other>outer>inner_").drop(); | ||
| 3 | sp.disable_function.function("outer>inner").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func.ini b/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func.ini new file mode 100644 index 0000000..4f7a629 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("outer>call_user_func>inner").simulation().drop(); | ||
| 2 | sp.disable_function.function("outer>inner").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func_ret.ini b/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func_ret.ini new file mode 100644 index 0000000..f003b7d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_chain_call_user_func_ret.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("one>two").simulation().ret("matching_two").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_eval_filename.ini b/src/tests/disable_function/config/config_disabled_functions_eval_filename.ini new file mode 100644 index 0000000..6c593fc --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_eval_filename.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("eval").filename_r("^.*/disabled_functions_eval_filename.php$").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_eval_user_func.ini b/src/tests/disable_function/config/config_disabled_functions_eval_user_func.ini new file mode 100644 index 0000000..4d0d370 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_eval_user_func.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("my_func").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_filename_r.ini b/src/tests/disable_function/config/config_disabled_functions_filename_r.ini new file mode 100644 index 0000000..fe79608 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_filename_r.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function_r("^system$").filename_r("\\.txt$").drop(); | ||
| 2 | sp.disable_function.function_r("^shell_exec$").filename_r("\\.php$").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_include.ini b/src/tests/disable_function/config/config_disabled_functions_include.ini new file mode 100644 index 0000000..cee0d86 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_include.ini | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | sp.disable_function.function("include").param("").value_r("sim$").drop().simulation(); | ||
| 2 | sp.disable_function.function("include").param("").value_r("meh$").drop(); | ||
| 3 | |||
| 4 | sp.disable_function.function("include_once").param("").value_r("sim$").drop().simulation(); | ||
| 5 | sp.disable_function.function("include_once").param("").value_r("meh$").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_local_var_array.ini b/src/tests/disable_function/config/config_disabled_functions_local_var_array.ini new file mode 100644 index 0000000..15dd5a1 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_local_var_array.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foo").var("$a[test2][foo]").value("aaa").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_local_var_array_key.ini b/src/tests/disable_function/config/config_disabled_functions_local_var_array_key.ini new file mode 100644 index 0000000..75c840d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_local_var_array_key.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foo").var("$a[test2][foo]").key("aaa").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_method.ini b/src/tests/disable_function/config/config_disabled_functions_method.ini new file mode 100644 index 0000000..8fbce65 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_method.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("AwesomeClass::method1").drop(); | ||
| 2 | sp.disable_function.function("method2").drop(); | ||
| 3 | sp.disable_function.function("AwesomeClass::method3").param("a").value("pouet").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_name_r.ini b/src/tests/disable_function/config/config_disabled_functions_name_r.ini new file mode 100644 index 0000000..167d6f0 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_name_r.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function_r("^not_system$").ret("42").drop(); | ||
| 2 | sp.disable_function.function_r("^system$").ret("1337").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_name_regexp_type.ini b/src/tests/disable_function/config/config_disabled_functions_name_regexp_type.ini new file mode 100644 index 0000000..38f9657 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_name_regexp_type.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strcmp").pos("0").param_type("array").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_name_type.ini b/src/tests/disable_function/config/config_disabled_functions_name_type.ini new file mode 100644 index 0000000..25bdf98 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_name_type.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function_r("^strcmp$").param("str1").param_type("array").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_namespace.ini b/src/tests/disable_function/config/config_disabled_functions_namespace.ini new file mode 100644 index 0000000..2926611 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_namespace.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("strcmp").drop(); | ||
| 2 | sp.disable_function.function("my_super_namespace\\my_function").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_nul_byte.ini b/src/tests/disable_function/config/config_disabled_functions_nul_byte.ini new file mode 100644 index 0000000..9ead077 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_nul_byte.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("system").param("command").value_r("id").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param.ini b/src/tests/disable_function/config/config_disabled_functions_param.ini new file mode 100644 index 0000000..87f1b3c --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param.ini | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | sp.disable_function.function("system").param("command").value_r("^id$").alias("1").drop(); | ||
| 2 | sp.disable_function.function("array_sum").param("array").value_r("^8$").alias("2").drop(); | ||
| 3 | sp.disable_function.function("shell_exec").param("cmd").value("id").alias("3").drop(); | ||
| 4 | sp.disable_function.function("shell_exec").param("cmd").value("bla").alias("4").drop(); | ||
| 5 | sp.disable_function.function("strcmp").param("str1").value("bla").alias("5").drop().simulation(); | ||
| 6 | sp.disable_function.function("strncmp").param("str1").value("bla").drop().simulation(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_alias.ini b/src/tests/disable_function/config/config_disabled_functions_param_alias.ini new file mode 100644 index 0000000..2f06244 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_alias.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("system").alias("1").drop(); | ||
| 2 | sp.disable_function.function("shell_exec").alias("2").drop().simulation(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_allow.ini b/src/tests/disable_function/config/config_disabled_functions_param_allow.ini new file mode 100644 index 0000000..8e139e4 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_allow.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("system").param("command").value("echo win").filename("/test.php").drop(); | ||
| 2 | sp.disable_function.function("system").param("command").value("echo win").allow(); | ||
| 3 | sp.disable_function.function("system").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_array.ini b/src/tests/disable_function/config/config_disabled_functions_param_array.ini new file mode 100644 index 0000000..f676d76 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_array.ini | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | sp.disable_function.function("foo").param("arr[a]").value("abcd").alias("1").drop(); | ||
| 2 | sp.disable_function.function("foo").param("arr[bla]").value("abcdef").alias("2").drop(); | ||
| 3 | sp.disable_function.function("foo").param("arr[test]").alias("3").drop(); | ||
| 4 | sp.disable_function.function("foo").param("arr[test2][foo]").value("aaa").alias("4").drop(); | ||
| 5 | sp.disable_function.function("foo").param("arr[test2][bar]").key("lol").alias("5").drop(); | ||
| 6 | sp.disable_function.function("foo").param("arr[test2][bar]").key("123").alias("6").drop(); | ||
| 7 | sp.disable_function.function("foo").param("qwe[a]").value("abcd").alias("7").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_int.ini b/src/tests/disable_function/config/config_disabled_functions_param_int.ini new file mode 100644 index 0000000..1c93c2f --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_int.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("foobar").param("id").value("42").drop(); | ||
| 2 | sp.disable_function.function("foobar").param("id").value_r("^1337").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_r.ini b/src/tests/disable_function/config/config_disabled_functions_param_r.ini new file mode 100644 index 0000000..09a59fe --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_r.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("system").param_r("^not_command$").value("id").drop(); | ||
| 2 | sp.disable_function.function("system").param_r("^command$").value("id").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_r_array.ini b/src/tests/disable_function/config/config_disabled_functions_param_r_array.ini new file mode 100644 index 0000000..fcac71d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_r_array.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("foo").param_r("arr").value("abcd").alias("1").drop(); | ||
| 2 | sp.disable_function.function("foo").param_r("arr").key_r("abc").alias("2").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_runtime.ini b/src/tests/disable_function/config/config_disabled_functions_param_runtime.ini new file mode 100644 index 0000000..e7a011f --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_runtime.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("test").param("param").value_r("1337").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_param_str_representation.ini b/src/tests/disable_function/config/config_disabled_functions_param_str_representation.ini new file mode 100644 index 0000000..13b3974 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_param_str_representation.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("var_export").param("var").value("bla").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_require.ini b/src/tests/disable_function/config/config_disabled_functions_require.ini new file mode 100644 index 0000000..63a4eb2 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_require.ini | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | sp.disable_function.function("require").param("").value_r("sim$").drop().simulation(); | ||
| 2 | sp.disable_function.function("require").param("").value_r("meh$").drop(); | ||
| 3 | |||
| 4 | sp.disable_function.function("require_once").param("").value_r("sim$").drop().simulation(); | ||
| 5 | sp.disable_function.function("require_once").param("").value_r("meh$").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_require_allow.ini b/src/tests/disable_function/config/config_disabled_functions_require_allow.ini new file mode 100644 index 0000000..ee2bb67 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_require_allow.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("require").param("").value_r("meh$").allow(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_ret_allow.ini b/src/tests/disable_function/config/config_disabled_functions_ret_allow.ini new file mode 100644 index 0000000..a97e21d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_ret_allow.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("strpos").hash("70b33f3eaf585b245640bb2c92445d0040b2bcb31395aa25dede9f2df4dbcbe8").allow(); | ||
| 2 | sp.disable_function.function("strpos").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_ret_allow_value.ini b/src/tests/disable_function/config/config_disabled_functions_ret_allow_value.ini new file mode 100644 index 0000000..b5d3bdd --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_ret_allow_value.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strpos").ret("0").allow(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_ret_right_hash.ini b/src/tests/disable_function/config/config_disabled_functions_ret_right_hash.ini new file mode 100644 index 0000000..af4fdd4 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_ret_right_hash.ini | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | sp.disable_function.function("system").ret("1").drop(); | ||
| 2 | sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); | ||
| 3 | sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); | ||
| 4 | sp.disable_function.function("system").ret("1337").hash("d259c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_ret_simulation.ini b/src/tests/disable_function/config/config_disabled_functions_ret_simulation.ini new file mode 100644 index 0000000..bd0af4e --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_ret_simulation.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("strpos").ret("0").simulation().drop(); | ||
| 2 | sp.disable_function.function("stripos").ret("0").simulation().drop().alias("1"); | ||
| 3 | sp.disable_function.function("strcmp").ret("0").drop(); | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_ret_user.ini b/src/tests/disable_function/config/config_disabled_functions_ret_user.ini new file mode 100644 index 0000000..d214376 --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_ret_user.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("qwe").ret("asd").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_functions_right_hash.ini b/src/tests/disable_function/config/config_disabled_functions_right_hash.ini new file mode 100644 index 0000000..4e9b88c --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_right_hash.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("system").hash("1337c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").allow(); | ||
| 2 | sp.disable_function.function("system").hash("d259c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").allow(); | ||
| 3 | sp.disable_function.function("system").drop(); \ No newline at end of file | ||
diff --git a/src/tests/disable_function/config/config_disabled_functions_variadic.ini b/src/tests/disable_function/config/config_disabled_functions_variadic.ini new file mode 100644 index 0000000..cd1028d --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_functions_variadic.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foo").param("$b").value("1337").drop(); | |||
diff --git a/src/tests/disable_function/config/config_disabled_user_functions.ini b/src/tests/disable_function/config/config_disabled_user_functions.ini new file mode 100644 index 0000000..16ae4cb --- /dev/null +++ b/src/tests/disable_function/config/config_disabled_user_functions.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("my_super_function").drop(); | |||
diff --git a/src/tests/disable_function/config/config_noncore_function_hooking.ini b/src/tests/disable_function/config/config_noncore_function_hooking.ini new file mode 100644 index 0000000..341cbf9 --- /dev/null +++ b/src/tests/disable_function/config/config_noncore_function_hooking.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("custom_fun").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_curl_verify_certs.ini b/src/tests/disable_function/config/disabled_function_curl_verify_certs.ini new file mode 100644 index 0000000..133e024 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_curl_verify_certs.ini | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # `81` being SSL_VERIFYHOST, and `64` SSL_VERIFYPEER | ||
| 2 | |||
| 3 | sp.disable_function.function("curl_setopt").param("value").value("1").allow(); | ||
| 4 | sp.disable_function.function("curl_setopt").param("value").value("2").allow(); | ||
| 5 | sp.disable_function.function("curl_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 6 | sp.disable_function.function("curl_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
| 7 | |||
| 8 | # --- | ||
| 9 | |||
| 10 | sp.disable_function.function("curl_setopt_array").param("options[CURLOPT_SSL_VERIFYHOST]").value("0").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 11 | sp.disable_function.function("curl_setopt_array").param("options[CURLOPT_SSL_VERIFYPEER]").value("0").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
| 12 | |||
| 13 | # --- | ||
| 14 | |||
| 15 | sp.disable_function.function("curl_multi_setopt").param("value").value("1").allow(); | ||
| 16 | sp.disable_function.function("curl_multi_setopt").param("value").value("2").allow(); | ||
| 17 | sp.disable_function.function("curl_multi_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 18 | sp.disable_function.function("curl_multi_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
diff --git a/src/tests/disable_function/config/disabled_function_echo.ini b/src/tests/disable_function/config/disabled_function_echo.ini new file mode 100644 index 0000000..39bc5e3 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_echo.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("echo").var("$abc").value("123").drop(); | ||
| 2 | sp.disable_function.function("echo").value("oops").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_function_local_var.ini b/src/tests/disable_function/config/disabled_function_local_var.ini new file mode 100644 index 0000000..3d553c0 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_local_var.ini | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | sp.disable_function.function("phpinfo").var("$b").value("1337").drop(); | ||
| 2 | sp.disable_function.function("strlen").var("$a").value("1337").drop(); | ||
| 3 | sp.disable_function.function("strlen").var("$a['123']").value("block").drop(); | ||
| 4 | sp.disable_function.function("strlen").var("$a[$c]->prop").value("block").drop(); | ||
| 5 | sp.disable_function.function("strlen").var("$a->zxc").value("not a good value").drop(); | ||
| 6 | sp.disable_function.function("strlen").var("\\asd\\test_object::TEST_VALUE['constant']").value("no good").drop(); | ||
| 7 | sp.disable_function.function("strlen").var("\\asd\\test_object::TEST_VALUE").value("qwerty").drop(); | ||
| 8 | sp.disable_function.function("strlen").var("\\qwe\\ASD").value("qwerty").drop(); | ||
| 9 | sp.disable_function.function("strlen").var("\\qwe\\QWE['123']").value("asdfgh").drop(); | ||
| 10 | sp.disable_function.function("strlen").var("$qwe").value("block this").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_function_local_var_2.ini b/src/tests/disable_function/config/disabled_function_local_var_2.ini new file mode 100644 index 0000000..6c0ae66 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_local_var_2.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strlen").var("$b['_GET][\"obj->nop::qwe'][$b[456][$d->$idk->qwe[\\qwe\\UNE_CONSTANTE]]][$a]->uio").value("valeur de apres").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_local_var_array_not_array.ini b/src/tests/disable_function/config/disabled_function_local_var_array_not_array.ini new file mode 100644 index 0000000..ea25d1f --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_local_var_array_not_array.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foobar").var("a").value("test").drop().simulation(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_local_var_const.ini b/src/tests/disable_function/config/disabled_function_local_var_const.ini new file mode 100644 index 0000000..8450de5 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_local_var_const.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strlen").var("MY_CONST").value("1337").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_local_var_obj.ini b/src/tests/disable_function/config/disabled_function_local_var_obj.ini new file mode 100644 index 0000000..df6b617 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_local_var_obj.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.disable_function.function("strlen").var("$test->$test_array").value("value").drop(); | ||
| 2 | sp.disable_function.function("strlen").var("$arg->$test_array").value("value").drop(); | ||
| 3 | sp.disable_function.function("strlen").var("$test->$arg").value("nop_object").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_function_param.ini b/src/tests/disable_function/config/disabled_function_param.ini new file mode 100644 index 0000000..6dbae6b --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_param.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("qweqwe").param("$asd[0]").value("2").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_print.ini b/src/tests/disable_function/config/disabled_function_print.ini new file mode 100644 index 0000000..22d957f --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_print.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("print").value("oops").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_function_super_global_var.ini b/src/tests/disable_function/config/disabled_function_super_global_var.ini new file mode 100644 index 0000000..178a01a --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_super_global_var.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strlen").var("$_GET[bla]").value("test2").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions.ini b/src/tests/disable_function/config/disabled_functions.ini new file mode 100644 index 0000000..df7013f --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions.ini | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | sp.disable_function.function("system").drop(); | ||
| 2 | sp.disable_function.function("vprintf").hash("123456789").drop(); | ||
| 3 | sp.disable_function.function("printf").disable().drop(); | ||
| 4 | sp.disable_function.function("printf").simulation().drop(); | ||
| 5 | sp.disable_function.function("print").disable().drop(); # this is a comment | ||
| 6 | sp.disable_function.function_r("^var_dump$").drop(); | ||
| 7 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); | ||
| 8 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); | ||
| 9 | sp.disable_function.function("eval").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_broken_line.ini b/src/tests/disable_function/config/disabled_functions_broken_line.ini new file mode 100644 index 0000000..01229c5 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_broken_line.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("system").line("qwe").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_cidr.ini b/src/tests/disable_function/config/disabled_functions_cidr.ini new file mode 100644 index 0000000..f69ce07 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_cidr.ini | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("2001:ab9:a::123/64"); | ||
| 2 | sp.disable_function.function("system").drop().cidr("192.168.0.1/16"); | ||
| 3 | sp.disable_function.function("system").drop().cidr("127.0.0.1/8"); | ||
| 4 | sp.disable_function.function("printf").drop().cidr("10.0.0.1/8"); | ||
| 5 | sp.disable_function.function("strpos").drop().cidr("127.0.0.2/4"); | ||
| 6 | sp.disable_function.function("strpos").drop().cidr("::ffff:192.0.2.128/128"); | ||
| 7 | sp.disable_function.function("strpos").drop().cidr("2001:ab9:a::123/64"); | ||
| 8 | sp.disable_function.function("strpos").drop().cidr("2001:0db8:f000:f000:f000:ff00:0042:8329/124"); | ||
| 9 | sp.disable_function.function("printf").drop().cidr("2002:0db8:0000:0000:0000:ff00:0042:8329/24"); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_die.ini b/src/tests/disable_function/config/disabled_functions_die.ini new file mode 100644 index 0000000..4f070b9 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_die.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("die").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_drop_include.ini b/src/tests/disable_function/config/disabled_functions_drop_include.ini new file mode 100644 index 0000000..0b10f65 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_drop_include.ini | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | sp.disable_function.function("require_once").value_r("\.ico$").drop(); | ||
| 2 | sp.disable_function.function("include_once").value_r("\.ico$").drop(); | ||
| 3 | sp.disable_function.function("require").value_r("\.ico$").drop(); | ||
| 4 | sp.disable_function.function("include").value_r("\.ico$").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_drop_include_simulation.ini b/src/tests/disable_function/config/disabled_functions_drop_include_simulation.ini new file mode 100644 index 0000000..4064da1 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_drop_include_simulation.ini | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | sp.disable_function.function("require_once").value_r("\.ico$").drop().simulation(); | ||
| 2 | sp.disable_function.function("include_once").value_r("\.ico$").drop().simulation(); | ||
| 3 | sp.disable_function.function("require").value_r("\.ico$").drop().simulation(); | ||
| 4 | sp.disable_function.function("include").value_r("\.ico$").drop().simulation(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_eval.ini b/src/tests/disable_function/config/disabled_functions_eval.ini new file mode 100644 index 0000000..f761259 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_eval.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("eval").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_eval_simulation.ini b/src/tests/disable_function/config/disabled_functions_eval_simulation.ini new file mode 100644 index 0000000..f1dc58c --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_eval_simulation.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("eval").drop().simulation(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_exit.ini b/src/tests/disable_function/config/disabled_functions_exit.ini new file mode 100644 index 0000000..905296e --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_exit.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("exit").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_invalid_pos.ini b/src/tests/disable_function/config/disabled_functions_invalid_pos.ini new file mode 100644 index 0000000..42988e4 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_invalid_pos.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("system").pos("qwe").value("id").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_line.ini b/src/tests/disable_function/config/disabled_functions_line.ini new file mode 100644 index 0000000..b00cab6 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_line.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("system").line("3").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_mb.ini b/src/tests/disable_function/config/disabled_functions_mb.ini new file mode 100644 index 0000000..36eae40 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_mb.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("strlen").drop(); | ||
| 2 | sp.disable_function.function("mb_strlen").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_pos.ini b/src/tests/disable_function/config/disabled_functions_pos.ini new file mode 100644 index 0000000..7f7c04d --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_pos.ini | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | sp.disable_function.function("system").pos("1337").value("id").drop(); | ||
| 2 | sp.disable_function.function("system").pos("0").value("id").drop(); | ||
| 3 | sp.disable_function.function("system").pos("1").param_type("ARRAY").alias("1").drop(); | ||
| 4 | sp.disable_function.function("strlen").pos("0").value("id").alias("strlen array").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_regexp.ini b/src/tests/disable_function/config/disabled_functions_regexp.ini new file mode 100644 index 0000000..0276039 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_regexp.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function_r("str").drop().simulation(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret.ini b/src/tests/disable_function/config/disabled_functions_ret.ini new file mode 100644 index 0000000..60cea82 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret.ini | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | sp.disable_function.function("testFunction").ret("0").drop().disable(); | ||
| 2 | sp.disable_function.function("strpos").ret("0").drop().filename_r(".*\\.not_matching"); | ||
| 3 | sp.disable_function.function("strpos").ret("0").drop().filename_r(".*\\.php"); | ||
| 4 | sp.disable_function.function_r("str[ia]pos").ret_r("^[^a-z]+$").drop(); | ||
| 5 | sp.disable_function.function_r("stripos").ret_r("^[^a-z]+").drop(); | ||
| 6 | sp.disable_function.function("Bob::a").ret("2").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type.ini b/src/tests/disable_function/config/disabled_functions_ret_type.ini new file mode 100644 index 0000000..bf88402 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strpos").ret_type("false").drop().alias("Return value is FALSE"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_array.ini b/src/tests/disable_function/config/disabled_functions_ret_type_array.ini new file mode 100644 index 0000000..f72dd82 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_array.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("get_loaded_extensions").drop().alias("Return value is an array").ret_type("array"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_double.ini b/src/tests/disable_function/config/disabled_functions_ret_type_double.ini new file mode 100644 index 0000000..a5a6ce3 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_double.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("cos").ret_type("double").drop().alias("Return value is a double"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_long.ini b/src/tests/disable_function/config/disabled_functions_ret_type_long.ini new file mode 100644 index 0000000..03abf8a --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_long.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("strlen").ret_type("long").drop().alias("Return value is a long"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_null.ini b/src/tests/disable_function/config/disabled_functions_ret_type_null.ini new file mode 100644 index 0000000..70c4d69 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_null.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("my_function").ret_type("null").drop().alias("Return value is null"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_object.ini b/src/tests/disable_function/config/disabled_functions_ret_type_object.ini new file mode 100644 index 0000000..8fe240b --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_object.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("a").ret_type("object").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_resource.ini b/src/tests/disable_function/config/disabled_functions_ret_type_resource.ini new file mode 100644 index 0000000..a9c9acf --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_resource.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("fopen").ret_type("resource").drop().alias("Return value is a resource"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_str.ini b/src/tests/disable_function/config/disabled_functions_ret_type_str.ini new file mode 100644 index 0000000..2d306b0 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_str.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("substr").ret_type("string").drop().alias("Return value is a string"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_ret_type_true.ini b/src/tests/disable_function/config/disabled_functions_ret_type_true.ini new file mode 100644 index 0000000..df5db0e --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_ret_type_true.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("is_numeric").ret_type("true").drop().alias("Return value is a true"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_retval.ini b/src/tests/disable_function/config/disabled_functions_retval.ini new file mode 100644 index 0000000..25a99f0 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_retval.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("str_repeat").ret("fufufu").filename("/var/www/test.php").drop(); | ||
| 2 | sp.disable_function.function("str_repeat").ret("fufufu").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_retval_dump.ini b/src/tests/disable_function/config/disabled_functions_retval_dump.ini new file mode 100644 index 0000000..97df351 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_retval_dump.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("str_repeat").ret("fufufu").drop().dump("/tmp/dump_result/"); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_retval_rx.ini b/src/tests/disable_function/config/disabled_functions_retval_rx.ini new file mode 100644 index 0000000..2352941 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_retval_rx.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("str_repeat").ret_r("(fu){3}").drop(); | |||
diff --git a/src/tests/disable_function/config/disabled_functions_zero_cidr.ini b/src/tests/disable_function/config/disabled_functions_zero_cidr.ini new file mode 100644 index 0000000..e0bf2d6 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_zero_cidr.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("system").drop().cidr("0.0.0.0/0"); | |||
diff --git a/src/tests/disable_function/config/empty.ini b/src/tests/disable_function/config/empty.ini new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tests/disable_function/config/empty.ini | |||
diff --git a/src/tests/disable_function/disabled_function_echo.phpt b/src/tests/disable_function/disabled_function_echo.phpt new file mode 100644 index 0000000..21e2002 --- /dev/null +++ b/src/tests/disable_function/disabled_function_echo.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Echo hooking | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_echo.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test($a) { | ||
| 10 | print "$a"; | ||
| 11 | } | ||
| 12 | echo "qwe"; | ||
| 13 | test("rty"); | ||
| 14 | test("oops"); | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | --EXPECTF-- | ||
| 18 | qwerty | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'echo' in %a/disabled_function_echo.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_echo_2.phpt b/src/tests/disable_function/disabled_function_echo_2.phpt new file mode 100644 index 0000000..66cace3 --- /dev/null +++ b/src/tests/disable_function/disabled_function_echo_2.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Echo hooking | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_echo.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo "qwe"; | ||
| 10 | echo "1", "oops"; | ||
| 11 | ?> | ||
| 12 | --CLEAN-- | ||
| 13 | --EXPECTF-- | ||
| 14 | qwe1 | ||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'echo' in %a/disabled_function_echo_2.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_echo_local_var.phpt b/src/tests/disable_function/disabled_function_echo_local_var.phpt new file mode 100644 index 0000000..300f38e --- /dev/null +++ b/src/tests/disable_function/disabled_function_echo_local_var.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Echo hooking | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_echo.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test() { | ||
| 10 | print "3\n"; | ||
| 11 | } | ||
| 12 | $abc = 1; | ||
| 13 | test(); | ||
| 14 | $abc = 123; | ||
| 15 | test(); | ||
| 16 | ?> | ||
| 17 | --CLEAN-- | ||
| 18 | --EXPECTF-- | ||
| 19 | 3 | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'echo' in %a/disabled_function_echo_local_var.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_client_valid_certs.phpt b/src/tests/disable_function/disabled_function_ensure_client_valid_certs.phpt new file mode 100644 index 0000000..513b650 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_client_valid_certs.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt', because its argument '$option' content (64) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/disabled_function_ensure_client_valid_certs.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt b/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt new file mode 100644 index 0000000..a854558 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled via `curl_multi_setopt` | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $mch = curl_multi_init(); | ||
| 13 | curl_multi_setopt($mch, CURLOPT_SSL_VERIFYPEER, 0); | ||
| 14 | echo "1337"; | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_multi_setopt', because its argument '$option' content (64) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/disabled_function_ensure_client_valid_certs_curl_multi_setopt.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt b/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt new file mode 100644 index 0000000..86f95d2 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled via `curl_setopt_array` | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | $options = array(CURLOPT_SSL_VERIFYPEER => 0); | ||
| 15 | curl_setopt_array($ch, $options); | ||
| 16 | echo "1337"; | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt_array', because its argument '$options' content (0) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/disabled_function_ensure_client_valid_certs_curl_setopt_array.php on line 5 | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_server_valid_certs.phpt b/src/tests/disable_function/disabled_function_ensure_server_valid_certs.phpt new file mode 100644 index 0000000..8a50c97 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_server_valid_certs.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt', because its argument '$option' content (81) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/disabled_function_ensure_server_valid_certs.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt b/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt new file mode 100644 index 0000000..4513848 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled via `curl_multi_setopt` | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $mch = curl_multi_init(); | ||
| 13 | curl_multi_setopt($mch, CURLOPT_SSL_VERIFYHOST, 0); | ||
| 14 | echo "1337"; | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_multi_setopt', because its argument '$option' content (81) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/disabled_function_ensure_server_valid_certs_curl_multi_setopt.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt b/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt new file mode 100644 index 0000000..c10d9b0 --- /dev/null +++ b/src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled via `curl_setopt_array` | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | $options = array(CURLOPT_SSL_VERIFYHOST => 0); | ||
| 15 | curl_setopt_array($ch, $options); | ||
| 16 | echo "1337"; | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt_array', because its argument '$options' content (0) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/disabled_function_ensure_server_valid_certs_curl_setopt_array.php on line 5 | ||
diff --git a/src/tests/disable_function/disabled_function_local_var.phpt b/src/tests/disable_function/disabled_function_local_var.phpt new file mode 100644 index 0000000..99b2b08 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $a = 1338; | ||
| 10 | function test(){ | ||
| 11 | echo strlen("id") . "\n"; | ||
| 12 | } | ||
| 13 | echo "Value of a: $a\n"; | ||
| 14 | test(); | ||
| 15 | |||
| 16 | $a = 1337; | ||
| 17 | echo "Value of a: $a\n"; | ||
| 18 | test(); | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | Value of a: 1338 | ||
| 22 | 2 | ||
| 23 | Value of a: 1337 | ||
| 24 | |||
| 25 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_10.phpt b/src/tests/disable_function/disabled_function_local_var_10.phpt new file mode 100644 index 0000000..4902972 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_10.phpt | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $qwe = Array('123' => Array('qwe'), '456' => Array('no block this')); | ||
| 10 | var_dump($qwe); | ||
| 11 | strlen("qwe"); | ||
| 12 | $qwe = Array('123' => Array('qwe'), '456' => Array(Array('block this'))); | ||
| 13 | var_dump($qwe); | ||
| 14 | strlen("qwe"); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | array(2) { | ||
| 18 | [123]=> | ||
| 19 | array(1) { | ||
| 20 | [0]=> | ||
| 21 | string(3) "qwe" | ||
| 22 | } | ||
| 23 | [456]=> | ||
| 24 | array(1) { | ||
| 25 | [0]=> | ||
| 26 | string(13) "no block this" | ||
| 27 | } | ||
| 28 | } | ||
| 29 | array(2) { | ||
| 30 | [123]=> | ||
| 31 | array(1) { | ||
| 32 | [0]=> | ||
| 33 | string(3) "qwe" | ||
| 34 | } | ||
| 35 | [456]=> | ||
| 36 | array(1) { | ||
| 37 | [0]=> | ||
| 38 | array(1) { | ||
| 39 | [0]=> | ||
| 40 | string(10) "block this" | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_10.php on line 7 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_2.phpt b/src/tests/disable_function/disabled_function_local_var_2.phpt new file mode 100644 index 0000000..5b21d07 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_2.phpt | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $a = 1338; | ||
| 10 | function test(){ | ||
| 11 | echo strlen("id") . "\n"; | ||
| 12 | } | ||
| 13 | echo "Value of a: $a\n"; | ||
| 14 | test(); | ||
| 15 | |||
| 16 | $a = Array(); | ||
| 17 | $a['qwe'] = 'block'; | ||
| 18 | $a['123'] = 'nop'; | ||
| 19 | echo "Value of a:\n"; | ||
| 20 | var_dump($a); | ||
| 21 | test(); | ||
| 22 | |||
| 23 | $a['123'] = 'block'; | ||
| 24 | echo "Value of a:\n"; | ||
| 25 | var_dump($a); | ||
| 26 | test(); | ||
| 27 | ?> | ||
| 28 | --EXPECTF-- | ||
| 29 | Value of a: 1338 | ||
| 30 | 2 | ||
| 31 | Value of a: | ||
| 32 | array(2) { | ||
| 33 | ["qwe"]=> | ||
| 34 | string(5) "block" | ||
| 35 | [123]=> | ||
| 36 | string(3) "nop" | ||
| 37 | } | ||
| 38 | 2 | ||
| 39 | Value of a: | ||
| 40 | array(2) { | ||
| 41 | ["qwe"]=> | ||
| 42 | string(5) "block" | ||
| 43 | [123]=> | ||
| 44 | string(5) "block" | ||
| 45 | } | ||
| 46 | |||
| 47 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_2.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_3.phpt b/src/tests/disable_function/disabled_function_local_var_3.phpt new file mode 100644 index 0000000..597be1d --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_3.phpt | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test(){ | ||
| 10 | echo strlen("id") . "\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a = Array(); | ||
| 14 | $c = '123'; | ||
| 15 | $a['qwe'] = 'qwe'; | ||
| 16 | $a['123'] = 'nop'; | ||
| 17 | echo "Value of a:\n"; | ||
| 18 | var_dump($a); | ||
| 19 | test(); | ||
| 20 | |||
| 21 | $a[$c] = (Object)['prop' => 'block']; | ||
| 22 | echo "Value of a:\n"; | ||
| 23 | var_dump($a); | ||
| 24 | test(); | ||
| 25 | ?> | ||
| 26 | --EXPECTF-- | ||
| 27 | Value of a: | ||
| 28 | array(2) { | ||
| 29 | ["qwe"]=> | ||
| 30 | string(3) "qwe" | ||
| 31 | [123]=> | ||
| 32 | string(3) "nop" | ||
| 33 | } | ||
| 34 | 2 | ||
| 35 | Value of a: | ||
| 36 | array(2) { | ||
| 37 | ["qwe"]=> | ||
| 38 | string(3) "qwe" | ||
| 39 | [123]=> | ||
| 40 | object(stdClass)#1 (1) { | ||
| 41 | ["prop"]=> | ||
| 42 | string(5) "block" | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_3.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_4.phpt b/src/tests/disable_function/disabled_function_local_var_4.phpt new file mode 100644 index 0000000..b441576 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_4.phpt | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var_2.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace qwe { | ||
| 10 | const UNE_CONSTANTE = 'constant'; | ||
| 11 | } | ||
| 12 | namespace asd { | ||
| 13 | $b = Array(); | ||
| 14 | $b['_GET[obj->nop]'] = Array(); | ||
| 15 | $b['_GET[obj->nop]']["qwe"] = Array(); | ||
| 16 | $b[456] = Array(); | ||
| 17 | $b[456]['zxc'] = "qwe"; | ||
| 18 | $b[456]['nop'] = "nop"; | ||
| 19 | $b['_GET[obj->nop]']["qwe"][321] = "Yeay"; | ||
| 20 | $b["123"] = "qwe"; | ||
| 21 | $b["123a"] = "foo"; | ||
| 22 | $b["asd"] = "zxc"; | ||
| 23 | $b['_GET]["obj->nop::qwe']["qwe"][1337] = (Object)(['uio' => "valeur de apres"]); | ||
| 24 | $b['_GET]["obj->nop::qwe']["qwe"][1338] = (Object)(['uio' => "valeur de a"]); | ||
| 25 | $c = (Object)(['qwe' => Array(\qwe\UNE_CONSTANTE => 'zxc')]); | ||
| 26 | $idk = 'test_asd'; | ||
| 27 | $class_name = 'test_object'; | ||
| 28 | class test_object { | ||
| 29 | const TEST_VALUE = ['constant' => 'truc']; | ||
| 30 | private $asd = "qwe"; | ||
| 31 | public $qwe = 'bar'; | ||
| 32 | private $test_asd = ''; | ||
| 33 | function __construct($asd) { | ||
| 34 | $this->test_asd = $asd; | ||
| 35 | } | ||
| 36 | function do_a_barell_roll() { | ||
| 37 | var_dump($this->test_asd); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | $d = new test_object($c); | ||
| 41 | $a = 1338; | ||
| 42 | function test(){ | ||
| 43 | strlen("qwe"); | ||
| 44 | } | ||
| 45 | echo "Valeur: " . $b['_GET]["obj->nop::qwe']["qwe"][$a]->uio . "\n"; | ||
| 46 | test(); | ||
| 47 | |||
| 48 | $a = 1337; | ||
| 49 | echo "Valeur: " . $b['_GET]["obj->nop::qwe']["qwe"][$a]->uio . "\n"; | ||
| 50 | test(); | ||
| 51 | } | ||
| 52 | ?> | ||
| 53 | --EXPECTF-- | ||
| 54 | Valeur: valeur de a | ||
| 55 | Valeur: valeur de apres | ||
| 56 | |||
| 57 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_4.php on line 36 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_5.phpt b/src/tests/disable_function/disabled_function_local_var_5.phpt new file mode 100644 index 0000000..602e96e --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_5.phpt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test(){ | ||
| 10 | echo strlen("id") . "\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a = Array(); | ||
| 14 | echo "Value of a:\n"; | ||
| 15 | var_dump($a); | ||
| 16 | test(); | ||
| 17 | |||
| 18 | $a = (Object)['zxc' => 'not a good value']; | ||
| 19 | echo "Value of a:\n"; | ||
| 20 | var_dump($a); | ||
| 21 | test(); | ||
| 22 | ?> | ||
| 23 | --EXPECTF-- | ||
| 24 | Value of a: | ||
| 25 | array(0) { | ||
| 26 | } | ||
| 27 | 2 | ||
| 28 | Value of a: | ||
| 29 | object(stdClass)#1 (1) { | ||
| 30 | ["zxc"]=> | ||
| 31 | string(16) "not a good value" | ||
| 32 | } | ||
| 33 | |||
| 34 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_5.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_6.phpt b/src/tests/disable_function/disabled_function_local_var_6.phpt new file mode 100644 index 0000000..1866353 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_6.phpt | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace asd { | ||
| 10 | function test(){ | ||
| 11 | strlen("qwe"); | ||
| 12 | } | ||
| 13 | echo "Valeur: " . \asd\test_object::TEST_VALUE['constant'] . "\n"; | ||
| 14 | test(); | ||
| 15 | class test_object { | ||
| 16 | const TEST_VALUE = ['constant' => 'no good']; | ||
| 17 | private $asd = "qwe"; | ||
| 18 | public $qwe = 'bar'; | ||
| 19 | private $test_asd = ''; | ||
| 20 | function __construct($asd) { | ||
| 21 | $this->test_asd = $asd; | ||
| 22 | } | ||
| 23 | function do_a_barell_roll() { | ||
| 24 | var_dump($this->test_asd); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | ?> | ||
| 29 | --EXPECTF-- | ||
| 30 | Valeur: no good | ||
| 31 | |||
| 32 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_6.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_7.phpt b/src/tests/disable_function/disabled_function_local_var_7.phpt new file mode 100644 index 0000000..e615a80 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_7.phpt | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace asd { | ||
| 10 | function test(){ | ||
| 11 | strlen("qwe"); | ||
| 12 | } | ||
| 13 | echo "Valeur: " . \asd\test_object::TEST_VALUE . "\n"; | ||
| 14 | test(); | ||
| 15 | class test_object { | ||
| 16 | const TEST_VALUE = "qwerty"; | ||
| 17 | private $asd = "qwe"; | ||
| 18 | public $qwe = 'bar'; | ||
| 19 | private $test_asd = ''; | ||
| 20 | function __construct($asd) { | ||
| 21 | $this->test_asd = $asd; | ||
| 22 | } | ||
| 23 | function do_a_barell_roll() { | ||
| 24 | var_dump($this->test_asd); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | ?> | ||
| 29 | --EXPECTF-- | ||
| 30 | Valeur: qwerty | ||
| 31 | |||
| 32 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_7.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_8.phpt b/src/tests/disable_function/disabled_function_local_var_8.phpt new file mode 100644 index 0000000..1f1a0dc --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_8.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace qwe { | ||
| 10 | const ASD = 'qwerty'; | ||
| 11 | } | ||
| 12 | namespace asd { | ||
| 13 | const asd = 'qwe'; | ||
| 14 | echo "Valeur: " . \qwe\ASD . "\n"; | ||
| 15 | strlen("qwe"); | ||
| 16 | } | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Valeur: qwerty | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_8.php on line 8 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_9.phpt b/src/tests/disable_function/disabled_function_local_var_9.phpt new file mode 100644 index 0000000..458d878 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_9.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace qwe { | ||
| 10 | const QWE = Array('123'=>'asdfgh'); | ||
| 11 | } | ||
| 12 | namespace asd { | ||
| 13 | const asd = 'qwe'; | ||
| 14 | echo "Valeur: " . \qwe\QWE[123]. "\n"; | ||
| 15 | strlen("qwe"); | ||
| 16 | } | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Valeur: asdfgh | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_9.php on line 8 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_const.phpt b/src/tests/disable_function/disabled_function_local_var_const.phpt new file mode 100644 index 0000000..8d9d58a --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_const.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a constant | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var_const.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $a = 1337; | ||
| 10 | define("MY_CONST", $a); | ||
| 11 | strlen("test"); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_const.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_local_var_crash.phpt b/src/tests/disable_function/disabled_function_local_var_crash.phpt new file mode 100644 index 0000000..8dec946 --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_crash.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test(){ | ||
| 10 | echo strlen("id") . "\n"; | ||
| 11 | } | ||
| 12 | ob_start(test()); | ||
| 13 | echo "test\n"; | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | 2 | ||
| 17 | test | ||
| 18 | |||
diff --git a/src/tests/disable_function/disabled_function_local_var_obj.phpt b/src/tests/disable_function/disabled_function_local_var_obj.phpt new file mode 100644 index 0000000..29d57cc --- /dev/null +++ b/src/tests/disable_function/disabled_function_local_var_obj.phpt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a local variable | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var_obj.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | class test_class { | ||
| 10 | public $qwe = 'value'; | ||
| 11 | function __construct($arg, $value) { | ||
| 12 | $this->$arg = $value; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | $test_array = ['qwe']; | ||
| 17 | $arg = 'qwe'; | ||
| 18 | $test = new test_class('qwe', 'qwe'); | ||
| 19 | echo strlen($test->$arg) . "\n"; | ||
| 20 | $test = new test_class('qwe', 'nop_object'); | ||
| 21 | echo strlen($test->$arg) . "\n"; | ||
| 22 | ?> | ||
| 23 | --EXPECTF-- | ||
| 24 | 3 | ||
| 25 | |||
| 26 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_local_var_obj.php on line 14 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_param.phpt b/src/tests/disable_function/disabled_function_param.phpt new file mode 100644 index 0000000..9b8b942 --- /dev/null +++ b/src/tests/disable_function/disabled_function_param.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a param | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_param.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function qweqwe($asd) { | ||
| 10 | echo "OK\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $asd = Array(2); | ||
| 14 | qweqwe(Array(1)); | ||
| 15 | qweqwe(Array(2)); | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | OK | ||
| 19 | |||
| 20 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'qweqwe', because its argument '$asd' content (2) matched a rule in %a/disabled_function_param.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_print.phpt b/src/tests/disable_function/disabled_function_print.phpt new file mode 100644 index 0000000..a8b10b4 --- /dev/null +++ b/src/tests/disable_function/disabled_function_print.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Echo hooking | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_print.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function test($a) { | ||
| 10 | print "$a"; | ||
| 11 | } | ||
| 12 | print "qwe"; | ||
| 13 | test("rty"); | ||
| 14 | test("oops"); | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | --EXPECTF-- | ||
| 18 | qwerty | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'echo' in %a/disabled_function_print.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_super_global_var.phpt b/src/tests/disable_function/disabled_function_super_global_var.phpt new file mode 100644 index 0000000..d97194a --- /dev/null +++ b/src/tests/disable_function/disabled_function_super_global_var.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a super global | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_super_global_var.ini | ||
| 7 | --GET-- | ||
| 8 | bla=test | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | function test(){ | ||
| 12 | echo strlen($_GET['bla']) . "\n"; | ||
| 13 | } | ||
| 14 | test(); | ||
| 15 | $_GET['bla'] = 'test2'; | ||
| 16 | test(); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | 4 | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_function_super_global_var.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions.phpt b/src/tests/disable_function/disabled_functions.phpt new file mode 100644 index 0000000..6e57dba --- /dev/null +++ b/src/tests/disable_function/disabled_functions.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | strcmp("1", "2"); | ||
| 10 | system("id"); | ||
| 11 | printf("printf in simulation mode\n"); | ||
| 12 | print("print in disabled mode\n"); | ||
| 13 | var_dump("this is a super test"); | ||
| 14 | echo strpos("pouet", "o"); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_callback_called_file_r.phpt b/src/tests/disable_function/disabled_functions_callback_called_file_r.phpt new file mode 100644 index 0000000..9c25f9d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_callback_called_file_r.phpt | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching on the filename_r where the callback function is called, and not defined | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_callback_called_file_r.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | |||
| 11 | @unlink("$dir/myfunc_callback.php"); | ||
| 12 | |||
| 13 | $mycode = <<< 'EOD' | ||
| 14 | <?php | ||
| 15 | |||
| 16 | function test_callback() { | ||
| 17 | return "Test_callback"; | ||
| 18 | } | ||
| 19 | |||
| 20 | function test(callable $toto) { | ||
| 21 | return $toto(); | ||
| 22 | } | ||
| 23 | ?> | ||
| 24 | EOD; | ||
| 25 | |||
| 26 | file_put_contents("$dir/myfunc_callback.php", $mycode); | ||
| 27 | |||
| 28 | include "$dir/myfunc_callback.php"; | ||
| 29 | |||
| 30 | echo test('test_callback'); | ||
| 31 | |||
| 32 | ?> | ||
| 33 | --CLEAN-- | ||
| 34 | <?php | ||
| 35 | $dir = __DIR__; | ||
| 36 | @unlink("$dir/myfunc_callback.php"); | ||
| 37 | ?> | ||
| 38 | --EXPECTF-- | ||
| 39 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'test_callback' in %a/myfunc_callback.php on line 4 | ||
diff --git a/src/tests/disable_function/disabled_functions_called_file_r.phpt b/src/tests/disable_function/disabled_functions_called_file_r.phpt new file mode 100644 index 0000000..b361dc8 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_called_file_r.phpt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching on the filename_r where the function is called, and not defined | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_called_file_r.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | |||
| 11 | @unlink("$dir/myfunc.php"); | ||
| 12 | |||
| 13 | $mycode = <<< EOD | ||
| 14 | <?php | ||
| 15 | function test() { | ||
| 16 | echo "TOTO"; | ||
| 17 | } | ||
| 18 | ?> | ||
| 19 | EOD; | ||
| 20 | |||
| 21 | file_put_contents("$dir/myfunc.php", $mycode); | ||
| 22 | |||
| 23 | include "$dir/myfunc.php"; | ||
| 24 | |||
| 25 | test(); | ||
| 26 | |||
| 27 | ?> | ||
| 28 | --CLEAN-- | ||
| 29 | <?php | ||
| 30 | $dir = __DIR__; | ||
| 31 | @unlink("$dir/myfunc.php"); | ||
| 32 | ?> | ||
| 33 | --EXPECTF-- | ||
| 34 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'test' in %a/myfunc.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_chain.phpt b/src/tests/disable_function/disabled_functions_chain.phpt new file mode 100644 index 0000000..5aee085 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chain.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching the calltrace | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | function outer() { | ||
| 11 | function inner() { | ||
| 12 | echo "I'm in the inner function!\n"; | ||
| 13 | } | ||
| 14 | echo "I'm in the outer function, before the call!\n"; | ||
| 15 | inner(); | ||
| 16 | echo "I'm in the outer function, after the call!\n"; | ||
| 17 | } | ||
| 18 | |||
| 19 | echo "I'm before the call to outer\n"; | ||
| 20 | outer(); | ||
| 21 | echo "I'm after the call to outer\n"; | ||
| 22 | ?> | ||
| 23 | --EXPECTF-- | ||
| 24 | I'm before the call to outer | ||
| 25 | I'm in the outer function, before the call! | ||
| 26 | |||
| 27 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'outer>inner' in %a/disabled_functions_chain.php on line 5 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_chain_call_user_func.phpt b/src/tests/disable_function/disabled_functions_chain_call_user_func.phpt new file mode 100644 index 0000000..90c1f32 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chain_call_user_func.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching the calltrace, with call_user_func involved | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_chain_call_user_func.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | function outer() { | ||
| 11 | function inner() { | ||
| 12 | echo "I'm in the inner function!\n"; | ||
| 13 | } | ||
| 14 | echo "I'm in the outer function, before the call!\n"; | ||
| 15 | call_user_func("inner"); | ||
| 16 | echo "I'm in the outer function, after the call!\n"; | ||
| 17 | } | ||
| 18 | |||
| 19 | echo "I'm before the call to outer\n"; | ||
| 20 | outer(); | ||
| 21 | echo "I'm after the call to outer\n"; | ||
| 22 | ?> | ||
| 23 | --EXPECTF-- | ||
| 24 | I'm before the call to outer | ||
| 25 | I'm in the outer function, before the call! | ||
| 26 | |||
| 27 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'outer>inner' in %a/disabled_functions_chain_call_user_func.php on line 5 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_chain_call_user_func_ret.phpt b/src/tests/disable_function/disabled_functions_chain_call_user_func_ret.phpt new file mode 100644 index 0000000..6a4cca6 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chain_call_user_func_ret.phpt | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching the calltrace, on the return value | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_chain_call_user_func_ret.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function two($a) { | ||
| 10 | echo "two\n"; | ||
| 11 | return $a . "_two"; | ||
| 12 | } | ||
| 13 | function one($a) { | ||
| 14 | echo "one\n"; | ||
| 15 | two($a); | ||
| 16 | return $a . "_one"; | ||
| 17 | } | ||
| 18 | |||
| 19 | echo one('not matching') . "\n"; | ||
| 20 | echo one('matching') . "\n"; | ||
| 21 | echo one('still not matching') . "\n"; | ||
| 22 | |||
| 23 | ?> | ||
| 24 | --EXPECTF-- | ||
| 25 | one | ||
| 26 | two | ||
| 27 | not matching_one | ||
| 28 | one | ||
| 29 | two | ||
| 30 | |||
| 31 | Warning: [snuffleupagus][disabled_function] Aborted execution on return of the function 'two', because the function returned 'matching_two', which matched a rule in %a/disabled_functions_chain_call_user_func_ret.php on line %d | ||
| 32 | matching_one | ||
| 33 | one | ||
| 34 | two | ||
| 35 | still not matching_one | ||
diff --git a/src/tests/disable_function/disabled_functions_chain_not_matching.phpt b/src/tests/disable_function/disabled_functions_chain_not_matching.phpt new file mode 100644 index 0000000..3a0400a --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chain_not_matching.phpt | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions by matching the calltrace | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | function outer() { | ||
| 11 | function inner_() { | ||
| 12 | echo "I'm in the inner function!\n"; | ||
| 13 | } | ||
| 14 | echo "I'm in the outer function, before the call!\n"; | ||
| 15 | inner_(); | ||
| 16 | echo "I'm in the outer function, after the call!\n"; | ||
| 17 | } | ||
| 18 | |||
| 19 | echo "I'm before the call to outer\n"; | ||
| 20 | outer(); | ||
| 21 | echo "I'm after the call to outer\n"; | ||
| 22 | ?> | ||
| 23 | --EXPECTF-- | ||
| 24 | I'm before the call to outer | ||
| 25 | I'm in the outer function, before the call! | ||
| 26 | I'm in the inner function! | ||
| 27 | I'm in the outer function, after the call! | ||
| 28 | I'm after the call to outer | ||
diff --git a/src/tests/disable_function/disabled_functions_cidr.phpt b/src/tests/disable_function/disabled_functions_cidr.phpt new file mode 100644 index 0000000..dcd4189 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_cidr.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --ENV-- | ||
| 6 | return <<<EOF | ||
| 7 | REMOTE_ADDR=127.0.0.1 | ||
| 8 | EOF; | ||
| 9 | --INI-- | ||
| 10 | sp.configuration_file={PWD}/config/disabled_functions_cidr.ini | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | system("echo 42"); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions_cidr.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_cidr_6.phpt b/src/tests/disable_function/disabled_functions_cidr_6.phpt new file mode 100644 index 0000000..17822cd --- /dev/null +++ b/src/tests/disable_function/disabled_functions_cidr_6.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --ENV-- | ||
| 6 | return <<<EOF | ||
| 7 | REMOTE_ADDR=2001:0db8:f000:f000:f000:ff00:0042:8328 | ||
| 8 | EOF; | ||
| 9 | --INI-- | ||
| 10 | sp.configuration_file={PWD}/config/disabled_functions_cidr.ini | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | strpos("a", "b"); | ||
| 14 | printf(1337); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strpos' in %a/disabled_functions_cidr_6.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_die.phpt b/src/tests/disable_function/disabled_functions_die.phpt new file mode 100644 index 0000000..bfabaee --- /dev/null +++ b/src/tests/disable_function/disabled_functions_die.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - die | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_die.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | die('OMG'); | ||
| 10 | ?> | ||
| 11 | --XFAIL-- | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'die' in %a/disabled_function_echo.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_drop_include.phpt b/src/tests/disable_function/disabled_functions_drop_include.phpt new file mode 100644 index 0000000..e18dd73 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_drop_include.phpt | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable function, bug : https://github.com/nbs-system/snuffleupagus/issues/181 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_drop_include.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | |||
| 11 | @unlink("$dir/test_include.php"); | ||
| 12 | |||
| 13 | $code = <<< 'EOD' | ||
| 14 | <?php | ||
| 15 | $test = "testOK"; | ||
| 16 | ?> | ||
| 17 | EOD; | ||
| 18 | |||
| 19 | file_put_contents("$dir/test_include.php", $code); | ||
| 20 | |||
| 21 | include "$dir/test_include.php"; | ||
| 22 | |||
| 23 | echo $test; | ||
| 24 | |||
| 25 | ?> | ||
| 26 | |||
| 27 | --EXPECTF-- | ||
| 28 | testOK | ||
diff --git a/src/tests/disable_function/disabled_functions_drop_include_simulation.phpt b/src/tests/disable_function/disabled_functions_drop_include_simulation.phpt new file mode 100644 index 0000000..07c3e98 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_drop_include_simulation.phpt | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable function, bug : https://github.com/nbs-system/snuffleupagus/issues/181 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_drop_include_simulation.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | |||
| 11 | @unlink("$dir/test_include.php"); | ||
| 12 | |||
| 13 | $code = <<< 'EOD' | ||
| 14 | <?php | ||
| 15 | $test = "testOK"; | ||
| 16 | ?> | ||
| 17 | EOD; | ||
| 18 | |||
| 19 | file_put_contents("$dir/test_include.php", $code); | ||
| 20 | |||
| 21 | include "$dir/test_include.php"; | ||
| 22 | |||
| 23 | echo $test; | ||
| 24 | |||
| 25 | ?> | ||
| 26 | |||
| 27 | --EXPECTF-- | ||
| 28 | testOK | ||
diff --git a/src/tests/disable_function/disabled_functions_eval.phpt b/src/tests/disable_function/disabled_functions_eval.phpt new file mode 100644 index 0000000..a5d1489 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_eval.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - eval | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_eval.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][disabled_function] Aborted execution on call of the function 'eval' in %a/disabled_functions_eval.php(3) : eval()'d code on line 1 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_eval_filename.phpt b/src/tests/disable_function/disabled_functions_eval_filename.phpt new file mode 100644 index 0000000..4491e9e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_eval_filename.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - eval | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_eval_filename.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][disabled_function] Aborted execution on call of the function 'eval' in %a/disabled_functions_eval_filename.php(3) : eval()'d code on line 1 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_eval_simulation.phpt b/src/tests/disable_function/disabled_functions_eval_simulation.phpt new file mode 100644 index 0000000..2df04a9 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_eval_simulation.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - eval (simulation) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_eval_simulation.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $var = 123456789; | ||
| 10 | eval('$var = 1337 + 1337;'); | ||
| 11 | print("Variable: $var\n"); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'eval' in %a/disabled_functions_eval_simulation.php(3) : eval()'d code on line 1 | ||
| 15 | Variable: 2674 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_eval_user.phpt b/src/tests/disable_function/disabled_functions_eval_user.phpt new file mode 100644 index 0000000..30ba1d5 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_eval_user.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - eval with a disabled user func | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_eval_user_func.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function my_func() { | ||
| 10 | echo "1337\n"; | ||
| 11 | return 10; | ||
| 12 | } | ||
| 13 | $a = 0; | ||
| 14 | eval('$a = my_func();'); | ||
| 15 | echo '$a = ' . $a . "\n"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'my_func' in %a/disabled_functions_eval_user.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_exit.phpt b/src/tests/disable_function/disabled_functions_exit.phpt new file mode 100644 index 0000000..b204fcd --- /dev/null +++ b/src/tests/disable_function/disabled_functions_exit.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - exit | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_exit.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | exit('OMG'); | ||
| 10 | ?> | ||
| 11 | --XFAIL-- | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'exit' in %a/disabled_function_echo.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_filename_r.phpt b/src/tests/disable_function/disabled_functions_filename_r.phpt new file mode 100644 index 0000000..0eb5f7d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_filename_r.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - filename regexp | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_filename_r.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo 42"); | ||
| 10 | shell_exec("echo 43"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | 42 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'shell_exec' in %a/disabled_functions_filename_r.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_include_once.phpt b/src/tests/disable_function/disabled_functions_include_once.phpt new file mode 100644 index 0000000..26b7ecc --- /dev/null +++ b/src/tests/disable_function/disabled_functions_include_once.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - include_once | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_include.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA\n"); | ||
| 11 | file_put_contents($dir . '/test.sim', "MEH\n"); | ||
| 12 | include_once $dir . '/test.bla'; | ||
| 13 | include_once $dir . '/test.sim'; | ||
| 14 | echo "1337\n"; | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | <?php | ||
| 18 | $dir = __DIR__; | ||
| 19 | unlink($dir . '/test.bla'); | ||
| 20 | unlink($dir . '/test.sim'); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | BLA | ||
| 24 | |||
| 25 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'include_once', because its argument 'inclusion path' content (%a/test.sim) matched a rule in %a/disabled_functions_include_once.php on line 6 | ||
| 26 | MEH | ||
| 27 | 1337 | ||
diff --git a/src/tests/disable_function/disabled_functions_include_simulation.phpt b/src/tests/disable_function/disabled_functions_include_simulation.phpt new file mode 100644 index 0000000..199e91a --- /dev/null +++ b/src/tests/disable_function/disabled_functions_include_simulation.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Include (simulation) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_include.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA\n"); | ||
| 11 | file_put_contents($dir . '/test.sim', "MEH\n"); | ||
| 12 | include $dir . '/test.bla'; | ||
| 13 | include $dir . '/test.sim'; | ||
| 14 | echo "1337\n"; | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | <?php | ||
| 18 | $dir = __DIR__; | ||
| 19 | unlink($dir . '/test.bla'); | ||
| 20 | unlink($dir . '/test.sim'); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | BLA | ||
| 24 | |||
| 25 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'include', because its argument 'inclusion path' content (%a/test.sim) matched a rule in %a/disabled_functions_include_simulation.php on line 6 | ||
| 26 | MEH | ||
| 27 | 1337 | ||
diff --git a/src/tests/disable_function/disabled_functions_local_var_array.phpt b/src/tests/disable_function/disabled_functions_local_var_array.phpt new file mode 100644 index 0000000..2c55a6e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_local_var_array.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_local_var_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo' in %a/disabled_functions_local_var_array.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_local_var_array_key.phpt b/src/tests/disable_function/disabled_functions_local_var_array_key.phpt new file mode 100644 index 0000000..777611b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_local_var_array_key.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_local_var_array_key.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("foo"=>Array("aaa"=>"ccc")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo' in %a/disabled_functions_local_var_array_key.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_local_var_array_not_array.phpt b/src/tests/disable_function/disabled_functions_local_var_array_not_array.phpt new file mode 100644 index 0000000..54e8719 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_local_var_array_not_array.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_local_var_array_not_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foobar($a) { | ||
| 10 | var_dump($a); | ||
| 11 | } | ||
| 12 | $a = ["lol"=>2, "test"=>1]; | ||
| 13 | foobar("test"); | ||
| 14 | |||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | string(4) "test" | ||
diff --git a/src/tests/disable_function/disabled_functions_mb.phpt b/src/tests/disable_function/disabled_functions_mb.phpt new file mode 100644 index 0000000..a2fd99e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_mb.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_mb.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strlen("id"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_functions_mb.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_method.phpt b/src/tests/disable_function/disabled_functions_method.phpt new file mode 100644 index 0000000..72e633e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_method.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_method.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | class AwesomeClass { | ||
| 10 | function method1($a) { | ||
| 11 | echo "method1:" . $a . "\n"; | ||
| 12 | } | ||
| 13 | function method2($a) { | ||
| 14 | echo "method2:" . $a . "\n"; | ||
| 15 | } | ||
| 16 | function method3($a) { | ||
| 17 | echo "method3:" . $a . "\n"; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | $c = new AwesomeClass(); | ||
| 22 | $c->method1("pif"); | ||
| 23 | $c->method2("paf"); | ||
| 24 | $c->method3("pouet"); | ||
| 25 | ?> | ||
| 26 | --EXPECTF-- | ||
| 27 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'AwesomeClass::method1' in %a/disabled_functions_method.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_name_r.phpt b/src/tests/disable_function/disabled_functions_name_r.phpt new file mode 100644 index 0000000..1ecee14 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_name_r.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_name_r.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo 42"); | ||
| 10 | system("echo 1337"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | 42 | ||
| 14 | 1337 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'system', because the function returned '1337', which matched a rule in %a/disabled_functions_name_r.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_name_regexp_type.phpt b/src/tests/disable_function/disabled_functions_name_regexp_type.phpt new file mode 100644 index 0000000..2ceadbf --- /dev/null +++ b/src/tests/disable_function/disabled_functions_name_regexp_type.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_name_regexp_type.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strcmp("pouet", "pouet") . "\n"; | ||
| 10 | echo strcmp(1, 2) . "\n"; | ||
| 11 | echo strcmp([1], "pouet") . "\n"; | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | 0 | ||
| 15 | -1 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strcmp', because its argument 'str1' content (?) matched a rule in %a/disabled_functions_name_regexp_type.php on line 4 \ 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 new file mode 100644 index 0000000..2d14d12 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_name_type.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_name_type.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strcmp("pouet", "pouet") . "\n"; | ||
| 10 | echo strcmp([1,23], "pouet") . "\n"; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] 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 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_namespace.phpt b/src/tests/disable_function/disabled_functions_namespace.phpt new file mode 100644 index 0000000..1acfce2 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_namespace.phpt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions in namespaces | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_namespace.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | namespace my_super_namespace { | ||
| 10 | function my_function() { | ||
| 11 | echo "Should not be printed\n"; | ||
| 12 | } | ||
| 13 | } | ||
| 14 | namespace my_second_namespace { | ||
| 15 | function my_function() { | ||
| 16 | echo "Second namespace\n"; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | namespace { | ||
| 20 | function my_function() { | ||
| 21 | echo "Anonymous namespace\n"; | ||
| 22 | } | ||
| 23 | \strcmp("1", "2"); | ||
| 24 | \my_super_namespace\my_function(); | ||
| 25 | \my_second_namespace\my_function(); | ||
| 26 | my_function(); | ||
| 27 | } | ||
| 28 | ?> | ||
| 29 | --EXPECTF-- | ||
| 30 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strcmp' in %a/disabled_functions_namespace.php on line 16 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_noconf.phpt b/src/tests/disable_function/disabled_functions_noconf.phpt new file mode 100644 index 0000000..cb13413 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_noconf.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/empty.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strpos("pouet", "o"); | ||
| 10 | ?> | ||
| 11 | --EXPECT-- | ||
| 12 | 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_nul_byte.phpt b/src/tests/disable_function/disabled_functions_nul_byte.phpt new file mode 100644 index 0000000..984541d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_nul_byte.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with nul byte | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_nul_byte.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("\0id"); | ||
| 10 | system("id"); | ||
| 11 | |||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system', because its argument '$command' content (0id) matched a rule in %a/disabled_functions_nul_byte.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param.phpt b/src/tests/disable_function/disabled_functions_param.phpt new file mode 100644 index 0000000..fb6dcbb --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("id"); | ||
| 10 | system("echo win"); | ||
| 11 | var_dump(array_sum([1,2,3,4,5])); | ||
| 12 | shell_exec("id"); | ||
| 13 | echo shell_exec("echo 42"); | ||
| 14 | strcmp("bla", "ble"); | ||
| 15 | strncmp("bla", "ble", 2); | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system', because its argument '$command' content (id) matched the rule '1' in %a/disabled_functions_param.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_alias.phpt b/src/tests/disable_function/disabled_functions_param_alias.phpt new file mode 100644 index 0000000..9c249d9 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_alias.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - alias | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_alias.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("id"); | ||
| 10 | shell_exec("id"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system', because of the the rule '1' in %a/disabled_functions_param_alias.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_allow.phpt b/src/tests/disable_function/disabled_functions_param_allow.phpt new file mode 100644 index 0000000..f570415 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_allow.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - allow | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_allow.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo win"); | ||
| 10 | system("id"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | win | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions_param_allow.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array.phpt b/src/tests/disable_function/disabled_functions_param_array.phpt new file mode 100644 index 0000000..37a02e0 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("a"=>"test1"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("a"=>"abcde"); | ||
| 16 | foo($a); | ||
| 17 | |||
| 18 | $a=Array("a"=>"abcd"); | ||
| 19 | foo($a); | ||
| 20 | ?> | ||
| 21 | --EXPECTF-- | ||
| 22 | test1 | ||
| 23 | abcde | ||
| 24 | |||
| 25 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (abcd) matched the rule '1' in %a/disabled_functions_param_array.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_deref.phpt b/src/tests/disable_function/disabled_functions_param_array_deref.phpt new file mode 100644 index 0000000..3305965 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_deref.phpt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a=Array("bla"=>"aaa", "a"=>"eee" ); | ||
| 14 | foo($a); | ||
| 15 | |||
| 16 | $a=Array("bla"=>"aaa", "a"=>"abcdef" ); | ||
| 17 | foo($a); | ||
| 18 | |||
| 19 | $a=Array("bla"=>"abcdef", "not_bla"=>"134"); | ||
| 20 | foo($a); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | eee | ||
| 24 | abcdef | ||
| 25 | |||
| 26 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (abcdef) matched the rule '2' in %a/disabled_functions_param_array_deref.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_no_value.phpt b/src/tests/disable_function/disabled_functions_param_array_no_value.phpt new file mode 100644 index 0000000..dfb67a2 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_no_value.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - matching on an array's variable only | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 14 | foo($a); | ||
| 15 | |||
| 16 | $a=Array("test"=>"aaa", "a"=>"fff" ); | ||
| 17 | foo($a); | ||
| 18 | |||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | cccc | ||
| 22 | |||
| 23 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (aaa) matched the rule '3' in %a/disabled_functions_param_array_no_value.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_r.phpt b/src/tests/disable_function/disabled_functions_param_array_r.phpt new file mode 100644 index 0000000..1773bbe --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_r.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array using regexp | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_r_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>"pof", "pof"=>"pif", "a"=>Array("qwe"=>"bbb"), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("a"=>"abcd", "pof"=>"pif", "bar"=>Array("qwe"=>"bbb"), "b"=>"cccc"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument 'arr' content (ARRAY) matched the rule '1' in %a/disabled_functions_param_array_r.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_r_keys.phpt b/src/tests/disable_function/disabled_functions_param_array_r_keys.phpt new file mode 100644 index 0000000..0748e92 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_r_keys.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array using regexp | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_r_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>"pof", "pof"=>"pif", "qwe"=>Array("qwe"=>"bbb"), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("a"=>"", "pof"=>"pif", "bar"=>Array("qwe"=>"bbb"), "qweabcqwe"=>"nop"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument 'arr' content (ARRAY) matched the rule '2' in %a/disabled_functions_param_array_r_keys.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_several_levels.phpt b/src/tests/disable_function/disabled_functions_param_array_several_levels.phpt new file mode 100644 index 0000000..cbe845b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_several_levels.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (ARRAY) matched the rule '4' in %a/disabled_functions_param_array_several_levels.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_several_levels_int.phpt b/src/tests/disable_function/disabled_functions_param_array_several_levels_int.phpt new file mode 100644 index 0000000..d957acf --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_several_levels_int.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("foo"=>Array("123"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (ARRAY) matched the rule '4' in %a/disabled_functions_param_array_several_levels_int.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_several_levels_keys.phpt b/src/tests/disable_function/disabled_functions_param_array_several_levels_keys.phpt new file mode 100644 index 0000000..59d27c0 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_several_levels_keys.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "bar"=>Array("qwe"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("bar"=>Array("lol"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (ARRAY) matched the rule '5' in %a/disabled_functions_param_array_several_levels_keys.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_array_several_levels_keys_int.phpt b/src/tests/disable_function/disabled_functions_param_array_several_levels_keys_int.phpt new file mode 100644 index 0000000..647c394 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_array_several_levels_keys_int.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "bar"=>Array("qwe"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("bar"=>Array("123"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo', because its argument '$arr' content (ARRAY) matched the rule '6' in %a/disabled_functions_param_array_several_levels_keys_int.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_broken_line.phpt b/src/tests/disable_function/disabled_functions_param_broken_line.phpt new file mode 100644 index 0000000..4fc3c45 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_broken_line.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a specific line - broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_broken_line.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo 1337"); | ||
| 10 | system("echo 1338"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | PHP Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][config] Invalid configuration file in Unknown on line 0 | ||
| 18 | Could not startup. | ||
diff --git a/src/tests/disable_function/disabled_functions_param_int.phpt b/src/tests/disable_function/disabled_functions_param_int.phpt new file mode 100644 index 0000000..e8b0a42 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_int.phpt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_int.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foobar($id) { | ||
| 10 | echo $id."\n"; | ||
| 11 | } | ||
| 12 | foobar(1); | ||
| 13 | foobar(42); | ||
| 14 | foobar(1337); | ||
| 15 | foobar(13374242); | ||
| 16 | foobar(0x2A); | ||
| 17 | foobar("10"); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | 1 | ||
| 21 | |||
| 22 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foobar', because its argument '$id' content (42) matched a rule in %a/disabled_functions_param_int.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt b/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt new file mode 100644 index 0000000..c52443d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on argument's position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_invalid_pos.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo 1"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | PHP Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][config] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/disable_function/disabled_functions_param_line.phpt b/src/tests/disable_function/disabled_functions_param_line.phpt new file mode 100644 index 0000000..75bfedd --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_line.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on a specific line | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_line.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo 1337"); | ||
| 10 | system("id"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | 1337 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions_param_line.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_pos.phpt b/src/tests/disable_function/disabled_functions_param_pos.phpt new file mode 100644 index 0000000..348d34b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_pos.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on argument's position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_pos.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("id"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Warning: [snuffleupagus][config] 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 | |||
| 14 | Fatal error: [snuffleupagus][disabled_function] 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_param_pos2.phpt b/src/tests/disable_function/disabled_functions_param_pos2.phpt new file mode 100644 index 0000000..87e18c0 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_pos2.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on argument's position, not the first time | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_pos.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | strlen("od"); | ||
| 10 | strlen("id"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen', because its argument 'str' content (id) matched the rule 'strlen array' in %a/disabled_functions_param_pos2.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_r.phpt b/src/tests/disable_function/disabled_functions_param_r.phpt new file mode 100644 index 0000000..722f126 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_r.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_r.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("id"); | ||
| 10 | system("echo win"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system', because its argument 'command' content (id) matched a rule in %a/disabled_functions_param_r.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_param_str_representation.phpt b/src/tests/disable_function/disabled_functions_param_str_representation.phpt new file mode 100644 index 0000000..7cbdc0f --- /dev/null +++ b/src/tests/disable_function/disabled_functions_param_str_representation.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - casting various types to string internally | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_str_representation.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo var_export(true) . "\n"; | ||
| 10 | echo var_export(false) . "\n"; | ||
| 11 | echo var_export(null) . "\n"; | ||
| 12 | echo var_export(1) . "\n"; | ||
| 13 | echo var_export(1.0) . "\n"; | ||
| 14 | function f(&$a) { | ||
| 15 | echo var_export($a) . "\n"; | ||
| 16 | } | ||
| 17 | $a = 123; f($a); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | true | ||
| 21 | false | ||
| 22 | NULL | ||
| 23 | 1 | ||
| 24 | 1.0 | ||
| 25 | 123 | ||
diff --git a/src/tests/disable_function/disabled_functions_parse_class.phpt b/src/tests/disable_function/disabled_functions_parse_class.phpt new file mode 100644 index 0000000..af9ed88 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_parse_class.phpt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Parsing of an Object as a return value of a function | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | /* | ||
| 10 | Because Snuffleupagus used to cast everything with the `zval_get_string` function, | ||
| 11 | this sometimes raised exceptions, because PHP is awful. | ||
| 12 | */ | ||
| 13 | class Bob { | ||
| 14 | function a() { | ||
| 15 | return new StdClass; | ||
| 16 | } | ||
| 17 | } | ||
| 18 | $b = new Bob; | ||
| 19 | echo ($b->a() instanceof StdClass)?'Y':'N'; | ||
| 20 | ?> | ||
| 21 | --EXPECT-- | ||
| 22 | Y | ||
diff --git a/src/tests/disable_function/disabled_functions_pos_type.phpt b/src/tests/disable_function/disabled_functions_pos_type.phpt new file mode 100644 index 0000000..30aef8f --- /dev/null +++ b/src/tests/disable_function/disabled_functions_pos_type.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - match on argument's position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_pos.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system([123, 456]); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Warning: [snuffleupagus][config] 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 | |||
| 14 | Warning: [snuffleupagus][config] 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 | |||
| 16 | Fatal error: [snuffleupagus][disabled_function] 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 | ||
diff --git a/src/tests/disable_function/disabled_functions_regexp_multiple.phpt b/src/tests/disable_function/disabled_functions_regexp_multiple.phpt new file mode 100644 index 0000000..79f1fc7 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_regexp_multiple.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_regexp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strlen("id") . "\n"; | ||
| 10 | echo strcmp("1", "2") . "\n"; | ||
| 11 | print("After") . "\n"; | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_functions_regexp_multiple.php on line 2 | ||
| 15 | 2 | ||
| 16 | |||
| 17 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strcmp' in %a/disabled_functions_regexp_multiple.php on line 3 | ||
| 18 | -1 | ||
| 19 | After \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_register_shutdown_function.phpt b/src/tests/disable_function/disabled_functions_register_shutdown_function.phpt new file mode 100644 index 0000000..b6f1a10 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_register_shutdown_function.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Called with register_shutdown_function | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_user_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function my_super_function() { | ||
| 10 | echo 'lose'; | ||
| 11 | } | ||
| 12 | echo "1337\n"; | ||
| 13 | register_shutdown_function('my_super_function'); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | 1337 | ||
| 17 | |||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'my_super_function' in %a/disabled_functions_register_shutdown_function.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_register_tick_function.phpt b/src/tests/disable_function/disabled_functions_register_tick_function.phpt new file mode 100644 index 0000000..6e3fb6f --- /dev/null +++ b/src/tests/disable_function/disabled_functions_register_tick_function.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Called with register_tick_function | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_user_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | declare(ticks=1); | ||
| 10 | function my_super_function() { | ||
| 11 | echo 'lose'; | ||
| 12 | } | ||
| 13 | echo "1337\n"; | ||
| 14 | register_tick_function('my_super_function'); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | 1337 | ||
| 18 | |||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'my_super_function' in %a/disabled_functions_register_tick_function.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_require.phpt b/src/tests/disable_function/disabled_functions_require.phpt new file mode 100644 index 0000000..77dfbf5 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_require.phpt | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Require | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_require.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA"); | ||
| 11 | file_put_contents($dir . '/test.meh', "MEH"); | ||
| 12 | require $dir . '/test.bla'; | ||
| 13 | require $dir . '/test.meh'; | ||
| 14 | echo "1337"; | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | <?php | ||
| 18 | $dir = __DIR__; | ||
| 19 | unlink($dir . '/test.bla'); | ||
| 20 | unlink($dir . '/test.meh'); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | BLA | ||
| 24 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'require', because its argument 'inclusion path' content (%a/test.meh) matched a rule in %a/disabled_functions_require.php on line 6 | ||
diff --git a/src/tests/disable_function/disabled_functions_require_allow.phpt b/src/tests/disable_function/disabled_functions_require_allow.phpt new file mode 100644 index 0000000..1e3bc56 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_require_allow.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Require (allow) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_require_allow.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA\n"); | ||
| 11 | file_put_contents($dir . '/test.meh', "MEH\n"); | ||
| 12 | require $dir . '/test.bla'; | ||
| 13 | require $dir . '/test.meh'; | ||
| 14 | echo "1337"; | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | BLA | ||
| 18 | MEH | ||
| 19 | 1337 | ||
| 20 | --CLEAN-- | ||
| 21 | <?php | ||
| 22 | $dir = __DIR__; | ||
| 23 | unlink($dir . '/test.bla'); | ||
| 24 | unlink($dir . '/test.meh'); | ||
| 25 | ?> | ||
diff --git a/src/tests/disable_function/disabled_functions_require_once.phpt b/src/tests/disable_function/disabled_functions_require_once.phpt new file mode 100644 index 0000000..84e93cd --- /dev/null +++ b/src/tests/disable_function/disabled_functions_require_once.phpt | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - require_once | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_require.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA"); | ||
| 11 | file_put_contents($dir . '/test.meh', "MEH"); | ||
| 12 | require_once $dir . '/test.bla'; | ||
| 13 | require_once $dir . '/test.meh'; | ||
| 14 | echo "1337"; | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | <?php | ||
| 18 | $dir = __DIR__; | ||
| 19 | unlink($dir . '/test.bla'); | ||
| 20 | unlink($dir . '/test.meh'); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | BLA | ||
| 24 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'require_once', because its argument 'inclusion path' content (%a/test.meh) matched a rule in %a/disabled_functions_require_once.php on line 6 | ||
diff --git a/src/tests/disable_function/disabled_functions_require_simulation.phpt b/src/tests/disable_function/disabled_functions_require_simulation.phpt new file mode 100644 index 0000000..6c97480 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_require_simulation.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Require (simulation) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_require.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $dir = __DIR__; | ||
| 10 | file_put_contents($dir . '/test.bla', "BLA\n"); | ||
| 11 | file_put_contents($dir . '/test.sim', "MEH\n"); | ||
| 12 | require $dir . '/test.bla'; | ||
| 13 | require $dir . '/test.sim'; | ||
| 14 | echo "1337\n"; | ||
| 15 | ?> | ||
| 16 | --CLEAN-- | ||
| 17 | <?php | ||
| 18 | $dir = __DIR__; | ||
| 19 | unlink($dir . '/test.bla'); | ||
| 20 | unlink($dir . '/test.sim'); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | BLA | ||
| 24 | |||
| 25 | Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'require', because its argument 'inclusion path' content (%a/test.sim) matched a rule in %a/disabled_functions_require_simulation.php on line 6 | ||
| 26 | MEH | ||
| 27 | 1337 | ||
diff --git a/src/tests/disable_function/disabled_functions_ret.phpt b/src/tests/disable_function/disabled_functions_ret.phpt new file mode 100644 index 0000000..7c5d596 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret`. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strpos("pouet", "p"); | ||
| 10 | echo stripos("pouet", "p"); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'strpos', because the function returned '0', which matched a rule in %a/disabled_functions_ret.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret2.phpt b/src/tests/disable_function/disabled_functions_ret2.phpt new file mode 100644 index 0000000..e32c585 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret2.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret`. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo stripos("pouet", "p"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'stripos', because the function returned '0', which matched a rule in %a/disabled_functions_ret2.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret3.phpt b/src/tests/disable_function/disabled_functions_ret3.phpt new file mode 100644 index 0000000..dc60c43 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret3.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret`. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret.ini | ||
| 7 | memory_limit=-1 | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | class Bob { | ||
| 11 | function a() { | ||
| 12 | echo("We're in function `a`.\n"); | ||
| 13 | return 2; | ||
| 14 | } | ||
| 15 | } | ||
| 16 | $b = new Bob(); | ||
| 17 | echo "`a` returned: " . $b->a() . ".\n"; | ||
| 18 | echo("We're at the end of the execution.\n"); | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | We're in function `a`. | ||
| 22 | |||
| 23 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'Bob::a', because the function returned '2', which matched a rule in %a/disabled_functions_ret3.php on line 9 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_allow.phpt b/src/tests/disable_function/disabled_functions_ret_allow.phpt new file mode 100644 index 0000000..1690995 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_allow.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret`. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_allow.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strpos("pouet", "p"); | ||
| 10 | echo stripos("pouet", "p"); | ||
| 11 | ?> | ||
| 12 | --EXPECT-- | ||
| 13 | 00 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_allow_value.phpt b/src/tests/disable_function/disabled_functions_ret_allow_value.phpt new file mode 100644 index 0000000..881a006 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_allow_value.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` allowed | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_allow_value.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strpos("pouet", "p"); | ||
| 10 | ?> | ||
| 11 | --EXPECT-- | ||
| 12 | 0 | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_right_hash.phpt b/src/tests/disable_function/disabled_functions_ret_right_hash.phpt new file mode 100644 index 0000000..1307172 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_right_hash.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_right_hash.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo $((1 + 1336))"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | 1337 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'system', because the function returned '1337', which matched a rule in %a/disabled_functions_ret_right_hash.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_simulation.phpt b/src/tests/disable_function/disabled_functions_ret_simulation.phpt new file mode 100644 index 0000000..bd4cea0 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_simulation.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` simulation | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_simulation.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strpos("pouet", "p") . "\n"; | ||
| 10 | echo stripos("pouet", "p") . "\n"; | ||
| 11 | strcmp("p", "p") . "\n"; | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Warning: [snuffleupagus][disabled_function] Aborted execution on return of the function 'strpos', because the function returned '0', which matched a rule in %a/disabled_functions_ret_simulation.php on line 2 | ||
| 15 | 0 | ||
| 16 | |||
| 17 | Warning: [snuffleupagus][disabled_function] Aborted execution on return of the function 'stripos', because the function returned '0', which matched the rule '1' in %a/disabled_functions_ret_simulation.php on line 3 | ||
| 18 | 0 | ||
| 19 | |||
| 20 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'strcmp', because the function returned '0', which matched a rule in %a/disabled_functions_ret_simulation.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type.phpt b/src/tests/disable_function/disabled_functions_ret_type.phpt new file mode 100644 index 0000000..88401ca --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (false) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(strpos("pouet", "p")) . "\n"; | ||
| 10 | echo "1337\n"; | ||
| 11 | echo strpos("pouet", "123"); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | int(0) | ||
| 15 | 1337 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'strpos', because the function returned 'FALSE', which matched the rule 'Return value is FALSE' in %a/disabled_functions_ret_type.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_array.phpt b/src/tests/disable_function/disabled_functions_ret_type_array.phpt new file mode 100644 index 0000000..3ceac9e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_array.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (array). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo get_loaded_extensions(); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'get_loaded_extensions', because the function returned 'ARRAY', which matched the rule 'Return value is an array' in %a/disabled_functions_ret_type_array.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_double.phpt b/src/tests/disable_function/disabled_functions_ret_type_double.phpt new file mode 100644 index 0000000..b0e895c --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_double.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (double). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_double.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo cos(0.5) . "\n"; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'cos', because the function returned '0.877583', which matched the rule 'Return value is a double' in %a/disabled_functions_ret_type_double.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_long.phpt b/src/tests/disable_function/disabled_functions_ret_type_long.phpt new file mode 100644 index 0000000..c389533 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_long.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (long). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_long.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo strlen("pouet") . "\n"; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'strlen', because the function returned '5', which matched the rule 'Return value is a long' in %a/disabled_functions_ret_type_long.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_null.phpt b/src/tests/disable_function/disabled_functions_ret_type_null.phpt new file mode 100644 index 0000000..894b3f5 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_null.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (null). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_null.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function my_function() { | ||
| 10 | return NULL; | ||
| 11 | } | ||
| 12 | |||
| 13 | var_dump(my_function()); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'my_function', because the function returned 'NULL', which matched the rule 'Return value is null' in %a/disabled_functions_ret_type_null.php on line 6 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_object.phpt b/src/tests/disable_function/disabled_functions_ret_type_object.phpt new file mode 100644 index 0000000..171cd4b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_object.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (object). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_object.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function a(){ | ||
| 10 | return new StdClass(); | ||
| 11 | } | ||
| 12 | $var = a(); | ||
| 13 | echo "fail"; | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'a', because the function returned 'OBJECT', which matched a rule in %a/disabled_functions_ret_type_object.php on line 5 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_resource.phpt b/src/tests/disable_function/disabled_functions_ret_type_resource.phpt new file mode 100644 index 0000000..4ae38b6 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_resource.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (resource). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_resource.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo fopen("/etc/passwd", "r"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'fopen', because the function returned 'RESOURCE', which matched the rule 'Return value is a resource' in %a/disabled_functions_ret_type_resource.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_str.phpt b/src/tests/disable_function/disabled_functions_ret_type_str.phpt new file mode 100644 index 0000000..356ff43 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_str.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (string). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_str.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo substr("pouet", 3) . "\n"; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'substr', because the function returned 'et', which matched the rule 'Return value is a string' in %a/disabled_functions_ret_type_str.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_type_true.phpt b/src/tests/disable_function/disabled_functions_ret_type_true.phpt new file mode 100644 index 0000000..8ddb1f7 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_type_true.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions check on `ret` by type matching (true). | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_ret_type_true.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(is_numeric("pouet")) . "\n"; | ||
| 10 | echo "1337\n"; | ||
| 11 | echo is_numeric("1234") . "\n"; | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | bool(false) | ||
| 15 | 1337 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'is_numeric', because the function returned 'TRUE', which matched the rule 'Return value is a true' in %a/disabled_functions_ret_type_true.php on line 4 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_user.phpt b/src/tests/disable_function/disabled_functions_ret_user.phpt new file mode 100644 index 0000000..8caa9bd --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_user.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Check NULL return value for user func | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_user.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function qwe() { | ||
| 10 | return "asd"; | ||
| 11 | } | ||
| 12 | qwe(); | ||
| 13 | echo 1; | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'qwe', because the function returned 'asd', which matched a rule in %a/disabled_functions_ret_user.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_user_used.phpt b/src/tests/disable_function/disabled_functions_ret_user_used.phpt new file mode 100644 index 0000000..5857905 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_user_used.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Check return value for user func | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_ret_user.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function qwe() { | ||
| 10 | return "asd"; | ||
| 11 | } | ||
| 12 | echo qwe(); | ||
| 13 | ?> | ||
| 14 | --EXPECTF-- | ||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'qwe', because the function returned 'asd', which matched a rule in %a/disabled_functions_ret_user_used.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_val.phpt b/src/tests/disable_function/disabled_functions_ret_val.phpt new file mode 100644 index 0000000..40a3be9 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_val.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions ret val | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_retval.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo str_repeat("fufu",1)."\n"; | ||
| 10 | echo str_repeat("fufufu",1); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | fufu | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'str_repeat', because the function returned 'fufufu', which matched a rule in %a/disabled_functions_ret_val.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_val_dump.phpt b/src/tests/disable_function/disabled_functions_ret_val_dump.phpt new file mode 100644 index 0000000..51e4f29 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_val_dump.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions ret val - dump | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_retval_dump.ini | ||
| 7 | --ENV-- | ||
| 8 | DOCUMENT_ROOT=a | ||
| 9 | --POST-- | ||
| 10 | post_a=data_post_a&post_b=data_post_b | ||
| 11 | --GET-- | ||
| 12 | get_a=data_get_a&get_b=data_get_b | ||
| 13 | --COOKIE-- | ||
| 14 | cookie_a=data_cookie_a&cookie_b=data_cookie_b | ||
| 15 | --FILE-- | ||
| 16 | <?php | ||
| 17 | echo str_repeat("fufu",1)."\n"; | ||
| 18 | echo str_repeat("fufufu",1); | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | fufu | ||
| 22 | |||
| 23 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'str_repeat', because the function returned 'fufufu', which matched a rule in %a/disabled_functions_ret_val_dump.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_ret_val_rx.phpt b/src/tests/disable_function/disabled_functions_ret_val_rx.phpt new file mode 100644 index 0000000..ba06649 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_ret_val_rx.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions ret val rx | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_retval_rx.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo str_repeat("fufu",1)."\n"; | ||
| 10 | echo str_repeat("fufufu",1); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | fufu | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on return of the function 'str_repeat', because the function returned 'fufufu', which matched a rule in %a/disabled_functions_ret_val_rx.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_right_hash.phpt b/src/tests/disable_function/disabled_functions_right_hash.phpt new file mode 100644 index 0000000..f3c5fb3 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_right_hash.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_right_hash.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | system("echo $((1 + 1336))"); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | 1337 | ||
diff --git a/src/tests/disable_function/disabled_functions_runtime.phpt b/src/tests/disable_function/disabled_functions_runtime.phpt new file mode 100644 index 0000000..4ba1a53 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_runtime.phpt | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - runtime inclusion | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_runtime.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | $dir = __DIR__; | ||
| 11 | $content = '<?php function test($param) { echo $param . "\n"; }'; | ||
| 12 | file_put_contents('file_to_include1.php', $content); | ||
| 13 | file_put_contents('file_to_include2.php', $content); | ||
| 14 | |||
| 15 | if (rand() % 2) { | ||
| 16 | include "file_to_include1.php"; | ||
| 17 | } else { | ||
| 18 | include "file_to_include2.php"; | ||
| 19 | } | ||
| 20 | |||
| 21 | test('1338');test('1337'); | ||
| 22 | |||
| 23 | ?> | ||
| 24 | --CLEAN-- | ||
| 25 | <?php | ||
| 26 | unlink("file_to_include1.php"); | ||
| 27 | unlink("file_to_include2.php"); | ||
| 28 | ?> | ||
| 29 | --EXPECTF-- | ||
| 30 | 1338 | ||
| 31 | |||
| 32 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'test', because its argument '$param' content (1337) matched a rule in %a/src/file_to_include%d.php on line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_upper.phpt b/src/tests/disable_function/disabled_functions_upper.phpt new file mode 100644 index 0000000..8fa8ea3 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_upper.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - uppercase | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | sYSTEm("id"); | ||
| 10 | pRINTf("printf in simulation mode\n"); | ||
| 11 | pRINT("print in disabled mode\n"); | ||
| 12 | vaR_DUmp("this is a super test"); | ||
| 13 | echo sTRPOs("pouet", "o"); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions_upper.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_variadic.phpt b/src/tests/disable_function/disabled_functions_variadic.phpt new file mode 100644 index 0000000..95d308e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_variadic.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - support for variadic functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_variadic.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo(...$b) { | ||
| 10 | return count($b); | ||
| 11 | } | ||
| 12 | |||
| 13 | echo foo(5, 4, 3, 2, 1); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Warning: [snuffleupagus][disable_function] Snuffleupagus doesn't support variadic functions yet, sorry. Check https://github.com/nbs-system/snuffleupagus/issues/164 for details. in %a/disabled_functions_variadic.php on line %d | ||
| 17 | |||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'foo' in %a/disabled_functions_variadic.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_zero_cidr.phpt b/src/tests/disable_function/disabled_functions_zero_cidr.phpt new file mode 100644 index 0000000..4e5f930 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_zero_cidr.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --ENV-- | ||
| 6 | return <<<EOF | ||
| 7 | REMOTE_ADDR=127.0.0.1 | ||
| 8 | EOF; | ||
| 9 | --INI-- | ||
| 10 | sp.configuration_file={PWD}/config/disabled_functions_zero_cidr.ini | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | system("echo 42"); | ||
| 14 | printf("1337"); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions_zero_cidr.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_native_functions_indirect.phpt b/src/tests/disable_function/disabled_native_functions_indirect.phpt new file mode 100644 index 0000000..ba355d6 --- /dev/null +++ b/src/tests/disable_function/disabled_native_functions_indirect.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disabled native functions, called indirectly | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | array_map('system', [1,2,3,4]); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_native_functions_indirect.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_user_functions.phpt b/src/tests/disable_function/disabled_user_functions.phpt new file mode 100644 index 0000000..9c17b79 --- /dev/null +++ b/src/tests/disable_function/disabled_user_functions.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disabled user-created functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_user_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function my_super_function() { | ||
| 10 | echo 1; | ||
| 11 | } | ||
| 12 | my_super_function(); | ||
| 13 | ?> | ||
| 14 | --EXPECTF-- | ||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'my_super_function' in %a/disabled_user_functions.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_user_functions_indirect.phpt b/src/tests/disable_function/disabled_user_functions_indirect.phpt new file mode 100644 index 0000000..f663ded --- /dev/null +++ b/src/tests/disable_function/disabled_user_functions_indirect.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disabled user-created functions, called indirectly | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_user_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function my_super_function() { | ||
| 10 | echo 1; | ||
| 11 | } | ||
| 12 | array_map('my_super_function', [1,2,3,4]); | ||
| 13 | ?> | ||
| 14 | --EXPECTF-- | ||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'my_super_function' in %a/disabled_user_functions_indirect.php on line 3 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/noncore_function_hooking.phpt b/src/tests/disable_function/noncore_function_hooking.phpt new file mode 100644 index 0000000..52bb114 --- /dev/null +++ b/src/tests/disable_function/noncore_function_hooking.phpt | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | --TEST-- | ||
| 2 | Hooking of user-defined functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_noncore_function_hooking.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function custom_fun($a) { | ||
| 10 | echo $a; | ||
| 11 | } | ||
| 12 | custom_fun("hello"); | ||
| 13 | ?> | ||
| 14 | --EXPECTF-- | ||
| 15 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'custom_fun' in %a/noncore_function_hooking.php on line 3 \ No newline at end of file | ||
