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