summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Esser2014-02-16 10:15:45 +0100
committerStefan Esser2014-02-16 10:15:45 +0100
commit2bf085a8d27a5b9a05a0164fcc0c1ea41e78c601 (patch)
treec6a0fe86a534c73e161d3dcc4d5772d1a9a24282
parentb14abbdf791ee28a540b1a047e697777e589e675 (diff)
Tests for suhosin.executor.include.allow_writable_files
-rw-r--r--tests/include/include_allow_writable_files_off.phpt31
-rw-r--r--tests/include/include_allow_writable_files_on.phpt29
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/include/include_allow_writable_files_off.phpt b/tests/include/include_allow_writable_files_off.phpt
new file mode 100644
index 0000000..3fb9e89
--- /dev/null
+++ b/tests/include/include_allow_writable_files_off.phpt
@@ -0,0 +1,31 @@
1--TEST--
2Testing suhosin.executor.include.allow_writable_files=Off
3--DESCRIPTION--
4Because the test file itself is writable the whole test case is not executed!!!
5--SKIPIF--
6<?php include "../skipifcli.inc"; ?>
7--INI--
8suhosin.log.syslog=0
9suhosin.log.sapi=255
10suhosin.log.script=0
11suhosin.log.phpscript=0
12suhosin.executor.include.whitelist=
13suhosin.executor.include.blacklist=
14suhosin.executor.include.allow_writable_files=Off
15--FILE--
16<?php
17/* Because the test file itself is writable the whole test case is not executed!!! */
18$filename1 = tempnam(sys_get_temp_dir(), "suhosintestf1");
19$filename2 = tempnam(sys_get_temp_dir(), "suhosintestf2");
20file_put_contents($filename1, "<?php echo \"AAAA\\n\";");
21file_put_contents($filename2, "<?php echo \"BBBB\\n\";");
22chmod($filename1, 0400);
23chmod($filename2, 0600);
24include $filename1;
25include $filename2;
26chmod($filename1, 0600);
27unlink($filename1);
28unlink($filename2);
29?>
30--EXPECTF--
31ALERT - Include filename ('%s') is writable by PHP process (attacker 'REMOTE_ADDR not set', file '%s')
diff --git a/tests/include/include_allow_writable_files_on.phpt b/tests/include/include_allow_writable_files_on.phpt
new file mode 100644
index 0000000..8770699
--- /dev/null
+++ b/tests/include/include_allow_writable_files_on.phpt
@@ -0,0 +1,29 @@
1--TEST--
2Testing suhosin.executor.include.allow_writable_files=On
3--SKIPIF--
4<?php include "../skipifcli.inc"; ?>
5--INI--
6suhosin.log.syslog=0
7suhosin.log.sapi=255
8suhosin.log.script=0
9suhosin.log.phpscript=0
10suhosin.executor.include.whitelist=
11suhosin.executor.include.blacklist=
12suhosin.executor.include.allow_writable_files=On
13--FILE--
14<?php
15$filename1 = tempnam(sys_get_temp_dir(), "suhosintestf1");
16$filename2 = tempnam(sys_get_temp_dir(), "suhosintestf2");
17file_put_contents($filename1, "<?php echo \"AAAA\\n\";");
18file_put_contents($filename2, "<?php echo \"BBBB\\n\";");
19chmod($filename1, 0400);
20chmod($filename2, 0600);
21include $filename1;
22include $filename2;
23chmod($filename1, 0600);
24unlink($filename1);
25unlink($filename2);
26?>
27--EXPECTF--
28AAAA
29BBBB