diff options
| author | Ben Fuhrmannek | 2021-08-02 10:42:12 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-08-02 10:42:12 +0200 |
| commit | 4cda0120313dfd5d71236f6faf87416e93f5f89c (patch) | |
| tree | 0c2c6d15e8ac5287fb3304f96de719547d9e847a /src/tests | |
| parent | 6c132e6a1d8d339a20282afb5a4af52eb6bce9db (diff) | |
| parent | e62f226c3ed885808c832040872fc2d73ca46dac (diff) | |
Merge branch 'master' of https://github.com/jvoisin/snuffleupagus
Diffstat (limited to 'src/tests')
12 files changed, 65 insertions, 1 deletions
diff --git a/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt b/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt index ac85dea..45ccf24 100644 --- a/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt +++ b/src/tests/broken_configuration/broken_conf_config_invalid_param.phpt | |||
| @@ -13,4 +13,10 @@ function foo($blah, $x = null, $y = null) { | |||
| 13 | foo("qwe"); | 13 | foo("qwe"); |
| 14 | --EXPECTF-- | 14 | --EXPECTF-- |
| 15 | Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you are filtering on a parameter 'qwe' of the function 'foo', but the parameter does not exists. in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d | 15 | Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you are filtering on a parameter 'qwe' of the function 'foo', but the parameter does not exists. in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d |
| 16 | |||
| 17 | Warning: [snuffleupagus][0.0.0.0][config][log] - 0 parameter's name: 'blah' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d | ||
| 18 | |||
| 19 | Warning: [snuffleupagus][0.0.0.0][config][log] - 1 parameter's name: 'x' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d | ||
| 20 | |||
| 21 | Warning: [snuffleupagus][0.0.0.0][config][log] - 2 parameter's name: 'y' in %s/tests/broken_configuration/broken_conf_config_invalid_param.php on line %d | ||
| 16 | ok | 22 | ok |
diff --git a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt index 046dc7d..62ee41e 100644 --- a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt +++ b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt | |||
| @@ -6,6 +6,7 @@ Broken configuration - encrypted session without encryption key | |||
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_encryption_key.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_encryption_key.ini |
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --XFAIL-- | ||
| 9 | --EXPECT-- | 10 | --EXPECT-- |
| 10 | 11 | ||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in`sp.global`: please set it first in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in`sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt index bb0f212..5acc1cd 100644 --- a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt +++ b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt | |||
| @@ -6,6 +6,7 @@ Broken configuration - encrypted session without env var | |||
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_env_var.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_env_var.ini |
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --XFAIL-- | ||
| 9 | --EXPECT-- | 10 | --EXPECT-- |
| 10 | 11 | ||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/deny_writable/deny_writable_execution_simulation.phpt b/src/tests/deny_writable/deny_writable_execution_simulation.phpt index 30f8cb1..d4b8efc 100644 --- a/src/tests/deny_writable/deny_writable_execution_simulation.phpt +++ b/src/tests/deny_writable/deny_writable_execution_simulation.phpt | |||
| @@ -3,7 +3,7 @@ Readonly execution attempt (simulation mode) | |||
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> |
| 5 | <?php | 5 | <?php |
| 6 | if (!extension_loaded("snuffleupagus")) { print "skip" }; | 6 | if (!extension_loaded("snuffleupagus")) { print "skip"; }; |
| 7 | 7 | ||
| 8 | // root has write privileges on any file | 8 | // root has write privileges on any file |
| 9 | if (TRUE == function_exists("posix_getuid")) { | 9 | if (TRUE == function_exists("posix_getuid")) { |
diff --git a/src/tests/disable_function/config/disabled_functions.ini b/src/tests/disable_function/config/disabled_functions.ini index df7013f..0758c98 100644 --- a/src/tests/disable_function/config/disabled_functions.ini +++ b/src/tests/disable_function/config/disabled_functions.ini | |||
| @@ -7,3 +7,4 @@ sp.disable_function.function_r("^var_dump$").drop(); | |||
| 7 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); | 7 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); |
| 8 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); | 8 | sp.disable_function.function("sprintf").filename("/wrong file name").drop(); |
| 9 | sp.disable_function.function("eval").drop(); | 9 | sp.disable_function.function("eval").drop(); |
| 10 | sp.disable_function.function("shell_exec").param("foo").value("bar").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_chmod.ini b/src/tests/disable_function/config/disabled_functions_chmod.ini new file mode 100644 index 0000000..e601900 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_chmod.ini | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | # PHP7 and below | ||
| 2 | sp.disable_function.function("chmod").param("mode").value("511").drop(); | ||
| 3 | # PHP8 | ||
| 4 | sp.disable_function.function("chmod").param("permissions").value("511").drop(); | ||
diff --git a/src/tests/disable_function/disabled_functions_chmod.phpt b/src/tests/disable_function/disabled_functions_chmod.phpt new file mode 100644 index 0000000..28f948d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chmod.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - chmod | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_chmod.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | chmod( 'foo', 0777 ); | ||
| 11 | ?> | ||
| 12 | --XFAIL-- | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$mode' content (511) matched a rule in %a/disabled_function_chmod.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_chmod_php8.phpt b/src/tests/disable_function/disabled_functions_chmod_php8.phpt new file mode 100644 index 0000000..71bb034 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_chmod_php8.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - chmod, in php8 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_chmod.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | chmod( 'foo', 0777 ); | ||
| 11 | ?> | ||
| 12 | --XFAIL-- | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$permissions' content (511) matched a rule in %a/disabled_function_chmod_php8.php on line %d | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_wrong.phpt b/src/tests/disable_function/disabled_functions_shell_exec_wrong.phpt new file mode 100644 index 0000000..fe8e73a --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_wrong.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec, with a non-existing command | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $gs = exec( 'foo' ); | ||
| 10 | echo "YES"; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | %snot found | ||
| 14 | YES | ||
diff --git a/src/tests/session_encryption/crypt_session_corrupted_session.phpt b/src/tests/session_encryption/crypt_session_corrupted_session.phpt index a89faf4..a97dbca 100644 --- a/src/tests/session_encryption/crypt_session_corrupted_session.phpt +++ b/src/tests/session_encryption/crypt_session_corrupted_session.phpt | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | ||
| 5 | --INI-- | 7 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_path = "/tmp" | 9 | session.save_path = "/tmp" |
diff --git a/src/tests/session_encryption/crypt_session_invalid.phpt b/src/tests/session_encryption/crypt_session_invalid.phpt index 9ec7c50..967d9d1 100644 --- a/src/tests/session_encryption/crypt_session_invalid.phpt +++ b/src/tests/session_encryption/crypt_session_invalid.phpt | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | SESSION crypt and bad decrypt | 2 | SESSION crypt and bad decrypt |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | ||
| 5 | --INI-- | 7 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | --ENV-- | 9 | --ENV-- |
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt index 493f5a3..a49e094 100644 --- a/src/tests/xxe/disable_xxe_dom_disabled.phpt +++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt | |||
| @@ -44,8 +44,13 @@ printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeVa | |||
| 44 | 44 | ||
| 45 | ?> | 45 | ?> |
| 46 | --EXPECTF-- | 46 | --EXPECTF-- |
| 47 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d | ||
| 47 | libxml_disable_entity to true: WARNING, external entity loaded! | 48 | libxml_disable_entity to true: WARNING, external entity loaded! |
| 49 | |||
| 50 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d | ||
| 48 | libxml_disable_entity to false: WARNING, external entity loaded! | 51 | libxml_disable_entity to false: WARNING, external entity loaded! |
| 52 | |||
| 53 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d | ||
| 49 | without xxe: foo | 54 | without xxe: foo |
| 50 | --CLEAN-- | 55 | --CLEAN-- |
| 51 | <?php | 56 | <?php |
