mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-10 05:53:19 +09:00
Redact commonly used credential parameters during logging (#1154)
This commit is contained in:
1 parent
67fd972efd
commit
650136070e
1 file changed
+24
@@ -15,6 +15,7 @@
|
||||
class Box_EventManager implements \Box\InjectionAwareInterface
|
||||
{
|
||||
protected $di;
|
||||
protected $sensitiveParameters = ['password', 'pass', 'passwd', 'password_confirmation'];
|
||||
|
||||
/**
|
||||
* @param mixed $di
|
||||
@@ -44,6 +45,10 @@ class Box_EventManager implements \Box\InjectionAwareInterface
|
||||
$subject = $data['subject'] ?? null;
|
||||
$params = $data['params'] ?? null;
|
||||
|
||||
if (is_array($params)) {
|
||||
$params = $this->hideSensitiveParameters($params);
|
||||
}
|
||||
|
||||
if (BB_DEBUG) {
|
||||
$this->di['logger']->debug($event.': '.var_export($params, 1));
|
||||
}
|
||||
@@ -57,6 +62,25 @@ class Box_EventManager implements \Box\InjectionAwareInterface
|
||||
return $e->getReturnValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide some of the known sensitive parameters.
|
||||
*
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function hideSensitiveParameters($params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->sensitiveParameters)) {
|
||||
$params[$key] = '********';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Box_EventDispatcher $disp
|
||||
* @param string $event
|
||||
|
||||
Reference in new issue
Block a user