Skip to content

Commit c94bea0

Browse files
committed
fix(config): Decrypt sensitive appconfigs when requested
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent ca2df76 commit c94bea0

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

build/psalm-baseline.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,11 +3002,7 @@
30023002
<file src="core/Command/Config/ListConfigs.php">
30033003
<DeprecatedMethod>
30043004
<code><![CDATA[getFilteredValues]]></code>
3005-
<code><![CDATA[getValues]]></code>
30063005
</DeprecatedMethod>
3007-
<FalsableReturnStatement>
3008-
<code><![CDATA[$this->appConfig->getValues($app, false)]]></code>
3009-
</FalsableReturnStatement>
30103006
</file>
30113007
<file src="core/Command/Db/ConvertType.php">
30123008
<DeprecatedMethod>

core/Command/Config/ListConfigs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function getAppConfigs(string $app, bool $noSensitiveValues) {
132132
if ($noSensitiveValues) {
133133
return $this->appConfig->getFilteredValues($app);
134134
} else {
135-
return $this->appConfig->getValues($app, false);
135+
return $this->appConfig->getAllValues($app);
136136
}
137137
}
138138

lib/private/AppConfig.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ function (string $key) use ($prefix): bool {
265265
);
266266

267267
if (!$filtered) {
268+
foreach ($values as $key => $value) {
269+
$sensitive = $this->isSensitive($app, $key, null);
270+
if ($sensitive && is_string($value) && str_starts_with($value, self::ENCRYPTION_PREFIX)) {
271+
$values[$key] = $this->crypto->decrypt(substr($value, self::ENCRYPTION_PREFIX_LENGTH));
272+
}
273+
}
274+
268275
return $values;
269276
}
270277

tests/Core/Command/Config/ListConfigsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ public static function listData(): array {
107107
],
108108
// app config
109109
[
110-
['files', false, [
110+
['files', [
111111
'enabled' => 'yes',
112112
]],
113-
['core', false, [
113+
['core', [
114114
'global_cache_gc_lastrun' => '1430388388',
115115
]],
116116
],
@@ -243,10 +243,10 @@ public static function listData(): array {
243243
],
244244
// app config
245245
[
246-
['files', false, [
246+
['files', [
247247
'enabled' => 'yes',
248248
]],
249-
['core', false, [
249+
['core', [
250250
'global_cache_gc_lastrun' => '1430388388',
251251
]],
252252
],
@@ -281,7 +281,7 @@ public function testList($app, $systemConfigs, $systemConfigMap, $appConfig, $pr
281281
->method('getValue')
282282
->willReturnMap($systemConfigMap);
283283
$this->appConfig->expects($this->any())
284-
->method('getValues')
284+
->method('getAllValues')
285285
->willReturnMap($appConfig);
286286
} else {
287287
$this->systemConfig->expects($this->any())
@@ -296,7 +296,7 @@ public function testList($app, $systemConfigs, $systemConfigMap, $appConfig, $pr
296296
->method('getApps')
297297
->willReturn(['core', 'files']);
298298
$this->appConfig->expects($this->any())
299-
->method('getValues')
299+
->method('getAllValues')
300300
->willReturnMap($appConfig);
301301

302302
$this->consoleInput->expects($this->once())

0 commit comments

Comments
 (0)