summaryrefslogtreecommitdiff
path: root/src/tests/session_encryption
diff options
context:
space:
mode:
authorjvoisin2022-03-20 18:20:45 +0100
committerjvoisin2022-03-20 18:20:45 +0100
commit81dd7f2ef07af306fe83d7755cbac4529aa9fc8d (patch)
tree32cc44c6231b30db5ac7b15699297863460784aa /src/tests/session_encryption
parent83b01942dfc80474cc05e09aeef4b44307a7120b (diff)
parentc38df1077a6c1dfbca1baca049214d053e2e7684 (diff)
Merge remote-tracking branch 'sektioneins/master'
Diffstat (limited to 'src/tests/session_encryption')
-rw-r--r--src/tests/session_encryption/config/config_crypt_session.ini2
-rw-r--r--src/tests/session_encryption/config/config_crypt_session_simul.ini2
-rw-r--r--src/tests/session_encryption/crypt_session_corrupted_session.phpt9
-rw-r--r--src/tests/session_encryption/crypt_session_invalid.phpt5
-rw-r--r--src/tests/session_encryption/crypt_session_invalid_simul.phpt15
-rw-r--r--src/tests/session_encryption/crypt_session_read_uncrypt.phpt19
-rw-r--r--src/tests/session_encryption/crypt_session_valid.phpt3
-rw-r--r--src/tests/session_encryption/crypt_session_valid_simul.phpt3
-rw-r--r--src/tests/session_encryption/set_custom_session_handler.phpt5
-rw-r--r--src/tests/session_encryption/set_custom_session_handler2.phpt5
-rw-r--r--src/tests/session_encryption/set_custom_session_handler_ini.phpt3
11 files changed, 52 insertions, 19 deletions
diff --git a/src/tests/session_encryption/config/config_crypt_session.ini b/src/tests/session_encryption/config/config_crypt_session.ini
index 14b0c2c..054f0f8 100644
--- a/src/tests/session_encryption/config/config_crypt_session.ini
+++ b/src/tests/session_encryption/config/config_crypt_session.ini
@@ -1,2 +1,2 @@
1sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); 1sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR");
2sp.session.encrypt(); \ No newline at end of file 2sp.session.encrypt(); \ No newline at end of file
diff --git a/src/tests/session_encryption/config/config_crypt_session_simul.ini b/src/tests/session_encryption/config/config_crypt_session_simul.ini
index fbd43eb..5e3433b 100644
--- a/src/tests/session_encryption/config/config_crypt_session_simul.ini
+++ b/src/tests/session_encryption/config/config_crypt_session_simul.ini
@@ -1,3 +1,3 @@
1sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); 1sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR");
2sp.session.encrypt(); 2sp.session.encrypt();
3sp.session.simulation(); \ No newline at end of file 3sp.session.simulation(); \ No newline at end of file
diff --git a/src/tests/session_encryption/crypt_session_corrupted_session.phpt b/src/tests/session_encryption/crypt_session_corrupted_session.phpt
index a97dbca..eca43b4 100644
--- a/src/tests/session_encryption/crypt_session_corrupted_session.phpt
+++ b/src/tests/session_encryption/crypt_session_corrupted_session.phpt
@@ -2,11 +2,12 @@
2Set a custom session handler 2Set 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"; ?> 5<?php if (!extension_loaded("session")) print "skip"; ?>
6<?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> 6--EXTENSIONS--
7session
7--INI-- 8--INI--
8sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
9session.save_path = "/tmp" 10session.save_path="/tmp"
10--ENV-- 11--ENV--
11return <<<EOF 12return <<<EOF
12REMOTE_ADDR=127.0.0.1 13REMOTE_ADDR=127.0.0.1
@@ -29,4 +30,4 @@ session_start();
29var_dump($_SESSION); 30var_dump($_SESSION);
30?> 31?>
31--EXPECTF-- 32--EXPECTF--
32Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s 33Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s
diff --git a/src/tests/session_encryption/crypt_session_invalid.phpt b/src/tests/session_encryption/crypt_session_invalid.phpt
index 967d9d1..a71a601 100644
--- a/src/tests/session_encryption/crypt_session_invalid.phpt
+++ b/src/tests/session_encryption/crypt_session_invalid.phpt
@@ -2,8 +2,9 @@
2SESSION crypt and bad decrypt 2SESSION 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"; ?> 5<?php if (!extension_loaded("session")) print "skip"; ?>
6<?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> 6--EXTENSIONS--
7session
7--INI-- 8--INI--
8sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
9--ENV-- 10--ENV--
diff --git a/src/tests/session_encryption/crypt_session_invalid_simul.phpt b/src/tests/session_encryption/crypt_session_invalid_simul.phpt
index cbb80dc..3eb619c 100644
--- a/src/tests/session_encryption/crypt_session_invalid_simul.phpt
+++ b/src/tests/session_encryption/crypt_session_invalid_simul.phpt
@@ -2,8 +2,14 @@
2SESSION crypt and bad decrypt 2SESSION 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 (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini 9sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
10display_errors=0
11log_errors=1
12error_log="{PWD}"/crypt_session_invalid_simul.tmp
7--ENV-- 13--ENV--
8return <<<EOF 14return <<<EOF
9REMOTE_ADDR=127.0.0.1 15REMOTE_ADDR=127.0.0.1
@@ -19,9 +25,12 @@ putenv("REMOTE_ADDR=127.0.0.2");
19session_id($id); // Recover the session with the previous session_id 25session_id($id); // Recover the session with the previous session_id
20session_start(); // Re start the session, It will read and decrypt the non empty session 26session_start(); // Re start the session, It will read and decrypt the non empty session
21var_dump($_SESSION); // Dump the session 27var_dump($_SESSION); // Dump the session
28
29echo file_get_contents(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
30unlink(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
31
22?> 32?>
23--EXPECTF-- 33--EXPECTF--
24array(1) { 34array(0) {
25 ["toto"]=>
26 string(4) "tata"
27} 35}
36%sPHP Warning: [snuffleupagus][127.0.0.2][cookie_encryption][simulation] Something went wrong with the decryption of the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_invalid_simul.php on line 9%A \ No newline at end of file
diff --git a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
index 5e81b52..5966f8e 100644
--- a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
+++ b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
@@ -2,27 +2,33 @@
2SESSION crypt/decrypt valid 2SESSION crypt/decrypt valid
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5<?php if (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini 9sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
10session.save_path="{PWD}"
11display_errors=0
12log_errors=1
13error_log="{PWD}"/crypt_session_read_uncrypt.tmp
7--ENV-- 14--ENV--
8return <<<EOF 15return <<<EOF
9REMOTE_ADDR=127.0.0.1 16REMOTE_ADDR=127.0.0.1
10EOF; 17EOF;
11--FILE-- 18--FILE--
12<?php 19<?php
13$current_path = dirname(getcwd()) . "/src/tests/" ;
14ini_set("session.save_path", $current_path);
15
16session_start(); 20session_start();
17$id = session_id(); // Get the session_id to use it later 21$id = session_id(); // Get the session_id to use it later
18$filename_sess = $current_path . "sess_" . $id; 22$filename_sess = dirname(__FILE__) . "/sess_" . $id;
19file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write a unencrypted session 23file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write unencrypted session
20session_write_close(); // Close the session 24session_write_close(); // Close the session
21 25
22session_id($id); 26session_id($id);
23session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session 27session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session
24var_dump($_SESSION); 28var_dump($_SESSION);
25echo "OK"; 29echo "OK\n";
30echo file_get_contents(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp");
31unlink(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp");
26unlink($filename_sess); 32unlink($filename_sess);
27?> 33?>
28--EXPECTF-- 34--EXPECTF--
@@ -31,3 +37,4 @@ array(1) {
31 string(4) "tata" 37 string(4) "tata"
32} 38}
33OK 39OK
40%aPHP Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_read_uncrypt.php on line 9
diff --git a/src/tests/session_encryption/crypt_session_valid.phpt b/src/tests/session_encryption/crypt_session_valid.phpt
index c272486..a28685b 100644
--- a/src/tests/session_encryption/crypt_session_valid.phpt
+++ b/src/tests/session_encryption/crypt_session_valid.phpt
@@ -2,6 +2,9 @@
2SESSION crypt/decrypt valid 2SESSION crypt/decrypt valid
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5<?php if (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
7--ENV-- 10--ENV--
diff --git a/src/tests/session_encryption/crypt_session_valid_simul.phpt b/src/tests/session_encryption/crypt_session_valid_simul.phpt
index d63277d..6af015e 100644
--- a/src/tests/session_encryption/crypt_session_valid_simul.phpt
+++ b/src/tests/session_encryption/crypt_session_valid_simul.phpt
@@ -2,6 +2,9 @@
2SESSION crypt/decrypt valid 2SESSION crypt/decrypt valid
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5<?php if (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini 9sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
7--ENV-- 10--ENV--
diff --git a/src/tests/session_encryption/set_custom_session_handler.phpt b/src/tests/session_encryption/set_custom_session_handler.phpt
index 725ee43..04edcd0 100644
--- a/src/tests/session_encryption/set_custom_session_handler.phpt
+++ b/src/tests/session_encryption/set_custom_session_handler.phpt
@@ -2,9 +2,12 @@
2Set a custom session handler 2Set 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 (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
7session.save_path = "/tmp" 10session.save_path="/tmp"
8--ENV-- 11--ENV--
9return <<<EOF 12return <<<EOF
10REMOTE_ADDR=127.0.0.1 13REMOTE_ADDR=127.0.0.1
diff --git a/src/tests/session_encryption/set_custom_session_handler2.phpt b/src/tests/session_encryption/set_custom_session_handler2.phpt
index 8cc6786..0ebf7b6 100644
--- a/src/tests/session_encryption/set_custom_session_handler2.phpt
+++ b/src/tests/session_encryption/set_custom_session_handler2.phpt
@@ -2,9 +2,12 @@
2Set a custom session handler, twice 2Set a custom session handler, twice
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5<?php if (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
7session.save_path = "/tmp" 10session.save_path="/tmp"
8--ENV-- 11--ENV--
9return <<<EOF 12return <<<EOF
10REMOTE_ADDR=127.0.0.1 13REMOTE_ADDR=127.0.0.1
diff --git a/src/tests/session_encryption/set_custom_session_handler_ini.phpt b/src/tests/session_encryption/set_custom_session_handler_ini.phpt
index f9fbfb2..a454fc6 100644
--- a/src/tests/session_encryption/set_custom_session_handler_ini.phpt
+++ b/src/tests/session_encryption/set_custom_session_handler_ini.phpt
@@ -2,6 +2,9 @@
2Set a custom session handler 2Set 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 (!extension_loaded("session")) print "skip"; ?>
6--EXTENSIONS--
7session
5--INI-- 8--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 9sp.configuration_file={PWD}/config/config_crypt_session.ini
7session.save_handler = 10session.save_handler =