‪TYPO3CMS  ‪main
SecurityStatusReport.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Http\Message\ServerRequestInterface;
26 
32 {
38  public function ‪getStatus(ServerRequestInterface $request = null): array
39  {
40  if ($request !== null) {
42  }
43  return [
44  'installToolProtection' => $this->‪getInstallToolProtectionStatus(),
45  'serverResponseStatus' => GeneralUtility::makeInstance(ServerResponseCheck::class)->asStatus(),
46  ];
47  }
48 
49  public function ‪getLabel(): string
50  {
51  return 'security';
52  }
53 
60  {
62  // @todo: Note $this->getLanguageService() is declared to allow null. Calling ->sL() may fatal?!
63  $value = $this->‪getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_disabled');
64  $message = '';
65  $severity = ContextualFeedbackSeverity::OK;
68  $severity = ContextualFeedbackSeverity::WARNING;
69  // @todo: See todo on removeInstallToolEnableFilesIfRequested() when this GU::getIndpEnv() is about to be removed.
70  $disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
71  $value = $this->‪getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
72  $message = sprintf(
73  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
74  '<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>'
75  );
76  $message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
77  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
78  } else {
81  } else {
82  $severity = ContextualFeedbackSeverity::NOTICE;
83  // @todo: See todo on removeInstallToolEnableFilesIfRequested() when this GU::getIndpEnv() is about to be removed.
84  $disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
85  $value = $this->‪getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
86  $message = sprintf(
87  $this->‪getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
88  '<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>',
89  floor((@filemtime($enableInstallToolFile) + ‪EnableFileService::INSTALL_TOOL_ENABLE_FILE_LIFETIME - time()) / 60)
90  );
91  $message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
92  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
93  }
94  }
95  }
96  return GeneralUtility::makeInstance(
97  Status::class,
98  $this->‪getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
99  $value,
100  $message,
101  $severity
102  );
103  }
104 
105  private function ‪removeInstallToolEnableFilesIfRequested(ServerRequestInterface $request): void
106  {
107  // @todo: This should of course be a POST-only call! No idea how, but it should be.
108  // Also, the EnableFileService is pretty ugly nowadays, since it can handle
109  // multiple file locations, but does not reflect this in its methods properly.
110  // Thankfully, EnableFileService is @internal, so all this could be cleaned up
111  // without being breaking ...
112  if (($request->getQueryParams()['adminCmd'] ?? '') === 'remove_ENABLE_INSTALL_TOOL') {
114  }
115  }
116 
118  {
119  return ‪$GLOBALS['LANG'] ?? null;
120  }
121 }
‪TYPO3\CMS\Install\Report\SecurityStatusReport\getStatus
‪Status[] getStatus(ServerRequestInterface $request=null)
Definition: SecurityStatusReport.php:38
‪TYPO3\CMS\Install\Report
Definition: EnvironmentStatusReport.php:16
‪TYPO3\CMS\Install\Report\SecurityStatusReport\getLabel
‪getLabel()
Definition: SecurityStatusReport.php:49
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:26
‪TYPO3\CMS\Install\Report\SecurityStatusReport\getInstallToolProtectionStatus
‪Status getInstallToolProtectionStatus()
Definition: SecurityStatusReport.php:59
‪TYPO3\CMS\Install\Report\SecurityStatusReport
Definition: SecurityStatusReport.php:32
‪TYPO3\CMS\Install\Service\EnableFileService\INSTALL_TOOL_ENABLE_FILE_LIFETIME
‪const INSTALL_TOOL_ENABLE_FILE_LIFETIME
Definition: EnableFileService.php:40
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Install\Service\EnableFileService\installToolEnableFileExists
‪static installToolEnableFileExists()
Definition: EnableFileService.php:95
‪TYPO3\CMS\Install\Report\SecurityStatusReport\getLanguageService
‪getLanguageService()
Definition: SecurityStatusReport.php:117
‪TYPO3\CMS\Install\SystemEnvironment\ServerResponse\ServerResponseCheck
Definition: ServerResponseCheck.php:43
‪TYPO3\CMS\Install\Service\EnableFileService\isInstallToolEnableFilePermanent
‪static isInstallToolEnableFilePermanent()
Definition: EnableFileService.php:121
‪TYPO3\CMS\Install\Report\SecurityStatusReport\removeInstallToolEnableFilesIfRequested
‪removeInstallToolEnableFilesIfRequested(ServerRequestInterface $request)
Definition: SecurityStatusReport.php:105
‪TYPO3\CMS\Install\Service\EnableFileService\removeInstallToolEnableFile
‪static removeInstallToolEnableFile()
Definition: EnableFileService.php:70
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Install\Service\EnableFileService\getBestLocationForInstallToolEnableFile
‪static getBestLocationForInstallToolEnableFile()
Definition: EnableFileService.php:170
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Reports\RequestAwareStatusProviderInterface
Definition: RequestAwareStatusProviderInterface.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Install\Service\EnableFileService\installToolEnableFileLifetimeExpired
‪static installToolEnableFileLifetimeExpired()
Definition: EnableFileService.php:135