mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Monitoring/Object: filter protected customvars
Move the responsibility from the viewscript to Monitoring/Object refs #6641
This commit is contained in:
parent
ea0248ecf4
commit
071937910b
@ -1,12 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (! $object->customvars) { return; }
|
|
||||||
|
|
||||||
foreach ($object->customvars as $name => $value) {
|
foreach ($object->customvars as $name => $value) {
|
||||||
$name = ucwords(str_replace('_', ' ', strtolower($name)));
|
|
||||||
if (preg_match('~(?:pw|pass|community)~', strtolower($name))) {
|
|
||||||
$value = '***';
|
|
||||||
}
|
|
||||||
printf(
|
printf(
|
||||||
"<tr><th>%s</th><td>%s</td></tr>\n",
|
"<tr><th>%s</th><td>%s</td></tr>\n",
|
||||||
$this->escape($name),
|
$this->escape($name),
|
||||||
|
@ -20,6 +20,7 @@ use Icinga\Module\Monitoring\DataView\Comment;
|
|||||||
use Icinga\Module\Monitoring\DataView\Servicegroup;
|
use Icinga\Module\Monitoring\DataView\Servicegroup;
|
||||||
use Icinga\Module\Monitoring\DataView\Customvar;
|
use Icinga\Module\Monitoring\DataView\Customvar;
|
||||||
use Icinga\Web\UrlParams;
|
use Icinga\Web\UrlParams;
|
||||||
|
use Icinga\Application\Config;
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractObject
|
abstract class AbstractObject
|
||||||
@ -120,6 +121,17 @@ abstract class AbstractObject
|
|||||||
|
|
||||||
public function fetchCustomvars()
|
public function fetchCustomvars()
|
||||||
{
|
{
|
||||||
|
$monitoringSecurity = Config::module('monitoring')->get('security')->toArray();
|
||||||
|
$customvars = array();
|
||||||
|
foreach (explode(',', $monitoringSecurity['protected_customvars']) as $customvar) {
|
||||||
|
$nonWildcards = array();
|
||||||
|
foreach (explode('*', $customvar) as $nonWildcard) {
|
||||||
|
$nonWildcards[] = preg_quote($nonWildcard, '/');
|
||||||
|
}
|
||||||
|
$customvars[] = implode('.*', $nonWildcards);
|
||||||
|
}
|
||||||
|
$customvars = '/^(' . implode('|', $customvars) . ')$/i';
|
||||||
|
|
||||||
$query = Customvar::fromParams(array('backend' => null), array(
|
$query = Customvar::fromParams(array('backend' => null), array(
|
||||||
'varname',
|
'varname',
|
||||||
'varvalue'
|
'varvalue'
|
||||||
@ -136,6 +148,12 @@ abstract class AbstractObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->customvars = $query->getQuery()->fetchPairs();
|
$this->customvars = $query->getQuery()->fetchPairs();
|
||||||
|
foreach ($this->customvars as $name => &$value) {
|
||||||
|
if (preg_match($customvars, ucwords(str_replace('_', ' ', strtolower($name))))) {
|
||||||
|
$value = '***';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user