From dec52f69792d3a039188f6b3c4052db2b094388b Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 12:20:25 +0200 Subject: Migrate getenv test to new SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 45 +++++++++++----------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 9d59051e2a8..960419a252f 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -58,8 +58,8 @@ use OC\DB\MissingIndexInformation; use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OC\IntegrityCheck\Checker; -use OC\Lock\NoopLockingProvider; use OC\Lock\DBLockingProvider; +use OC\Lock\NoopLockingProvider; use OC\MemoryInfo; use OCP\App\IAppManager; use OCP\AppFramework\Controller; @@ -131,27 +131,27 @@ class CheckSetupController extends Controller { private ISetupCheckManager $setupCheckManager; public function __construct($AppName, - IRequest $request, - IConfig $config, - IClientService $clientService, - IURLGenerator $urlGenerator, - IL10N $l10n, - Checker $checker, - LoggerInterface $logger, - IEventDispatcher $dispatcher, - Connection $db, - ILockingProvider $lockingProvider, - IDateTimeFormatter $dateTimeFormatter, - MemoryInfo $memoryInfo, - ISecureRandom $secureRandom, - IniGetWrapper $iniGetWrapper, - IDBConnection $connection, - IThrottler $throttler, - ITempManager $tempManager, - IManager $manager, - IAppManager $appManager, - IServerContainer $serverContainer, - ISetupCheckManager $setupCheckManager, + IRequest $request, + IConfig $config, + IClientService $clientService, + IURLGenerator $urlGenerator, + IL10N $l10n, + Checker $checker, + LoggerInterface $logger, + IEventDispatcher $dispatcher, + Connection $db, + ILockingProvider $lockingProvider, + IDateTimeFormatter $dateTimeFormatter, + MemoryInfo $memoryInfo, + ISecureRandom $secureRandom, + IniGetWrapper $iniGetWrapper, + IDBConnection $connection, + IThrottler $throttler, + ITempManager $tempManager, + IManager $manager, + IAppManager $appManager, + IServerContainer $serverContainer, + ISetupCheckManager $setupCheckManager, ) { parent::__construct($AppName, $request); $this->config = $config; @@ -817,7 +817,6 @@ Raw output public function check() { return new DataResponse( [ - 'isGetenvServerWorking' => !empty(getenv('PATH')), 'isReadOnlyConfig' => $this->isReadOnlyConfig(), 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), 'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(), -- cgit v1.2.3 From 506f3961ecf6616bac81f2c56d5e20d58ab435c6 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 14:35:09 +0200 Subject: Remove duplicated ReadOnlyConfig setup check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 5 ----- .../tests/Controller/CheckSetupControllerTest.php | 6 ------ core/js/setupchecks.js | 6 ------ core/js/tests/specs/setupchecksSpec.js | 25 ---------------------- 4 files changed, 42 deletions(-) (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 960419a252f..4463228fc71 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -564,10 +564,6 @@ Raw output return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); } - protected function isReadOnlyConfig(): bool { - return \OC_Helper::isReadOnlyConfigEnabled(); - } - protected function wasEmailTestSuccessful(): bool { // Handle the case that the configuration was set before the check was introduced or it was only set via command line and not from the UI if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '' && $this->config->getSystemValue('mail_domain', '') === '') { @@ -817,7 +813,6 @@ Raw output public function check() { return new DataResponse( [ - 'isReadOnlyConfig' => $this->isReadOnlyConfig(), 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), 'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(), 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index f6493da1d0b..80cb1ec9ea1 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase { $this->setupCheckManager, ]) ->setMethods([ - 'isReadOnlyConfig', 'wasEmailTestSuccessful', 'hasValidTransactionIsolationLevel', 'hasFileinfoInstalled', @@ -379,10 +378,6 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('isReadOnlyConfig') - ->willReturn(false); $this->checkSetupController ->expects($this->once()) ->method('wasEmailTestSuccessful') @@ -494,7 +489,6 @@ class CheckSetupControllerTest extends TestCase { $expected = new DataResponse( [ - 'isReadOnlyConfig' => false, 'wasEmailTestSuccessful' => false, 'hasValidTransactionIsolationLevel' => true, 'hasFileinfoInstalled' => true, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index d45c54263b2..e94c334db66 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -180,12 +180,6 @@ var afterCall = function(data, statusText, xhr) { var messages = []; if (xhr.status === 200 && data) { - if (data.isReadOnlyConfig) { - messages.push({ - msg: t('core', 'The read-only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if (!data.wasEmailTestSuccessful) { messages.push({ msg: t('core', 'You have not set or verified your email server configuration, yet. Please head over to the {mailSettingsStart}Basic settings{mailSettingsEnd} in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',) diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index ebd9c95aa02..982cb254daa 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -293,7 +292,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -362,7 +360,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -427,7 +424,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -491,7 +487,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -555,7 +550,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: false, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -619,7 +613,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: false, hasDBFileLocking: false, @@ -683,7 +676,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: true, @@ -747,7 +739,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -813,7 +804,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -877,7 +867,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -943,7 +932,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1007,7 +995,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1091,7 +1078,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1162,7 +1148,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1226,7 +1211,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1290,7 +1274,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1358,7 +1341,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1423,7 +1405,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1485,7 +1466,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1550,7 +1530,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1615,7 +1594,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1679,7 +1657,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1743,7 +1720,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, @@ -1814,7 +1790,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - isReadOnlyConfig: false, wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, -- cgit v1.2.3 From 5957a2bf6bfbb89c7c6b689e3eef89b7072fe3cf Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 14:45:05 +0200 Subject: Migrate email test to new SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 15 ---- .../lib/SetupChecks/EmailTestSuccessful.php | 76 +++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 6 -- core/js/setupchecks.js | 8 -- core/js/tests/specs/setupchecksSpec.js | 87 ---------------------- 8 files changed, 80 insertions(+), 116 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/EmailTestSuccessful.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index d5c0995bb46..8626e190ff6 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -75,6 +75,7 @@ return array( 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => $baseDir . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', + 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index bf141287ddf..76b2d357cda 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -90,6 +90,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', + 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 7fa20a6a187..3f6333017c4 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -50,6 +50,7 @@ use OCA\Settings\Search\SectionSearch; use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; use OCA\Settings\SetupChecks\DefaultPhoneRegionSet; +use OCA\Settings\SetupChecks\EmailTestSuccessful; use OCA\Settings\SetupChecks\InternetConnectivity; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\PhpDefaultCharset; @@ -150,6 +151,7 @@ class Application extends App implements IBootstrap { }); $context->registerSetupCheck(CheckUserCertificates::class); $context->registerSetupCheck(DefaultPhoneRegionSet::class); + $context->registerSetupCheck(EmailTestSuccessful::class); $context->registerSetupCheck(InternetConnectivity::class); $context->registerSetupCheck(LegacySSEKeyFormat::class); $context->registerSetupCheck(PhpDefaultCharset::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 4463228fc71..b5d20598cbd 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -564,20 +564,6 @@ Raw output return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); } - protected function wasEmailTestSuccessful(): bool { - // Handle the case that the configuration was set before the check was introduced or it was only set via command line and not from the UI - if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '' && $this->config->getSystemValue('mail_domain', '') === '') { - return false; - } - - // The mail test was unsuccessful or the config was changed using the UI without verifying with a testmail, hence return false - if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '0') { - return false; - } - - return true; - } - protected function hasValidTransactionIsolationLevel(): bool { try { if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) { @@ -814,7 +800,6 @@ Raw output return new DataResponse( [ 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), - 'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(), 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), 'hasDBFileLocking' => $this->hasDBFileLocking(), diff --git a/apps/settings/lib/SetupChecks/EmailTestSuccessful.php b/apps/settings/lib/SetupChecks/EmailTestSuccessful.php new file mode 100644 index 00000000000..cced7866fc7 --- /dev/null +++ b/apps/settings/lib/SetupChecks/EmailTestSuccessful.php @@ -0,0 +1,76 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Settings\SetupChecks; + +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class EmailTestSuccessful implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IConfig $config, + private IURLGenerator $urlGenerator, + ) { + } + + public function getName(): string { + return $this->l10n->t('Email test'); + } + + public function getCategory(): string { + return 'config'; + } + + protected function wasEmailTestSuccessful(): bool { + // Handle the case that the configuration was set before the check was introduced or it was only set via command line and not from the UI + if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '' && $this->config->getSystemValue('mail_domain', '') === '') { + return false; + } + + // The mail test was unsuccessful or the config was changed using the UI without verifying with a testmail, hence return false + if ($this->config->getAppValue('core', 'emailTestSuccessful', '') === '0') { + return false; + } + + return true; + } + + public function run(): SetupResult { + if ($this->wasEmailTestSuccessful()) { + return SetupResult::success($this->l10n->t('Email test was successfully sent')); + } else { + // If setup check could link to settings pages, this one should link to OC.generateUrl('/settings/admin') + return SetupResult::info( + $this->l10n->t('You have not set or verified your email server configuration, yet. Please head over to the "Basic settings" in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.'), + $this->urlGenerator->linkToDocs('admin-email') + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 80cb1ec9ea1..586b59132ee 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase { $this->setupCheckManager, ]) ->setMethods([ - 'wasEmailTestSuccessful', 'hasValidTransactionIsolationLevel', 'hasFileinfoInstalled', 'hasWorkingFileLocking', @@ -378,10 +377,6 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('wasEmailTestSuccessful') - ->willReturn(false); $this->checkSetupController ->expects($this->once()) ->method('hasValidTransactionIsolationLevel') @@ -489,7 +484,6 @@ class CheckSetupControllerTest extends TestCase { $expected = new DataResponse( [ - 'wasEmailTestSuccessful' => false, 'hasValidTransactionIsolationLevel' => true, 'hasFileinfoInstalled' => true, 'hasWorkingFileLocking' => true, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index e94c334db66..04eed184c90 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -180,14 +180,6 @@ var afterCall = function(data, statusText, xhr) { var messages = []; if (xhr.status === 200 && data) { - if (!data.wasEmailTestSuccessful) { - messages.push({ - msg: t('core', 'You have not set or verified your email server configuration, yet. Please head over to the {mailSettingsStart}Basic settings{mailSettingsEnd} in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',) - .replace('{mailSettingsStart}', '') - .replace('{mailSettingsEnd}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if (!data.hasValidTransactionIsolationLevel) { messages.push({ msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'), diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 982cb254daa..14f8d95e962 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -292,7 +291,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -360,7 +358,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -424,7 +421,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -487,7 +483,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -540,69 +535,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an info if the mail server config was not set or verified, yet', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasFileinfoInstalled: true, - wasEmailTestSuccessful: false, - hasWorkingFileLocking: true, - hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'You have not set or verified your email server configuration, yet. Please head over to the Basic settings in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - it('should return an info if transactional file locking is not set up', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -613,7 +545,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: false, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -676,7 +607,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: true, hasValidTransactionIsolationLevel: true, @@ -739,7 +669,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -804,7 +733,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -867,7 +795,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -932,7 +859,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -995,7 +921,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1078,7 +1003,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1148,7 +1072,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1211,7 +1134,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1274,7 +1196,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1341,7 +1262,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1405,7 +1325,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1466,7 +1385,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1530,7 +1448,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1594,7 +1511,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1657,7 +1573,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1720,7 +1635,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, @@ -1790,7 +1704,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ hasFileinfoInstalled: true, - wasEmailTestSuccessful: true, hasWorkingFileLocking: true, hasDBFileLocking: false, hasValidTransactionIsolationLevel: true, -- cgit v1.2.3 From 3c75075eba3414da7b3c4db9aefe22da074cdcd9 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:04:02 +0200 Subject: Migrate database transaction level check to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 17 ----- .../lib/SetupChecks/TransactionIsolation.php | 75 ++++++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 6 -- core/js/tests/specs/setupchecksSpec.js | 24 ------- 7 files changed, 79 insertions(+), 47 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/TransactionIsolation.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index 8626e190ff6..b770553839e 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -85,6 +85,7 @@ return array( 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => $baseDir . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => $baseDir . '/../lib/SetupChecks/TransactionIsolation.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => $baseDir . '/../lib/UserMigration/AccountMigrator.php', 'OCA\\Settings\\UserMigration\\AccountMigratorException' => $baseDir . '/../lib/UserMigration/AccountMigratorException.php', 'OCA\\Settings\\WellKnown\\ChangePasswordHandler' => $baseDir . '/../lib/WellKnown/ChangePasswordHandler.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 76b2d357cda..c8aff3de76e 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -100,6 +100,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => __DIR__ . '/..' . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => __DIR__ . '/..' . '/../lib/SetupChecks/TransactionIsolation.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigrator.php', 'OCA\\Settings\\UserMigration\\AccountMigratorException' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigratorException.php', 'OCA\\Settings\\WellKnown\\ChangePasswordHandler' => __DIR__ . '/..' . '/../lib/WellKnown/ChangePasswordHandler.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 3f6333017c4..abc61c7e601 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -60,6 +60,7 @@ use OCA\Settings\SetupChecks\PhpOutdated; use OCA\Settings\SetupChecks\PhpOutputBuffering; use OCA\Settings\SetupChecks\ReadOnlyConfig; use OCA\Settings\SetupChecks\SupportedDatabase; +use OCA\Settings\SetupChecks\TransactionIsolation; use OCA\Settings\UserMigration\AccountMigrator; use OCA\Settings\WellKnown\ChangePasswordHandler; use OCA\Settings\WellKnown\SecurityTxtHandler; @@ -161,6 +162,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(PhpOutputBuffering::class); $context->registerSetupCheck(ReadOnlyConfig::class); $context->registerSetupCheck(SupportedDatabase::class); + $context->registerSetupCheck(TransactionIsolation::class); $context->registerUserMigrator(AccountMigrator::class); } diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index b5d20598cbd..dc36e8208e3 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -47,8 +47,6 @@ namespace OCA\Settings\Controller; use bantu\IniGetWrapper\IniGetWrapper; use DirectoryIterator; -use Doctrine\DBAL\Exception; -use Doctrine\DBAL\TransactionIsolationLevel; use GuzzleHttp\Exception\ClientException; use OC; use OC\AppFramework\Http; @@ -564,20 +562,6 @@ Raw output return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); } - protected function hasValidTransactionIsolationLevel(): bool { - try { - if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) { - return true; - } - - return $this->db->getTransactionIsolation() === TransactionIsolationLevel::READ_COMMITTED; - } catch (Exception $e) { - // ignore - } - - return true; - } - protected function hasFileinfoInstalled(): bool { return \OC_Util::fileInfoLoaded(); } @@ -799,7 +783,6 @@ Raw output public function check() { return new DataResponse( [ - 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(), 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), 'hasDBFileLocking' => $this->hasDBFileLocking(), diff --git a/apps/settings/lib/SetupChecks/TransactionIsolation.php b/apps/settings/lib/SetupChecks/TransactionIsolation.php new file mode 100644 index 00000000000..3b7be7da3e1 --- /dev/null +++ b/apps/settings/lib/SetupChecks/TransactionIsolation.php @@ -0,0 +1,75 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Settings\SetupChecks; + +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\TransactionIsolationLevel; +use OC\DB\Connection; +use OCP\IDBConnection; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class TransactionIsolation implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IURLGenerator $urlGenerator, + private IDBConnection $connection, + private Connection $db, + ) { + } + + public function getName(): string { + return $this->l10n->t('Database transaction isolation level'); + } + + public function getCategory(): string { + return 'database'; + } + + public function run(): SetupResult { + try { + if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) { + return SetupResult::success(); + } + + if ($this->db->getTransactionIsolation() === TransactionIsolationLevel::READ_COMMITTED) { + return SetupResult::success('Read committed'); + } else { + return SetupResult::error( + $this->l10n->t('Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'), + $this->urlGenerator->linkToDocs('admin-db-transaction') + ); + } + } catch (Exception $e) { + return SetupResult::warning( + $this->l10n->t('Was not able to get transaction isolation level: %s', $e->getMessage()) + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 586b59132ee..b08c639f45f 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase { $this->setupCheckManager, ]) ->setMethods([ - 'hasValidTransactionIsolationLevel', 'hasFileinfoInstalled', 'hasWorkingFileLocking', 'hasDBFileLocking', @@ -377,10 +376,6 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('hasValidTransactionIsolationLevel') - ->willReturn(true); $this->checkSetupController ->expects($this->once()) ->method('hasFileinfoInstalled') @@ -484,7 +479,6 @@ class CheckSetupControllerTest extends TestCase { $expected = new DataResponse( [ - 'hasValidTransactionIsolationLevel' => true, 'hasFileinfoInstalled' => true, 'hasWorkingFileLocking' => true, 'hasDBFileLocking' => true, diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 14f8d95e962..306813c90f9 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -226,7 +226,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -293,7 +292,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -360,7 +358,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -423,7 +420,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: false, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -485,7 +481,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -547,7 +542,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: false, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -609,7 +603,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: true, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -671,7 +664,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -735,7 +727,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -797,7 +788,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -861,7 +851,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -923,7 +912,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -1005,7 +993,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1074,7 +1061,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1136,7 +1122,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1198,7 +1183,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1264,7 +1248,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1327,7 +1310,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1387,7 +1369,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1450,7 +1431,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1513,7 +1493,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1575,7 +1554,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1637,7 +1615,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1706,7 +1683,6 @@ describe('OC.SetupChecks tests', function() { hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, - hasValidTransactionIsolationLevel: true, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', -- cgit v1.2.3 From f9770b8ef27cfa503e06708e127a014c3c08828b Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:06:30 +0200 Subject: Remove duplicate fileinfo PHP module check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 5 ----- .../tests/Controller/CheckSetupControllerTest.php | 6 ------ core/js/tests/specs/setupchecksSpec.js | 24 ---------------------- 3 files changed, 35 deletions(-) (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index dc36e8208e3..4abef63dc7b 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -562,10 +562,6 @@ Raw output return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); } - protected function hasFileinfoInstalled(): bool { - return \OC_Util::fileInfoLoaded(); - } - protected function hasWorkingFileLocking(): bool { return !($this->lockingProvider instanceof NoopLockingProvider); } @@ -783,7 +779,6 @@ Raw output public function check() { return new DataResponse( [ - 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(), 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), 'hasDBFileLocking' => $this->hasDBFileLocking(), 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(), diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index b08c639f45f..661deddb913 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase { $this->setupCheckManager, ]) ->setMethods([ - 'hasFileinfoInstalled', 'hasWorkingFileLocking', 'hasDBFileLocking', 'getLastCronInfo', @@ -376,10 +375,6 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('hasFileinfoInstalled') - ->willReturn(true); $this->checkSetupController ->expects($this->once()) ->method('hasWorkingFileLocking') @@ -479,7 +474,6 @@ class CheckSetupControllerTest extends TestCase { $expected = new DataResponse( [ - 'hasFileinfoInstalled' => true, 'hasWorkingFileLocking' => true, 'hasDBFileLocking' => true, 'suggestedOverwriteCliURL' => '', diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 306813c90f9..357e111e3ee 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -223,7 +223,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -289,7 +288,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -355,7 +353,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -417,7 +414,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -478,7 +474,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -539,7 +534,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: false, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -600,7 +594,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: true, suggestedOverwriteCliURL: '', @@ -661,7 +654,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -724,7 +716,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -785,7 +776,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -848,7 +838,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -909,7 +898,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -990,7 +978,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1058,7 +1045,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1119,7 +1105,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1180,7 +1165,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1245,7 +1229,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1307,7 +1290,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1366,7 +1348,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1428,7 +1409,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1490,7 +1470,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1551,7 +1530,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1612,7 +1590,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', @@ -1680,7 +1657,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, hasWorkingFileLocking: true, hasDBFileLocking: false, suggestedOverwriteCliURL: '', -- cgit v1.2.3 From 6911dc30e6032d11dda3a45a679aec9cf5cf0ccf Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:16:28 +0200 Subject: Migrated both file locking checks to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 12 -- apps/settings/lib/SetupChecks/FileLocking.php | 78 ++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 12 -- core/js/setupchecks.js | 28 ---- core/js/tests/specs/setupchecksSpec.js | 164 --------------------- 8 files changed, 82 insertions(+), 216 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/FileLocking.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index b770553839e..540a88aa31e 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -76,6 +76,7 @@ return array( 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => $baseDir . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php', + 'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index c8aff3de76e..ee18ef73023 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -91,6 +91,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php', + 'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index abc61c7e601..412008084b4 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -51,6 +51,7 @@ use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; use OCA\Settings\SetupChecks\DefaultPhoneRegionSet; use OCA\Settings\SetupChecks\EmailTestSuccessful; +use OCA\Settings\SetupChecks\FileLocking; use OCA\Settings\SetupChecks\InternetConnectivity; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\PhpDefaultCharset; @@ -153,6 +154,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(CheckUserCertificates::class); $context->registerSetupCheck(DefaultPhoneRegionSet::class); $context->registerSetupCheck(EmailTestSuccessful::class); + $context->registerSetupCheck(FileLocking::class); $context->registerSetupCheck(InternetConnectivity::class); $context->registerSetupCheck(LegacySSEKeyFormat::class); $context->registerSetupCheck(PhpDefaultCharset::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 4abef63dc7b..8e912a2212e 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -56,8 +56,6 @@ use OC\DB\MissingIndexInformation; use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OC\IntegrityCheck\Checker; -use OC\Lock\DBLockingProvider; -use OC\Lock\NoopLockingProvider; use OC\MemoryInfo; use OCP\App\IAppManager; use OCP\AppFramework\Controller; @@ -562,14 +560,6 @@ Raw output return str_contains($this->config->getSystemValue('dbtype'), 'sqlite'); } - protected function hasWorkingFileLocking(): bool { - return !($this->lockingProvider instanceof NoopLockingProvider); - } - - protected function hasDBFileLocking(): bool { - return ($this->lockingProvider instanceof DBLockingProvider); - } - protected function getSuggestedOverwriteCliURL(): string { $currentOverwriteCliUrl = $this->config->getSystemValue('overwrite.cli.url', ''); $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; @@ -779,8 +769,6 @@ Raw output public function check() { return new DataResponse( [ - 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(), - 'hasDBFileLocking' => $this->hasDBFileLocking(), 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(), 'cronInfo' => $this->getLastCronInfo(), 'cronErrors' => $this->getCronErrors(), diff --git a/apps/settings/lib/SetupChecks/FileLocking.php b/apps/settings/lib/SetupChecks/FileLocking.php new file mode 100644 index 00000000000..8012751ab9f --- /dev/null +++ b/apps/settings/lib/SetupChecks/FileLocking.php @@ -0,0 +1,78 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Settings\SetupChecks; + +use OC\Lock\DBLockingProvider; +use OC\Lock\NoopLockingProvider; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Lock\ILockingProvider; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class FileLocking implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IURLGenerator $urlGenerator, + private ILockingProvider $lockingProvider, + ) { + } + + public function getName(): string { + return $this->l10n->t('File locking'); + } + + public function getCategory(): string { + return 'system'; + } + + protected function hasWorkingFileLocking(): bool { + return !($this->lockingProvider instanceof NoopLockingProvider); + } + + protected function hasDBFileLocking(): bool { + return ($this->lockingProvider instanceof DBLockingProvider); + } + + public function run(): SetupResult { + if (!$this->hasWorkingFileLocking()) { + return SetupResult::warning( + $this->l10n->t('Transactional file locking is disabled, this might lead to issues with race conditions. Enable "filelocking.enabled" in config.php to avoid these problems.'), + $this->urlGenerator->linkToDocs('admin-transactional-locking') + ); + } + + if ($this->hasDBFileLocking()) { + return SetupResult::info( + $this->l10n->t('The database is used for transactional file locking. To enhance performance, please configure memcache, if available.'), + $this->urlGenerator->linkToDocs('admin-transactional-locking') + ); + } + + return SetupResult::success(); + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 661deddb913..b273d3e29cd 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,8 +189,6 @@ class CheckSetupControllerTest extends TestCase { $this->setupCheckManager, ]) ->setMethods([ - 'hasWorkingFileLocking', - 'hasDBFileLocking', 'getLastCronInfo', 'getSuggestedOverwriteCliURL', 'getCurlVersion', @@ -375,14 +373,6 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('hasWorkingFileLocking') - ->willReturn(true); - $this->checkSetupController - ->expects($this->once()) - ->method('hasDBFileLocking') - ->willReturn(true); $this->checkSetupController ->expects($this->once()) ->method('getSuggestedOverwriteCliURL') @@ -474,8 +464,6 @@ class CheckSetupControllerTest extends TestCase { $expected = new DataResponse( [ - 'hasWorkingFileLocking' => true, - 'hasDBFileLocking' => true, 'suggestedOverwriteCliURL' => '', 'cronInfo' => [ 'diffInSeconds' => 123, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 04eed184c90..ba83ff93812 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -180,18 +180,6 @@ var afterCall = function(data, statusText, xhr) { var messages = []; if (xhr.status === 200 && data) { - if (!data.hasValidTransactionIsolationLevel) { - messages.push({ - msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if(!data.hasFileinfoInstalled) { - messages.push({ - msg: t('core', 'The PHP module "fileinfo" is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if (data.isBruteforceThrottled) { messages.push({ msg: t('core', 'Your remote address was identified as "{remoteAddress}" and is bruteforce throttled at the moment slowing down the performance of various requests. If the remote address is not your address this can be an indication that a proxy is not configured correctly. Further information can be found in the {linkstart}documentation ↗{linkend}.', { remoteAddress: data.bruteforceRemoteAddress }) @@ -200,22 +188,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_ERROR }); } - if(!data.hasWorkingFileLocking) { - messages.push({ - msg: t('core', 'Transactional file locking is disabled, this might lead to issues with race conditions. Enable "filelocking.enabled" in config.php to avoid these problems. See the {linkstart}documentation ↗{linkend} for more information.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if(data.hasDBFileLocking) { - messages.push({ - msg: t('core', 'The database is used for transactional file locking. To enhance performance, please configure memcache, if available. See the {linkstart}documentation ↗{linkend} for more information.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if (data.suggestedOverwriteCliURL !== '') { messages.push({ msg: t('core', 'Please make sure to set the "overwrite.cli.url" option in your config.php file to the URL that your users mainly use to access this Nextcloud. Suggestion: "{suggestedOverwriteCliURL}". Otherwise there might be problems with the URL generation via cron. (It is possible though that the suggested URL is not the URL that your users mainly use to access this Nextcloud. Best is to double check this in any case.)', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}), diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 357e111e3ee..89d3cdfc926 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -223,8 +223,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -288,8 +286,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -353,8 +349,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -414,8 +408,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: false, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -474,8 +466,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -525,126 +515,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an info if transactional file locking is not set up', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasWorkingFileLocking: false, - hasDBFileLocking: false, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Transactional file locking is disabled, this might lead to issues with race conditions. Enable "filelocking.enabled" in config.php to avoid these problems. See the documentation ↗ for more information.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return an info if database file locking is used', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The database is used for transactional file locking. To enhance performance, please configure memcache, if available. See the documentation ↗ for more information.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - it('should return a warning if there are app directories with wrong permissions', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -654,8 +524,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -716,8 +584,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -776,8 +642,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -838,8 +702,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -898,8 +760,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, @@ -978,8 +838,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1045,8 +903,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1105,8 +961,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1165,8 +1019,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1229,8 +1081,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1290,8 +1140,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1348,8 +1196,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1409,8 +1255,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1470,8 +1314,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1530,8 +1372,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1590,8 +1430,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', @@ -1657,8 +1495,6 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasWorkingFileLocking: true, - hasDBFileLocking: false, suggestedOverwriteCliURL: '', isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', -- cgit v1.2.3 From ddd13a90d81e3198d06ac35b1dd4674a87e677ad Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:24:00 +0200 Subject: Migrate memcache check to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 10 ---- .../lib/SetupChecks/MemcacheConfigured.php | 60 ++++++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 30 ----------- core/js/setupchecks.js | 8 --- core/js/tests/specs/setupchecksSpec.js | 30 ----------- 8 files changed, 64 insertions(+), 78 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/MemcacheConfigured.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index 540a88aa31e..c045d8975ca 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -79,6 +79,7 @@ return array( 'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', + 'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => $baseDir . '/../lib/SetupChecks/MemcacheConfigured.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpGetEnv' => $baseDir . '/../lib/SetupChecks/PhpGetEnv.php', 'OCA\\Settings\\SetupChecks\\PhpModules' => $baseDir . '/../lib/SetupChecks/PhpModules.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index ee18ef73023..5506a36e58a 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -94,6 +94,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', + 'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => __DIR__ . '/..' . '/../lib/SetupChecks/MemcacheConfigured.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpGetEnv' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpGetEnv.php', 'OCA\\Settings\\SetupChecks\\PhpModules' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpModules.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 412008084b4..b0c6bfbc636 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -54,6 +54,7 @@ use OCA\Settings\SetupChecks\EmailTestSuccessful; use OCA\Settings\SetupChecks\FileLocking; use OCA\Settings\SetupChecks\InternetConnectivity; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; +use OCA\Settings\SetupChecks\MemcacheConfigured; use OCA\Settings\SetupChecks\PhpDefaultCharset; use OCA\Settings\SetupChecks\PhpModules; use OCA\Settings\SetupChecks\PhpGetEnv; @@ -157,6 +158,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(FileLocking::class); $context->registerSetupCheck(InternetConnectivity::class); $context->registerSetupCheck(LegacySSEKeyFormat::class); + $context->registerSetupCheck(MemcacheConfigured::class); $context->registerSetupCheck(PhpDefaultCharset::class); $context->registerSetupCheck(PhpModules::class); $context->registerSetupCheck(PhpGetEnv::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 8e912a2212e..ccdadcb3cea 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -194,14 +194,6 @@ class CheckSetupController extends Controller { return $this->manager->isFairUseOfFreePushService(); } - /** - * Checks whether a local memcache is installed or not - * @return bool - */ - private function isMemcacheConfigured() { - return $this->config->getSystemValue('memcache.local', null) !== null; - } - /** * Whether PHP can generate "secure" pseudorandom integers * @@ -775,8 +767,6 @@ Raw output 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(), 'isBruteforceThrottled' => $this->throttler->getAttempts($this->request->getRemoteAddress()) !== 0, 'bruteforceRemoteAddress' => $this->request->getRemoteAddress(), - 'isMemcacheConfigured' => $this->isMemcacheConfigured(), - 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), 'isRandomnessSecure' => $this->isRandomnessSecure(), 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php new file mode 100644 index 00000000000..2cde18a25df --- /dev/null +++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php @@ -0,0 +1,60 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCA\Settings\SetupChecks; + +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class MemcacheConfigured implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IConfig $config, + private IURLGenerator $urlGenerator, + ) { + } + + public function getName(): string { + return $this->l10n->t('Memcache'); + } + + public function getCategory(): string { + return 'system'; + } + + public function run(): SetupResult { + if ($this->config->getSystemValue('memcache.local', null) !== null) { + return SetupResult::success($this->l10n->t('Configured')); + } else { + return SetupResult::info( + $this->l10n->t('No memory cache has been configured. To enhance performance, please configure a memcache, if available.'), + $this->urlGenerator->linkToDocs('admin-performance') + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index b273d3e29cd..f992ecf8591 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -222,34 +222,6 @@ class CheckSetupControllerTest extends TestCase { $this->dirsToRemove = []; } - public function testIsMemcacheConfiguredFalse() { - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('memcache.local', null) - ->willReturn(null); - - $this->assertFalse( - self::invokePrivate( - $this->checkSetupController, - 'isMemcacheConfigured' - ) - ); - } - - public function testIsMemcacheConfiguredTrue() { - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('memcache.local', null) - ->willReturn('SomeProvider'); - - $this->assertTrue( - self::invokePrivate( - $this->checkSetupController, - 'isMemcacheConfigured' - ) - ); - } - /** * @dataProvider dataForwardedForHeadersWorking * @@ -471,8 +443,6 @@ class CheckSetupControllerTest extends TestCase { 'backgroundJobsUrl' => 'https://example.org', ], 'cronErrors' => [], - 'isMemcacheConfigured' => true, - 'memcacheDocs' => 'http://docs.example.org/server/go.php?to=admin-performance', 'isRandomnessSecure' => self::invokePrivate($this->checkSetupController, 'isRandomnessSecure'), 'securityDocs' => 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html', 'isUsedTlsLibOutdated' => '', diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index ba83ff93812..a334c0bd789 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -224,14 +224,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_ERROR }); } - if(!data.isMemcacheConfigured) { - messages.push({ - msg: t('core', 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if(!data.isRandomnessSecure) { messages.push({ msg: t('core', 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the {linkstart}documentation ↗{linkend}.') diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 89d3cdfc926..c1160d08f17 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -226,7 +226,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -264,10 +263,6 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([ - { - msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation ↗.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }, { msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING @@ -289,7 +284,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -327,10 +321,6 @@ describe('OC.SetupChecks tests', function() { async.done(function( data, s, x ){ expect(data).toEqual([ - { - msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation ↗.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }, { msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING @@ -352,7 +342,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -412,7 +401,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: false, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -470,7 +458,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: false, hasPassedCodeIntegrityCheck: true, @@ -528,7 +515,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -587,7 +573,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: false, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, @@ -647,7 +632,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, isBruteforceThrottled: true, bruteforceRemoteAddress: '::1', - isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, @@ -705,7 +689,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, @@ -763,7 +746,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, @@ -842,7 +824,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -907,7 +888,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -965,7 +945,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1023,7 +1002,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1085,7 +1063,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1144,7 +1121,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1200,7 +1176,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1259,7 +1234,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1318,7 +1292,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1376,7 +1349,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1434,7 +1406,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, @@ -1499,7 +1470,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, -- cgit v1.2.3 From 147b29fca2f36cc0d633486e30b7694c157b26e0 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:31:09 +0200 Subject: Migrate Randomness secure check to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 21 ----- apps/settings/lib/SetupChecks/RandomnessSecure.php | 63 +++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 10 --- core/js/setupchecks.js | 8 -- core/js/tests/specs/setupchecksSpec.js | 92 ---------------------- 8 files changed, 67 insertions(+), 131 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/RandomnessSecure.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index c045d8975ca..c69b49ec309 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -85,6 +85,7 @@ return array( 'OCA\\Settings\\SetupChecks\\PhpModules' => $baseDir . '/../lib/SetupChecks/PhpModules.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', + 'OCA\\Settings\\SetupChecks\\RandomnessSecure' => $baseDir . '/../lib/SetupChecks/RandomnessSecure.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => $baseDir . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => $baseDir . '/../lib/SetupChecks/TransactionIsolation.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 5506a36e58a..eba8fadc98a 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -100,6 +100,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\PhpModules' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpModules.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', + 'OCA\\Settings\\SetupChecks\\RandomnessSecure' => __DIR__ . '/..' . '/../lib/SetupChecks/RandomnessSecure.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => __DIR__ . '/..' . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => __DIR__ . '/..' . '/../lib/SetupChecks/TransactionIsolation.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index b0c6bfbc636..0770418c3bb 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -60,6 +60,7 @@ use OCA\Settings\SetupChecks\PhpModules; use OCA\Settings\SetupChecks\PhpGetEnv; use OCA\Settings\SetupChecks\PhpOutdated; use OCA\Settings\SetupChecks\PhpOutputBuffering; +use OCA\Settings\SetupChecks\RandomnessSecure; use OCA\Settings\SetupChecks\ReadOnlyConfig; use OCA\Settings\SetupChecks\SupportedDatabase; use OCA\Settings\SetupChecks\TransactionIsolation; @@ -164,6 +165,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(PhpGetEnv::class); $context->registerSetupCheck(PhpOutdated::class); $context->registerSetupCheck(PhpOutputBuffering::class); + $context->registerSetupCheck(RandomnessSecure::class); $context->registerSetupCheck(ReadOnlyConfig::class); $context->registerSetupCheck(SupportedDatabase::class); $context->registerSetupCheck(TransactionIsolation::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index ccdadcb3cea..f5849cce5a8 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -80,7 +80,6 @@ use OCP\IURLGenerator; use OCP\Lock\ILockingProvider; use OCP\Notification\IManager; use OCP\Security\Bruteforce\IThrottler; -use OCP\Security\ISecureRandom; use OCP\SetupCheck\ISetupCheckManager; use Psr\Log\LoggerInterface; @@ -108,8 +107,6 @@ class CheckSetupController extends Controller { private $dateTimeFormatter; /** @var MemoryInfo */ private $memoryInfo; - /** @var ISecureRandom */ - private $secureRandom; /** @var IniGetWrapper */ private $iniGetWrapper; /** @var IDBConnection */ @@ -139,7 +136,6 @@ class CheckSetupController extends Controller { ILockingProvider $lockingProvider, IDateTimeFormatter $dateTimeFormatter, MemoryInfo $memoryInfo, - ISecureRandom $secureRandom, IniGetWrapper $iniGetWrapper, IDBConnection $connection, IThrottler $throttler, @@ -162,7 +158,6 @@ class CheckSetupController extends Controller { $this->lockingProvider = $lockingProvider; $this->dateTimeFormatter = $dateTimeFormatter; $this->memoryInfo = $memoryInfo; - $this->secureRandom = $secureRandom; $this->iniGetWrapper = $iniGetWrapper; $this->connection = $connection; $this->tempManager = $tempManager; @@ -194,20 +189,6 @@ class CheckSetupController extends Controller { return $this->manager->isFairUseOfFreePushService(); } - /** - * Whether PHP can generate "secure" pseudorandom integers - * - * @return bool - */ - private function isRandomnessSecure() { - try { - $this->secureRandom->generate(1); - } catch (\Exception $ex) { - return false; - } - return true; - } - /** * Public for the sake of unit-testing * @@ -767,8 +748,6 @@ Raw output 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(), 'isBruteforceThrottled' => $this->throttler->getAttempts($this->request->getRemoteAddress()) !== 0, 'bruteforceRemoteAddress' => $this->request->getRemoteAddress(), - 'isRandomnessSecure' => $this->isRandomnessSecure(), - 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), diff --git a/apps/settings/lib/SetupChecks/RandomnessSecure.php b/apps/settings/lib/SetupChecks/RandomnessSecure.php new file mode 100644 index 00000000000..c30d4f2f79a --- /dev/null +++ b/apps/settings/lib/SetupChecks/RandomnessSecure.php @@ -0,0 +1,63 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCA\Settings\SetupChecks; + +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Security\ISecureRandom; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class RandomnessSecure implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IConfig $config, + private IURLGenerator $urlGenerator, + private ISecureRandom $secureRandom, + ) { + } + + public function getName(): string { + return $this->l10n->t('Random generator'); + } + + public function getCategory(): string { + return 'security'; + } + + public function run(): SetupResult { + try { + $this->secureRandom->generate(1); + } catch (\Exception $ex) { + return SetupResult::error( + $this->l10n->t('No suitable source for randomness found by PHP which is highly discouraged for security reasons.'), + $this->urlGenerator->linkToDocs('admin-security') + ); + } + return SetupResult::success($this->l10n->t('Secure')); + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index f992ecf8591..693d80744ce 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -40,7 +40,6 @@ use OC; use OC\DB\Connection; use OC\IntegrityCheck\Checker; use OC\MemoryInfo; -use OC\Security\SecureRandom; use OCA\Settings\Controller\CheckSetupController; use OCP\App\IAppManager; use OCP\AppFramework\Http; @@ -100,8 +99,6 @@ class CheckSetupControllerTest extends TestCase { private $dateTimeFormatter; /** @var MemoryInfo|MockObject */ private $memoryInfo; - /** @var SecureRandom|\PHPUnit\Framework\MockObject\MockObject */ - private $secureRandom; /** @var IniGetWrapper|\PHPUnit\Framework\MockObject\MockObject */ private $iniGetWrapper; /** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */ @@ -154,7 +151,6 @@ class CheckSetupControllerTest extends TestCase { $this->memoryInfo = $this->getMockBuilder(MemoryInfo::class) ->setMethods(['isMemoryLimitSufficient',]) ->getMock(); - $this->secureRandom = $this->getMockBuilder(SecureRandom::class)->getMock(); $this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class)->getMock(); $this->connection = $this->getMockBuilder(IDBConnection::class) ->disableOriginalConstructor()->getMock(); @@ -178,7 +174,6 @@ class CheckSetupControllerTest extends TestCase { $this->lockingProvider, $this->dateTimeFormatter, $this->memoryInfo, - $this->secureRandom, $this->iniGetWrapper, $this->connection, $this->throttler, @@ -443,8 +438,6 @@ class CheckSetupControllerTest extends TestCase { 'backgroundJobsUrl' => 'https://example.org', ], 'cronErrors' => [], - 'isRandomnessSecure' => self::invokePrivate($this->checkSetupController, 'isRandomnessSecure'), - 'securityDocs' => 'https://docs.example.org/server/8.1/admin_manual/configuration_server/hardening.html', 'isUsedTlsLibOutdated' => '', 'forwardedForHeadersWorking' => false, 'reverseProxyDocs' => 'reverse-proxy-doc-link', @@ -495,7 +488,6 @@ class CheckSetupControllerTest extends TestCase { $this->lockingProvider, $this->dateTimeFormatter, $this->memoryInfo, - $this->secureRandom, $this->iniGetWrapper, $this->connection, $this->throttler, @@ -1224,7 +1216,6 @@ Array $this->lockingProvider, $this->dateTimeFormatter, $this->memoryInfo, - $this->secureRandom, $this->iniGetWrapper, $this->connection, $this->throttler, @@ -1280,7 +1271,6 @@ Array $this->lockingProvider, $this->dateTimeFormatter, $this->memoryInfo, - $this->secureRandom, $this->iniGetWrapper, $this->connection, $this->throttler, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index a334c0bd789..029096b43b2 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -224,14 +224,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_ERROR }); } - if(!data.isRandomnessSecure) { - messages.push({ - msg: t('core', 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } if(data.isUsedTlsLibOutdated) { messages.push({ msg: data.isUsedTlsLibOutdated, diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index c1160d08f17..eaea1d2f5b8 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -282,7 +281,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -340,7 +338,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -388,63 +385,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an error if /dev/urandom is not accessible', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - suggestedOverwriteCliURL: '', - isRandomnessSecure: false, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the documentation ↗.', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - it('should return an error if the wrong memcache PHP module is installed', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -455,8 +395,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: false, @@ -512,8 +450,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -571,7 +507,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: false, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -628,7 +563,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, isBruteforceThrottled: true, bruteforceRemoteAddress: '::1', @@ -687,7 +621,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -744,7 +677,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -821,8 +753,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -885,8 +815,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -942,8 +870,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -999,8 +925,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1060,8 +984,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1118,8 +1040,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1173,8 +1093,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1231,8 +1149,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1289,8 +1205,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1346,8 +1260,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1403,8 +1315,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1467,8 +1377,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, -- cgit v1.2.3 From 086d3ceecc211f255dd24e6ffaed553a6ca2046d Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 15:51:51 +0200 Subject: Migrate code integrity to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 2 - apps/settings/lib/SetupChecks/CodeIntegrity.php | 63 ++++++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 2 - core/js/setupchecks.js | 10 ---- core/js/tests/specs/setupchecksSpec.js | 21 -------- 8 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/CodeIntegrity.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index c69b49ec309..d18528ff4d4 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -74,6 +74,7 @@ return array( 'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir . '/../lib/Settings/Personal/Security/WebAuthn.php', 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => $baseDir . '/../lib/SetupChecks/CheckUserCertificates.php', + 'OCA\\Settings\\SetupChecks\\CodeIntegrity' => $baseDir . '/../lib/SetupChecks/CodeIntegrity.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index eba8fadc98a..5512082304f 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -89,6 +89,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php', 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php', + 'OCA\\Settings\\SetupChecks\\CodeIntegrity' => __DIR__ . '/..' . '/../lib/SetupChecks/CodeIntegrity.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 0770418c3bb..518dc88bfa0 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -49,6 +49,7 @@ use OCA\Settings\Search\AppSearch; use OCA\Settings\Search\SectionSearch; use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; +use OCA\Settings\SetupChecks\CodeIntegrity; use OCA\Settings\SetupChecks\DefaultPhoneRegionSet; use OCA\Settings\SetupChecks\EmailTestSuccessful; use OCA\Settings\SetupChecks\FileLocking; @@ -154,6 +155,7 @@ class Application extends App implements IBootstrap { ); }); $context->registerSetupCheck(CheckUserCertificates::class); + $context->registerSetupCheck(CodeIntegrity::class); $context->registerSetupCheck(DefaultPhoneRegionSet::class); $context->registerSetupCheck(EmailTestSuccessful::class); $context->registerSetupCheck(FileLocking::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index f5849cce5a8..80dd6952980 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -752,8 +752,6 @@ Raw output 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), - 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), - 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), 'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), diff --git a/apps/settings/lib/SetupChecks/CodeIntegrity.php b/apps/settings/lib/SetupChecks/CodeIntegrity.php new file mode 100644 index 00000000000..234e1fbf058 --- /dev/null +++ b/apps/settings/lib/SetupChecks/CodeIntegrity.php @@ -0,0 +1,63 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCA\Settings\SetupChecks; + +use OC\IntegrityCheck\Checker; +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class CodeIntegrity implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IURLGenerator $urlGenerator, + private Checker $checker, + ) { + } + + public function getName(): string { + return $this->l10n->t('Code integrity'); + } + + public function getCategory(): string { + return 'security'; + } + + public function run(): SetupResult { + if (!$this->checker->isCodeCheckEnforced()) { + return SetupResult::info($this->l10n->t('Integrity checker has been disabled. Integrity cannot be verified.')); + } elseif ($this->checker->hasPassedCheck()) { + return SetupResult::success($this->l10n->t('No altered files')); + } else { + // FIXME: If setup check can link to settings pages this should link to /settings/integrity/failed and /settings/integrity/rescan?requesttoken=TOKEN + return SetupResult::error( + $this->l10n->t('Some files have not passed the integrity check.'), + $this->urlGenerator->linkToDocs('admin-code-integrity') + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 693d80744ce..86305aecdc6 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -442,8 +442,6 @@ class CheckSetupControllerTest extends TestCase { 'forwardedForHeadersWorking' => false, 'reverseProxyDocs' => 'reverse-proxy-doc-link', 'isCorrectMemcachedPHPModuleInstalled' => true, - 'hasPassedCodeIntegrityCheck' => true, - 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity', 'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'], 'isSettimelimitAvailable' => true, 'hasFreeTypeSupport' => false, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 029096b43b2..80b6e077578 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -246,16 +246,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } - if(!data.hasPassedCodeIntegrityCheck) { - messages.push({ - msg: t('core', 'Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the {linkstart1}documentation ↗{linkend}. ({linkstart2}List of invalid files…{linkend} / {linkstart3}Rescan…{linkend})') - .replace('{linkstart1}', '') - .replace('{linkstart2}', '') - .replace('{linkstart3}', '') - .replace(/{linkend}/g, ''), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } if(data.OpcacheSetupRecommendations.length > 0) { var listOfOPcacheRecommendations = ""; data.OpcacheSetupRecommendations.forEach(function(element){ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index eaea1d2f5b8..fc5fa35a64e 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -227,7 +227,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -284,7 +283,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -341,7 +339,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -398,7 +395,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: false, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -453,7 +449,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -511,7 +506,6 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: false, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -569,7 +563,6 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -625,7 +618,6 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: false, hasFreeTypeSupport: true, @@ -681,7 +673,6 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -756,7 +747,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -818,7 +808,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -873,7 +862,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: false, @@ -928,7 +916,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -987,7 +974,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1043,7 +1029,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1096,7 +1081,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1152,7 +1136,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1208,7 +1191,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1263,7 +1245,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1318,7 +1299,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, @@ -1380,7 +1360,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, hasFreeTypeSupport: true, -- cgit v1.2.3 From ac3da13b38d2bb4ec658b5f89e35d56271db3f22 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 16:07:11 +0200 Subject: Migrate Freetype check to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 9 --- .../lib/SetupChecks/PhpFreetypeSupport.php | 63 ++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 5 -- core/js/setupchecks.js | 6 -- core/js/tests/specs/setupchecksSpec.js | 74 ---------------------- 8 files changed, 67 insertions(+), 94 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/PhpFreetypeSupport.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index d18528ff4d4..5c29e5ece4d 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -82,6 +82,7 @@ return array( 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => $baseDir . '/../lib/SetupChecks/MemcacheConfigured.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', + 'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => $baseDir . '/../lib/SetupChecks/PhpFreetypeSupport.php', 'OCA\\Settings\\SetupChecks\\PhpGetEnv' => $baseDir . '/../lib/SetupChecks/PhpGetEnv.php', 'OCA\\Settings\\SetupChecks\\PhpModules' => $baseDir . '/../lib/SetupChecks/PhpModules.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 5512082304f..250ca31757c 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -97,6 +97,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => __DIR__ . '/..' . '/../lib/SetupChecks/MemcacheConfigured.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', + 'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpFreetypeSupport.php', 'OCA\\Settings\\SetupChecks\\PhpGetEnv' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpGetEnv.php', 'OCA\\Settings\\SetupChecks\\PhpModules' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpModules.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 518dc88bfa0..7516a307d00 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -58,6 +58,7 @@ use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\MemcacheConfigured; use OCA\Settings\SetupChecks\PhpDefaultCharset; use OCA\Settings\SetupChecks\PhpModules; +use OCA\Settings\SetupChecks\PhpFreetypeSupport; use OCA\Settings\SetupChecks\PhpGetEnv; use OCA\Settings\SetupChecks\PhpOutdated; use OCA\Settings\SetupChecks\PhpOutputBuffering; @@ -164,6 +165,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(MemcacheConfigured::class); $context->registerSetupCheck(PhpDefaultCharset::class); $context->registerSetupCheck(PhpModules::class); + $context->registerSetupCheck(PhpFreetypeSupport::class); $context->registerSetupCheck(PhpGetEnv::class); $context->registerSetupCheck(PhpOutdated::class); $context->registerSetupCheck(PhpOutputBuffering::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 80dd6952980..270956326ed 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -454,14 +454,6 @@ Raw output return $recommendations; } - /** - * Check if the required FreeType functions are present - * @return bool - */ - protected function hasFreeTypeSupport() { - return function_exists('imagettfbbox') && function_exists('imagettftext'); - } - protected function hasMissingIndexes(): array { $indexInfo = new MissingIndexInformation(); @@ -754,7 +746,6 @@ Raw output 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), 'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), - 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), 'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(), 'missingIndexes' => $this->hasMissingIndexes(), 'missingColumns' => $this->hasMissingColumns(), diff --git a/apps/settings/lib/SetupChecks/PhpFreetypeSupport.php b/apps/settings/lib/SetupChecks/PhpFreetypeSupport.php new file mode 100644 index 00000000000..3c67c3ddb6e --- /dev/null +++ b/apps/settings/lib/SetupChecks/PhpFreetypeSupport.php @@ -0,0 +1,63 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Settings\SetupChecks; + +use OCP\IL10N; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class PhpFreetypeSupport implements ISetupCheck { + public function __construct( + private IL10N $l10n, + ) { + } + + public function getName(): string { + return $this->l10n->t('Freetype'); + } + + public function getCategory(): string { + return 'php'; + } + + /** + * Check if the required FreeType functions are present + */ + protected function hasFreeTypeSupport(): bool { + return function_exists('imagettfbbox') && function_exists('imagettftext'); + } + + public function run(): SetupResult { + if ($this->hasFreeTypeSupport()) { + return SetupResult::success($this->l10n->t('Supported')); + } else { + return SetupResult::info( + $this->l10n->t('Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'), + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 86305aecdc6..6e65d4a5a5c 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase { 'getCurlVersion', 'isPhpOutdated', 'getOpcacheSetupRecommendations', - 'hasFreeTypeSupport', 'hasMissingIndexes', 'hasMissingPrimaryKeys', 'isSqliteUsed', @@ -328,9 +327,6 @@ class CheckSetupControllerTest extends TestCase { ->expects($this->once()) ->method('getOpcacheSetupRecommendations') ->willReturn(['recommendation1', 'recommendation2']); - $this->checkSetupController - ->method('hasFreeTypeSupport') - ->willReturn(false); $this->checkSetupController ->method('hasMissingIndexes') ->willReturn([]); @@ -444,7 +440,6 @@ class CheckSetupControllerTest extends TestCase { 'isCorrectMemcachedPHPModuleInstalled' => true, 'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'], 'isSettimelimitAvailable' => true, - 'hasFreeTypeSupport' => false, 'isSqliteUsed' => false, 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', 'missingIndexes' => [], diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 80b6e077578..d19034f3419 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -264,12 +264,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } - if (!data.hasFreeTypeSupport) { - messages.push({ - msg: t('core', 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } if (data.missingIndexes.length > 0) { var listOfMissingIndexes = ""; data.missingIndexes.forEach(function(element){ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index fc5fa35a64e..cb8a74b26a2 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -229,7 +229,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -285,7 +284,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -341,7 +339,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -397,7 +394,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: false, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -451,7 +447,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -508,7 +503,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -565,7 +559,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -620,7 +613,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: false, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -675,7 +667,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -749,7 +740,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -810,7 +800,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -849,60 +838,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an info if server has no FreeType support', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - suggestedOverwriteCliURL: '', - isFairUseOfFreePushService: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: false, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - it('should return an error if the php version is no longer supported', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -918,7 +853,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -976,7 +910,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1031,7 +964,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1083,7 +1015,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1138,7 +1069,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1193,7 +1123,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1247,7 +1176,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1301,7 +1229,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], @@ -1362,7 +1289,6 @@ describe('OC.SetupChecks tests', function() { isCorrectMemcachedPHPModuleInstalled: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, - hasFreeTypeSupport: true, missingIndexes: [], missingPrimaryKeys: [], missingColumns: [], -- cgit v1.2.3 From 0fd5ed98540860acf87ff709765f28619ed8d3b9 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 26 Oct 2023 16:53:57 +0200 Subject: Migrate 32bit check to SetupCheck API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 + .../settings/composer/composer/autoload_static.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 9 --- apps/settings/lib/SetupChecks/SystemIs64bit.php | 67 ++++++++++++++++++++ .../tests/Controller/CheckSetupControllerTest.php | 7 --- core/js/setupchecks.js | 11 ---- core/js/tests/specs/setupchecksSpec.js | 72 ---------------------- 8 files changed, 71 insertions(+), 99 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/SystemIs64bit.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index 5c29e5ece4d..b78c044a02c 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -90,6 +90,7 @@ return array( 'OCA\\Settings\\SetupChecks\\RandomnessSecure' => $baseDir . '/../lib/SetupChecks/RandomnessSecure.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => $baseDir . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\SetupChecks\\SystemIs64bit' => $baseDir . '/../lib/SetupChecks/SystemIs64bit.php', 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => $baseDir . '/../lib/SetupChecks/TransactionIsolation.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => $baseDir . '/../lib/UserMigration/AccountMigrator.php', 'OCA\\Settings\\UserMigration\\AccountMigratorException' => $baseDir . '/../lib/UserMigration/AccountMigratorException.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 250ca31757c..18dae0aaec5 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -105,6 +105,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\RandomnessSecure' => __DIR__ . '/..' . '/../lib/SetupChecks/RandomnessSecure.php', 'OCA\\Settings\\SetupChecks\\ReadOnlyConfig' => __DIR__ . '/..' . '/../lib/SetupChecks/ReadOnlyConfig.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', + 'OCA\\Settings\\SetupChecks\\SystemIs64bit' => __DIR__ . '/..' . '/../lib/SetupChecks/SystemIs64bit.php', 'OCA\\Settings\\SetupChecks\\TransactionIsolation' => __DIR__ . '/..' . '/../lib/SetupChecks/TransactionIsolation.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigrator.php', 'OCA\\Settings\\UserMigration\\AccountMigratorException' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigratorException.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 7516a307d00..dfb65669e8e 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -65,6 +65,7 @@ use OCA\Settings\SetupChecks\PhpOutputBuffering; use OCA\Settings\SetupChecks\RandomnessSecure; use OCA\Settings\SetupChecks\ReadOnlyConfig; use OCA\Settings\SetupChecks\SupportedDatabase; +use OCA\Settings\SetupChecks\SystemIs64bit; use OCA\Settings\SetupChecks\TransactionIsolation; use OCA\Settings\UserMigration\AccountMigrator; use OCA\Settings\WellKnown\ChangePasswordHandler; @@ -172,6 +173,7 @@ class Application extends App implements IBootstrap { $context->registerSetupCheck(RandomnessSecure::class); $context->registerSetupCheck(ReadOnlyConfig::class); $context->registerSetupCheck(SupportedDatabase::class); + $context->registerSetupCheck(SystemIs64bit::class); $context->registerSetupCheck(TransactionIsolation::class); $context->registerUserMigrator(AccountMigrator::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 270956326ed..d316e39d503 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -632,14 +632,6 @@ Raw output return true; } - protected function is64bit(): bool { - if (PHP_INT_SIZE < 8) { - return false; - } else { - return true; - } - } - protected function isMysqlUsedWithoutUTF8MB4(): bool { return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false); } @@ -755,7 +747,6 @@ Raw output 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(), 'isImagickEnabled' => $this->isImagickEnabled(), 'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(), - 'is64bit' => $this->is64bit(), 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(), 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(), 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(), diff --git a/apps/settings/lib/SetupChecks/SystemIs64bit.php b/apps/settings/lib/SetupChecks/SystemIs64bit.php new file mode 100644 index 00000000000..e4c21af2387 --- /dev/null +++ b/apps/settings/lib/SetupChecks/SystemIs64bit.php @@ -0,0 +1,67 @@ + + * + * @author Côme Chilliet + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Settings\SetupChecks; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class SystemIs64bit implements ISetupCheck { + public function __construct( + private IL10N $l10n, + private IURLGenerator $urlGenerator, + ) { + } + + public function getName(): string { + return $this->l10n->t('Architecture'); + } + + public function getCategory(): string { + return 'system'; + } + + protected function is64bit(): bool { + if (PHP_INT_SIZE < 8) { + return false; + } else { + return true; + } + } + + public function run(): SetupResult { + if ($this->is64bit()) { + return SetupResult::success($this->l10n->t('64-bit')); + } else { + return SetupResult::warning( + $this->l10n->t('It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit!'), + $this->urlGenerator->linkToDocs('admin-system-requirements') + ); + } + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 6e65d4a5a5c..bab02f981bf 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -196,7 +196,6 @@ class CheckSetupControllerTest extends TestCase { 'getAppDirsWithDifferentOwner', 'isImagickEnabled', 'areWebauthnExtensionsEnabled', - 'is64bit', 'hasBigIntConversionPendingColumns', 'isMysqlUsedWithoutUTF8MB4', 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed', @@ -371,11 +370,6 @@ class CheckSetupControllerTest extends TestCase { ->method('areWebauthnExtensionsEnabled') ->willReturn(false); - $this->checkSetupController - ->expects($this->once()) - ->method('is64bit') - ->willReturn(false); - $this->checkSetupController ->expects($this->once()) ->method('hasBigIntConversionPendingColumns') @@ -449,7 +443,6 @@ class CheckSetupControllerTest extends TestCase { 'appDirsWithDifferentOwner' => [], 'isImagickEnabled' => false, 'areWebauthnExtensionsEnabled' => false, - 'is64bit' => false, 'pendingBigIntConversionColumns' => [], 'isMysqlUsedWithoutUTF8MB4' => false, 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index d19034f3419..0f95eb8c4a5 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -318,17 +318,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_INFO }) } - if (!data.is64bit) { - messages.push({ - msg: t( - 'core', - 'It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit! For further details read {linkstart}the documentation page ↗{linkend} about this.' - .replace('{linkstart}', '') - .replace('{linkend}', ''), - ), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } if (data.imageMagickLacksSVGSupport) { messages.push({ msg: t('core', 'Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.'), diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index cb8a74b26a2..733042c3f99 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -240,7 +240,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -295,7 +294,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -350,7 +348,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -405,7 +402,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -460,7 +456,6 @@ describe('OC.SetupChecks tests', function() { ], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -514,7 +509,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -570,7 +564,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -624,7 +617,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -678,7 +670,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -751,7 +742,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -811,7 +801,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -864,7 +853,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -921,7 +909,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -975,7 +962,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -1026,7 +1012,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false, @@ -1080,7 +1065,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: false, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -1134,7 +1118,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: false, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -1161,59 +1144,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an error for 32bit instances', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - suggestedOverwriteCliURL: '', - isFairUseOfFreePushService: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: false, - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'It seems like you are running a 32-bit PHP version. Nextcloud needs 64-bit to run well. Please upgrade your OS and PHP to 64-bit! For further details read the documentation page ↗ about this.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - it('should return an info if there is no default phone region', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -1240,7 +1170,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, @@ -1300,7 +1229,6 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [], isImagickEnabled: true, areWebauthnExtensionsEnabled: true, - is64bit: true, pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, -- cgit v1.2.3 From 00d3856b92aa533777907b990d76e98bb4d3c9dc Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Mon, 6 Nov 2023 17:48:42 +0100 Subject: Revert "Migrate code integrity to SetupCheck API" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit aa2d315d95d37b48752d0e92d0ce79913be1d4f1. Signed-off-by: Côme Chilliet --- .../composer/composer/autoload_classmap.php | 1 - .../settings/composer/composer/autoload_static.php | 1 - apps/settings/lib/AppInfo/Application.php | 4 +- .../lib/Controller/CheckSetupController.php | 2 + apps/settings/lib/SetupChecks/CodeIntegrity.php | 63 ---------------------- .../tests/Controller/CheckSetupControllerTest.php | 2 + core/js/setupchecks.js | 10 ++++ core/js/tests/specs/setupchecksSpec.js | 19 +++++++ 8 files changed, 34 insertions(+), 68 deletions(-) delete mode 100644 apps/settings/lib/SetupChecks/CodeIntegrity.php (limited to 'apps/settings/lib/Controller/CheckSetupController.php') diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index b78c044a02c..f4d29d724f7 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -74,7 +74,6 @@ return array( 'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir . '/../lib/Settings/Personal/Security/WebAuthn.php', 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => $baseDir . '/../lib/SetupChecks/CheckUserCertificates.php', - 'OCA\\Settings\\SetupChecks\\CodeIntegrity' => $baseDir . '/../lib/SetupChecks/CodeIntegrity.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => $baseDir . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\FileLocking' => $baseDir . '/../lib/SetupChecks/FileLocking.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 18dae0aaec5..f8595eb7c68 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -89,7 +89,6 @@ class ComposerStaticInitSettings 'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php', 'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php', 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php', - 'OCA\\Settings\\SetupChecks\\CodeIntegrity' => __DIR__ . '/..' . '/../lib/SetupChecks/CodeIntegrity.php', 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\EmailTestSuccessful' => __DIR__ . '/..' . '/../lib/SetupChecks/EmailTestSuccessful.php', 'OCA\\Settings\\SetupChecks\\FileLocking' => __DIR__ . '/..' . '/../lib/SetupChecks/FileLocking.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index dfb65669e8e..d2539864708 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -49,7 +49,6 @@ use OCA\Settings\Search\AppSearch; use OCA\Settings\Search\SectionSearch; use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; -use OCA\Settings\SetupChecks\CodeIntegrity; use OCA\Settings\SetupChecks\DefaultPhoneRegionSet; use OCA\Settings\SetupChecks\EmailTestSuccessful; use OCA\Settings\SetupChecks\FileLocking; @@ -57,9 +56,9 @@ use OCA\Settings\SetupChecks\InternetConnectivity; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\MemcacheConfigured; use OCA\Settings\SetupChecks\PhpDefaultCharset; -use OCA\Settings\SetupChecks\PhpModules; use OCA\Settings\SetupChecks\PhpFreetypeSupport; use OCA\Settings\SetupChecks\PhpGetEnv; +use OCA\Settings\SetupChecks\PhpModules; use OCA\Settings\SetupChecks\PhpOutdated; use OCA\Settings\SetupChecks\PhpOutputBuffering; use OCA\Settings\SetupChecks\RandomnessSecure; @@ -157,7 +156,6 @@ class Application extends App implements IBootstrap { ); }); $context->registerSetupCheck(CheckUserCertificates::class); - $context->registerSetupCheck(CodeIntegrity::class); $context->registerSetupCheck(DefaultPhoneRegionSet::class); $context->registerSetupCheck(EmailTestSuccessful::class); $context->registerSetupCheck(FileLocking::class); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index d316e39d503..04efb6b47a7 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -736,6 +736,8 @@ Raw output 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), + 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), + 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), 'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), 'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(), diff --git a/apps/settings/lib/SetupChecks/CodeIntegrity.php b/apps/settings/lib/SetupChecks/CodeIntegrity.php deleted file mode 100644 index 234e1fbf058..00000000000 --- a/apps/settings/lib/SetupChecks/CodeIntegrity.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * @author Côme Chilliet - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ -namespace OCA\Settings\SetupChecks; - -use OC\IntegrityCheck\Checker; -use OCP\IL10N; -use OCP\IURLGenerator; -use OCP\SetupCheck\ISetupCheck; -use OCP\SetupCheck\SetupResult; - -class CodeIntegrity implements ISetupCheck { - public function __construct( - private IL10N $l10n, - private IURLGenerator $urlGenerator, - private Checker $checker, - ) { - } - - public function getName(): string { - return $this->l10n->t('Code integrity'); - } - - public function getCategory(): string { - return 'security'; - } - - public function run(): SetupResult { - if (!$this->checker->isCodeCheckEnforced()) { - return SetupResult::info($this->l10n->t('Integrity checker has been disabled. Integrity cannot be verified.')); - } elseif ($this->checker->hasPassedCheck()) { - return SetupResult::success($this->l10n->t('No altered files')); - } else { - // FIXME: If setup check can link to settings pages this should link to /settings/integrity/failed and /settings/integrity/rescan?requesttoken=TOKEN - return SetupResult::error( - $this->l10n->t('Some files have not passed the integrity check.'), - $this->urlGenerator->linkToDocs('admin-code-integrity') - ); - } - } -} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index bab02f981bf..e8087fbd2d1 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -432,6 +432,8 @@ class CheckSetupControllerTest extends TestCase { 'forwardedForHeadersWorking' => false, 'reverseProxyDocs' => 'reverse-proxy-doc-link', 'isCorrectMemcachedPHPModuleInstalled' => true, + 'hasPassedCodeIntegrityCheck' => true, + 'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity', 'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'], 'isSettimelimitAvailable' => true, 'isSqliteUsed' => false, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 0f95eb8c4a5..f5ac8575365 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -246,6 +246,16 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } + if(!data.hasPassedCodeIntegrityCheck) { + messages.push({ + msg: t('core', 'Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the {linkstart1}documentation ↗{linkend}. ({linkstart2}List of invalid files…{linkend} / {linkstart3}Rescan…{linkend})') + .replace('{linkstart1}', '') + .replace('{linkstart2}', '') + .replace('{linkstart3}', '') + .replace(/{linkend}/g, ''), + type: OC.SetupChecks.MESSAGE_TYPE_ERROR + }); + } if(data.OpcacheSetupRecommendations.length > 0) { var listOfOPcacheRecommendations = ""; data.OpcacheSetupRecommendations.forEach(function(element){ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 733042c3f99..246574653a9 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -227,6 +227,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -281,6 +282,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -335,6 +337,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -389,6 +392,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: false, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -441,6 +445,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -496,6 +501,7 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: false, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -551,6 +557,7 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -604,6 +611,7 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: false, missingIndexes: [], @@ -657,6 +665,7 @@ describe('OC.SetupChecks tests', function() { forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -729,6 +738,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -788,6 +798,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'], isSettimelimitAvailable: true, missingIndexes: [], @@ -840,6 +851,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -896,6 +908,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -949,6 +962,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -999,6 +1013,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -1052,6 +1067,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -1105,6 +1121,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -1157,6 +1174,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], @@ -1216,6 +1234,7 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], isSettimelimitAvailable: true, missingIndexes: [], -- cgit v1.2.3