first commit

This commit is contained in:
salam committed 2026-10-19 08:18:39 +02:00
commit 1218dd1517
12716 files changed
+989233

No files matched your search

@@ -0,0 +1,128 @@
<?php
namespace TYPO3\CMS\Install\Report;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\SystemEnvironment\Check;
use TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck;
use TYPO3\CMS\Install\SystemEnvironment\SetupCheck;
use TYPO3\CMS\Reports\ExtendedStatusProviderInterface;
use TYPO3\CMS\Reports\Status;
use TYPO3\CMS\Reports\StatusProviderInterface;
/**
* Provides an environment status report
* @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
*/
class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatusProviderInterface
{
/**
* Compile environment status report
*
* @return Status[]
*/
public function getStatus()
{
return $this->getStatusInternal(false);
}
/**
* Returns the detailed status of an extension or (sub)system
*
* @return Status[]
*/
public function getDetailedStatus()
{
return $this->getStatusInternal(true);
}
/**
* @param $verbose
* @return Status[]
*/
protected function getStatusInternal($verbose)
{
$statusMessageQueue = new FlashMessageQueue('install');
foreach (GeneralUtility::makeInstance(Check::class)->getStatus() as $message) {
$statusMessageQueue->enqueue($message);
}
foreach (GeneralUtility::makeInstance(SetupCheck::class)->getStatus() as $message) {
$statusMessageQueue->enqueue($message);
}
foreach (GeneralUtility::makeInstance(DatabaseCheck::class)->getStatus() as $message) {
$statusMessageQueue->enqueue($message);
}
$reportStatusTypes = [
'error' => [],
'warning' => [],
'ok' => [],
'information' => [],
'notice' => [],
];
foreach ($statusMessageQueue->toArray() as $message) {
switch ($message->getSeverity()) {
case FlashMessage::ERROR:
$reportStatusTypes['error'][] = $message;
break;
case FlashMessage::WARNING:
$reportStatusTypes['warning'][] = $message;
break;
case FlashMessage::OK:
$reportStatusTypes['ok'][] = $message;
break;
case FlashMessage::INFO:
$reportStatusTypes['information'][] = $message;
break;
case FlashMessage::NOTICE:
$reportStatusTypes['notice'][] = $message;
break;
}
}
$statusArray = [];
foreach ($reportStatusTypes as $type => $statusObjects) {
$value = count($statusObjects);
$message = '';
if ($verbose) {
foreach ($statusObjects as $statusObject) {
$message .= '### ' . $statusObject->getTitle() . ': ' . $statusObject->getSeverity() . CRLF;
}
}
if ($value > 0) {
$pathToXliff = 'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf';
// Map information type to abbreviation which is used in \TYPO3\CMS\Reports\Status class
if ($type === 'information') {
$type = 'info';
}
if (!$verbose) {
$message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
}
$severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
$statusArray[] = GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
$message,
$severity
);
}
}
return $statusArray;
}
}
@@ -0,0 +1,340 @@
<?php
namespace TYPO3\CMS\Install\Report;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\Exception\RemoteFetchException;
use TYPO3\CMS\Install\Service\UpgradeWizardsService;
use TYPO3\CMS\Reports\Status;
/**
* Provides an installation status report.
* @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
*/
class InstallStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
{
protected const WRAP_FLAT = 1;
protected const WRAP_NESTED = 2;
protected $useMarkup;
public function __construct(bool $useMarkup = true)
{
$this->useMarkup = $useMarkup;
}
/**
* Compiles a collection of system status checks as a status report.
*
* @return Status[]
*/
public function getStatus()
{
return [
'FileSystem' => $this->getFileSystemStatus(),
'RemainingUpdates' => $this->getRemainingUpdatesStatus(),
'NewVersion' => $this->getNewVersionStatus(),
];
}
/**
* Checks for several directories being writable.
*
* @return Status Indicates status of the file system
*/
protected function getFileSystemStatus()
{
$languageService = $this->getLanguageService();
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_writable');
$message = '';
$severity = Status::OK;
// Requirement level
// -1 = not required, but if it exists may be writable or not
// 0 = not required, if it exists the dir should be writable
// 1 = required, doesn't have to be writable
// 2 = required, has to be writable
$varPath = Environment::getVarPath();
$sitePath = Environment::getPublicPath();
$rootPath = Environment::getProjectPath();
$checkWritable = [
$sitePath . '/typo3temp/' => 2,
$sitePath . '/typo3temp/assets/' => 2,
$sitePath . '/typo3temp/assets/compressed/' => 2,
// only needed when GraphicalFunctions is used
$sitePath . '/typo3temp/assets/images/' => 0,
// used in PageGenerator (inlineStyle2Temp) and Backend + Language JS files
$sitePath . '/typo3temp/assets/css/' => 2,
$sitePath . '/typo3temp/assets/js/' => 2,
// fallback storage of FAL
$sitePath . '/typo3temp/assets/_processed_/' => 0,
$varPath => 2,
$varPath . '/transient/' => 2,
$varPath . '/charset/' => 2,
$varPath . '/lock/' => 2,
$sitePath . '/typo3conf/' => 2,
Environment::getLabelsPath() => 0,
$sitePath . '/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
$sitePath . '/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
];
// Check for writable extension folder files in non-composer mode only
if (!Environment::isComposerMode()) {
$checkWritable[Environment::getExtensionsPath()] = 0;
if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['allowGlobalInstall']) {
$checkWritable[Environment::getBackendPath() . '/ext/'] = -1;
}
}
foreach ($checkWritable as $path => $requirementLevel) {
$relPath = substr($path, strlen($rootPath) + 1);
if (!@is_dir($path)) {
// If the directory is missing, try to create it
GeneralUtility::mkdir($path);
}
if (!@is_dir($path)) {
if ($requirementLevel > 0) {
// directory is required
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_missingDirectory');
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
$severity = Status::ERROR;
} else {
$message .= sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryDoesNotExist'), $relPath);
if ($requirementLevel == 0) {
$message .= ' ' . $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldAlsoBeWritable');
}
$message .= '<br />';
if ($severity < Status::WARNING) {
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_nonExistingDirectory');
$severity = Status::WARNING;
}
}
} else {
if (!is_writable($path)) {
switch ($requirementLevel) {
case 0:
$message .= sprintf(
$languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryShouldBeWritable'),
$path
) . '<br />';
if ($severity < Status::WARNING) {
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_recommendedWritableDirectory');
$severity = Status::WARNING;
}
break;
case 2:
$value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_requiredWritableDirectory');
$message .= sprintf(
$languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_directoryMustBeWritable'),
$path
) . '<br />';
$severity = Status::ERROR;
break;
default:
}
}
}
}
return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_fileSystem'), $value, $message, $severity);
}
/**
* Returns all incomplete update wizards.
*
* Fetches all wizards that are not marked "done" in the registry and filters out
* the ones that should not be rendered (= no upgrade required).
*
* @return array
*/
protected function getIncompleteWizards(): array
{
$upgradeWizardsService = GeneralUtility::makeInstance(UpgradeWizardsService::class);
$incompleteWizards = $upgradeWizardsService->getUpgradeWizardsList();
$incompleteWizards = array_filter(
$incompleteWizards,
function ($wizard) {
return $wizard['shouldRenderWizard'];
}
);
return $incompleteWizards;
}
/**
* Checks if there are still updates to perform
*
* @return Status Represents whether the installation is completely updated yet
*/
protected function getRemainingUpdatesStatus()
{
$languageService = $this->getLanguageService();
$value = $languageService->getLL('status_updateComplete');
$message = '';
$severity = Status::OK;
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
// check if there are update wizards left to perform
$incompleteWizards = $this->getIncompleteWizards();
if (count($incompleteWizards)) {
// At least one incomplete wizard was found
$value = $languageService->getLL('status_updateIncomplete');
$severity = Status::WARNING;
$url = (string)$uriBuilder->buildUriFromRoute('tools_toolsupgrade');
$message = sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_update'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
}
return GeneralUtility::makeInstance(Status::class, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remainingUpdates'), $value, $message, $severity);
}
/**
* Checks if there is a new minor TYPO3 version to update to.
*
* @return Status Represents whether there is a new version available online
*/
protected function getNewVersionStatus()
{
$languageService = $this->getLanguageService();
/** @var \TYPO3\CMS\Install\Service\CoreVersionService $coreVersionService */
$coreVersionService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\CoreVersionService::class);
// No updates for development versions
if (!$coreVersionService->isInstalledVersionAReleasedVersion()) {
return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_isDevelopmentVersion'), Status::NOTICE);
}
try {
$versionMaintenanceWindow = $coreVersionService->getMaintenanceWindow();
} catch (RemoteFetchException $remoteFetchException) {
return GeneralUtility::makeInstance(
Status::class,
'TYPO3',
TYPO3_version,
$languageService->sL(
'LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_remoteFetchException'
),
Status::NOTICE
);
}
if (!$versionMaintenanceWindow->isSupportedByCommunity() && !$versionMaintenanceWindow->isSupportedByElts()) {
// Version is not maintained
$message = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_versionOutdated');
$status = Status::ERROR;
} else {
$message = '';
$status = Status::OK;
// There is an update available
$availableReleases = [];
$latestRelease = $coreVersionService->getYoungestPatchRelease();
$isCurrentVersionElts = $coreVersionService->isCurrentInstalledVersionElts();
if ($coreVersionService->isPatchReleaseSuitableForUpdate($latestRelease)) {
$availableReleases[] = $latestRelease;
}
if (!$versionMaintenanceWindow->isSupportedByCommunity()) {
if ($latestRelease->isElts()) {
$latestCommunityDrivenRelease = $coreVersionService->getYoungestCommunityPatchRelease();
if ($coreVersionService->isPatchReleaseSuitableForUpdate($latestCommunityDrivenRelease)) {
$availableReleases[] = $latestCommunityDrivenRelease;
}
} elseif (!$isCurrentVersionElts) {
// Inform user about ELTS being available soon if:
// - regular support ran out
// - the current installed version is no ELTS
// - no ELTS update was released, yet
$message = sprintf(
$languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_elts_information'),
TYPO3_version,
'<a href="https://typo3.com/elts" target="_blank" rel="noopener">https://typo3.com/elts</a>'
);
$status = Status::WARNING;
}
}
if ($availableReleases !== []) {
$messages = [];
$status = Status::WARNING;
foreach ($availableReleases as $availableRelease) {
$versionString = $availableRelease->getVersion();
if ($availableRelease->isElts()) {
$versionString .= ' ELTS';
}
if ($coreVersionService->isUpdateSecurityRelevant($availableRelease)) {
$status = Status::ERROR;
$updateMessage = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersionSecurityRelevant'), $versionString);
} else {
$updateMessage = sprintf($languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_newVersion'), $versionString);
}
if ($availableRelease->isElts()) {
if ($isCurrentVersionElts) {
$updateMessage .= ' ' . sprintf(
$languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_elts_download'),
'<a href="https://my.typo3.org" target="_blank" rel="noopener">my.typo3.org</a>'
);
} else {
$updateMessage .= ' ' . sprintf(
$languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_elts_subscribe'),
$coreVersionService->getInstalledVersion(),
'<a href="https://typo3.com/elts" target="_blank" rel="noopener">https://typo3.com/elts</a>'
);
}
}
$messages[] = $updateMessage;
}
$message = $this->wrapList($messages, count($messages) > 1 ? self::WRAP_NESTED : self::WRAP_FLAT);
}
}
return GeneralUtility::makeInstance(Status::class, 'TYPO3', TYPO3_version, $message, $status);
}
protected function wrapList(array $items, int $style): string
{
if (!$this->useMarkup) {
return implode(', ', $items);
}
if ($style === self::WRAP_NESTED) {
return sprintf(
'<ul>%s</ul>',
implode('', $this->wrapItems($items, '<li>', '</li>'))
);
}
return sprintf(
'<p>%s</p>',
implode('', $this->wrapItems($items, '<br>', ''))
);
}
protected function wrapItems(array $items, string $before, string $after): array
{
return array_map(
static function (string $item) use ($before, $after): string {
return $before . $item . $after;
},
array_filter($items)
);
}
/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
@@ -0,0 +1,158 @@
<?php
namespace TYPO3\CMS\Install\Report;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\EnableFileService;
use TYPO3\CMS\Install\SystemEnvironment\ServerResponse\ServerResponseCheck;
use TYPO3\CMS\Reports\Status;
/**
* Provides an status report of the security of the install tool
* @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
*/
class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
{
/**
* Compiles a collection of system status checks as a status report.
*
* @return Status[]
*/
public function getStatus()
{
$this->executeAdminCommand();
return [
'installToolPassword' => $this->getInstallToolPasswordStatus(),
'installToolProtection' => $this->getInstallToolProtectionStatus(),
'serverResponseStatus' => GeneralUtility::makeInstance(ServerResponseCheck::class)->asStatus(),
];
}
/**
* Checks whether the Install Tool password is set to its default value.
*
* @return Status An object representing the security of the install tool password
*/
protected function getInstallToolPasswordStatus()
{
// @todo @deprecated: This should be removed in TYPO3 v10.0 when install tool allows proper hashes only
$value = $GLOBALS['LANG']->getLL('status_ok');
$message = '';
$severity = Status::OK;
$isDefaultPassword = false;
$installToolPassword = $GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'];
$hashInstance = null;
$hashFactory = GeneralUtility::makeInstance(PasswordHashFactory::class);
try {
$hashInstance = $hashFactory->get($installToolPassword, 'BE');
} catch (InvalidPasswordHashException $e) {
// $hashInstance stays null
$value = $GLOBALS['LANG']->getLL('status_wrongValue');
$message = $e->getMessage();
$severity = Status::ERROR;
}
if ($installToolPassword !== '' && $hashInstance !== null) {
$isDefaultPassword = $hashInstance->checkPassword('joh316', $installToolPassword);
} elseif ($installToolPassword === 'bacb98acf97e0b6112b1d1b650b84971') {
// using MD5 of legacy default password 'joh316'
$isDefaultPassword = true;
}
if ($isDefaultPassword) {
$value = $GLOBALS['LANG']->getLL('status_insecure');
$severity = Status::ERROR;
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$changeInstallToolPasswordUrl = (string)$uriBuilder->buildUriFromRoute('tools_toolssettings');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.installtool_default_password'),
'<a href="' . htmlspecialchars($changeInstallToolPasswordUrl) . '">',
'</a>'
);
}
return GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installToolPassword'),
$value,
$message,
$severity
);
}
/**
* Checks for the existence of the ENABLE_INSTALL_TOOL file.
*
* @return Status An object representing whether ENABLE_INSTALL_TOOL exists
*/
protected function getInstallToolProtectionStatus()
{
$enableInstallToolFile = Environment::getPublicPath() . '/' . EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
$value = $GLOBALS['LANG']->getLL('status_disabled');
$message = '';
$severity = Status::OK;
if (EnableFileService::installToolEnableFileExists()) {
if (EnableFileService::isInstallToolEnableFilePermanent()) {
$severity = Status::WARNING;
$disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
'<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>'
);
$message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
} else {
if (EnableFileService::installToolEnableFileLifetimeExpired()) {
EnableFileService::removeInstallToolEnableFile();
} else {
$severity = Status::NOTICE;
$disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
'<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>',
floor((@filemtime($enableInstallToolFile) + EnableFileService::INSTALL_TOOL_ENABLE_FILE_LIFETIME - time()) / 60)
);
$message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
}
}
}
return GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
$value,
$message,
$severity
);
}
/**
* Executes commands like removing the Install Tool enable file.
*/
protected function executeAdminCommand()
{
$command = GeneralUtility::_GET('adminCmd');
switch ($command) {
case 'remove_ENABLE_INSTALL_TOOL':
EnableFileService::removeInstallToolEnableFile();
break;
default:
// Do nothing
}
}
}