mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
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()
|
public function fetchCustomvars()
|
||||||
{
|
{
|
||||||
$blacklist = array();
|
$blacklist = array();
|
||||||
|
$hidden = array();
|
||||||
$blacklistPattern = '';
|
$blacklistPattern = '';
|
||||||
|
$hiddenPattern = '';
|
||||||
|
|
||||||
if (($blacklistConfig = Config::module('monitoring')->get('security', 'protected_customvars', '')) !== '') {
|
if (($blacklistConfig = Config::module('monitoring')->get('security', 'protected_customvars', '')) !== '') {
|
||||||
foreach (explode(',', $blacklistConfig) as $customvar) {
|
foreach (explode(',', $blacklistConfig) as $customvar) {
|
||||||
@ -432,6 +434,17 @@ abstract class MonitoredObject implements Filterable
|
|||||||
$blacklistPattern = '/^(' . implode('|', $blacklist) . ')$/i';
|
$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) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$this->fetchServiceVariables();
|
$this->fetchServiceVariables();
|
||||||
$customvars = $this->serviceVariables;
|
$customvars = $this->serviceVariables;
|
||||||
@ -447,6 +460,12 @@ abstract class MonitoredObject implements Filterable
|
|||||||
$this->customvars = $this->obfuscateCustomVars($this->customvars, $blacklistPattern);
|
$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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user