diff --git a/pandora_console/include/lib/TacticalView/Element.php b/pandora_console/include/lib/TacticalView/Element.php index 424e473250..8e81d4fd15 100644 --- a/pandora_console/include/lib/TacticalView/Element.php +++ b/pandora_console/include/lib/TacticalView/Element.php @@ -82,11 +82,19 @@ class Element $this->interval = 0; $this->title = __('Default element'); $this->ajaxController = $ajax_controller; - $agent = agents_get_agents(['nombre' => 'pandora.internals']); - if (is_array($agent) === true && count($agent) > 0) { - $this->monitoringAgent = $agent[0]; + // Without ACL. + $agent = db_get_row('tagente', 'nombre', 'pandora.internals', '*'); + if (is_array($agent) === true) { + $this->monitoringAgent = $agent; } + /* + // With ACL. + $agent = agents_get_agents(['nombre' => 'pandora.internals']); + if (is_array($agent) === true && count($agent) > 0) { + $this->monitoringAgent = $agent[0]; + } + */ } diff --git a/pandora_console/include/lib/TacticalView/elements/Agents.php b/pandora_console/include/lib/TacticalView/elements/Agents.php index d3061599f6..1aec4cb57d 100644 --- a/pandora_console/include/lib/TacticalView/elements/Agents.php +++ b/pandora_console/include/lib/TacticalView/elements/Agents.php @@ -139,7 +139,18 @@ class Agents extends Element $start = get_parameter('start', 0); $length = get_parameter('length', $config['block_size']); $pagination = ''; - $order = ''; + + $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); + + if (in_array(0, $id_groups) === false) { + foreach ($id_groups as $key => $id_group) { + if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) { + unset($id_groups[$key]); + } + } + } + + $id_groups = implode(',', $id_groups); try { ob_start(); @@ -169,8 +180,10 @@ class Agents extends Element SELECT gr.id_grupo, count(*) AS total FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo + WHERE a.id_grupo IN ('.$id_groups.') OR g.id_group IN ('.$id_groups.') GROUP BY a.id_grupo ORDER BY total DESC LIMIT 20 ) top_groups ON top_groups.id_grupo = gr.id_grupo + WHERE a.id_grupo IN ('.$id_groups.') OR g.id_group IN ('.$id_groups.') GROUP BY a.id_grupo ORDER BY total DESC %s', @@ -193,8 +206,10 @@ class Agents extends Element SELECT gr.id_grupo, count(*) AS total FROM tagente a LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo + WHERE a.id_grupo IN ('.$id_groups.') OR g.id_group IN ('.$id_groups.') GROUP BY a.id_grupo ORDER BY total DESC LIMIT 20 ) top_groups ON top_groups.id_grupo = gr.id_grupo + WHERE a.id_grupo IN ('.$id_groups.') OR g.id_group IN ('.$id_groups.') GROUP BY a.id_grupo ORDER BY total DESC'; @@ -214,7 +229,7 @@ class Agents extends Element return json_encode(['error' => $e->getMessage()]); } - json_decode($response); + return json_decode($response); if (json_last_error() === JSON_ERROR_NONE) { return $response; } else { @@ -235,9 +250,25 @@ class Agents extends Element */ public function getOperatingSystemGraph():string { + global $config; + $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); + + if (in_array(0, $id_groups) === false) { + foreach ($id_groups as $key => $id_group) { + if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) { + unset($id_groups[$key]); + } + } + } + + $id_groups = implode(',', $id_groups); + $sql = 'SELECT name, count(*) AS total FROM tagente a + LEFT JOIN tagent_secondary_group g ON g.id_agent = a.id_agente + LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo LEFT JOIN tconfig_os os ON os.id_os = a.id_os + WHERE a.id_grupo IN ('.$id_groups.') OR g.id_group IN ('.$id_groups.') GROUP BY a.id_os ORDER BY total DESC'; $rows = db_process_sql($sql); diff --git a/pandora_console/include/lib/TacticalView/elements/Database.php b/pandora_console/include/lib/TacticalView/elements/Database.php index ffd38c8156..7d46d29cb1 100644 --- a/pandora_console/include/lib/TacticalView/elements/Database.php +++ b/pandora_console/include/lib/TacticalView/elements/Database.php @@ -329,4 +329,17 @@ class Database extends Element } + /** + * Check if user can manage database + * + * @return boolean + */ + public function checkAcl():bool + { + global $config; + $db_m = (bool) check_acl($config['id_user'], 0, 'DM'); + return $db_m; + } + + } diff --git a/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php index b0c3d9d75d..71a57d3070 100644 --- a/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php +++ b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php @@ -95,10 +95,24 @@ class MonitoringElements extends Element */ public function getModuleGroupGraph():string { + global $config; + $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); + + if (in_array(0, $id_groups) === false) { + foreach ($id_groups as $key => $id_group) { + if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) { + unset($id_groups[$key]); + } + } + } + + $id_groups = implode(',', $id_groups); $sql = 'SELECT name, count(*) AS total FROM tagente_modulo m + LEFT JOIN tagente a on a.id_agente = m.id_agente + LEFT JOIN tagent_secondary_group gs ON gs.id_agent = a.id_agente LEFT JOIN tmodule_group g ON g.id_mg = m.id_module_group - WHERE name <> "" + WHERE name <> "" AND (a.id_grupo IN ('.$id_groups.') OR gs.id_group IN ('.$id_groups.')) GROUP BY m.id_module_group ORDER BY total DESC LIMIT 10'; @@ -145,15 +159,29 @@ class MonitoringElements extends Element */ public function getAgentGroupsGraph():string { + global $config; + $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); + + if (in_array(0, $id_groups) === false) { + foreach ($id_groups as $key => $id_group) { + if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) { + unset($id_groups[$key]); + } + } + } + + $id_groups = implode(',', $id_groups); + $sql = 'SELECT gr.nombre, count(*) + IFNULL((SELECT count(*) AS total FROM tagente second_a LEFT JOIN tagent_secondary_group second_g ON second_g.id_agent = second_a.id_agente - WHERE a.id_grupo = second_g.id_group + WHERE a.id_grupo = second_g.id_group AND second_g.id_group IN ('.$id_groups.') GROUP BY second_g.id_group ), 0) AS total FROM tagente a LEFT JOIN tgrupo gr ON gr.id_grupo = a.id_grupo + WHERE a.id_grupo IN ('.$id_groups.') GROUP BY a.id_grupo ORDER BY total DESC LIMIT 10'; diff --git a/pandora_console/views/tacticalView/view.php b/pandora_console/views/tacticalView/view.php index 5561258777..17b73d360b 100644 --- a/pandora_console/views/tacticalView/view.php +++ b/pandora_console/views/tacticalView/view.php @@ -53,7 +53,7 @@
-
+
title; ?> @@ -91,6 +91,7 @@
+ checkAcl() === true) : ?>
@@ -141,6 +142,7 @@
+
@@ -238,7 +240,7 @@
title; ?>
-
+
@@ -254,7 +256,7 @@
checkAclUserList() === true) : ?>
-