From 7bc489ba4d0d4f7feb7c7376f48a32957b7b65fb Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Fri, 22 Jan 2016 18:37:27 +0100
Subject: [PATCH 01/96] MonitoredObject: obfuscate custom variables recursively
refs #10640
---
.../Monitoring/Object/MonitoredObject.php | 33 ++++++++++++++-----
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
index 4a787d309..37d1d48d7 100644
--- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
+++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php
@@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Object;
+use stdClass;
use InvalidArgumentException;
use Icinga\Application\Config;
use Icinga\Data\Filter\Filter;
@@ -456,18 +457,34 @@ abstract class MonitoredObject implements Filterable
$customvars = $this->hostVariables;
}
- $this->customvars = array();
- foreach ($customvars as $name => $value) {
- if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
- $this->customvars[$name] = '***';
- } else {
- $this->customvars[$name] = $value;
- }
- }
+ $this->customvars = $this->obfuscateCustomVars($customvars, $blacklistPattern);
return $this;
}
+ /**
+ * Obfuscate custom variables recursively for $this->customvars.
+ *
+ * @param stdClass|array $customvars The custom variables to obfuscate
+ * @param string $blacklistPattern Which custom variables to obfuscate
+ *
+ * @return stdClass|array The obfuscated custom variables
+ */
+ protected function obfuscateCustomVars($customvars, $blacklistPattern)
+ {
+ $obfuscatedCustomVars = array();
+ foreach ($customvars as $name => $value) {
+ if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
+ $obfuscatedCustomVars[$name] = '***';
+ } else {
+ $obfuscatedCustomVars[$name] = $value instanceof stdClass || is_array($value)
+ ? $this->obfuscateCustomVars($value, $blacklistPattern)
+ : $value;
+ }
+ }
+ return $customvars instanceof stdClass ? (object) $obfuscatedCustomVars : $obfuscatedCustomVars;
+ }
+
/**
* Fetch the host custom variables related to this object
*
From b0932d2413e7b5cc7127fc89c8fa389b908669f1 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Mon, 15 Feb 2016 16:26:52 +0100
Subject: [PATCH 02/96] Implement escapeComment helper
refs #10654
---
.../views/helpers/EscapeComment.php | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 modules/monitoring/application/views/helpers/EscapeComment.php
diff --git a/modules/monitoring/application/views/helpers/EscapeComment.php b/modules/monitoring/application/views/helpers/EscapeComment.php
new file mode 100644
index 000000000..be85a223e
--- /dev/null
+++ b/modules/monitoring/application/views/helpers/EscapeComment.php
@@ -0,0 +1,38 @@
+).
+ *
+ * @param string $comment
+ *
+ * @return string
+ */
+ public function escapeComment($comment)
+ {
+ if (self::$purifier === null) {
+ require_once 'HTMLPurifier/Bootstrap.php';
+ require_once 'HTMLPurifier.php';
+ require_once 'HTMLPurifier.autoload.php';
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Core.EscapeNonASCIICharacters', true);
+ $config->set('HTML.Allowed', 'a[href]');
+ $config->set('Cache.DefinitionImpl', null);
+ self::$purifier = new HTMLPurifier($config);
+ }
+ return self::$purifier->purify($comment);
+ }
+}
From af3abb76c823531ad3e5efd9b2f4a86f1040ef4d Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Tue, 16 Feb 2016 14:55:27 +0100
Subject: [PATCH 03/96] Render simple HTML links (a[href]) in acknowledgements,
comments and downtimes
refs #10654
---
.../monitoring/application/views/scripts/downtime/show.phtml | 2 +-
.../views/scripts/partials/comment/comment-detail.phtml | 2 +-
.../views/scripts/partials/downtime/downtime-header.phtml | 2 +-
.../application/views/scripts/partials/event-history.phtml | 4 +++-
.../views/scripts/show/components/acknowledgement.phtml | 2 +-
.../application/views/scripts/show/components/comments.phtml | 2 +-
.../application/views/scripts/show/components/downtime.phtml | 2 +-
7 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml
index c584540fc..b10ae9587 100644
--- a/modules/monitoring/application/views/scripts/downtime/show.phtml
+++ b/modules/monitoring/application/views/scripts/downtime/show.phtml
@@ -45,7 +45,7 @@
= $this->translate('Comment') ?> |
-
+
diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
index 433b60412..0fb72c38d 100644
--- a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
+++ b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
@@ -56,5 +56,5 @@
diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml
index cf2cdf651..96130db7a 100644
--- a/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml
+++ b/modules/monitoring/application/views/scripts/partials/downtime/downtime-header.phtml
@@ -67,6 +67,6 @@
diff --git a/modules/monitoring/application/views/scripts/partials/event-history.phtml b/modules/monitoring/application/views/scripts/partials/event-history.phtml
index e7ae0e034..7a0cee293 100644
--- a/modules/monitoring/application/views/scripts/partials/event-history.phtml
+++ b/modules/monitoring/application/views/scripts/partials/event-history.phtml
@@ -147,7 +147,9 @@ $history->limit($limit * $page);
icon($icon, null, $iconCssClass ? array('class' => $iconCssClass) : array());
} ?>
- = nl2br($this->createTicketLinks($this->escape($msg)), false) ?>
+ = $this->nl2br($this->createTicketLinks($this->escapeComment($msg)))
+ // TODO(ak): this allows only a[href] in messages, but plugin output allows more
+ ?>
diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml
index 289405c5b..568dc9062 100644
--- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml
@@ -44,7 +44,7 @@ $acknowledgement = $object->acknowledgement;
} ?>
- = $this->nl2br($this->createTicketLinks($this->escape($acknowledgement->getComment()))) ?>
+ = $this->nl2br($this->createTicketLinks($this->escapeComment($acknowledgement->getComment()))) ?>
diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml
index 34b72c589..671c363d1 100644
--- a/modules/monitoring/application/views/scripts/show/components/comments.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml
@@ -67,7 +67,7 @@ if (empty($object->comments) && ! $addLink) {
} ?>
- = $this->nl2br($this->createTicketLinks($this->escape($comment->comment))) ?>
+ = $this->nl2br($this->createTicketLinks($this->escapeComment($comment->comment))) ?>
diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml
index 7da27f2bf..5655da4c4 100644
--- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml
+++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml
@@ -96,7 +96,7 @@ if (empty($object->comments) && ! $addLink) {
} ?>
- = $this->nl2br($this->createTicketLinks($this->escape($downtime->comment))) ?>
+ = $this->nl2br($this->createTicketLinks($this->escapeComment($downtime->comment))) ?>
From 6c39fb51f8bd73c852c8b6e46702bea11b8729ae Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Wed, 17 Feb 2016 18:23:38 +0100
Subject: [PATCH 04/96] Menu: move Configuration/Authentication to
Configuration/Application/Authentication
refs #10309
---
application/controllers/ConfigController.php | 23 ++++----------------
library/Icinga/Application/Web.php | 6 -----
2 files changed, 4 insertions(+), 25 deletions(-)
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
index 7b01bbff5..ce8440749 100644
--- a/application/controllers/ConfigController.php
+++ b/application/controllers/ConfigController.php
@@ -45,27 +45,12 @@ class ConfigController extends Controller
'url' => 'config/resource',
'baseTarget' => '_main'
));
- return $tabs;
- }
-
- /**
- * Create and return the tabs to display when showing authentication configuration
- */
- public function createAuthenticationTabs()
- {
- $tabs = $this->getTabs();
- $tabs->add('userbackend', array(
- 'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'),
- 'label' => $this->translate('Users'),
+ $tabs->add('authentication', array(
+ 'title' => $this->translate('Configure the user and group backends'),
+ 'label' => $this->translate('Authentication'),
'url' => 'config/userbackend',
'baseTarget' => '_main'
));
- $tabs->add('usergroupbackend', array(
- 'title' => $this->translate('Configure how users are associated with groups by Icinga Web 2'),
- 'label' => $this->translate('User Groups'),
- 'url' => 'usergroupbackend/list',
- 'baseTarget' => '_main'
- ));
return $tabs;
}
@@ -194,7 +179,7 @@ class ConfigController extends Controller
$form->handleRequest();
$this->view->form = $form;
- $this->createAuthenticationTabs()->activate('userbackend');
+ $this->createApplicationTabs()->activate('authentication');
$this->render('userbackend/reorder');
}
diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php
index d0535423f..f50beb2e8 100644
--- a/library/Icinga/Application/Web.php
+++ b/library/Icinga/Application/Web.php
@@ -321,12 +321,6 @@ class Web extends EmbeddedWeb
'permission' => 'config/application/*',
'priority' => 810
),
- 'authentication' => array(
- 'label' => t('Authentication'),
- 'url' => 'config/userbackend',
- 'permission' => 'config/application/*',
- 'priority' => 820
- ),
'authorization' => array(
'label' => t('Authorization'),
'permission' => 'config/authentication/*',
From 88ff055f39b669a9750d084d39649418f0ee8384 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Wed, 17 Feb 2016 18:43:26 +0100
Subject: [PATCH 05/96] Combine the lists of user and group backends
refs #10309
---
application/controllers/ConfigController.php | 4 +-
.../UsergroupbackendController.php | 36 ++----------
.../scripts/config/userbackend/reorder.phtml | 52 +++++++++++++++++
.../views/scripts/usergroupbackend/list.phtml | 56 -------------------
4 files changed, 59 insertions(+), 89 deletions(-)
delete mode 100644 application/views/scripts/usergroupbackend/list.phtml
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
index ce8440749..c1d75b711 100644
--- a/application/controllers/ConfigController.php
+++ b/application/controllers/ConfigController.php
@@ -169,16 +169,18 @@ class ConfigController extends Controller
}
/**
- * Action for listing and reordering user backends
+ * Action for listing user and group backends
*/
public function userbackendAction()
{
$this->assertPermission('config/application/userbackend');
+ $this->assertPermission('config/application/usergroupbackend');
$form = new UserBackendReorderForm();
$form->setIniConfig(Config::app('authentication'));
$form->handleRequest();
$this->view->form = $form;
+ $this->view->backendNames = Config::app('groups');
$this->createApplicationTabs()->activate('authentication');
$this->render('userbackend/reorder');
}
diff --git a/application/controllers/UsergroupbackendController.php b/application/controllers/UsergroupbackendController.php
index 2f134cddd..14456fc01 100644
--- a/application/controllers/UsergroupbackendController.php
+++ b/application/controllers/UsergroupbackendController.php
@@ -29,16 +29,7 @@ class UsergroupbackendController extends Controller
*/
public function indexAction()
{
- $this->redirectNow('usergroupbackend/list');
- }
-
- /**
- * Show a list of all user group backends
- */
- public function listAction()
- {
- $this->view->backendNames = Config::app('groups');
- $this->createListTabs()->activate('usergroupbackend');
+ $this->redirectNow('config/userbackend');
}
/**
@@ -47,7 +38,7 @@ class UsergroupbackendController extends Controller
public function createAction()
{
$form = new UserGroupBackendForm();
- $form->setRedirectUrl('usergroupbackend/list');
+ $form->setRedirectUrl('config/userbackend');
$form->addDescription($this->translate('Create a new backend to associate users and groups with.'));
$form->setIniConfig(Config::app('groups'));
$form->setOnSuccess(function (UserGroupBackendForm $form) {
@@ -78,7 +69,7 @@ class UsergroupbackendController extends Controller
$backendName = $this->params->getRequired('backend');
$form = new UserGroupBackendForm();
- $form->setRedirectUrl('usergroupbackend/list');
+ $form->setRedirectUrl('config/userbackend');
$form->setIniConfig(Config::app('groups'));
$form->setOnSuccess(function (UserGroupBackendForm $form) use ($backendName) {
try {
@@ -121,7 +112,7 @@ class UsergroupbackendController extends Controller
$backendForm = new UserGroupBackendForm();
$backendForm->setIniConfig(Config::app('groups'));
$form = new ConfirmRemovalForm();
- $form->setRedirectUrl('usergroupbackend/list');
+ $form->setRedirectUrl('config/userbackend');
$form->setOnSuccess(function (ConfirmRemovalForm $form) use ($backendName, $backendForm) {
try {
$backendForm->delete($backendName);
@@ -141,23 +132,4 @@ class UsergroupbackendController extends Controller
$this->renderForm($form, $this->translate('Remove User Group Backend'));
}
-
- /**
- * Create the tabs for the application configuration
- */
- protected function createListTabs()
- {
- $tabs = $this->getTabs();
- $tabs->add('userbackend', array(
- 'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'),
- 'label' => $this->translate('Users'),
- 'url' => 'config/userbackend'
- ));
- $tabs->add('usergroupbackend', array(
- 'title' => $this->translate('Configure how users are associated with groups by Icinga Web 2'),
- 'label' => $this->translate('User Groups'),
- 'url' => 'usergroupbackend/list'
- ));
- return $tabs;
- }
}
diff --git a/application/views/scripts/config/userbackend/reorder.phtml b/application/views/scripts/config/userbackend/reorder.phtml
index a065b6005..02eec6b1d 100644
--- a/application/views/scripts/config/userbackend/reorder.phtml
+++ b/application/views/scripts/config/userbackend/reorder.phtml
@@ -14,4 +14,56 @@
)
) ?>
= $form ?>
+
+ = $this->qlink(
+ $this->translate('Create a New User Group Backend') ,
+ 'usergroupbackend/create',
+ null,
+ array(
+ 'class' => 'button-link',
+ 'data-base-target' => '_next',
+ 'icon' => 'plus',
+ 'title' => $this->translate('Create a new user group backend')
+ )
+ ) ?>
+
+
+
+
+ = $this->translate('Backend') ?> |
+ |
+
+
+
+ $config):
+ $type = $config->get('backend');
+?>
+
+
+ = $this->qlink(
+ $backendName,
+ 'usergroupbackend/edit',
+ array('backend' => $backendName),
+ array(
+ 'icon' => $type === 'external' ? 'magic' : ($type === 'ldap' || $type === 'msldap' ? 'sitemap' : 'database'),
+ 'title' => sprintf($this->translate('Edit user group backend %s'), $backendName)
+ )
+ ); ?>
+ |
+
+ = $this->qlink(
+ null,
+ 'usergroupbackend/remove',
+ array('backend' => $backendName),
+ array(
+ 'class' => 'action-link',
+ 'icon' => 'cancel',
+ 'title' => sprintf($this->translate('Remove user group backend %s'), $backendName)
+ )
+ ) ?>
+ |
+
+
+
+
diff --git a/application/views/scripts/usergroupbackend/list.phtml b/application/views/scripts/usergroupbackend/list.phtml
deleted file mode 100644
index 5ce1df90f..000000000
--- a/application/views/scripts/usergroupbackend/list.phtml
+++ /dev/null
@@ -1,56 +0,0 @@
-
- = $tabs ?>
-
-
- = $this->qlink(
- $this->translate('Create a New User Group Backend') ,
- 'usergroupbackend/create',
- null,
- array(
- 'class' => 'button-link',
- 'data-base-target' => '_next',
- 'icon' => 'plus',
- 'title' => $this->translate('Create a new user group backend')
- )
- ) ?>
-
-
-
-
- = $this->translate('Backend') ?> |
- |
-
-
-
- $config):
- $type = $config->get('backend');
-?>
-
-
- = $this->qlink(
- $backendName,
- 'usergroupbackend/edit',
- array('backend' => $backendName),
- array(
- 'icon' => $type === 'external' ? 'magic' : ($type === 'ldap' || $type === 'msldap' ? 'sitemap' : 'database'),
- 'title' => sprintf($this->translate('Edit user group backend %s'), $backendName)
- )
- ); ?>
- |
-
- = $this->qlink(
- null,
- 'usergroupbackend/remove',
- array('backend' => $backendName),
- array(
- 'class' => 'action-link',
- 'icon' => 'cancel',
- 'title' => sprintf($this->translate('Remove user group backend %s'), $backendName)
- )
- ) ?>
- |
-
-
-
-
-
From 4e9e0f9b358699f8bd964c893dffba911718524a Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Wed, 17 Feb 2016 18:48:47 +0100
Subject: [PATCH 06/96] Separate the lists of user and group backends with
headings
refs #10309
---
application/views/scripts/config/userbackend/reorder.phtml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/application/views/scripts/config/userbackend/reorder.phtml b/application/views/scripts/config/userbackend/reorder.phtml
index 02eec6b1d..a8e351e5d 100644
--- a/application/views/scripts/config/userbackend/reorder.phtml
+++ b/application/views/scripts/config/userbackend/reorder.phtml
@@ -2,6 +2,7 @@
= $tabs ?>
+
= $this->translate('User Backends') ?>
= $this->qlink(
$this->translate('Create a New User Backend') ,
'config/createuserbackend',
@@ -15,6 +16,7 @@
) ?>
= $form ?>
+
= $this->translate('User Group Backends') ?>
= $this->qlink(
$this->translate('Create a New User Group Backend') ,
'usergroupbackend/create',
From a3c7a04826e0a2c38a855c3d4b9a069601022a22 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Wed, 17 Feb 2016 18:56:55 +0100
Subject: [PATCH 07/96] Menu: rename Configuration/Authorization to
Configuration/Authentication
refs #10309
---
library/Icinga/Application/Web.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php
index f50beb2e8..c3328a169 100644
--- a/library/Icinga/Application/Web.php
+++ b/library/Icinga/Application/Web.php
@@ -321,8 +321,8 @@ class Web extends EmbeddedWeb
'permission' => 'config/application/*',
'priority' => 810
),
- 'authorization' => array(
- 'label' => t('Authorization'),
+ 'authentication' => array(
+ 'label' => t('Authentication'),
'permission' => 'config/authentication/*',
'priority' => 830,
'url' => 'role/list'
From c4610ab05d1779fac6908e890f1572ca021cd791 Mon Sep 17 00:00:00 2001
From: "Alexander A. Klimov"
Date: Thu, 18 Feb 2016 10:39:52 +0100
Subject: [PATCH 08/96] Comments list: display the absolute expire date and
time in tooltips
refs #10277
---
.../views/scripts/partials/comment/comment-detail.phtml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
index 433b60412..5ac1c6f47 100644
--- a/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
+++ b/modules/monitoring/application/views/scripts/partials/comment/comment-detail.phtml
@@ -38,8 +38,9 @@