dolibarr 23.0.3
security.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2022 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25// Load Dolibarr environment
26require '../../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
54require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
55
56// Load translation files required by the page
57$langs->loadLangs(array("install", "other", "admin", "errors", "website"));
58
59if (!$user->admin) {
61}
62
63if (GETPOST('action', 'aZ09') == 'donothing') {
64 exit;
65}
66
67$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1);
68
69
70/*
71 * View
72 */
73
74$form = new Form($db);
75
76llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_security');
77
78print load_fiche_titre($langs->trans("Security"), '', 'title_setup');
79
80print '<span class="opacitymedium">'.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').'</span>';
81print ' &nbsp; &nbsp; ';
82print '<a href="'.$_SERVER["PHP_SELF"].'">';
83print img_picto($langs->trans("Reload"), 'refresh').' ';
84print $langs->trans("Reload");
85print '</a>';
86print '<br>';
87print '<br>';
88
89
90print '<br>';
91
92
93print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder');
94
95
96print '<div class="divsection wordbreak">';
97
98// Get version of PHP
99$phpversion = version_php();
100print "<strong>PHP</strong>: ".$langs->trans("Version").": ".$phpversion;
101if (function_exists('php_ini_loaded_file')) {
102 $inipath = php_ini_loaded_file();
103 print " - <strong>INI</strong>: ".$inipath;
104}
105print "<br>\n";
106
107// Get version of web server
108print "<br><strong>Web server - ".$langs->trans("Version")."</strong>: ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
109print '<strong>'.$langs->trans("DataRootServer")."</strong>: ".DOL_DATA_ROOT."<br>\n";
110// Web user group by default
111$labeluser = dol_getwebuser('user');
112$labelgroup = dol_getwebuser('group');
113if ($labeluser && $labelgroup) {
114 print '<strong>'.$langs->trans("WebUserGroup")." (env vars)</strong> : ".$labeluser.':'.$labelgroup;
115 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
116 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
117 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span><br>'."\n";
118 }
119}
120// Web user group real (detected by 'id' external command)
121if (function_exists('exec')) {
122 $arrayout = array();
123 $varout = 0;
124 exec('id', $arrayout, $varout);
125 if (empty($varout)) { // Test command is ok. Work only on Linux OS.
126 print '<strong>'.$langs->trans("WebUserGroup")." (real, 'id' command)</strong> : ".implode(',', $arrayout)."<br>\n";
127 }
128}
129print '<br>';
130
131print (ini_get('session.use_strict_mode') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.use_strict_mode</strong> = ".(ini_get('session.use_strict_mode') ? ini_get('session.use_strict_mode') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
132print (ini_get('session.use_only_cookies') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.use_only_cookies</strong> = ".(ini_get('session.use_only_cookies') ? ini_get('session.use_only_cookies') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
133print (ini_get('session.cookie_httponly') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.cookie_httponly</strong> = ".(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
134print (ini_get('session.cookie_samesite') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None');
135if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') == 'Lax') {
136 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Lax').")</span>";
137} elseif (ini_get('session.cookie_samesite') == 'Strict') {
138 print ' &nbsp; '.img_warning().' <span class="opacitymedium">'.$langs->trans("WarningPaypalPaymentNotCompatibleWithStrict")."</span>";
139}
140print "<br>\n";
141
142print (ini_get('open_basedir') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP open_basedir</strong> = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").': '.$_SERVER["DOCUMENT_ROOT"].','.DOL_DATA_ROOT).')</span>')."<br>\n";
143
144print ((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? img_picto('', 'tick', 'class="pictofixedwidth"') : img_warning('', '', 'pictofixedwidth nopaddingleft'))."<strong>PHP short_open_tag</strong> = ".((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? yn(0) : yn(1)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).')</span>'."<br>\n";
145
146print (ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning', 'class="pictofixedwidth nopaddingleft"') : img_picto('', 'tick', 'class="pictofixedwidth"'))."<strong>PHP allow_url_fopen</strong> = ".(ini_get('allow_url_fopen') ? ini_get('allow_url_fopen') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).", except if Yes is required by some external modules)</span><br>\n";
147
148print (ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning', 'class="pictofixedwidth nopaddingleft"') : img_picto('', 'tick', 'class="pictofixedwidth"')). "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? ini_get('allow_url_include') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
149//print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' &nbsp; <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
150
151if (getDolGlobalString('MAIN_SECURITY_SHOW_MORE_INFO')) {
152 print "<strong>PHP auto_prepend_file</strong> = ".(ini_get('auto_prepend_file') ? ini_get('auto_prepend_file') : '')."</span><br>\n";
153
154 print "<strong>PHP sendmail_path</strong> = ".(ini_get('sendmail_path') ? ini_get('sendmail_path') : '')."</span><br>\n";
155}
156
157print '<br>';
158print "<strong>PHP disable_functions</strong>: ";
159// The original value is...
160$disablefunctionorign = '';
161$phparray = phpinfo_array();
162foreach ($phparray as $key => $value) {
163 foreach ($value as $keyparam => $keyvalue) {
164 if ($keyparam == 'disable_functions') {
165 if (!empty($keyvalue['master'])) {
166 $disablefunctionorign = $keyvalue['master'];
167 break;
168 }
169 }
170 }
171}
172/*
173if (empty($disablefunctionorign)) {
174 $disablefunctionorign = ini_get('disable_functions'); // Not always the real value
175}
176*/
177$arrayoffunctionsdisabled = explode(',', $disablefunctionorign);
178
179$arrayoffunctionstodisable = explode(',', 'dl,apache_note,apache_setenv,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,show_source,virtual');
180//$arrayoffunctionstodisable[] = 'stream_wrapper_restore';
181//$arrayoffunctionstodisable[] = 'stream_wrapper_register';
182if ($execmethod == 1) {
183 $arrayoffunctionstodisable2 = explode(',', 'passthru,shell_exec,system,proc_open,popen');
184 $functiontokeep = 'exec';
185} else {
186 $arrayoffunctionstodisable2 = explode(',', 'exec,passthru,shell_exec,system,proc_open');
187 $functiontokeep = 'popen';
188}
189$i = 0;
190foreach ($arrayoffunctionsdisabled as $functionkey) {
191 if ($i > 0) {
192 print ', ';
193 }
194 print '<span class="opacitymedium">'.$functionkey.'</span>';
195 $i++;
196}
197print "<br>\n";
198$todisabletext = '';
199$i = 0;
200foreach ($arrayoffunctionstodisable as $functiontodisable) {
201 if (\function_exists($functiontodisable)) {
202 if ($i > 0) {
203 $todisabletext .= ', ';
204 }
205 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
206 $i++;
207 }
208}
209if ($todisabletext) {
210 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"').$langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
211 print '<br>';
212}
213$todisabletext = '';
214$i = 0;
215foreach ($arrayoffunctionstodisable2 as $functiontodisable) {
216 if (\function_exists($functiontodisable)) {
217 if ($i > 0) {
218 $todisabletext .= ', ';
219 }
220 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
221 $i++;
222 }
223}
224if ($todisabletext) {
225 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"').$langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
226 print '<br>';
227}
228if (!function_exists($functiontokeep)) {
229 print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning', 'class="pictofixedwidth"');
230} else {
231 print img_picto('', 'tick', 'class="pictofixedwidth"');
232}
233print $langs->trans("PHPFunctionsRequiredForCLI").': ';
234print '<span class="opacitymedium" title="exec or popen can be used depending on MAIN_EXEC_USE_POPEN option, currently to '.getDolGlobalInt('MAIN_EXEC_USE_POPEN').'">'.$functiontokeep.'</span>';
235print '<br>';
236
237print '<br>';
238
239// JSON
240$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
241$test = !in_array('json', $loadedExtensions);
242if ($test || function_exists('dol_json_decode')) {
243 print img_picto('', 'error', 'class="pictofixedwidth nopaddingleft"');
244} else {
245 print img_picto('', 'tick', 'class="pictofixedwidth"');
246}
247print '<strong>JSON</strong>: ';
248if ($test || function_exists('dol_json_decode')) {
249 print $langs->trans("NotInstalled").' - '.$langs->trans("VulnerableToRCEAttack");
250} else {
251 print $langs->trans("Available").' <span class="opacitymedium">(PHP native so not emulated, safe)</span>';
252}
253print '<br>';
254
255// XDebug
256$test = !function_exists('xdebug_is_enabled') && !extension_loaded('xdebug');
257if ($test) {
258 print img_picto('', 'tick', 'class="pictofixedwidth"');
259} else {
260 print img_picto('', 'warning', 'class="pictofixedwidth nopaddingleft"');
261}
262print '<strong>XDebug</strong>: ';
263if ($test) {
264 print $langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
265} else {
266 print $langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug"));
267 print ' - '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php">XDebug admin page</a>';
268}
269
270print '</div>';
271
272print '<br>';
273
274
275// OS Setup - Permissions on files
276
277print '<br>';
278print load_fiche_titre($langs->trans("OSSetup").' - '.$langs->trans("PermissionsOnFiles"), '', 'folder');
279
280print '<div class="divsection wordbreak">';
281
282print '<strong>'.$langs->trans("PermissionsOnFilesInWebRoot").'</strong>: ';
283$arrayoffilesinroot = dol_dir_list(DOL_DOCUMENT_ROOT, 'all', 1, '', array('\/custom'), 'name', SORT_ASC, 4, 1, '', 1);
284$fileswithwritepermission = array();
285foreach ($arrayoffilesinroot as $fileinroot) {
286 // Test if there is at least one write permission file. If yes, add the entry into array $fileswithwritepermission
287 if (isset($fileinroot['perm']) && ($fileinroot['perm'] & 0222)) {
288 $fileswithwritepermission[] = $fileinroot['relativename'];
289 }
290}
291if (empty($fileswithwritepermission)) {
292 print img_picto('', 'tick').' '.$langs->trans("NoWritableFilesFoundIntoRootDir");
293} else {
294 print img_warning().' '.$langs->trans("SomeFilesOrDirInRootAreWritable");
295 print ' &nbsp; - &nbsp; <span class="classlink cursorpointer" onclick="javascript: console.log(\'Toggle examples\'); jQuery(\'#examplewritablefiles\').toggle();">'.$langs->trans("Examples").'</span>';
296 print '<span id="examplewritablefiles" class="hideobject"><br>'.$langs->trans("Example").': ';
297 $i = 0;
298 foreach ($fileswithwritepermission as $filewithwritepermission) {
299 if ($i > 0) {
300 print ', ';
301 }
302 print '<span class="opacitymedium">'.$filewithwritepermission.'</span>';
303 if ($i > 20) {
304 print ' ...';
305 break;
306 }
307 $i++;
308 }
309 print '</span>';
310}
311print '<br>';
312print '<br>';
313
314print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: '; // $conffile is defined into filefunc.inc.php
315$perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
316if ($perms) {
317 if (($perms & 0x0004) || ($perms & 0x0002)) {
318 print img_warning().' '.$langs->trans("ConfFileIsReadableOrWritableByAnyUsers");
319 // Web user group by default
320 $labeluser = dol_getwebuser('user');
321 $labelgroup = dol_getwebuser('group');
322 print ' '.$langs->trans("User").': '.$labeluser.':'.$labelgroup;
323 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
324 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
325 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span>';
326 }
327 } else {
328 print img_picto('', 'tick');
329 }
330} else {
331 print img_warning().' '.$langs->trans("FailedToReadFile", $conffile);
332}
333print '<br>';
334print '<br>';
335
336$installlock = DOL_DATA_ROOT.'/install.lock';
337$upgradeunlock = DOL_DATA_ROOT.'/upgrade.unlock';
338$installmoduleslock = DOL_DATA_ROOT.'/installmodules.lock';
339
340// Is install (upgrade) locked
341$test = file_exists($installlock);
342print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
343if ($test) {
344 if (file_exists($upgradeunlock)) {
345 print img_picto('', 'tick').' '.$langs->trans("InstallLockedBy", $installlock);
346 } else {
347 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
348 }
349} else {
350 print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
351}
352
353print '<br>';
354print '<br>';
355
356// Is upgrade unlocked
357if (file_exists($installlock)) { // If install not locked, no need to show this.
358 if (file_exists($upgradeunlock)) {
359 print '<strong>'.$langs->trans("DolibarrUpgrade").'</strong>: ';
360 print img_warning().' '.$langs->trans("WarningUpgradeHasBeenUnlocked", $upgradeunlock);
361 print '<br>';
362 print '<br>';
363 }
364}
365
366// Is addon install locked ?
367$test = file_exists($installmoduleslock);
368print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
369if ($test) {
370 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
371} else {
372 print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
373}
374
375print '</div>';
376
377
378
379// File conf.php
380
381print '<br>';
382print '<br>';
383print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffile.')', '', 'folder');
384
385print '<div class="divsection wordbreak">';
386print '<strong>$dolibarr_main_prod</strong>: '.($dolibarr_main_prod ? $dolibarr_main_prod : '0');
387if (empty($dolibarr_main_prod)) {
388 print ' &nbsp; &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1);
389}
390print '<br>';
391
392if (!empty($dolibarr_nocsrfcheck)) {
393 print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
394 print ' &nbsp; &nbsp;'.img_picto('', 'error').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0);
395 print '<br>';
396}
397
398print '<strong>$dolibarr_main_restrict_ip</strong>: ';
399if (empty($dolibarr_main_restrict_ip)) {
400 print $langs->trans("None");
401 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("StaticIPsOfUsers")).')</span>';
402} else {
403 print $dolibarr_main_restrict_ip;
404}
405print '<br>';
406
407
408print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
409if (empty($dolibarr_main_restrict_os_commands)) {
410 print $langs->trans("None");
411} else {
412 print $dolibarr_main_restrict_os_commands;
413}
414print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mariadb-dump, mariadb, mysqldump, mysql, pg_dump, pg_restore, clamdscan').')</span>';
415print '<br>';
416
417
418print '<strong>$dolibarr_main_restrict_eval_methods</strong>: ';
419if (empty($dolibarr_main_restrict_eval_methods)) {
420 print $langs->trans("None");
421} else {
422 print $dolibarr_main_restrict_eval_methods;
423}
424print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'getDolGlobalString, getDolGlobalInt, getDolCurrency, getDolEntity, getDolDBType, fetchNoCompute, hasRight, isAdmin, isModEnabled, isStringVarMatching, abs, min, max, round, dol_now, dol_concat, preg_match').')</span>';
425print '<br>';
426
427
428print '<strong>$dolibarr_website_allow_custom_php</strong>: ';
429if (!empty($dolibarr_website_allow_custom_php) && $dolibarr_website_allow_custom_php == 2) {
430 print img_picto('', 'warning').' ';
431}
432if (empty($dolibarr_website_allow_custom_php)) {
433 print '0';
434} else {
435 print $dolibarr_website_allow_custom_php;
436}
437print ' &nbsp; &nbsp; <span class="opacitymedium">(';
438if (isModEnabled('website')) {
439 print $langs->trans("RecommendedValueIs", '0 if you don\'t include PHP in your websites, else 1');
440} else {
441 print $langs->trans("RecommendedValueIs", '0');
442}
443print ')</span>';
444print '<br>';
445
446
447if (!getDolGlobalString('SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF')) {
448 print '<strong>$dolibarr_main_db_pass</strong>: ';
449 if (!empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
450 print img_picto('', 'warning').' '.$langs->trans("DatabasePasswordNotObfuscated").' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("SetOptionTo", $langs->transnoentitiesnoconv("MainDbPasswordFileConfEncrypted"), yn(1)).')</span>';
451 //print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
452 } else {
453 print img_picto('', 'tick').' '.$langs->trans("DatabasePasswordObfuscated");
454 }
455
456 print '<br>';
457}
458
459print '<strong>$dolibarr_main_stream_to_disable</strong>: ';
460// $arrayofstreamtodisable is defined into filefunc.inc.php
461'@phan-var-force string[] $arrayofstreamtodisable';
462if (empty($dolibarr_main_stream_to_disable)) {
463 print '<span class="opacitymedium">'.$langs->trans("Undefined").' = '.implode(', ', $arrayofstreamtodisable).'</span>';
464} else {
465 print implode(', ', $dolibarr_main_stream_to_disable);
466}
467print '<span class="bold"> &nbsp; -> Current PHP streams allowed = </span>';
468$arrayofstreams = stream_get_wrappers();
469if (!empty($arrayofstreams)) {
470 sort($arrayofstreams);
471 print '<span class="wordbreak">'.implode(',', $arrayofstreams).'</span>';
472 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php,zip').')</span>'."\n";
473}
474print '</div>';
475
476
477/*
478if (!empty($dolibarr_main_stream_do_not_disable)) {
479 print '<strong>$dolibarr_main_stream_do_not_disable</strong>: ';
480 if (empty($dolibarr_main_stream_do_not_disable)) {
481 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
482 } else {
483 print join(', ', $dolibarr_main_stream_do_not_disable);
484 }
485 print ' -> PHP stream allowed = ';
486 $arrayofstreams = stream_get_wrappers();
487 if (!empty($arrayofstreams)) {
488 sort($arrayofstreams);
489 print (join(',', $arrayofstreams)).' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Undefined').')</span>'."\n";
490 }
491
492 print '<br>';
493}
494*/
495
496
497// Menu Home - Setup - Security
498
499print '<br>';
500print '<br>';
501
502print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder');
503
504print '<div class="divsection wordbreak">';
505
506print '<strong>'.$langs->trans("UseCaptchaCode").' - Login</strong>: ';
507print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? '' : img_picto('', 'tick').' ';
508print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? 0 : 1);
509print '<br>';
510print '<br>';
511
512print '<strong>'.$langs->trans("UseCaptchaCode").' - Ticket</strong>: ';
513print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET') ? '' : img_picto('', 'tick').' ';
514print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET') ? 0 : 1);
515print '<br>';
516print '<br>';
517
518print '<strong>'.$langs->trans("UseCaptchaCode").' - Thirdparty public contact form</strong>: ';
519print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_THIRPARTY') ? '' : img_picto('', 'tick').' ';
520print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_THIRPARTY') ? 0 : 1);
521print '<br>';
522print '<br>';
523
524print '<strong>'.$langs->trans("UseCaptchaCode").' - Membership subscription</strong>: ';
525print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') ? '' : img_picto('', 'tick').' ';
526print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_MEMBER') ? 0 : 1);
527print '<br>';
528print '<br>';
529
530$sessiontimeout = ini_get("session.gc_maxlifetime");
531if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
532 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
533}
534print '<strong>'.$langs->trans("SessionTimeOut").'</strong>';
535if (!ini_get("session.gc_probability")) {
536 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
537} else {
538 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
539}
540print ': '.getDolGlobalInt('MAIN_SESSION_TIMEOUT').' '.strtolower($langs->trans("Seconds"));
541print '<br><br>';
542
543print '<strong>'.$langs->trans("MaxNumberOfImagesInGetPost").'</strong>: ';
544print(getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT') ? img_picto('', 'tick').' ' : '').getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').' '.strtolower($langs->trans("Images"));
545print '<br><br>';
546
547print '<strong>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</strong>: ';
548print(getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200) ? img_picto('', 'tick').' ' : '').getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200).' '.strtolower($langs->trans("Posts"));
549print '<br><br>';
550
551print '<strong>'.$langs->trans("MaxNumberOfAttachementOnForms").'</strong>: ';
552print(getDolGlobalInt('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS', 10) ? img_picto('', 'tick').' ' : '').getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).' '.strtolower($langs->trans("Files"));
553print '<br><br>';
554
555
556// Clear password ?
557
558print '<strong>'.$langs->trans("DoNotStoreClearPassword").'</strong>: ';
559print !getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? '' : img_picto('', 'tick').' ';
560print yn(!getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? 0 : 1);
561if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
562 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
563}
564print '<br>';
565print '<br>';
566
567
568// Mask by default in upload
569$umask = getDolGlobalString('MAIN_UMASK');
570
571print '<strong>'.$langs->trans("UMask").'</strong>: ';
572if (! in_array($umask, array('600', '660', '0600', '0660'))) {
573 print img_warning().' ';
574}
575print $umask;
576if (! in_array($umask, array('600', '660', '0600', '0660'))) {
577 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
578}
579print '<br>';
580print '<br>';
581
582
583/* Already into section conf file */
584/*
585$usepassinconfencrypted = 0;
586global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
587if (preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
588 $usepassinconfencrypted = 1;
589}
590print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
591print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' ';
592print yn($usepassinconfencrypted);
593if (empty($usepassinconfencrypted)) {
594 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
595}
596print '<br>';
597print '<br>';
598*/
599
600/* Password length
601
602// Stored into $tabconf[0] if module generator is "Perso" or specific to the module generator.
603$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
604
605print '<strong>'.$langs->trans("PasswordLength").'</strong>: ';
606print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
607print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
608if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
609 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
610}
611print '<br>';
612print '<br>';
613*/
614
615print '<strong>'.$langs->trans("AntivirusEnabledOnUpload").'</strong>: ';
616print getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') ? img_picto('', 'tick').' ' : img_warning().' ';
617print yn(!getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') ? 0 : 1);
618if (!getDolGlobalString('MAIN_ANTIVIRUS_UPLOAD_ON') || !getDolGlobalString('MAIN_ANTIVIRUS_COMMAND')) {
619 print ' - <span class="opacitymedium">'.$langs->trans("Recommended").': '.$langs->trans("DefinedAPathForAntivirusCommandIntoSetup", $langs->transnoentitiesnoconv("Home")." - ".$langs->transnoentitiesnoconv("Setup")." - ".$langs->transnoentitiesnoconv("Security")).'</span>';
620} else {
621 print ' &nbsp; - ' . getDolGlobalString('MAIN_ANTIVIRUS_COMMAND');
622 if (defined('MAIN_ANTIVIRUS_COMMAND') && !defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
623 print ' - <span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
624 }
625}
626print '<br>';
627print '<br>';
628
629// File extension locked in upload by default
630
631print '<strong>'.$langs->trans("UploadExtensionRestriction").'</strong>: ';
632print implode(', ', explode(',', getDolGlobalString('MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION', implode(',', getExecutableContent()))));
633print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.implode(', ', getExecutableContent()).')</span>';
634print '<br>';
635print '<br>';
636
637
638print '<strong>'.$langs->trans("MAIN_SECURITY_MAXFILESIZE_DOWNLOADED").'</strong> = '.getDolGlobalString('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': < 100000)</span>')."<br>";
639print '<br>';
640
641
642
643$securityevent = new Events($db);
644$eventstolog = $securityevent->eventstolog;
645
646print '<strong>'.$langs->trans("AuditedSecurityEvents").'</strong>: ';
647$out = '';
648if (!empty($eventstolog) && is_array($eventstolog)) {
649 // Loop on each event type
650 $i = 0;
651 foreach ($eventstolog as $key => $arr) {
652 if ($arr['id']) {
653 $key = 'MAIN_LOGEVENTS_'.$arr['id'];
654 $value = getDolGlobalString($key);
655 if ($value) {
656 if ($i > 0) {
657 $out .= ', ';
658 }
659 $out .= '<span class="opacitymedium">'.$key.'</span>';
660 $i++;
661 }
662 }
663 }
664 print $out;
665}
666
667if (empty($out)) {
668 print img_warning().' '.$langs->trans("NoSecurityEventsAreAduited", $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit")).'<br>';
669} else {
670 $s = $langs->trans("SeeSetupPage", ' {s1}'.$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit").'{s2}');
671 print ' - '.str_replace('{s2}', '</a>', str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/admin/events.php" target="_blank">'.img_picto('', 'url', 'class="pictofixedwidth"'), $s));
672}
673
674print '<br>';
675
676print '<br>';
677
678print '<strong>MAIN_SECURITY_FORCERP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCERP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\" or \"same-origin\" so browser doesn't send any referrer when going into another web site domain)</span><br>";
679print '<br>';
680
681print '<strong>MAIN_SECURITY_FORCESTS</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCESTS', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": max-age=31536000; includeSubDomains)</span><br>";
682print '<br>';
683
684print '<strong>MAIN_SECURITY_FORCEPP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCEPP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": camera=*, microphone=(), geolocation=*)</span><br>";
685print '<br>';
686
687if (getDolGlobalString('MAIN_SECURITY_FORCECSPRO')) {
688 $examplecsprule = "frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com *.dolistore.com *.githubusercontent.com";
689 print '<strong>MAIN_SECURITY_FORCECSPRO</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCECSPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "'.$examplecsprule.'")</span><br>';
690 print '<br>';
691}
692
693$examplecsprule = "frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com *.dolistore.com *.githubusercontent.com";
694print '<strong>MAIN_SECURITY_FORCECSP</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "'.$examplecsprule.'")</span><br>';
695print '<br>';
696
697$tmpurl = constant('DOL_MAIN_URL_ROOT');
698$tmpurl = preg_replace('/^(https?:\/\/[^\/]+)\/.*$/', '\1', $tmpurl);
699print '<strong>MAIN_SECURITY_FORCE_ACCESS_CONTROL_ALLOW_ORIGIN</strong> = '.getDolGlobalString('MAIN_SECURITY_FORCE_ACCESS_CONTROL_ALLOW_ORIGIN', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 so browsers will accept answers of a page only if page was requested from the domain ".$tmpurl.". Note: it is not possible to limit to several domains)</span><br>";
700
701print '</div>';
702
703print '<br>';
704
705
706
707// Modules/Applications
708
709print '<br>';
710print '<br>';
711print load_fiche_titre($langs->trans("Modules"), '', 'folder');
712
713print '<div class="divsection wordbreak">';
714
715// Module log
716print '<strong>'.$langs->trans("Syslog").'</strong>: ';
717$test = isModEnabled('syslog');
718if (!$test) {
719 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
720} else {
721 if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) {
722 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog"));
723 } else {
724 print img_picto('', 'tick').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL'));
725 }
726 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
727}
728print '<br>';
729
730print '<br>';
731
732// Module debugbar
733print '<strong>'.$langs->trans("DebugBar").'</strong>: ';
734$test = isModEnabled('debugbar');
735if (!$test) {
736 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
737} else {
738 print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar"));
739 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
740}
741print '<br>';
742
743// Modules for Payments
744$test = isModEnabled('stripe');
745if ($test) {
746 print '<br>';
747
748 print '<strong>'.$langs->trans("Stripe").'</strong>: ';
749 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
750 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
751 } else {
752 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
753 }
754 print '<br>';
755} else {
756 $test = isModEnabled('paypal');
757 if ($test) {
758 print '<br>';
759
760 print '<strong>'.$langs->trans("Paypal").'</strong>: ';
761 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
762 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
763 } else {
764 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
765 }
766 print '<br>';
767 }
768}
769
770print '</div>';
771
772
773// APIs
774
775print '<br>';
776print '<br>';
777print load_fiche_titre($langs->trans("API"), '', 'folder');
778
779print '<div class="divsection wordbreak">';
780
781if (!isModEnabled('api') && !isModEnabled('webservices')) {
782 print $langs->trans("APIsAreNotEnabled");
783} else {
784 if (isModEnabled('webservices')) {
785 print img_picto('', 'warning').' '.$langs->trans('YouEnableDeprecatedWSAPIsUseRESTAPIsInstead')."<br>\n";
786 print '<br>';
787 }
788 if (isModEnabled('api')) {
789 print '<strong>API_ENDPOINT_RULES</strong> = '.getDolGlobalString('API_ENDPOINT_RULES', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)</span>')."<br>\n";
790
791 print '<br>';
792
793 print '<strong>API_DISABLE_LOGIN_API</strong> = '.getDolGlobalString('API_DISABLE_LOGIN_API', '0').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
794 }
795}
796
797
798print '</div>';
799
800
801print '<br>';
802print '<br>';
803
804
805// Other setup
806
807print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
808
809print '<div class="divsection wordbreak">';
810
811print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES', '0').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span><br>';
812print '<br>';
813
814print '<strong>MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE</strong> = '.getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
815print '<br>';
816
817print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>')."<br>";
818print '<br>';
819
820print '<strong>MAIN_SECURITY_CSRF_WITH_TOKEN</strong> = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)</span>'."<br>";
821
822print '</div>';
823
824print '<br>';
825print '<br>';
826
827
828
829// Database encryption
830
831print load_fiche_titre($langs->trans("DatabaseEncryption"), '', 'folder');
832
833print '<div class="divsection wordbreak">';
834
835//print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
836print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("Passwords"));
837print $form->textwithpicto('', 'non reversible encryption, defined into MAIN_SECURITY_HASH_ALGO');
838print '</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
839if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
840 print '<span class="opacitymedium"> &nbsp; &nbsp; (If unset: \'md5\')</span>';
841}
842if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
843 print '<br><strong>MAIN_SECURITY_SALT</strong> = '.getDolGlobalString('MAIN_SECURITY_SALT', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').'<br>';
844} else {
845 print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
846 print '<br>';
847}
848if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
849 print '<div class="info">The recommended value for MAIN_SECURITY_HASH_ALGO is now \'password_hash\' but setting it now will make ALL existing passwords of all users not valid, so update is not possible.<br>';
850 print 'If you really want to switch, you must:<br>';
851 print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\'<br>';
852 print '- In same session, WITHOUT LOGGING OUT, go into your admin user record and set a new password<br>';
853 print '- You can now logout and login with this new password. You must now reset password of all other users.<br>';
854 print '</div>';
855}
856print '<br>';
857
858$action = GETPOST('action');
859$exampletodecrypt = GETPOST('exampletodecrypt', 'password');
860
861print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("SensitiveData"));
862print $form->textwithpicto('', 'reversible encryption done with dolEncrypt/dolDecrypt');
863print '</strong> = '.constant('MAIN_SECURITY_REVERSIBLE_ALGO').' with a random seed + a crypt key defined into the conf.php file (in $dolibarr_main_instance_unique_id or $dolibarr_main_dolcrypt_key)<br>';
864print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
865print '<input type="hidden" name="action" value="doldecrypt">';
866print '<input type="hidden" name="token" value="'.newToken().'">';
867print '<input type="hidden" name="page_y" value="">';
868print $langs->trans("ToolToDecryptAString").': ';
869print '<input type="text" class="minwidth500" name="exampletodecrypt" placeholder="dolcrypt:ALGOXXXX:ABCDFEF1234" value="'.$exampletodecrypt.'">';
870print '<input type="submit" class="reposition button small smallpaddingimp" name="submit" value="'.$langs->transnoentitiesnoconv("Decrypt").'">';
871if ($action == 'doldecrypt' && $user->admin && $exampletodecrypt) {
872 usleep(200);
873 $decryptedstring = dolDecrypt($exampletodecrypt);
874 if (ascii_check($decryptedstring)) {
875 print '<br> => <textarea rows="'.ROWS_1.'" class="valignmiddle quatrevingtpercent">'.dolPrintHTMLForTextArea($decryptedstring).'</textarea>';
876 } else {
877 print '<br><span class="error"> => Failed to decrypt. The crypting key saved into the conf.php file seems to not be the one used to encrypt the provided encrypted string</span>';
878 }
879}
880print '</form>';
881
882print '</div>';
883
884
885print '<br>';
886print '<br>';
887
888
889// Websites
890
891if (isModEnabled('website')) {
892 print load_fiche_titre($langs->trans("Website"), '', 'website');
893 print '<div class="divsection wordbreak">';
894
895 $sql = "SELECT w.rowid as id, w.ref";
896 $sql .= " FROM ".MAIN_DB_PREFIX."website as w";
897 $sql .= " WHERE w.entity = ".((int) $conf->entity);
898 $sql .= " AND w.status = 1";
899
900 $resql = $db->query($sql);
901 if ($resql) {
902 $num_rows = $db->num_rows($resql);
903 if ($num_rows > 0) {
904 $i = 0;
905 while ($obj = $db->fetch_object($resql)) {
906 print "<strong>".$langs->trans("WebsiteSecurityOptions").": ".$obj->ref."</strong>";
907 print'<br><br>';
908
909 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCERP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCERP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("Undefined").'="strict-origin-when-cross-origin" '.$langs->trans("or").' "same-origin"=more secured)</span><br>';
910
911 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCESTS</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCESTS', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")</span><br>";
912
913 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCEPP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCEPP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"camera=(), microphone=(), geolocation=*\")</span><br>";
914
915 if (getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO')) {
916 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSPPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
917 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
918 $examplecsprule = "default-src 'self' 'unsafe-inline' matomo.".getDomainFromURL($_SERVER["SERVER_NAME"], 1)." *.transifex.net *.transifex.com *.cloudflare.com *.cloudflareinsights.com *.google-analytics.com *.googletagmanager.com *.google.com *.gstatic.com *.googleapis.com *.googleadservices.com *.ads-twitter.com *.doubleclick.net; frame-ancestors 'self'; object-src *.youtube.com; frame-src 'self' *.twitter.com *.facebook.com *.youtube.com; img-src * data:;";
919 print $examplecsprule;
920 print '")</span><br>';
921 }
922
923 print '<strong>WEBSITE_'.$obj->id.'_SECURITY_FORCECSP</strong> = '.getDolGlobalString('WEBSITE_'.$obj->id.'_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
924 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
925 $examplecsprule = "default-src 'self' 'unsafe-inline' matomo.".getDomainFromURL($_SERVER["SERVER_NAME"], 1)." *.transifex.net *.transifex.com *.cloudflare.com *.cloudflareinsights.com *.google-analytics.com *.googletagmanager.com *.google.com *.gstatic.com *.googleapis.com *.googleadservices.com *.ads-twitter.com *.doubleclick.net; frame-ancestors 'self'; object-src *.youtube.com; frame-src 'self' *.twitter.com *.facebook.com *.youtube.com; img-src * data:;";
926 print $examplecsprule;
927 print '")</span><br>';
928
929 $i++;
930 if ($i != $num_rows) {
931 print '<br>';
932 }
933 }
934 } else {
935 print '<span class="opacity">'.$langs->trans("NoWebsite").'</span>';
936 }
937 } else {
938 dol_print_error($db);
939 }
940 print '</div>';
941
942
943 print '<br>';
944}
945
946
947// Other - experimental
948
949print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
950
951print '<div class="divsection wordbreak">';
952print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
953if (!getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
954 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
955} else {
956 print getDolGlobalString('MAIN_EXEC_USE_POPEN');
957}
958if ($execmethod == 1) {
959 print '<span class="opacitymedium"> &nbsp; &nbsp; "exec" PHP method will be used for shell commands';
960 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
961 print '</span>';
962}
963if ($execmethod == 2) {
964 print '<span class="opacitymedium"> &nbsp; &nbsp; "popen" PHP method will be used for shell commands';
965 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
966 print '</span>';
967}
968print '<br>';
969print '<br>';
970
971print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
972print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span>";
973
974// Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML
975$savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
976$savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
977$savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
978$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
979$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
980$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
981$result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
982$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
983$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
984$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
985
986if ($result == 'InvalidHTMLStringCantBeCleaned') {
987 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
988} else {
989 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
990}
991print '<br>';
992
993print '<br>';
994
995print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
996print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span> &nbsp; - &nbsp; Module "php-tidy" must be enabled (currently: '.((extension_loaded('tidy') && class_exists("tidy")) ? 'Enabled' : img_picto('', 'warning').' Not available').")";
997if (extension_loaded('tidy') && class_exists("tidy")) {
998 // Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY
999 $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
1000 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
1001 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
1002 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
1003 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
1004 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
1005 $result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
1006 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
1007 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
1008 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
1009
1010 if ($result == 'InvalidHTMLStringCantBeCleaned') {
1011 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
1012 } else {
1013 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
1014 }
1015}
1016print '<br>';
1017
1018print '<br>';
1019
1020print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1021print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span><br>";
1022print '<br>';
1023
1024// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1, disallow url links except if on the local wrapper document.php or viewimage.php
1025// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2, disallow all urls link
1026print '<strong>MAIN_DISALLOW_URL_INTO_DESCRIPTIONS</strong> = '.getDolGlobalString('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1=only local links allowed (to wrapper document.php or image.php) or 2=no links at all)</span>')."<br>";
1027print '<br>';
1028
1029print '<strong>MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS</strong> = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1030print '<br>';
1031
1032print '<strong>MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL</strong> = '.getDolGlobalString('MAIN_ALLOW_OBFUSCATION_METHODS_IN_DOL_EVAL', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1033print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": ".$langs->trans("Undefined").' '.$langs->trans("or")." 0 - The value 1 allows the use of concatenation functions like . or dol_concat into extra fields conditions or formula but is not secured)</span><br>";
1034print '<br>';
1035
1036print '<strong>MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER</strong> = '.getDolGlobalString('MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
1037print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - The value 0 allows the use of subrequests into extrafields conditions. It remains not possible in API filters to avoid bind SQL injections whatever is this value)</span><br>";
1038print '<br>';
1039
1040
1041// MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS
1042
1043print '<strong>MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL</strong> = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1044print '<br>';
1045
1046print '<strong>MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED</strong> = '.getDolGlobalString('MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
1047
1048
1049
1050/*
1051 * If we call URL with param security.php/test/test and security.php/test%2Ftest, we can get information if
1052 * AllowEncodedSlashes is enabled or not.
1053 * Note: When there is a string after the page.php/... and before the ? or #, it is available into the $_SERVER["PATH_INFO"].
1054 * Note about $_SERVER:
1055 * REQUEST_URI: /test/before_rewrite/script.php/path/info?q=helloword
1056 * PHP_SELF: /test/after_rewrite/script.php/path/info
1057 * QUERY_STRING: q=helloword
1058 * SCRIPT_NAME: /test/after_rewrite/script.php
1059 * PATH_INFO: /path/info (usually not defined because there is no text between page.php/... and before the ? or #)
1060 * SCRIPT_FILENAME: /var/www/test/php/script.php
1061 * __FILE__ : /var/www/test/php/script_included.php
1062 */
1063$request = $_SERVER['REQUEST_URI'];
1064if (strpos($request, '%2F') !== false) { // It seems than even when AllowEncodedSlashes=NoDecode, behaviour is forced to On on some servers.
1065 echo '<br><strong>AllowEncodedSlashes probably enabled (NoDecode)</strong>';
1066} elseif (strpos($request, '/test/test') !== false) {
1067 echo '<br><strong>AllowEncodedSlashes enabled with decoding On</strong>';
1068} else {
1069 //echo 'Cannot determine';
1070}
1071
1072
1073
1074print '</div>';
1075
1076
1077print '<br>';
1078print '<br>';
1079
1080
1081print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder');
1082
1083print '<div class="divsection wordbreak">';
1084
1085print '<span class="opacitymedium">';
1086print $langs->trans("RecommendMitigationOnURL").'<br>';
1087print '</span>';
1088
1089print '<br>';
1090$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/';
1091print '<span class="fas fa-shield-alt"></span> Login or API authentication (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulesbruteforce.conf">fail2ban example on GitHub</a>)<br>';
1092print '<span class="fas fa-shield-alt"></span> '.DOL_URL_ROOT.'/passwordforgotten.php (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulespassforgotten.conf">fail2ban example on GitHub</a>)<br>';
1093print '<span class="fas fa-shield-alt"></span> '.DOL_URL_ROOT.'/public/* (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-limitpublic.conf">fail2ban example on GitHub</a>)<br>';
1094print '<br>';
1095$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/';
1096print '<span class="fas fa-shield-alt"></span> You can also protect the application using a HTTP Basic authentication layer (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'virtualhost">apache2 virtualhost example on GitHub</a>)<br>';
1097
1098print '</div>';
1099
1100// End of page
1101llxFooter();
1102$db->close();
phpinfo_array()
Return the php_info into an array.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Events class.
Class to manage generation of HTML components Only common components must be here.
$conffile
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
version_php()
Return PHP version.
getExecutableContent()
Return array of extension for executable files of text files that can contains executable code.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolPrintHTMLForTextArea($s, $allowiframe=0)
Return a string ready to be output on input textarea.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
ascii_check($str)
Check if a string is in ASCII.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external links.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getwebuser($mode)
Return user/group account of web server.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.