]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(appconfig): returns correct value on details 44914/head
authorMaxence Lange <maxence@artificial-owl.com>
Wed, 17 Apr 2024 17:27:21 +0000 (16:27 -0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 18 Apr 2024 08:06:27 +0000 (08:06 +0000)
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
core/Command/Config/App/SetConfig.php
lib/private/AppConfig.php
tests/lib/AppConfigTest.php

index ae6f24e71d49ebf127f005fdf2ae1fd986d2a774..3adba4af69704efbbb1e85201a64b9de479f9cea 100644 (file)
@@ -173,8 +173,8 @@ class SetConfig extends Base {
                         */
                        $sensitive = $input->getOption('sensitive');
                        try {
-                               $currSensitive = $this->appConfig->isLazy($appName, $configName);
-                               if ($sensitive === null || $sensitive === $currSensitive || !$this->ask($input, $output, ($sensitive) ? 'LAZY' : 'NOT LAZY')) {
+                               $currSensitive = $this->appConfig->isSensitive($appName, $configName, null);
+                               if ($sensitive === null || $sensitive === $currSensitive || !$this->ask($input, $output, ($sensitive) ? 'SENSITIVE' : 'NOT SENSITIVE')) {
                                        $sensitive = $currSensitive;
                                }
                        } catch (AppConfigUnknownKeyException) {
index 5d753a6ee9ca96386fac224423e173d650101faa..ccd07b1c20a0a9f9e93202f9697df7b44ee6aca7 100644 (file)
@@ -1032,14 +1032,20 @@ class AppConfig implements IAppConfig {
                        throw new AppConfigUnknownKeyException('unknown config key');
                }
 
+               $value = $cache[$app][$key];
+               $sensitive = $this->isSensitive($app, $key, null);
+               if ($sensitive && str_starts_with($value, self::ENCRYPTION_PREFIX)) {
+                       $value = $this->crypto->decrypt(substr($value, self::ENCRYPTION_PREFIX_LENGTH));
+               }
+
                return [
                        'app' => $app,
                        'key' => $key,
-                       'value' => $cache[$app][$key],
+                       'value' => $value,
                        'type' => $type,
                        'lazy' => $lazy,
                        'typeString' => $typeString,
-                       'sensitive' => $this->isSensitive($app, $key, null)
+                       'sensitive' => $sensitive
                ];
        }
 
index 86bd339bc7ef9c3c1a8aa4d0b9d7be450d6785b5..3efeed5755dc6617016b74a8b2a23d1f9ea421ce 100644 (file)
@@ -1238,7 +1238,7 @@ class AppConfigTest extends TestCase {
                        [
                                'app' => 'sensitive-app',
                                'key' => 'lazy-key',
-                               'value' => $this->baseStruct['sensitive-app']['lazy-key']['encrypted'],
+                               'value' => 'value',
                                'type' => 4,
                                'lazy' => true,
                                'typeString' => 'string',