security.php 38 KB

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