From eb1d612d961b562e744b8c6d8d361075b6daad55 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 23 May 2022 09:25:47 +0200 Subject: [PATCH 01/24] Add api to register setup checks Signed-off-by: Carl Schwan --- apps/settings/appinfo/routes.php | 1 + apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 18 ++++- .../lib/SetupChecks/CheckUserCertificates.php | 48 +++++--------- apps/settings/src/components/SetupCheck.vue | 64 ++++++++++++++++++ apps/settings/src/main-admin-setup-check.js | 43 ++++++++++++ .../templates/settings/admin/overview.php | 3 + lib/composer/composer/autoload_classmap.php | 2 + lib/composer/composer/autoload_static.php | 2 + .../Bootstrap/RegistrationContext.php | 30 ++++++++- lib/private/SetupCheck/SetupCheckManager.php | 31 +++++++++ .../Bootstrap/IRegistrationContext.php | 10 +++ lib/public/SetupCheck/ISetupCheck.php | 23 +++++++ lib/public/SetupCheck/SetupResult.php | 66 +++++++++++++++++++ webpack.modules.js | 1 + 15 files changed, 307 insertions(+), 37 deletions(-) create mode 100644 apps/settings/src/components/SetupCheck.vue create mode 100644 apps/settings/src/main-admin-setup-check.js create mode 100644 lib/private/SetupCheck/SetupCheckManager.php create mode 100644 lib/public/SetupCheck/ISetupCheck.php create mode 100644 lib/public/SetupCheck/SetupResult.php diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index e238510b1a75f..266237eabce7e 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -65,6 +65,7 @@ ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST' , 'root' => ''], ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET' , 'root' => ''], ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET' , 'root' => ''], + ['name' => 'CheckSetup#setupCheckManager', 'url' => '/settings/setupcheck', 'verb' => 'GET' , 'root' => ''], ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET' , 'root' => ''], ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET' , 'root' => ''], ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET' , 'root' => ''], diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index c69826f7842a5..22993a79485dd 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -48,6 +48,7 @@ use OCA\Settings\Search\AppSearch; use OCA\Settings\Search\SectionSearch; use OCA\Settings\Search\UserSearch; +use OCA\Settings\SetupChecks\CheckUserCertificates; use OCA\Settings\UserMigration\AccountMigrator; use OCA\Settings\WellKnown\ChangePasswordHandler; use OCA\Settings\WellKnown\SecurityTxtHandler; @@ -137,6 +138,7 @@ public function register(IRegistrationContext $context): void { Util::getDefaultEmailAddress('no-reply') ); }); + $context->registerSetupCheck(CheckUserCertificates::class); $context->registerUserMigrator(AccountMigrator::class); } diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 5dcf6cda29c84..bcfd23603006e 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -135,6 +135,7 @@ class CheckSetupController extends Controller { private $appManager; /** @var IServerContainer */ private $serverContainer; + private OC\SetupCheck\SetupCheckManager $setupCheckManager; public function __construct($AppName, IRequest $request, @@ -156,7 +157,8 @@ public function __construct($AppName, ITempManager $tempManager, IManager $manager, IAppManager $appManager, - IServerContainer $serverContainer + IServerContainer $serverContainer, + OC\SetupCheck\SetupCheckManager $setupCheckManager ) { parent::__construct($AppName, $request); $this->config = $config; @@ -178,6 +180,16 @@ public function __construct($AppName, $this->manager = $manager; $this->appManager = $appManager; $this->serverContainer = $serverContainer; + $this->setupCheckManager = $setupCheckManager; + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @return DataResponse + */ + public function setupCheckManager(): DataResponse { + return new DataResponse($this->setupCheckManager->runAll()); } /** @@ -909,7 +921,7 @@ public function check() { $phpDefaultCharset = new PhpDefaultCharset(); $phpOutputBuffering = new PhpOutputBuffering(); $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator); - $checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator); + //$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator); $supportedDatabases = new SupportedDatabase($this->l10n, $this->connection); $ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer); $needsSystemAddressBookSync = new NeedsSystemAddressBookSync($this->config, $this->l10n); @@ -963,7 +975,7 @@ public function check() { PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()], PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()], LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()], - CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()], + //CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()], 'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '', SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()], 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(), diff --git a/apps/settings/lib/SetupChecks/CheckUserCertificates.php b/apps/settings/lib/SetupChecks/CheckUserCertificates.php index 52fea7b6551d7..38832bd28605b 100644 --- a/apps/settings/lib/SetupChecks/CheckUserCertificates.php +++ b/apps/settings/lib/SetupChecks/CheckUserCertificates.php @@ -4,6 +4,7 @@ /** * @copyright Copyright (c) 2020 Morris Jobke + * @copyright Copyright (c) 2022 Carl Schwan * * @author Morris Jobke * @@ -27,50 +28,35 @@ use OCP\IConfig; use OCP\IL10N; -use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; -class CheckUserCertificates { - /** @var IL10N */ - private $l10n; - /** @var string */ - private $configValue; - /** @var IURLGenerator */ - private $urlGenerator; +class CheckUserCertificates implements ISetupCheck { + private IL10N $l10n; + private string $configValue; - public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) { + public function __construct(IL10N $l10n, IConfig $config) { $this->l10n = $l10n; $configValue = $config->getAppValue('files_external', 'user_certificate_scan', ''); $this->configValue = $configValue; - $this->urlGenerator = $urlGenerator; } - public function description(): string { - if ($this->configValue === '') { - return ''; - } - if ($this->configValue === 'not-run-yet') { - return $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.'); - } - return $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.'); + public function getCategory(): string { + return 'security'; } - public function severity(): string { - return 'warning'; + public function getName(): string { + return $this->l10n->t('Checking for old user imported certificate'); } - public function run(): bool { + public function run(): SetupResult { // all fine if neither "not-run-yet" nor a result - return $this->configValue === ''; - } - - public function elements(): array { - if ($this->configValue === '' || $this->configValue === 'not-run-yet') { - return []; + if ($this->configValue === '') { + return new SetupResult(SetupResult::SUCCESS); } - $data = json_decode($this->configValue); - if (!is_array($data)) { - return []; + if ($this->configValue === 'not-run-yet') { + return new SetupResult(SetupResult::INFO, $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.')); } - return $data; + return new SetupResult(SetupResult::ERROR, $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.')); } } diff --git a/apps/settings/src/components/SetupCheck.vue b/apps/settings/src/components/SetupCheck.vue new file mode 100644 index 0000000000000..f5317386a06a6 --- /dev/null +++ b/apps/settings/src/components/SetupCheck.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/apps/settings/src/main-admin-setup-check.js b/apps/settings/src/main-admin-setup-check.js new file mode 100644 index 0000000000000..b05889a06f0a5 --- /dev/null +++ b/apps/settings/src/main-admin-setup-check.js @@ -0,0 +1,43 @@ +/** + * @copyright 2022 Christopher Ng + * + * @author Christopher Ng + * + * @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 . + * + */ + +import Vue from 'vue' +import { getRequestToken } from '@nextcloud/auth' +import { translate as t } from '@nextcloud/l10n' + +import logger from './logger' + +import SetupCheck from './components/SetupCheck' + +__webpack_nonce__ = btoa(getRequestToken()) + +Vue.mixin({ + props: { + logger, + }, + methods: { + t, + }, +}) + +const SetupCheckView = Vue.extend(SetupCheck) +new SetupCheckView().$mount('#vue-admin-setup-check') diff --git a/apps/settings/templates/settings/admin/overview.php b/apps/settings/templates/settings/admin/overview.php index d8b3674f47e53..69f1479fc16b1 100644 --- a/apps/settings/templates/settings/admin/overview.php +++ b/apps/settings/templates/settings/admin/overview.php @@ -25,6 +25,7 @@ /** @var array $_ */ /** @var \OCP\Defaults $theme */ +\OCP\Util::addScript('settings', 'vue-settings-admin-setup-check'); ?>
@@ -66,6 +67,8 @@
+
+

t('Version'));?>

diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 4387852556d96..204b749befcfc 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -601,6 +601,8 @@ 'OCP\\Settings\\IManager' => $baseDir . '/lib/public/Settings/IManager.php', 'OCP\\Settings\\ISettings' => $baseDir . '/lib/public/Settings/ISettings.php', 'OCP\\Settings\\ISubAdminSettings' => $baseDir . '/lib/public/Settings/ISubAdminSettings.php', + 'OCP\\SetupCheck\\ISetupCheck' => $baseDir . '/lib/public/SetupCheck/ISetupCheck.php', + 'OCP\\SetupCheck\\SetupResult' => $baseDir . '/lib/public/SetupCheck/SetupResult.php', 'OCP\\Share' => $baseDir . '/lib/public/Share.php', 'OCP\\Share\\Events\\BeforeShareCreatedEvent' => $baseDir . '/lib/public/Share/Events/BeforeShareCreatedEvent.php', 'OCP\\Share\\Events\\BeforeShareDeletedEvent' => $baseDir . '/lib/public/Share/Events/BeforeShareDeletedEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 9b33577d66a26..9ad208fc85427 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -634,6 +634,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Settings\\IManager' => __DIR__ . '/../../..' . '/lib/public/Settings/IManager.php', 'OCP\\Settings\\ISettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISettings.php', 'OCP\\Settings\\ISubAdminSettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISubAdminSettings.php', + 'OCP\\SetupCheck\\ISetupCheck' => __DIR__ . '/../../..' . '/lib/public/SetupCheck/ISetupCheck.php', + 'OCP\\SetupCheck\\SetupResult' => __DIR__ . '/../../..' . '/lib/public/SetupCheck/SetupResult.php', 'OCP\\Share' => __DIR__ . '/../../..' . '/lib/public/Share.php', 'OCP\\Share\\Events\\BeforeShareCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/BeforeShareCreatedEvent.php', 'OCP\\Share\\Events\\BeforeShareDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/BeforeShareDeletedEvent.php', diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index b3ef3ee65fba6..d45885270067c 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -55,6 +55,7 @@ use OCP\Notification\INotifier; use OCP\Profile\ILinkAction; use OCP\Search\IProvider; +use OCP\SetupCheck\ISetupCheck; use OCP\Share\IPublicShareTemplateProvider; use OCP\Support\CrashReport\IReporter; use OCP\UserMigration\IMigrator as IUserMigrator; @@ -143,11 +144,13 @@ class RegistrationContext { /** @var ServiceRegistration[] */ private $publicShareTemplateProviders = []; - /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; + + /** @var ServiceRegistration[] */ + private array $setupChecks = []; /** @var PreviewProviderRegistration[] */ - private $previewProviders = []; + private array $previewProviders = []; public function __construct(LoggerInterface $logger) { $this->logger = $logger; @@ -369,6 +372,13 @@ public function registerPublicShareTemplateProvider(string $class): void { $class ); } + + public function registerSetupCheck(string $setupCheckClass): void { + $this->context->registerSetupCheck( + $this->appId, + $setupCheckClass + ); + } }; } @@ -520,6 +530,13 @@ public function registerPublicShareTemplateProvider(string $appId, string $class $this->publicShareTemplateProviders[] = new ServiceRegistration($appId, $class); } + /** + * @psalm-param class-string $setupCheckClass + */ + public function registerSetupCheck(string $appId, string $setupCheckClass): void { + $this->setupChecks[] = new ServiceRegistration($appId, $setupCheckClass); + } + /** * @param App[] $apps */ @@ -822,4 +839,11 @@ public function getSensitiveMethods(): array { public function getPublicShareTemplateProviders(): array { return $this->publicShareTemplateProviders; } + + /** + * @return ServiceRegistration[] + */ + public function getSetupChecks(): array { + return $this->setupChecks; + } } diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php new file mode 100644 index 0000000000000..08c73fda893e4 --- /dev/null +++ b/lib/private/SetupCheck/SetupCheckManager.php @@ -0,0 +1,31 @@ +coordinator = $coordinator; + } + + public function runAll(): array { + $results = []; + $setupChecks = $this->coordinator->getRegistrationContext()->getSetupChecks(); + foreach ($setupChecks as $setupCheck) { + /** @var ISetupCheck $setupCheckObject */ + $setupCheckObject = Server::get($setupCheck->getService()); + $setupResult = $setupCheckObject->run(); + $category = $setupCheckObject->getCategory(); + if (!isset($results[$category])) { + $results[$category] = []; + } + $results[$category][$setupCheckObject->getName()] = $setupResult; + } + return $results; + } +} diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index c34cec38eb127..ad83129514fb8 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -371,4 +371,14 @@ public function registerSensitiveMethods(string $class, array $methods): void; * @since 26.0.0 */ public function registerPublicShareTemplateProvider(string $class): void; + + /** + * Register an implementation of \OCP\SetupCheck\ISetupCheck that + * will handle the implementation of a setup check + * + * @psalm-param class-string<\OCP\SetupCheck\ISetupCheck> $setupCheckClass + * @return void + * @since 25.0.0 + */ + public function registerSetupCheck(string $setupCheckClass): void; } diff --git a/lib/public/SetupCheck/ISetupCheck.php b/lib/public/SetupCheck/ISetupCheck.php new file mode 100644 index 0000000000000..e4f35b55f3cdd --- /dev/null +++ b/lib/public/SetupCheck/ISetupCheck.php @@ -0,0 +1,23 @@ +severity = $severity; + $this->description = $description; + $this->linkToDoc = $linkToDoc; + } + + /** + * @brief Get the severity for the setup check result + * + * @psalm-return self::INFO|self::WARNING|self::ERROR + * @since 25.0.0 + */ + public function getSeverity(): string { + return $this->severity; + } + + /** + * @brief Get the description for the setup check result + * + * @since 25.0.0 + */ + public function getDescription(): ?string { + return $this->description; + } + + /** + * @brief Get a link to the doc for the explanation. + * + * @since 25.0.0 + */ + public function getLinkToDoc(): ?string { + return $this->linkToDoc; + } + + #[\ReturnTypeWillChange] + function jsonSerialize() { + return [ + 'severity' => $this->severity, + 'description' => $this->description, + 'linkToDoc' => $this->linkToDoc, + ]; + } +} diff --git a/webpack.modules.js b/webpack.modules.js index 67be70c5fed64..6285f14c9aff9 100644 --- a/webpack.modules.js +++ b/webpack.modules.js @@ -90,6 +90,7 @@ module.exports = { 'vue-settings-admin-ai': path.join(__dirname, 'apps/settings/src', 'main-admin-ai.js'), 'vue-settings-admin-delegation': path.join(__dirname, 'apps/settings/src', 'main-admin-delegation.js'), 'vue-settings-admin-security': path.join(__dirname, 'apps/settings/src', 'main-admin-security.js'), + 'vue-settings-admin-setup-check': path.join(__dirname, 'apps/settings/src', 'main-admin-setup-check.js'), 'vue-settings-apps-users-management': path.join(__dirname, 'apps/settings/src', 'main-apps-users-management.js'), 'vue-settings-nextcloud-pdf': path.join(__dirname, 'apps/settings/src', 'main-nextcloud-pdf.js'), 'vue-settings-personal-info': path.join(__dirname, 'apps/settings/src', 'main-personal-info.js'), From c71e47f5c311836973c7ae22b174dfbbf8117304 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 30 May 2022 09:59:52 +0200 Subject: [PATCH 02/24] Progress Signed-off-by: Carl Schwan --- apps/settings/lib/AppInfo/Application.php | 2 + .../lib/Controller/CheckSetupController.php | 7 -- .../lib/SetupChecks/LegacySSEKeyFormat.php | 32 ++++---- apps/settings/src/components/SetupCheck.vue | 78 ++++++++++++++++--- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + apps/user_ldap/lib/AppInfo/Application.php | 2 + .../lib/SetupChecks/LdapInvalidUuids.php | 37 ++++----- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/public/SetupCheck/ISetupCheck.php | 5 ++ 11 files changed, 111 insertions(+), 56 deletions(-) rename apps/{settings => user_ldap}/lib/SetupChecks/LdapInvalidUuids.php (66%) diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index 22993a79485dd..c3ed7b31e7970 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -49,6 +49,7 @@ use OCA\Settings\Search\SectionSearch; use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; +use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\UserMigration\AccountMigrator; use OCA\Settings\WellKnown\ChangePasswordHandler; use OCA\Settings\WellKnown\SecurityTxtHandler; @@ -139,6 +140,7 @@ public function register(IRegistrationContext $context): void { ); }); $context->registerSetupCheck(CheckUserCertificates::class); + $context->registerSetupCheck(LegacySSEKeyFormat::class); $context->registerUserMigrator(AccountMigrator::class); } diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index bcfd23603006e..829873f0069bd 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -64,7 +64,6 @@ use OC\MemoryInfo; use OCA\Settings\SetupChecks\CheckUserCertificates; use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync; -use OCA\Settings\SetupChecks\LdapInvalidUuids; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\PhpDefaultCharset; use OCA\Settings\SetupChecks\PhpOutputBuffering; @@ -920,10 +919,7 @@ protected function imageMagickLacksSVGSupport(): bool { public function check() { $phpDefaultCharset = new PhpDefaultCharset(); $phpOutputBuffering = new PhpOutputBuffering(); - $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator); - //$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator); $supportedDatabases = new SupportedDatabase($this->l10n, $this->connection); - $ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer); $needsSystemAddressBookSync = new NeedsSystemAddressBookSync($this->config, $this->l10n); return new DataResponse( @@ -974,12 +970,9 @@ public function check() { 'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(), PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()], PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()], - LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()], - //CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()], 'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '', SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()], 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(), - LdapInvalidUuids::class => ['pass' => $ldapInvalidUuids->run(), 'description' => $ldapInvalidUuids->description(), 'severity' => $ldapInvalidUuids->severity()], NeedsSystemAddressBookSync::class => ['pass' => $needsSystemAddressBookSync->run(), 'description' => $needsSystemAddressBookSync->description(), 'severity' => $needsSystemAddressBookSync->severity()], ] ); diff --git a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php index 4814d3fba7c01..44560590f7495 100644 --- a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php +++ b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php @@ -28,14 +28,13 @@ use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; -class LegacySSEKeyFormat { - /** @var IL10N */ - private $l10n; - /** @var IConfig */ - private $config; - /** @var IURLGenerator */ - private $urlGenerator; +class LegacySSEKeyFormat implements ISetupCheck { + private IL10N $l10n; + private IConfig $config; + private IURLGenerator $urlGenerator; public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) { $this->l10n = $l10n; @@ -43,19 +42,18 @@ public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGene $this->urlGenerator = $urlGenerator; } - public function description(): string { - return $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'); + public function getCategory(): string { + return 'security'; } - public function severity(): string { - return 'warning'; + public function getName(): string { + return $this->l10n->t('Checking for old server-side-encryption being disabled'); } - public function run(): bool { - return $this->config->getSystemValueBool('encryption.legacy_format_support', false) === false; - } - - public function linkToDocumentation(): string { - return $this->urlGenerator->linkToDocs('admin-sse-legacy-format'); + public function run(): SetupResult { + if ($this->config->getSystemValueBool('encryption.legacy_format_support', false) === false) { + return new SetupResult(SetupResult::SUCCESS); + } + return new SetupResult(SetupResult::WARNING, $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format')); } } diff --git a/apps/settings/src/components/SetupCheck.vue b/apps/settings/src/components/SetupCheck.vue index f5317386a06a6..40d7ac429afc3 100644 --- a/apps/settings/src/components/SetupCheck.vue +++ b/apps/settings/src/components/SetupCheck.vue @@ -3,12 +3,24 @@ :description="t('settings', `It's important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the linked documentation for more information.`)">
-
+ class="check-card"> +

{{ category }}

+ + + + + {{ stats[category].successes }} / {{ stats[category].total }} +
-
-
+
+
@@ -34,15 +46,33 @@ export default { data() { return { results: [], + collapsed: {}, + stats: {}, } }, mounted() { this.loadSetupChecks() }, methods: { + toggleCollapse(category) { + this.collapsed[category] = !this.collapsed[category] + }, async loadSetupChecks() { const { data } = await axios.get(generateUrl('/settings/setupcheck')) - console.debug(data) + const collapsed = {} + const stats = {} + for (const [category, checks] of Object.entries(data)) { + const values = Object.values(checks) + stats[category] = { + total: values.length, + successes: values.filter((check) => check.severity === 'success').length, + warnings: values.filter((check) => check.severity === 'warning').length, + errors: values.filter((check) => check.severity === 'errors').length, + } + collapsed[category] = stats[category].errors > 0 + } + this.collapsed = collapsed + this.stats = stats this.results = data }, }, @@ -50,15 +80,41 @@ export default { diff --git a/apps/user_ldap/composer/composer/autoload_classmap.php b/apps/user_ldap/composer/composer/autoload_classmap.php index 6f7e5a8c1dad1..bdca3c1c295d2 100644 --- a/apps/user_ldap/composer/composer/autoload_classmap.php +++ b/apps/user_ldap/composer/composer/autoload_classmap.php @@ -82,6 +82,7 @@ 'OCA\\User_LDAP\\Service\\UpdateGroupsService' => $baseDir . '/../lib/Service/UpdateGroupsService.php', 'OCA\\User_LDAP\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php', 'OCA\\User_LDAP\\Settings\\Section' => $baseDir . '/../lib/Settings/Section.php', + 'OCA\\User_LDAP\\SetupChecks\\LdapInvalidUuids' => $baseDir . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\User_LDAP\\UserPluginManager' => $baseDir . '/../lib/UserPluginManager.php', 'OCA\\User_LDAP\\User\\DeletedUsersIndex' => $baseDir . '/../lib/User/DeletedUsersIndex.php', 'OCA\\User_LDAP\\User\\Manager' => $baseDir . '/../lib/User/Manager.php', diff --git a/apps/user_ldap/composer/composer/autoload_static.php b/apps/user_ldap/composer/composer/autoload_static.php index 9932166b96026..1b4d3984890f3 100644 --- a/apps/user_ldap/composer/composer/autoload_static.php +++ b/apps/user_ldap/composer/composer/autoload_static.php @@ -97,6 +97,7 @@ class ComposerStaticInitUser_LDAP 'OCA\\User_LDAP\\Service\\UpdateGroupsService' => __DIR__ . '/..' . '/../lib/Service/UpdateGroupsService.php', 'OCA\\User_LDAP\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', 'OCA\\User_LDAP\\Settings\\Section' => __DIR__ . '/..' . '/../lib/Settings/Section.php', + 'OCA\\User_LDAP\\SetupChecks\\LdapInvalidUuids' => __DIR__ . '/..' . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\User_LDAP\\UserPluginManager' => __DIR__ . '/..' . '/../lib/UserPluginManager.php', 'OCA\\User_LDAP\\User\\DeletedUsersIndex' => __DIR__ . '/..' . '/../lib/User/DeletedUsersIndex.php', 'OCA\\User_LDAP\\User\\Manager' => __DIR__ . '/..' . '/../lib/User/Manager.php', diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php index 1b6c8cab0fd3c..459de75181232 100644 --- a/apps/user_ldap/lib/AppInfo/Application.php +++ b/apps/user_ldap/lib/AppInfo/Application.php @@ -43,6 +43,7 @@ use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\User_Proxy; use OCA\User_LDAP\UserPluginManager; +use OCA\User_LDAP\SetupChecks\LdapInvalidUuids; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -116,6 +117,7 @@ function (ContainerInterface $c) { false ); $context->registerEventListener(PostLoginEvent::class, LoginListener::class); + $context->registerSetupCheck(LdapInvalidUuids::class); } public function boot(IBootContext $context): void { diff --git a/apps/settings/lib/SetupChecks/LdapInvalidUuids.php b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php similarity index 66% rename from apps/settings/lib/SetupChecks/LdapInvalidUuids.php rename to apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php index 11b0105cada84..f8c8a5f1fc534 100644 --- a/apps/settings/lib/SetupChecks/LdapInvalidUuids.php +++ b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php @@ -24,27 +24,29 @@ * */ -namespace OCA\Settings\SetupChecks; +namespace OCA\User_LDAP\SetupChecks; use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\UserMapping; use OCP\App\IAppManager; use OCP\IL10N; use OCP\IServerContainer; +use OCP\SetupCheck\ISetupCheck; -class LdapInvalidUuids { +class LdapInvalidUuids implements ISetupCheck { + private IL10N $l10n; + private IServerContainer $server; + private UserMapping $userMapping; + private GroupMapping $groupMapping; - /** @var IAppManager */ - private $appManager; - /** @var IL10N */ - private $l10n; - /** @var IServerContainer */ - private $server; - - public function __construct(IAppManager $appManager, IL10N $l10n, IServerContainer $server) { - $this->appManager = $appManager; + public function __construct(IL10N $l10n, UserMapping $userMapping, GroupMapping $groupMapping) { $this->l10n = $l10n; - $this->server = $server; + $this->userMapping = $userMapping; + $this->groupMapping = $groupMapping; + } + + public function getCategory(): string { + return 'ldap'; } public function description(): string { @@ -56,14 +58,7 @@ public function severity(): string { } public function run(): bool { - if (!$this->appManager->isEnabledForUser('user_ldap')) { - return true; - } - /** @var UserMapping $userMapping */ - $userMapping = $this->server->get(UserMapping::class); - /** @var GroupMapping $groupMapping */ - $groupMapping = $this->server->get(GroupMapping::class); - return count($userMapping->getList(0, 1, true)) === 0 - && count($groupMapping->getList(0, 1, true)) === 0; + return count($this->userMapping->getList(0, 1, true)) === 0 + && count($this->groupMapping->getList(0, 1, true)) === 0; } } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 204b749befcfc..b656f83e747b5 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1655,6 +1655,7 @@ 'OC\\Settings\\Manager' => $baseDir . '/lib/private/Settings/Manager.php', 'OC\\Settings\\Section' => $baseDir . '/lib/private/Settings/Section.php', 'OC\\Setup' => $baseDir . '/lib/private/Setup.php', + 'OC\\SetupCheck\\SetupCheckManager' => $baseDir . '/lib/private/SetupCheck/SetupCheckManager.php', 'OC\\Setup\\AbstractDatabase' => $baseDir . '/lib/private/Setup/AbstractDatabase.php', 'OC\\Setup\\MySQL' => $baseDir . '/lib/private/Setup/MySQL.php', 'OC\\Setup\\OCI' => $baseDir . '/lib/private/Setup/OCI.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 9ad208fc85427..70f47a58976c8 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1688,6 +1688,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Settings\\Manager' => __DIR__ . '/../../..' . '/lib/private/Settings/Manager.php', 'OC\\Settings\\Section' => __DIR__ . '/../../..' . '/lib/private/Settings/Section.php', 'OC\\Setup' => __DIR__ . '/../../..' . '/lib/private/Setup.php', + 'OC\\SetupCheck\\SetupCheckManager' => __DIR__ . '/../../..' . '/lib/private/SetupCheck/SetupCheckManager.php', 'OC\\Setup\\AbstractDatabase' => __DIR__ . '/../../..' . '/lib/private/Setup/AbstractDatabase.php', 'OC\\Setup\\MySQL' => __DIR__ . '/../../..' . '/lib/private/Setup/MySQL.php', 'OC\\Setup\\OCI' => __DIR__ . '/../../..' . '/lib/private/Setup/OCI.php', diff --git a/lib/public/SetupCheck/ISetupCheck.php b/lib/public/SetupCheck/ISetupCheck.php index e4f35b55f3cdd..05b43778651d6 100644 --- a/lib/public/SetupCheck/ISetupCheck.php +++ b/lib/public/SetupCheck/ISetupCheck.php @@ -16,6 +16,11 @@ interface ISetupCheck { */ public function getCategory(): string; + /** + * @since 25.0.0 + */ + public function getName(): string; + /** * @since 25.0.0 */ From 0890012e72c594805406b95b39707db1acdf0d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 28 Sep 2023 11:36:35 +0200 Subject: [PATCH 03/24] Fix SetupChecks/LdapInvalidUuids.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/SetupChecks/LdapInvalidUuids.php | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php index f8c8a5f1fc534..473fedc5c1de9 100644 --- a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php +++ b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php @@ -6,6 +6,7 @@ * @copyright Copyright (c) 2022 Arthur Schiwon * * @author Arthur Schiwon + * @author Côme Chilliet * * @license GNU AGPL version 3 or any later version * @@ -28,14 +29,12 @@ use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\UserMapping; -use OCP\App\IAppManager; use OCP\IL10N; -use OCP\IServerContainer; use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; class LdapInvalidUuids implements ISetupCheck { private IL10N $l10n; - private IServerContainer $server; private UserMapping $userMapping; private GroupMapping $groupMapping; @@ -49,16 +48,16 @@ public function getCategory(): string { return 'ldap'; } - public function description(): string { - return $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.'); + public function getName(): string { + return $this->l10n->t('Checking for invalid LDAP UUIDs'); } - public function severity(): string { - return 'warning'; - } - - public function run(): bool { - return count($this->userMapping->getList(0, 1, true)) === 0 - && count($this->groupMapping->getList(0, 1, true)) === 0; + public function run(): SetupResult { + if (count($this->userMapping->getList(0, 1, true)) === 0 + && count($this->groupMapping->getList(0, 1, true)) === 0) { + return new SetupResult(SetupResult::SUCCESS); + } else { + return new SetupResult(SetupResult::WARNING, $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.')); + } } } From a3ec716c333a5ad081619a5b2e84a83c2d27f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 28 Sep 2023 12:13:44 +0200 Subject: [PATCH 04/24] Fix UI and add PhpOutdated check 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 | 2 +- .../composer/composer/autoload_static.php | 2 +- apps/settings/lib/AppInfo/Application.php | 2 + apps/settings/lib/SetupChecks/PhpOutdated.php | 54 +++++++++++++++++++ apps/settings/src/components/SetupCheck.vue | 8 +-- 5 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 apps/settings/lib/SetupChecks/PhpOutdated.php diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index a1e0b7632ca5f..f9710bcf4142e 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -74,10 +74,10 @@ '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\\LdapInvalidUuids' => $baseDir . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', + 'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => $baseDir . '/../lib/UserMigration/AccountMigrator.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index 1eef91c5d91cf..9f307d1c9393d 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -89,10 +89,10 @@ 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\\LdapInvalidUuids' => __DIR__ . '/..' . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', + 'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', 'OCA\\Settings\\UserMigration\\AccountMigrator' => __DIR__ . '/..' . '/../lib/UserMigration/AccountMigrator.php', diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index c3ed7b31e7970..83f801208ed59 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -50,6 +50,7 @@ use OCA\Settings\Search\UserSearch; use OCA\Settings\SetupChecks\CheckUserCertificates; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; +use OCA\Settings\SetupChecks\PhpOutdated; use OCA\Settings\UserMigration\AccountMigrator; use OCA\Settings\WellKnown\ChangePasswordHandler; use OCA\Settings\WellKnown\SecurityTxtHandler; @@ -141,6 +142,7 @@ public function register(IRegistrationContext $context): void { }); $context->registerSetupCheck(CheckUserCertificates::class); $context->registerSetupCheck(LegacySSEKeyFormat::class); + $context->registerSetupCheck(PhpOutdated::class); $context->registerUserMigrator(AccountMigrator::class); } diff --git a/apps/settings/lib/SetupChecks/PhpOutdated.php b/apps/settings/lib/SetupChecks/PhpOutdated.php new file mode 100644 index 0000000000000..51b479ec4b96e --- /dev/null +++ b/apps/settings/lib/SetupChecks/PhpOutdated.php @@ -0,0 +1,54 @@ + + * + * @author Carl Schwan + * @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 PhpOutdated implements ISetupCheck { + public function __construct( + private IL10N $l10n, + ) { + } + + public function getCategory(): string { + return 'security'; + } + + public function getName(): string { + return $this->l10n->t('Checking for PHP version'); + } + + public function run(): SetupResult { + if (PHP_VERSION_ID < 80100) { + return new SetupResult(SetupResult::WARNING, $this->l10n->t('You are currently running PHP %s. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.', [PHP_VERSION]), 'https://secure.php.net/supported-versions.php'); + } + return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('You are currently running PHP %s.', [PHP_VERSION])); + } +} diff --git a/apps/settings/src/components/SetupCheck.vue b/apps/settings/src/components/SetupCheck.vue index 40d7ac429afc3..c85434fe91239 100644 --- a/apps/settings/src/components/SetupCheck.vue +++ b/apps/settings/src/components/SetupCheck.vue @@ -1,5 +1,5 @@ - - diff --git a/apps/settings/src/main-admin-setup-check.js b/apps/settings/src/main-admin-setup-check.js deleted file mode 100644 index 5f984fd626a75..0000000000000 --- a/apps/settings/src/main-admin-setup-check.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @copyright 2022 Christopher Ng - * - * @author Christopher Ng - * - * @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 . - * - */ - -import Vue from 'vue' -import { getRequestToken } from '@nextcloud/auth' -import { translate as t } from '@nextcloud/l10n' - -import logger from './logger.js' - -import SetupCheck from './components/SetupCheck.vue' - -__webpack_nonce__ = btoa(getRequestToken()) - -Vue.mixin({ - props: { - logger, - }, - methods: { - t, - }, -}) - -const SetupCheckView = Vue.extend(SetupCheck) -new SetupCheckView().$mount('#vue-admin-setup-check') diff --git a/apps/settings/templates/settings/admin/overview.php b/apps/settings/templates/settings/admin/overview.php index 69f1479fc16b1..d8b3674f47e53 100644 --- a/apps/settings/templates/settings/admin/overview.php +++ b/apps/settings/templates/settings/admin/overview.php @@ -25,7 +25,6 @@ /** @var array $_ */ /** @var \OCP\Defaults $theme */ -\OCP\Util::addScript('settings', 'vue-settings-admin-setup-check'); ?>
@@ -67,8 +66,6 @@
-
-

t('Version'));?>

diff --git a/webpack.modules.js b/webpack.modules.js index 6285f14c9aff9..67be70c5fed64 100644 --- a/webpack.modules.js +++ b/webpack.modules.js @@ -90,7 +90,6 @@ module.exports = { 'vue-settings-admin-ai': path.join(__dirname, 'apps/settings/src', 'main-admin-ai.js'), 'vue-settings-admin-delegation': path.join(__dirname, 'apps/settings/src', 'main-admin-delegation.js'), 'vue-settings-admin-security': path.join(__dirname, 'apps/settings/src', 'main-admin-security.js'), - 'vue-settings-admin-setup-check': path.join(__dirname, 'apps/settings/src', 'main-admin-setup-check.js'), 'vue-settings-apps-users-management': path.join(__dirname, 'apps/settings/src', 'main-apps-users-management.js'), 'vue-settings-nextcloud-pdf': path.join(__dirname, 'apps/settings/src', 'main-nextcloud-pdf.js'), 'vue-settings-personal-info': path.join(__dirname, 'apps/settings/src', 'main-personal-info.js'), From be11ffd86a9d1052a014542382a0dae73308c6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 16 Oct 2023 09:41:51 +0200 Subject: [PATCH 19/24] Add debug logging when running setup checks to help with debugging slow results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/SetupCheck/SetupCheckManager.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php index 1a7b5d555b9a1..0bf3dc3986100 100644 --- a/lib/private/SetupCheck/SetupCheckManager.php +++ b/lib/private/SetupCheck/SetupCheckManager.php @@ -30,12 +30,13 @@ use OCP\Server; use OCP\SetupCheck\ISetupCheck; use OCP\SetupCheck\ISetupCheckManager; +use Psr\Log\LoggerInterface; class SetupCheckManager implements ISetupCheckManager { - private Coordinator $coordinator; - - public function __construct(Coordinator $coordinator) { - $this->coordinator = $coordinator; + public function __construct( + private Coordinator $coordinator, + private LoggerInterface $logger, + ) { } public function runAll(): array { @@ -44,6 +45,7 @@ public function runAll(): array { foreach ($setupChecks as $setupCheck) { /** @var ISetupCheck $setupCheckObject */ $setupCheckObject = Server::get($setupCheck->getService()); + $this->logger->debug('Running check '.get_class($setupCheckObject)); $setupResult = $setupCheckObject->run(); $category = $setupCheckObject->getCategory(); if (!isset($results[$category])) { From 6aa6f26427192cb4bab7ee614b5e6c020047f755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 16 Oct 2023 09:47:51 +0200 Subject: [PATCH 20/24] =?UTF-8?q?Move=20NeedsSystemAddressBookSync=20to=20?= =?UTF-8?q?dav=20application=20where=20it=E2=80=99s=20registered?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/composer/composer/autoload_classmap.php | 1 + apps/dav/composer/composer/autoload_static.php | 1 + apps/dav/lib/AppInfo/Application.php | 2 +- .../lib/SetupChecks/NeedsSystemAddressBookSync.php | 2 +- apps/settings/composer/composer/autoload_classmap.php | 1 - apps/settings/composer/composer/autoload_static.php | 1 - 6 files changed, 4 insertions(+), 4 deletions(-) rename apps/{settings => dav}/lib/SetupChecks/NeedsSystemAddressBookSync.php (98%) diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index 6d41801728b58..414c5df4a4a29 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -308,6 +308,7 @@ 'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php', 'OCA\\DAV\\Settings\\AvailabilitySettings' => $baseDir . '/../lib/Settings/AvailabilitySettings.php', 'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php', + 'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php', 'OCA\\DAV\\SystemTag\\SystemTagList' => $baseDir . '/../lib/SystemTag/SystemTagList.php', 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir . '/../lib/SystemTag/SystemTagMappingNode.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 600397c371e1a..7b0520cc220c5 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -323,6 +323,7 @@ class ComposerStaticInitDAV 'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php', 'OCA\\DAV\\Settings\\AvailabilitySettings' => __DIR__ . '/..' . '/../lib/Settings/AvailabilitySettings.php', 'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php', + 'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php', 'OCA\\DAV\\SystemTag\\SystemTagList' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagList.php', 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagMappingNode.php', diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 22545b6c7e67c..08529435caeb3 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -89,9 +89,9 @@ use OCA\DAV\Search\ContactsSearchProvider; use OCA\DAV\Search\EventsSearchProvider; use OCA\DAV\Search\TasksSearchProvider; +use OCA\DAV\SetupChecks\NeedsSystemAddressBookSync; use OCA\DAV\UserMigration\CalendarMigrator; use OCA\DAV\UserMigration\ContactsMigrator; -use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; diff --git a/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php similarity index 98% rename from apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php rename to apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php index b7cfe9cc34877..78f8a1bff696e 100644 --- a/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php +++ b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php @@ -25,7 +25,7 @@ * */ -namespace OCA\Settings\SetupChecks; +namespace OCA\DAV\SetupChecks; use OCP\IConfig; use OCP\IL10N; diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index d07cbebfb8354..c6b768e8b333f 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -77,7 +77,6 @@ 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => $baseDir . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => $baseDir . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', - 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index debf3f2966a6f..0905343597036 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -92,7 +92,6 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\DefaultPhoneRegionSet' => __DIR__ . '/..' . '/../lib/SetupChecks/DefaultPhoneRegionSet.php', 'OCA\\Settings\\SetupChecks\\InternetConnectivity' => __DIR__ . '/..' . '/../lib/SetupChecks/InternetConnectivity.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', - 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', From 11ebf469da14224b3e1146b65eb16095ab8b22a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <91878298+come-nc@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:37:07 +0200 Subject: [PATCH 21/24] Remove useless var in apps/settings/lib/SetupChecks/CheckUserCertificates.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benjamin Gaussorgues Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> --- apps/settings/lib/SetupChecks/CheckUserCertificates.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/settings/lib/SetupChecks/CheckUserCertificates.php b/apps/settings/lib/SetupChecks/CheckUserCertificates.php index 5d58f61b67599..909ba9e149bd0 100644 --- a/apps/settings/lib/SetupChecks/CheckUserCertificates.php +++ b/apps/settings/lib/SetupChecks/CheckUserCertificates.php @@ -38,8 +38,7 @@ public function __construct( private IL10N $l10n, IConfig $config, ) { - $configValue = $config->getAppValue('files_external', 'user_certificate_scan', ''); - $this->configValue = $configValue; + $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', ''); } public function getCategory(): string { From 2e4d1549a44ce3b29d3287ba3721a464733bf708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 16 Oct 2023 17:23:47 +0200 Subject: [PATCH 22/24] Change SetupResult API to named constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../NeedsSystemAddressBookSync.php | 4 +-- .../lib/SetupChecks/CheckUserCertificates.php | 8 ++--- .../lib/SetupChecks/DefaultPhoneRegionSet.php | 5 ++- .../lib/SetupChecks/InternetConnectivity.php | 6 ++-- .../lib/SetupChecks/LegacySSEKeyFormat.php | 4 +-- .../lib/SetupChecks/PhpDefaultCharset.php | 4 +-- apps/settings/lib/SetupChecks/PhpOutdated.php | 4 +-- .../lib/SetupChecks/PhpOutputBuffering.php | 4 +-- .../lib/SetupChecks/ReadOnlyConfig.php | 4 +-- .../lib/SetupChecks/SupportedDatabase.php | 8 ++--- .../lib/SetupChecks/LdapInvalidUuids.php | 4 +-- lib/public/SetupCheck/SetupResult.php | 35 ++++++++++++++++++- 12 files changed, 61 insertions(+), 29 deletions(-) diff --git a/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php index 78f8a1bff696e..476b37c160245 100644 --- a/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php +++ b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php @@ -49,9 +49,9 @@ public function getCategory(): string { public function run(): SetupResult { if ($this->config->getAppValue('dav', 'needs_system_address_book_sync', 'no') === 'no') { - return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('No outstanding DAV system address book sync.')); + return SetupResult::success($this->l10n->t('No outstanding DAV system address book sync.')); } else { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling occ dav:sync-system-addressbook.')); + return SetupResult::warning($this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling occ dav:sync-system-addressbook.')); } } } diff --git a/apps/settings/lib/SetupChecks/CheckUserCertificates.php b/apps/settings/lib/SetupChecks/CheckUserCertificates.php index 909ba9e149bd0..e09ef267e07a6 100644 --- a/apps/settings/lib/SetupChecks/CheckUserCertificates.php +++ b/apps/settings/lib/SetupChecks/CheckUserCertificates.php @@ -38,7 +38,7 @@ public function __construct( private IL10N $l10n, IConfig $config, ) { - $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', ''); + $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', ''); } public function getCategory(): string { @@ -52,11 +52,11 @@ public function getName(): string { public function run(): SetupResult { // all fine if neither "not-run-yet" nor a result if ($this->configValue === '') { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } if ($this->configValue === 'not-run-yet') { - return new SetupResult(SetupResult::INFO, $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.')); + return SetupResult::info($this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.')); } - return new SetupResult(SetupResult::ERROR, $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.')); + return SetupResult::error($this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.')); } } diff --git a/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php b/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php index 6cc37b08abe76..8b11ea90fddde 100644 --- a/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php +++ b/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php @@ -47,10 +47,9 @@ public function getCategory(): string { public function run(): SetupResult { if ($this->config->getSystemValueString('default_phone_region', '') !== '') { - return new SetupResult(SetupResult::SUCCESS, $this->config->getSystemValueString('default_phone_region', '')); + return SetupResult::success($this->config->getSystemValueString('default_phone_region', '')); } else { - return new SetupResult( - SetupResult::INFO, + return SetupResult::info( $this->l10n->t('Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code of the region to your config file.'), 'https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements' ); diff --git a/apps/settings/lib/SetupChecks/InternetConnectivity.php b/apps/settings/lib/SetupChecks/InternetConnectivity.php index 697dddc935a38..e27c5e2e981d3 100644 --- a/apps/settings/lib/SetupChecks/InternetConnectivity.php +++ b/apps/settings/lib/SetupChecks/InternetConnectivity.php @@ -57,7 +57,7 @@ public function getName(): string { public function run(): SetupResult { if ($this->config->getSystemValue('has_internet_connection', true) === false) { - return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('Internet connectivity is disabled in configuration file.')); + return SetupResult::success($this->l10n->t('Internet connectivity is disabled in configuration file.')); } $siteArray = $this->config->getSystemValue('connectivity_check_domains', [ @@ -66,10 +66,10 @@ public function run(): SetupResult { foreach ($siteArray as $site) { if ($this->isSiteReachable($site)) { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } } - return new SetupResult(SetupResult::WARNING, $this->l10n->t('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.')); + return SetupResult::warning($this->l10n->t('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.')); } /** diff --git a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php index 68964b3fdab0d..72300ede2b0d5 100644 --- a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php +++ b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php @@ -49,8 +49,8 @@ public function getName(): string { public function run(): SetupResult { if ($this->config->getSystemValueBool('encryption.legacy_format_support', false) === false) { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } - return new SetupResult(SetupResult::WARNING, $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format')); + return SetupResult::warning($this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format')); } } diff --git a/apps/settings/lib/SetupChecks/PhpDefaultCharset.php b/apps/settings/lib/SetupChecks/PhpDefaultCharset.php index 5c14e9a6734e5..3f7a8c58e52f2 100644 --- a/apps/settings/lib/SetupChecks/PhpDefaultCharset.php +++ b/apps/settings/lib/SetupChecks/PhpDefaultCharset.php @@ -45,9 +45,9 @@ public function getCategory(): string { public function run(): SetupResult { if (strtoupper(trim(ini_get('default_charset'))) === 'UTF-8') { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } else { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('PHP configuration option default_charset should be UTF-8')); + return SetupResult::warning($this->l10n->t('PHP configuration option default_charset should be UTF-8')); } } } diff --git a/apps/settings/lib/SetupChecks/PhpOutdated.php b/apps/settings/lib/SetupChecks/PhpOutdated.php index 51b479ec4b96e..2d1616493152f 100644 --- a/apps/settings/lib/SetupChecks/PhpOutdated.php +++ b/apps/settings/lib/SetupChecks/PhpOutdated.php @@ -47,8 +47,8 @@ public function getName(): string { public function run(): SetupResult { if (PHP_VERSION_ID < 80100) { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('You are currently running PHP %s. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.', [PHP_VERSION]), 'https://secure.php.net/supported-versions.php'); + return SetupResult::warning($this->l10n->t('You are currently running PHP %s. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.', [PHP_VERSION]), 'https://secure.php.net/supported-versions.php'); } - return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('You are currently running PHP %s.', [PHP_VERSION])); + return SetupResult::success($this->l10n->t('You are currently running PHP %s.', [PHP_VERSION])); } } diff --git a/apps/settings/lib/SetupChecks/PhpOutputBuffering.php b/apps/settings/lib/SetupChecks/PhpOutputBuffering.php index f3a21418c1c4f..58321e9f5dc81 100644 --- a/apps/settings/lib/SetupChecks/PhpOutputBuffering.php +++ b/apps/settings/lib/SetupChecks/PhpOutputBuffering.php @@ -46,9 +46,9 @@ public function getName(): string { public function run(): SetupResult { $value = trim(ini_get('output_buffering')); if ($value === '' || $value === '0') { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } else { - return new SetupResult(SetupResult::ERROR, $this->l10n->t('PHP configuration option output_buffering must be disabled')); + return SetupResult::error($this->l10n->t('PHP configuration option output_buffering must be disabled')); } } } diff --git a/apps/settings/lib/SetupChecks/ReadOnlyConfig.php b/apps/settings/lib/SetupChecks/ReadOnlyConfig.php index 4c81a410449b0..56f86ba9ab442 100644 --- a/apps/settings/lib/SetupChecks/ReadOnlyConfig.php +++ b/apps/settings/lib/SetupChecks/ReadOnlyConfig.php @@ -47,9 +47,9 @@ public function getCategory(): string { public function run(): SetupResult { if ($this->config->getSystemValueBool('config_is_read_only', false)) { - return new SetupResult(SetupResult::INFO, $this->l10n->t('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.')); + return SetupResult::info($this->l10n->t('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.')); } else { - return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('Nextcloud configuration file is writable')); + return SetupResult::success($this->l10n->t('Nextcloud configuration file is writable')); } } } diff --git a/apps/settings/lib/SetupChecks/SupportedDatabase.php b/apps/settings/lib/SetupChecks/SupportedDatabase.php index 0cbaa5b114ed6..3d10798a7dabd 100644 --- a/apps/settings/lib/SetupChecks/SupportedDatabase.php +++ b/apps/settings/lib/SetupChecks/SupportedDatabase.php @@ -68,11 +68,11 @@ public function run(): SetupResult { if (str_contains($version, 'mariadb')) { if (version_compare($version, '10.2', '<')) { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $row['Value'])); + return SetupResult::warning($this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $row['Value'])); } } else { if (version_compare($version, '8', '<')) { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('MySQL version "%s" is used. Nextcloud 21 and higher do not support this version and require MySQL 8.0 or MariaDB 10.2 or higher.', $row['Value'])); + return SetupResult::warning($this->l10n->t('MySQL version "%s" is used. Nextcloud 21 and higher do not support this version and require MySQL 8.0 or MariaDB 10.2 or higher.', $row['Value'])); } } break; @@ -84,13 +84,13 @@ public function run(): SetupResult { $result->execute(); $row = $result->fetch(); if (version_compare($row['server_version'], '9.6', '<')) { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 and higher do not support this version and require PostgreSQL 9.6 or higher.', $row['server_version'])); + return SetupResult::warning($this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 and higher do not support this version and require PostgreSQL 9.6 or higher.', $row['server_version'])); } break; case OraclePlatform::class: break; } // TODO still show db and version on success? - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } } diff --git a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php index a11246fd1420e..d6de11d35b9d5 100644 --- a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php +++ b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php @@ -52,9 +52,9 @@ public function getName(): string { public function run(): SetupResult { if (count($this->userMapping->getList(0, 1, true)) === 0 && count($this->groupMapping->getList(0, 1, true)) === 0) { - return new SetupResult(SetupResult::SUCCESS); + return SetupResult::success(); } else { - return new SetupResult(SetupResult::WARNING, $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.')); + return SetupResult::warning($this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.')); } } } diff --git a/lib/public/SetupCheck/SetupResult.php b/lib/public/SetupCheck/SetupResult.php index 158a9489cfef2..27026f8281506 100644 --- a/lib/public/SetupCheck/SetupResult.php +++ b/lib/public/SetupCheck/SetupResult.php @@ -38,16 +38,49 @@ class SetupResult implements \JsonSerializable { public const ERROR = 'error'; /** + * @brief Private constructor, use success()/info()/warning()/error() instead * @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity * @since 28.0.0 */ - public function __construct( + private function __construct( private string $severity, private ?string $description = null, private ?string $linkToDoc = null, ) { } + /** + * @brief Create a success result object + * @since 28.0.0 + */ + public static function success(?string $description = null, ?string $linkToDoc = null): self { + return new self(self::SUCCESS, $description, $linkToDoc); + } + + /** + * @brief Create an info result object + * @since 28.0.0 + */ + public static function info(?string $description = null, ?string $linkToDoc = null): self { + return new self(self::INFO, $description, $linkToDoc); + } + + /** + * @brief Create a warning result object + * @since 28.0.0 + */ + public static function warning(?string $description = null, ?string $linkToDoc = null): self { + return new self(self::WARNING, $description, $linkToDoc); + } + + /** + * @brief Create an error result object + * @since 28.0.0 + */ + public static function error(?string $description = null, ?string $linkToDoc = null): self { + return new self(self::ERROR, $description, $linkToDoc); + } + /** * @brief Get the severity for the setup check result * From a3cc3b188d5294033c20d84232d334d9e0f488a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 19 Oct 2023 11:43:39 +0200 Subject: [PATCH 23/24] Small code style fix in SetupCheckManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/SetupCheck/SetupCheckManager.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php index 0bf3dc3986100..f9e67772019ac 100644 --- a/lib/private/SetupCheck/SetupCheckManager.php +++ b/lib/private/SetupCheck/SetupCheckManager.php @@ -48,9 +48,7 @@ public function runAll(): array { $this->logger->debug('Running check '.get_class($setupCheckObject)); $setupResult = $setupCheckObject->run(); $category = $setupCheckObject->getCategory(); - if (!isset($results[$category])) { - $results[$category] = []; - } + $results[$category] ??= []; $results[$category][$setupCheckObject->getName()] = $setupResult; } return $results; From 789ff3f414fe9d128b6831b9981b2425ce0849d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 19 Oct 2023 14:46:46 +0200 Subject: [PATCH 24/24] Fix jsunit tests for SetupChecks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests could be simplified to test generic setup check directly with fake data instead of trying to mimic real steps results but for now this will do. Signed-off-by: Côme Chilliet --- core/js/tests/specs/setupchecksSpec.js | 313 ++++++++++++++++++++----- 1 file changed, 252 insertions(+), 61 deletions(-) diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 163a21c46a786..676111c80a4b4 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -233,7 +233,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -256,22 +255,32 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: '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.', + linkToDoc: null + } + }, + }, }) ); async.done(function( data, s, x ){ expect(data).toEqual([ { - 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 - }, { 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 + }, + ]); done(); }); }); @@ -295,7 +304,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -318,23 +326,32 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: '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.', + linkToDoc: null + } + }, + }, }) ); 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 }, - { - 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 - }]); + ]); done(); }); }); @@ -358,7 +375,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -381,10 +397,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: '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.', + linkToDoc: null + } + }, + }, }) ); @@ -419,7 +443,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: false, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -442,10 +465,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -478,7 +509,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: false, @@ -501,10 +531,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -537,7 +575,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -560,10 +597,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -596,7 +641,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -619,10 +663,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -655,7 +707,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -678,10 +729,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -714,7 +773,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -739,10 +797,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -774,7 +840,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: false, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -798,10 +863,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -835,7 +908,6 @@ describe('OC.SetupChecks tests', function() { isFairUseOfFreePushService: true, isBruteforceThrottled: true, bruteforceRemoteAddress: '::1', - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -859,10 +931,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -894,7 +974,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -918,10 +997,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -953,7 +1040,6 @@ describe('OC.SetupChecks tests', function() { suggestedOverwriteCliURL: '', isRandomnessSecure: true, isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -977,10 +1063,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1033,10 +1127,8 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, - phpSupported: {eol: true, version: '5.4.0'}, isCorrectMemcachedPHPModuleInstalled: true, hasPassedCodeIntegrityCheck: true, OpcacheSetupRecommendations: [], @@ -1057,16 +1149,31 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + security: { + "Checking for PHP version": { + severity: "warning", + description: "You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.", + linkToDoc: "https://secure.php.net/supported-versions.php" + } + }, + }, }) ); async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'You are currently running PHP 5.4.0. Upgrade your PHP version to take advantage of performance and security updates provided by the PHP Group ↗ as soon as your distribution supports it.', + msg: 'You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible. For more details see the documentation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); @@ -1093,7 +1200,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1116,10 +1222,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1152,7 +1266,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1175,10 +1288,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1211,7 +1332,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1234,10 +1354,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: true, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1274,7 +1402,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1297,11 +1424,19 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', reverseProxyGeneratedURL: 'http://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1334,7 +1469,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1357,11 +1491,19 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', reverseProxyGeneratedURL: 'http://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1391,7 +1533,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1414,10 +1555,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1451,7 +1600,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1474,10 +1622,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1511,7 +1667,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1534,10 +1689,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1570,7 +1733,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1593,10 +1755,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) ); @@ -1629,7 +1799,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1652,16 +1821,31 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: true, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + config: { + "Checking for default phone region": { + severity: "info", + description: "Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add \"default_phone_region\" with the respective ISO 3166-1 code of the region to your config file.", + linkToDoc: "https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements" + }, + }, + }, }) ); async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code ↗ of the region to your config file.', + msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code of the region to your config file. For more details see the documentation ↗.', type: OC.SetupChecks.MESSAGE_TYPE_INFO }]); done(); @@ -1688,7 +1872,6 @@ describe('OC.SetupChecks tests', function() { isRandomnessSecure: true, securityDocs: 'https://docs.nextcloud.com/myDocs.html', isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, isMemcacheConfigured: true, forwardedForHeadersWorking: true, isCorrectMemcachedPHPModuleInstalled: true, @@ -1711,10 +1894,18 @@ describe('OC.SetupChecks tests', function() { recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', temporaryDirectoryWritable: false, + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + }, }) );