diff --git a/pandora_console/include/class/Networkmap.class.php b/pandora_console/include/class/Networkmap.class.php
index 01ae6b0b09..28ab2cc018 100644
--- a/pandora_console/include/class/Networkmap.class.php
+++ b/pandora_console/include/class/Networkmap.class.php
@@ -115,6 +115,12 @@ class Networkmap extends Map {
}
}
+ $is_node_policy = false;
+ if ($this->subtype == MAP_SUBTYPE_POLICIES) {
+ if (strstr($chunks[1], "&id_policy=") !== false) {
+ $is_node_policy = true;
+ }
+ }
$id_agent = null;
@@ -126,7 +132,17 @@ class Networkmap extends Map {
$color = DEFAULT_NODE_COLOR;
$image = DEFAULT_NODE_IMAGE;
- if ($is_node_group) {
+ if ($is_node_policy) {
+ preg_match("/
(.*)<\/TD><\/TR><\/TABLE>>/", $chunks[0], $matches);
$title = $matches[1];
preg_match("/id_group=([0-9]*)/", $chunks[1], $matches);
@@ -302,10 +318,17 @@ class Networkmap extends Map {
switch ($this->subtype) {
case MAP_SUBTYPE_GROUPS:
+ $return['show_policies'] = false;
$return['show_groups'] = true;
$return['show_agents'] = $this->filter['show_agents'];
break;
+ case MAP_SUBTYPE_POLICIES:
+ $return['show_policies'] = true;
+ $return['show_groups'] = false;
+ $return['show_agents'] = $this->filter['show_agents'];
+ break;
default:
+ $return['show_policies'] = false;
$return['show_groups'] = false;
$return['show_agents'] = true;
break;
@@ -353,7 +376,8 @@ class Networkmap extends Map {
$parameters['module_group'],
$parameters['show_modulegroup'],
$parameters['show_groups'],
- $parameters['show_agents']);
+ $parameters['show_agents'],
+ $parameters['show_policies']);
$filename_dot = sys_get_temp_dir() . "/networkmap" . uniqid() . ".dot";
diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index 7086d08fe2..199733de16 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -506,7 +506,8 @@ define("ITEM_TYPE_MODULE_NETWORKMAP", 1);
define("ITEM_TYPE_EDGE_NETWORKMAP", 2);
define("ITEM_TYPE_FICTIONAL_NODE", 3);
define("ITEM_TYPE_MODULEGROUP_NETWORKMAP", 4);
-define("ITEM_TYPE_GROUP_NETWORKMAP", 5);
+define("ITEM_TYPE_GROUP_NETWORKMAP", 5);
+define("ITEM_TYPE_POLICY_NETWORKMAP", 6);
/* Another constants new networkmap */
define("DEFAULT_NODE_WIDTH", 30);
diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php
index 87d8371db5..4160efcbbd 100644
--- a/pandora_console/include/functions_networkmap.php
+++ b/pandora_console/include/functions_networkmap.php
@@ -234,7 +234,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$size_canvas = null, $old_mode = false, $id_tag = 0,
$show_all_modules = false, $only_modules_alerts = false,
$filter_module_group = 0, $show_modulegroup = false,
- $show_groups = false, $show_agents = true) {
+ $show_groups = false, $show_agents = true, $show_policies = false) {
global $config;
@@ -371,6 +371,18 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
}
}
+ // Get policy data
+ if ($show_policies) {
+
+ $policies =
+ enterprise_hook("networkmap_enterprise_get_policies",
+ array($group));
+
+ $agents = enterprise_hook(
+ "networkmap_enterprise_filter_agents_policies",
+ array($policies, $agents));
+ }
+
// Get groups data
if ($show_groups) {
@@ -412,8 +424,25 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$nodes = array ();
$node_count = 0;
+ // Parse policies
+ if ($show_policies) {
+ $nodes_policies = array();
+ foreach ($policies as $policy) {
+ $node_count ++;
+ $policy['type'] = 'policy';
+ $policy['id_node'] = $node_count;
+
+ $orphans[$node_count] = 1;
+
+ $nodes[$node_count] = $policy;
+
+ // Add node
+ $nodes_policies[$policy['id']] = $policy;
+ }
+ }
+
+ // Parse groups
if ($show_groups) {
- // Parse groups
$nodes_groups = array();
foreach ($groups as $group2) {
$node_count ++;
@@ -470,6 +499,13 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$parents[$node_count] = $agent['parent'] = $nodes_groups[$agent['id_grupo']]['id_node'];
}
+ if ($show_policies) {
+ $id_policy = db_get_value(
+ 'id_policy',
+ 'tpolicy_agents', 'id_agent', $agent['id_agent']);
+ $parents[$node_count] = $agent['parent'] = $nodes_policies[$id_policy]['id_node'];
+ }
+
$node_ref[$agent['id_agente']] = $node_count;
$agent['id_node'] = $node_count;
@@ -749,6 +785,12 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
}
switch ($node['type']) {
+ case 'policy':
+ if (enterprise_installed()) {
+ enterprise_include_once("include/functions_policies.php");
+ $graph .= policies_create_node($node, $simple, $font_size)."\n\t\t";
+ }
+ break;
case 'group':
$graph .= networkmap_create_group_node ($node , $simple, $font_size, $metaconsole = false, null, $strict_user) .
"\n\t\t";
|