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
24 require '../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
31 require_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 
36 if (!$user->admin) {
38 }
39 
40 if (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 
53 llxHeader();
54 
55 print load_fiche_titre($langs->trans("Security"), '', 'title_setup');
56 
57 print '<span class="opacitymedium">'.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').'</span>';
58 print ' &nbsp; &nbsp; ';
59 print '<a href="'.$_SERVER["PHP_SELF"].'">';
60 print img_picto($langs->trans("Reload"), 'refresh').' ';
61 print $langs->trans("Reload");
62 print '</a>';
63 print '<br>';
64 print '<br>';
65 
66 print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder');
67 
68 // Get version of PHP
69 $phpversion = version_php();
70 print "<strong>PHP</strong>: ".$langs->trans("Version").": ".$phpversion;
71 if (function_exists('php_ini_loaded_file')) {
72  $inipath = php_ini_loaded_file();
73  print " - <strong>INI</strong>: ".$inipath;
74 }
75 print "<br>\n";
76 
77 // Get version of web server
78 print "<br><strong>Web server - ".$langs->trans("Version")."</strong>: ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
79 print '<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');
83 if ($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)
91 if (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 }
98 print '<br>';
99 
100 print "<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";
101 print "<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";
102 print "<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";
103 print "<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None');
104 if (!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 }
109 print "<br>\n";
110 print "<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";
111 print "<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";
112 print "<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";
113 print "<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";
115 print "<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');
118 if ($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;
126 foreach ($arrayoffunctionsdisabled as $functionkey) {
127  if ($i > 0) {
128  print ', ';
129  }
130  print '<span class="opacitymedium">'.$functionkey.'</span>';
131  $i++;
132 }
133 print "<br>\n";
134 $todisabletext = '';
135 $i = 0;
136 foreach ($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 }
145 if ($todisabletext) {
146  print $langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
147  print '<br>';
148 }
149 $todisabletext = '';
150 $i = 0;
151 foreach ($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 }
160 if ($todisabletext) {
161  print $langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
162  print '<br>';
163 }
164 
165 print $langs->trans("PHPFunctionsRequiredForCLI").': ';
166 if (in_array($functiontokeep, $arrayoffunctionsdisabled)) {
167  print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning');
168 }
169 print '<span class="opacitymedium">'.$functiontokeep.'</span>';
170 print '<br>';
171 
172 $arrayofstreams = stream_get_wrappers();
173 if (!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 
178 print '<br>';
179 
180 // XDebug
181 print '<strong>'.$langs->trans("XDebug").'</strong>: ';
182 $test = !function_exists('xdebug_is_enabled') && !extension_loaded('xdebug');
183 if ($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 }
189 print '<br>';
190 
191 
192 // OS Permissions
193 
194 print '<br>';
195 print '<br>';
196 print '<br>';
197 print load_fiche_titre($langs->trans("OSSetup").' - '.$langs->trans("PermissionsOnFiles"), '', 'folder');
198 
199 print '<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();
202 foreach ($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 }
208 if (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 }
226 print '<br>';
227 print '<br>';
228 
229 print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: '; // $conffile is defined into filefunc.inc.php
230 $perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
231 if ($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 }
248 print '<br>';
249 print '<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
256 print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
257 if (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 }
266 print '<br>';
267 
268 // Is upgrade unlocked
269 if (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 ?
278 print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
279 if (file_exists($installmoduleslock)) {
280  print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
281 } else {
282  print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
283 }
284 print '<br>';
285 
286 
287 
288 // File conf.php
289 
290 print '<br>';
291 print '<br>';
292 print '<br>';
293 print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffile.')', '', 'folder');
294 
295 print '<strong>$dolibarr_main_prod</strong>: '.($dolibarr_main_prod ? $dolibarr_main_prod : '0');
296 if (empty($dolibarr_main_prod)) {
297  print ' &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1);
298 }
299 print '<br>';
300 
301 print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
302 if (!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 }
307 print '<br>';
308 
309 print '<strong>$dolibarr_main_restrict_ip</strong>: ';
310 if (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 }
316 print '<br>';
317 
318 print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
319 if (empty($dolibarr_main_restrict_os_commands)) {
320  print $langs->trans("None");
321 } else {
322  print $dolibarr_main_restrict_os_commands;
323 }
324 print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pgrestore, clamdscan').')</span>';
325 print '<br>';
326 
327 if (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 
343 print '<br>';
344 print '<br>';
345 print '<br>';
346 
347 print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder');
348 
349 
350 print '<strong>'.$langs->trans("UseCaptchaCode").'</strong>: ';
351 print empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) ? '' : img_picto('', 'tick').' ';
352 print yn(empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) ? 0 : 1);
353 print '<br>';
354 print '<br>';
355 
356 
357 $sessiontimeout = ini_get("session.gc_maxlifetime");
358 if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
359  $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
360 }
361 print '<strong>'.$langs->trans("SessionTimeOut").'</strong>';
362 if (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 }
367 print ': '.getDolGlobalInt('MAIN_SESSION_TIMEOUT').' '.strtolower($langs->trans("Seconds"));
368 print '<br><br>';
369 
370 print '<strong>'.$langs->trans("MaxNumberOfImagesInGetPost").'</strong>: ';
371 print getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').' '.strtolower($langs->trans("Images"));
372 print '<br><br>';
373 
374 print '<strong>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</strong>: ';
375 print getDolGlobalInt('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS', 200).' '.strtolower($langs->trans("Posts"));
376 print '<br><br>';
377 
378 print '<strong>'.$langs->trans("MaxNumberOfAttachementOnForms").'</strong>: ';
379 print getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).' '.strtolower($langs->trans("Files"));
380 print '<br><br>';
381 
382 print '<strong>'.$langs->trans("DoNotStoreClearPassword").'</strong>: ';
383 print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
384 print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
385 if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
386  print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
387 }
388 print '<br>';
389 print '<br>';
390 
391 /* Already into section conf file */
392 /*
393 $usepassinconfencrypted = 0;
394 global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
395 if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
396  $usepassinconfencrypted = 1;
397 }
398 print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
399 print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' ';
400 print yn($usepassinconfencrypted);
401 if (empty($usepassinconfencrypted)) {
402  print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
403 }
404 print '<br>';
405 print '<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 
413 print '<strong>'.$langs->trans("PasswordLength").'</strong>: ';
414 print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
415 print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
416 if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
417  print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
418 }
419 print '<br>';
420 print '<br>';
421 */
422 
423 print '<strong>'.$langs->trans("AntivirusEnabledOnUpload").'</strong>: ';
424 print empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? img_warning().' ' : img_picto('', 'tick').' ';
425 print yn(empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? 0 : 1);
426 if (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 }
434 print '<br>';
435 print '<br>';
436 
437 $umask = getDolGlobalString('MAIN_UMASK');
438 
439 print '<strong>'.$langs->trans("UMask").'</strong>: ';
440 if (! in_array($umask, array('600', '660', '0600', '0660'))) {
441  print img_warning().' ';
442 }
443 print $umask;
444 if (! in_array($umask, array('600', '660', '0600', '0660'))) {
445  print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
446 }
447 print '<br>';
448 print '<br>';
449 
450 
451 $securityevent = new Events($db);
452 $eventstolog = $securityevent->eventstolog;
453 
454 print '<strong>'.$langs->trans("AuditedSecurityEvents").'</strong>: ';
455 $out = '';
456 if (!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 
475 if (empty($out)) {
476  print img_warning().' '.$langs->trans("NoSecurityEventsAreAduited", $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit")).'<br>';
477 }
478 
479 print '<br>';
480 
481 
482 // Modules/Applications
483 
484 print '<br>';
485 print '<br>';
486 print '<br>';
487 print load_fiche_titre($langs->trans("Modules"), '', 'folder');
488 
489 // Module log
490 print '<strong>'.$langs->trans("Syslog").'</strong>: ';
491 $test = isModEnabled('syslog');
492 if (!$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 }
502 print '<br>';
503 
504 print '<br>';
505 
506 // Module debugbar
507 print '<strong>'.$langs->trans("DebugBar").'</strong>: ';
508 $test = isModEnabled('debugbar');
509 if (!$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 }
515 print '<br>';
516 
517 print '<br>';
518 
519 // Modules for Payments
520 $test = isModEnabled('stripe');
521 if ($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 
545 print '<br>';
546 print '<br>';
547 print '<br>';
548 print load_fiche_titre($langs->trans("API"), '', 'folder');
549 
550 if (!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 
564 print '<br><br>';
565 
566 
567 print '<br>';
568 
569 
570 print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
571 
572 print '<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>';
573 print '<br>';
574 
575 print '<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>';
576 print '<br>';
577 
578 //print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
579 print '<strong>MAIN_SECURITY_HASH_ALGO</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
580 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
581  print '<span class="opacitymedium"> &nbsp; &nbsp; If unset: \'md5\'</span>';
582 }
583 if ($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 }
589 if ($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 }
597 print '<br>';
598 
599 print '<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>";
600 print '<br>';
601 
602 print '<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>";
603 print '<br>';
604 
605 print '<br>';
606 print '<br>';
607 
608 
609 print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
610 
611 print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
612 if (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 }
617 if ($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 }
622 if ($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 }
627 print '<br>';
628 print '<br>';
629 
630 print '<strong>MAIN_SECURITY_MAXFILESIZE_DOWNLOADED</strong> = '.getDolGlobalString('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 100000000)</span>')."<br>";
631 print '<br>';
632 
633 print '<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>";
634 print '<br>';
635 
636 print '<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>";
637 print '<br>';
638 
639 print '<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>";
640 print '<br>';
641 
642 print '<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>";
643 print '<br>';
644 
645 // MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS
646 
647 print '<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>";
648 print '<br>';
649 
650 print '<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>";
651 print '<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;";
654 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>';
655 print '<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;";
658 print '<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>';
659 print '<br>';
660 
661 print '<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>";
662 print '<br>';
663 
664 print '<strong>WEBSITE_MAIN_SECURITY_FORCECSPRO</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
665 print ' &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>";
666 print '<br>';
667 
668 print '<strong>WEBSITE_MAIN_SECURITY_FORCECSP</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
669 print ' &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>";
670 print '<br>';
671 
672 print '<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>";
673 print '<br>';
674 
675 print '<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>";
676 print '<br>';
677 
678 print '<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>";
679 print '<br>';
680 
681 print '<br>';
682 
683 
684 print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder');
685 
686 print '<span class="opacitymedium">';
687 print $langs->trans("RecommendMitigationOnURL").'<br>';
688 print '</span>';
689 
690 print '<br>';
691 $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/';
692 print '- Login or API authentication (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulesbruteforce.conf">fail2ban example on GitHub</a>)<br>';
693 print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-rulespassforgotten.conf">fail2ban example on GitHub</a>)<br>';
694 print '- '.DOL_URL_ROOT.'/public/* (see <a target="_blank" rel="noopener" href="'.$urlexamplebase.'web-dolibarr-limitpublic.conf">fail2ban example on GitHub</a>)<br>';
695 print '<br>';
696 $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/';
697 print '- 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
701 llxFooter();
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.