Introduce hide customvar option in monitoring view
This commit is contained in:
parent
8236b3baf0
commit
55104cba14
|
@ -61,6 +61,21 @@ class SecurityConfigForm extends ConfigForm
|
|||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'text',
|
||||
'hidden_customvars',
|
||||
array(
|
||||
'allowEmpty' => true,
|
||||
'attribs' => array('placeholder' => $this->getDefaultProtectedCustomvars()),
|
||||
'label' => $this->translate('Hidden Custom Variables'),
|
||||
'description' => $this->translate(
|
||||
'Comma separated case insensitive list of hidden custom variables.'
|
||||
. ' Use * as a placeholder for zero or more wildcard characters.'
|
||||
. ' Existence of those custom variables will not be shown, but remain usable for modules.'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -419,7 +419,9 @@ abstract class MonitoredObject implements Filterable
|
|||
public function fetchCustomvars()
|
||||
{
|
||||
$blacklist = array();
|
||||
$hidden = array();
|
||||
$blacklistPattern = '';
|
||||
$hiddenPattern = '';
|
||||
|
||||
if (($blacklistConfig = Config::module('monitoring')->get('security', 'protected_customvars', '')) !== '') {
|
||||
foreach (explode(',', $blacklistConfig) as $customvar) {
|
||||
|
@ -432,6 +434,17 @@ abstract class MonitoredObject implements Filterable
|
|||
$blacklistPattern = '/^(' . implode('|', $blacklist) . ')$/i';
|
||||
}
|
||||
|
||||
if (($hiddenConfig = Config::module('monitoring')->get('security', 'hidden_customvars', '')) !== '') {
|
||||
foreach (explode(',', $hiddenConfig) as $customvar) {
|
||||
$nonWildcards = array();
|
||||
foreach (explode('*', $customvar) as $nonWildcard) {
|
||||
$nonWildcards[] = preg_quote($nonWildcard, '/');
|
||||
}
|
||||
$hidden[] = implode('.*', $nonWildcards);
|
||||
}
|
||||
$hiddenPattern = '/^(' . implode('|', $hidden) . ')$/i';
|
||||
}
|
||||
|
||||
if ($this->type === self::TYPE_SERVICE) {
|
||||
$this->fetchServiceVariables();
|
||||
$customvars = $this->serviceVariables;
|
||||
|
@ -447,6 +460,12 @@ abstract class MonitoredObject implements Filterable
|
|||
$this->customvars = $this->obfuscateCustomVars($this->customvars, $blacklistPattern);
|
||||
}
|
||||
|
||||
if ($hiddenPattern) {
|
||||
$this->customvars = array_filter($this->customvars, function ($elem) use ($hiddenPattern) {
|
||||
return !($hiddenPattern && preg_match($hiddenPattern, $elem));
|
||||
},ARRAY_FILTER_USE_KEY);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue