diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-07-28 23:30:17 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-07-28 23:30:17 +0200 |
commit | 2a6f46e6891ee82b613be6151d2f51583c45c2bf (patch) | |
tree | 9c2419d41c3fac9674b5b6323e79d4e66b018c64 /lib/private/Log | |
parent | bbe15b4b43f95e1600f5122a7bf72a64ee404b36 (diff) | |
download | nextcloud-server-2a6f46e6891ee82b613be6151d2f51583c45c2bf.tar.gz nextcloud-server-2a6f46e6891ee82b613be6151d2f51583c45c2bf.zip |
allow apps to specify methods carrying sensitive parameters
… in order to remove them from logging.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Log')
-rw-r--r-- | lib/private/Log/ExceptionSerializer.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php index 3c3ff95f8e1..aaf6a39235e 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -109,7 +109,7 @@ class ExceptionSerializer { $this->systemConfig = $systemConfig; } - public const methodsWithSensitiveParametersByClass = [ + protected array $methodsWithSensitiveParametersByClass = [ SetupController::class => [ 'run', 'display', @@ -190,8 +190,8 @@ class ExceptionSerializer { $sensitiveValues = []; $trace = array_map(function (array $traceLine) use (&$sensitiveValues) { $className = $traceLine['class'] ?? ''; - if ($className && isset(self::methodsWithSensitiveParametersByClass[$className]) - && in_array($traceLine['function'], self::methodsWithSensitiveParametersByClass[$className], true)) { + if ($className && isset($this->methodsWithSensitiveParametersByClass[$className]) + && in_array($traceLine['function'], $this->methodsWithSensitiveParametersByClass[$className], true)) { return $this->editTrace($sensitiveValues, $traceLine); } foreach (self::methodsWithSensitiveParameters as $sensitiveMethod) { @@ -289,4 +289,11 @@ class ExceptionSerializer { return $data; } + + public function enlistSensitiveMethods(string $class, array $methods): void { + if (!isset($this->methodsWithSensitiveParametersByClass[$class])) { + $this->methodsWithSensitiveParametersByClass[$class] = []; + } + $this->methodsWithSensitiveParametersByClass[$class] = array_merge($this->methodsWithSensitiveParametersByClass[$class], $methods); + } } |