From 9a0400bdbc7d4decb32fe8fa3960e9e77f9fe898 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 27 Oct 2017 17:22:35 +0200 Subject: Bump the coverage --- .../config_disabled_functions_ret_right_hash.ini | 2 +- .../config/config_encrypted_cookies_empty_env.ini | 2 ++ src/tests/disabled_functions_param_array.phpt | 16 +++++++++++--- .../disabled_functions_param_array_deref.phpt | 25 ++++++++++++++++++++++ .../disabled_functions_param_array_no_value.phpt | 22 +++++++++++++++++++ ...abled_functions_param_array_several_levels.phpt | 20 +++++++++++++++++ src/tests/disabled_functions_ret_right_hash.phpt | 1 + src/tests/encrypt_cookies_empty_env.phpt | 19 ++++++++++++++++ 8 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 src/tests/config/config_encrypted_cookies_empty_env.ini create mode 100644 src/tests/disabled_functions_param_array_deref.phpt create mode 100644 src/tests/disabled_functions_param_array_no_value.phpt create mode 100644 src/tests/disabled_functions_param_array_several_levels.phpt create mode 100644 src/tests/encrypt_cookies_empty_env.phpt (limited to 'src') diff --git a/src/tests/config/config_disabled_functions_ret_right_hash.ini b/src/tests/config/config_disabled_functions_ret_right_hash.ini index 8ec8f83..af4fdd4 100644 --- a/src/tests/config/config_disabled_functions_ret_right_hash.ini +++ b/src/tests/config/config_disabled_functions_ret_right_hash.ini @@ -1,4 +1,4 @@ sp.disable_function.function("system").ret("1").drop(); sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); -sp.disable_function.function("system").ret("1337").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); +sp.disable_function.function("system").ret("1337").hash("d259c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").drop(); diff --git a/src/tests/config/config_encrypted_cookies_empty_env.ini b/src/tests/config/config_encrypted_cookies_empty_env.ini new file mode 100644 index 0000000..ac1f840 --- /dev/null +++ b/src/tests/config/config_encrypted_cookies_empty_env.ini @@ -0,0 +1,2 @@ +sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); +sp.cookie_encryption.cookie("super_cookie"); diff --git a/src/tests/disabled_functions_param_array.phpt b/src/tests/disabled_functions_param_array.phpt index 4738745..8fb75e1 100644 --- a/src/tests/disabled_functions_param_array.phpt +++ b/src/tests/disabled_functions_param_array.phpt @@ -11,21 +11,31 @@ function foo($arr) { } $a=Array("a"=>"test1"); foo($a); -$a=Array("a"=>"abcd"); -foo($a); + $a=Array("a"=>"abcde"); foo($a); + +$a=Array("a"=>"abcd"); +foo($a); +/* + $a=Array("bla"=>"abcdef"); foo($a); + $a=Array("bla"=>"aaa", "a"=>"eee" ); foo($a); + $a=Array("test"=>"aaa", "a"=>"fff" ); foo($a); + $a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); foo($a); + $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); foo($a); + */ ?> --EXPECTF-- test1 -[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/disabled_functions_param_array.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '1'. \ No newline at end of file +abcde +[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/disabled_functions_param_array.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '1'. diff --git a/src/tests/disabled_functions_param_array_deref.phpt b/src/tests/disabled_functions_param_array_deref.phpt new file mode 100644 index 0000000..556cb06 --- /dev/null +++ b/src/tests/disabled_functions_param_array_deref.phpt @@ -0,0 +1,25 @@ +--TEST-- +Disable functions +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini +--FILE-- +"aaa", "a"=>"eee" ); +foo($a); + +$a=Array("bla"=>"aaa", "a"=>"abcdef" ); +foo($a); + +$a=Array("bla"=>"abcdef", "not_bla"=>"134"); +foo($a); +?> +--EXPECTF-- +eee +abcdef +[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_deref.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '2'. diff --git a/src/tests/disabled_functions_param_array_no_value.phpt b/src/tests/disabled_functions_param_array_no_value.phpt new file mode 100644 index 0000000..06b9839 --- /dev/null +++ b/src/tests/disabled_functions_param_array_no_value.phpt @@ -0,0 +1,22 @@ +--TEST-- +Disable functions - matching on an array's variable only +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini +--FILE-- +Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); +foo($a); + +$a=Array("test"=>"aaa", "a"=>"fff" ); +foo($a); + +?> +--EXPECTF-- +cccc +[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_no_value.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '3'. diff --git a/src/tests/disabled_functions_param_array_several_levels.phpt b/src/tests/disabled_functions_param_array_several_levels.phpt new file mode 100644 index 0000000..cef6ded --- /dev/null +++ b/src/tests/disabled_functions_param_array_several_levels.phpt @@ -0,0 +1,20 @@ +--TEST-- +Disable functions - match on an array value buried in several levels +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini +--FILE-- +Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); +foo($a); + +$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); +foo($a); +?> +--EXPECTF-- +cccc +[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_several_levels.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '4'. diff --git a/src/tests/disabled_functions_ret_right_hash.phpt b/src/tests/disabled_functions_ret_right_hash.phpt index e0d8b5b..ff683e1 100644 --- a/src/tests/disabled_functions_ret_right_hash.phpt +++ b/src/tests/disabled_functions_ret_right_hash.phpt @@ -10,3 +10,4 @@ system("echo $((1 + 1336))"); ?> --EXPECTF-- 1337 +[snuffleupagus][0.0.0.0][disabled_function][drop] The execution has been aborted in %a/tests/disabled_functions_ret_right_hash.php:2, because the return value (1337) of the function 'system' matched a rule. diff --git a/src/tests/encrypt_cookies_empty_env.phpt b/src/tests/encrypt_cookies_empty_env.phpt new file mode 100644 index 0000000..1136d4d --- /dev/null +++ b/src/tests/encrypt_cookies_empty_env.phpt @@ -0,0 +1,19 @@ +--TEST-- +Cookie encryption - empty environment variable specified +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/config_encrypted_cookies_empty_env.ini +display_errors=1 +display_startup_errors=1 +error_reporting=E_ALL +--COOKIE-- +super_cookie=1337;awful_cookie=awful_cookie_value; +--ENV-- +return << +--EXPECT-- +1 -- cgit v1.3