mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
MonitoredObject: Keep structure of nested cvs during protection
fixes #4439 (cherry picked from commit d123b390b1c550de91988a3451d2c3818082c12e)
This commit is contained in:
parent
479f990d59
commit
78e947a021
@ -466,19 +466,22 @@ abstract class MonitoredObject implements Filterable
|
||||
return $customvars;
|
||||
}
|
||||
|
||||
$obfuscatedCustomVars = [];
|
||||
$obfuscator = function ($vars) use ($blacklistPattern, &$obfuscatedCustomVars, &$obfuscator) {
|
||||
$obfuscator = function ($vars) use ($blacklistPattern, &$obfuscator) {
|
||||
$result = [];
|
||||
foreach ($vars as $name => $value) {
|
||||
if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
|
||||
$obfuscatedCustomVars[$name] = '***';
|
||||
$result[$name] = '***';
|
||||
} elseif ($value instanceof stdClass || is_array($value)) {
|
||||
$obfuscated = $obfuscator($value);
|
||||
$result[$name] = $value instanceof stdClass ? (object) $obfuscated : $obfuscated;
|
||||
} else {
|
||||
$obfuscatedCustomVars[$name] = $value instanceof stdClass || is_array($value)
|
||||
? $obfuscator($value)
|
||||
: $value;
|
||||
$result[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
};
|
||||
$obfuscator($customvars);
|
||||
$obfuscatedCustomVars = $obfuscator($customvars);
|
||||
|
||||
return $customvars instanceof stdClass ? (object) $obfuscatedCustomVars : $obfuscatedCustomVars;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user