]> source.dussan.org Git - nextcloud-server.git/commitdiff
remove args from logging of common-spelled methods dependent on class
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 6 May 2019 22:19:48 +0000 (00:19 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 9 May 2019 09:25:54 +0000 (11:25 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Log/ExceptionSerializer.php

index 499bb4101e93d40d444fc1495f76766f01b16c2f..b9932cfa05ceb99cc9e9adf9a9f773d0130992ab 100644 (file)
@@ -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;