From b245b3b4a8946652d68e026616bfe029d091f761 Mon Sep 17 00:00:00 2001 From: Junichi Satoh Date: Fri, 20 Dec 2019 11:25:01 +0900 Subject: [PATCH 1/5] Added support for MySQL 8.0. --- pandora_console/include/functions_servers.php | 6 ++++-- pandora_console/install.php | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 4049df62c9..a3649994fc 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -919,9 +919,10 @@ function servers_get_info($id_server=-1) // Remote servers LAG Calculation (server_type != 0). if ($server['server_type'] != 0) { + // MySQL 8.0 has function lag(). So, lag must be enclosed in quotations. $result = db_get_row_sql( 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, - AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag + AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag" FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 @@ -935,9 +936,10 @@ function servers_get_info($id_server=-1) ); } else { // Local/Dataserver server LAG calculation. + // MySQL 8.0 has function lag(). So, lag must be enclosed in quotations. $result = db_get_row_sql( 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, - AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag + AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag" FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 diff --git a/pandora_console/install.php b/pandora_console/install.php index 01dd3aba64..c891e8f385 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -965,9 +965,12 @@ function install_step4() $step5 = mysqli_query( $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" + "CREATE USER pandora@$host IDENTIFIED BY '".$random_password."'" ); + $step5 |= mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host" + ); mysqli_query($connection, 'FLUSH PRIVILEGES'); check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); From 95600412e1246d431fba1647a6112e86237c9bb7 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Tue, 14 Jan 2020 13:14:09 +0100 Subject: [PATCH 2/5] Minor visual changes in alert list --- .../godmode/alerts/alert_list.list.php | 340 +++++++++--------- pandora_console/include/styles/pandora.css | 5 +- 2 files changed, 170 insertions(+), 175 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index f830f47dbd..e567f20716 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -412,65 +412,56 @@ $url_up_template = $url.'&sort_field=template&sort=up&pure='.$pure; $url_down_template = $url.'&sort_field=template&sort=down&pure='.$pure; -$table = new stdClass(); +$table_alert_list = new stdClass(); if (is_metaconsole()) { - $table->class = 'alert_list databox'; + $table_alert_list->class = 'alert_list databox'; } else { - $table->class = 'info_table'; + $table_alert_list->class = 'info_table'; } -$table->width = '100%'; -$table->cellpadding = 0; -$table->cellspacing = 0; -$table->size = []; +$table_alert_list->width = '100%'; +$table_alert_list->cellpadding = 0; +$table_alert_list->cellspacing = 0; +$table_alert_list->size = []; -$table->align = []; -$table->align[0] = 'left'; -$table->align[1] = 'left'; -$table->align[2] = 'left'; -$table->align[3] = 'left'; -$table->align[4] = 'left'; +$table_alert_list->align = []; +$table_alert_list->align[0] = 'left'; +$table_alert_list->align[1] = 'left'; +$table_alert_list->align[2] = 'left'; +$table_alert_list->align[3] = 'left'; +$table_alert_list->align[4] = 'left'; -$table->head = []; +$table_alert_list->head = []; if (! $id_agente) { - $table->style = []; - $table->style[0] = 'font-weight: bold;'; - $table->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown); - $table->headstyle[0] = 'width: 100%; min-width: 12em;'; - $table->headstyle[1] = 'min-width: 15em;'; - $table->headstyle[2] = 'min-width: 20em;'; - $table->headstyle[3] = 'min-width: 1em;'; - $table->headstyle[4] = 'min-width: 15em;'; - - /* - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $table->size[4] = '8%'; - }*/ + $table_alert_list->style = []; + $table_alert_list->style[0] = 'font-weight: bold;'; + $table_alert_list->head[0] = __('Agent').ui_get_sorting_arrows($url_up_agente, $url_down_agente, $selectAgentUp, $selectAgentDown); } else { - $table->head[0] = __('Module').ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); - $table->headstyle[0] = 'width: 100%; min-width: 15em;'; - $table->headstyle[1] = 'min-width: 15em;'; - $table->headstyle[2] = 'min-width: 20em;'; - $table->headstyle[3] = 'min-width: 1em;'; - $table->headstyle[4] = 'min-width: 15em;'; + $table_alert_list->head[0] = __('Module').ui_get_sorting_arrows($url_up_module, $url_down_module, $selectModuleUp, $selectModuleDown); } -$table->head[1] = __('Template').ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); -$table->head[2] = __('Actions'); -$table->head[3] = __('Status'); -$table->head[4] = "".__('Op.').''; +$table_alert_list->head[1] = __('Status'); +$table_alert_list->head[2] = __('Template').ui_get_sorting_arrows($url_up_template, $url_down_template, $selectTemplateUp, $selectTemplateDown); +$table_alert_list->head[3] = __('Actions'); +$table_alert_list->head[4] = "".__('Op.').''; -$table->valign[0] = 'middle'; -$table->valign[1] = 'middle'; -$table->valign[2] = 'middle'; -$table->valign[3] = 'middle'; -$table->valign[4] = 'middle'; +$table_alert_list->headstyle[0] = 'min-width: 200px; width:30%;'; +$table_alert_list->headstyle[1] = 'min-width: 50px; width:8%'; +$table_alert_list->headstyle[2] = 'min-width: 150px; width:22%;'; +$table_alert_list->headstyle[3] = 'min-width: 200px; width:30%;'; +$table_alert_list->headstyle[4] = 'min-width: 150px; width:10%;'; -$table->style[4] = 'min-width:80px'; +$table_alert_list->valign[0] = 'middle'; +$table_alert_list->valign[1] = 'middle'; +$table_alert_list->valign[2] = 'middle'; +$table_alert_list->valign[3] = 'middle'; +$table_alert_list->valign[4] = 'middle'; -$table->data = []; +$table_alert_list->cellstyle = []; + +$table_alert_list->data = []; $url .= $sort_params; @@ -479,14 +470,14 @@ $iterator = 0; foreach ($simple_alerts as $alert) { if ($alert['disabled']) { - $table->rowstyle[$iterator] = 'font-style: italic; color: #aaaaaa;'; - $table->style[$iterator][1] = 'font-style: italic; color: #aaaaaa;'; + $table_alert_list->rowstyle[$iterator] = 'font-style: italic; color: #aaaaaa;'; + $table_alert_list->style[$iterator][2] = 'font-style: italic; color: #aaaaaa;'; } if ($rowPair) { - $table->rowclass[$iterator] = 'rowPair'; + $table_alert_list->rowclass[$iterator] = 'rowPair'; } else { - $table->rowclass[$iterator] = 'rowOdd'; + $table_alert_list->rowclass[$iterator] = 'rowOdd'; } $rowPair = !$rowPair; @@ -523,38 +514,53 @@ foreach ($simple_alerts as $alert) { $all_groups = agents_get_all_groups_agent($id_agente); } - $module_name = modules_get_agentmodule_name($alert['id_agent_module']); - $data[0] .= ui_print_truncate_text($module_name, 'module_medium', false, true, true, '[…]', 'display:block;font-size: 7.2pt').'
'; + $status = STATUS_ALERT_NOT_FIRED; + $title = ''; + if ($alert['times_fired'] > 0) { + $status = STATUS_ALERT_FIRED; + $title = __('Alert fired').' '.$alert['internal_counter'].' '.__('time(s)'); + } else if ($alert['disabled'] > 0) { + $status = STATUS_ALERT_DISABLED; + $title = __('Alert disabled'); + } else { + $status = STATUS_ALERT_NOT_FIRED; + $title = __('Alert not fired'); + } + + $module_name = modules_get_agentmodule_name($alert['id_agent_module']); + $data[0] .= ui_print_truncate_text($module_name, 'module_medium', false, true, true, '[…]', 'display:block;font-weight:normal;').'
'; + + $data[1] = ui_print_status_image($status, $title, true); $template_group = db_get_value('id_group', 'talert_templates', 'id', $alert['id_alert_template']); // The access to the template manage page is necessary have LW permissions on template group if (check_acl($config['id_user'], $template_group, 'LW')) { - $data[1] .= ""; + $data[2] .= ""; } - $data[1] .= ui_print_truncate_text( + $data[2] .= ui_print_truncate_text( alerts_get_alert_template_name($alert['id_alert_template']), 'module_medium', false, true, true, '[…]', - 'font-size: 7.1pt' + '' ); - $data[1] .= ' '; - $data[1] .= html_print_image('images/zoom.png', true, ['id' => 'template-details-'.$alert['id_alert_template'], 'class' => 'img_help']); - $data[1] .= ' '; + $data[2] .= html_print_image('images/zoom.png', true, ['id' => 'template-details-'.$alert['id_alert_template'], 'class' => 'img_help action_button_img']); + $data[2] .= ' '; if (check_acl($config['id_user'], $template_group, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) { - $data[1] .= ''; + $data[2] .= ''; } $actions = alerts_get_alert_agent_module_actions($alert['id']); - $data[2] = ""; + $data[3] = "
"; // Get and show default actions for this alert $default_action = db_get_sql( 'SELECT id_alert_action @@ -562,69 +568,74 @@ foreach ($simple_alerts as $alert) { WHERE id = '.$alert['id_alert_template'] ); if ($default_action != '') { - $data[2] .= "'; - $data[2] .= ''; - $data[2] .= ''; + $data[3] .= "'; + $data[3] .= ''; } foreach ($actions as $action_id => $action) { - $data[2] .= ''; - $data[2] .= ''; + $data[3] .= ''; + + $data[3] .= ''; - $data[2] .= ''; + $data[3] .= ''; + $data[3] .= ''; } - $data[2] .= ''; - $data[2] .= '
  • "; - $data[2] .= db_get_sql("SELECT name FROM talert_actions WHERE id = $default_action").' ('.__('Default').')'; - $data[2] .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true); - $data[2] .= '
  • "; + $data[3] .= db_get_sql("SELECT name FROM talert_actions WHERE id = $default_action").' ('.__('Default').')'; + $data[3] .= '
'; - $data[2] .= '
    '; - $data[2] .= '
  • '; + $data[3] .= '
'; + $data[3] .= '
    '; + $data[3] .= '
  • '; if ($alert['disabled']) { - $data[2] .= ''; + $data[3] .= ''; } else { - $data[2] .= ''; + $data[3] .= ''; } - $data[2] .= ui_print_truncate_text($action['name'], (GENERIC_SIZE_TEXT + 20), false); - $data[2] .= ' ('; + $data[3] .= ui_print_truncate_text($action['name'], (GENERIC_SIZE_TEXT + 20), false); + $data[3] .= ' ('; if ($action['fires_min'] == $action['fires_max']) { if ($action['fires_min'] == 0) { - $data[2] .= __('Always'); + $data[3] .= __('Always'); } else { - $data[2] .= __('On').' '.$action['fires_min']; + $data[3] .= __('On').' '.$action['fires_min']; } } else if ($action['fires_min'] < $action['fires_max']) { if ($action['fires_min'] == 0) { - $data[2] .= __('Until').' '.$action['fires_max']; + $data[3] .= __('Until').' '.$action['fires_max']; } else { - $data[2] .= __('From').' '.$action['fires_min'].' '.__('to').' '.$action['fires_max']; + $data[3] .= __('From').' '.$action['fires_min'].' '.__('to').' '.$action['fires_max']; } } else { - $data[2] .= __('From').' '.$action['fires_min']; + $data[3] .= __('From').' '.$action['fires_min']; } if ($action['module_action_threshold'] != 0) { - $data[2] .= ' '.__('Threshold').' '.human_time_description_alerts($action['module_action_threshold'], true, 'tiny'); + $data[3] .= ' '.__('Threshold').' '.human_time_description_alerts($action['module_action_threshold'], true, 'tiny'); } - $data[2] .= ')'; - $data[2] .= ''; - $data[2] .= '
  • '; - $data[2] .= '
'; + $data[3] .= ')'; + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ''; - // Is possible manage actions if have LW permissions in the agent group of the alert module + $data[3] .= '
'; + $data[3] .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true); + // Is possible manage actions if have LW permissions in the agent group of the alert module if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW')) { // ~ $data[2] .= ''; - $data[2] .= html_print_input_image( + $data[3] .= html_print_input_hidden('delete_action', 1, true); + $data[3] .= html_print_input_hidden('id_alert', $alert['id'], true); + $data[3] .= html_print_input_hidden('id_action', $action_id, true); + $data[3] .= ''; + $data[3] .= html_print_input_image( 'update_action', 'images/config.png', 1, @@ -632,19 +643,20 @@ foreach ($simple_alerts as $alert) { true, [ 'title' => __('Update action'), + 'class' => 'action_button_img', 'onclick' => 'show_display_update_action(\''.$action['id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action_id.'\',\''.$alert['id_agent_module'].'\')', ] ); - $data[2] .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); + $data[3] .= html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); } - $data[2] .= '
'; + $data[3] .= ''; + $data[3] .= ''; // Is possible manage actions if have LW permissions in the agent group of the alert module if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) { $own_info = get_user_info($config['id_user']); @@ -660,45 +672,45 @@ foreach ($simple_alerts as $alert) { $actions = alerts_get_alert_actions_filter(true, 'id_group IN ('.$filter_groups.')'); } - $data[2] .= ''; + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= ''; + $data[3] .= html_print_submit_button(__('Add'), 'addbutton', false, ['class' => 'sub next', 'style' => 'float:right'], true); + $data[3] .= ''; + $data[3] .= ''; } - $status = STATUS_ALERT_NOT_FIRED; - $title = ''; - - if ($alert['times_fired'] > 0) { - $status = STATUS_ALERT_FIRED; - $title = __('Alert fired').' '.$alert['internal_counter'].' '.__('time(s)'); - } else if ($alert['disabled'] > 0) { - $status = STATUS_ALERT_DISABLED; - $title = __('Alert disabled'); - } else { - $status = STATUS_ALERT_NOT_FIRED; - $title = __('Alert not fired'); - } - - $data[3] = ui_print_status_image($status, $title, true); - - $table->cellclass[] = [ - 3 => 'action_buttons', + $table_alert_list->cellclass[] = [ + 1 => 'action_buttons', 4 => 'action_buttons', ]; $data[4] = '
'; @@ -790,11 +786,11 @@ foreach ($simple_alerts as $alert) { if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { $policyInfo = policies_is_alert_in_policy2($alert['id'], false); if ($policyInfo === false) { - $data[3] .= ''; + $data[1] .= ''; } else { $img = 'images/policies.png'; - $data[3] .= '  '.html_print_image($img, true, ['title' => $policyInfo['name']]).''; + $data[1] .= '  '.html_print_image($img, true, ['title' => $policyInfo['name']]).''; } } } @@ -840,11 +836,11 @@ foreach ($simple_alerts as $alert) { $data[4] .= '
'; } - array_push($table->data, $data); + array_push($table_alert_list->data, $data); } if (isset($data)) { - html_print_table($table); + html_print_table($table_alert_list); if ($id_agente) { ui_pagination($total, 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.$form_params.$sort_params, 0, 0, false, 'offset', true, 'pagination-bottom'); } else { @@ -864,7 +860,7 @@ if (isset($dont_display_alert_create_bttn)) { } if ($display_create && (check_acl($config['id_user'], 0, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) && !$id_cluster) { - echo '
'; + echo '
'; echo '
'; html_print_submit_button(__('Create'), 'crtbtn', false, 'class="sub next"'); echo '
'; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index a003dd0d7a..6976c652d9 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4985,11 +4985,10 @@ input:checked + .p-slider:before { .action_buttons input[type="image"], .action_button_img { border-radius: 4px; - border: 1px solid #dcdcdc; - padding: 1px; + border: 1px solid #dcdcdc !important; + padding: 1px !important; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); max-width: 21px; - background-color: transparent; /*BORRAR*/ } /* This class is for only one icon to be a button type. */ From 2926ead13b50df8cfc8c207473ef9b1c8b54d276 Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 15 Jan 2020 12:14:37 +0100 Subject: [PATCH 3/5] Fixed group change on networkmap.ACL and source group working separated --- pandora_console/extras/mr/35.sql | 3 +- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 + .../include/functions_networkmap.php | 14 +++ .../agentes/pandora_networkmap.editor.php | 90 +++++++++++++++++-- .../operation/agentes/pandora_networkmap.php | 63 ++++++++----- .../agentes/pandora_networkmap.view.php | 10 +-- pandora_console/pandoradb.sql | 1 + 7 files changed, 148 insertions(+), 35 deletions(-) diff --git a/pandora_console/extras/mr/35.sql b/pandora_console/extras/mr/35.sql index 86236df36f..3a002f44f8 100644 --- a/pandora_console/extras/mr/35.sql +++ b/pandora_console/extras/mr/35.sql @@ -1,5 +1,6 @@ START TRANSACTION; +ALTER TABLE `tmap` ADD COLUMN `id_group_map` INT(10) UNSIGNED NOT NULL default 0; ALTER TABLE `tevent_filter` MODIFY `severity` TEXT NOT NULL; -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 0c95628752..bbc07ad08c 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1195,6 +1195,8 @@ CREATE TABLE IF NOT EXISTS `tmap` ( `generation_method` INTEGER UNSIGNED NOT NULL default 0, `generated` INTEGER UNSIGNED NOT NULL default 0, `filter` TEXT, + `id_group_map` INT(10) UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index dda25538ee..56172331c6 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1453,6 +1453,20 @@ function networkmap_delete_nodes($id_map) } +/** + * Delete relations given id_map + * + * @param integer $id_map + * @return integer result + */ +function networkmap_delete_relations($id_map) +{ + $result = db_process_sql_delete('trel_item', ['id_map' => $id_map]); + + return $result; +} + + function get_networkmaps($id) { $groups = array_keys(users_get_groups(null, 'IW')); diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 7f698d8653..d719df08cd 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -81,8 +81,8 @@ if ($edit_networkmap) { $id_group = $values['id_group']; // ACL for the network map. - $networkmap_write = check_acl($config['id_user'], $id_group, 'MW'); - $networkmap_manage = check_acl($config['id_user'], $id_group, 'MM'); + $networkmap_write = check_acl($config['id_user'], $id_group_map, 'MW'); + $networkmap_manage = check_acl($config['id_user'], $id_group_map, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -95,6 +95,9 @@ if ($edit_networkmap) { $name = io_safe_output($values['name']); + // Id group of the map itself, not data source. + $id_group_map = $values['id_group_map']; + $description = $values['description']; $filter = json_decode($values['filter'], true); @@ -267,8 +270,8 @@ if ($not_found) { $config['id_user'], 'AR', true, - 'id_group', - $id_group, + 'id_group_map', + $id_group_map, '', '', '', @@ -329,6 +332,28 @@ if ($not_found) { $table->data['source_data_ip_mask'][0] = __('Source from CIDR IP mask'); $table->data['source_data_ip_mask'][1] = html_print_input_text('ip_mask', $ip_mask, '', 20, 255, true, $disabled_source); + $table->data['source_data_group'][0] = __('Source group'); + $table->data['source_data_group'][1] = html_print_select_groups( + $config['id_user'], + 'AR', + true, + 'id_group', + $id_group, + '', + '', + '', + true + ); + $table->data['source_data_group'][1] .= html_print_image( + 'images/error.png', + true, + [ + 'id' => 'group_change_warning', + 'title' => __('Source id group changed. All elements in networkmap will be lost.'), + 'style' => 'display : none', + ] + ); + $table->data['source_data_dont_show_subgroups'][0] = __('Don\'t show subgroups:'); $table->data['source_data_dont_show_subgroups'][1] = html_print_checkbox( 'dont_show_subgroups', @@ -379,7 +404,7 @@ if ($not_found) { $table->data['kval'][0] = __('Default ideal node separation'); $table->data['kval'][1] = html_print_input_text('kval', $kval, '', 5, 10, true, $disabled_source, false, $itemClass).ui_print_help_tip(__('Only fdp. Default ideal node separation in the layout. By default 0.3'), true); - echo '
'; + echo ''; html_print_table($table); @@ -420,8 +445,11 @@ $(document).ready(function() { .css('display', 'none'); $("#form_editor-source_data_dont_show_subgroups") .css('display', 'none'); + $("#form_editor-source_data_group") + .css('display', 'none'); $("#form_editor-source_data_recon_task") .css('display', ''); + } else if (source == 'ip_mask') { $("#form_editor-source_data_ip_mask") @@ -430,6 +458,8 @@ $(document).ready(function() { .css('display', 'none'); $("#form_editor-source_data_dont_show_subgroups") .css('display', 'none'); + $("#form_editor-source_data_group") + .css('display', 'none'); } else if (source == 'group') { $("#form_editor-source_data_ip_mask") @@ -438,6 +468,8 @@ $(document).ready(function() { .css('display', 'none'); $("#form_editor-source_data_dont_show_subgroups") .css('display', ''); + $("#form_editor-source_data_group") + .css('display', ''); } }); @@ -508,5 +540,53 @@ $(document).ready(function() { $("input[name='source']").trigger("change"); $("#method").trigger("change"); + + + // Control if id_group has changed. + var id_group_old = $("#id_group").val(); + var id_group_changed = false; + + $("#id_group").on('change',{id_group_old: id_group_old}, function () { + + var id_group_new = $("#id_group").val(); + if((id_group_old != id_group_new) && (update_networkmap == 1 )) { + id_group_changed = true; + $("#group_change_warning").show(); + + } else { + id_group_changed = false; + $("#group_change_warning").hide(); + } + }); + + var update_networkmap = 0; + // Show advice if id_group has changed. + update_networkmap = $("input[name='update_networkmap']").val(); + + $( "#submit-crt" ).click(function( event ) { + + if(update_networkmap == 1 && id_group_changed === true) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onDeny: function() { + // Continue execution. + return false; + }, + onAccept: function () { + // Submit form + $("#networkmap_options_form").submit(); + } + }) + event.preventDefault(); + } + }); + + +}); + + diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 2aa1404e30..97ebcf82c3 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -12,10 +12,10 @@ // Load global variables global $config; -// Check user credentials +// Check user credentials. check_login(); -// General ACL for the network maps +// General ACL for the network maps. $networkmaps_read = check_acl($config['id_user'], 0, 'MR'); $networkmaps_write = check_acl($config['id_user'], 0, 'MW'); $networkmaps_manage = check_acl($config['id_user'], 0, 'MM'); @@ -53,11 +53,12 @@ if (enterprise_installed()) { if ($save_empty_networkmap) { $id_group = (int) get_parameter('id_group', 0); + $id_group_map = (int) get_paramater('id_group_map', 0); - // ACL for the network map + // ACL for the network map. // $networkmap_read = check_acl ($config['id_user'], $id_group, "MR"); - $networkmap_write = check_acl($config['id_user'], $id_group, 'MW'); - $networkmap_manage = check_acl($config['id_user'], $id_group, 'MM'); + $networkmap_write = check_acl($config['id_user'], $id_group_map, 'MW'); + $networkmap_manage = check_acl($config['id_user'], $id_group_map, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -93,6 +94,7 @@ if (enterprise_installed()) { $values['description'] = $description; $values['source'] = 0; $values['source_data'] = $id_group; + $values['id_group_map'] = $id_group_map; if (!$networkmap_write && !$networkmap_manage) { @@ -139,10 +141,12 @@ if (enterprise_installed()) { } } else if ($update_empty_networkmap) { $id_group = (int) get_parameter('id_group', 0); + $id_group_map = (int) get_parameter('id_group_map', 0); + // ACL for the new network map - $networkmap_write_new = check_acl($config['id_user'], $id_group, 'MW'); - $networkmap_manage_new = check_acl($config['id_user'], $id_group, 'MM'); + $networkmap_write_new = check_acl($config['id_user'], $id_group_map, 'MW'); + $networkmap_manage_new = check_acl($config['id_user'], $id_group_map, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -221,11 +225,13 @@ if ($new_networkmap || $save_networkmap) { if ($save_networkmap) { $id_group = (int) get_parameter('id_group', 0); + $id_group_map = (int) get_parameter('id_group_map', 0); + // ACL for the network map // $networkmap_read = check_acl ($config['id_user'], $id_group, "MR"); - $networkmap_write = check_acl($config['id_user'], $id_group, 'MW'); - $networkmap_manage = check_acl($config['id_user'], $id_group, 'MM'); + $networkmap_write = check_acl($config['id_user'], $id_group_map, 'MW'); + $networkmap_manage = check_acl($config['id_user'], $id_group_map, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -282,6 +288,7 @@ if ($new_networkmap || $save_networkmap) { $values['height'] = $height; $values['id_user'] = $config['id_user']; $values['description'] = $description; + $values['id_group_map'] = $id_group_map; switch ($method) { case 'twopi': @@ -401,8 +408,10 @@ else if ($update_networkmap || $copy_networkmap || $delete) { return; } - $id_group_old = db_get_value('id_group', 'tmap', 'id', $id); - if ($id_group_old === false) { + // ACL for the network map. + $id_group_map_old = db_get_value('id_group_map', 'tmap', 'id', $id); + + if ($id_group_map_old === false) { db_pandora_audit( 'ACL Violation', 'Trying to accessnode graph builder' @@ -411,9 +420,8 @@ else if ($update_networkmap || $copy_networkmap || $delete) { return; } - // ACL for the network map - $networkmap_write = check_acl($config['id_user'], $id_group_old, 'MW'); - $networkmap_manage = check_acl($config['id_user'], $id_group_old, 'MM'); + $networkmap_write = check_acl($config['id_user'], $id_group_map_old, 'MW'); + $networkmap_manage = check_acl($config['id_user'], $id_group_map_old, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -426,10 +434,14 @@ else if ($update_networkmap || $copy_networkmap || $delete) { if ($update_networkmap) { $id_group = (int) get_parameter('id_group', 0); + // Get id of old group source to check changes. + $id_group_old = db_get_value('id_group', 'tmap', 'id', $id); + // ACL for the new network map - $networkmap_write_new = check_acl($config['id_user'], $id_group, 'MW'); - $networkmap_manage_new = check_acl($config['id_user'], $id_group, 'MM'); + $id_group_map = (int) get_parameter('id_group_map', 0); + $networkmap_write_new = check_acl($config['id_user'], $id_group_map, 'MW'); + $networkmap_manage_new = check_acl($config['id_user'], $id_group_map, 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -456,6 +468,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { $values = []; $values['name'] = $name; $values['id_group'] = $id_group; + $values['id_group_map'] = $id_group_map; $description = get_parameter('description', ''); $values['description'] = $description; @@ -493,6 +506,8 @@ else if ($update_networkmap || $copy_networkmap || $delete) { // If change the group, the map must be regenerated if ($id_group != $id_group_old) { networkmap_delete_nodes($id); + // Delete relations. + networkmap_delete_relations($id); } $networkmap_write = $networkmap_write_new; @@ -701,9 +716,9 @@ switch ($tab) { $network_maps = db_get_all_rows_filter( 'tmap', [ - 'id_group' => $id_groups, - 'limit' => $limit, - 'offset' => $offset, + 'id_group_map' => $id_groups, + 'limit' => $limit, + 'offset' => $offset, ] ); @@ -712,9 +727,9 @@ switch ($tab) { foreach ($network_maps as $network_map) { // ACL for the network map - $networkmap_read = check_acl($config['id_user'], $network_map['id_group'], 'MR'); - $networkmap_write = check_acl($config['id_user'], $network_map['id_group'], 'MW'); - $networkmap_manage = check_acl($config['id_user'], $network_map['id_group'], 'MM'); + $networkmap_read = check_acl($config['id_user'], $network_map['id_group_map'], 'MR'); + $networkmap_write = check_acl($config['id_user'], $network_map['id_group_map'], 'MW'); + $networkmap_manage = check_acl($config['id_user'], $network_map['id_group_map'], 'MM'); if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -722,7 +737,7 @@ switch ($tab) { 'Trying to access networkmap enterprise' ); include 'general/noaccess.php'; - return; + continue; } $data = []; @@ -768,7 +783,7 @@ switch ($tab) { } } - $data['groups'] = ui_print_group_icon($network_map['id_group'], true); + $data['groups'] = ui_print_group_icon($network_map['id_group_map'], true); if ($networkmap_write || $networkmap_manage) { $table->cellclass[] = [ diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 2ee34806d9..3c4565fe9a 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -576,8 +576,8 @@ if (is_ajax()) { $filter = json_encode($array_filter); // ACL for the network map. - $networkmap_write = check_acl($config['id_user'], $networkmap['id_group'], 'MW'); - $networkmap_manage = check_acl($config['id_user'], $networkmap['id_group'], 'MM'); + $networkmap_write = check_acl($config['id_user'], $networkmap['id_group_map'], 'MW'); + $networkmap_manage = check_acl($config['id_user'], $networkmap['id_group_map'], 'MM'); if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( @@ -800,9 +800,9 @@ if ($networkmap === false) { return; } else { // ACL for the network map. - $networkmap_read = check_acl($config['id_user'], $networkmap['id_group'], 'MR'); - $networkmap_write = check_acl($config['id_user'], $networkmap['id_group'], 'MW'); - $networkmap_manage = check_acl($config['id_user'], $networkmap['id_group'], 'MM'); + $networkmap_read = check_acl($config['id_user'], $networkmap['id_group_map'], 'MR'); + $networkmap_write = check_acl($config['id_user'], $networkmap['id_group_map'], 'MW'); + $networkmap_manage = check_acl($config['id_user'], $networkmap['id_group_map'], 'MM'); if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) { db_pandora_audit( diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a42a9592c3..134eceba32 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2188,6 +2188,7 @@ CREATE TABLE IF NOT EXISTS `tmap` ( `generation_method` INTEGER UNSIGNED NOT NULL default 0, `generated` INTEGER UNSIGNED NOT NULL default 0, `filter` TEXT, + `id_group_map` INT(10) UNSIGNED NOT NULL default 0, PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; From 28b585196b08339137f7a29d58aaf1fc353ec90a Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Wed, 15 Jan 2020 14:11:36 +0100 Subject: [PATCH 4/5] Ent 5099 dobles interfaces en mapas de red no se visualizan --- pandora_console/include/class/NetworkMap.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index b28b43f502..43fb9138c7 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -1340,6 +1340,10 @@ class NetworkMap if ($rel['parent_type'] == NODE_MODULE && $rel['child_type'] == NODE_MODULE ) { + // Keep std references. + $ref_id_parent = $id_parent; + $ref_id_child = $id_child; + // Module information available. $id_parent = $rel['id_parent_source_data']; $id_child = $rel['id_child_source_data']; @@ -1374,6 +1378,12 @@ class NetworkMap 'index' => $index, 'priority' => $priority, ]; + + // Keep node reference mapping - low precedence relationship. + $rel_map[$ref_id_parent.'_'.$ref_id_child] = [ + 'index' => $index, + 'priority' => $priority, + ]; } } else if ($rel['parent_type'] == NODE_AGENT && $rel['child_type'] == NODE_AGENT From 40f03e56824241c08bab1cbaef2ba7f737325ef5 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 16 Jan 2020 00:01:08 +0100 Subject: [PATCH 5/5] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a54002818d..b201f03df1 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.742-200115 +Version: 7.0NG.742-200116 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index ec00c3d207..667a916eae 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.742-200115" +pandora_version="7.0NG.742-200116" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 366e7ad559..901a25684c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.742'; -use constant AGENT_BUILD => '200115'; +use constant AGENT_BUILD => '200116'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index fd41ec1f90..a5ba25309f 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.742 -%define release 200115 +%define release 200116 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 920028aef8..9391a8fe18 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.742 -%define release 200115 +%define release 200116 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index df8455a431..33b85b6879 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.742" -PI_BUILD="200115" +PI_BUILD="200116" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 214118aaff..462a905312 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200115} +{200116} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 6889d27878..1b90cd4356 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.742(Build 200115)") +#define PANDORA_VERSION ("7.0NG.742(Build 200116)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index a206edfda6..069494b28e 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.742(Build 200115))" + VALUE "ProductVersion", "(7.0NG.742(Build 200116))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 543a1c91f4..a21b22de5f 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.742-200115 +Version: 7.0NG.742-200116 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 0048357d77..dbe006c507 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.742-200115" +pandora_version="7.0NG.742-200116" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 9585142299..391e652262 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200115'; +$build_version = 'PC200116'; $pandora_version = 'v7.0NG.742'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 2f6a94fb1f..d42fc41a5f 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 9bf45f239b..52d2982409 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.742 -%define release 200115 +%define release 200116 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 9d3f896141..b0c0b3e120 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.742 -%define release 200115 +%define release 200116 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 528e0568d4..cd6e05391a 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.742" -PI_BUILD="200115" +PI_BUILD="200116" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 8864f9ddac..2a7b857f60 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.742 PS200115"; +my $version = "7.0NG.742 PS200116"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 81eabe2acc..d97ee4766c 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.742 PS200115"; +my $version = "7.0NG.742 PS200116"; # save program name for logging my $progname = basename($0);