Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
treat sensitive config keys by pattern
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and Backportbot committed Jul 26, 2019
commit 8c956693a5a02b422955d781d09163552d017644
9 changes: 5 additions & 4 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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$/',
],
];

Expand Down Expand Up @@ -289,8 +289,9 @@ public function getFilteredValues($app) {
$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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/AppConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ public function testGetFilteredValues() {
->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);
}
Expand Down