diff options
| author | xXx-caillou-xXx | 2018-08-29 18:09:51 +0200 |
|---|---|---|
| committer | jvoisin | 2018-08-29 16:09:51 +0000 |
| commit | 89e859d09248de6b1b9b9cdd652cb72c9f7ff098 (patch) | |
| tree | f24c9e82da5bede181607903fb4e98f59210a057 /src/tests | |
| parent | 10552296658a87e59b60a20214fef1902320d390 (diff) | |
Change how we're validating certificates
Diffstat (limited to 'src/tests')
9 files changed, 134 insertions, 37 deletions
diff --git a/src/tests/config/disabled_function_curl_verify_certs.ini b/src/tests/config/disabled_function_curl_verify_certs.ini index 64d54a7..133e024 100644 --- a/src/tests/config/disabled_function_curl_verify_certs.ini +++ b/src/tests/config/disabled_function_curl_verify_certs.ini | |||
| @@ -1 +1,18 @@ | |||
| 1 | sp.curl_verify_certificates.enable(); | 1 | # `81` being SSL_VERIFYHOST, and `64` SSL_VERIFYPEER |
| 2 | |||
| 3 | sp.disable_function.function("curl_setopt").param("value").value("1").allow(); | ||
| 4 | sp.disable_function.function("curl_setopt").param("value").value("2").allow(); | ||
| 5 | sp.disable_function.function("curl_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 6 | sp.disable_function.function("curl_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
| 7 | |||
| 8 | # --- | ||
| 9 | |||
| 10 | sp.disable_function.function("curl_setopt_array").param("options[CURLOPT_SSL_VERIFYHOST]").value("0").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 11 | sp.disable_function.function("curl_setopt_array").param("options[CURLOPT_SSL_VERIFYPEER]").value("0").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
| 12 | |||
| 13 | # --- | ||
| 14 | |||
| 15 | sp.disable_function.function("curl_multi_setopt").param("value").value("1").allow(); | ||
| 16 | sp.disable_function.function("curl_multi_setopt").param("value").value("2").allow(); | ||
| 17 | sp.disable_function.function("curl_multi_setopt").param("option").value("81").drop().alias("Please don't turn CURLOPT_SSL_VERIFYHOST off."); | ||
| 18 | sp.disable_function.function("curl_multi_setopt").param("option").value("64").drop().alias("Please don't turn CURLOPT_SSL_VERIFYPEER off."); | ||
diff --git a/src/tests/disabled_function_ensure_client_valid_certs.phpt b/src/tests/disabled_function_ensure_client_valid_certs.phpt new file mode 100644 index 0000000..374ee42 --- /dev/null +++ b/src/tests/disabled_function_ensure_client_valid_certs.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt', because its argument '$option' content (64) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/tests/disabled_function_ensure_client_valid_certs.php on line %d | ||
diff --git a/src/tests/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt b/src/tests/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt new file mode 100644 index 0000000..fd4d176 --- /dev/null +++ b/src/tests/disabled_function_ensure_client_valid_certs_curl_multi_setopt.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled via `curl_multi_setopt` | ||
| 3 | --EXTENSIONS-- | ||
| 4 | curl | ||
| 5 | --SKIPIF-- | ||
| 6 | <?php | ||
| 7 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 8 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 9 | ?> | ||
| 10 | --INI-- | ||
| 11 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 12 | --FILE-- | ||
| 13 | <?php | ||
| 14 | $mch = curl_multi_init(); | ||
| 15 | curl_multi_setopt($mch, CURLOPT_SSL_VERIFYPEER, 0); | ||
| 16 | echo "1337"; | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_multi_setopt', because its argument '$option' content (64) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/tests/disabled_function_ensure_client_valid_certs_curl_multi_setopt.php on line %d | ||
diff --git a/src/tests/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt b/src/tests/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt new file mode 100644 index 0000000..ce6a585 --- /dev/null +++ b/src/tests/disabled_function_ensure_client_valid_certs_curl_setopt_array.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled via `curl_setopt_array` | ||
| 3 | --EXTENSIONS-- | ||
| 4 | curl | ||
| 5 | --SKIPIF-- | ||
| 6 | <?php | ||
| 7 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 8 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 9 | ?> | ||
| 10 | --INI-- | ||
| 11 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 12 | --FILE-- | ||
| 13 | <?php | ||
| 14 | $ch = curl_init(); | ||
| 15 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 16 | $options = array(CURLOPT_SSL_VERIFYPEER => 0); | ||
| 17 | curl_setopt_array($ch, $options); | ||
| 18 | echo "1337"; | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt_array', because its argument '$options' content (0) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYPEER off.' in %s/tests/disabled_function_ensure_client_valid_certs_curl_setopt_array.php on line 5 | ||
diff --git a/src/tests/disabled_function_ensure_server_valid_certs.phpt b/src/tests/disabled_function_ensure_server_valid_certs.phpt new file mode 100644 index 0000000..01a4406 --- /dev/null +++ b/src/tests/disabled_function_ensure_server_valid_certs.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 6 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt', because its argument '$option' content (81) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/tests/disabled_function_ensure_server_valid_certs.php on line %d | ||
diff --git a/src/tests/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt b/src/tests/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt new file mode 100644 index 0000000..add2a18 --- /dev/null +++ b/src/tests/disabled_function_ensure_server_valid_certs_curl_multi_setopt.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled via `curl_multi_setopt` | ||
| 3 | --EXTENSIONS-- | ||
| 4 | curl | ||
| 5 | --SKIPIF-- | ||
| 6 | <?php | ||
| 7 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 8 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 9 | ?> | ||
| 10 | --INI-- | ||
| 11 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 12 | --FILE-- | ||
| 13 | <?php | ||
| 14 | $mch = curl_multi_init(); | ||
| 15 | curl_multi_setopt($mch, CURLOPT_SSL_VERIFYHOST, 0); | ||
| 16 | echo "1337"; | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_multi_setopt', because its argument '$option' content (81) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/tests/disabled_function_ensure_server_valid_certs_curl_multi_setopt.php on line %d | ||
diff --git a/src/tests/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt b/src/tests/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt new file mode 100644 index 0000000..3345797 --- /dev/null +++ b/src/tests/disabled_function_ensure_server_valid_certs_curl_setopt_array.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled via `curl_setopt_array` | ||
| 3 | --EXTENSIONS-- | ||
| 4 | curl | ||
| 5 | --SKIPIF-- | ||
| 6 | <?php | ||
| 7 | if (!extension_loaded("snuffleupagus")) { die("skip"); } | ||
| 8 | if (!extension_loaded("curl")) { die("skip"); } | ||
| 9 | ?> | ||
| 10 | --INI-- | ||
| 11 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 12 | --FILE-- | ||
| 13 | <?php | ||
| 14 | $ch = curl_init(); | ||
| 15 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 16 | $options = array(CURLOPT_SSL_VERIFYHOST => 0); | ||
| 17 | curl_setopt_array($ch, $options); | ||
| 18 | echo "1337"; | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'curl_setopt_array', because its argument '$options' content (0) matched the rule 'Please don't turn CURLOPT_SSL_VERIFYHOST off.' in %s/tests/disabled_function_ensure_server_valid_certs_curl_setopt_array.php on line 5 | ||
diff --git a/src/tests/ensure_client_valid_certs.phpt b/src/tests/ensure_client_valid_certs.phpt deleted file mode 100644 index 64c523c..0000000 --- a/src/tests/ensure_client_valid_certs.phpt +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that client certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) die "skip"; | ||
| 6 | if (!extension_loaded("curl")) die "skip"; | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][verify_vertificates] Please don't deactivate client certificate validation in %s/tests/ensure_client_valid_certs.php on line %d | ||
diff --git a/src/tests/ensure_server_valid_certs.phpt b/src/tests/ensure_server_valid_certs.phpt deleted file mode 100644 index 7eaf1a4..0000000 --- a/src/tests/ensure_server_valid_certs.phpt +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - Ensure that server certificates validation can't be disabled | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) die "skip"; | ||
| 6 | if (!extension_loaded("curl")) die "skip"; | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disabled_function_curl_verify_certs.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $ch = curl_init(); | ||
| 13 | curl_setopt($ch, CURLOPT_VERBOSE, '1'); | ||
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '0'); | ||
| 15 | echo "1337"; | ||
| 16 | ?> | ||
| 17 | --EXPECTF-- | ||
| 18 | Fatal error: [snuffleupagus][verify_vertificates] Please don't deactivate client certificate validation in %s/tests/ensure_server_valid_certs.php on line 3 | ||
