summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-07-26 13:31:14 +0200
committerBackportbot <backportbot-noreply@rullzer.com>2019-07-26 13:21:22 +0000
commita9ccac2f206882ad1008c219cc94c48e7a434f57 (patch)
tree31c7e87d79547d4d7bed2ee39d7ac5402fb38c5b
parent159ff6dd976704cb405e3502e3d0bbf81c80ffce (diff)
downloadnextcloud-server-a9ccac2f206882ad1008c219cc94c48e7a434f57.tar.gz
nextcloud-server-a9ccac2f206882ad1008c219cc94c48e7a434f57.zip
treat sensitive config keys by pattern
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r--lib/private/AppConfig.php9
-rw-r--r--tests/lib/AppConfigTest.php2
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index 6d24ca5fa8e..8e921dbb7cf 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -44,10 +44,10 @@ class AppConfig implements IAppConfig {
/** @var array[] */
protected $sensitiveValues = [
'spreed' => [
- 'turn_server_secret',
+ '/^turn_server_secret$/',
],
'user_ldap' => [
- 'ldap_agent_password',
+ '/^(s..)?ldap_agent_password$/',
],
];
@@ -289,8 +289,9 @@ class AppConfig implements IAppConfig {
$values = $this->getValues($app, false);
if (isset($this->sensitiveValues[$app])) {
- foreach ($this->sensitiveValues[$app] as $sensitiveKey) {
- if (isset($values[$sensitiveKey])) {
+ foreach ($this->sensitiveValues[$app] as $sensitiveKeyExp) {
+ $sensitiveKeys = preg_grep($sensitiveKeyExp, array_keys($values));
+ foreach ($sensitiveKeys as $sensitiveKey) {
$values[$sensitiveKey] = IConfig::SENSITIVE_VALUE;
}
}
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index fed929352d3..9456fe4c232 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -318,12 +318,14 @@ class AppConfigTest extends TestCase {
->with('user_ldap', false)
->willReturn([
'ldap_agent_password' => 'secret',
+ 's42ldap_agent_password' => 'secret',
'ldap_dn' => 'dn',
]);
$values = $config->getFilteredValues('user_ldap');
$this->assertEquals([
'ldap_agent_password' => IConfig::SENSITIVE_VALUE,
+ 's42ldap_agent_password' => IConfig::SENSITIVE_VALUE,
'ldap_dn' => 'dn',
], $values);
}