Module: check_mk
Branch: master
Commit: d18d9419281d28d8e935573f78d26559b4fe1a3b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d18d9419281d28…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 27 14:21:14 2018 +0200
6728 FIX Hide links to not permitted views from host context menu
The entries for linking to BI aggregations of a host and HW/SW inventory of
a host are now hidden from the host context menu when a user is not permitted
to see the target views.
Change-Id: I483d1ba885b1ac7a44f6f363fd58765d42a2d806
---
.werks/6728 | 13 +++++++++++++
cmk/gui/plugins/views/icons/builtin.py | 7 ++++++-
cmk/gui/plugins/views/icons/inventory.py | 4 ++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/.werks/6728 b/.werks/6728
new file mode 100644
index 0000000..12e7268
--- /dev/null
+++ b/.werks/6728
@@ -0,0 +1,13 @@
+Title: Hide links to not permitted views from host context menu
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1538050817
+
+The entries for linking to BI aggregations of a host and HW/SW inventory of
+a host are now hidden from the host context menu when a user is not permitted
+to see the target views.
diff --git a/cmk/gui/plugins/views/icons/builtin.py
b/cmk/gui/plugins/views/icons/builtin.py
index bd6032b..433adf4 100644
--- a/cmk/gui/plugins/views/icons/builtin.py
+++ b/cmk/gui/plugins/views/icons/builtin.py
@@ -740,8 +740,13 @@ def paint_aggregations(what, row, tags, host_custom_vars):
if config.bi_precompile_on_demand \
or bi.is_part_of_aggregation(what, row["site"],
row["host_name"],
row.get("service_description")):
+ view_name = "aggr_%s" % what
+
+ if not config.user.may("view.%s" % view_name):
+ return
+
urivars = [
- ("view_name", "aggr_" + what),
+ ("view_name", view_name),
("aggr_%s_site" % what, row["site"]),
("aggr_%s_host" % what, row["host_name"]),
]
diff --git a/cmk/gui/plugins/views/icons/inventory.py
b/cmk/gui/plugins/views/icons/inventory.py
index 580ba78..96669be 100644
--- a/cmk/gui/plugins/views/icons/inventory.py
+++ b/cmk/gui/plugins/views/icons/inventory.py
@@ -34,6 +34,10 @@ def paint_icon_inventory(what, row, tags, customer_vars):
from cmk.gui.plugins.views import url_to_view
if (what == "host" or
row.get("service_check_command","").startswith("check_mk_active-cmk_inv!"))
\
and inventory.has_inventory(row["host_name"]):
+
+ if not config.user.may("view.inv_host"):
+ return
+
return 'inv', _("Show Hardware/Software Inventory of this
host"), url_to_view(row, 'inv_host')
multisite_icons_and_actions['inventory'] = {