dolibarr 18.0.6
security.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2022 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23// Load Dolibarr environment
24require '../../main.inc.php';
25require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
32
33// Load translation files required by the page
34$langs->loadLangs(array("install", "other", "admin", "errors"));
35
36if (!$user->admin) {
38}
39
40if (GETPOST('action', 'aZ09') == 'donothing') {
41 exit;
42}
43
44$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1);
45
46
47/*
48 * View
49 */
50
51$form = new Form($db);
52
53llxHeader();
54
55print load_fiche_titre($langs->trans("Security"), '', 'title_setup');
56
57print '<span class="opacitymedium">'.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').'</span>';
58print ' &nbsp; &nbsp; ';
59print '<a href="'.$_SERVER["PHP_SELF"].'">';
60print img_picto($langs->trans("Reload"), 'refresh').' ';
61print $langs->trans("Reload");
62print '</a>';
63print '<br>';
64print '<br>';
65
66print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder');
67
68// Get version of PHP
69$phpversion = version_php();
70print "<strong>PHP</strong>: ".$langs->trans("Version").": ".$phpversion;
71if (function_exists('php_ini_loaded_file')) {
72 $inipath = php_ini_loaded_file();
73 print " - <strong>INI</strong>: ".$inipath;
74}
75print "<br>\n";
76
77// Get version of web server
78print "<br><strong>Web server - ".$langs->trans("Version")."</strong>: ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
79print '<strong>'.$langs->trans("DataRootServer")."</strong>: ".DOL_DATA_ROOT."<br>\n";
80// Web user group by default
81$labeluser = dol_getwebuser('user');
82$labelgroup = dol_getwebuser('group');
83if ($labeluser && $labelgroup) {
84 print '<strong>'.$langs->trans("WebUserGroup")." (env vars)</strong> : ".$labeluser.':'.$labelgroup;
85 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
86 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
87 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span><br>'."\n";
88 }
89}
90// Web user group real (detected by 'id' external command)
91if (function_exists('exec')) {
92 $arrayout = array(); $varout = 0;
93 exec('id', $arrayout, $varout);
94 if (empty($varout)) { // Test command is ok. Work only on Linux OS.
95 print '<strong>'.$langs->trans("WebUserGroup")." (real, 'id' command)</strong> : ".join(',', $arrayout)."<br>\n";
96 }
97}
98print '<br>';
99
100print "<strong>PHP session.use_strict_mode</strong> = ".(ini_get('session.use_strict_mode') ? '' : img_warning().' ').(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";
101print "<strong>PHP session.use_only_cookies</strong> = ".(ini_get('session.use_only_cookies') ? '' : img_warning().' ').(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";
102print "<strong>PHP session.cookie_httponly</strong> = ".(ini_get('session.cookie_httponly') ? '' : img_warning().' ').(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
103print "<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None');
104if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') == 'Lax') {
105 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Lax').")</span>";
106} elseif (ini_get('session.cookie_samesite') == 'Strict') {
107 print ' &nbsp; '.img_warning().' <span class="opacitymedium">'.$langs->trans("WarningPaypalPaymentNotCompatibleWithStrict")."</span>";
108}
109print "<br>\n";
110print "<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";
111print "<strong>PHP short_open_tag</strong> = ".((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? yn(0) : img_warning().' '.yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).')</span>'."<br>\n";
112print "<strong>PHP allow_url_fopen</strong> = ".(ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_fopen') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
113print "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_include') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
114//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";
115print "<strong>PHP disable_functions</strong> = ";
116$arrayoffunctionsdisabled = explode(',', ini_get('disable_functions'));
117$arrayoffunctionstodisable = explode(',', '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');
118if ($execmethod == 1) {
119 $arrayoffunctionstodisable2 = explode(',', 'passthru,shell_exec,system,proc_open,popen');
120 $functiontokeep = 'exec';
121} else {
122 $arrayoffunctionstodisable2 = explode(',', 'exec,passthru,shell_exec,system,proc_open');
123 $functiontokeep = 'popen';
124}
125$i = 0;
126foreach ($arrayoffunctionsdisabled as $functionkey) {
127 if ($i > 0) {
128 print ', ';
129 }
130 print '<span class="opacitymedium">'.$functionkey.'</span>';
131 $i++;
132}
133print "<br>\n";
134$todisabletext = '';
135$i = 0;
136foreach ($arrayoffunctionstodisable as $functiontodisable) {
137 if (! in_array($functiontodisable, $arrayoffunctionsdisabled)) {
138 if ($i > 0) {
139 $todisabletext .= ', ';
140 }
141 $todisabletext .= img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' <span class="opacitymedium">'.$functiontodisable.'</span>';
142 $i++;
143 }
144}
145if ($todisabletext) {
146 print $langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
147 print '<br>';
148}
149$todisabletext = '';
150$i = 0;
151foreach ($arrayoffunctionstodisable2 as $functiontodisable) {
152 if (! in_array($functiontodisable, $arrayoffunctionsdisabled)) {
153 if ($i > 0) {
154 $todisabletext .= ', ';
155 }
156 $todisabletext .= img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' <span class="opacitymedium">'.$functiontodisable.'</span>';
157 $i++;
158 }
159}
160if ($todisabletext) {
161 print $langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
162 print '<br>';
163}
164
165print $langs->trans("PHPFunctionsRequiredForCLI").': ';
166if (in_array($functiontokeep, $arrayoffunctionsdisabled)) {
167 print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning');
168}
169print '<span class="opacitymedium">'.$functiontokeep.'</span>';
170print '<br>';
171
172$arrayofstreams = stream_get_wrappers();
173if (!empty($arrayofstreams)) {
174 sort($arrayofstreams);
175 print "<strong>PHP streams</strong> = ".(join(',', $arrayofstreams)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'file,http,https,php').')</span>'."<br>\n";
176}
177
178print '<br>';
179
180// XDebug
181print '<strong>'.$langs->trans("XDebug").'</strong>: ';
182$test = !function_exists('xdebug_is_enabled') && !extension_loaded('xdebug');
183if ($test) {
184 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
185} else {
186 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug"));
187 print ' - '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php">XDebug admin page</a>';
188}
189print '<br>';
190
191
192// OS Permissions
193
194print '<br>';
195print '<br>';
196print '<br>';
197print load_fiche_titre($langs->trans("OSSetup").' - '.$langs->trans("PermissionsOnFiles"), '', 'folder');
198
199print '<strong>'.$langs->trans("PermissionsOnFilesInWebRoot").'</strong>: ';
200$arrayoffilesinroot = dol_dir_list(DOL_DOCUMENT_ROOT, 'all', 1, '', array('\/custom'), 'name', SORT_ASC, 4, 1, '', 1);
201$fileswithwritepermission = array();
202foreach ($arrayoffilesinroot as $fileinroot) {
203 // Test if there is at least one write permission file. If yes, add the entry into array $fileswithwritepermission
204 if (isset($fileinroot['perm']) && ($fileinroot['perm'] & 0222)) {
205 $fileswithwritepermission[] = $fileinroot['relativename'];
206 }
207}
208if (empty($fileswithwritepermission)) {
209 print img_picto('', 'tick').' '.$langs->trans("NoWritableFilesFoundIntoRootDir");
210} else {
211 print img_warning().' '.$langs->trans("SomeFilesOrDirInRootAreWritable");
212 print '<br>'.$langs->trans("Example").': ';
213 $i = 0;
214 foreach ($fileswithwritepermission as $filewithwritepermission) {
215 if ($i > 0) {
216 print ', ';
217 }
218 print '<span class="opacitymedium">'.$filewithwritepermission.'</span>';
219 if ($i > 20) {
220 print ' ...';
221 break;
222 }
223 $i++;
224 }
225}
226print '<br>';
227print '<br>';
228
229print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: '; // $conffile is defined into filefunc.inc.php
230$perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
231if ($perms) {
232 if (($perms & 0x0004) || ($perms & 0x0002)) {
233 print img_warning().' '.$langs->trans("ConfFileIsReadableOrWritableByAnyUsers");
234 // Web user group by default
235 $labeluser = dol_getwebuser('user');
236 $labelgroup = dol_getwebuser('group');
237 print ' '.$langs->trans("User").': '.$labeluser.':'.$labelgroup;
238 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
239 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
240 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span>';
241 }
242 } else {
243 print img_picto('', 'tick');
244 }
245} else {
246 print img_warning().' '.$langs->trans("FailedToReadFile", $conffile);
247}
248print '<br>';
249print '<br>';
250
251$installlock = DOL_DATA_ROOT.'/install.lock';
252$upgradeunlock = DOL_DATA_ROOT.'/upgrade.unlock';
253$installmoduleslock = DOL_DATA_ROOT.'/installmodules.lock';
254
255// Is install (upgrade) locked
256print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
257if (file_exists($installlock)) {
258 if (file_exists($upgradeunlock)) {
259 print img_picto('', 'tick').' '.$langs->trans("InstallLockedBy", $installlock);
260 } else {
261 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
262 }
263} else {
264 print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
265}
266print '<br>';
267
268// Is upgrade unlocked
269if (file_exists($installlock)) { // If install not locked, no need to show this.
270 if (file_exists($upgradeunlock)) {
271 print '<strong>'.$langs->trans("DolibarrUpgrade").'</strong>: ';
272 print img_warning().' '.$langs->trans("UpgradeHasBeenUnlocked", $upgradeunlock);
273 print '<br>';
274 }
275}
276
277// Is addon install locked ?
278print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
279if (file_exists($installmoduleslock)) {
280 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
281} else {
282 print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
283}
284print '<br>';
285
286
287
288// File conf.php
289
290print '<br>';
291print '<br>';
292print '<br>';
293print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffile.')', '', 'folder');
294
295print '<strong>$dolibarr_main_prod</strong>: '.($dolibarr_main_prod ? $dolibarr_main_prod : '0');
296if (empty($dolibarr_main_prod)) {
297 print ' &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1);
298}
299print '<br>';
300
301print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
302if (!empty($dolibarr_nocsrfcheck)) {
303 print ' &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0);
304} else {
305 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span>';
306}
307print '<br>';
308
309print '<strong>$dolibarr_main_restrict_ip</strong>: ';
310if (empty($dolibarr_main_restrict_ip)) {
311 print $langs->trans("None");
312 //print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
313} else {
314 print $dolibarr_main_restrict_ip;
315}
316print '<br>';
317
318print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
319if (empty($dolibarr_main_restrict_os_commands)) {
320 print $langs->trans("None");
321} else {
322 print $dolibarr_main_restrict_os_commands;
323}
324print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore, clamdscan').')</span>';
325print '<br>';
326
327if (empty($conf->global->SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF)) {
328 print '<strong>$dolibarr_main_db_pass</strong>: ';
329 if (!empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
330 print img_picto('', 'warning').' '.$langs->trans("DatabasePasswordNotObfuscated").' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("SetOptionTo", $langs->transnoentitiesnoconv("MainDbPasswordFileConfEncrypted"), yn(1)).')</span>';
331 //print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
332 } else {
333 print img_picto('', 'tick').' '.$langs->trans("DatabasePasswordObfuscated");
334 }
335
336 print '<br>';
337}
338
339
340
341// Menu Home - Setup - Security
342
343print '<br>';
344print '<br>';
345print '<br>';
346
347print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder');
348
349
350print '<strong>'.$langs->trans("UseCaptchaCode").'</strong>: ';
351print empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) ? '' : img_picto('', 'tick').' ';
352print yn(empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) ? 0 : 1);
353print '<br>';
354print '<br>';
355
356
357$sessiontimeout = ini_get("session.gc_maxlifetime");
358if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
359 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
360}
361print '<strong>'.$langs->trans("SessionTimeOut").'</strong>';
362if (ini_get("session.gc_probability") == 0) {
363 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
364} else {
365 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
366}
367print ': '.getDolGlobalInt('MAIN_SESSION_TIMEOUT').' '.strtolower($langs->trans("Seconds"));
368print '<br><br>';
369
370print '<strong>'.$langs->trans("MaxNumberOfImagesInGetPost").'</strong>: ';
371print getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').' '.strtolower($langs->trans("Images"));
372print '<br><br>';
373
374print '<strong>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</strong>: ';
375print getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200).' '.strtolower($langs->trans("Posts"));
376print '<br><br>';
377
378print '<strong>'.$langs->trans("MaxNumberOfAttachementOnForms").'</strong>: ';
379print getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).' '.strtolower($langs->trans("Files"));
380print '<br><br>';
381
382print '<strong>'.$langs->trans("DoNotStoreClearPassword").'</strong>: ';
383print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
384print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
385if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
386 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
387}
388print '<br>';
389print '<br>';
390
391/* Already into section conf file */
392/*
393$usepassinconfencrypted = 0;
394global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
395if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
396 $usepassinconfencrypted = 1;
397}
398print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
399print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' ';
400print yn($usepassinconfencrypted);
401if (empty($usepassinconfencrypted)) {
402 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
403}
404print '<br>';
405print '<br>';
406*/
407
408/* Password length
409
410// Stored into $tabconf[0] if module generator is "Perso" or specific to the module generator.
411$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
412
413print '<strong>'.$langs->trans("PasswordLength").'</strong>: ';
414print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
415print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
416if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
417 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
418}
419print '<br>';
420print '<br>';
421*/
422
423print '<strong>'.$langs->trans("AntivirusEnabledOnUpload").'</strong>: ';
424print empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? img_warning().' ' : img_picto('', 'tick').' ';
425print yn(empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? 0 : 1);
426if (empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) {
427 print ' - <span class="opacitymedium">'.$langs->trans("Recommended").': '.$langs->trans("DefinedAPathForAntivirusCommandIntoSetup", $langs->transnoentitiesnoconv("Home")." - ".$langs->transnoentitiesnoconv("Setup")." - ".$langs->transnoentitiesnoconv("Security")).'</span>';
428} else {
429 print ' &nbsp; - '.$conf->global->MAIN_ANTIVIRUS_COMMAND;
430 if (defined('MAIN_ANTIVIRUS_COMMAND') && !defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
431 print ' - <span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
432 }
433}
434print '<br>';
435print '<br>';
436
437$umask = getDolGlobalString('MAIN_UMASK');
438
439print '<strong>'.$langs->trans("UMask").'</strong>: ';
440if (! in_array($umask, array('600', '660', '0600', '0660'))) {
441 print img_warning().' ';
442}
443print $umask;
444if (! in_array($umask, array('600', '660', '0600', '0660'))) {
445 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
446}
447print '<br>';
448print '<br>';
449
450
451$securityevent = new Events($db);
452$eventstolog = $securityevent->eventstolog;
453
454print '<strong>'.$langs->trans("AuditedSecurityEvents").'</strong>: ';
455$out = '';
456if (!empty($eventstolog) && is_array($eventstolog)) {
457 // Loop on each event type
458 $i = 0;
459 foreach ($eventstolog as $key => $arr) {
460 if ($arr['id']) {
461 $key = 'MAIN_LOGEVENTS_'.$arr['id'];
462 $value = empty($conf->global->$key) ? '' : $conf->global->$key;
463 if ($value) {
464 if ($i > 0) {
465 $out .= ', ';
466 }
467 $out .= '<span class="opacitymedium">'.$key.'</span>';
468 $i++;
469 }
470 }
471 }
472 print $out;
473}
474
475if (empty($out)) {
476 print img_warning().' '.$langs->trans("NoSecurityEventsAreAduited", $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit")).'<br>';
477}
478
479print '<br>';
480
481
482// Modules/Applications
483
484print '<br>';
485print '<br>';
486print '<br>';
487print load_fiche_titre($langs->trans("Modules"), '', 'folder');
488
489// Module log
490print '<strong>'.$langs->trans("Syslog").'</strong>: ';
491$test = isModEnabled('syslog');
492if (!$test) {
493 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
494} else {
495 if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) {
496 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog"));
497 } else {
498 print img_picto('', 'tick').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL'));
499 }
500 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
501}
502print '<br>';
503
504print '<br>';
505
506// Module debugbar
507print '<strong>'.$langs->trans("DebugBar").'</strong>: ';
508$test = isModEnabled('debugbar');
509if (!$test) {
510 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
511} else {
512 print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar"));
513 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
514}
515print '<br>';
516
517print '<br>';
518
519// Modules for Payments
520$test = isModEnabled('stripe');
521if ($test) {
522 print '<strong>'.$langs->trans("Stripe").'</strong>: ';
523 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
524 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
525 } else {
526 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
527 }
528 print '<br>';
529} else {
530 $test = isModEnabled('paypal');
531 if ($test) {
532 print '<strong>'.$langs->trans("Paypal").'</strong>: ';
533 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
534 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
535 } else {
536 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
537 }
538 print '<br>';
539 }
540}
541
542
543// APIs
544
545print '<br>';
546print '<br>';
547print '<br>';
548print load_fiche_titre($langs->trans("API"), '', 'folder');
549
550if (!isModEnabled('api') && !isModEnabled('webservices')) {
551 print $langs->trans("APIsAreNotEnabled");
552} else {
553 if (isModEnabled('webservices')) {
554 print $langs->trans('YouEnableDeprecatedWSAPIsUseRESTAPIsInstead')."<br>\n";
555 print '<br>';
556 }
557 if (isModEnabled('api')) {
558 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";
559 print '<br>';
560 }
561}
562
563
564print '<br><br>';
565
566
567print '<br>';
568
569
570print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
571
572print '<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>';
573print '<br>';
574
575print '<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>';
576print '<br>';
577
578//print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
579print '<strong>MAIN_SECURITY_HASH_ALGO</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
580if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
581 print '<span class="opacitymedium"> &nbsp; &nbsp; If unset: \'md5\'</span>';
582}
583if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
584 print '<br><strong>MAIN_SECURITY_SALT</strong> = '.getDolGlobalString('MAIN_SECURITY_SALT', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').'<br>';
585} else {
586 print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
587 print '<br>';
588}
589if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
590 print '<div class="info">The recommanded 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>';
591 print 'If you really want to switch, you must:<br>';
592 print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\'<br>';
593 print '- In same session, WITHOUT LOGGING OUT, go into your admin user record and set a new password<br>';
594 print '- You can now logout and login with this new password. You must now reset password of all other users.<br>';
595 print '</div><br>';
596}
597print '<br>';
598
599print '<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>";
600print '<br>';
601
602print '<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>";
603print '<br>';
604
605print '<br>';
606print '<br>';
607
608
609print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
610
611print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
612if (empty($conf->global->MAIN_EXEC_USE_POPEN)) {
613 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
614} else {
615 print $conf->global->MAIN_EXEC_USE_POPEN;
616}
617if ($execmethod == 1) {
618 print '<span class="opacitymedium"> &nbsp; &nbsp; "exec" PHP method will be used for shell commands';
619 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
620 print '</span>';
621}
622if ($execmethod == 2) {
623 print '<span class="opacitymedium"> &nbsp; &nbsp; "popen" PHP method will be used for shell commands';
624 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
625 print '</span>';
626}
627print '<br>';
628print '<br>';
629
630print '<strong>MAIN_SECURITY_MAXFILESIZE_DOWNLOADED</strong> = '.getDolGlobalString('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 100000000)</span>')."<br>";
631print '<br>';
632
633print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>')."<br>";
634print '<br>';
635
636print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>')."<br>";
637print '<br>';
638
639print '<strong>MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS</strong> = '.getDolGlobalString('MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)</span>')."<br>";
640print '<br>';
641
642print '<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>";
643print '<br>';
644
645// MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS
646
647print '<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>";
648print '<br>';
649
650print '<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>";
651print '<br>';
652
653$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;";
654print '<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>';
655print '<br>';
656
657$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;";
658print '<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>';
659print '<br>';
660
661print '<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")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)</span><br>";
662print '<br>';
663
664print '<strong>WEBSITE_MAIN_SECURITY_FORCECSPRO</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
665print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; style-src https://cdnjs.cloudflare.com *.googleapis.com; script-src *.transifex.com *.google-analytics.com *.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src * data:;\")</span><br>";
666print '<br>';
667
668print '<strong>WEBSITE_MAIN_SECURITY_FORCECSP</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
669print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; style-src https://cdnjs.cloudflare.com *.googleapis.com; script-src *.transifex.com *.google-analytics.com *.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src * data:;\")</span><br>";
670print '<br>';
671
672print '<strong>WEBSITE_MAIN_SECURITY_FORCERP</strong> = '.getDolGlobalString('WEBSITE_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\")</span><br>";
673print '<br>';
674
675print '<strong>WEBSITE_MAIN_SECURITY_FORCESTS</strong> = '.getDolGlobalString('>WEBSITE_MAIN_SECURITY_FORCESTS', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")</span><br>";
676print '<br>';
677
678print '<strong>WEBSITE_MAIN_SECURITY_FORCEPP</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCEPP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").": \"camera: (); microphone: ();\")</span><br>";
679print '<br>';
680
681print '<br>';
682
683
684print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder');
685
686print '<span class="opacitymedium">';
687print $langs->trans("RecommendMitigationOnURL").'<br>';
688print '</span>';
689
690print '<br>';
691$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/';
692print '- Login or API authentication (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulesbruteforce.conf">fail2ban example on GitHub</a>)<br>';
693print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulespassforgotten.conf">fail2ban example on GitHub</a>)<br>';
694print '- '.DOL_URL_ROOT.'/public/* (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-limitpublic.conf">fail2ban example on GitHub</a>)<br>';
695print '<br>';
696$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/';
697print '- 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>';
698
699
700// End of page
701llxFooter();
702$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Events class.
Class to manage generation of HTML components Only common components must be here.
dol_dir_list($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:62
version_php()
Return PHP version.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_getwebuser($mode)
Return user/group account of web server.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.