Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable15] use a pattern to identify sensitive config keys #16565

Merged
merged 1 commit into from Jul 27, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/private/AppConfig.php
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
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