summaryrefslogtreecommitdiff
path: root/src/tests/disable_function
diff options
context:
space:
mode:
authorjvoisin2019-01-14 19:29:25 +0000
committerGitHub2019-01-14 19:29:25 +0000
commite79f7e3bd992c7f0915ef9afe7afb6d79740527a (patch)
treef881c25694eb00da2331a9ab280ec1c24a5662ab /src/tests/disable_function
parentc943db586ac46b686b49bdf61d8473e39dd93000 (diff)
Reorganize the testsuite
Splitting the testsuite in several components makes it easier to manage and comprehend. This was also needed some some tests aren't passing on Alpine Linux, but we still want to run as many of them as we can on this platform.
Diffstat (limited to 'src/tests/disable_function')
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_callback_called_file_r.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_called_file_r.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_chain.ini3
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_chain_call_user_func.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_chain_call_user_func_ret.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_eval_filename.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_eval_user_func.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_filename_r.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_include.ini5
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_local_var_array.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_local_var_array_key.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_method.ini3
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_name_r.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_name_regexp_type.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_name_type.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_namespace.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_nul_byte.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param.ini6
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_alias.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_allow.ini3
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_array.ini7
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_int.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_r.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_r_array.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_runtime.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_param_str_representation.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_require.ini5
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_require_allow.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_ret_allow.ini2
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_ret_allow_value.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_ret_right_hash.ini4
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_ret_simulation.ini3
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_ret_user.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_right_hash.ini3
-rw-r--r--src/tests/disable_function/config/config_disabled_functions_variadic.ini1
-rw-r--r--src/tests/disable_function/config/config_disabled_user_functions.ini1
-rw-r--r--src/tests/disable_function/config/config_noncore_function_hooking.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_curl_verify_certs.ini18
-rw-r--r--src/tests/disable_function/config/disabled_function_echo.ini2
-rw-r--r--src/tests/disable_function/config/disabled_function_local_var.ini10
-rw-r--r--src/tests/disable_function/config/disabled_function_local_var_2.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_local_var_array_not_array.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_local_var_const.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_local_var_obj.ini3
-rw-r--r--src/tests/disable_function/config/disabled_function_param.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_print.ini1
-rw-r--r--src/tests/disable_function/config/disabled_function_super_global_var.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions.ini9
-rw-r--r--src/tests/disable_function/config/disabled_functions_broken_line.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_cidr.ini9
-rw-r--r--src/tests/disable_function/config/disabled_functions_die.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_drop_include.ini4
-rw-r--r--src/tests/disable_function/config/disabled_functions_drop_include_simulation.ini4
-rw-r--r--src/tests/disable_function/config/disabled_functions_eval.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_eval_simulation.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_exit.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_invalid_pos.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_line.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_mb.ini2
-rw-r--r--src/tests/disable_function/config/disabled_functions_pos.ini4
-rw-r--r--src/tests/disable_function/config/disabled_functions_regexp.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret.ini6
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_array.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_double.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_long.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_null.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_object.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_resource.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_str.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_ret_type_true.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_retval.ini2
-rw-r--r--src/tests/disable_function/config/disabled_functions_retval_dump.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_retval_rx.ini1
-rw-r--r--src/tests/disable_function/config/disabled_functions_zero_cidr.ini1
-rw-r--r--src/tests/disable_function/config/empty.ini0
-rw-r--r--src/tests/disable_function/disabled_function_echo.phpt19
-rw-r--r--src/tests/disable_function/disabled_function_echo_2.phpt15
-rw-r--r--src/tests/disable_function/disabled_function_echo_local_var.phpt21
-rw-r--r--src/tests/disable_function/disabled_function_ensure_client_valid_certs.phpt18
-rw-r--r--src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt17
-rw-r--r--src/tests/disable_function/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt19
-rw-r--r--src/tests/disable_function/disabled_function_ensure_server_valid_certs.phpt18
-rw-r--r--src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt17
-rw-r--r--src/tests/disable_function/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt19
-rw-r--r--src/tests/disable_function/disabled_function_local_var.phpt25
-rw-r--r--src/tests/disable_function/disabled_function_local_var_10.phpt45
-rw-r--r--src/tests/disable_function/disabled_function_local_var_2.phpt47
-rw-r--r--src/tests/disable_function/disabled_function_local_var_3.phpt46
-rw-r--r--src/tests/disable_function/disabled_function_local_var_4.phpt57
-rw-r--r--src/tests/disable_function/disabled_function_local_var_5.phpt34
-rw-r--r--src/tests/disable_function/disabled_function_local_var_6.phpt32
-rw-r--r--src/tests/disable_function/disabled_function_local_var_7.phpt32
-rw-r--r--src/tests/disable_function/disabled_function_local_var_8.phpt21
-rw-r--r--src/tests/disable_function/disabled_function_local_var_9.phpt21
-rw-r--r--src/tests/disable_function/disabled_function_local_var_const.phpt14
-rw-r--r--src/tests/disable_function/disabled_function_local_var_crash.phpt18
-rw-r--r--src/tests/disable_function/disabled_function_local_var_obj.phpt26
-rw-r--r--src/tests/disable_function/disabled_function_param.phpt20
-rw-r--r--src/tests/disable_function/disabled_function_print.phpt19
-rw-r--r--src/tests/disable_function/disabled_function_super_global_var.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_callback_called_file_r.phpt39
-rw-r--r--src/tests/disable_function/disabled_functions_called_file_r.phpt34
-rw-r--r--src/tests/disable_function/disabled_functions_chain.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_chain_call_user_func.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_chain_call_user_func_ret.phpt35
-rw-r--r--src/tests/disable_function/disabled_functions_chain_not_matching.phpt28
-rw-r--r--src/tests/disable_function/disabled_functions_cidr.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_cidr_6.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_die.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_drop_include.phpt28
-rw-r--r--src/tests/disable_function/disabled_functions_drop_include_simulation.phpt28
-rw-r--r--src/tests/disable_function/disabled_functions_eval.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_eval_filename.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_eval_simulation.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_eval_user.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_exit.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_filename_r.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_include_once.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_include_simulation.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_local_var_array.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_local_var_array_key.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_local_var_array_not_array.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_mb.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_method.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_name_r.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_name_regexp_type.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_name_type.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_namespace.phpt30
-rw-r--r--src/tests/disable_function/disabled_functions_noconf.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_nul_byte.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_param.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_param_alias.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_param_allow.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_param_array.phpt25
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_deref.phpt26
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_no_value.phpt23
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_r.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_r_keys.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_several_levels.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_several_levels_int.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_several_levels_keys.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_array_several_levels_keys_int.phpt21
-rw-r--r--src/tests/disable_function/disabled_functions_param_broken_line.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_param_int.phpt22
-rw-r--r--src/tests/disable_function/disabled_functions_param_invalid_pos.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_param_line.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_param_pos.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_param_pos2.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_param_r.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_param_str_representation.phpt25
-rw-r--r--src/tests/disable_function/disabled_functions_parse_class.phpt22
-rw-r--r--src/tests/disable_function/disabled_functions_pos_type.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_regexp_multiple.phpt19
-rw-r--r--src/tests/disable_function/disabled_functions_register_shutdown_function.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_register_tick_function.phpt19
-rw-r--r--src/tests/disable_function/disabled_functions_require.phpt24
-rw-r--r--src/tests/disable_function/disabled_functions_require_allow.phpt25
-rw-r--r--src/tests/disable_function/disabled_functions_require_once.phpt24
-rw-r--r--src/tests/disable_function/disabled_functions_require_simulation.phpt27
-rw-r--r--src/tests/disable_function/disabled_functions_ret.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_ret2.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret3.phpt23
-rw-r--r--src/tests/disable_function/disabled_functions_ret_allow.phpt13
-rw-r--r--src/tests/disable_function/disabled_functions_ret_allow_value.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_right_hash.phpt14
-rw-r--r--src/tests/disable_function/disabled_functions_ret_simulation.phpt20
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_array.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_double.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_long.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_null.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_object.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_resource.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_str.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_ret_type_true.phpt17
-rw-r--r--src/tests/disable_function/disabled_functions_ret_user.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_ret_user_used.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_ret_val.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_ret_val_dump.phpt23
-rw-r--r--src/tests/disable_function/disabled_functions_ret_val_rx.phpt15
-rw-r--r--src/tests/disable_function/disabled_functions_right_hash.phpt12
-rw-r--r--src/tests/disable_function/disabled_functions_runtime.phpt32
-rw-r--r--src/tests/disable_function/disabled_functions_upper.phpt16
-rw-r--r--src/tests/disable_function/disabled_functions_variadic.phpt18
-rw-r--r--src/tests/disable_function/disabled_functions_zero_cidr.phpt17
-rw-r--r--src/tests/disable_function/disabled_native_functions_indirect.phpt12
-rw-r--r--src/tests/disable_function/disabled_user_functions.phpt15
-rw-r--r--src/tests/disable_function/disabled_user_functions_indirect.phpt15
-rw-r--r--src/tests/disable_function/noncore_function_hooking.phpt15
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 @@
1sp.disable_function.function("outer>inner>other").drop();
2sp.disable_function.function("other>outer>inner_").drop();
3sp.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 @@
1sp.disable_function.function("outer>call_user_func>inner").simulation().drop();
2sp.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 @@
1sp.disable_function.function_r("^system$").filename_r("\\.txt$").drop();
2sp.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 @@
1sp.disable_function.function("include").param("").value_r("sim$").drop().simulation();
2sp.disable_function.function("include").param("").value_r("meh$").drop();
3
4sp.disable_function.function("include_once").param("").value_r("sim$").drop().simulation();
5sp.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 @@
1sp.disable_function.function("AwesomeClass::method1").drop();
2sp.disable_function.function("method2").drop();
3sp.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 @@
1sp.disable_function.function_r("^not_system$").ret("42").drop();
2sp.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 @@
1sp.disable_function.function("strcmp").drop();
2sp.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 @@
1sp.disable_function.function("system").param("command").value_r("^id$").alias("1").drop();
2sp.disable_function.function("array_sum").param("array").value_r("^8$").alias("2").drop();
3sp.disable_function.function("shell_exec").param("cmd").value("id").alias("3").drop();
4sp.disable_function.function("shell_exec").param("cmd").value("bla").alias("4").drop();
5sp.disable_function.function("strcmp").param("str1").value("bla").alias("5").drop().simulation();
6sp.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 @@
1sp.disable_function.function("system").alias("1").drop();
2sp.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 @@
1sp.disable_function.function("system").param("command").value("echo win").filename("/test.php").drop();
2sp.disable_function.function("system").param("command").value("echo win").allow();
3sp.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 @@
1sp.disable_function.function("foo").param("arr[a]").value("abcd").alias("1").drop();
2sp.disable_function.function("foo").param("arr[bla]").value("abcdef").alias("2").drop();
3sp.disable_function.function("foo").param("arr[test]").alias("3").drop();
4sp.disable_function.function("foo").param("arr[test2][foo]").value("aaa").alias("4").drop();
5sp.disable_function.function("foo").param("arr[test2][bar]").key("lol").alias("5").drop();
6sp.disable_function.function("foo").param("arr[test2][bar]").key("123").alias("6").drop();
7sp.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 @@
1sp.disable_function.function("foobar").param("id").value("42").drop();
2sp.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 @@
1sp.disable_function.function("system").param_r("^not_command$").value("id").drop();
2sp.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 @@
1sp.disable_function.function("foo").param_r("arr").value("abcd").alias("1").drop();
2sp.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 @@
1sp.disable_function.function("require").param("").value_r("sim$").drop().simulation();
2sp.disable_function.function("require").param("").value_r("meh$").drop();
3
4sp.disable_function.function("require_once").param("").value_r("sim$").drop().simulation();
5sp.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 @@
1sp.disable_function.function("strpos").hash("70b33f3eaf585b245640bb2c92445d0040b2bcb31395aa25dede9f2df4dbcbe8").allow();
2sp.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 @@
1sp.disable_function.function("system").ret("1").drop();
2sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop();
3sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop();
4sp.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 @@
1sp.disable_function.function("strpos").ret("0").simulation().drop();
2sp.disable_function.function("stripos").ret("0").simulation().drop().alias("1");
3sp.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 @@
1sp.disable_function.function("system").hash("1337c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").allow();
2sp.disable_function.function("system").hash("d259c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").allow();
3sp.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
3sp.disable_function.function("curl_setopt").param("value").value("1").allow();
4sp.disable_function.function("curl_setopt").param("value").value("2").allow();
5sp.disable_function.function("curl_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off.");
6sp.disable_function.function("curl_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off.");
7
8# ---
9
10sp.disable_function.function("curl_setopt_array").param("options[CURLOPT_SSL_VERIFYHOST]").value("0").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off.");
11sp.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
15sp.disable_function.function("curl_multi_setopt").param("value").value("1").allow();
16sp.disable_function.function("curl_multi_setopt").param("value").value("2").allow();
17sp.disable_function.function("curl_multi_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off.");
18sp.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 @@
1sp.disable_function.function("echo").var("$abc").value("123").drop();
2sp.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 @@
1sp.disable_function.function("phpinfo").var("$b").value("1337").drop();
2sp.disable_function.function("strlen").var("$a").value("1337").drop();
3sp.disable_function.function("strlen").var("$a['123']").value("block").drop();
4sp.disable_function.function("strlen").var("$a[$c]->prop").value("block").drop();
5sp.disable_function.function("strlen").var("$a->zxc").value("not a good value").drop();
6sp.disable_function.function("strlen").var("\\asd\\test_object::TEST_VALUE['constant']").value("no good").drop();
7sp.disable_function.function("strlen").var("\\asd\\test_object::TEST_VALUE").value("qwerty").drop();
8sp.disable_function.function("strlen").var("\\qwe\\ASD").value("qwerty").drop();
9sp.disable_function.function("strlen").var("\\qwe\\QWE['123']").value("asdfgh").drop();
10sp.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 @@
1sp.disable_function.function("strlen").var("$test->$test_array").value("value").drop();
2sp.disable_function.function("strlen").var("$arg->$test_array").value("value").drop();
3sp.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 @@
1sp.disable_function.function("system").drop();
2sp.disable_function.function("vprintf").hash("123456789").drop();
3sp.disable_function.function("printf").disable().drop();
4sp.disable_function.function("printf").simulation().drop();
5sp.disable_function.function("print").disable().drop(); # this is a comment
6sp.disable_function.function_r("^var_dump$").drop();
7sp.disable_function.function("sprintf").filename("/wrong file name").drop();
8sp.disable_function.function("sprintf").filename("/wrong file name").drop();
9sp.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 @@
1sp.disable_function.function("system").drop().cidr("2001:ab9:a::123/64");
2sp.disable_function.function("system").drop().cidr("192.168.0.1/16");
3sp.disable_function.function("system").drop().cidr("127.0.0.1/8");
4sp.disable_function.function("printf").drop().cidr("10.0.0.1/8");
5sp.disable_function.function("strpos").drop().cidr("127.0.0.2/4");
6sp.disable_function.function("strpos").drop().cidr("::ffff:192.0.2.128/128");
7sp.disable_function.function("strpos").drop().cidr("2001:ab9:a::123/64");
8sp.disable_function.function("strpos").drop().cidr("2001:0db8:f000:f000:f000:ff00:0042:8329/124");
9sp.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 @@
1sp.disable_function.function("require_once").value_r("\.ico$").drop();
2sp.disable_function.function("include_once").value_r("\.ico$").drop();
3sp.disable_function.function("require").value_r("\.ico$").drop();
4sp.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 @@
1sp.disable_function.function("require_once").value_r("\.ico$").drop().simulation();
2sp.disable_function.function("include_once").value_r("\.ico$").drop().simulation();
3sp.disable_function.function("require").value_r("\.ico$").drop().simulation();
4sp.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 @@
1sp.disable_function.function("strlen").drop();
2sp.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 @@
1sp.disable_function.function("system").pos("1337").value("id").drop();
2sp.disable_function.function("system").pos("0").value("id").drop();
3sp.disable_function.function("system").pos("1").param_type("ARRAY").alias("1").drop();
4sp.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 @@
1sp.disable_function.function("testFunction").ret("0").drop().disable();
2sp.disable_function.function("strpos").ret("0").drop().filename_r(".*\\.not_matching");
3sp.disable_function.function("strpos").ret("0").drop().filename_r(".*\\.php");
4sp.disable_function.function_r("str[ia]pos").ret_r("^[^a-z]+$").drop();
5sp.disable_function.function_r("stripos").ret_r("^[^a-z]+").drop();
6sp.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 @@
1sp.disable_function.function("str_repeat").ret("fufufu").filename("/var/www/test.php").drop();
2sp.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--
2Echo hooking
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_echo.ini
7--FILE--
8<?php
9function test($a) {
10 print "$a";
11}
12echo "qwe";
13test("rty");
14test("oops");
15?>
16--CLEAN--
17--EXPECTF--
18qwerty
19Fatal 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--
2Echo hooking
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_echo.ini
7--FILE--
8<?php
9echo "qwe";
10echo "1", "oops";
11?>
12--CLEAN--
13--EXPECTF--
14qwe1
15Fatal 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--
2Echo hooking
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_echo.ini
7--FILE--
8<?php
9function test() {
10 print "3\n";
11}
12$abc = 1;
13test();
14$abc = 123;
15test();
16?>
17--CLEAN--
18--EXPECTF--
193
20
21Fatal 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--
2Disable functions - Ensure that client certificates validation can't be disabled
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$ch = curl_init();
13curl_setopt($ch, CURLOPT_VERBOSE, '1');
14curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '0');
15echo "1337";
16?>
17--EXPECTF--
18Fatal 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--
2Disable functions - Ensure that client certificates validation can't be disabled via `curl_multi_setopt`
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$mch = curl_multi_init();
13curl_multi_setopt($mch, CURLOPT_SSL_VERIFYPEER, 0);
14echo "1337";
15?>
16--EXPECTF--
17Fatal 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--
2Disable functions - Ensure that client certificates validation can't be disabled via `curl_setopt_array`
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$ch = curl_init();
13curl_setopt($ch, CURLOPT_VERBOSE, '1');
14$options = array(CURLOPT_SSL_VERIFYPEER => 0);
15curl_setopt_array($ch, $options);
16echo "1337";
17?>
18--EXPECTF--
19Fatal 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--
2Disable functions - Ensure that server certificates validation can't be disabled
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$ch = curl_init();
13curl_setopt($ch, CURLOPT_VERBOSE, '1');
14curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '0');
15echo "1337";
16?>
17--EXPECTF--
18Fatal 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--
2Disable functions - Ensure that server certificates validation can't be disabled via `curl_multi_setopt`
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$mch = curl_multi_init();
13curl_multi_setopt($mch, CURLOPT_SSL_VERIFYHOST, 0);
14echo "1337";
15?>
16--EXPECTF--
17Fatal 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--
2Disable functions - Ensure that server certificates validation can't be disabled via `curl_setopt_array`
3--SKIPIF--
4<?php
5if (!extension_loaded("snuffleupagus")) { die("skip"); }
6if (!extension_loaded("curl")) { die("skip"); }
7?>
8--INI--
9sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini
10--FILE--
11<?php
12$ch = curl_init();
13curl_setopt($ch, CURLOPT_VERBOSE, '1');
14$options = array(CURLOPT_SSL_VERIFYHOST => 0);
15curl_setopt_array($ch, $options);
16echo "1337";
17?>
18--EXPECTF--
19Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9$a = 1338;
10function test(){
11 echo strlen("id") . "\n";
12}
13echo "Value of a: $a\n";
14test();
15
16$a = 1337;
17echo "Value of a: $a\n";
18test();
19?>
20--EXPECTF--
21Value of a: 1338
222
23Value of a: 1337
24
25Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9$qwe = Array('123' => Array('qwe'), '456' => Array('no block this'));
10var_dump($qwe);
11strlen("qwe");
12$qwe = Array('123' => Array('qwe'), '456' => Array(Array('block this')));
13var_dump($qwe);
14strlen("qwe");
15?>
16--EXPECTF--
17array(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}
29array(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
45Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9$a = 1338;
10function test(){
11 echo strlen("id") . "\n";
12}
13echo "Value of a: $a\n";
14test();
15
16$a = Array();
17$a['qwe'] = 'block';
18$a['123'] = 'nop';
19echo "Value of a:\n";
20var_dump($a);
21test();
22
23$a['123'] = 'block';
24echo "Value of a:\n";
25var_dump($a);
26test();
27?>
28--EXPECTF--
29Value of a: 1338
302
31Value of a:
32array(2) {
33 ["qwe"]=>
34 string(5) "block"
35 [123]=>
36 string(3) "nop"
37}
382
39Value of a:
40array(2) {
41 ["qwe"]=>
42 string(5) "block"
43 [123]=>
44 string(5) "block"
45}
46
47Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9function test(){
10 echo strlen("id") . "\n";
11}
12
13$a = Array();
14$c = '123';
15$a['qwe'] = 'qwe';
16$a['123'] = 'nop';
17echo "Value of a:\n";
18var_dump($a);
19test();
20
21$a[$c] = (Object)['prop' => 'block'];
22echo "Value of a:\n";
23var_dump($a);
24test();
25?>
26--EXPECTF--
27Value of a:
28array(2) {
29 ["qwe"]=>
30 string(3) "qwe"
31 [123]=>
32 string(3) "nop"
33}
342
35Value of a:
36array(2) {
37 ["qwe"]=>
38 string(3) "qwe"
39 [123]=>
40 object(stdClass)#1 (1) {
41 ["prop"]=>
42 string(5) "block"
43 }
44}
45
46Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var_2.ini
7--FILE--
8<?php
9namespace qwe {
10 const UNE_CONSTANTE = 'constant';
11}
12namespace 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';
28class 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;
42function test(){
43 strlen("qwe");
44}
45echo "Valeur: " . $b['_GET]["obj->nop::qwe']["qwe"][$a]->uio . "\n";
46test();
47
48$a = 1337;
49echo "Valeur: " . $b['_GET]["obj->nop::qwe']["qwe"][$a]->uio . "\n";
50test();
51}
52?>
53--EXPECTF--
54Valeur: valeur de a
55Valeur: valeur de apres
56
57Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9function test(){
10 echo strlen("id") . "\n";
11}
12
13$a = Array();
14echo "Value of a:\n";
15var_dump($a);
16test();
17
18$a = (Object)['zxc' => 'not a good value'];
19echo "Value of a:\n";
20var_dump($a);
21test();
22?>
23--EXPECTF--
24Value of a:
25array(0) {
26}
272
28Value of a:
29object(stdClass)#1 (1) {
30 ["zxc"]=>
31 string(16) "not a good value"
32}
33
34Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9namespace asd {
10function test(){
11 strlen("qwe");
12}
13echo "Valeur: " . \asd\test_object::TEST_VALUE['constant'] . "\n";
14test();
15class 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--
30Valeur: no good
31
32Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9namespace asd {
10function test(){
11 strlen("qwe");
12}
13echo "Valeur: " . \asd\test_object::TEST_VALUE . "\n";
14test();
15class 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--
30Valeur: qwerty
31
32Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9namespace qwe {
10 const ASD = 'qwerty';
11}
12namespace asd {
13 const asd = 'qwe';
14 echo "Valeur: " . \qwe\ASD . "\n";
15 strlen("qwe");
16}
17?>
18--EXPECTF--
19Valeur: qwerty
20
21Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9namespace qwe {
10 const QWE = Array('123'=>'asdfgh');
11}
12namespace asd {
13 const asd = 'qwe';
14 echo "Valeur: " . \qwe\QWE[123]. "\n";
15 strlen("qwe");
16}
17?>
18--EXPECTF--
19Valeur: asdfgh
20
21Fatal 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--
2Disable functions - match on a constant
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var_const.ini
7--FILE--
8<?php
9$a = 1337;
10define("MY_CONST", $a);
11strlen("test");
12?>
13--EXPECTF--
14Fatal 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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var.ini
7--FILE--
8<?php
9function test(){
10 echo strlen("id") . "\n";
11}
12ob_start(test());
13echo "test\n";
14?>
15--EXPECTF--
162
17test
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--
2Disable functions - match on a local variable
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var_obj.ini
7--FILE--
8<?php
9class 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');
19echo strlen($test->$arg) . "\n";
20$test = new test_class('qwe', 'nop_object');
21echo strlen($test->$arg) . "\n";
22?>
23--EXPECTF--
243
25
26Fatal 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--
2Disable functions - match on a param
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_param.ini
7--FILE--
8<?php
9function qweqwe($asd) {
10 echo "OK\n";
11}
12
13$asd = Array(2);
14qweqwe(Array(1));
15qweqwe(Array(2));
16?>
17--EXPECTF--
18OK
19
20Fatal 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--
2Echo hooking
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_print.ini
7--FILE--
8<?php
9function test($a) {
10 print "$a";
11}
12print "qwe";
13test("rty");
14test("oops");
15?>
16--CLEAN--
17--EXPECTF--
18qwerty
19Fatal 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--
2Disable functions - match on a super global
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_super_global_var.ini
7--GET--
8bla=test
9--FILE--
10<?php
11function test(){
12 echo strlen($_GET['bla']) . "\n";
13}
14test();
15$_GET['bla'] = 'test2';
16test();
17?>
18--EXPECTF--
194
20
21Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions.ini
7--FILE--
8<?php
9strcmp("1", "2");
10system("id");
11printf("printf in simulation mode\n");
12print("print in disabled mode\n");
13var_dump("this is a super test");
14echo strpos("pouet", "o");
15?>
16--EXPECTF--
17Fatal 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--
2Disable 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--
6sp.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
16function test_callback() {
17 return "Test_callback";
18}
19
20function test(callable $toto) {
21 return $toto();
22}
23?>
24EOD;
25
26file_put_contents("$dir/myfunc_callback.php", $mycode);
27
28include "$dir/myfunc_callback.php";
29
30echo test('test_callback');
31
32?>
33--CLEAN--
34<?php
35$dir = __DIR__;
36@unlink("$dir/myfunc_callback.php");
37?>
38--EXPECTF--
39Fatal 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--
2Disable 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--
6sp.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
15function test() {
16 echo "TOTO";
17}
18?>
19EOD;
20
21file_put_contents("$dir/myfunc.php", $mycode);
22
23include "$dir/myfunc.php";
24
25test();
26
27?>
28--CLEAN--
29<?php
30$dir = __DIR__;
31@unlink("$dir/myfunc.php");
32?>
33--EXPECTF--
34Fatal 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--
2Disable functions by matching the calltrace
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini
7--FILE--
8<?php
9
10function 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
19echo "I'm before the call to outer\n";
20outer();
21echo "I'm after the call to outer\n";
22?>
23--EXPECTF--
24I'm before the call to outer
25I'm in the outer function, before the call!
26
27Fatal 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--
2Disable functions by matching the calltrace, with call_user_func involved
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain_call_user_func.ini
7--FILE--
8<?php
9
10function 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
19echo "I'm before the call to outer\n";
20outer();
21echo "I'm after the call to outer\n";
22?>
23--EXPECTF--
24I'm before the call to outer
25I'm in the outer function, before the call!
26
27Fatal 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--
2Disable functions by matching the calltrace, on the return value
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain_call_user_func_ret.ini
7--FILE--
8<?php
9function two($a) {
10 echo "two\n";
11 return $a . "_two";
12}
13function one($a) {
14 echo "one\n";
15 two($a);
16 return $a . "_one";
17}
18
19echo one('not matching') . "\n";
20echo one('matching') . "\n";
21echo one('still not matching') . "\n";
22
23?>
24--EXPECTF--
25one
26two
27not matching_one
28one
29two
30
31Warning: [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
32matching_one
33one
34two
35still 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--
2Disable functions by matching the calltrace
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini
7--FILE--
8<?php
9
10function 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
19echo "I'm before the call to outer\n";
20outer();
21echo "I'm after the call to outer\n";
22?>
23--EXPECTF--
24I'm before the call to outer
25I'm in the outer function, before the call!
26I'm in the inner function!
27I'm in the outer function, after the call!
28I'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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--ENV--
6return <<<EOF
7REMOTE_ADDR=127.0.0.1
8EOF;
9--INI--
10sp.configuration_file={PWD}/config/disabled_functions_cidr.ini
11--FILE--
12<?php
13system("echo 42");
14?>
15--EXPECTF--
16Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--ENV--
6return <<<EOF
7REMOTE_ADDR=2001:0db8:f000:f000:f000:ff00:0042:8328
8EOF;
9--INI--
10sp.configuration_file={PWD}/config/disabled_functions_cidr.ini
11--FILE--
12<?php
13strpos("a", "b");
14printf(1337);
15?>
16--EXPECTF--
17Fatal 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--
2Disable functions - die
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_die.ini
7--FILE--
8<?php
9die('OMG');
10?>
11--XFAIL--
12--EXPECTF--
13Fatal 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--
2Disable function, bug : https://github.com/nbs-system/snuffleupagus/issues/181
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.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?>
17EOD;
18
19file_put_contents("$dir/test_include.php", $code);
20
21include "$dir/test_include.php";
22
23echo $test;
24
25?>
26
27--EXPECTF--
28testOK
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--
2Disable function, bug : https://github.com/nbs-system/snuffleupagus/issues/181
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.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?>
17EOD;
18
19file_put_contents("$dir/test_include.php", $code);
20
21include "$dir/test_include.php";
22
23echo $test;
24
25?>
26
27--EXPECTF--
28testOK
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--
2Disable functions - eval
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_eval.ini
7--FILE--
8<?php
9$var = 123456789;
10eval('$var = 1337 + 1337;');
11print("Variable: $var\n");
12?>
13--EXPECTF--
14Fatal 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--
2Disable functions - eval
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_eval_filename.ini
7--FILE--
8<?php
9$var = 123456789;
10eval('$var = 1337 + 1337;');
11print("Variable: $var\n");
12?>
13--EXPECTF--
14Fatal 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--
2Disable functions - eval (simulation)
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_eval_simulation.ini
7--FILE--
8<?php
9$var = 123456789;
10eval('$var = 1337 + 1337;');
11print("Variable: $var\n");
12?>
13--EXPECTF--
14Warning: [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
15Variable: 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--
2Disable functions - eval with a disabled user func
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_eval_user_func.ini
7--FILE--
8<?php
9function my_func() {
10 echo "1337\n";
11 return 10;
12}
13$a = 0;
14eval('$a = my_func();');
15echo '$a = ' . $a . "\n";
16?>
17--EXPECTF--
18Fatal 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--
2Disable functions - exit
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_exit.ini
7--FILE--
8<?php
9exit('OMG');
10?>
11--XFAIL--
12--EXPECTF--
13Fatal 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--
2Disable functions - filename regexp
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_filename_r.ini
7--FILE--
8<?php
9system("echo 42");
10shell_exec("echo 43");
11?>
12--EXPECTF--
1342
14
15Fatal 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--
2Disable functions - include_once
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_include.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA\n");
11file_put_contents($dir . '/test.sim', "MEH\n");
12include_once $dir . '/test.bla';
13include_once $dir . '/test.sim';
14echo "1337\n";
15?>
16--CLEAN--
17<?php
18$dir = __DIR__;
19unlink($dir . '/test.bla');
20unlink($dir . '/test.sim');
21?>
22--EXPECTF--
23BLA
24
25Warning: [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
26MEH
271337
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--
2Disable functions - Include (simulation)
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_include.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA\n");
11file_put_contents($dir . '/test.sim', "MEH\n");
12include $dir . '/test.bla';
13include $dir . '/test.sim';
14echo "1337\n";
15?>
16--CLEAN--
17<?php
18$dir = __DIR__;
19unlink($dir . '/test.bla');
20unlink($dir . '/test.sim');
21?>
22--EXPECTF--
23BLA
24
25Warning: [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
26MEH
271337
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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_local_var_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_local_var_array_key.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("foo"=>Array("aaa"=>"ccc")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_local_var_array_not_array.ini
7--FILE--
8<?php
9function foobar($a) {
10 var_dump($a);
11}
12$a = ["lol"=>2, "test"=>1];
13foobar("test");
14
15?>
16--EXPECTF--
17string(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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_mb.ini
7--FILE--
8<?php
9echo strlen("id");
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_method.ini
7--FILE--
8<?php
9class 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--
27Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_name_r.ini
7--FILE--
8<?php
9system("echo 42");
10system("echo 1337");
11?>
12--EXPECTF--
1342
141337
15
16Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_name_regexp_type.ini
7--FILE--
8<?php
9echo strcmp("pouet", "pouet") . "\n";
10echo strcmp(1, 2) . "\n";
11echo strcmp([1], "pouet") . "\n";
12?>
13--EXPECTF--
140
15-1
16
17Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_name_type.ini
7--FILE--
8<?php
9echo strcmp("pouet", "pouet") . "\n";
10echo strcmp([1,23], "pouet") . "\n";
11?>
12--EXPECTF--
130
14
15Fatal 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--
2Disable functions in namespaces
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_namespace.ini
7--FILE--
8<?php
9namespace my_super_namespace {
10 function my_function() {
11 echo "Should not be printed\n";
12 }
13}
14namespace my_second_namespace {
15 function my_function() {
16 echo "Second namespace\n";
17 }
18}
19namespace {
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();
26my_function();
27}
28?>
29--EXPECTF--
30Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/empty.ini
7--FILE--
8<?php
9echo strpos("pouet", "o");
10?>
11--EXPECT--
121
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--
2Disable functions with nul byte
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_nul_byte.ini
7--FILE--
8<?php
9system("\0id");
10system("id");
11
12?>
13--EXPECTF--
14Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param.ini
7--FILE--
8<?php
9system("id");
10system("echo win");
11var_dump(array_sum([1,2,3,4,5]));
12shell_exec("id");
13echo shell_exec("echo 42");
14strcmp("bla", "ble");
15strncmp("bla", "ble", 2);
16?>
17--EXPECTF--
18Fatal 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--
2Disable functions - alias
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_alias.ini
7--FILE--
8<?php
9system("id");
10shell_exec("id");
11?>
12--EXPECTF--
13Fatal 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--
2Disable functions - allow
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_allow.ini
7--FILE--
8<?php
9system("echo win");
10system("id");
11?>
12--EXPECTF--
13win
14
15Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("a"=>"test1");
13foo($a);
14
15$a=Array("a"=>"abcde");
16foo($a);
17
18$a=Array("a"=>"abcd");
19foo($a);
20?>
21--EXPECTF--
22test1
23abcde
24
25Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12
13$a=Array("bla"=>"aaa", "a"=>"eee" );
14foo($a);
15
16$a=Array("bla"=>"aaa", "a"=>"abcdef" );
17foo($a);
18
19$a=Array("bla"=>"abcdef", "not_bla"=>"134");
20foo($a);
21?>
22--EXPECTF--
23eee
24abcdef
25
26Fatal 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--
2Disable functions - matching on an array's variable only
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12
13$a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
14foo($a);
15
16$a=Array("test"=>"aaa", "a"=>"fff" );
17foo($a);
18
19?>
20--EXPECTF--
21cccc
22
23Fatal 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--
2Disable functions - match on an array using regexp
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_r_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>"pof", "pof"=>"pif", "a"=>Array("qwe"=>"bbb"), "a"=>"cccc");
13foo($a);
14
15$a=Array("a"=>"abcd", "pof"=>"pif", "bar"=>Array("qwe"=>"bbb"), "b"=>"cccc");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array using regexp
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_r_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>"pof", "pof"=>"pif", "qwe"=>Array("qwe"=>"bbb"), "a"=>"cccc");
13foo($a);
14
15$a=Array("a"=>"", "pof"=>"pif", "bar"=>Array("qwe"=>"bbb"), "qweabcqwe"=>"nop");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("foo"=>Array("123"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "bar"=>Array("qwe"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("bar"=>Array("lol"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "bar"=>Array("qwe"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("bar"=>Array("123"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20
21Fatal 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--
2Disable functions - match on a specific line - broken configuration
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_broken_line.ini
7--FILE--
8<?php
9system("echo 1337");
10system("echo 1338");
11?>
12--EXPECTF--
13PHP Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0
14
15Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0
16
17Fatal error: [snuffleupagus][config] Invalid configuration file in Unknown on line 0
18Could 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_int.ini
7--FILE--
8<?php
9function foobar($id) {
10 echo $id."\n";
11}
12foobar(1);
13foobar(42);
14foobar(1337);
15foobar(13374242);
16foobar(0x2A);
17foobar("10");
18?>
19--EXPECTF--
201
21
22Fatal 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--
2Disable functions - match on argument's position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_invalid_pos.ini
7--FILE--
8<?php
9system("echo 1");
10?>
11--EXPECTF--
12PHP Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0
13
14Fatal error: [snuffleupagus][config] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0
15
16Fatal error: [snuffleupagus][config] Invalid configuration file in Unknown on line 0
17Could 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--
2Disable functions - match on a specific line
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_line.ini
7--FILE--
8<?php
9system("echo 1337");
10system("id");
11?>
12--EXPECTF--
131337
14
15Fatal 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--
2Disable functions - match on argument's position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_pos.ini
7--FILE--
8<?php
9system("id");
10?>
11--EXPECTF--
12Warning: [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
14Fatal 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--
2Disable functions - match on argument's position, not the first time
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_pos.ini
7--FILE--
8<?php
9strlen("od");
10strlen("id");
11?>
12--EXPECTF--
13Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_r.ini
7--FILE--
8<?php
9system("id");
10system("echo win");
11?>
12--EXPECTF--
13Fatal 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--
2Disable functions - casting various types to string internally
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_str_representation.ini
7--FILE--
8<?php
9echo var_export(true) . "\n";
10echo var_export(false) . "\n";
11echo var_export(null) . "\n";
12echo var_export(1) . "\n";
13echo var_export(1.0) . "\n";
14function f(&$a) {
15 echo var_export($a) . "\n";
16}
17$a = 123; f($a);
18?>
19--EXPECTF--
20true
21false
22NULL
231
241.0
25123
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--
2Disable functions - Parsing of an Object as a return value of a function
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret.ini
7--FILE--
8<?php
9/*
10Because Snuffleupagus used to cast everything with the `zval_get_string` function,
11this sometimes raised exceptions, because PHP is awful.
12 */
13class Bob {
14 function a() {
15 return new StdClass;
16 }
17}
18$b = new Bob;
19echo ($b->a() instanceof StdClass)?'Y':'N';
20?>
21--EXPECT--
22Y
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--
2Disable functions - match on argument's position
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_pos.ini
7--FILE--
8<?php
9system([123, 456]);
10?>
11--EXPECTF--
12Warning: [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
14Warning: [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
16Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_regexp.ini
7--FILE--
8<?php
9echo strlen("id") . "\n";
10echo strcmp("1", "2") . "\n";
11print("After") . "\n";
12?>
13--EXPECTF--
14Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strlen' in %a/disabled_functions_regexp_multiple.php on line 2
152
16
17Warning: [snuffleupagus][disabled_function] Aborted execution on call of the function 'strcmp' in %a/disabled_functions_regexp_multiple.php on line 3
18-1
19After \ 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--
2Disable functions - Called with register_shutdown_function
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_user_functions.ini
7--FILE--
8<?php
9function my_super_function() {
10 echo 'lose';
11}
12echo "1337\n";
13register_shutdown_function('my_super_function');
14?>
15--EXPECTF--
161337
17
18Fatal 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--
2Disable functions - Called with register_tick_function
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_user_functions.ini
7--FILE--
8<?php
9declare(ticks=1);
10function my_super_function() {
11 echo 'lose';
12}
13echo "1337\n";
14register_tick_function('my_super_function');
15?>
16--EXPECTF--
171337
18
19Fatal 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--
2Disable functions - Require
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_require.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA");
11file_put_contents($dir . '/test.meh', "MEH");
12require $dir . '/test.bla';
13require $dir . '/test.meh';
14echo "1337";
15?>
16--CLEAN--
17<?php
18$dir = __DIR__;
19unlink($dir . '/test.bla');
20unlink($dir . '/test.meh');
21?>
22--EXPECTF--
23BLA
24Fatal 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--
2Disable functions - Require (allow)
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_require_allow.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA\n");
11file_put_contents($dir . '/test.meh', "MEH\n");
12require $dir . '/test.bla';
13require $dir . '/test.meh';
14echo "1337";
15?>
16--EXPECTF--
17BLA
18MEH
191337
20--CLEAN--
21<?php
22$dir = __DIR__;
23unlink($dir . '/test.bla');
24unlink($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--
2Disable functions - require_once
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_require.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA");
11file_put_contents($dir . '/test.meh', "MEH");
12require_once $dir . '/test.bla';
13require_once $dir . '/test.meh';
14echo "1337";
15?>
16--CLEAN--
17<?php
18$dir = __DIR__;
19unlink($dir . '/test.bla');
20unlink($dir . '/test.meh');
21?>
22--EXPECTF--
23BLA
24Fatal 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--
2Disable functions - Require (simulation)
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_require.ini
7--FILE--
8<?php
9$dir = __DIR__;
10file_put_contents($dir . '/test.bla', "BLA\n");
11file_put_contents($dir . '/test.sim', "MEH\n");
12require $dir . '/test.bla';
13require $dir . '/test.sim';
14echo "1337\n";
15?>
16--CLEAN--
17<?php
18$dir = __DIR__;
19unlink($dir . '/test.bla');
20unlink($dir . '/test.sim');
21?>
22--EXPECTF--
23BLA
24
25Warning: [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
26MEH
271337
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--
2Disable functions check on `ret`.
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret.ini
7--FILE--
8<?php
9echo strpos("pouet", "p");
10echo stripos("pouet", "p");
11?>
12--EXPECTF--
13Fatal 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--
2Disable functions check on `ret`.
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret.ini
7--FILE--
8<?php
9echo stripos("pouet", "p");
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret`.
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret.ini
7memory_limit=-1
8--FILE--
9<?php
10class Bob {
11 function a() {
12 echo("We're in function `a`.\n");
13 return 2;
14 }
15}
16$b = new Bob();
17echo "`a` returned: " . $b->a() . ".\n";
18echo("We're at the end of the execution.\n");
19?>
20--EXPECTF--
21We're in function `a`.
22
23Fatal 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--
2Disable functions check on `ret`.
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_allow.ini
7--FILE--
8<?php
9echo strpos("pouet", "p");
10echo stripos("pouet", "p");
11?>
12--EXPECT--
1300 \ 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--
2Disable functions check on `ret` allowed
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_allow_value.ini
7--FILE--
8<?php
9echo strpos("pouet", "p");
10?>
11--EXPECT--
120
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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_right_hash.ini
7--FILE--
8<?php
9system("echo $((1 + 1336))");
10?>
11--EXPECTF--
121337
13
14Fatal 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--
2Disable functions check on `ret` simulation
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_simulation.ini
7--FILE--
8<?php
9echo strpos("pouet", "p") . "\n";
10echo stripos("pouet", "p") . "\n";
11strcmp("p", "p") . "\n";
12?>
13--EXPECTF--
14Warning: [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
150
16
17Warning: [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
180
19
20Fatal 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--
2Disable functions check on `ret` by type matching (false)
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type.ini
7--FILE--
8<?php
9var_dump(strpos("pouet", "p")) . "\n";
10echo "1337\n";
11echo strpos("pouet", "123");
12?>
13--EXPECTF--
14int(0)
151337
16
17Fatal 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--
2Disable functions check on `ret` by type matching (array).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_array.ini
7--FILE--
8<?php
9echo get_loaded_extensions();
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret` by type matching (double).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_double.ini
7--FILE--
8<?php
9echo cos(0.5) . "\n";
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret` by type matching (long).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_long.ini
7--FILE--
8<?php
9echo strlen("pouet") . "\n";
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret` by type matching (null).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_null.ini
7--FILE--
8<?php
9function my_function() {
10 return NULL;
11}
12
13var_dump(my_function());
14?>
15--EXPECTF--
16Fatal 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--
2Disable functions check on `ret` by type matching (object).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_object.ini
7--FILE--
8<?php
9function a(){
10 return new StdClass();
11}
12$var = a();
13echo "fail";
14?>
15--EXPECTF--
16Fatal 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--
2Disable functions check on `ret` by type matching (resource).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_resource.ini
7--FILE--
8<?php
9echo fopen("/etc/passwd", "r");
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret` by type matching (string).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_str.ini
7--FILE--
8<?php
9echo substr("pouet", 3) . "\n";
10?>
11--EXPECTF--
12Fatal 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--
2Disable functions check on `ret` by type matching (true).
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_ret_type_true.ini
7--FILE--
8<?php
9var_dump(is_numeric("pouet")) . "\n";
10echo "1337\n";
11echo is_numeric("1234") . "\n";
12?>
13--EXPECTF--
14bool(false)
151337
16
17Fatal 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--
2Check NULL return value for user func
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_user.ini
7--FILE--
8<?php
9function qwe() {
10 return "asd";
11}
12qwe();
13echo 1;
14?>
15--EXPECTF--
16Fatal 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--
2Check return value for user func
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_ret_user.ini
7--FILE--
8<?php
9function qwe() {
10 return "asd";
11}
12echo qwe();
13?>
14--EXPECTF--
15Fatal 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--
2Disable functions ret val
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_retval.ini
7--FILE--
8<?php
9echo str_repeat("fufu",1)."\n";
10echo str_repeat("fufufu",1);
11?>
12--EXPECTF--
13fufu
14
15Fatal 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--
2Disable functions ret val - dump
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_retval_dump.ini
7--ENV--
8DOCUMENT_ROOT=a
9--POST--
10post_a=data_post_a&post_b=data_post_b
11--GET--
12get_a=data_get_a&get_b=data_get_b
13--COOKIE--
14cookie_a=data_cookie_a&cookie_b=data_cookie_b
15--FILE--
16<?php
17echo str_repeat("fufu",1)."\n";
18echo str_repeat("fufufu",1);
19?>
20--EXPECTF--
21fufu
22
23Fatal 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--
2Disable functions ret val rx
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions_retval_rx.ini
7--FILE--
8<?php
9echo str_repeat("fufu",1)."\n";
10echo str_repeat("fufufu",1);
11?>
12--EXPECTF--
13fufu
14
15Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_right_hash.ini
7--FILE--
8<?php
9system("echo $((1 + 1336))");
10?>
11--EXPECTF--
121337
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--
2Disable functions - runtime inclusion
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.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"; }';
12file_put_contents('file_to_include1.php', $content);
13file_put_contents('file_to_include2.php', $content);
14
15if (rand() % 2) {
16 include "file_to_include1.php";
17} else {
18 include "file_to_include2.php";
19}
20
21test('1338');test('1337');
22
23?>
24--CLEAN--
25<?php
26unlink("file_to_include1.php");
27unlink("file_to_include2.php");
28?>
29--EXPECTF--
301338
31
32Fatal 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--
2Disable functions - uppercase
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions.ini
7--FILE--
8<?php
9sYSTEm("id");
10pRINTf("printf in simulation mode\n");
11pRINT("print in disabled mode\n");
12vaR_DUmp("this is a super test");
13echo sTRPOs("pouet", "o");
14?>
15--EXPECTF--
16Fatal 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--
2Disable functions - support for variadic functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_variadic.ini
7--FILE--
8<?php
9function foo(...$b) {
10 return count($b);
11}
12
13echo foo(5, 4, 3, 2, 1);
14?>
15--EXPECTF--
16Warning: [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
18Fatal 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--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--ENV--
6return <<<EOF
7REMOTE_ADDR=127.0.0.1
8EOF;
9--INI--
10sp.configuration_file={PWD}/config/disabled_functions_zero_cidr.ini
11--FILE--
12<?php
13system("echo 42");
14printf("1337");
15?>
16--EXPECTF--
17Fatal 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--
2Disabled native functions, called indirectly
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_functions.ini
7--FILE--
8<?php
9array_map('system', [1,2,3,4]);
10?>
11--EXPECTF--
12Fatal 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--
2Disabled user-created functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_user_functions.ini
7--FILE--
8<?php
9function my_super_function() {
10 echo 1;
11}
12my_super_function();
13?>
14--EXPECTF--
15Fatal 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--
2Disabled user-created functions, called indirectly
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_user_functions.ini
7--FILE--
8<?php
9function my_super_function() {
10 echo 1;
11}
12array_map('my_super_function', [1,2,3,4]);
13?>
14--EXPECTF--
15Fatal 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--
2Hooking of user-defined functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_noncore_function_hooking.ini
7--FILE--
8<?php
9function custom_fun($a) {
10 echo $a;
11}
12custom_fun("hello");
13?>
14--EXPECTF--
15Fatal 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