dolibarr 21.0.0-alpha
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24// Load Dolibarr environment
25require '../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
33
34// Load translation files required by the page
35$langs->loadLangs(array("install", "other", "admin", "errors"));
36
37if (!$user->admin) {
39}
40
41if (GETPOST('action', 'aZ09') == 'donothing') {
42 exit;
43}
44
45$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1);
46
47
48/*
49 * View
50 */
51
52$form = new Form($db);
53
54llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_security');
55
56print load_fiche_titre($langs->trans("Security"), '', 'title_setup');
57
58print '<span class="opacitymedium">'.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').'</span>';
59print ' &nbsp; &nbsp; ';
60print '<a href="'.$_SERVER["PHP_SELF"].'">';
61print img_picto($langs->trans("Reload"), 'refresh').' ';
62print $langs->trans("Reload");
63print '</a>';
64print '<br>';
65print '<br>';
66
67
68print '<br>';
69
70
71print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder');
72
73
74print '<div class="divsection wordbreak">';
75
76// Get version of PHP
77$phpversion = version_php();
78print "<strong>PHP</strong>: ".$langs->trans("Version").": ".$phpversion;
79if (function_exists('php_ini_loaded_file')) {
80 $inipath = php_ini_loaded_file();
81 print " - <strong>INI</strong>: ".$inipath;
82}
83print "<br>\n";
84
85// Get version of web server
86print "<br><strong>Web server - ".$langs->trans("Version")."</strong>: ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
87print '<strong>'.$langs->trans("DataRootServer")."</strong>: ".DOL_DATA_ROOT."<br>\n";
88// Web user group by default
89$labeluser = dol_getwebuser('user');
90$labelgroup = dol_getwebuser('group');
91if ($labeluser && $labelgroup) {
92 print '<strong>'.$langs->trans("WebUserGroup")." (env vars)</strong> : ".$labeluser.':'.$labelgroup;
93 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
94 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
95 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span><br>'."\n";
96 }
97}
98// Web user group real (detected by 'id' external command)
99if (function_exists('exec')) {
100 $arrayout = array();
101 $varout = 0;
102 exec('id', $arrayout, $varout);
103 if (empty($varout)) { // Test command is ok. Work only on Linux OS.
104 print '<strong>'.$langs->trans("WebUserGroup")." (real, 'id' command)</strong> : ".implode(',', $arrayout)."<br>\n";
105 }
106}
107print '<br>';
108
109print "<strong>PHP session.use_strict_mode</strong> = ".(ini_get('session.use_strict_mode') ? img_picto('', 'tick').' ' : 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";
110print "<strong>PHP session.use_only_cookies</strong> = ".(ini_get('session.use_only_cookies') ? img_picto('', 'tick').' ' : 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";
111print "<strong>PHP session.cookie_httponly</strong> = ".(ini_get('session.cookie_httponly') ? img_picto('', 'tick').' ' : img_warning().' ').(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
112print "<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? img_picto('', 'tick').' ' .ini_get('session.cookie_samesite') : 'None');
113if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') == 'Lax') {
114 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Lax').")</span>";
115} elseif (ini_get('session.cookie_samesite') == 'Strict') {
116 print ' &nbsp; '.img_warning().' <span class="opacitymedium">'.$langs->trans("WarningPaypalPaymentNotCompatibleWithStrict")."</span>";
117}
118print "<br>\n";
119
120print "<strong>PHP open_basedir</strong> = ".(ini_get('open_basedir') ? img_picto('', 'tick').' '.ini_get('open_basedir') : img_warning().' '.yn(0).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").': '.$_SERVER["DOCUMENT_ROOT"].','.DOL_DATA_ROOT).')</span>')."<br>\n";
121
122print "<strong>PHP short_open_tag</strong> = ".((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? img_picto('', 'tick').' '.yn(0) : img_warning().' '.yn(1)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).')</span>'."<br>\n";
123
124print "<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")).", except if Yes is required by some external modules)</span><br>\n";
125
126print "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_include') : img_picto('', 'tick').' '.yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
127//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";
128
129if (getDolGlobalString('MAIN_SECURITY_SHOW_MORE_INFO')) {
130 print "<strong>PHP auto_prepend_file</strong> = ".(ini_get('auto_prepend_file') ? ini_get('auto_prepend_file') : '')."</span><br>\n";
131
132 print "<strong>PHP sendmail_path</strong> = ".(ini_get('sendmail_path') ? ini_get('sendmail_path') : '')."</span><br>\n";
133}
134
135print "<strong>PHP disable_functions</strong> = ";
136$arrayoffunctionsdisabled = explode(',', ini_get('disable_functions'));
137$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');
138//$arrayoffunctionstodisable[] = 'stream_wrapper_restore';
139//$arrayoffunctionstodisable[] = 'stream_wrapper_register';
140if ($execmethod == 1) {
141 $arrayoffunctionstodisable2 = explode(',', 'passthru,shell_exec,system,proc_open,popen');
142 $functiontokeep = 'exec';
143} else {
144 $arrayoffunctionstodisable2 = explode(',', 'exec,passthru,shell_exec,system,proc_open');
145 $functiontokeep = 'popen';
146}
147$i = 0;
148foreach ($arrayoffunctionsdisabled as $functionkey) {
149 if ($i > 0) {
150 print ', ';
151 }
152 print '<span class="opacitymedium">'.$functionkey.'</span>';
153 $i++;
154}
155print "<br>\n";
156$todisabletext = '';
157$i = 0;
158foreach ($arrayoffunctionstodisable as $functiontodisable) {
159 if (\function_exists($functiontodisable)) {
160 if ($i > 0) {
161 $todisabletext .= ', ';
162 }
163 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
164 $i++;
165 }
166}
167if ($todisabletext) {
168 print img_picto('', 'warning', 'class="pictofixedwidth"').$langs->trans("YouShouldDisablePHPFunctions").': '.$todisabletext;
169 print '<br>';
170}
171$todisabletext = '';
172$i = 0;
173foreach ($arrayoffunctionstodisable2 as $functiontodisable) {
174 if (\function_exists($functiontodisable)) {
175 if ($i > 0) {
176 $todisabletext .= ', ';
177 }
178 $todisabletext .= ' <span class="opacitymedium">'.$functiontodisable.'</span>';
179 $i++;
180 }
181}
182if ($todisabletext) {
183 print img_picto('', 'warning', 'class="pictofixedwidth"').$langs->trans("IfCLINotRequiredYouShouldDisablePHPFunctions").': '.$todisabletext;
184 print '<br>';
185}
186if (!\function_exists($functiontokeep)) {
187 print img_picto($langs->trans("PHPFunctionsRequiredForCLI"), 'warning', 'class="pictofixedwidth"');
188} else {
189 print img_picto('', 'tick', 'class="pictofixedwidth"');
190}
191print $langs->trans("PHPFunctionsRequiredForCLI").': ';
192print '<span class="opacitymedium">'.$functiontokeep.'</span>';
193print '<br>';
194
195print '<br>';
196
197// JSON
198print '<strong>JSON</strong>: ';
199$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
200$test = !in_array('json', $loadedExtensions);
201if ($test || function_exists('dol_json_decode')) {
202 print img_picto('', 'error').' '.$langs->trans("NotInstalled").' - '.$langs->trans("VulnerableToRCEAttack");
203} else {
204 print img_picto('', 'tick').' '.$langs->trans("Available").' <span class="opacitymedium">(PHP native so not emulated, safe)</span>';
205}
206print '<br>';
207
208// XDebug
209print '<strong>XDebug</strong>: ';
210$test = !function_exists('xdebug_is_enabled') && !extension_loaded('xdebug');
211if ($test) {
212 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
213} else {
214 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug"));
215 print ' - '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php">XDebug admin page</a>';
216}
217
218print '</div>';
219
220print '<br>';
221
222
223// OS Permissions
224
225print '<br>';
226print load_fiche_titre($langs->trans("OSSetup").' - '.$langs->trans("PermissionsOnFiles"), '', 'folder');
227
228print '<div class="divsection wordbreak">';
229
230print '<strong>'.$langs->trans("PermissionsOnFilesInWebRoot").'</strong>: ';
231$arrayoffilesinroot = dol_dir_list(DOL_DOCUMENT_ROOT, 'all', 1, '', array('\/custom'), 'name', SORT_ASC, 4, 1, '', 1);
232$fileswithwritepermission = array();
233foreach ($arrayoffilesinroot as $fileinroot) {
234 // Test if there is at least one write permission file. If yes, add the entry into array $fileswithwritepermission
235 if (isset($fileinroot['perm']) && ($fileinroot['perm'] & 0222)) {
236 $fileswithwritepermission[] = $fileinroot['relativename'];
237 }
238}
239if (empty($fileswithwritepermission)) {
240 print img_picto('', 'tick').' '.$langs->trans("NoWritableFilesFoundIntoRootDir");
241} else {
242 print img_warning().' '.$langs->trans("SomeFilesOrDirInRootAreWritable");
243 print '<br>'.$langs->trans("Example").': ';
244 $i = 0;
245 foreach ($fileswithwritepermission as $filewithwritepermission) {
246 if ($i > 0) {
247 print ', ';
248 }
249 print '<span class="opacitymedium">'.$filewithwritepermission.'</span>';
250 if ($i > 20) {
251 print ' ...';
252 break;
253 }
254 $i++;
255 }
256}
257print '<br>';
258print '<br>';
259
260print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: '; // $conffile is defined into filefunc.inc.php
261$perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
262if ($perms) {
263 if (($perms & 0x0004) || ($perms & 0x0002)) {
264 print img_warning().' '.$langs->trans("ConfFileIsReadableOrWritableByAnyUsers");
265 // Web user group by default
266 $labeluser = dol_getwebuser('user');
267 $labelgroup = dol_getwebuser('group');
268 print ' '.$langs->trans("User").': '.$labeluser.':'.$labelgroup;
269 if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) {
270 $arrayofinfoofuser = posix_getpwuid(posix_geteuid());
271 print ' <span class="opacitymedium">(POSIX '.$arrayofinfoofuser['name'].':'.$arrayofinfoofuser['gecos'].':'.$arrayofinfoofuser['dir'].':'.$arrayofinfoofuser['shell'].')</span>';
272 }
273 } else {
274 print img_picto('', 'tick');
275 }
276} else {
277 print img_warning().' '.$langs->trans("FailedToReadFile", $conffile);
278}
279print '<br>';
280print '<br>';
281
282$installlock = DOL_DATA_ROOT.'/install.lock';
283$upgradeunlock = DOL_DATA_ROOT.'/upgrade.unlock';
284$installmoduleslock = DOL_DATA_ROOT.'/installmodules.lock';
285
286// Is install (upgrade) locked
287print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
288if (file_exists($installlock)) {
289 if (file_exists($upgradeunlock)) {
290 print img_picto('', 'tick').' '.$langs->trans("InstallLockedBy", $installlock);
291 } else {
292 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
293 }
294} else {
295 print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
296}
297
298print '<br>';
299print '<br>';
300
301// Is upgrade unlocked
302if (file_exists($installlock)) { // If install not locked, no need to show this.
303 if (file_exists($upgradeunlock)) {
304 print '<strong>'.$langs->trans("DolibarrUpgrade").'</strong>: ';
305 print img_warning().' '.$langs->trans("WarningUpgradeHasBeenUnlocked", $upgradeunlock);
306 print '<br>';
307 print '<br>';
308 }
309}
310
311// Is addon install locked ?
312print '<strong>'.$langs->trans("DolibarrAddonInstall").'</strong>: ';
313if (file_exists($installmoduleslock)) {
314 print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installmoduleslock);
315} else {
316 print $langs->trans("InstallOfAddonIsNotBlocked", DOL_DATA_ROOT);
317}
318
319print '</div>';
320
321
322
323// File conf.php
324
325print '<br>';
326print '<br>';
327print load_fiche_titre($langs->trans("ConfigurationFile").' ('.$conffile.')', '', 'folder');
328
329print '<div class="divsection wordbreak">';
330print '<strong>$dolibarr_main_prod</strong>: '.($dolibarr_main_prod ? $dolibarr_main_prod : '0');
331if (empty($dolibarr_main_prod)) {
332 print ' &nbsp; &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1);
333}
334print '<br>';
335
336print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
337if (!empty($dolibarr_nocsrfcheck)) {
338 print ' &nbsp; &nbsp;'.img_picto('', 'error').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0);
339} else {
340 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span>';
341}
342print '<br>';
343
344print '<strong>$dolibarr_main_restrict_ip</strong>: ';
345if (empty($dolibarr_main_restrict_ip)) {
346 print $langs->trans("None");
347 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("StaticIPsOfUsers")).')</span>';
348} else {
349 print $dolibarr_main_restrict_ip;
350}
351print '<br>';
352
353print '<strong>$dolibarr_main_restrict_os_commands</strong>: ';
354if (empty($dolibarr_main_restrict_os_commands)) {
355 print $langs->trans("None");
356} else {
357 print $dolibarr_main_restrict_os_commands;
358}
359print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'mysqldump, mysql, pg_dump, pg_restore, mariadb, mariadb-dump, clamdscan').')</span>';
360print '<br>';
361
362if (!getDolGlobalString('SECURITY_DISABLE_TEST_ON_OBFUSCATED_CONF')) {
363 print '<strong>$dolibarr_main_db_pass</strong>: ';
364 if (!empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
365 print img_picto('', 'warning').' '.$langs->trans("DatabasePasswordNotObfuscated").' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("SetOptionTo", $langs->transnoentitiesnoconv("MainDbPasswordFileConfEncrypted"), yn(1)).')</span>';
366 //print ' <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("IPsOfUsers")).')</span>';
367 } else {
368 print img_picto('', 'tick').' '.$langs->trans("DatabasePasswordObfuscated");
369 }
370
371 print '<br>';
372}
373
374print '<strong>$dolibarr_main_stream_to_disable</strong>: ';
375// $arrayofstreamtodisable is defined into filefunc.inc.php
376'@phan-var-force string[] $arrayofstreamtodisable';
377if (empty($dolibarr_main_stream_to_disable)) {
378 print '<span class="opacitymedium">'.$langs->trans("Undefined").' = '.implode(', ', $arrayofstreamtodisable).'</span>';
379} else {
380 print implode(', ', $dolibarr_main_stream_to_disable);
381}
382print '<span class="bold"> &nbsp; -> Current PHP streams allowed = </span>';
383$arrayofstreams = stream_get_wrappers();
384if (!empty($arrayofstreams)) {
385 sort($arrayofstreams);
386 print '<span class="wordbreakall">'.implode(',', $arrayofstreams).'</span>';
387 print ' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': '.$langs->trans("TryToKeepOnly", 'file,http,https,php,zip').')</span>'."\n";
388}
389print '</div>';
390
391
392/*
393if (!empty($dolibarr_main_stream_do_not_disable)) {
394 print '<strong>$dolibarr_main_stream_do_not_disable</strong>: ';
395 if (empty($dolibarr_main_stream_do_not_disable)) {
396 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
397 } else {
398 print join(', ', $dolibarr_main_stream_do_not_disable);
399 }
400 print ' -> PHP stream allowed = ';
401 $arrayofstreams = stream_get_wrappers();
402 if (!empty($arrayofstreams)) {
403 sort($arrayofstreams);
404 print (join(',', $arrayofstreams)).' &nbsp; &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Undefined').')</span>'."\n";
405 }
406
407 print '<br>';
408}
409*/
410
411// Menu Home - Setup - Security
412
413print '<br>';
414print '<br>';
415
416print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder');
417
418print '<div class="divsection wordbreak">';
419
420print '<strong>'.$langs->trans("UseCaptchaCode").'</strong>: ';
421print !getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? '' : img_picto('', 'tick').' ';
422print yn(!getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA') ? 0 : 1);
423print '<br>';
424print '<br>';
425
426
427$sessiontimeout = ini_get("session.gc_maxlifetime");
428if (!getDolGlobalString('MAIN_SESSION_TIMEOUT')) {
429 $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
430}
431print '<strong>'.$langs->trans("SessionTimeOut").'</strong>';
432if (!ini_get("session.gc_probability")) {
433 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
434} else {
435 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
436}
437print ': '.getDolGlobalInt('MAIN_SESSION_TIMEOUT').' '.strtolower($langs->trans("Seconds"));
438print '<br><br>';
439
440print '<strong>'.$langs->trans("MaxNumberOfImagesInGetPost").'</strong>: ';
441print(getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT') ? img_picto('', 'tick').' ' : '').getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').' '.strtolower($langs->trans("Images"));
442print '<br><br>';
443
444print '<strong>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</strong>: ';
445print(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"));
446print '<br><br>';
447
448print '<strong>'.$langs->trans("MaxNumberOfAttachementOnForms").'</strong>: ';
449print(getDolGlobalInt('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS', 10) ? img_picto('', 'tick').' ' : '').getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).' '.strtolower($langs->trans("Files"));
450print '<br><br>';
451
452print '<strong>'.$langs->trans("DoNotStoreClearPassword").'</strong>: ';
453print !getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? '' : img_picto('', 'tick').' ';
454print yn(!getDolGlobalString('DATABASE_PWD_ENCRYPTED') ? 0 : 1);
455if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
456 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
457}
458print '<br>';
459print '<br>';
460
461/* Already into section conf file */
462/*
463$usepassinconfencrypted = 0;
464global $dolibarr_main_db_pass, $dolibarr_main_db_encrypted_pass;
465if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
466 $usepassinconfencrypted = 1;
467}
468print '<strong>'.$langs->trans("MainDbPasswordFileConfEncrypted").'</strong>: ';
469print $usepassinconfencrypted ? img_picto('', 'tick').' ' : img_warning().' ';
470print yn($usepassinconfencrypted);
471if (empty($usepassinconfencrypted)) {
472 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
473}
474print '<br>';
475print '<br>';
476*/
477
478/* Password length
479
480// Stored into $tabconf[0] if module generator is "Perso" or specific to the module generator.
481$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
482
483print '<strong>'.$langs->trans("PasswordLength").'</strong>: ';
484print empty($conf->global->DATABASE_PWD_ENCRYPTED) ? '' : img_picto('', 'tick').' ';
485print yn(empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1);
486if (empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
487 print ' <span class="opacitymedium">('.$langs->trans("Recommended").' '.yn(1).')</span>';
488}
489print '<br>';
490print '<br>';
491*/
492
493print '<strong>'.$langs->trans("AntivirusEnabledOnUpload").'</strong>: ';
494print !getDolGlobalString('MAIN_ANTIVIRUS_COMMAND') ? img_warning().' ' : img_picto('', 'tick').' ';
495print yn(!getDolGlobalString('MAIN_ANTIVIRUS_COMMAND') ? 0 : 1);
496if (!getDolGlobalString('MAIN_ANTIVIRUS_COMMAND')) {
497 print ' - <span class="opacitymedium">'.$langs->trans("Recommended").': '.$langs->trans("DefinedAPathForAntivirusCommandIntoSetup", $langs->transnoentitiesnoconv("Home")." - ".$langs->transnoentitiesnoconv("Setup")." - ".$langs->transnoentitiesnoconv("Security")).'</span>';
498} else {
499 print ' &nbsp; - ' . getDolGlobalString('MAIN_ANTIVIRUS_COMMAND');
500 if (defined('MAIN_ANTIVIRUS_COMMAND') && !defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
501 print ' - <span class="opacitymedium">'.$langs->trans("ValueIsForcedBySystem").'</span>';
502 }
503}
504print '<br>';
505print '<br>';
506
507$umask = getDolGlobalString('MAIN_UMASK');
508
509print '<strong>'.$langs->trans("UMask").'</strong>: ';
510if (! in_array($umask, array('600', '660', '0600', '0660'))) {
511 print img_warning().' ';
512}
513print $umask;
514if (! in_array($umask, array('600', '660', '0600', '0660'))) {
515 print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0600 | 0660)</span>';
516}
517print '<br>';
518print '<br>';
519
520
521$securityevent = new Events($db);
522$eventstolog = $securityevent->eventstolog;
523
524print '<strong>'.$langs->trans("AuditedSecurityEvents").'</strong>: ';
525$out = '';
526if (!empty($eventstolog) && is_array($eventstolog)) {
527 // Loop on each event type
528 $i = 0;
529 foreach ($eventstolog as $key => $arr) {
530 if ($arr['id']) {
531 $key = 'MAIN_LOGEVENTS_'.$arr['id'];
532 $value = getDolGlobalString($key);
533 if ($value) {
534 if ($i > 0) {
535 $out .= ', ';
536 }
537 $out .= '<span class="opacitymedium">'.$key.'</span>';
538 $i++;
539 }
540 }
541 }
542 print $out;
543}
544
545if (empty($out)) {
546 print img_warning().' '.$langs->trans("NoSecurityEventsAreAduited", $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit")).'<br>';
547} else {
548 $s = $langs->trans("SeeSetupPage", '{s1}'.$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Security").' - '.$langs->transnoentities("Audit").'{s2}');
549 print ' - '.str_replace('{s2}', '</a>', str_replace('{s1}', '<a href="'.DOL_URL_ROOT.'/admin/events.php" target="_blank">', $s));
550}
551
552print '</div>';
553
554print '<br>';
555
556
557// Modules/Applications
558
559print '<br>';
560print '<br>';
561print load_fiche_titre($langs->trans("Modules"), '', 'folder');
562
563print '<div class="divsection wordbreak">';
564
565// Module log
566print '<strong>'.$langs->trans("Syslog").'</strong>: ';
567$test = isModEnabled('syslog');
568if (!$test) {
569 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
570} else {
571 if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) {
572 print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog"));
573 } else {
574 print img_picto('', 'tick').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL'));
575 }
576 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
577}
578print '<br>';
579
580print '<br>';
581
582// Module debugbar
583print '<strong>'.$langs->trans("DebugBar").'</strong>: ';
584$test = isModEnabled('debugbar');
585if (!$test) {
586 print img_picto('', 'tick').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis");
587} else {
588 print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar"));
589 //print ' '.$langs->trans("MoreInformation").' <a href="'.DOL_URL_ROOT.'/admin/system/xdebug.php'.'">XDebug admin page</a>';
590}
591print '<br>';
592
593
594// Modules for Payments
595$test = isModEnabled('stripe');
596if ($test) {
597 print '<br>';
598
599 print '<strong>'.$langs->trans("Stripe").'</strong>: ';
600 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
601 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
602 } else {
603 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Stripe"));
604 }
605 print '<br>';
606} else {
607 $test = isModEnabled('paypal');
608 if ($test) {
609 print '<br>';
610
611 print '<strong>'.$langs->trans("Paypal").'</strong>: ';
612 if (!getDolGlobalString('PAYMENT_SECURITY_TOKEN_UNIQUE')) {
613 print img_picto('', 'error').' '.$langs->trans("OptionXShouldBeEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
614 } else {
615 print img_picto('', 'tick').' '.$langs->trans("OptionXIsCorrectlyEnabledInModuleY", $langs->transnoentities("SecurityTokenIsUnique"), $langs->transnoentities("Paypal"));
616 }
617 print '<br>';
618 }
619}
620
621print '</div>';
622
623
624// APIs
625
626print '<br>';
627print '<br>';
628print load_fiche_titre($langs->trans("API"), '', 'folder');
629
630print '<div class="divsection wordbreak">';
631
632if (!isModEnabled('api') && !isModEnabled('webservices')) {
633 print $langs->trans("APIsAreNotEnabled");
634} else {
635 if (isModEnabled('webservices')) {
636 print img_picto('', 'warning').' '.$langs->trans('YouEnableDeprecatedWSAPIsUseRESTAPIsInstead')."<br>\n";
637 print '<br>';
638 }
639 if (isModEnabled('api')) {
640 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";
641 }
642}
643
644print '<br>';
645
646print '<strong>API_DISABLE_LOGIN_API</strong> = '.getDolGlobalString('API_DISABLE_LOGIN_API', '0').' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
647
648print '</div>';
649
650
651print '<br>';
652print '<br>';
653
654
655print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
656
657print '<div class="divsection wordbreak">';
658
659print '<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>';
660print '<br>';
661
662print '<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>';
663print '<br>';
664
665print '<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>";
666print '<br>';
667
668print '<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>";
669
670print '</div>';
671
672
673print '<br>';
674print '<br>';
675
676
677print load_fiche_titre($langs->trans("DatabaseEncryption"), '', 'folder');
678
679print '<div class="divsection wordbreak">';
680
681//print '<strong>'.$langs->trans("PasswordEncryption").'</strong>: ';
682print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("Passwords")).' (non reversible encryption, defined into MAIN_SECURITY_HASH_ALGO)</strong> = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>')." &nbsp; ";
683if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) {
684 print '<span class="opacitymedium"> &nbsp; &nbsp; (If unset: \'md5\')</span>';
685}
686if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
687 print '<br><strong>MAIN_SECURITY_SALT</strong> = '.getDolGlobalString('MAIN_SECURITY_SALT', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>').'<br>';
688} else {
689 print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
690 print '<br>';
691}
692if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') {
693 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>';
694 print 'If you really want to switch, you must:<br>';
695 print '- Go on home - setup - other and add constant MAIN_SECURITY_HASH_ALGO to value \'password_hash\'<br>';
696 print '- In same session, WITHOUT LOGGING OUT, go into your admin user record and set a new password<br>';
697 print '- You can now logout and login with this new password. You must now reset password of all other users.<br>';
698 print '</div>';
699}
700print '<br>';
701
702$action = GETPOST('action');
703$exampletodecrypt = GETPOST('exampletodecrypt', 'password');
704
705print '<strong>'.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("SensitiveData")).' (reversible encryption done with dolEncrypt/dolDecrypt)</strong> = '.constant('MAIN_SECURITY_REVERSIBLE_ALGO').' with key defined into conf.php file in $dolibarr_main_instance_unique_id<br>';
706print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
707print '<input type="hidden" name="action" value="doldecrypt">';
708print '<input type="hidden" name="token" value="'.newToken().'">';
709print '<input type="hidden" name="page_y" value="">';
710print $langs->trans("ToolToDecryptAString").': ';
711print '<input type="text" name="exampletodecrypt" placeholder="dolcrypt:ALGOXXXX:ABCDFEF1234" value="'.$exampletodecrypt.'">';
712print '<input type="submit" class="reposition button small smallpaddingimp" name="submit" value="'.$langs->transnoentitiesnoconv("Decrypt").'">';
713if ($action == 'doldecrypt' && $user->admin && $exampletodecrypt) {
714 usleep(200);
715 print ' => <textarea rows="'.ROWS_1.'" class="valignmiddle">'.dolPrintHTMLForTextArea(dolDecrypt($exampletodecrypt)).'</textarea>';
716}
717print '</form>';
718
719print '</div>';
720
721
722print '<br>';
723print '<br>';
724
725
726// Other - experimental
727
728print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
729
730print '<div class="divsection wordbreak">';
731print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
732if (!getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
733 print '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>';
734} else {
735 print $conf->global->MAIN_EXEC_USE_POPEN;
736}
737if ($execmethod == 1) {
738 print '<span class="opacitymedium"> &nbsp; &nbsp; "exec" PHP method will be used for shell commands';
739 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
740 print '</span>';
741}
742if ($execmethod == 2) {
743 print '<span class="opacitymedium"> &nbsp; &nbsp; "popen" PHP method will be used for shell commands';
744 print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
745 print '</span>';
746}
747print '<br>';
748print '<br>';
749
750print '<strong>MAIN_SECURITY_MAXFILESIZE_DOWNLOADED</strong> = '.getDolGlobalString('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED', '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 100000000)</span>')."<br>";
751print '<br>';
752
753print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
754print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span>";
755
756// Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML
757$savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
758$savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
759$savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
760$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
761$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
762$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
763$result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
764$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
765$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
766$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
767
768if ($result == 'InvalidHTMLStringCantBeCleaned') {
769 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
770} else {
771 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
772}
773print '<br>';
774
775print '<br>';
776
777print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
778print ' &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').")";
779if (extension_loaded('tidy') && class_exists("tidy")) {
780 // Test compatibility of MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY
781 $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES');
782 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML');
783 $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY');
784 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
785 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
786 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
787 $result = dol_htmlwithnojs('<img onerror<=alert(document.domain)> src=>0xbeefed');
788 $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = $savMAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES;
789 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML;
790 $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $savMAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
791
792 if ($result == 'InvalidHTMLStringCantBeCleaned') {
793 print ' &nbsp; - &nbsp; '.img_warning().' Your libxml seems to old to work correctly with this option. Disable it !';
794 } else {
795 print ' &nbsp; - &nbsp; Test of compatibility with this option seems ok';
796 }
797}
798print '<br>';
799
800print '<br>';
801
802print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES') ? '1' : '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
803print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").": 1 - does not work on HTML5 with some old libxml libs)</span><br>";
804print '<br>';
805
806// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1, disallow url links except if on /medias
807// MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2, disallow all external urls link
808print '<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 or 2=no links at all)</span>')."<br>";
809print '<br>';
810
811print '<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>";
812print '<br>';
813
814// MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS
815
816print '<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>";
817print '<br>';
818
819print '<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>";
820print '<br>';
821
822$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;";
823print '<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>';
824print '<br>';
825
826$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;";
827print '<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>';
828print '<br>';
829
830print '<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\" so browser doesn't send any referrer when going into another web site domain)</span><br>";
831print '<br>';
832
833print '<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)</span><br>";
834print '<br>';
835
836// For websites
837
838print '<strong>WEBSITE_MAIN_SECURITY_FORCECSPRO</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSPRO', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
839print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
840$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:;";
841print $examplecsprule;
842print '")</span><br>';
843print '<br>';
844
845print '<strong>WEBSITE_MAIN_SECURITY_FORCECSP</strong> = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>');
846print ' &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': "';
847$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:;";
848print $examplecsprule;
849print '")</span><br>';
850print '<br>';
851
852print '<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").'="strict-origin-when-cross-origin" '.$langs->trans("or").' "same-origin"=more secured)</span><br>';
853print '<br>';
854
855print '<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>";
856print '<br>';
857
858print '<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=(), geolocation=*\")</span><br>";
859
860print '</div>';
861
862
863print '<br>';
864
865
866print load_fiche_titre($langs->trans("LimitsAndMitigation"), '', 'folder');
867
868print '<div class="divsection wordbreak">';
869
870print '<span class="opacitymedium">';
871print $langs->trans("RecommendMitigationOnURL").'<br>';
872print '</span>';
873
874print '<br>';
875$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/';
876print '<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>';
877print '<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>';
878print '<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>';
879print '<br>';
880$urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/';
881print '<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>';
882
883print '</div>';
884
885// End of page
886llxFooter();
887$db->close();
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:70
Events class.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
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:63
version_php()
Return PHP version.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external link.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.