|
| 1 | +# encoding: utf-8 |
| 2 | +# Copyright 2015, Dominik Richter |
| 3 | +# License: Apache v2 |
| 4 | + |
| 5 | +require 'spec_helper' |
| 6 | + |
| 7 | +describe 'PHP config parameters' do |
| 8 | + # Some things we don't do: |
| 9 | + # * safe_mode |
| 10 | + # reason: deprecated |
| 11 | + # see: http://php.net/manual/de/features.safe-mode.php |
| 12 | + |
| 13 | + # Base configuration |
| 14 | + |
| 15 | + context php_config('open_basedir') do |
| 16 | + its(:value) { should eq '/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/' } |
| 17 | + end |
| 18 | + |
| 19 | + # Time / Memory Quota |
| 20 | + |
| 21 | + context php_config('max_execution_time') do |
| 22 | + its(:value) { should eq 30 } |
| 23 | + end |
| 24 | + |
| 25 | + context php_config('max_input_nesting_level') do |
| 26 | + its(:value) { should eq 64 } |
| 27 | + end |
| 28 | + |
| 29 | + context php_config('memory_limit') do |
| 30 | + its(:value) { should eq '128M' } |
| 31 | + end |
| 32 | + |
| 33 | + context php_config('post_max_size') do |
| 34 | + its(:value) { should eq '8M' } |
| 35 | + end |
| 36 | + |
| 37 | + # PHP Capabilities |
| 38 | + |
| 39 | + # TODO: do we have a recommended minimum-set? |
| 40 | + context php_config('disable_functions') do |
| 41 | + its(:value) { should eq 'php_uname, getmyuid, getmypid, passthru, leak, listen, diskfreespace, tmpfile, link, ignore_user_abord, shell_exec, dl, set_time_limit, exec, system, highlight_file, source, show_source, fpaththru, virtual, posix_ctermid, posix_getcwd, posix_getegid, posix_geteuid, posix_getgid, posix_getgrgid, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgid, posix_getpgrp, posix_getpid, posix, _getppid, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_getuid, posix_isatty, posix_kill, posix_mkfifo, posix_setegid, posix_seteuid, posix_setgid, posix_setpgid, posix_setsid, posix_setuid, posix_times, posix_ttyname, posix_uname, proc_open, proc_close, proc_get_status, proc_nice, proc_terminate, phpinfo' } |
| 42 | + end |
| 43 | + |
| 44 | + # TODO: do we have a recommended minimum-set? |
| 45 | + context php_config('disable_classes') do |
| 46 | + its(:value) { should eq '...' } |
| 47 | + end |
| 48 | + |
| 49 | + context php_config('register_globals') do |
| 50 | + its(:value) { should eq 'Off' } |
| 51 | + end |
| 52 | + |
| 53 | + context php_config('expose_php') do |
| 54 | + its(:value) { should eq 'Off' } |
| 55 | + end |
| 56 | + |
| 57 | + context php_config('enable_dl') do |
| 58 | + its(:value) { should eq 'Off' } |
| 59 | + end |
| 60 | + |
| 61 | + context php_config('default_charset') do |
| 62 | + its(:value) { should eq 'utf-8' } |
| 63 | + end |
| 64 | + |
| 65 | + context php_config('default_mimetype') do |
| 66 | + its(:value) { should eq 'text/html' } |
| 67 | + end |
| 68 | + |
| 69 | + # removed as of PHP5.4, so... |
| 70 | + # remove these test? |
| 71 | + context php_config('magic_quotes_gpc') do |
| 72 | + its(:value) { should eq nil} |
| 73 | + end |
| 74 | + context php_config('magic_quotes_sybase') do |
| 75 | + its(:value) { should eq nil} |
| 76 | + end |
| 77 | + |
| 78 | + # # removed // how to test this? |
| 79 | + # context php_config('magic_quotes_runtime') do |
| 80 | + # its(:value) { should eq 'Off'} |
| 81 | + # end |
| 82 | + |
| 83 | + # Upload / Open |
| 84 | + |
| 85 | + context php_config('allow_url_fopen') do |
| 86 | + its(:value) { should eq 'Off' } |
| 87 | + end |
| 88 | + |
| 89 | + context php_config('allow_url_include') do |
| 90 | + its(:value) { should eq 'Off' } |
| 91 | + end |
| 92 | + |
| 93 | + context php_config('file_uploads') do |
| 94 | + its(:value) { should eq 'Off' } |
| 95 | + end |
| 96 | + |
| 97 | + # Alternative: restrict upload maximum to prevent |
| 98 | + # system overload: |
| 99 | + # upload_tmp_dir = /var/php_tmp |
| 100 | + # upload_max_filezize = 10M |
| 101 | + |
| 102 | + # Log // Information Disclosure |
| 103 | + |
| 104 | + context php_config('display_errors') do |
| 105 | + its(:value) { should eq 'Off' } |
| 106 | + end |
| 107 | + |
| 108 | + context php_config('display_startup_errors') do |
| 109 | + its(:value) { should eq 'Off' } |
| 110 | + end |
| 111 | + |
| 112 | + context php_config('log_errors') do |
| 113 | + its(:value) { should eq 'On' } |
| 114 | + end |
| 115 | + |
| 116 | + # Session Handling |
| 117 | + |
| 118 | + context php_config('session.save_path') do |
| 119 | + its(:value) { should eq '/var/lib/php' } |
| 120 | + end |
| 121 | + |
| 122 | + context php_config('session.cookie_httponly') do |
| 123 | + its(:value) { should eq 1 } |
| 124 | + end |
| 125 | + |
| 126 | + # Mail |
| 127 | + |
| 128 | + context php_config('mail.add_x_header') do |
| 129 | + its(:value) { should eq 'Off' } |
| 130 | + |
| 131 | +end |
0 commit comments