]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add setup check that links to the migration documentation
authorMorris Jobke <hey@morrisjobke.de>
Wed, 12 Aug 2020 13:16:33 +0000 (15:16 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 19 Aug 2020 13:45:45 +0000 (15:45 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/Controller/CheckSetupController.php
apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php [new file with mode: 0644]
apps/settings/tests/Controller/CheckSetupControllerTest.php
core/js/setupchecks.js

index e59b2e7fdbba91900a907870e743f8d799e31c0e..04ea0295798ee65b3b5206e806a005f8325859f0 100644 (file)
@@ -54,6 +54,7 @@ return array(
     'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
     '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\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
     'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
     'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php',
 );
index 4d69a0193a78c983a7a88e896b6e969cff12df66..476a717a32a7df22212866ae68701c9748c8628b 100644 (file)
@@ -69,6 +69,7 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
         '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\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
         'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
         'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
     );
index 6e45edee18f9b80514783bc333c1561f84d85c0f..476b58e564a88e17016d9818f5576dfd10df3d27 100644 (file)
@@ -53,6 +53,7 @@ use OC\DB\SchemaWrapper;
 use OC\IntegrityCheck\Checker;
 use OC\Lock\NoopLockingProvider;
 use OC\MemoryInfo;
+use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
 use OCA\Settings\SetupChecks\PhpDefaultCharset;
 use OCA\Settings\SetupChecks\PhpOutputBuffering;
 use OCP\AppFramework\Controller;
@@ -687,6 +688,7 @@ Raw output
        public function check() {
                $phpDefaultCharset = new PhpDefaultCharset();
                $phpOutputBuffering = new PhpOutputBuffering();
+               $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
                return new DataResponse(
                        [
                                'isGetenvServerWorking' => !empty(getenv('PATH')),
@@ -729,6 +731,7 @@ Raw output
                                'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
                                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()],
                        ]
                );
        }
diff --git a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php
new file mode 100644 (file)
index 0000000..4c0c056
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
+ *
+ * @author DMorris Jobke <hey@morrisjobke.de>
+ *
+ * @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 <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\Settings\SetupChecks;
+
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+
+class LegacySSEKeyFormat {
+       /** @var IL10N */
+       private $l10n;
+       /** @var IConfig */
+       private $config;
+       /** @var IURLGenerator */
+       private $urlGenerator;
+
+       public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
+               $this->l10n = $l10n;
+               $this->config = $config;
+               $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 severity(): string {
+               return 'warning';
+       }
+
+       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');
+       }
+}
index ff3a43ae2a4f9bfeb0b149b98d97b37d9d2acaa6..a1f7e8aa83f7def338ebdf7984ca07b5160593a9 100644 (file)
@@ -595,6 +595,7 @@ class CheckSetupControllerTest extends TestCase {
                                'reverseProxyGeneratedURL' => 'https://server/index.php',
                                'OCA\Settings\SetupChecks\PhpDefaultCharset' => ['pass' => true, 'description' => 'PHP configuration option default_charset should be UTF-8', 'severity' => 'warning'],
                                'OCA\Settings\SetupChecks\PhpOutputBuffering' => ['pass' => true, 'description' => 'PHP configuration option output_buffering must be disabled', 'severity' => 'error'],
+                               'OCA\Settings\SetupChecks\LegacySSEKeyFormat' => ['pass' => true, 'description' => 'The old server-side-encryption format is enabled. We recommend disabling this.', 'severity' => 'warning', 'linkToDocumentation' => ''],
                        ]
                );
                $this->assertEquals($expected, $this->checkSetupController->check());
index a1f0d1aca571e497425d425ee217c5e48d3ccacf..f03bc723978798d2958482502eb0b86bc8e57bf5 100644 (file)
 
                                        OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset', messages)
                                        OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering', messages)
+                                       OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat', messages)
 
                                } else {
                                        messages.push({
                },
 
                addGenericSetupCheck: function(data, check, messages) {
-                       var setupCheck = data[check] || { pass: true, description: '', severity: 'info'}
+                       var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDocumentation: null}
 
                        var type = OC.SetupChecks.MESSAGE_TYPE_INFO
                        if (setupCheck.severity === 'warning') {
                                type = OC.SetupChecks.MESSAGE_TYPE_ERROR
                        }
 
+                       var message = setupCheck.description;
+                       if (setupCheck.linkToDocumentation) {
+                               message += ' ' + t('core', 'For more details see the <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', {docLink: setupCheck.linkToDocumentation});
+                       }
+
                        if (!setupCheck.pass) {
                                messages.push({
-                                       msg: setupCheck.description,
+                                       msg: message,
                                        type: type,
                                })
                        }