From 3c720bec3a78775f37839256cfc4b2fea1348550 Mon Sep 17 00:00:00 2001 From: Christian Göttsche Date: Wed, 13 Dec 2023 20:37:42 +0100 Subject: print key and value on INI violations On violations of INI settings include the key and if appropriate the value in the log message. This helps to locate offenders and fine tune the configuration itself. --- src/tests/ini/ini_min_policy_drop.phpt | 2 +- src/tests/ini/ini_minmax.phpt | 4 ++-- src/tests/ini/ini_null.phpt | 2 +- src/tests/ini/ini_regexp.phpt | 2 +- src/tests/ini/ini_regexp_drop.phpt | 2 +- src/tests/ini/ini_regexp_drop_base64.phpt | 13 +++++++++++++ 6 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 src/tests/ini/ini_regexp_drop_base64.phpt (limited to 'src/tests') diff --git a/src/tests/ini/ini_min_policy_drop.phpt b/src/tests/ini/ini_min_policy_drop.phpt index 1ec9f9a..43e180e 100644 --- a/src/tests/ini/ini_min_policy_drop.phpt +++ b/src/tests/ini/ini_min_policy_drop.phpt @@ -10,4 +10,4 @@ var_dump(ini_set("max_execution_time", "29") === false); var_dump(ini_get("max_execution_time")); ?> --EXPECTF-- -Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value out of range in %a/ini_min_policy_drop.php on line 2%A +Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value 29 for `max_execution_time` out of range in %a/ini_min_policy_drop.php on line 2%A diff --git a/src/tests/ini/ini_minmax.phpt b/src/tests/ini/ini_minmax.phpt index facb73e..10c15a4 100644 --- a/src/tests/ini/ini_minmax.phpt +++ b/src/tests/ini/ini_minmax.phpt @@ -25,10 +25,10 @@ string(2) "30" bool(false) string(3) "300" -Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 8 +Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value 29 for `max_execution_time` out of range in %a/ini_minmax.php on line 8 bool(true) string(3) "300" -Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 11 +Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value 301 for `max_execution_time` out of range in %a/ini_minmax.php on line 11 bool(true) string(3) "300"%A diff --git a/src/tests/ini/ini_null.phpt b/src/tests/ini/ini_null.phpt index dfc2555..0835222 100644 --- a/src/tests/ini/ini_null.phpt +++ b/src/tests/ini/ini_null.phpt @@ -21,6 +21,6 @@ string(15) "foo@example.com" bool(false) string(0) "" -Warning: [snuffleupagus][0.0.0.0][ini_protection][log] new INI value must not be NULL or empty in %a/ini_null.php on line 8 +Warning: [snuffleupagus][0.0.0.0][ini_protection][log] new INI value for `unserialize_callback_func` must not be NULL or empty in %a/ini_null.php on line 8 bool(true) string(3) "def"%A diff --git a/src/tests/ini/ini_regexp.phpt b/src/tests/ini/ini_regexp.phpt index c7cab35..3d2156c 100644 --- a/src/tests/ini/ini_regexp.phpt +++ b/src/tests/ini/ini_regexp.phpt @@ -15,5 +15,5 @@ var_dump(ini_get("highlight.comment")); --EXPECTF-- string(7) "#000aBc" -Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value does not match regex in %a/ini_regexp.php on line 5 +Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value `xxx` for `highlight.comment` does not match regex in %a/ini_regexp.php on line 5 string(7) "#000aBc"%A diff --git a/src/tests/ini/ini_regexp_drop.phpt b/src/tests/ini/ini_regexp_drop.phpt index 432be8d..134e5c3 100644 --- a/src/tests/ini/ini_regexp_drop.phpt +++ b/src/tests/ini/ini_regexp_drop.phpt @@ -10,4 +10,4 @@ var_dump(ini_set("user_agent", "Foo") === false); var_dump(ini_get("user_agent")); ?> --EXPECTF-- -Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value does not match regex in %a/ini_regexp_drop.php on line 2%A%A%A%A +Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value `Foo` for `user_agent` does not match regex in %a/ini_regexp_drop.php on line 2%A%A%A%A diff --git a/src/tests/ini/ini_regexp_drop_base64.phpt b/src/tests/ini/ini_regexp_drop_base64.phpt new file mode 100644 index 0000000..32076d5 --- /dev/null +++ b/src/tests/ini/ini_regexp_drop_base64.phpt @@ -0,0 +1,13 @@ +--TEST-- +INI protection .min() + .drop(), log base64 +--SKIPIF-- + +--INI-- +sp.configuration_file={PWD}/config/sp.ini +--FILE-- + +--EXPECTF-- +Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value `Rm9vCg0=`(base64) for `user_agent` does not match regex in %a/ini_regexp_drop_base64.php on line 2%A%A%A%A -- cgit v1.3