diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-05-07 00:19:48 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-05-07 00:19:48 +0200 |
commit | d6d1666600c0d19a67d8e2e2e3636ac1adaba19b (patch) | |
tree | a9d9ca71e787893e40d3a583b6f4b08fe6f52d49 /lib/private/Log | |
parent | 4ad8d0c0d8e43ed9f95e217fd7e2f8894bf61104 (diff) | |
download | nextcloud-server-d6d1666600c0d19a67d8e2e2e3636ac1adaba19b.tar.gz nextcloud-server-d6d1666600c0d19a67d8e2e2e3636ac1adaba19b.zip |
remove args from logging of common-spelled methods dependent on class
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Log')
-rw-r--r-- | lib/private/Log/ExceptionSerializer.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php index 499bb4101e9..b9932cfa05c 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -21,7 +21,9 @@ namespace OC\Log; +use OC\Core\Controller\SetupController; use OC\HintException; +use OC\Setup; class ExceptionSerializer { const methodsWithSensitiveParameters = [ @@ -76,24 +78,36 @@ class ExceptionSerializer { // files_external: UserStoragesController 'update', + ]; - // Setup - 'install', - - // SetupController - 'run', - 'display', - 'loadAutoConfig', + const methodsWithSensitiveParametersByClass = [ + SetupController::class => [ + 'run', + 'display', + 'loadAutoConfig', + ], + Setup::class => [ + 'install' + ] ]; + private function editTrace(array &$sensitiveValues, array $traceLine): array { + $sensitiveValues = array_merge($sensitiveValues, $traceLine['args']); + $traceLine['args'] = ['*** sensitive parameters replaced ***']; + return $traceLine; + } + private function filterTrace(array $trace) { $sensitiveValues = []; $trace = array_map(function (array $traceLine) use (&$sensitiveValues) { + $className = $traceLine['class']; + if (isset(self::methodsWithSensitiveParametersByClass[$className]) + && in_array($traceLine['function'], self::methodsWithSensitiveParametersByClass[$className], true)) { + return $this->editTrace($sensitiveValues, $traceLine); + } foreach (self::methodsWithSensitiveParameters as $sensitiveMethod) { if (strpos($traceLine['function'], $sensitiveMethod) !== false) { - $sensitiveValues = array_merge($sensitiveValues, $traceLine['args']); - $traceLine['args'] = ['*** sensitive parameters replaced ***']; - return $traceLine; + return $this->editTrace($sensitiveValues, $traceLine); } } return $traceLine; |