From 10a5cd496f0f5059b6eb72fff5408446cc0f21e5 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 14 Jul 2023 13:53:52 +0200 Subject: [PATCH 001/414] #11714 Fix external link --- pandora_console/godmode/users/configure_user.php | 12 ++++++++---- pandora_console/godmode/users/user_management.php | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 7227aaa09e..56f15ee0a8 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -349,8 +349,10 @@ if ($create_user === true) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; @@ -643,8 +645,10 @@ if ($update_user) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section'); + } else if ($values['section'] === HOME_SCREEN_OTHER) { + $values['data_section'] = get_parameter('data_section_other'); + } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section_external'); } // $values['section'] = $homeScreenValues[$values['section']]; diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 241177f2a2..ec967c293d 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -52,8 +52,8 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select($dashboards // Home screen. Visual consoles. $customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); // Home screen. External link and Other. -$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true); -$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true); $customHomeScreenDataField = ''; foreach ($customHomeScreenAddition as $key => $customField) { From 6c41ccc0f3a8847514b59cc414bfa15824932bd2 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 17 Jul 2023 08:59:19 +0200 Subject: [PATCH 002/414] #11699 fix css filter --- pandora_console/include/styles/pandora_black.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index 652d777f72..999810c367 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -1464,6 +1464,10 @@ ul.datatable_filter:has(li > div.action-buttons) { background-color: #222 !important; } +ul.datatable_filter { + background-color: #222 !important; +} + span.ui-dialog-title { color: #fff !important; } From 57eec94c42745492389490482520d0c093b725f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Fri, 28 Jul 2023 09:32:30 -0600 Subject: [PATCH 003/414] Add OS, server and interval. --- pandora_server/util/pandora_manage.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 71fd0db43e..2b0f20f244 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -4508,7 +4508,9 @@ sub cli_create_event() { # exist_check($id_agent,'agent',$agent_name); if($id_agent == -1){ if($force_create_agent == 1){ - pandora_create_agent ($conf, '', $agent_name, '', $id_group, '', '', 'Created by cli_create_event', '', $dbh); + my $target_os = pandora_get_os($dbh, 'other'); + my $target_server = $conf{'servername'}; + pandora_create_agent ($conf, $target_server, $agent_name, '', $id_group, '', $target_os, 'Created by cli_create_event', '300', $dbh); print_log "[INFO] Adding agent '$agent_name' \n\n"; $id_agent = get_agent_id($dbh,$agent_name); } From aead8d006e84f01f30607e32d7d4f7f5ea90631e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 29 Aug 2023 14:11:32 +0200 Subject: [PATCH 004/414] #11894 Fixed links does not update the page when creating or deleting links --- pandora_console/godmode/setup/links.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/setup/links.php b/pandora_console/godmode/setup/links.php index fc27454b48..20e61e95b0 100644 --- a/pandora_console/godmode/setup/links.php +++ b/pandora_console/godmode/setup/links.php @@ -54,8 +54,12 @@ if (isset($_POST['create'])) { if (! $result) { ui_print_error_message(__('There was a problem creating link')); } else { - ui_print_success_message(__('Successfully created')); $id_link = $result; + ui_print_result_message( + $id_link, + __('Successfully created'), + __('Could not be created') + ); } } @@ -111,8 +115,8 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { $link = ''; } - echo ''; echo ''; + echo '
'; if ($creation_mode == 1) { echo ""; } else { @@ -179,10 +183,10 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { ) ); - echo '
'; + echo ''; } else { - // Main list view for Links editor - $rows = db_get_all_rows_in_table('tlink', 'name'); + // Main list view for Links editor. + $rows = db_get_all_fields_in_table('tlink', '', '', 'name'); if ($rows === false) { $rows = []; } From a0b02670fb4028a5a6752463a5aceb4fa37b23ee Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:45:27 +0200 Subject: [PATCH 005/414] #11954 Fix pagination --- pandora_console/godmode/agentes/fields_manager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 25b06e2f5a..53b4995d20 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,6 +217,7 @@ foreach ($fields as $field) { array_push($table->data, $data); } +$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -231,6 +232,9 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - ['type' => 'form_action'] + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], ); echo ''; From eab6a00300d97a1ef5ab8da2097f14af712c90c4 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:49:59 +0200 Subject: [PATCH 006/414] #11945 Amend changes --- pandora_console/godmode/agentes/fields_manager.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 53b4995d20..25b06e2f5a 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,7 +217,6 @@ foreach ($fields as $field) { array_push($table->data, $data); } -$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -232,9 +231,6 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - [ - 'type' => 'form_action', - 'right_content' => $tablePagination, - ], + ['type' => 'form_action'] ); echo ''; From 9c470053aee6de01f0a740c26899887419a8ef40 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 10:58:39 +0200 Subject: [PATCH 007/414] #11954 Fix pagination --- pandora_console/godmode/agentes/fields_manager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 25b06e2f5a..53b4995d20 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -217,6 +217,7 @@ foreach ($fields as $field) { array_push($table->data, $data); } +$tablePagination = ''; if ($fields) { html_print_table($table); $tablePagination = ui_pagination($count_fields, false, $offset, 0, true, 'offset', false); @@ -231,6 +232,9 @@ html_print_action_buttons( [ 'icon' => 'next' ], true ), - ['type' => 'form_action'] + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], ); echo ''; From 9ae34fae404fa1bc7c324448cd67fc275cd92020 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 31 Aug 2023 12:35:32 +0200 Subject: [PATCH 008/414] #11954 Fix delete alerts action in bulk --- .../godmode/massive/massive_delete_action_alerts.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_action_alerts.php b/pandora_console/godmode/massive/massive_delete_action_alerts.php index cad37a3a29..0cd712e124 100644 --- a/pandora_console/godmode/massive/massive_delete_action_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_action_alerts.php @@ -111,7 +111,8 @@ if ($delete) { $alerts_agent_modules = []; foreach ($agent_alerts['simple'] as $agent_alert) { if ((in_array($agent_alert['id_alert_template'], $id_alert_templates)) && (in_array($agent_alert['id_agent_module'], $modules_id))) { - $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + // $alerts_agent_modules = array_merge($alerts_agent_modules, alerts_get_alerts_agent_module($agent_alert['id_agent_module'], true, false, 'id')); + $alerts_agent_modules[] = $agent_alert['id']; } } @@ -126,7 +127,7 @@ if ($delete) { $agent_module_actions = []; foreach ($alerts_agent_modules as $alert_agent_module) { - $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module['id'], ['id', 'id_alert_action']); + $agent_module_actions = alerts_get_alert_agent_module_actions($alert_agent_module, ['id', 'id_alert_action']); foreach ($agent_module_actions as $agent_module_action) { foreach ($actions as $action) { From dac99b7a30be4960df2832e3cb420792a886fd62 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 08:55:18 +0200 Subject: [PATCH 009/414] #11886 Fix minimun misprint --- pandora_console/include/functions_reporting_html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index eb7c555fb9..60e6e41a0c 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -4091,7 +4091,7 @@ function reporting_html_value( $table2->head = [ __('Agent'), __('Module'), - __('Minimun'), + __('Minimum'), ]; break; @@ -4162,7 +4162,7 @@ function reporting_html_value( case 'min_value': $table1->head = [ __('Lapse'), - __('Minimun'), + __('Minimum'), ]; break; From 98112d9ff3e51f286e7058d8a2c9518183d37b1b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 1 Sep 2023 09:05:16 +0200 Subject: [PATCH 010/414] #11759 fix delete action snmp alert --- pandora_console/godmode/snmpconsole/snmp_alert.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/godmode/snmpconsole/snmp_alert.php b/pandora_console/godmode/snmpconsole/snmp_alert.php index d23b65d7ea..0df4298d7a 100755 --- a/pandora_console/godmode/snmpconsole/snmp_alert.php +++ b/pandora_console/godmode/snmpconsole/snmp_alert.php @@ -1952,6 +1952,7 @@ if ($create_alert || $update_alert) { [ 'border' => '0', 'alt' => __('Delete'), + 'class' => 'invert_filter main_menu_icon', ] ).' '; $data[1] .= ''; From 3960c2021a9f874b1c290b6d49d8937fc59bf595 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 09:06:48 +0200 Subject: [PATCH 011/414] #11856 Fix view events tooltip --- pandora_console/include/styles/tables.css | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index 7d93624dbb..bd68fe4358 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -652,6 +652,7 @@ div.advanced-options-events > div.filter_input { .vert-align-bottom { vertical-align: bottom; + font-size: 8pt; } label.vert-align-bottom > a.tip { From 94315147cfeb8d88daeeb53c1c062f9babd7b052 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 1 Sep 2023 10:12:03 +0200 Subject: [PATCH 012/414] #11750 module_data name file add module id --- pandora_console/include/functions_api.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7e22befbee..95e3e47919 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -10299,8 +10299,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) modules_get_type_name($agentModule['id_tipo_modulo']), $data ); - - if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$time.'.data', $xml)) { + if (false === @file_put_contents($config['remote_config'].'/'.io_safe_output($agent['nombre']).'.'.$idAgentModule.'.'.$time.'.data', $xml)) { returnError(sprintf('XML file could not be generated in path: %s', $config['remote_config'])); } else { echo __('XML file was generated successfully in path: ').$config['remote_config']; From 82db8bd4bda6e6aa4865147bbfbd583a0d2f3bf4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 1 Sep 2023 10:28:02 +0200 Subject: [PATCH 013/414] #11077 fix trre view widget style modal --- pandora_console/include/functions_treeview.php | 6 +++--- pandora_console/include/styles/pandora.css | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 025276ecef..bdc7339b4a 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -785,7 +785,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) false, false, '', - 'white-box-content mrgn_top_0 mrgn_btn_0px', + 'white-box-content-no-height mrgn_top_0 mrgn_btn_0px', 'white_table_flex' ); @@ -805,7 +805,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) true, false, '', - 'white-box-content mrgn_top_0 mrgn_btn_0px border-bottom-gray', + 'white-box-content-no-height mrgn_top_0 mrgn_btn_0px border-bottom-gray', 'white_table_flex' ); } @@ -980,7 +980,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false) true, empty($table_advanced->data), '', - 'white-box-content mrgn_top_0 mrgn_btn_0px border-bottom-gray', + 'white-box-content-no-height mrgn_top_0 mrgn_btn_0px border-bottom-gray', 'white_table_flex' ); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index abbb50c927..486e3717f2 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6369,6 +6369,18 @@ div#status_pie { min-width: 100%; } +.white-box-content-no-height { + width: 100%; + background-color: #fff; + box-sizing: border-box; + /*border: 1px solid #e2e2e2;*/ + display: flex; + align-items: center; + flex-wrap: wrap; + padding: 10px; + min-width: 100%; +} + .white-box-content-clean { padding-left: 2em; padding-top: 1em; From f3d2d7f3e63b8e215184c5eba931129d068de6e6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 10:48:03 +0200 Subject: [PATCH 014/414] #11854 Fix Create network monitoring from welcome pandora fms agent --- .../include/class/WelcomeWindow.class.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 5e66268403..3b49e1a56f 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -702,7 +702,7 @@ class WelcomeWindow extends Wizard 'next', 'style' => 'margin-top:15px; float:right;']); ?> @@ -1263,14 +1262,18 @@ class WelcomeWindow extends Wizard }); }); - $('#button-create_conectivity').click(function(){ + $('#button-create_conectivity').click(function(e){ + if($("#text-ip_target")[0].checkValidity() == false) { + $("#text-ip_target")[0].reportValidity(); + return false; + } $.ajax({ async: false, type: "POST", url: "include/ajax/task_to_perform.php", data: { check_connectivity: 1, - id_group: $('#id_group :selected').val(), + id_group: $('#id_group1 option:selected').val(), ip_target: $('#text-ip_target').val(), agent_name: $('#text-agent_name').val(), }, From 4129833a3804779ce8f7d9b07affc379d40c3606 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 1 Sep 2023 11:44:12 +0200 Subject: [PATCH 015/414] #11026 message update only for token enable --- .../include/class/ConsoleSupervisor.php | 24 ++++++++++--------- pandora_console/include/styles/pandora.css | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index f6d3767708..97e613cc20 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -2373,17 +2373,19 @@ class ConsoleSupervisor include_once $config['homedir'].'/include/functions_update_manager.php'; $login = get_parameter('login', false); - if (update_manager_verify_registration() === false) { - $this->notify( - [ - 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Update manager section'), - 'message' => __('Click here to start the registration process'), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', - ] - ); - } else { - $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + if ($config['autoupdate'] === true || $_GET['sec2'] === 'godmode/update_manager/update_manager') { + if (update_manager_verify_registration() === false) { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Update manager section'), + 'message' => __('Click here to start the registration process'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + ] + ); + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + } } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index abbb50c927..573ac1a40c 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4928,6 +4928,7 @@ div#dialog_messages table th:last-child { margin-top: 55px; border-radius: 5px; max-height: 530px; + position: fixed; } #notification-wrapper::before { From 5a31621abfc33c93ee1c772f5b7e20d6c734c163 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 1 Sep 2023 13:15:42 +0200 Subject: [PATCH 016/414] #11903 Fix gis maps --- .../godmode/gis_maps/configure_gis_map.php | 14 +++++++++----- pandora_console/include/functions_gis.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index a6f282d2cf..fee2b9d723 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -243,10 +243,15 @@ switch ($action) { $map_default_altitude = get_parameter('map_default_altitude'); $map_group_id = get_parameter('map_group_id'); $map_levels_zoom = get_parameter('map_levels_zoom', 16); - $map_connection_list_temp = explode(',', get_parameter('map_connection_list')); + $map_connection_list_temp_string = implode(',', $map_connection_list_temp); + if (strlen($map_connection_list_temp_string) > 0) { + $where_map_connection = ' WHERE id_tmap_connection IN('.$map_connection_list_temp_string.')'; + } else { + $where_map_connection = ''; + } - $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'); + $listConnectionTemp = db_get_all_rows_sql('SELECT id_tmap_connection, conection_name, group_id FROM tgis_map_connection'.$where_map_connection); foreach ($map_connection_list_temp as $index => $value) { $cleanValue = trim($value); @@ -256,7 +261,6 @@ switch ($action) { } $map_connection_default = get_parameter('map_connection_default'); - $map_connection_list = []; foreach ($listConnectionTemp as $idMapConnection) { $default = 0; @@ -345,7 +349,7 @@ function deleteConnectionMap(idConnectionMap) { checked = $("#radiobtn0001", $("#map_connection_" + idConnectionMap)).attr('checked'); $("#map_connection_" + idConnectionMap).remove(); - + if (checked) { //Checked first, but not is index = 0 maybe. @@ -485,7 +489,7 @@ foreach ($listConnectionTemp as $connectionTemp) { $table->data[1][0] = __('Add Map connection').$iconError; $table->data[1][1] = " - - + \ No newline at end of file From 3327d79ed62b38bc6f63611c57fe4c9f60c49c54 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 6 Sep 2023 09:35:12 +0200 Subject: [PATCH 026/414] #11442 Change Welcome tips arrows and buttons --- .../include/class/TipsWindow.class.php | 21 +++- .../include/javascript/tipsWindow.js | 101 ++++++++++++++---- pandora_console/include/styles/pandora.css | 22 ++++ .../include/styles/tips_window.css | 3 +- .../views/dashboard/tipsWindow.php | 39 ++++--- 5 files changed, 144 insertions(+), 42 deletions(-) diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index ae4271fba9..6406c69194 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -47,6 +47,7 @@ class TipsWindow 'renderPreview', 'setShowTipsAtStartup', 'getTips', + 'getTipById', ]; /** @@ -221,8 +222,13 @@ class TipsWindow * * @return array $tip */ - public function getTipById($idTip) + public function getTipById($idTip=false, $return=false) { + if ($idTip === false) { + $idTip = get_parameter('idTip'); + } + + $return = get_parameter('return', false); $tip = db_get_row( 'twelcome_tip', 'id', @@ -232,9 +238,20 @@ class TipsWindow $tip['title'] = io_safe_output($tip['title']); $tip['text'] = io_safe_output($tip['text']); $tip['url'] = io_safe_output($tip['url']); + $tip['files'] = $this->getFilesFromTip($tip['id']); } - return $tip; + if ($return !== false) { + if (empty($tip) === false) { + echo json_encode(['success' => true, 'data' => $tip]); + return; + } else { + echo json_encode(['success' => false]); + return; + } + } else { + return $tip; + } } diff --git a/pandora_console/include/javascript/tipsWindow.js b/pandora_console/include/javascript/tipsWindow.js index 94d28c9339..cb804ecebb 100644 --- a/pandora_console/include/javascript/tipsWindow.js +++ b/pandora_console/include/javascript/tipsWindow.js @@ -81,14 +81,17 @@ function removeInputImage(e) { $("#notices_images").addClass("invisible"); } } -function render({ title, text, url, files }) { +function render({ title, text, url, files, method }) { $("#title_tip").html(title); $("#text_tip").html(text); if (url) { - $("#url_tip").removeClass("invisible"); + $("#button-learn_more").removeAttr("disabled"); + $("#button-learn_more").removeClass("disabled_button"); $("#url_tip").attr("href", url); } else { - $("#url_tip").addClass("invisible"); + $("#button-learn_more").attr("disabled", "disabled"); + $("#button-learn_more").addClass("disabled_button"); + $("#url_tip").attr("href", ""); } $(".carousel").empty(); @@ -110,7 +113,11 @@ function render({ title, text, url, files }) { if (index >= limitRound - 1) { $($(".count-round-tip")[0]).addClass("active"); } else { - $($(".count-round-tip")[index + 1]).addClass("active"); + if (method == "next") { + $($(".count-round-tip")[index + 1]).addClass("active"); + } else { + $($(".count-round-tip")[index - 1]).addClass("active"); + } } return false; } @@ -146,23 +153,79 @@ function render_counter() { function next_tip() { if (idTips.length >= totalTips) { idTips = []; + $("#hidden-tip_position").val(-1); } - $.ajax({ - method: "POST", - url: url, - dataType: "json", - data: { - page: page, - method: "getRandomTip", - exclude: JSON.stringify(idTips) - }, - success: function({ success, data }) { - if (success) { - idTips.push(parseInt(data.id)); - render(data); + let tip_position = parseInt($("#hidden-tip_position").val()) + 1; + let idTip = idTips[tip_position]; + if (idTip === undefined) { + $.ajax({ + method: "POST", + url: url, + dataType: "json", + data: { + page: page, + method: "getRandomTip", + exclude: JSON.stringify(idTips) + }, + success: function({ success, data }) { + if (success) { + let tip_position = parseInt($("#hidden-tip_position").val()) + 1; + $("#hidden-tip_position").val(tip_position); + idTips.push(parseInt(data.id)); + data.method = "next"; + render(data); + } } - } - }); + }); + } else { + $.ajax({ + method: "POST", + url: url, + dataType: "json", + data: { + page: page, + method: "getTipById", + idTip: idTip, + return: true + }, + success: function({ success, data }) { + if (success) { + let tip_position = parseInt($("#hidden-tip_position").val()) + 1; + $("#hidden-tip_position").val(tip_position); + data.method = "next"; + render(data); + } + } + }); + } +} + +function previous_tip() { + let actual_tip_position = parseInt($("#hidden-tip_position").val()); + + if (actual_tip_position != 0) { + let tip_position = parseInt($("#hidden-tip_position").val()) - 1; + let idTip = idTips[tip_position]; + $.ajax({ + method: "POST", + url: url, + dataType: "json", + data: { + page: page, + method: "getTipById", + idTip: idTip, + return: true + }, + success: function({ success, data }) { + if (success) { + let tip_position = parseInt($("#hidden-tip_position").val()) - 1; + $("#hidden-tip_position").val(tip_position); + data.method = "prev"; + render(data); + } + } + }); + } } function load_tips_modal(settings) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d87d959ac5..3bbf8cb16d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12566,3 +12566,25 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { .ui-date-range-in > a { background-color: #81b92e3b !important; } + +.ui-dialog .tips_header.ui-dialog-titlebar { + height: fit-content !important; +} + +.arrow_counter:hover { + cursor: pointer; +} + +.disabled_button { + background-color: #ccc !important; + border: 2px solid #444 !important; + color: #444 !important; +} + +.disabled_button:hover { + cursor: not-allowed; +} + +.counter-tips { + margin-right: 20px; +} diff --git a/pandora_console/include/styles/tips_window.css b/pandora_console/include/styles/tips_window.css index 505799949b..53906401a8 100644 --- a/pandora_console/include/styles/tips_window.css +++ b/pandora_console/include/styles/tips_window.css @@ -21,7 +21,7 @@ display: flex !important; padding: 0px 20px; justify-content: space-between; - height: fit-content; + height: fit-content !important; background-color: white; color: #161628; border-top-left-radius: 25px !important; @@ -161,6 +161,7 @@ span.count-round-tip.active { margin-top: 10px; } .arrow_counter { + cursor: pointer; width: 7px; margin: 0px 5px; } diff --git a/pandora_console/views/dashboard/tipsWindow.php b/pandora_console/views/dashboard/tipsWindow.php index b9ff3f2420..573a11abcc 100644 --- a/pandora_console/views/dashboard/tipsWindow.php +++ b/pandora_console/views/dashboard/tipsWindow.php @@ -72,37 +72,36 @@ $output .= '

'.$title.'

'; $output .= '

'; $output .= $text; $output .= '

'; - -$link_class = 'invisible'; +$disabled_class = 'disabled_button'; +$disabled = true; if (empty($url) === false && $url !== '') { - $link_class = ''; + $disabled_class = ''; + $disabled = false; } -$output .= ''.__('See more info').''; - $output .= ''; $output .= '
'; - +$output .= ''; $output .= html_print_button( - __('Maybe later'), + __('Learn more'), + 'learn_more', + $disabled, '', - false, - '', - [ - 'onclick' => 'close_dialog()', - 'class' => 'secondary mini', - ], + ['class' => 'secondary mini '.$disabled_class], true ); +$output .= ''; $output .= '
'; -$output .= html_print_image('images/arrow-left-grey.png', true, ['class' => 'arrow_counter']); -$output .= html_print_image('images/arrow-right-grey.png', true, ['class' => 'arrow_counter']); + +$output .= html_print_image('images/arrow-left-grey.png', true, ['class' => 'arrow_counter', 'onclick' => 'previous_tip()']); +$output .= html_print_image('images/arrow-right-grey.png', true, ['class' => 'arrow_counter', 'onclick' => 'next_tip()']); +$output .= html_print_input_hidden('tip_position', 0, true); $output .= '
'; if ($preview === true) { $output .= html_print_button( - __('Ok'), - 'next_tip', + __('Close'), + 'close_dialog', false, '', [ @@ -113,12 +112,12 @@ if ($preview === true) { ); } else { $output .= html_print_button( - __('Ok'), - 'next_tip', + __('Close'), + 'close_dialog', false, '', [ - 'onclick' => 'next_tip()', + 'onclick' => 'close_dialog()', 'class' => ($totalTips === '1') ? 'mini hide-button' : 'mini', ], true From f8f13227f87096a15c7fc431c64bf278079704e5 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 6 Sep 2023 10:28:44 +0200 Subject: [PATCH 027/414] #11537 Fix metaconsole inventory and hd traces --- pandora_console/include/class/ConfigPEN.class.php | 1 - pandora_console/include/functions_inventory.php | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/class/ConfigPEN.class.php b/pandora_console/include/class/ConfigPEN.class.php index 4e4975e64d..6e2f7ec1f6 100644 --- a/pandora_console/include/class/ConfigPEN.class.php +++ b/pandora_console/include/class/ConfigPEN.class.php @@ -184,7 +184,6 @@ class ConfigPEN extends HTML return db_get_value_sql($sql); } - hd($sql, true); return db_get_all_rows_sql($sql); } diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index 0becb94fec..afa61c3811 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -77,8 +77,6 @@ function inventory_get_data( } if ($inventory_search_string != '') { - hd(1, true); - hd($inventory_search_string, true); array_push($where, "REPLACE(tagent_module_inventory.data, ' ', ' ') LIKE '%".$inventory_search_string."%'"); } @@ -748,8 +746,6 @@ function inventory_get_datatable( } if ($inventory_search_string != '') { - hd(2, true); - hd($inventory_search_string, true); array_push($where, "REPLACE(tagente_datos_inventory.data, ' ', ' ') LIKE '%".$inventory_search_string."%'"); } @@ -799,7 +795,13 @@ function inventory_get_datatable( $data_rows = explode(PHP_EOL, $row['data_inventory']); foreach ($data_rows as $data_key => $data_value) { - if (empty($data_value) === false && strpos(str_replace(' ', ' ', $data_value), $inventory_search_string)) { + if (empty($inventory_search_string) !== true) { + $search_check = strpos(str_replace(' ', ' ', $data_value), $inventory_search_string); + } else { + $search_check = true; + } + + if (empty($data_value) === false && $search_check !== false) { $row['data'] = $data_value; $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; } @@ -895,8 +897,6 @@ function get_data_basic_info_sql($params, $count=false) ' AND ( REPLACE(alias, " ", " ") LIKE "%%%s%%" )', $params['search'] ); - hd(3, true); - hd($params['search'], true); } if ($params['utimestamp'] > 0 && $count === false) { From 0cd43b8315e48c654725564c02a01781a3fee0c7 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 6 Sep 2023 15:45:35 +0200 Subject: [PATCH 028/414] fixed web console erratas --- .../godmode/reporting/reporting_builder.list_items.php | 2 +- pandora_console/godmode/setup/setup.php | 2 +- pandora_console/include/functions_reporting_html.php | 2 +- tests/console/Views.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index d3fd439181..e92e038dfe 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -777,7 +777,7 @@ $table->data[0][0] = html_print_label_input_block( ) ); $table->data[0][1] = html_print_label_input_block( - __('Poisition'), + __('Position'), html_print_input_text_extended( 'position_to_delete', 1, diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 7e17f9fe4c..84cce309a8 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -370,7 +370,7 @@ switch ($section) { break; default: - $subpage = 'seccion: '.$section; + $subpage = 'seccion: '; // Default. break; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index eb7c555fb9..b57ee0e7e1 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2712,7 +2712,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $out .= ''; $out .= '
'; $out .= ''; - $out .= ' + + + +
".html_print_select($listConnection, 'map_connection_list', '', '', '', '0', true)." + ".html_print_select($listConnection, 'select-map_connection_list', '', '', '', '0', true)." ".html_print_image( diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index ba9116759b..b57ec9e9ff 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list)
'.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).' '.$radioButton.''.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).''.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter main_menu_icon']).'
'.__('Events per agent').''; + $out .= '
'.__('Events by agent').''; $data = []; $options = []; $labels = []; diff --git a/tests/console/Views.py b/tests/console/Views.py index b4ad48134e..f4967e3db7 100644 --- a/tests/console/Views.py +++ b/tests/console/Views.py @@ -305,7 +305,7 @@ class viewAppear(PandoraWebDriverTestCase): click_menu_element(driver,"CSV import") time.sleep(2) self.assertEqual("Upload file" in driver.page_source,True) - click_menu_element(driver,"CSV import group") + click_menu_element(driver,"Import groups with CSV file") time.sleep(2) self.assertEqual("Upload file" in driver.page_source,True) click_menu_element(driver,"IPAM") From d48cd703bc28fb050d5d747622f0373cda493b01 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 7 Sep 2023 10:25:09 +0200 Subject: [PATCH 029/414] Added distro information in About and Diagnostic info --- pandora_console/include/class/Diagnostics.class.php | 6 +++++- pandora_console/include/functions_menu.php | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index 2c00a6b328..2ce5b54170 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -728,7 +728,7 @@ class Diagnostics extends Wizard $cpuModelName = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"'; $cpuProcessor = 'cat /proc/cpuinfo | grep "processor" | wc -l'; $ramMemTotal = 'cat /proc/meminfo | grep "MemTotal"'; - + $distroInfo = 'cat /etc/os-release | grep "PRETTY_NAME" | cut -f 2 -d "="'; exec( "ifconfig | awk '{ print $2}' | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}'", $output @@ -747,6 +747,10 @@ class Diagnostics extends Wizard 'name' => __('RAM'), 'value' => exec($ramMemTotal), ], + 'distroInfo' => [ + 'name' => __('Distro'), + 'value' => str_replace('"', '', exec($distroInfo)), + ], 'osInfo' => [ 'name' => __('Os'), 'value' => exec('uname -a'), diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index a1927bb60a..231d084bae 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -1164,6 +1164,14 @@ if (is_ajax()) {

'.$sys_info->data->ramInfo->value.'

+

'.$sys_info->data->distroInfo->name.'

+
+

'.$sys_info->data->distroInfo->value.'

+

'.$sys_info->data->osInfo->name.'

From f445066d134da812c8670eb208cabe2b5bce56b6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 7 Sep 2023 16:29:18 +0200 Subject: [PATCH 030/414] #11679 Fix linked module name --- pandora_console/include/ajax/module.php | 2 ++ .../operation/search_modules.getdata.php | 26 ++++++++++++------- pandora_console/operation/search_modules.php | 10 ++++--- pandora_console/operation/search_results.php | 2 +- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 1e529c487c..278774b8cd 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1155,7 +1155,9 @@ if (check_login()) { ); } + $data[2] .= ''; $data[2] .= ui_print_truncate_text($module['nombre'], 'module_medium', false, true, true, '…', 'font-size: 9pt;'); + $data[2] .= ''; if (empty($module['extended_info']) === false) { $data[2] .= ui_print_help_tip($module['extended_info'], true, '/images/default_list.png'); } diff --git a/pandora_console/operation/search_modules.getdata.php b/pandora_console/operation/search_modules.getdata.php index e83c6035ef..a278ca8cd0 100644 --- a/pandora_console/operation/search_modules.getdata.php +++ b/pandora_console/operation/search_modules.getdata.php @@ -19,17 +19,25 @@ require_once $config['homedir'].'/include/functions_users.php'; $searchModules = check_acl($config['id_user'], 0, 'AR'); -$selectModuleNameUp = ''; -$selectModuleNameDown = ''; -$selectAgentNameUp = ''; -$selectAgentNameDown = ''; +if ($config['style'] === 'pandora_black') { + $selectModuleNameUp = ''; + $selectModuleNameDown = ''; + $selectAgentNameUp = ''; + $selectAgentNameDown = ''; +} else { + $selectModuleNameUp = '_black'; + $selectModuleNameDown = '_black'; + $selectAgentNameUp = '_black'; + $selectAgentNameDown = '_black'; +} + $is_admin = (bool) db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); switch ($sortField) { case 'module_name': switch ($sort) { case 'up': - $selectModuleNameUp = $selected; + $selectModuleNameUp = $selected_module; $order = [ 'field' => 'module_name', 'order' => 'ASC', @@ -37,7 +45,7 @@ switch ($sortField) { break; case 'down': - $selectModuleNameDown = $selected; + $selectModuleNameDown = $selected_module; $order = [ 'field' => 'module_name', 'order' => 'DESC', @@ -49,7 +57,7 @@ switch ($sortField) { case 'agent_name': switch ($sort) { case 'up': - $selectAgentNameUp = $selected; + $selectAgentNameUp = $selected_module; $order = [ 'field' => 'agent_name', 'order' => 'ASC', @@ -57,7 +65,7 @@ switch ($sortField) { break; case 'down': - $selectAgentNameDown = $selected; + $selectAgentNameDown = $selected_module; $order = [ 'field' => 'agent_name', 'order' => 'DESC', @@ -67,7 +75,7 @@ switch ($sortField) { break; default: - $selectModuleNameUp = $selected; + $selectModuleNameUp = $selected_module; $order = [ 'field' => 'module_name', 'order' => 'ASC', diff --git a/pandora_console/operation/search_modules.php b/pandora_console/operation/search_modules.php index 6d35064b68..41d545928f 100644 --- a/pandora_console/operation/search_modules.php +++ b/pandora_console/operation/search_modules.php @@ -30,10 +30,9 @@ if (!$modules || !$searchModules) { $table->cellspacing = 4; $table->width = '98%'; $table->class = 'info_table'; - $table->head = []; - $table->head[0] = __('Module').' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp]).''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown]).''; - $table->head[1] = __('Agent').' '.html_print_image('images/sort_up.png', true, ['style' => $selectAgentNameUp]).''.html_print_image('images/sort_down.png', true, ['style' => $selectAgentNameDown]).''; + $table->head[0] = __('Module').' '.html_print_image('images/sort_up'.$selectModuleNameUp.'.png', true).''.html_print_image('images/sort_down'.$selectModuleNameDown.'.png', true).''; + $table->head[1] = __('Agent').' '.html_print_image('images/sort_up'.$selectAgentNameUp.'.png', true).''.html_print_image('images/sort_down'.$selectAgentNameDown.'.png', true).''; $table->head[2] = __('Type'); $table->head[3] = __('Interval'); $table->head[4] = __('Status'); @@ -80,6 +79,9 @@ if (!$modules || !$searchModules) { $module['datos'] = modules_get_last_value($module['id_agente_modulo']); $module['module_name'] = $module['nombre']; + $linked_module_name = ''; + $linked_module_name .= $module['module_name']; + $linked_module_name .= ''; // To search the monitor status $status_sql = sprintf('SELECT estado from tagente_estado where id_agente_modulo ='.$module['id_agente_modulo']); $status_sql = db_process_sql($status_sql); @@ -226,7 +228,7 @@ if (!$modules || !$searchModules) { array_push( $table->data, [ - $module['module_name'], + $linked_module_name, $agentCell, $typeCell, $intervalCell, diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index cef9788be0..76638e3525 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -60,7 +60,7 @@ $order = null; $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $selected = 'border: 1px solid black;'; - +$selected_module = '_green'; if ($searchMain) { $main_tab = [ 'text' => "".html_print_image( From 02e2903b37f4538b59c0ec18cf9134986a4bfe39 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 7 Sep 2023 17:58:26 +0200 Subject: [PATCH 031/414] #11995 Prevent breaked graphics --- pandora_console/include/graphs/flot/pandora.flot.js | 3 +++ pandora_console/include/styles/pandora.css | 1 + 2 files changed, 4 insertions(+) diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 56cd4a71a1..077a3200e5 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2223,6 +2223,9 @@ function pandoraFlotArea( } var dataInSelection = ranges.xaxis.to - ranges.xaxis.from; + if (dataInSelection < 35000) { + return; + } var maxticks_zoom = dataInSelection / 3600000 / number_ticks; if (maxticks_zoom < 0.001) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d87d959ac5..bc31c721e5 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6646,6 +6646,7 @@ table.table_modal_alternate tr td:first-child { white-space: normal; word-break: break-all; line-height: 1.3; + max-width: 40px !important; } table#agent_interface_info .flot-text .flot-x-axis div { From 4b5dcff3cc41cbac4bc801d0d64638ce093c1e9d Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 8 Sep 2023 09:26:08 +0200 Subject: [PATCH 032/414] #10529 Fix token session timeout --- pandora_console/godmode/setup/setup_auth.php | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 6616cd765c..580ccab9a3 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -535,16 +535,47 @@ html_print_action_buttons( __('Update'), 'update_button', false, - [ 'icon' => 'update' ], + [ + 'icon' => 'update', + 'onclick' => 'onFormSubmit()', + ], true ) ); echo ''; +echo ui_print_warning_message( + [ + 'message' => __('Session timeout must be a number'), + 'force_class' => 'invisible js_warning_msg', + ], + '', + true +); ?> From 09cae778c52172af465b1a9cc5c775bf29a2a8a1 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 4 Oct 2023 16:28:40 +0200 Subject: [PATCH 098/414] #12153 Create event list graph --- pandora_console/include/ajax/events.php | 4 +- pandora_console/include/functions_events.php | 40 ++++++++++++++------ pandora_console/include/graphs/fgraph.php | 6 +++ pandora_console/operation/events/events.php | 11 +++--- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 1e9d744739..fbab653bf7 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -2764,9 +2764,7 @@ if ($draw_row_response_info === true) { if ((bool) $draw_events_graph === true) { $filter = get_parameter('filter'); - $output = ''; - hd($filter, true); - $output .= '

grafica

'; + $output = event_print_graph($filter); echo $output; return; } \ No newline at end of file diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index edefd1c187..76439fd8c4 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6207,13 +6207,14 @@ function event_get_counter_extraId(array $event, ?array $filters) function event_print_graph( $filter, - $start_utimestamp, - $end_utimestamp, - $graph_width, - $graph_height, + $graph_height=100, ) { global $config; - $num_data = 10; + $events = events_get_all(['te.id_evento', 'te.timestamp', 'te.utimestamp'], $filter, null, null, 'te.utimestamp', true); + $start_utimestamp = $events[0]['utimestamp']; + $end_utimestamp = $events[array_key_last($events)]['utimestamp']; + $num_data = count($events); + $num_intervals = ($num_data > 75) ? 75 : $num_data; $period = ($end_utimestamp - $start_utimestamp); @@ -6256,12 +6257,26 @@ function event_print_graph( $chart = []; $labels = []; $color = []; - $currentutimestamp = $start_utimestamp; - for ($i = 0; $i < $num_intervals; $i++,$currentutimestamp += $interval_length) { - $labels[] = date($chart_time_format, $currentutimestamp); + $count = 0; + $control_timestamp = $start_utimestamp; + $data_events = []; + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $data_events = array_reverse($data_events, true); + foreach ($data_events as $utimestamp => $count) { + $labels[] = date($chart_time_format, $utimestamp); $chart[] = [ - 'y' => 1, - 'x' => date($chart_time_format, $currentutimestamp), + 'y' => $count, + 'x' => date($chart_time_format, $utimestamp), ]; $color[] = '#82b92f'; } @@ -6276,6 +6291,7 @@ function event_print_graph( 'waterMark' => $water_mark, 'legend' => ['display' => false], 'colors' => $color, + 'border' => false, 'scales' => [ 'x' => [ 'grid' => ['display' => false], @@ -6287,9 +6303,9 @@ function event_print_graph( 'labels' => $labels, ]; - $graph = '
'; + $graph = '
'; $graph .= vbar_graph($chart, $options); $graph .= '
'; - echo $graph; + return $graph; } diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 494ec9c010..d7f3e3ed7b 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -1187,6 +1187,12 @@ function get_build_setup_charts($type, $options, $data) ) { $colors = $options['colors']; $borders = $options['colors']; + if (isset($options['border']) === true && (bool) $options['border'] === false) { + $borders = []; + foreach ($colors as $color) { + $borders[] = 'rgba(0, 0, 0, 0)'; + } + } } else { // Colors. $defaultColor = []; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 076d48e60a..febdb33156 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -2728,8 +2728,8 @@ try { $graph_div = html_print_div( [ 'id' => 'events-graph', - 'class' => 'mrgn_top_10px mrg_btt_60 invisible', - 'style' => 'text-align: left;'.$graph_background, + 'class' => 'invisible', + 'style' => 'margin-bottom: 10px; text-align: left;'.$graph_background, ], true ); @@ -2750,7 +2750,6 @@ try { true ); - hd(get_parameter('filter'), true); // Print datatable. @@ -3502,6 +3501,10 @@ $(document).ready( function() { $("#button-remove_without").click(function() { click_button_remove_tag("without"); }); + + $("#button-events_form_search_bt").click(function(){ + show_events_graph(); + }); //Autorefresh in fullscreen @@ -3737,8 +3740,6 @@ function show_events_graph(){ $('#events-graph') .empty() .html(data); - console.log('success'); - console.log(data); } }); } From 87aa79b176d8209671385456ad389cc84ffb689a Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 5 Oct 2023 09:45:17 +0200 Subject: [PATCH 099/414] #12153 Fix graph --- pandora_console/include/functions_events.php | 129 ++++++++++++------- 1 file changed, 82 insertions(+), 47 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 76439fd8c4..8e2896c448 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6207,17 +6207,48 @@ function event_get_counter_extraId(array $event, ?array $filters) function event_print_graph( $filter, - $graph_height=100, + $graph_height=400, ) { global $config; + $show_all_data = false; $events = events_get_all(['te.id_evento', 'te.timestamp', 'te.utimestamp'], $filter, null, null, 'te.utimestamp', true); - $start_utimestamp = $events[0]['utimestamp']; - $end_utimestamp = $events[array_key_last($events)]['utimestamp']; - $num_data = count($events); - $num_intervals = ($num_data > 75) ? 75 : $num_data; + if (empty($filter['date_from']) === false + && empty($filter['time_from']) === false + && empty($filter['date_to']) === false + && empty($filter['time_to']) === false + ) { + $start_utimestamp = strtotime($filter['date_from'].' '.$filter['time_from']); + $end_utimestamp = strtotime($filter['date_to'].' '.$filter['time_to']); + } else if ($filter['event_view_hr'] !== '') { + $start_utimestamp = strtotime('-'.$filter['event_view_hr'].' hours'); + $end_utimestamp = strtotime('now'); + } else { + $show_all_data = true; + $start_utimestamp = $events[0]['utimestamp']; + $end_utimestamp = $events[array_key_last($events)]['utimestamp']; + } + + $data_events = []; + $control_timestamp = $start_utimestamp; + $count = 0; + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; + } + + $num_data = count($data_events); + + $num_intervals = $num_data; $period = ($end_utimestamp - $start_utimestamp); + if ($period <= SECONDS_6HOURS) { $chart_time_format = 'H:i:s'; } else if ($period < SECONDS_1DAY) { @@ -6230,55 +6261,59 @@ function event_print_graph( $chart_time_format = 'M d H\h'; } - $interval_length = (int) ($period / $num_intervals); - - $currentutimestamp = $start_utimestamp; - for ($i = 0; $i < $num_intervals; $i++) { - if ($currentutimestamp === $start_utimestamp) { - $filter['aggs']['messages']['filters']['filters'][$i]['range']['utimestamp'] = [ - 'gte' => $currentutimestamp, - 'lte' => ($currentutimestamp + $interval_length), - ]; - } else if ($currentutimestamp === $end_utimestamp) { - $filter['aggs']['messages']['filters']['filters'][$i]['range']['utimestamp'] = [ - 'gt' => $currentutimestamp, - 'lte' => $end_utimestamp, - ]; - } else { - $filter['aggs']['messages']['filters']['filters'][$i]['range']['utimestamp'] = [ - 'gt' => $currentutimestamp, - 'lte' => ($currentutimestamp + $interval_length), - ]; - } - - $currentutimestamp += $interval_length; - } - $chart = []; $labels = []; $color = []; $count = 0; - $control_timestamp = $start_utimestamp; - $data_events = []; - foreach ($events as $event) { - if ($event['utimestamp'] === $control_timestamp) { - $count++; - } else { - $control_timestamp = $event['utimestamp']; - $count = 1; + + if ($show_all_data === true) { + foreach ($events as $event) { + if ($event['utimestamp'] === $control_timestamp) { + $count++; + } else { + $control_timestamp = $event['utimestamp']; + $count = 1; + } + + $data_events[$control_timestamp] = $count; } - $data_events[$control_timestamp] = $count; - } + $data_events = array_reverse($data_events, true); - $data_events = array_reverse($data_events, true); - foreach ($data_events as $utimestamp => $count) { - $labels[] = date($chart_time_format, $utimestamp); - $chart[] = [ - 'y' => $count, - 'x' => date($chart_time_format, $utimestamp), - ]; - $color[] = '#82b92f'; + foreach ($data_events as $utimestamp => $count) { + $labels[] = date($chart_time_format, $utimestamp); + $chart[] = [ + 'y' => $count, + 'x' => date($chart_time_format, $utimestamp), + ]; + $color[] = '#82b92f'; + } + } else { + $interval_length = (int) ($period / $num_intervals); + $intervals = []; + $intervals[0] = $start_utimestamp; + for ($i = 0; $i < $num_intervals; $i++) { + $intervals[($i + 1)] = ($intervals[$i] + $interval_length); + } + + $control_data = []; + + foreach ($data_events as $utimestamp => $count_event) { + for ($i = 0; $i < $num_intervals; $i++) { + if ((int) $utimestamp > (int) $intervals[$i] && (int) $utimestamp < (int) $intervals[($i + 1)]) { + $control_data[(string) $intervals[$i]] += $count_event; + } + } + } + + for ($i = 0; $i < $num_intervals; $i++) { + $labels[] = date($chart_time_format, $intervals[$i]); + $chart[] = [ + 'y' => $control_data[$intervals[$i]], + 'x' => date($chart_time_format, $intervals[$i]), + ]; + $color[] = '#82b92f'; + } } $water_mark = [ From 6312804386f9624248f844983297d9cd96e12fce Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 5 Oct 2023 09:52:52 +0200 Subject: [PATCH 100/414] #12153 Fix graph height --- pandora_console/include/functions_events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8e2896c448..bd54d61623 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6207,7 +6207,7 @@ function event_get_counter_extraId(array $event, ?array $filters) function event_print_graph( $filter, - $graph_height=400, + $graph_height=100, ) { global $config; $show_all_data = false; From c20ca271ba430de34e7917fdbfd870a4afaf8b4a Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 6 Oct 2023 13:05:42 +0200 Subject: [PATCH 101/414] fix translate pandora_enterprise#11760 --- pandora_console/include/lib/Dashboard/Widgets/events_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index 7e050d3ee8..3706c33d5e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -396,7 +396,7 @@ class EventsListWidget extends Widget 0 => \__('Only pending'), 2 => \__('Only in process'), 3 => \__('Only not validated'), - 4 => \__('Only not process'), + 4 => \__('Only not in process'), ]; $inputs['inputs']['row1'][] = [ From 049e25f866d62388573997b5238f9cea7fd9cf41 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 6 Oct 2023 13:51:18 +0200 Subject: [PATCH 102/414] #8686 Add filter in managemnet tree group --- pandora_console/godmode/groups/group_list.php | 307 +++++++++++++----- pandora_console/include/ajax/tree.ajax.php | 2 + .../include/class/TreeGroupEdition.class.php | 148 +++++++-- pandora_console/include/functions_agents.php | 21 ++ 4 files changed, 373 insertions(+), 105 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 00bbdddb39..201d3cea4e 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -757,6 +757,125 @@ if ($tab == 'tree') { /* * Group tree view. */ + + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters filter-table-adv'; + if (is_metaconsole() === true) { + $table->cellspacing = 0; + $table->cellpadding = 0; + } + + $search_group_string = get_parameter('search_group_string', ''); + $search_agent_string = get_parameter('search_agent_string', ''); + $agent_status = get_parameter('agent_status', ''); + $show_not_init_agents = get_parameter('show_not_init_agents', 1); + $show_not_init_modules = get_parameter('show_not_init_modules', 1); + $show_full_hirearchy = get_parameter('show_full_hirearchy', 1); + + + $table->data = []; + $table->head = []; + $table->style = []; + + $table->style[0] = 'width: 50%;'; + $table->style[1] = 'width: 50%;'; + + $table->data[0][0] = html_print_label_input_block( + __('Search group'), + html_print_input_text( + 'search_group_string', + $search_group_string, + '', + 25, + 255, + true, + false, + false, + '', + ) + ); + + $agents_status_list = agents_status_list(); + + $table->data[0][1] = html_print_label_input_block( + __('Search by agent status').ui_print_help_tip(__('Shows the groups that contain an agent with the status that has been searched'), true), + html_print_select( + $agents_status_list, + 'agent_status', + $agent_status, + '', + __('All'), + '', + true, + false, + false, + 'w200p', + false, + 'width: 100%;' + ) + ); + + $table->data[1][0] = html_print_label_input_block( + __('Search by agent').ui_print_help_tip(__('Shows groups that contain an agent matching the search'), true), + html_print_input_text( + 'search_agent_string', + $search_agent_string, + '', + 25, + 255, + true, + false, + false, + '', + ) + ); + + $table->data[1][1] = html_print_label_input_block( + __('Show full hierarchy'), + html_print_checkbox_switch_extended( + 'show_full_hirearchy', + 1, + $show_full_hirearchy, + false, + '', + '', + true + ) + ); + + $table->data[3][0] = ' '; + + $table->data[3][1] = html_print_submit_button( + __('Filter'), + 'filter', + false, + [ + 'class' => 'float-right', + 'icon' => 'search', + ], + true + ); + + $form = "
"; + $form .= html_print_table($table, true); + $form .= '
'; + + + + ui_toggle( + $form, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); + + echo "
"; } else { /* @@ -826,6 +945,8 @@ if ($tab == 'tree') { ); $form .= ''; + + ui_toggle( $form, ''.__('Filters').'', @@ -1058,87 +1179,119 @@ $tab = 'group_edition'; diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 319b98e168..600b30e74d 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -59,6 +59,7 @@ if (is_ajax() === true) { $metaID = (int) get_parameter('metaID', 0); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $default_filters = [ 'searchAgent' => '', 'statusAgent' => AGENT_STATUS_ALL, @@ -69,6 +70,7 @@ if (is_ajax() === true) { ]; $filter = get_parameter('filter', $default_filters); + $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); diff --git a/pandora_console/include/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php index 4071266a58..48a103c724 100644 --- a/pandora_console/include/class/TreeGroupEdition.class.php +++ b/pandora_console/include/class/TreeGroupEdition.class.php @@ -106,20 +106,24 @@ class TreeGroupEdition extends TreeGroup } // Build the group hierarchy. - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) === true - && ($groups[$id]['parent'] != 0) - ) { - $parent = $groups[$id]['parent']; - // Parent exists. - if (isset($groups[$parent]['children']) === false) { - $groups[$parent]['children'] = []; - } + if (isset($this->filter['show_full_hirearchy']) === false + || (isset($this->filter['show_full_hirearchy']) === true && (bool) $this->filter['show_full_hirearchy'] === true) + ) { + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) === true + && ($groups[$id]['parent'] != 0) + ) { + $parent = $groups[$id]['parent']; + // Parent exists. + if (isset($groups[$parent]['children']) === false) { + $groups[$parent]['children'] = []; + } - // Store a reference to the group into the parent. - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent. - $groups[$id]['have_parent'] = true; + // Store a reference to the group into the parent. + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent. + $groups[$id]['have_parent'] = true; + } } } @@ -167,24 +171,112 @@ class TreeGroupEdition extends TreeGroup ]; $group_acl = ''; - if (users_can_manage_group_all('AR') === false) { - $user_groups_str = implode(',', $this->userGroupsArray); - $group_acl = sprintf( - 'AND id_grupo IN (%s)', - $user_groups_str + $search_agent = ''; + $status_agent = ''; + $inner_agent = ''; + + if ((bool) is_metaconsole() === true) { + if (users_can_manage_group_all('AR') === false) { + $user_groups_str = implode(',', $this->userGroupsArray); + $group_acl = sprintf( + ' AND tgrupo.id_grupo IN (%s) ', + $user_groups_str + ); + } + + if (isset($this->filter['searchAgent']) === true && empty($this->filter['searchAgent']) === false + || isset($this->filter['statusAgent']) === true && strlen($this->filter['statusAgent']) > 0 + ) { + $inner_agent = 'INNER JOIN tmetaconsole_agent ON tgrupo.id_grupo = tmetaconsole_agent.id_grupo'; + } + + if (isset($this->filter['searchAgent']) === true && empty($this->filter['searchAgent']) === false) { + $search_agent = ' AND tmetaconsole_agent.alias LIKE "%'.$this->filter['searchAgent'].'%" '; + } + + if (isset($this->filter['statusAgent']) === true && strlen($this->filter['statusAgent']) > 0) { + switch ($this->filter['statusAgent']) { + case AGENT_STATUS_NORMAL: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count = 0 + AND tmetaconsole_agent.unknown_count = 0 + AND tmetaconsole_agent.normal_count > 0)'; + break; + + case AGENT_STATUS_WARNING: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count > 0 + AND tmetaconsole_agent.total_count > 0)'; + break; + + case AGENT_STATUS_CRITICAL: + $status_agent = ' AND tmetaconsole_agent.critical_count > 0'; + break; + + case AGENT_STATUS_UNKNOWN: + $status_agent = ' AND ( + tmetaconsole_agent.critical_count = 0 + AND tmetaconsole_agent.warning_count = 0 + AND tmetaconsole_agent.unknown_count > 0)'; + break; + + case AGENT_STATUS_NOT_NORMAL: + $status_agent = ' AND ( + tmetaconsole_agent.normal_count <> total_count + OR tmetaconsole_agent.total_count = notinit_count)'; + break; + + case AGENT_STATUS_NOT_INIT: + $status_agent = ' AND ( + tmetaconsole_agent.total_count = 0 + OR tmetaconsole_agent.total_count = notinit_count)'; + break; + + default: + // Nothing to do. + break; + } + } + + $sql = sprintf( + 'SELECT tgrupo.id_grupo AS gid, + tgrupo.nombre as name, + tgrupo.parent, + tgrupo.icon + FROM tgrupo + %s + WHERE 1=1 + %s + %s + %s ', + $inner_agent, + $search_agent, + $status_agent, + $group_acl + ); + } else { + if (users_can_manage_group_all('AR') === false) { + $user_groups_str = implode(',', $this->userGroupsArray); + $group_acl = sprintf( + 'AND id_grupo IN (%s)', + $user_groups_str + ); + } + + $sql = sprintf( + 'SELECT id_grupo AS gid, + nombre as name, + parent, + icon + FROM tgrupo + WHERE 1=1 + %s ', + $group_acl ); } - $sql = sprintf( - 'SELECT id_grupo AS gid, - nombre as name, - parent, - icon - FROM tgrupo - WHERE 1=1 %s', - $group_acl - ); - $stats = db_get_all_rows_sql($sql); $group_stats = []; foreach ($stats as $group) { diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..f7457b3d3c 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4856,4 +4856,25 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $agent_contact .= html_print_table($table_contact, true); return $agent_contact; +} + + +/** + * Return an array with a list of status agents + * + * @return array. + */ + + +function agents_status_list() +{ + $status_list = []; + $status_list[AGENT_STATUS_NORMAL] = __('Normal'); + $status_list[AGENT_STATUS_WARNING] = __('Warning'); + $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); + $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); + $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); + $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); + + return $status_list; } \ No newline at end of file From e980e60025ed8370ec5efbc92f1621774c63f38d Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 6 Oct 2023 14:33:06 +0200 Subject: [PATCH 103/414] changed behavior of prediction modules creation --- .../module_manager_editor_prediction.php | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index eb85a05618..ff5043fd33 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -131,9 +131,10 @@ if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { } $data = []; -$data[0] = __('Agent'); -$data[1] = __('Module'); -$data[2] = __('Period'); + +$data[0] = __('Module'); +$data[1] = __('Period'); + $table_simple->cellclass['caption_prediction_module'][0] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][1] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][2] = 'w33p'; @@ -163,34 +164,61 @@ $params['none_module_text'] = __('Select Module'); $params['use_hidden_input_idagent'] = true; $params['input_style'] = 'width: 100%;'; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; -$data[0] = ui_print_agent_autocomplete_input($params); -if ($id_agente > 0) { - $predictionModuleInput = html_print_select_from_sql( - 'SELECT id_agente_modulo, nombre - FROM tagente_modulo - WHERE delete_pending = 0 - AND history_data = 1 - AND id_agente = '.$id_agente_clean.' - AND id_agente_modulo <> '.$id_agente_modulo, +if (strstr($page, 'policy_modules') === false) { + $modules = agents_get_modules($id_agente); + + $predictionModuleInput = html_print_select( + $modules, 'prediction_module', $prediction_module, '', - __('Select Module'), + '', 0, true, false, true, + '', false, - 'width: 100%;' + false, + false, + false, + false, + '', + false, + false, + true ); } else { - $predictionModuleInput = ''; + $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); + + $predictionModuleInput = html_print_select( + $modules, + 'id_module_policy', + $module['custom_integer_1'], + '', + '', + 0, + true, + false, + true, + '', + false, + false, + false, + false, + false, + '', + false, + false, + true + ); } -$data[1] = $predictionModuleInput; -$data[2] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); -$data[2] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); +$data[0] = $predictionModuleInput; +$data[1] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); +$data[1] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); + $table_simple->cellclass['prediction_module'][0] = 'w33p'; $table_simple->cellclass['prediction_module'][1] = 'w33p'; $table_simple->cellclass['prediction_module'][2] = 'w33p'; From 041a13cb49ee75353fcf9dc304b350f18cc77643 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 9 Oct 2023 16:03:04 +0200 Subject: [PATCH 104/414] #12206 User password change limitation to local --- pandora_console/general/login_page.php | 2 +- .../godmode/users/configure_user.php | 116 +++++++++--------- 2 files changed, 61 insertions(+), 57 deletions(-) diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index e18d278ac8..bbc499661f 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -418,7 +418,7 @@ switch ($login_screen) { } if ($config['enterprise_installed']) { - if ($config['reset_pass_option']) { + if ($config['reset_pass_option'] && $config['auth'] === 'mysql') { $reset_pass_link = 'reset_pass.php'; // Reset password link. echo '
'; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 08040f839c..e4edb3765e 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -688,23 +688,55 @@ if ($update_user) { $id_user = (string) get_parameter('id_user', ''); if ($password_new != '') { - $correct_password = false; + if ($config['auth'] !== 'mysql') { + ui_print_error_message(__('It is not possible to change the password because external authentication is being used')); + } else { + $correct_password = false; - $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); + $user_credentials_check = process_user_login($id_user, $own_password_confirm, true); - if ($user_credentials_check !== false) { - $correct_password = true; - } + if ($user_credentials_check !== false) { + $correct_password = true; + } - if ((string) $password_confirm === (string) $password_new) { - if ($correct_password === true || is_user_admin($config['id_user'])) { - if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { - $pass_ok = login_validate_pass($password_new, $id, true); - if ($pass_ok != 1) { - ui_print_error_message($pass_ok); + if ((string) $password_confirm === (string) $password_new) { + if ($correct_password === true || is_user_admin($config['id_user'])) { + if ((is_user_admin($config['id_user']) === false || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) { + $pass_ok = login_validate_pass($password_new, $id, true); + if ($pass_ok != 1) { + ui_print_error_message($pass_ok); + } else { + $res2 = update_user_password($id, $password_new); + if ($res2) { + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password updated', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + $res3 = save_pass_history($id, $password_new); + + // Generate new API token. + $newToken = api_token_generate(); + $res4 = update_user($id, ['api_token' => $newToken]); + } + + ui_print_result_message( + $res1 || $res2, + __('User info successfully updated'), + __('Error updating user info (no change?)') + ); + } } else { $res2 = update_user_password($id, $password_new); if ($res2) { + $res3 = save_pass_history($id, $password_new); db_process_sql_insert( 'tsesion', [ @@ -717,7 +749,6 @@ if ($update_user) { 'utimestamp' => time(), ] ); - $res3 = save_pass_history($id, $password_new); // Generate new API token. $newToken = api_token_generate(); @@ -731,54 +762,27 @@ if ($update_user) { ); } } else { - $res2 = update_user_password($id, $password_new); - if ($res2) { - $res3 = save_pass_history($id, $password_new); - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password updated', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - - // Generate new API token. - $newToken = api_token_generate(); - $res4 = update_user($id, ['api_token' => $newToken]); + if ($own_password_confirm === '') { + ui_print_error_message(__('Password of the active user is required to perform password change')); + } else { + ui_print_error_message(__('Password of active user is not correct')); } - - ui_print_result_message( - $res1 || $res2, - __('User info successfully updated'), - __('Error updating user info (no change?)') - ); } } else { - if ($own_password_confirm === '') { - ui_print_error_message(__('Password of the active user is required to perform password change')); - } else { - ui_print_error_message(__('Password of active user is not correct')); - } + db_process_sql_insert( + 'tsesion', + [ + 'id_sesion' => '', + 'id_usuario' => $id, + 'ip_origen' => $_SERVER['REMOTE_ADDR'], + 'accion' => 'Password change', + 'descripcion' => 'Access password update failed', + 'fecha' => date('Y-m-d H:i:s'), + 'utimestamp' => time(), + ] + ); + ui_print_error_message(__('Passwords does not match')); } - } else { - db_process_sql_insert( - 'tsesion', - [ - 'id_sesion' => '', - 'id_usuario' => $id, - 'ip_origen' => $_SERVER['REMOTE_ADDR'], - 'accion' => 'Password change', - 'descripcion' => 'Access password update failed', - 'fecha' => date('Y-m-d H:i:s'), - 'utimestamp' => time(), - ] - ); - ui_print_error_message(__('Passwords does not match')); } } else { $has_skin = false; From eacecb4b8f55f0de38ec37c6c46c56c113b663e7 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 10 Oct 2023 10:50:56 +0200 Subject: [PATCH 105/414] #12062 Fix module plugin --- .../godmode/agentes/module_manager_editor_plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 970a2c4d9f..9b5d98c27d 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -171,7 +171,7 @@ foreach ($password_fields as $k => $p) { } $(document).ready(function () { - if ($("#id_plugin").val() === 0) { + if ($("#id_plugin").val() !== 0) { changePluginSelect(); } }); From 8c45c9a234bfbae3b56683a17b240d1d3351846f Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 10 Oct 2023 11:12:25 +0200 Subject: [PATCH 106/414] #12213 Fix warp update button --- pandora_console/include/functions_menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 346dee04b5..a67892a6f1 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -1003,7 +1003,7 @@ if (is_ajax()) { $dialogButtons = []; $dialogButtons[] = html_print_button( - __('Update manager'), + __('Warp update'), 'update_manager', false, 'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"', From 813a5ecd0d8850ed86fb723b647d9cf051071796 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 10 Oct 2023 11:34:47 +0200 Subject: [PATCH 107/414] #12168 Fixed filter to show the service genealogy --- .../include/class/TreeService.class.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index b30877a5b5..d45ce50573 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -731,7 +731,26 @@ class TreeService extends Tree if (isset($this->filter['searchService']) === true && empty($this->filter['searchService']) === false ) { - return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')"; + $sqlFilter = 'SELECT ts.id FROM tservice ts + where ts.name LIKE "%'.$this->filter['searchService'].'%" + OR ts.description LIKE "%'.$this->filter['searchService'].'%"'; + + $filterResult = db_get_all_rows_sql($sqlFilter); + + foreach ($filterResult as $key => $result) { + $ancestors = services_get_services_ancestors($result['id']); + $idAncestors = implode(',', $ancestors); + $numAncestors = count($ancestors); + if ($numAncestors > 1) { + $whereAncestors = ' AND tse.id_service_child in ('.$idAncestors.')'; + } else if ($numAncestors == 1) { + $whereAncestors = ' AND ts.id ='.$idAncestors; + } else { + $whereAncestors = ' AND ts.id ='.$result['id']; + } + } + + return $whereAncestors; } return ''; From 1c1d2cf1c1f8540e3261a7e57ca60d7e7c2e39e9 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 10 Oct 2023 16:35:36 +0200 Subject: [PATCH 108/414] #12208 Improve widget html editor --- .../include/lib/Dashboard/Widgets/post.php | 7 +++-- pandora_console/include/styles/form.css | 4 +-- .../views/dashboard/configurationWidgets.php | 31 +++++++++---------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/post.php b/pandora_console/include/lib/Dashboard/Widgets/post.php index d6274e279d..df20869780 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/post.php +++ b/pandora_console/include/lib/Dashboard/Widgets/post.php @@ -221,9 +221,10 @@ class PostWidget extends Widget 'type' => 'textarea', 'value' => $values['text'], 'return' => true, - 'rows' => 1, - 'columns' => 1, + 'rows' => 25, + 'columns' => 100, 'size' => 25, + 'style' => 'display: none;', ], ]; @@ -296,7 +297,7 @@ class PostWidget extends Widget public function getSizeModalConfiguration(): array { $size = [ - 'width' => 500, + 'width' => 1000, 'height' => 500, ]; diff --git a/pandora_console/include/styles/form.css b/pandora_console/include/styles/form.css index a0e5957358..c212d459f6 100644 --- a/pandora_console/include/styles/form.css +++ b/pandora_console/include/styles/form.css @@ -279,8 +279,8 @@ form.modal ul.wizard li { flex-wrap: nowrap; } -form.modal-dashboard ul.wizard li *, -form.modal ul.wizard li *:not(.tox.tox-tinymce *) { +form.modal-dashboard ul.wizard li > *, +form.modal ul.wizard li > *:not(.tox.tox-tinymce *) { flex: 1 1 50%; } diff --git a/pandora_console/views/dashboard/configurationWidgets.php b/pandora_console/views/dashboard/configurationWidgets.php index f985517f4f..68a51edbaa 100644 --- a/pandora_console/views/dashboard/configurationWidgets.php +++ b/pandora_console/views/dashboard/configurationWidgets.php @@ -28,15 +28,11 @@ // Includes. require_once $config['homedir'].'/include/class/HTML.class.php'; +ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/', true); +ui_require_javascript_file('pandora', 'include/javascript/', true); $output = ''; -$output .= ui_require_javascript_file( - 'tiny_mce', - 'include/javascript/tiny_mce/', - true -); - $form = [ 'action' => '#', 'method' => 'POST', @@ -47,6 +43,18 @@ $form = [ 'extra' => 'novalidate', ]; +$js = 'tinymce.init({ + selector: "#textarea_text", + plugins: "preview, searchreplace, table, nonbreaking, link, image", + promotion: false, + branding: false, + setup: function (editor) { + editor.on("change", function () { + tinymce.triggerSave(); + }) + } +});'; + HTML::printForm( [ 'form' => $form, @@ -56,15 +64,4 @@ HTML::printForm( ] ); -$output .= ''; echo $output; From 3a2b56cc4c171616d626362812a707f6494c9d5f Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 10 Oct 2023 16:50:42 +0200 Subject: [PATCH 109/414] #12204 Fix force check icon --- pandora_console/include/ajax/module.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 78daacb0a0..3c65200ae6 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1354,10 +1354,12 @@ if (check_login()) { $additionalLinkAction = '&flag=1'; $linkCaption = __('Force checks'); $imgaction = 'images/force@svg.svg'; + $visibility = ''; } else { $additionalLinkAction = ''; $linkCaption = __('Refresh'); $imgaction = 'images/go-back@svg.svg'; + $visibility = 'visibility: initial;'; } $moduleActionButtons[] = html_print_anchor( @@ -1369,6 +1371,7 @@ if (check_login()) { [ 'title' => __('Force remote check'), 'class' => 'main_menu_icon forced_title', + 'style' => $visibility, ] ), ], From f058ec5df83826d538aa30cb353d1b714e1e5964 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 08:12:55 +0200 Subject: [PATCH 110/414] #12213 Fix warp update notification --- pandora_console/include/class/ConsoleSupervisor.php | 2 +- pandora_console/operation/menu.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index a434a30e7f..b054f3362b 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -2391,7 +2391,7 @@ class ConsoleSupervisor $this->notify( [ 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Update manager section'), + 'title' => __('This instance is not registered in the Warp Update section'), 'message' => __('Click here to start the registration process'), 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', ] diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 6b98ffb55b..467348f6c9 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -770,7 +770,7 @@ if ($access_console_node === true) { // Check if was displayed inside other menu. if ($extension['operation_menu']['fatherId'] == '') { - if ($extension_menu['name'] == 'Update manager') { + if ($extension_menu['name'] == 'Warp update') { continue; } From e7fb3d50442780a19a54e55543061a5e1378ca46 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 08:14:00 +0200 Subject: [PATCH 111/414] #12213 Fix warp update notification --- pandora_console/include/functions_notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index b9393ce1c4..d9ac1c9f38 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -1059,7 +1059,7 @@ function notification_filter() break; case 'UPDATEMANAGER': - $type_name = 'UPDATE MANAGER'; + $type_name = 'WARP UPDATE'; break; case 'ALLOWOVERRIDE': From a8713264e289f4e746ef1e7ce460f81a5da9233e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 11 Oct 2023 09:55:44 +0200 Subject: [PATCH 112/414] #10807 fixed GIS MAP creation/editing view styles --- .../godmode/gis_maps/configure_gis_map.php | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index a6f282d2cf..f3f7d06d21 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -560,21 +560,23 @@ html_print_table($table); $user_groups = users_get_groups($config['user'], 'AR', false); -echo '

'.__('Layers').'

'; +echo '
'.__('Layers').''; $table->width = '100%'; $table->class = 'databox filters'; $table->valign = []; -$table->valign[0] = 'top'; -$table->valign[1] = 'top'; +$table->valign[0] = 'top; width: 50%'; +$table->valign[1] = 'top; width: 50%'; $table->data = []; $table->data[0][0] = '

'.__('List of layers').'

'; $table->data[0][1] = '
'.html_print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub add "', true).'
'; -$table->data[1][0] = '
'; -$table->data[1][1] = '
'; switch ($action) { case 'save_new': @@ -1229,6 +1233,8 @@ function getLayerRow (layerId, layerData) { .append($editCol) .append($deleteCol); + $("#list_layers").removeClass('invisible'); + return $row; } From 3e20ff7eaad11e8a8e19c4eef0bdc05a5a856b8c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 09:59:26 +0200 Subject: [PATCH 113/414] #12218 Fix show hide password button --- pandora_console/godmode/users/user_management.php | 12 +++++++----- pandora_console/include/styles/pandora.css | 8 +++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 6d5f9bf18b..167b7756ce 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -266,7 +266,7 @@ $passwordManageTable->data = []; $passwordManageTable->data['captions_newpassword'][0] = __('New password'); $passwordManageTable->rowclass['fields_newpassword'] = 'w540px'; -$passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_newpassword'][0] = '
'.html_print_input_text_extended( 'password_new', '', 'password_new', @@ -276,16 +276,17 @@ $passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_exte $view_mode, '', [ - 'class' => 'input w100p', + 'class' => 'input', 'placeholder' => __('Password'), + 'style' => 'width: 540px', ], true, true -); +).'
'; $passwordManageTable->data['captions_repeatpassword'][0] = __('Repeat new password'); $passwordManageTable->rowclass['fields_repeatpassword'] = 'w540px'; -$passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_extended( +$passwordManageTable->data['fields_repeatpassword'][0] = '
'.html_print_input_text_extended( 'password_confirm', '', 'password_conf', @@ -297,10 +298,11 @@ $passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_e [ 'class' => 'input w100p', 'placeholder' => __('Password confirmation'), + 'style' => 'width: 540px', ], true, true -); +).'
'; if ($new_user === false && users_is_admin() === false) { $passwordManageTable->data['captions_currentpassword'][0] = __('Current password'); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 45cacafb6b..fe6f22b23b 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11763,16 +11763,14 @@ p.trademark-copyright { } .show-hide-pass { - position: absolute; - right: 9px; - top: 4px; + position: fixed; border: 0; outline: none; - margin: 0; + margin-left: -50px; height: 30px; width: 40px; cursor: pointer; - display: inline-block; + display: initial; } .show-hide-pass-background { From a7436efd8c4370c73e917185bc2d9e87f433c080 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 13:31:25 +0200 Subject: [PATCH 114/414] #12219 Fix delete last user profile --- .../godmode/users/configure_user.php | 272 +++++++++++------- pandora_console/include/functions_profile.php | 2 +- 2 files changed, 173 insertions(+), 101 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 08040f839c..b313589403 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -157,14 +157,100 @@ if (is_ajax() === true) { return; } + + if ($delete_profile) { + $id2 = (string) get_parameter('id_user'); + $id_up = (int) get_parameter('id_user_profile'); + $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); + $id_perfil = $perfilUser['id_perfil']; + $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); + + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + 'Deleted profile for user '.io_safe_output($id2), + false, + false, + 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] + ); + + $return = profile_delete_user_profile($id2, $id_up); + ui_print_result_message( + $return, + __('Successfully deleted'), + __('Could not be deleted') + ); + + + $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2); + $user_is_global_admin = users_is_admin($id2); + $delete_user_profile = (bool) get_parameter('delete_user_profile', false); + + if ($has_profile === false && $user_is_global_admin === false && $delete_user_profile === true) { + $result = delete_user($id2); + + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s', io_safe_output($id_user)) + ); + } + + ui_print_result_message( + $result, + __('Successfully deleted'), + __('There was a problem deleting the user') + ); + + // Delete the user in all the consoles. + if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + // Connect to the remote console. + metaconsole_connect($server); + + // Delete the user. + $result = delete_user($id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s from metaconsole', io_safe_output($id_user)) + ); + } + + // Restore the db connection. + metaconsole_restore_db(); + + // Log to the metaconsole too. + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __( + 'Deleted user %s from %s', + io_safe_input($id_user), + io_safe_input($server['server_name']) + ) + ); + } + + ui_print_result_message( + $result, + __('Successfully deleted from %s', io_safe_input($server['server_name'])), + __('There was a problem deleting the user from %s', io_safe_input($server['server_name'])) + ); + } + } + + return $result; + } + + return $return; + } } $tab = get_parameter('tab', 'user'); - // Save autorefresh list. $autorefresh_list = (array) get_parameter_post('autorefresh_list'); $autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list); - // Header. if (is_metaconsole() === true) { user_meta_print_header(); @@ -197,11 +283,11 @@ if (is_metaconsole() === true) { ).'
', ], ]; - $buttons[$tab]['active'] = true; } $edit_user = get_parameter('edit_user'); + ui_print_standard_header( ($edit_user) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), 'images/gm_users.png', @@ -224,11 +310,9 @@ if (is_metaconsole() === true) { ], ] ); - $sec = 'gusuarios'; } - if ((bool) $config['user_can_update_info'] === true) { $view_mode = false; } else { @@ -864,89 +948,6 @@ if ($update_user) { $user_info = $values; } -if ($delete_profile) { - $id2 = (string) get_parameter('id_user'); - $id_up = (int) get_parameter('id_user_profile'); - $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); - $id_perfil = $perfilUser['id_perfil']; - $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); - - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - 'Deleted profile for user '.io_safe_output($id2), - false, - false, - 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] - ); - - $return = profile_delete_user_profile($id2, $id_up); - ui_print_result_message( - $return, - __('Successfully deleted'), - __('Could not be deleted') - ); - - - $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2); - $user_is_global_admin = users_is_admin($id2); - - if ($has_profile === false && $user_is_global_admin === false) { - $result = delete_user($id2); - - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s', io_safe_output($id_user)) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted'), - __('There was a problem deleting the user') - ); - - // Delete the user in all the consoles. - if (is_metaconsole() === true) { - $servers = metaconsole_get_servers(); - foreach ($servers as $server) { - // Connect to the remote console. - metaconsole_connect($server); - - // Delete the user. - $result = delete_user($id_user); - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s from metaconsole', io_safe_output($id_user)) - ); - } - - // Restore the db connection. - metaconsole_restore_db(); - - // Log to the metaconsole too. - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __( - 'Deleted user %s from %s', - io_safe_input($id_user), - io_safe_input($server['server_name']) - ) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted from %s', io_safe_input($server['server_name'])), - __('There was a problem deleting the user from %s', io_safe_input($server['server_name'])) - ); - } - } - } -} - if ((int) $status !== -1) { ui_print_result_message( $status, @@ -1157,6 +1158,13 @@ if (is_user_admin($id) === true) { ); } +html_print_div( + [ + 'id' => 'delete_profile_modal', + 'content' => '', + ] +); + $full_name = '
'.html_print_input_text_extended( 'fullname', $user_info['fullname'], @@ -1995,24 +2003,88 @@ if (is_metaconsole() === false) { } }); }); - + $('input:image[name="del"]').click(function(e) { - if ($(json_profile).length > 0) return; - if (!confirm('Are you sure?')) return; - e.preventDefault(); - var rows = $("#table_profiles tr").length; - if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { - if (!confirm('' + '. ' + '')) { - return; - } - } + + var rows = $("#table_profiles tr").length; + let deleteuser = 0; + e.preventDefault(); var id_user_profile = $(this).siblings(); id_user_profile = id_user_profile[1].value; var row = $(this).closest('tr'); + if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') { + $("#delete_profile_modal") + .empty() + .html(""); + // Set the title. + $("#delete_profile_modal").prop("title", ""); + // Build the dialog for show the mesage. + $("#delete_profile_modal").dialog({ + resizable: true, + draggable: true, + modal: true, + width: 500, + buttons: [ + { + text: "Cancel", + click: function() { + $(this).dialog("close"); + return false; + } + }, + { + text: "Delete", + click: function() { + $(this).dialog("close"); + deleteuser = 1; + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + }, + { + text: "Preserve", + click: function() { + $(this).dialog("close"); + deleteuser = 0; + delete_user_profile(id_user_profile, row, id_user, deleteuser) + } + } + ], + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: false, + open: function(event, ui) { + $(".ui-dialog-titlebar-close").hide(); + } + }); + } else { + if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { + if (!confirm('' + '. ' + '')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } else { + if (!confirm('Are you sure?')) { + return false; + } else { + delete_user_profile(id_user_profile, row, id_user, deleteuser); + } + } + } + + if ($(json_profile).length > 0) return; + }); + + function delete_user_profile(id_user_profile, row, id_user, deleteuser){ + var params = []; params.push("delete_profile=1"); + params.push("edit_user=1"); + params.push("delete_user_profile=" + deleteuser); params.push("id_user=" + id_user); params.push("id_user_profile=" + id_user_profile); params.push("page=godmode/users/configure_user"); @@ -2024,14 +2096,14 @@ if (is_metaconsole() === false) { row.remove(); var rows = $("#table_profiles tr").length; - if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1') { + if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); } else if (is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1') { window.location.replace(""); } } }); - }); + } function checkProfiles(e) { e.preventDefault(); diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 7cdbd1c461..e4415b3ca1 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -316,7 +316,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ] ); } else { - $data['actions'] = '
'; + $data['actions'] = ''; $data['actions'] .= html_print_input_image('del', 'images/delete.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']); $data['actions'] .= html_print_input_hidden('delete_profile', 1, true); $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true); From c9966ed9999947744e1c52eeb6add9bc8f9b0312 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 16:16:22 +0200 Subject: [PATCH 115/414] #12132 Limit tips --- pandora_console/include/javascript/tipsWindow.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/tipsWindow.js b/pandora_console/include/javascript/tipsWindow.js index 94d28c9339..c68e7c9b05 100644 --- a/pandora_console/include/javascript/tipsWindow.js +++ b/pandora_console/include/javascript/tipsWindow.js @@ -134,8 +134,9 @@ function render_counter() { $(".counter-tips img:eq(0)").after( "" ); + var limitRound = totalTips > 28 ? 28 : totalTips; if (totalTips > 1) { - for (let i = 1; i <= totalTips - 1; i++) { + for (let i = 1; i <= limitRound - 1; i++) { $(".count-round-tip:eq(0)").after( "" ); From fbe2629de362d4dd1653eacdeff6522f03ce27d6 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 13 Oct 2023 10:39:33 +0200 Subject: [PATCH 116/414] fix policy synthetic module form --- .../godmode/agentes/module_manager_editor_prediction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index ff5043fd33..e8fee22a87 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -292,7 +292,7 @@ if ($selector_form !== ENTERPRISE_NOT_HOOK) { } // Synthetic modules are an Enterprise feature. -$synthetic_module_form = enterprise_hook('get_synthetic_module_form'); +$synthetic_module_form = enterprise_hook('get_synthetic_module_form', [$policy_id]); if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; $data[0] = $synthetic_module_form; From 2062169f2f26f9e7b81f42f647558f60cc36d879 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 13 Oct 2023 12:55:58 +0200 Subject: [PATCH 117/414] #12177 Fix upload os icon --- pandora_console/godmode/setup/os.builder.php | 52 +++++++++++++++++--- pandora_console/godmode/setup/os.php | 8 ++- pandora_console/include/functions_html.php | 4 +- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index d8a2f47d00..0a8c23a08d 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -46,7 +46,7 @@ if ($idOS > 0) { $description = $os['description']; $icon = $os['icon_name']; } else { - $name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); + $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $icon = get_parameter('icon', 0); } @@ -87,9 +87,16 @@ if ($is_management_allowed === true) { if (in_array($file_ext, $allowed_extensions) === false) { $message = 9; + } else if (exif_imagetype($file_tmp) === false && $file_ext !== 'svg') { + $message = 10; } else { $message = 8; - move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + $file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + if ($file_uploaded !== true) { + $message = 10; + } } } } else { @@ -108,7 +115,7 @@ if ($is_management_allowed === true) { if ($resultOrId === false) { $message = 2; - $tab = 'builder'; + $tab = 'manage_os'; $actionHidden = 'save'; $textButton = __('Create'); $classButton = ['icon' => 'wand']; @@ -144,13 +151,19 @@ if ($is_management_allowed === true) { if (in_array($file_ext, $allowed_extensions) === false) { $message = 9; + } else if (exif_imagetype($file_tmp) === false) { + $message = 10; } else { $message = 8; - move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + $file_uploaded = move_uploaded_file($file_tmp, $config['homedir'].'/images/os_icons/'.$file_name); + + if ($file_uploaded !== true) { + $message = 10; + } } } } else { - $name = io_safe_input(strip_tags(io_safe_output((string) get_parameter('name')))); + $name = io_safe_input(strip_tags(trim(io_safe_output((string) get_parameter('name'))))); $description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description')))); $icon = get_parameter('icon', 0); @@ -254,7 +267,7 @@ $table->class = 'databox filter-table-adv'; $table->data[0][] = html_print_label_input_block( __('Name'), - html_print_input_text('name', $name, __('Name'), 20, 30, true, false, false, '', 'w250px') + html_print_input_text('name', $name, __('Name'), 20, 30, true, false, true, '', 'w250px') ); $table->data[0][] = html_print_label_input_block( @@ -290,6 +303,33 @@ html_print_action_buttons( echo ''; +$id_message = get_parameter('id_message', 0); + +if ($id_message !== 0) { + switch ($id_message) { + case 8: + echo ui_print_success_message(__('Icon successfuly uploaded'), '', true); + break; + + case 9: + echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); + break; + + case 9: + echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); + break; + + case 10: + echo ui_print_error_message(__('An error ocurrered to load icon'), '', true); + break; + + default: + // Nothing to do. + break; + } +} + + function get_list_os_icons_dir() { global $config; diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index 99402ff30a..dcfe95ecdb 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -162,11 +162,15 @@ if (empty($id_message) === false) { break; case 8: - echo ui_print_success_message(__('Icon successfuly uploaded'), '', true); + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=8'); break; case 9: - echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=9'); + break; + + case 10: + header('Location: index.php?sec=gagente&sec2=godmode/setup/os&tab=manage_os&action=edit&id_message=10'); break; default: diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 2552fbcdc1..2dac62a3ee 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4939,8 +4939,8 @@ function html_print_input_file($name, $return=false, $options=false, $inline_upl $inline_upload_anchor_to_form ), [ - 'mode' => 'link', - 'style' => 'min-width: initial;', + 'class' => 'secondary', + 'style' => 'min-width: initial; position: relative; margin-left: 5%; ', ], true, ); From 35efc20fc78aa9c93de7ad95a827e12d894668ab Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 13 Oct 2023 12:58:21 +0200 Subject: [PATCH 118/414] #12177 Fix message --- pandora_console/godmode/setup/os.builder.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index 0a8c23a08d..6313aa3edd 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -315,12 +315,8 @@ if ($id_message !== 0) { echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); break; - case 9: - echo ui_print_error_message(__('File must be of type JPG, JPEG, PNG or SVG'), '', true); - break; - case 10: - echo ui_print_error_message(__('An error ocurrered to load icon'), '', true); + echo ui_print_error_message(__('An error ocurrered to upload icon'), '', true); break; default: From c67a8ba25d09033756afa38af41113812dfbc20a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 13 Oct 2023 14:31:17 +0200 Subject: [PATCH 119/414] remove required --- .../godmode/agentes/module_manager_editor_prediction.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index e8fee22a87..a2806c5781 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -186,8 +186,7 @@ if (strstr($page, 'policy_modules') === false) { false, '', false, - false, - true + false ); } else { $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); From 276cfb672ce4765dd2cf97f93c39afdca439fcbb Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 16 Oct 2023 09:01:41 +0200 Subject: [PATCH 120/414] #12157 Add subtype to messages --- pandora_console/include/functions_messages.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 189844c174..fe35d5b5a6 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -122,6 +122,7 @@ function messages_create_message( 'id_usuario_origen' => $usuario_origen, 'subject' => $subject, 'mensaje' => $mensaje, + 'subtype' => 'NOTIF.MESSAGE', 'id_source' => get_notification_source_id('message'), 'timestamp' => get_system_time(), ] From a456912dd7457fdd39284c965755a6b667c5b297 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 16 Oct 2023 12:17:42 +0200 Subject: [PATCH 121/414] #12132 Fix welcome tips --- pandora_console/extras/mr/68.sql | 7 +++++++ pandora_console/include/class/TipsWindow.class.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 pandora_console/extras/mr/68.sql diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql new file mode 100644 index 0000000000..3095941187 --- /dev/null +++ b/pandora_console/extras/mr/68.sql @@ -0,0 +1,7 @@ +START TRANSACTION; + +DELETE FROM `twelcome_tip` WHERE `title` = 'Automatic agent provision system'; + +INSERT INTO `twelcome_tip` (`id_lang`,`id_profile`,`title`,`text`,`url`,`enable`) VALUES ('en_GB',0,'Automatic agent provision system','The agent self-provisioning system allows an agent recently entered into the system to automatically apply changes to their configuration (such as moving them from group, assigning them certain values in custom fields) and of course applying certain monitoring policies. It is one of the most powerful functionalities, aimed at managing very large system parks.','https://pandorafms.com/manual/start?id=en/documentation/02_installation/05_configuration_agents#conf',1); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php index ae4271fba9..56082611ea 100644 --- a/pandora_console/include/class/TipsWindow.class.php +++ b/pandora_console/include/class/TipsWindow.class.php @@ -744,7 +744,7 @@ class TipsWindow ); $table->data[1][1] = html_print_label_input_block( __('Url'), - html_print_input_text('url', '', '', 35, 100, true) + html_print_input_text('url', '', '', 35, 255, true) ); $table->data[2][0] = html_print_label_input_block( __('Text'), @@ -911,7 +911,7 @@ class TipsWindow ); $table->data[1][1] = html_print_label_input_block( __('Url'), - html_print_input_text('url', $tip['url'], '', 35, 100, true) + html_print_input_text('url', $tip['url'], '', 35, 255, true) ); $table->data[2][0] = html_print_label_input_block( __('Text'), From 172fd835476b4a6fb8751701e01f60474560cb52 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 16 Oct 2023 15:18:04 +0200 Subject: [PATCH 122/414] #11846 change list elements update post json --- .../visual_console_builder.elements.php | 88 +++++++++++++-- .../reporting/visual_console_builder.php | 105 ++++++++++++++++++ 2 files changed, 181 insertions(+), 12 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index 300ea33f40..c4f83e2d02 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -539,6 +539,7 @@ foreach ($layoutDatas as $layoutData) { $table->data[($i + 1)][5] .= html_print_checkbox('multiple_delete_items', $idLayoutData, false, true); $table->data[($i + 1)][5] .= ''.html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).''; $table->data[($i + 1)][5] .= html_print_input_hidden('updated_'.$idLayoutData, '0', true); + $table->data[($i + 1)][5] .= html_print_input_hidden('rowtype_'.$idLayoutData, $layoutData['type'], true); // Second row $table->data[($i + 2)]['icon'] = ''; @@ -789,14 +790,6 @@ if ($x > ini_get('max_input_vars')) { $pure = get_parameter('pure', 0); -if (is_metaconsole() === false) { - echo '
'; - html_print_input_hidden('action', 'update'); -} else { - echo ""; - html_print_input_hidden('action2', 'update'); -} - html_print_table($table); // Form for multiple delete. @@ -806,15 +799,14 @@ if (is_metaconsole() === false) { $url_multiple_delete = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&tab='.$activeTab.'&id_visual_console='.$visualConsole['id']; } -echo '
'; - $buttons = html_print_submit_button( __('Update'), 'go', false, [ - 'icon' => 'next', - 'form' => 'vc_elem_form', + 'icon' => 'next', + 'form' => 'vc_elem_form', + 'onclick' => 'submit_update_json()', ], true ); @@ -976,4 +968,76 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/'); return false; } + + function submit_update_json() { + var array_update = []; + $('input[id^=hidden-updated_]').each(function(){ + var id = $(this).attr('id').split('_')[1]; + + var label = $('#hidden-label_'+id).val(); + var image = $('#image_'+id).val(); + var width = $('#text-width_'+id).val(); + var height = $('#text-height_'+id).val(); + var pos_x = $('#text-left_'+id).val(); + var pos_y = $('#text-top_'+id).val(); + var parent = $('#parent_'+id).val(); + var agent = $('#hidden-agent_'+id).val(); + var module = $('#module_'+id).val(); + var period = $('#hidden-period_'+id).val(); + var map_linked = $('#map_linked_'+id).val(); + var id_server = $('#id_server_id_'+id).val(); + var rowtype = $('rowtype_'+id).val(); + var custom_graph = $('#custom_graph_'+id).val(); + + array_update.push({ + 'id': id, + 'label': label, + 'image': image, + 'width': width, + 'height': height, + 'pos_x': pos_x, + 'pos_y': pos_y, + 'parent': parent, + 'agent': agent, + 'module': module, + 'period': period, + 'map_linked': map_linked, + 'rowtype': rowtype, + 'custom_graph': custom_graph, + 'id_server': id_server, + }); + }); + + var background_width = $('#text-width').val(); + var background_height = $('#text-height').val(); + + if (background_height > 0 && background_width > 0){ + $.ajax({ + type: "POST", + url: "ajax.php", + data: { + page: "godmode/reporting/visual_console_builder", + action: "update_json", + tab: "list_elements", + array_update: JSON.stringify(array_update), + id_visual_console: "", + background: $('#background').val(), + background_width: $('#text-width').val(), + background_height: $('#text-height').val(), + }, + dataType: "json", + complete: function (data) { + location.reload(); + } + }); + } else { + confirmDialog({ + title: "", + message: "", + strOKButton: "", + hideCancelButton: true, + size: 300, + }); + } + } diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 986dcb423b..fc043228ed 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -78,6 +78,7 @@ $action = get_parameterBetweenListValues( 'update', 'delete', 'multiple_delete', + 'update_json', ], 'new' ); @@ -523,6 +524,110 @@ switch ($activeTab) { } break; + case 'update_json': + // Update background. + $background = get_parameter('background'); + $width = get_parameter('background_width'); + $height = get_parameter('background_height'); + + if ($width == 0 && $height == 0) { + $sizeBackground = getimagesize( + $config['homedir'].'/images/console/background/'.$background + ); + $width = $sizeBackground[0]; + $height = $sizeBackground[1]; + } + + db_process_sql_update( + 'tlayout', + [ + 'background' => $background, + 'width' => $width, + 'height' => $height, + ], + ['id' => $idVisualConsole] + ); + + // Return the updated visual console. + $visualConsole = db_get_row_filter( + 'tlayout', + ['id' => $idVisualConsole] + ); + + // Update elements in visual map. + $idsElements = db_get_all_rows_filter( + 'tlayout_data', + ['id_layout' => $idVisualConsole], + [ + 'id', + 'type', + ] + ); + + $array_update = json_decode(io_safe_output(get_parameter('array_update')), true); + + if (count($array_update)) { + foreach ($array_update as $row) { + $id = $row['id']; + $values = []; + $values['label'] = $row['label']; + $values['image'] = $row['image']; + $values['width'] = $row['width']; + $values['height'] = $row['height']; + $values['pos_x'] = $row['pos_x']; + $values['pos_y'] = $row['pos_y']; + + switch ($row['rowtype']) { + case NETWORK_LINK: + case LINE_ITEM: + continue 2; + + break; + + case SIMPLE_VALUE_MAX: + case SIMPLE_VALUE_MIN: + case SIMPLE_VALUE_AVG: + $values['period'] = $row['period']; + break; + + case MODULE_GRAPH: + $values['period'] = $row['period']; + unset($values['image']); + break; + + case GROUP_ITEM: + $values['id_group'] = $row['group']; + break; + + case CIRCULAR_PROGRESS_BAR: + case CIRCULAR_INTERIOR_PROGRESS_BAR: + case PERCENTILE_BUBBLE: + case PERCENTILE_BAR: + unset($values['height']); + break; + } + + if (defined('METACONSOLE')) { + $values['id_metaconsole'] = $row['id_server']; + } + + $values['id_agent'] = $row['agent']; + $values['id_agente_modulo'] = $row['module']; + $values['id_custom_graph'] = $row['custom_graph']; + $values['parent_item'] = $row['parent']; + $values['id_layout_linked'] = $row['map_linked']; + + if (enterprise_installed()) { + enterprise_visual_map_update_action_from_list_elements($row['rowtype'], $values, $id); + } + + db_process_sql_update('tlayout_data', $values, ['id' => $id]); + } + + return true; + } + break; + case 'delete': $id_element = get_parameter('id_element'); $result = db_process_sql_delete('tlayout_data', ['id' => $id_element]); From be99b512e23cbd717299b6ca5cbb27b40f2c62c3 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 08:41:06 +0200 Subject: [PATCH 123/414] #12137 Fix events graph --- .../agentes/estado_generalagente.php | 67 +++++++++---------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 1b91cf84c1..6bd64a2e78 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -160,6 +160,31 @@ $table_status->data['agent_version'][1] = (empty($agent['agent_version']) === tr $table_status->data['description'][0] = __('Description'); $table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? ''.__('N/A').'' : $agent['comentarios']; +$agentEventsHeader = html_print_div( + [ + 'class' => 'agent_details_header', + 'content' => ''.__('Events (Last 24h)').'', + ], + true +); + +$agentEventsGraph = html_print_div( + [ + 'class' => 'white-table-graph-content', + 'content' => graph_graphic_agentevents( + $id_agente, + 95, + 70, + SECONDS_1DAY, + '', + true, + true, + 500 + ), + ], + true +); + $table_agent = $agentStatusHeader.'
@@ -168,6 +193,9 @@ $table_agent = $agentStatusHeader.'
'.$alive_animation.html_print_table($table_status, true).'
+
+
+ '.$agentEventsHeader.$agentEventsGraph.'
'; @@ -536,39 +564,6 @@ $agentContact = html_print_div( true ); -$agentEventsHeader = html_print_div( - [ - 'class' => 'agent_details_header', - 'content' => ''.__('Events (Last 24h)').'', - ], - true -); - -$agentEventsGraph = html_print_div( - [ - 'class' => 'white-table-graph-content', - 'content' => graph_graphic_agentevents( - $id_agente, - 95, - 70, - SECONDS_1DAY, - '', - true, - true, - 500 - ), - ], - true -); - -$agentEvents = html_print_div( - [ - 'class' => 'box-flat agent_details_col w50p', - 'content' => $agentEventsHeader.$agentEventsGraph, - ], - true -); - /* * EVENTS TABLE END. */ @@ -596,13 +591,13 @@ html_print_div( 'content' => $agentDetails.$agentContact, ] ); - -html_print_div( +/* + html_print_div( [ 'class' => 'agent_details_line', 'content' => $agentEvents.$agentAccessRate, ] -); +);*/ if (empty($agentAdditionalInfo) === false) { html_print_div( From c00445eab0b2872f8733140fadbaf3c4ad647f8e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 09:05:22 +0200 Subject: [PATCH 124/414] #121773 Fix module name in events view --- pandora_console/operation/events/events.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index e7a20b8642..22c3bb8eda 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -540,19 +540,6 @@ if (is_ajax() === true) { ); } - if (empty($tmp->module_name) === false) { - $tmp->module_name = ui_print_truncate_text( - $tmp->module_name, - 'module_medium', - false, - true, - false, - '…', - true, - true, - ); - } - if (empty($tmp->comments) === false) { $tmp->comments = ui_print_comments($tmp->comments, 20); } From 1c609374a83becb228e92bd716704d2579c153e4 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 09:27:53 +0200 Subject: [PATCH 125/414] #12134 Count total modules --- pandora_console/operation/agentes/status_monitor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 046fbc5222..825fbb01df 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -2348,6 +2348,7 @@ if (empty($result) === false) { array_push($table->data, $data); } + echo '
'.sprintf(__('Total items: %s'), $count).'
'; html_print_table($table); if ($count_modules > $config['block_size']) { From 7b443414ca133830dce996ecc5bc5bf246634bfa Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 09:52:56 +0200 Subject: [PATCH 126/414] #12137 Fix graph events height --- .../operation/agentes/estado_generalagente.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 6bd64a2e78..6d87e5055d 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -174,13 +174,14 @@ $agentEventsGraph = html_print_div( 'content' => graph_graphic_agentevents( $id_agente, 95, - 70, + 50, SECONDS_1DAY, '', true, true, 500 ), + 'style' => 'margin-top: -25px', ], true ); @@ -591,13 +592,13 @@ html_print_div( 'content' => $agentDetails.$agentContact, ] ); -/* - html_print_div( + +html_print_div( [ 'class' => 'agent_details_line', 'content' => $agentEvents.$agentAccessRate, ] -);*/ +); if (empty($agentAdditionalInfo) === false) { html_print_div( From 08bccce67367b92acc1250d72d7d28e9279da755 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Tue, 17 Oct 2023 08:28:38 -0600 Subject: [PATCH 127/414] Remove root validation --- pandora_agents/pc/pandora_agent | 11 +---------- pandora_agents/unix/pandora_agent | 9 +-------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/pandora_agents/pc/pandora_agent b/pandora_agents/pc/pandora_agent index aa8208f5d0..04b7de51a5 100644 --- a/pandora_agents/pc/pandora_agent +++ b/pandora_agents/pc/pandora_agent @@ -2185,16 +2185,7 @@ sub configure ($) { #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - if (launch_tentacle_proxy() != 0) { - return 1; - } - } else { - error ('Proxy mode can not be launched as root'); - return 1; - } + return 1 if (launch_tentacle_proxy() != 0); } # Add the plugins directory to the PATH diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index de7a2e6946..d0b7c22ede 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -4183,14 +4183,7 @@ my $PID = $$; #Launch tentacle server in proxy mode if configured if ($Conf{'proxy_mode'}) { - - #Check if user is root - if ($> != 0) { - launch_tentacle_proxy(); - } else { - log_message ('error', 'Proxy mode can not be launched as root'); - exit 1; - } + launch_tentacle_proxy(); } # Advice if YAML::Tiny is allowed in this system From 19abe5f0f6340e3547c9f8345eee5f2553b57a49 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 17 Oct 2023 16:35:58 +0200 Subject: [PATCH 128/414] #9761 remove lines "logstash" --- pandora_console/include/class/ConsoleSupervisor.php | 9 --------- pandora_console/include/functions_notifications.php | 1 - 2 files changed, 10 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index b4320b1a4d..25e298e520 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -394,15 +394,6 @@ class ConsoleSupervisor $this->checkPandoraHistoryDB(); - /* - * Check pandoradb running in main DB. - * Check pandoradb running in historical DB. - * NOTIF.PANDORADB - * NOTIF.PANDORADB.HISTORICAL - */ - - $this->checkPandoraDBMaintenance(); - /* * Check historical DB MR version. * NOTIF.HISTORYDB.MR diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index b9393ce1c4..ea5b57283f 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -141,7 +141,6 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.PANDORADB', 'NOTIF.PANDORADB.HISTORICAL', 'NOTIF.HISTORYDB.MR', - 'NOTIF.EXT.ELASTICSEARCH', 'NOTIF.EXT.LOGSTASH', 'NOTIF.METACONSOLE.DB_CONNECTION', 'NOTIF.DOWNTIME', From 1935b3c8f472979ed25bff1982d040eb4237e207 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 18 Oct 2023 12:35:50 +0200 Subject: [PATCH 129/414] #9761 add again checkPandoraDBMaintenance --- pandora_console/include/class/ConsoleSupervisor.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 25e298e520..b4320b1a4d 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -394,6 +394,15 @@ class ConsoleSupervisor $this->checkPandoraHistoryDB(); + /* + * Check pandoradb running in main DB. + * Check pandoradb running in historical DB. + * NOTIF.PANDORADB + * NOTIF.PANDORADB.HISTORICAL + */ + + $this->checkPandoraDBMaintenance(); + /* * Check historical DB MR version. * NOTIF.HISTORYDB.MR From e0628f8c14a879e190b34008cb92b5a7594d6c0a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 18 Oct 2023 12:46:38 +0200 Subject: [PATCH 130/414] #9761 change notif to remove --- pandora_console/include/functions_notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ea5b57283f..93fca8602a 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -141,7 +141,7 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.PANDORADB', 'NOTIF.PANDORADB.HISTORICAL', 'NOTIF.HISTORYDB.MR', - 'NOTIF.EXT.LOGSTASH', + 'NOTIF.EXT.ELASTICSEARCH', 'NOTIF.METACONSOLE.DB_CONNECTION', 'NOTIF.DOWNTIME', 'NOTIF.UPDATEMANAGER.REGISTRATION', From 4fb7e1719b1d8cc53d5c8e61c90bd76a37eb747f Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 18 Oct 2023 12:49:47 +0200 Subject: [PATCH 131/414] add periodicity graph pandora_enterprise#9640 --- pandora_console/extensions/agents_modules.php | 2 +- pandora_console/include/ajax/module.php | 17 +- pandora_console/include/functions_graph.php | 537 ++++++++++++++++ pandora_console/include/graphs/fgraph.php | 67 +- pandora_console/include/styles/pandora.css | 33 +- .../operation/agentes/stat_win.php | 572 +++++++----------- pandora_console/operation/search_modules.php | 2 +- 7 files changed, 845 insertions(+), 385 deletions(-) diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index d6c4f3bb32..f372f45812 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -1007,7 +1007,7 @@ function mainAgentsModules() echo "
"; $win_handle = dechex(crc32($module_id.$module['name'])); $graph_type = return_graphtype(modules_get_agentmodule_type($module_id)); - $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&'.'id='.$module_id.'&'.'refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)"; + $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&id='.$module_id.'&period_graph=0&refresh='.SECONDS_10MINUTES."', 'day_".$win_handle."', 800, 480)"; echo ''; diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 78daacb0a0..2951ad495a 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1283,7 +1283,7 @@ if (check_login()) { } if (is_snapshot_data($module['datos']) === false) { - $link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&refresh='.SECONDS_10MINUTES.'&draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)'; + $link = 'winopeng_var(\'operation/agentes/stat_win.php?type='.$graph_type.'&period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&refresh='.SECONDS_10MINUTES.'&period_graph=0&draw_events='.$draw_events.'\', \'day_'.$win_handle.'\', 800, 480)'; $graphButtons[] = html_print_anchor( [ 'href' => 'javascript:'.$link, @@ -1499,9 +1499,14 @@ if (check_login()) { $output = ''; $graph_data = get_parameter('graph_data', ''); $params = json_decode(base64_decode($graph_data), true); + $form_data = json_decode(base64_decode(get_parameter('form_data', [])), true); $server_id = (int) get_parameter('server_id', 0); include_once $config['homedir'].'/include/functions_graph.php'; + $tab_active = get_parameter('active', 'tabs-chart-module-graph'); + + $output .= draw_form_stat_win($form_data, $tab_active); + // Metaconsole connection to the node. if (is_metaconsole() === true && empty($server_id) === false) { $server = metaconsole_get_connection_by_id($server_id); @@ -1553,7 +1558,15 @@ if (check_login()) { $output .= $graph['chart']; $output .= ''; } else { - $output .= grafico_modulo_sparse($params); + if ($tab_active === 'tabs-chart-module-graph') { + $output .= grafico_modulo_sparse($params); + } else { + $output .= graphic_periodicity_module($params); + if ($params['compare'] === 'separated') { + $params['date'] = ($params['date'] - $params['period']); + $output .= graphic_periodicity_module($params); + } + } } } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index e6605a488b..006870757e 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2422,6 +2422,147 @@ function graphic_combined_module( } +/** + * Draw periodicity graph + * + * @param array $params Params for draw chart. + * + * @return string Html output. + */ +function graphic_periodicity_module(array $params): string +{ + $date_array = []; + $date_array['period'] = $params['period']; + $date_array['final_date'] = $params['date']; + $date_array['start_date'] = ($params['date'] - $params['period']); + + $array_data = fullscale_data( + $params['agent_module_id'], + $date_array, + false, + false, + 1, + false, + $params['period_slice_chart'], + 0 + ); + + if (empty($array_data) === false) { + $graph_labels = []; + $multiple_labels = []; + foreach ($array_data['sum1']['slice_data'] as $time => $array_data) { + $graph_labels[] = date('H:i', ($time / 1000)); + + $avg = [ + 'y' => $array_data['avg'], + 'x' => $time, + ]; + + $max = [ + 'y' => $array_data['max'], + 'x' => $time, + ]; + + $min = [ + 'y' => $array_data['min'], + 'x' => $time, + ]; + + $sum = [ + 'y' => $array_data['sum'], + 'x' => $time, + ]; + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) { + $avg = [ + 'x' => $array_data['avg'], + 'y' => $time, + ]; + + $max = [ + 'x' => $array_data['max'], + 'y' => $time, + ]; + + $min = [ + 'x' => $array_data['min'], + 'y' => $time, + ]; + + $sum = [ + 'x' => $array_data['sum'], + 'y' => $time, + ]; + } + + $graph_values_avg[] = $avg; + $graph_values_max[] = $max; + $graph_values_min[] = $min; + $graph_values_sum[] = $sum; + } + + if ((bool) $params['period_average'] === true) { + $graph_values['avg'] = $graph_values_avg; + $multiple_labels['avg'] = [ + 'label' => __('Average'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_maximum'] === true) { + $graph_values['max'] = $graph_values_max; + $multiple_labels['max'] = [ + 'label' => __('Maximun'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_minimum'] === true) { + $graph_values['min'] = $graph_values_min; + $multiple_labels['min'] = [ + 'label' => __('Minimum'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + + if ((bool) $params['period_summatory'] === true) { + $graph_values['sum'] = $graph_values_sum; + $multiple_labels['sum'] = [ + 'label' => __('Summatory'), + 'fill' => ((int) $params['period_mode'] === CUSTOM_GRAPH_AREA) ? true : false, + ]; + } + } + + $options = [ + 'height' => 200, + 'waterMark' => true, + 'legend' => ['display' => true], + 'labels' => $graph_labels, + 'multiple' => $multiple_labels, + ]; + + $output = '
'; + $output .= '
'; + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS + || (int) $params['period_mode'] === CUSTOM_GRAPH_VBARS + ) { + if ((int) $params['period_mode'] === CUSTOM_GRAPH_HBARS) { + $options['axis'] = 'y'; + } + + $output .= vbar_graph($graph_values, $options); + } else { + $output .= line_graph($graph_values, $options); + } + + $output .= '
'; + $output .= '
'; + + return $output; + +} + + /** * Function for convert data summatory. * @@ -3909,6 +4050,7 @@ function fullscale_data( } $data['sum'.$series_suffix]['slice_data'][$real_date]['avg'] = ($sum_data / $count_data); + $data['sum'.$series_suffix]['slice_data'][$real_date]['sum'] = $sum_data; if ($max_value != (-PHP_INT_MAX)) { $data['sum'.$series_suffix]['slice_data'][$real_date]['max'] = $max_value; @@ -4174,6 +4316,7 @@ function fullscale_data( $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = 0; if (isset($count_data) === true) { $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['avg'] = ($sum_data / $count_data); + $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['sum'] = $sum_data; } $data['sum'.$series_suffix]['slice_data'][($date_array['final_date'] * 1000)]['max'] = $max_value; @@ -5351,3 +5494,397 @@ function graph_analytics_filter_select() return $result; } + + +function draw_form_stat_win(array $form_data, string $tab_active) +{ + $table = html_get_predefined_table('transparent', 2); + $table->width = '100%'; + $table->id = 'stat_win_form_div'; + $table->style[0] = 'text-align:left;font-weight: bold;font-size:8.5pt;line-height:30pt;'; + $table->style[1] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->style[2] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->style[3] = 'text-align:left;font-weight: bold;line-height:30pt;'; + $table->class = 'table_modal_alternate'; + $table->data = []; + + if ((bool) $form_data['histogram'] === true || $tab_active === 'tabs-chart-period-graph') { + $table->data[0][0] = __('Refresh time'); + $table->data[0][1] = '
'.html_print_extended_select_for_time( + 'refresh', + $form_data['refresh'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[0][2] = ''; + $table->data[0][3] = ''; + + $table->data[1][0] = __('Begin date'); + $table->data[1][1] = html_print_input_text( + 'start_date', + $form_data['start_date'], + '', + 10, + 20, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[1][2] = __('Begin time'); + $table->data[1][3] = html_print_input_text( + 'start_time', + $form_data['start_time'], + '', + 10, + 10, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[2][0] = __('Time range'); + $table->data[2][1] = '
'.html_print_extended_select_for_time( + 'period', + $form_data['period'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[3][0] = __('Time compare (Separated)'); + $table->data[3][1] = html_print_checkbox_switch( + 'time_compare_separated', + 1, + (bool) $form_data['time_compare_separated'], + true + ); + + $table->data[3][2] = ''; + $table->data[3][3] = ''; + + if ($tab_active === 'tabs-chart-period-graph') { + $table->data[4][0] = __('Maximum'); + $table->data[4][1] = html_print_checkbox_switch( + 'period_maximum', + 1, + (bool) $form_data['period_maximum'], + true + ); + + $table->data[4][2] = __('Minimum'); + $table->data[4][3] = html_print_checkbox_switch( + 'period_minimum', + 1, + (bool) $form_data['period_minimum'], + true + ); + + $table->data[5][0] = __('Average'); + $table->data[5][1] = html_print_checkbox_switch( + 'period_average', + 1, + (bool) $form_data['period_average'], + true + ); + + $table->data[5][2] = __('Summatory'); + $table->data[5][3] = html_print_checkbox_switch( + 'period_summatory', + 1, + (bool) $form_data['period_summatory'], + true + ); + + $table->data[6][0] = __('Slice'); + $table->data[6][1] = '
'.html_print_extended_select_for_time( + 'period_slice_chart', + (string) $form_data['period_slice_chart'], + '', + '', + 0, + 7, + true, + false, + true, + '', + false, + [ + SECONDS_1HOUR => __('1 hour'), + SECONDS_1DAY => __('1 day'), + SECONDS_1WEEK => __('1 week'), + SECONDS_1MONTH => __('1 month'), + ] + ).'
'; + + $table->data[6][2] = __('Mode'); + $options_period_mode = [ + CUSTOM_GRAPH_AREA => __('Area'), + CUSTOM_GRAPH_LINE => __('Line'), + // CUSTOM_GRAPH_HBARS => __('Horizontal bars'), + CUSTOM_GRAPH_VBARS => __('Vertical bars'), + ]; + + $table->data[6][3] = '
'.html_print_select( + $options_period_mode, + 'period_mode', + $form_data['period_mode'], + '', + '', + 0, + true, + false, + false + ).'
'; + } + } else { + $table->data[0][0] = __('Refresh time'); + $table->data[0][1] = '
'.html_print_extended_select_for_time( + 'refresh', + $form_data['refresh'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[0][2] = __('Show events'); + $disabled = false; + + $table->data[0][3] = html_print_checkbox_switch( + 'draw_events', + 1, + (bool) $form_data['draw_events'], + true, + $disabled + ); + + $table->data[1][0] = __('Begin date'); + $table->data[1][1] = html_print_input_text( + 'start_date', + $form_data['start_date'], + '', + 10, + 20, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[1][2] = __('Show alerts'); + $table->data[1][3] = html_print_checkbox_switch( + 'draw_alerts', + 1, + (bool) $form_data['draw_alerts'], + true + ); + + $table->data[2][0] = __('Begin time'); + $table->data[2][1] = html_print_input_text( + 'start_time', + $form_data['start_time'], + '', + 10, + 10, + true, + false, + false, + '', + 'small-input' + ); + + $table->data[2][2] = __('Show unknown graph'); + $table->data[2][3] = html_print_checkbox_switch( + 'unknown_graph', + 1, + (bool) $form_data['unknown_graph'], + true + ); + + $table->data[3][0] = __('Time range'); + $table->data[3][1] = '
'.html_print_extended_select_for_time( + 'period', + $form_data['period'], + '', + '', + 0, + 7, + true + ).'
'; + + $table->data[3][2] = ''; + $table->data[3][3] = ''; + + if (!modules_is_boolean($form_data['id'])) { + $table->data[4][0] = __('Zoom'); + $options = []; + $options[$form_data['zoom']] = 'x'.$form_data['zoom']; + $options[1] = 'x1'; + $options[2] = 'x2'; + $options[3] = 'x3'; + $options[4] = 'x4'; + $options[5] = 'x5'; + $table->data[4][1] = '
'.html_print_select( + $options, + 'zoom', + $form_data['zoom'], + '', + '', + 0, + true, + false, + false + ).'
'; + + $table->data[4][2] = __('Show percentil'); + $table->data[4][3] = html_print_checkbox_switch( + 'show_percentil', + 1, + (bool) $form_data['show_percentil'], + true + ); + } + + $table->data[5][0] = __('Time compare (Overlapped)'); + $table->data[5][1] = html_print_checkbox_switch( + 'time_compare_overlapped', + 1, + (bool) $form_data['time_compare_overlapped'], + true + ); + + $table->data[5][2] = __('Time compare (Separated)'); + $table->data[5][3] = html_print_checkbox_switch( + 'time_compare_separated', + 1, + (bool) $form_data['time_compare_separated'], + true + ); + + $table->data[6][0] = __('Show AVG/MAX/MIN data series in graph'); + $table->data[6][1] = html_print_checkbox_switch( + 'type_mode_graph', + 1, + (bool) $form_data['type_mode_graph'], + true, + false + ); + + $table->data[6][2] = __('Show full scale graph (TIP)'); + $table->data[6][2] .= ui_print_help_tip( + __('TIP mode charts do not support average - maximum - minimum series, you can only enable TIP or average, maximum or minimum series'), + true + ); + $table->data[6][3] = html_print_checkbox_switch( + 'fullscale', + 1, + (bool) $form_data['fullscale'], + true, + false + ); + + $table->data[7][0] = __('Projection graph'); + $table->data[7][0] .= ui_print_help_tip( + __('Projection graph take as begin date the current time'), + true + ); + $table->data[7][1] = html_print_checkbox_switch( + 'enable_projected_period', + 1, + (bool) $form_data['enable_projected_period'], + true + ); + + $table->data[7][2] = __('Projection period'); + $table->data[7][3] = '
'.html_print_extended_select_for_time( + 'period_projected', + $form_data['period_projected'], + '', + '', + 0, + 7, + true + ).'
'; + } + + $form_table = html_print_table($table, true); + $form_table .= html_print_div( + [ + 'class' => 'action-buttons-right-forced margin-top-10', + 'content' => html_print_submit_button( + __('Reload'), + 'submit', + false, + [ + 'icon' => 'search', + 'mode' => 'secondary mini', + 'class' => 'float-right', + ], + true + ), + ], + true + ); + + $output = '
'; + $output .= html_print_input_hidden('id', $form_data['id'], true); + $output .= html_print_input_hidden('label', $form_data['label'], true); + + if (empty($server_id) === false) { + $output .= html_print_input_hidden('server', $form_data['server_id'], true); + } + + $output .= html_print_input_hidden('histogram', $form_data['histogram'], true); + $output .= html_print_input_hidden('period_graph', $form_data['period_graph'], true); + $output .= html_print_input_hidden('type', $form_data['type'], true); + + $output .= ui_toggle( + $form_table, + ''.__('Graph configuration menu').''.ui_print_help_tip( + __('In Pandora FMS, data is stored compressed. The data visualization in database, charts or CSV exported data won\'t match, because is interpreted at runtime. Please check \'Pandora FMS Engineering\' chapter from documentation.'), + true + ), + '', + '', + true, + true, + '', + 'white-box-content', + 'box-flat pdd_10px', + 'images/arrow@svg.svg', + 'images/arrow@svg.svg', + true + ); + $output .= '
'; + + return $output; +} + + +function draw_container_chart_stat_win(?string $name='stat-win-module-graph') +{ + $output = '
'; + $output .= '
'; + $output .= html_print_image('images/spinner_charts.gif', true); + $output .= '
'; + + $output .= '
'; + $output .= '
'; + + $output .= '
'; + + return $output; +} diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 494ec9c010..9cf7b5621d 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -1220,11 +1220,24 @@ function get_build_setup_charts($type, $options, $data) break; case 'BAR': - $setData->setLabel('data')->setBackgroundColor($colors); - $setData->setLabel('data')->setBorderColor($borders); - $setData->setLabel('data')->setBorderWidth(2); - - $setData->setLabel('data')->data()->exchangeArray(array_values($data)); + if (isset($options['multiple']) === true && empty($options['multiple']) === false) { + $i = 0; + foreach ($options['multiple'] as $key_label => $info) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel(($info['label'] ?? '--')); + $dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i])); + $dataSet->setBorderColor(($info['borderColor'] ?? $borders[$i])); + $dataSet->setBorderWidth(($info['borderWidth'] ?? 2)); + $dataSet->data()->exchangeArray(array_values($data[$key_label])); + $chart->addDataSet($dataSet); + $i++; + } + } else { + $setData->setLabel('data')->setBackgroundColor($colors); + $setData->setLabel('data')->setBorderColor($borders); + $setData->setLabel('data')->setBorderWidth(2); + $setData->setLabel('data')->data()->exchangeArray(array_values($data)); + } // Para las horizontales. if (isset($options['axis']) === true @@ -1250,19 +1263,32 @@ function get_build_setup_charts($type, $options, $data) break; case 'LINE': - $chart->labels()->exchangeArray($options['labels']); - - foreach ($data as $key => $dataset) { - $dataSet1 = $chart->createDataSet(); - $dataSet1->setLabel($dataset['label']); - $dataSet1->setBackgroundColor($dataset['backgroundColor']); - $dataSet1->setBorderColor($dataset['borderColor']); - $dataSet1->setPointBackgroundColor($dataset['pointBackgroundColor']); - $dataSet1->setPointBorderColor($dataset['pointBorderColor']); - $dataSet1->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']); - $dataSet1->setPointHoverBorderColor($dataset['pointHoverBorderColor']); - $dataSet1->data()->exchangeArray($dataset['data']); - $chart->addDataSet($dataSet1); + if (isset($options['multiple']) === true && empty($options['multiple']) === false) { + $i = 0; + foreach ($options['multiple'] as $key_label => $info) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel(($info['label'] ?? '--')); + $dataSet->setBackgroundColor(($info['backgroundColor'] ?? $colors[$i])); + $dataSet->setBorderColor(($info['borderColorColor'] ?? $borders[$i])); + $dataSet->setFill(($info['fill'] ?? false)); + $dataSet->data()->exchangeArray(array_values($data[$key_label])); + $chart->addDataSet($dataSet); + $i++; + } + } else { + $chart->labels()->exchangeArray($options['labels']); + foreach ($data as $key => $dataset) { + $dataSet = $chart->createDataSet(); + $dataSet->setLabel($dataset['label']); + $dataSet->setBackgroundColor($dataset['backgroundColor']); + $dataSet->setBorderColor($dataset['borderColor']); + $dataSet->setPointBackgroundColor($dataset['pointBackgroundColor']); + $dataSet->setPointBorderColor($dataset['pointBorderColor']); + $dataSet->setPointHoverBackgroundColor($dataset['pointHoverBackgroundColor']); + $dataSet->setPointHoverBorderColor($dataset['pointHoverBorderColor']); + $dataSet->data()->exchangeArray($dataset['data']); + $chart->addDataSet($dataSet); + } } break; @@ -1271,7 +1297,10 @@ function get_build_setup_charts($type, $options, $data) break; } - if ($type !== 'RADAR' && $type !== 'LINE') { + if ($type !== 'RADAR' + && $type !== 'LINE' + && ((isset($options['multiple']) === false || empty($options['multiple']) === true)) + ) { $chart->addDataSet($setData); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 1e89e83243..87b2c9d89e 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -9572,9 +9572,19 @@ div.stat-win-spinner img { } .stat_win_histogram { - width: 95%; margin: 0 auto; - margin-top: 18%; +} + +.bg_general { + background-color: #ffffff; +} + +#tabs-chart-modal { + border: 0px; +} + +#tabs-chart-ul-graphs li a img { + margin-left: 20px; } #stat-win-module-graph .stat_win_histogram div.nodata_container { @@ -12787,3 +12797,22 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.container-periodicity-graph { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + align-content: center; + border: 1px solid #e5e9ed; + border-radius: 10px; + margin-top: 25px; + padding: 10px; +} + +.container-periodicity-graph > div { + flex: 0 0 auto; + width: 100%; + height: 300px; + background-color: transparent; +} diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index a16d4c6e65..0f8b7e707b 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -127,6 +127,7 @@ ui_print_message_dialog( diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 095f79b14a..349bad535e 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2045,6 +2045,12 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2065,7 +2071,10 @@ switch ($action) { break; } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); $values['id_agent_module'] = ''; @@ -2181,7 +2190,10 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ($values['server_name'] == '') { $values['server_name'] = get_parameter( @@ -2977,6 +2989,12 @@ switch ($action) { $good_format = true; break; + case 'ncm_backups': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -3003,7 +3021,10 @@ switch ($action) { ); } - $values['id_agent'] = get_parameter('id_agent'); + if (isset($values['id_agent']) === false) { + $values['id_agent'] = get_parameter('id_agent'); + } + $values['id_gs'] = get_parameter('id_custom_graph'); if (($values['type'] == 'alert_report_agent') || ($values['type'] == 'event_report_agent') @@ -3117,7 +3138,9 @@ switch ($action) { $values['id_module_group'] = get_parameter( 'combo_modulegroup' ); - $values['id_group'] = get_parameter('combo_group'); + if (isset($values['id_group']) === false) { + $values['id_group'] = get_parameter('combo_group'); + } if ((($values['type'] == 'custom_graph') diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3da9993933..8956e3adc9 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -968,6 +968,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Network configuration changes'), ]; + $types['ncm_backups'] = [ + 'optgroup' => __('NCM'), + 'name' => __('Network backups'), + ]; + if (enterprise_installed() === true) { $types['top_n_agents_sh'] = [ 'optgroup' => __('Security hardening'), diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 383a3b40d5..b050ba3b31 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -28,6 +28,7 @@ use PandoraFMS\Enterprise\Metaconsole\Node; use PandoraFMS\ITSM\ITSM; +use PandoraFMS\Enterprise\NetworkManager; global $config; @@ -72,6 +73,7 @@ if (is_ajax()) { $get_node_agent = (bool) get_parameter('get_node_agent', false); $get_agent_inventory_modules = (bool) get_parameter('get_agent_inventory_modules', false); $get_agent_inventory_dates = (bool) get_parameter('get_agent_inventory_dates', false); + $get_ncm_agents = (bool) get_parameter('get_ncm_agents', false); $refresh_contact = get_parameter('refresh_contact', 0); @@ -213,6 +215,30 @@ if (is_ajax()) { return; } + + // Get ncm Agent. + if ($get_ncm_agents === true) { + $fields = [ + '`tncm_agent`.id_agent', + '`tagente`.alias', + ]; + $id_group = (int) get_parameter('id_group'); + + $filter['filter_id_group'] = $id_group; + // Retrieve data. + $ncm_data = NetworkManager::agents( + // Fields. + $fields, + // Filter. + $filter, + ); + + echo json_encode($ncm_data); + return; + } + + + if ($get_modules_group_json === true) { $id_group = (int) get_parameter('id_module_group', 0); $id_agents = get_parameter('id_agents', null); From e062db2439ca1499f6ab6e93dd6fd5a456fec88d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 08:39:20 +0100 Subject: [PATCH 158/414] #8365 NCM add backup id to ncm queue --- pandora_console/pandoradb.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 1d7374bc03..8a4fca2917 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4226,6 +4226,7 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `script_type` INT UNSIGNED NOT NULL, + `id_agent_data` INT NOT NULL DEFAULT 0, `data` LONGBLOB, `status` INT NOT NULL DEFAULT 5, `updated_at` BIGINT NOT NULL DEFAULT 0, From 63c74e2aa958355b0471de1b38ebd608dc4f38dc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 08:55:21 +0100 Subject: [PATCH 159/414] #8365 recovery after vscode revert error --- pandora_console/extras/mr/67.sql | 6 +-- pandora_console/pandoradb.sql | 4 +- pandora_server/lib/PandoraFMS/Tools.pm | 61 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index aa44ceea56..d15e49cf38 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,7 +1,7 @@ START TRANSACTION; ALTER TABLE `tncm_queue` -ADD COLUMN `id_agent_data` INT NOT NULL DEFAULT 0 AFTER `id_script`; +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`, +ADD CONSTRAINT `fk_tncm_queue_tncm_agent_data` FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL; - -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8a4fca2917..de34968f68 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4240,10 +4240,12 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `id` SERIAL, `id_agent` INT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, + `id_agent_data` bigint unsigned, `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 70d697dab4..a0cc1c15ac 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -30,6 +30,9 @@ use Scalar::Util qw(looks_like_number); use LWP::UserAgent; use threads; use threads::shared; +use MIME::Base64; +use Crypt::CBC; +use Digest::SHA qw(hmac_sha256_base64); use JSON; use Encode qw/decode_utf8 encode_utf8/; @@ -181,6 +184,7 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check + decrypt_AES ); # ID of the different servers @@ -2983,6 +2987,63 @@ sub get_server_name { return "UNKNOWN"; } +############################################################################### +# Encrypt with AES cypher +############################################################################### +sub encrypt_AES { + my ($str_to_encrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher($password); + + my $cipher_text = $cipher->encrypt($str_to_encrypt); + my $b64str = encode_base64($cipher_text, ''); + + return $b64str; +} + +############################################################################### +# Decrypt with AES cypher +############################################################################### +sub decrypt_AES { + my ($str_to_decrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher($password); + + my $cipher_text = decode_base64($str_to_decrypt); + my $decrypted_str = $cipher->decrypt($cipher_text); + + return $decrypted_str; +} + +############################################################################### +# Get cipher for AES encrypt and decrypt +############################################################################### +sub _get_cipher { + my ($password) = @_; + + my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); + + my $iv = '0000000000000000'; + + my $cipher = Crypt::CBC->new( + -key => $hash_base64, + -cipher => 'Cipher::AES', + -iv => $iv, + -header => 'none', + -padding => 'standard', # PKCS7 padding + -keysize => 16, + -literal_key => 1 + ); + + return $cipher; +} + 1; __END__ From 84b9ac14fb66f5942637c819aef09475a598df00 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 30 Oct 2023 10:18:29 +0100 Subject: [PATCH 160/414] #8365Added viewer report for ncm backups --- pandora_console/include/functions_reporting.php | 8 ++++++++ pandora_console/operation/reporting/reporting_viewer.php | 1 + 2 files changed, 9 insertions(+) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 39f1642fa0..19c3f80b10 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -972,6 +972,14 @@ function reporting_make_reporting_data( ); break; + case 'ncm_backups': + $report['contents'][] = reporting_ncm_backups( + $report, + $content, + $pdf + ); + break; + case 'top_n_agents_sh': $report['contents'][] = reporting_top_n_agents_sh( $report, diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index cc42d7e6ac..4bc5a05b61 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -335,6 +335,7 @@ $table2->data[0][3] = $html_menu_export; $searchForm = '
'; $searchForm .= html_print_table($table2, true); $searchForm .= html_print_input_hidden('id_report', $id_report, true); +$Actionbuttons = ''; if ((bool) is_metaconsole() === true) { $Actionbuttons .= html_print_submit_button( From 307fd7b8cb66e0c2cd35821ccbc9c25a8062e04e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 30 Oct 2023 10:52:13 +0100 Subject: [PATCH 161/414] #8365 remove fk tncm_queue --- pandora_console/extras/mr/67.sql | 3 +-- pandora_console/pandoradb.sql | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index d15e49cf38..2f6824f1f2 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,7 +1,6 @@ START TRANSACTION; ALTER TABLE `tncm_queue` -ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`, -ADD CONSTRAINT `fk_tncm_queue_tncm_agent_data` FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL; +ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index de34968f68..65e2459bdb 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4244,8 +4244,7 @@ CREATE TABLE IF NOT EXISTS `tncm_queue` ( `utimestamp` INT UNSIGNED NOT NULL, `scheduled` INT UNSIGNED DEFAULT NULL, FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_agent_data`) REFERENCES `tncm_agent_data`(`id`) ON UPDATE CASCADE ON DELETE SET NULL + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- From d5a6411e02af7900e5256244ec548242579bf5f2 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 30 Oct 2023 16:26:14 +0100 Subject: [PATCH 162/414] #12252 added datatable vulnerabilities --- pandora_console/include/styles/vulnerabilities.css | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/styles/vulnerabilities.css b/pandora_console/include/styles/vulnerabilities.css index 11c05556ec..d724a6b5e5 100644 --- a/pandora_console/include/styles/vulnerabilities.css +++ b/pandora_console/include/styles/vulnerabilities.css @@ -119,7 +119,7 @@ .dt-buttons { display: flex; margin: 10px; - margin-left: 0px; + margin-left: 10px; position: relative; } .dt-buttons button { @@ -148,6 +148,15 @@ .col-md-7 { width: 80%; } + .col-sl-12 { + width: 100%; + display: flex; + } + + .col-sl-4 { + width: 33%; + margin: 10px; + } } @keyframes load { From 7db3e3bb2b52c03290523778e550416ddb761d8e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 30 Oct 2023 17:20:58 +0100 Subject: [PATCH 163/414] #8365 Added html report for ncm backups --- .../include/functions_reporting_html.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 99f3af63ad..8fc6f3cf79 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -480,6 +480,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust reporting_html_ncm_config($table, $item); break; + case 'ncm_backups': + reporting_html_ncm_backups($table, $item); + break; + case 'top_n_agents_sh': reporting_html_top_n_agents_sh($table, $item); break; @@ -7380,3 +7384,49 @@ function reporting_html_ncm_config($table, $item, $pdf=0) return $content; } } + + +/** + * HTML content for ncm backup report. + * + * @param array $item Content generated by reporting_ncm_config. + * + * @return string HTML code. + */ +function reporting_html_ncm_backups($table, $item, $pdf=0) +{ + ui_require_javascript_file('diff2html-ui.min'); + ui_require_css_file('diff2html.min'); + ui_require_css_file('highlight.min'); + ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('highlight.min'); + ui_require_javascript_file('highlightjs-line-numbers.min'); + ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); + + // Create table info. + $table_ncm = new stdClass(); + $table_ncm->width = '100%'; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->rowstyle['title'] = 'text-align: center; font-weight: bolder'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + + $table_ncm->data = []; + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + $row['diff'], + ]; + } + + if ($pdf === 0) { + return $table->data[] = html_print_table( + $table_ncm, + true + ); + } + +} From 325b0a758ac2e30e1aae3448fc50d79341eca726 Mon Sep 17 00:00:00 2001 From: Calvo Date: Tue, 31 Oct 2023 11:33:48 +0100 Subject: [PATCH 164/414] Added name and master server column to servers view --- .../godmode/servers/servers.build_table.php | 111 +++++++++--------- 1 file changed, 57 insertions(+), 54 deletions(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 101a99d955..80b9ff9c6b 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -64,32 +64,33 @@ $table->style = []; // $table->style[0] = 'font-weight: bold'; $table->align = []; $table->align[1] = 'center'; -$table->align[3] = 'center'; -$table->align[8] = 'right'; +$table->align[4] = 'center'; +$table->align[9] = 'right'; $table->headstyle[1] = 'text-align:center'; -$table->headstyle[3] = 'text-align:center'; -$table->headstyle[8] = 'text-align:right;width: 120px;'; +$table->headstyle[4] = 'text-align:center'; +$table->headstyle[9] = 'text-align:right;width: 120px;'; $table->titleclass = 'tabletitle'; $table->titlestyle = 'text-transform:uppercase;'; -$table->style[6] = 'display: flex;align-items: center;'; +$table->style[7] = 'display: flex;align-items: center;'; $table->head = []; $table->head[0] = __('Name'); $table->head[1] = __('Status'); $table->head[2] = __('Type'); -$table->head[3] = __('Version'); -$table->head[4] = __('Modules'); -$table->head[5] = __('Lag').ui_print_help_tip(__('Avg. Delay(sec)/Modules delayed'), true); -$table->head[6] = __('T/Q').ui_print_help_tip(__('Threads / Queued modules currently'), true); +$table->head[3] = __('Master'); +$table->head[4] = __('Version'); +$table->head[5] = __('Modules'); +$table->head[6] = __('Lag').ui_print_help_tip(__('Avg. Delay(sec)/Modules delayed'), true); +$table->head[7] = __('T/Q').ui_print_help_tip(__('Threads / Queued modules currently'), true); // This will have a column of data such as "6 hours". -$table->head[7] = __('Updated'); +$table->head[8] = __('Updated'); // Only Pandora Administrator can delete servers. if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $table->head[8] = ''.__('Op.').''; + $table->head[9] = ''.__('Op.').''; } $table->data = []; @@ -143,9 +144,11 @@ foreach ($servers as $server) { } // Type. - $data[2] = ''.$server['img']; + $data[2] = ''.$server['img'].' '.ucfirst($server['type']).' server'; if ($server['master'] == $master) { - $data[2] .= ui_print_help_tip(__('This is a master server'), true); + $data[3] .= __('Yes', true); + } else { + $data[3] .= __('-'); } if ((int) $server['exec_proxy'] === 1) { @@ -157,27 +160,27 @@ foreach ($servers as $server) { case 'event': case 'autoprovision': case 'migration': - $data[3] = $server['version']; - $data[4] = __('N/A'); + $data[4] = $server['version']; $data[5] = __('N/A'); + $data[6] = __('N/A'); break; case 'export': - $data[3] = $server['version']; - $data[4] = $server['modules'].' '.__('of').' '.$server['modules_total']; - $data[5] = __('N/A'); + $data[4] = $server['version']; + $data[5] = $server['modules'].' '.__('of').' '.$server['modules_total']; + $data[6] = __('N/A'); break; default: - $data[3] = $server['version']; - $data[4] = $server['modules'].' '.__('of').' '.$server['modules_total']; - $data[5] = ''.$server['lag_txt'].''; + $data[4] = $server['version']; + $data[5] = $server['modules'].' '.__('of').' '.$server['modules_total']; + $data[6] = ''.$server['lag_txt'].''; break; } - $data[6] = ''; + $data[7] = ''; if ($server['queued_modules'] > 500) { - $data[6] .= '
'.html_print_image( + $data[7] .= '  '; } - $data[6] .= $server['threads'].' : '.$server['queued_modules']; + $data[7] .= $server['threads'].' : '.$server['queued_modules']; - $data[7] = ui_print_timestamp($server['keepalive'], true); + $data[8] = ui_print_timestamp($server['keepalive'], true); if ($server['type'] === 'data') { $ext = '_server'; @@ -208,11 +211,11 @@ foreach ($servers as $server) { // Only Pandora Administrator can delete servers. if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $data[8] = ''; + $data[9] = ''; if ($server['type'] === 'recon') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/snmp-trap@svg.svg', true, [ @@ -221,12 +224,12 @@ foreach ($servers as $server) { ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($server['type'] === 'data') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/force@svg.svg', true, [ @@ -234,10 +237,10 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } else if ($server['type'] === 'enterprise snmp') { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/force@svg.svg', true, [ @@ -245,12 +248,12 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($server['type'] === 'event' && (bool) check_acl($config['id_user'], 0, 'LM') === true) { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/alert@svg.svg', true, [ @@ -258,11 +261,11 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/edit.svg', true, [ @@ -270,11 +273,11 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) { - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/agents@svg.svg', true, [ @@ -282,10 +285,10 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/remote-configuration@svg.svg', true, [ @@ -293,12 +296,12 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; $names_servers[$safe_server_name] = false; } - $data[8] .= ''; - $data[8] .= html_print_image( + $data[9] .= ''; + $data[9] .= html_print_image( 'images/delete.svg', true, [ @@ -307,14 +310,14 @@ foreach ($servers as $server) { 'class' => 'main_menu_icon invert_filter', ] ); - $data[8] .= ''; + $data[9] .= ''; } if ($tiny) { - unset($data[4]); - unset($data[6]); + unset($data[5]); unset($data[7]); unset($data[8]); + unset($data[9]); } $ext = ''; @@ -323,10 +326,10 @@ foreach ($servers as $server) { } if ($tiny) { - unset($table->head[4]); - unset($table->head[6]); + unset($table->head[5]); unset($table->head[7]); unset($table->head[8]); + unset($table->head[9]); } if ($tiny) { From b327c824da86c620a3aa383dff7e7c5be9d43ca4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 31 Oct 2023 13:45:26 +0100 Subject: [PATCH 165/414] #8365 NCM new special templates --- pandora_console/extras/mr/67.sql | 27 +++++++++++++++++++++++++++ pandora_console/pandoradb.sql | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 2f6824f1f2..9da40c6829 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -3,4 +3,31 @@ START TRANSACTION; ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; +CREATE TABLE IF NOT EXISTS `tncm_special_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `id_special_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; + +CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( + `id` SERIAL, + `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +ALTER TABLE `tncm_agent` +ADD COLUMN `special_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; + +ALTER TABLE `tncm_agent` +ADD COLUMN `special_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; + + COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 65e2459bdb..24020ffb0f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4191,6 +4191,29 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +-- ---------------------------------------------------------------------- +-- Table `tncm_special_template` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_special_template` ( + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- ---------------------------------------------------------------------- +-- Table `tncm_special_template_scripts` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( + `id` SERIAL, + `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + -- ---------------------------------------------------------------------- -- Table `tncm_agent` -- ---------------------------------------------------------------------- @@ -4206,10 +4229,13 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` ( `updated_at` BIGINT NOT NULL DEFAULT 0, `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, `id_template` BIGINT UNSIGNED, + `id_special_template` BIGINT UNSIGNED, `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, `execute` INT UNSIGNED NOT NULL DEFAULT 0, `cron_interval` VARCHAR(100) DEFAULT '', + `special_cron_interval` VARCHAR(100) DEFAULT '', `event_on_change` INT UNSIGNED DEFAULT null, + `special_event_on_change` INT UNSIGNED DEFAULT null, `last_error` TEXT, PRIMARY KEY (`id_agent`), FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, From bdac4b6235b4c64a38e294da65b5257551fc5ae3 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 31 Oct 2023 16:40:55 +0100 Subject: [PATCH 166/414] #12252 fixed value group in discovery when it is 0 --- pandora_console/include/class/ExtensionsDiscovery.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index 7fa1bfdb96..e908cc3c2b 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -1920,7 +1920,11 @@ class ExtensionsDiscovery extends Wizard $value = false; switch ($type) { case 'agent_groups': - $value = groups_get_name($v); + if ($v > 0) { + $value = groups_get_name($v); + } else { + $value = ''; + } break; case 'module_groups': From ff8c8e1796a1ff46a1994df2feb3fb73dbc57935 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 31 Oct 2023 16:45:03 +0100 Subject: [PATCH 167/414] #12252 revert fixed value group in discovery when it is 0 --- pandora_console/include/class/ExtensionsDiscovery.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandora_console/include/class/ExtensionsDiscovery.class.php b/pandora_console/include/class/ExtensionsDiscovery.class.php index e908cc3c2b..7fa1bfdb96 100644 --- a/pandora_console/include/class/ExtensionsDiscovery.class.php +++ b/pandora_console/include/class/ExtensionsDiscovery.class.php @@ -1920,11 +1920,7 @@ class ExtensionsDiscovery extends Wizard $value = false; switch ($type) { case 'agent_groups': - if ($v > 0) { - $value = groups_get_name($v); - } else { - $value = ''; - } + $value = groups_get_name($v); break; case 'module_groups': From 98332d728e9e84c80639e1f7cd989c7195ec1eac Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 31 Oct 2023 16:55:35 +0100 Subject: [PATCH 168/414] #8365 change name ncm agent data --- pandora_console/extras/mr/67.sql | 14 +++++++------- pandora_console/pandoradb.sql | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 9da40c6829..b2b34e5ce4 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -3,7 +3,7 @@ START TRANSACTION; ALTER TABLE `tncm_queue` ADD COLUMN `id_agent_data` bigint unsigned AFTER `id_script`; -CREATE TABLE IF NOT EXISTS `tncm_special_template` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, `name` TEXT, `vendors` TEXT, @@ -12,22 +12,22 @@ CREATE TABLE IF NOT EXISTS `tncm_special_template` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ALTER TABLE `tncm_agent` -ADD COLUMN `id_special_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; +ADD COLUMN `id_agent_data_template` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `id_template`; -CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( `id` SERIAL, - `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; ALTER TABLE `tncm_agent` -ADD COLUMN `special_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; +ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_interval`; ALTER TABLE `tncm_agent` -ADD COLUMN `special_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 24020ffb0f..8b83b26011 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4192,9 +4192,9 @@ CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- --- Table `tncm_special_template` +-- Table `tncm_agent_data_template` -- ---------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tncm_special_template` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template` ( `id` SERIAL, `name` TEXT, `vendors` TEXT, @@ -4203,14 +4203,14 @@ CREATE TABLE IF NOT EXISTS `tncm_special_template` ( ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- --- Table `tncm_special_template_scripts` +-- Table `tncm_agent_data_template_scripts` -- ---------------------------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tncm_special_template_scripts` ( +CREATE TABLE IF NOT EXISTS `tncm_agent_data_template_scripts` ( `id` SERIAL, - `id_special_template` BIGINT UNSIGNED NOT NULL, + `id_agent_data_template` BIGINT UNSIGNED NOT NULL, `id_script` BIGINT UNSIGNED NOT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_special_template`) REFERENCES `tncm_special_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent_data_template`) REFERENCES `tncm_agent_data_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; @@ -4229,13 +4229,13 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` ( `updated_at` BIGINT NOT NULL DEFAULT 0, `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, `id_template` BIGINT UNSIGNED, - `id_special_template` BIGINT UNSIGNED, + `id_agent_data_template` BIGINT UNSIGNED, `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, `execute` INT UNSIGNED NOT NULL DEFAULT 0, `cron_interval` VARCHAR(100) DEFAULT '', - `special_cron_interval` VARCHAR(100) DEFAULT '', + `agent_data_cron_interval` VARCHAR(100) DEFAULT '', `event_on_change` INT UNSIGNED DEFAULT null, - `special_event_on_change` INT UNSIGNED DEFAULT null, + `agent_data_event_on_change` INT UNSIGNED DEFAULT null, `last_error` TEXT, PRIMARY KEY (`id_agent`), FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, From f5e7ac8d4af9a6aa6ac39b44f1e1313748f8a225 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 31 Oct 2023 17:27:28 +0100 Subject: [PATCH 169/414] #8365 PDF report added for ncm backups --- .../include/functions_reporting_html.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8fc6f3cf79..76f0920e34 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7389,44 +7389,57 @@ function reporting_html_ncm_config($table, $item, $pdf=0) /** * HTML content for ncm backup report. * - * @param array $item Content generated by reporting_ncm_config. + * @param array $item Content generated by reporting_ncm_backups. * * @return string HTML code. */ function reporting_html_ncm_backups($table, $item, $pdf=0) { - ui_require_javascript_file('diff2html-ui.min'); ui_require_css_file('diff2html.min'); ui_require_css_file('highlight.min'); ui_require_css_file('highlight/vs.min'); + ui_require_javascript_file('diff2html-ui.min'); ui_require_javascript_file('highlight.min'); ui_require_javascript_file('highlightjs-line-numbers.min'); ui_require_javascript_file('languages/plaintext.min'); ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); - // Create table info. + // Create table diff. $table_ncm = new stdClass(); $table_ncm->width = '100%'; $table_ncm->class = 'info_table'; $table_ncm->styleTable = 'table-layout: fixed;'; - $table_ncm->rowstyle['title'] = 'text-align: center; font-weight: bolder'; + $table_ncm->headstyle[0] = 'width: 250px'; $table_ncm->head = []; $table_ncm->head[0] = __('Date'); $table_ncm->head[1] = __('Diff'); $table_ncm->data = []; - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - $row['diff'], - ]; - } if ($pdf === 0) { + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + $row['diff'], + ]; + } + return $table->data[] = html_print_table( $table_ncm, true ); + } else { + foreach ($item['data'] as $key => $row) { + $table_ncm->data[] = [ + $row['updated_at'], + ($row['diffstr'] === '') ? $row['diff'] : str_replace("\n", '
', $row['diffstr']), + ]; + } + + return html_print_table( + $table_ncm, + true + ); } } From 3031e7ddbddb52a6a7aea8381904bd4cf92825b5 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Wed, 1 Nov 2023 10:13:44 -0600 Subject: [PATCH 170/414] Add export Encrypt AES to tools --- pandora_server/lib/PandoraFMS/Tools.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index a0cc1c15ac..48a46ea740 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -185,6 +185,7 @@ our @EXPORT = qw( check_cron_element cron_check decrypt_AES + encrypt_AES ); # ID of the different servers From e403741b996be993ed7a113b68cc30a0a2deffcc Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Nov 2023 08:27:11 +0100 Subject: [PATCH 171/414] #12271 styles widget message dashboard --- pandora_console/include/lib/Dashboard/Widget.php | 2 +- pandora_console/views/dashboard/widget.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 82fc7cbda5..abb39de1b8 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -508,7 +508,7 @@ class Widget } if ($this->configurationRequired === true) { - $output .= '
'; + $output .= '
'; $output .= \ui_print_info_message( __('Please configure this widget before usage'), '', diff --git a/pandora_console/views/dashboard/widget.php b/pandora_console/views/dashboard/widget.php index cf160ccc76..a2fbdc1783 100644 --- a/pandora_console/views/dashboard/widget.php +++ b/pandora_console/views/dashboard/widget.php @@ -43,7 +43,7 @@ if ((int) $cellData['id_widget'] !== 0 || $widgetId !== 0) { true ); - $output .= '
'; + $output .= '
'; $output .= \ui_print_info_message( __('Please select widget'), '', From 1a021c96899c1cd6af25eb09421445d0baa490c1 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 11:24:50 +0100 Subject: [PATCH 172/414] Added Rijndael encryption for python pandoraPlugintools and PandoraFMS::Tools --- .../extras/pandoraPlugintools/encryption.py | 89 +++++++++++++++++- pandora_server/lib/PandoraFMS/Tools.pm | 92 +++++++++---------- 2 files changed, 132 insertions(+), 49 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index b1ec3c9315..576ae31ae3 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -39,7 +39,7 @@ def _print_debug( #### # Internal use only: Get AES cipher ######################################################################################### -def _get_cipher( +def _get_cipher_AES( password: str = _PASSWORD ) -> AES: ''' @@ -78,7 +78,7 @@ def encrypt_AES( Returns: str: The encrypted string in base64 encoding. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: msg_padded = pad(str_to_encrypt.encode(), AES.block_size, style='pkcs7') @@ -106,11 +106,94 @@ def decrypt_AES( Returns: str: The decrypted string. ''' - cipher = _get_cipher(password) + cipher = _get_cipher_AES(password) try: decrypted_str = unpad(cipher.decrypt(base64.b64decode(str_to_decrypt)), AES.block_size, style='pkcs7').decode().strip() except: decrypted_str = '' + return decrypted_str + +#### +# Internal use only: Get Rijndael cipher +######################################################################################### +def _get_cipher_Rijndael( + password: str = _PASSWORD + ) -> AES: + ''' + Internal use only: Get Rijndael cipher for encryption and decryption. + + Args: + password (str): The password used to derive the encryption key. + + Returns: + AES: An AES cipher instance for encryption and decryption. + ''' + key = b'' + msg = password.encode('utf-8') + hash_obj = hmac.new(key, msg, hashlib.sha256) + hash_result = hash_obj.digest() + hash_base64 = base64.b64encode(hash_result)[:16].decode() + + iv = b'0000000000000000' + + return AES.new(hash_base64.encode(), AES.MODE_CBC, iv) + +#### +# Return encrypted string +######################################################################################### +def encrypt_Rijndael( + str_to_encrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Encrypt a string using Rijndael encryption. + + Args: + str_to_encrypt (str): The string to be encrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The encrypted string in base64 encoding. + ''' + cipher = _get_cipher_Rijndael(password) + + block_size = 16 # Rijndael block size is 16 bytes + padding_length = block_size - (len(str_to_encrypt) % block_size) + padded_data = str_to_encrypt + chr(padding_length) * padding_length + + try: + b64str = base64.b64encode(cipher.encrypt(padded_data.encode())).decode() + except Exception as e: + b64str = '' + + return b64str + +#### +# Return decrypted string +######################################################################################### +def decrypt_Rijndael( + str_to_decrypt: str = "", + password: str = _PASSWORD + ) -> str: + ''' + Decrypt an encrypted string using Rijndael decryption. + + Args: + str_to_decrypt (str): The encrypted string to be decrypted. + password (str): The password used to derive the encryption key. + + Returns: + str: The decrypted string. + ''' + cipher = _get_cipher_Rijndael(password) + + try: + decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)).decode().strip() + padding_length = ord(decrypted_data[-1]) + decrypted_str = decrypted_data[:-padding_length] + except: + decrypted_str = '' + return decrypted_str \ No newline at end of file diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 48a46ea740..cb9ca7c86e 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -31,7 +31,7 @@ use LWP::UserAgent; use threads; use threads::shared; use MIME::Base64; -use Crypt::CBC; +use Crypt::Rijndael; use Digest::SHA qw(hmac_sha256_base64); use JSON; @@ -2989,62 +2989,62 @@ sub get_server_name { } ############################################################################### -# Encrypt with AES cypher +# Get cipher for Rijndael encrypt and decrypt ############################################################################### -sub encrypt_AES { - my ($str_to_encrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher($password); - - my $cipher_text = $cipher->encrypt($str_to_encrypt); - my $b64str = encode_base64($cipher_text, ''); - - return $b64str; -} - -############################################################################### -# Decrypt with AES cypher -############################################################################### -sub decrypt_AES { - my ($str_to_decrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher($password); - - my $cipher_text = decode_base64($str_to_decrypt); - my $decrypted_str = $cipher->decrypt($cipher_text); - - return $decrypted_str; -} - -############################################################################### -# Get cipher for AES encrypt and decrypt -############################################################################### -sub _get_cipher { +sub _get_cipher_Rijndael { my ($password) = @_; my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); my $iv = '0000000000000000'; - my $cipher = Crypt::CBC->new( - -key => $hash_base64, - -cipher => 'Cipher::AES', - -iv => $iv, - -header => 'none', - -padding => 'standard', # PKCS7 padding - -keysize => 16, - -literal_key => 1 - ); + my $cipher = Crypt::Rijndael->new($hash_base64, Crypt::Rijndael::MODE_CBC()); + $cipher->set_iv($iv); return $cipher; } +############################################################################### +# Encrypt with Rijndael cypher +############################################################################### +sub encrypt_Rijndael { + my ($str_to_encrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher_Rijndael($password); + + my $block_size = 16; # Rijndael block size is 16 bytes + my $padding_length = $block_size - (length($str_to_encrypt) % $block_size); + my $padded_data = $str_to_encrypt . chr($padding_length) x $padding_length; + + my $cipher_text = $cipher->encrypt($padded_data); + my $b64str = encode_base64($cipher_text, ''); + + return $b64str; +} + +############################################################################### +# Decrypt with Rijndael cypher +############################################################################### +sub decrypt_Rijndael { + my ($str_to_decrypt, $password) = @_; + + if (!defined($password)) { + $password = "default_salt"; + } + my $cipher = _get_cipher_Rijndael($password); + + my $cipher_text = decode_base64($str_to_decrypt); + my $decrypted_data = $cipher->decrypt($cipher_text); + + my $padding_length = ord(substr($decrypted_data, -1)); + my $decrypted_str = substr($decrypted_data, 0, -$padding_length); + + return $decrypted_str; +} + 1; __END__ From dc648167631d38a19f70c66b3617d33399b7d25f Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 11:26:20 +0100 Subject: [PATCH 173/414] Exported encrypt and decrypt functions in Tools.pm --- pandora_server/lib/PandoraFMS/Tools.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cb9ca7c86e..cb9b78e1b4 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -184,8 +184,8 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_AES - encrypt_AES + decrypt_Rijndael + encrypt_Rijndael ); # ID of the different servers From b368f3b370cecef00be0b23538a6674ea0b278ea Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Nov 2023 12:33:07 +0100 Subject: [PATCH 174/414] #12271 styles widget message dashboard --- pandora_console/include/lib/Dashboard/Widget.php | 2 +- pandora_console/include/styles/dashboards.css | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index abb39de1b8..82fc7cbda5 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -508,7 +508,7 @@ class Widget } if ($this->configurationRequired === true) { - $output .= '
'; + $output .= '
'; $output .= \ui_print_info_message( __('Please configure this widget before usage'), '', diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index d7fcbd761e..c12ea132a7 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -950,7 +950,8 @@ input.resize_button { right: 6%; } -.new-widget-message .info_box_information .title b { +.new-widget-message .info_box_information .title > b, +.container-center .info_box_information .title > b { margin-left: 60px; } From 9e4ba18f49287c18ee108856052281cfc86374f7 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 12:52:31 +0100 Subject: [PATCH 175/414] Changed pandoraPlugintools encryption funcion and removed encryption functions from Tools.pm --- .../extras/pandoraPlugintools/encryption.py | 21 +++--- pandora_server/lib/PandoraFMS/Tools.pm | 64 +------------------ 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/encryption.py b/pandora_server/extras/pandoraPlugintools/encryption.py index 576ae31ae3..6e456d2fcd 100644 --- a/pandora_server/extras/pandoraPlugintools/encryption.py +++ b/pandora_server/extras/pandoraPlugintools/encryption.py @@ -136,9 +136,7 @@ def _get_cipher_Rijndael( hash_result = hash_obj.digest() hash_base64 = base64.b64encode(hash_result)[:16].decode() - iv = b'0000000000000000' - - return AES.new(hash_base64.encode(), AES.MODE_CBC, iv) + return AES.new(hash_base64.encode(), AES.MODE_ECB) #### # Return encrypted string @@ -159,13 +157,13 @@ def encrypt_Rijndael( ''' cipher = _get_cipher_Rijndael(password) - block_size = 16 # Rijndael block size is 16 bytes - padding_length = block_size - (len(str_to_encrypt) % block_size) - padded_data = str_to_encrypt + chr(padding_length) * padding_length - try: - b64str = base64.b64encode(cipher.encrypt(padded_data.encode())).decode() - except Exception as e: + padded_data = str_to_encrypt.encode() + missing = 16 - (len(padded_data) % 16) + padded_data += bytes([0] * missing) if missing != 16 else b'' + + b64str = base64.b64encode(cipher.encrypt(padded_data)).decode() + except: b64str = '' return b64str @@ -190,9 +188,8 @@ def decrypt_Rijndael( cipher = _get_cipher_Rijndael(password) try: - decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)).decode().strip() - padding_length = ord(decrypted_data[-1]) - decrypted_str = decrypted_data[:-padding_length] + decrypted_data = cipher.decrypt(base64.b64decode(str_to_decrypt)) + decrypted_str = decrypted_data.rstrip(b'\x00').decode() except: decrypted_str = '' diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index cb9b78e1b4..61b68cd2ce 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -30,9 +30,6 @@ use Scalar::Util qw(looks_like_number); use LWP::UserAgent; use threads; use threads::shared; -use MIME::Base64; -use Crypt::Rijndael; -use Digest::SHA qw(hmac_sha256_base64); use JSON; use Encode qw/decode_utf8 encode_utf8/; @@ -184,8 +181,8 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_Rijndael - encrypt_Rijndael + decrypt_AES + encrypt_AES ); # ID of the different servers @@ -2988,63 +2985,6 @@ sub get_server_name { return "UNKNOWN"; } -############################################################################### -# Get cipher for Rijndael encrypt and decrypt -############################################################################### -sub _get_cipher_Rijndael { - my ($password) = @_; - - my $hash_base64 = substr(Digest::SHA::hmac_sha256_base64($password,''), 0, 16); - - my $iv = '0000000000000000'; - - my $cipher = Crypt::Rijndael->new($hash_base64, Crypt::Rijndael::MODE_CBC()); - $cipher->set_iv($iv); - - return $cipher; -} - -############################################################################### -# Encrypt with Rijndael cypher -############################################################################### -sub encrypt_Rijndael { - my ($str_to_encrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher_Rijndael($password); - - my $block_size = 16; # Rijndael block size is 16 bytes - my $padding_length = $block_size - (length($str_to_encrypt) % $block_size); - my $padded_data = $str_to_encrypt . chr($padding_length) x $padding_length; - - my $cipher_text = $cipher->encrypt($padded_data); - my $b64str = encode_base64($cipher_text, ''); - - return $b64str; -} - -############################################################################### -# Decrypt with Rijndael cypher -############################################################################### -sub decrypt_Rijndael { - my ($str_to_decrypt, $password) = @_; - - if (!defined($password)) { - $password = "default_salt"; - } - my $cipher = _get_cipher_Rijndael($password); - - my $cipher_text = decode_base64($str_to_decrypt); - my $decrypted_data = $cipher->decrypt($cipher_text); - - my $padding_length = ord(substr($decrypted_data, -1)); - my $decrypted_str = substr($decrypted_data, 0, -$padding_length); - - return $decrypted_str; -} - 1; __END__ From e6f505da5422b0ff60ed98857df396928bcebe6c Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Thu, 2 Nov 2023 12:53:38 +0100 Subject: [PATCH 176/414] Removed encryption functions from Tools.pm exporting --- pandora_server/lib/PandoraFMS/Tools.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 61b68cd2ce..70d697dab4 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -181,8 +181,6 @@ our @EXPORT = qw( check_cron_value check_cron_element cron_check - decrypt_AES - encrypt_AES ); # ID of the different servers From ed5fdfddf57fcdfc34c73a8e677a6075ef58c342 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Nov 2023 13:04:59 +0100 Subject: [PATCH 177/414] #12271 styles widget message dashboard --- pandora_console/include/styles/dashboards.css | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index c12ea132a7..675b5c7c50 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -950,9 +950,17 @@ input.resize_button { right: 6%; } -.new-widget-message .info_box_information .title > b, -.container-center .info_box_information .title > b { - margin-left: 60px; +.new-widget-message > div > table, +.container-center > div > table { + display: flex; + flex-direction: column; + align-items: center; +} + +.new-widget-message > div > table tr td > div, +.container-center > div > table tr td > div { + position: absolute; + right: 20px; } .parent_graph > .graph { From 47aeb3cc39ead3adf6fa5dc0ad714084b5f2829c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 2 Nov 2023 13:22:42 +0100 Subject: [PATCH 178/414] #12137 Fix Description --- pandora_console/include/styles/pandora.css | 2 +- pandora_console/operation/agentes/estado_generalagente.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 93717aa12c..4b9962d3f3 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6219,7 +6219,7 @@ div#status_pie { display: flex; align-items: flex-start; padding: 20px; - padding-bottom: 0; + padding-bottom: 5%; } .agent_details_content_cluster { diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 6d87e5055d..6ce71d1fc2 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -158,7 +158,7 @@ $table_status->data['agent_version'][0] = __('Agent Version'); $table_status->data['agent_version'][1] = (empty($agent['agent_version']) === true) ? ''.__('N/A').'' : $agent['agent_version']; $table_status->data['description'][0] = __('Description'); -$table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? ''.__('N/A').'' : $agent['comentarios']; +$table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? ''.__('N/A').'' : ui_print_truncate_text($agent['comentarios']); $agentEventsHeader = html_print_div( [ From 84ab19119b815fc340a58e9da01ee85ae43759b6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 2 Nov 2023 15:11:53 +0100 Subject: [PATCH 179/414] #12175 Fix recovery alert icon --- pandora_console/include/functions_events.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f709fe2b4c..f5c6342a70 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2594,6 +2594,7 @@ function events_print_type_img( switch ($type) { case 'alert_recovered': $style .= ' alert_module_background_state icon_background_normal '; + $icon = ''; break; case 'alert_manual_validation': @@ -2680,6 +2681,16 @@ function events_print_type_img( ); } + if ($type === 'alert_recovered') { + $output = html_print_div( + [ + 'title' => events_print_type_description($type, true), + 'class' => $style, + ], + true + ); + } + if ($return) { return $output; } From 3822ffc0f0d33b799a3d73b403a42803a5210eec Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 2 Nov 2023 15:22:49 +0100 Subject: [PATCH 180/414] #12137 Fix agent view --- pandora_console/include/styles/pandora.css | 8 ++------ .../operation/agentes/estado_generalagente.php | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 4b9962d3f3..48281140f4 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6046,7 +6046,7 @@ div#bullets_modules div { div.bullets_modules div { display: flex; align-items: center; - margin: 0 5px; + margin: 0 10px; } .orange_background { @@ -6219,7 +6219,7 @@ div#status_pie { display: flex; align-items: flex-start; padding: 20px; - padding-bottom: 5%; + padding-bottom: 1%; } .agent_details_content_cluster { @@ -12685,7 +12685,3 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { position: relative; top: -92px; } - -#agent_status_main > tbody { - position: absolute; -} diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 6ce71d1fc2..4157414fee 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -102,7 +102,7 @@ $agentCountModules = html_print_div( $table_status = new stdClass(); $table_status->id = 'agent_status_main'; -$table_status->width = '100%'; +$table_status->width = 'auto'; $table_status->height = 'auto'; $table_status->cellspacing = 0; $table_status->cellpadding = 0; From ab6aa1ba57df8e948258db39852baad86cb6f688 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 2 Nov 2023 17:13:16 +0100 Subject: [PATCH 181/414] #12268 dashboard widget events redirect event view --- .../include/javascript/pandora_events.js | 5 +++++ .../lib/Dashboard/Widgets/EventCardboard.php | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 86b84376c5..ed6adf6301 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1739,3 +1739,8 @@ function loadModal() { } } window.onload = loadModal; + +function openEvents(severity) { + $('input[name="filter[severity]"]').val(severity); + $("#event_redirect").submit(); +} diff --git a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php index fa2f8bb023..13028b3c57 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php +++ b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php @@ -530,6 +530,16 @@ class EventCardboard extends Widget ); } + $output .= ''; + $output .= html_print_input_hidden('filter[event_type]', $this->values['eventType'], true, false, false, 'filter[event_type]'); + $output .= html_print_input_hidden('filter[event_view_hr]', $this->values['maxHours'], true, false, false, 'filter[event_view_hr]'); + $output .= html_print_input_hidden('filter[status]', $this->values['eventStatus'], true, false, false, 'filter[status]'); + $output .= html_print_input_hidden('filter[id_group_filter]', $this->values['groupId'][0], true, false, false, 'filter[id_group_filter]'); + $output .= html_print_input_hidden('filter[severity]', '', true, false, false, 'filter[severity]'); + $output .= html_print_input_hidden('get_events', '1', true, false, false, 'get_events'); + $output .= html_print_input_hidden('filter[tag_with]', 'WyIwIl0=', true, false, false, 'filter[tag_with]'); + $output .= html_print_input_hidden('filter[tag_without]', 'WyIwIl0=', true, false, false, 'filter[tag_without]'); + $output .= ''; $output .= ''; $width_td = (100 / count(explode(',', $severity))); @@ -543,7 +553,8 @@ class EventCardboard extends Widget } } - switch ((int) $key) { + $severity_row = (int) $key; + switch ($severity_row) { case 0: $text = __('Maintenance'); $color = get_priority_class((int) $key); @@ -604,7 +615,7 @@ class EventCardboard extends Widget $border = ' border-right: 1px solid white; border-collapse: collapse;'; } - $output .= ' + + + + + + + + + + + + + + + @@ -6850,6 +6929,9 @@ function chooseType() { $("#row_cat_security_hardening").hide(); $("#row_ignore_skipped").hide(); $("#row_status_check").hide(); + $("#row_secmon_status").hide(); + $("#row_security_hardening_score").hide(); + $("#row_vulnerabilities_status").hide(); // SLA list default state. $("#sla_list").hide(); @@ -7749,6 +7831,14 @@ function chooseType() { $("#row_group").show(); $('#row_period').show(); break; + + case 'vuls_by_agent': + $("#row_group").show(); + $("#row_custom_field_filter").show(); + $("#row_secmon_status").show(); + $("#row_security_hardening_score").show(); + $("#row_vulnerabilities_status").show(); + break; } switch (type) { diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 095f79b14a..a85792f3e6 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2045,6 +2045,16 @@ switch ($action) { $good_format = true; break; + case 'vuls_by_agent': + $values['id_group'] = get_parameter('combo_group'); + $es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter'); + $es['secmon_status'] = get_parameter('secmon_status'); + $es['security_hardening_score'] = get_parameter('security_hardening_score'); + $es['vulnerabilities_status'] = get_parameter('vulnerabilities_status'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2977,6 +2987,16 @@ switch ($action) { $good_format = true; break; + case 'vuls_by_agent': + $values['id_group'] = get_parameter('combo_group'); + $es['agent_custom_field_filter'] = get_parameter('agent_custom_field_filter'); + $es['secmon_status'] = get_parameter('secmon_status'); + $es['security_hardening_score'] = get_parameter('security_hardening_score'); + $es['vulnerabilities_status'] = get_parameter('vulnerabilities_status'); + $values['external_source'] = json_encode($es); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 39f1642fa0..167a0db389 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1023,6 +1023,14 @@ function reporting_make_reporting_data( ); break; + case 'vuls_by_agent': + $report['contents'][] = reporting_vuls_by_agent( + $report, + $content, + $type + ); + break; + default: // Default. break; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 99f3af63ad..92508ac00b 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -507,6 +507,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust case 'evolution': reporting_evolution_graph($table, $item); break; + + case 'vuls_by_agent': + reporting_html_vuls_by_agent($table, $item); + break; } if ($item['type'] == 'agent_module') { @@ -522,6 +526,70 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust } +/** + * Function to print the all vulnerabilities by agent. + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param integer $pdf Flag for return table. + * + * @return mixed + */ +function reporting_html_vuls_by_agent($table, $item, $pdf=0) +{ + $table->width = '99%'; + $table->styleTable = 'border: 0px;'; + $table->colspan[2][0] = 3; + $table1 = new stdClass(); + $table1->headstyle[0] = 'text-align: left'; + $table1->headstyle[1] = 'text-align: left'; + $table1->headstyle[2] = 'text-align: left'; + $table1->width = '99%'; + $table1->class = 'info_table'; + $table1->titleclass = 'title_table_pdf'; + $table1->rowclass[0] = ''; + $table1->head[0] = __('Agent'); + $table1->head[1] = __('OS'); + $table1->head[2] = __('OS Version'); + $table1->head[3] = __('Group'); + $table1->head[4] = __('Ip'); + $table1->head[5] = __('Status'); + $table1->head[6] = __('SecMon'); + $table1->head[7] = __('Hardening'); + $table1->head[8] = __('Vulnerability'); + $table1->head[9] = __('Last contact'); + $table1->head[10] = __('L.S. Change'); + + $row = 1; + foreach ($item['data'] as $key => $vul) { + $table1->data[$row][0] = $vul['alias']; + $table1->data[$row][2] = $vul['name']; + $table1->data[$row][3] = $vul['os_version']; + $table1->data[$row][4] = $vul['nombre_gr']; + $table1->data[$row][5] = $vul['direccion']; + $table1->data[$row][6] = $vul['status']; + $table1->data[$row][7] = $vul['secmon']; + $table1->data[$row][8] = $vul['hardening']; + $table1->data[$row][9] = $vul['vulnerabilities']; + $table1->data[$row][10] = $vul['ultimo_contacto']; + $table1->data[$row][11] = $vul['last_status_c']; + $row++; + } + + if ($pdf === 1) { + $table1->title = $item['title']; + $table1->titleclass = 'title_table_pdf'; + $table1->titlestyle = 'text-align:left;'; + } + + $table->data[2][0] = html_print_table($table1, true); + + if ($pdf === 1) { + return html_print_table($table1, true); + } +} + + /** * Function to print the security hardening evolution. * diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 3da9993933..27533fa5a3 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -1003,6 +1003,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'optgroup' => __('Security hardening'), 'name' => __('Evolution'), ]; + + $types['vuls_by_agent'] = [ + 'optgroup' => __('Vulnerabilities'), + 'name' => __('Detailed security report'), + ]; } return $types; From c34515549c1fc5a830ba4981025976d21e88bf20 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 15 Nov 2023 11:23:10 +0100 Subject: [PATCH 243/414] #12456 fixed size of cards containing Agents hive information --- .../lib/Dashboard/Widgets/AgentHive.php | 26 +++++++++++++------ pandora_console/include/styles/dashboards.css | 4 +-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php index 3b881ca344..c663670df1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php +++ b/pandora_console/include/lib/Dashboard/Widgets/AgentHive.php @@ -435,11 +435,17 @@ class AgentHive extends Widget $output .= html_print_div( [ 'content' => (empty($data['os_version']) === true) - ? get_os_name((int) $data['id_os']) - : $data['os_version'], - 'style' => 'font-size: 6pt; display: - flex;justify-content: start;align-items: start; - color: #9FA5B1; font-weight: 600;margin-bottom: 5px', + ? ui_print_truncate_text(get_os_name((int) $data['id_os'])) + : ui_print_truncate_text($data['os_version']), + 'style' => 'font-size: 6pt; + display: flex; + justify-content: start; + align-items: start; + color: #9FA5B1; + font-weight: 600; + margin: 5px; + float: right; + word-break: break-all;', ], true ); @@ -455,8 +461,10 @@ class AgentHive extends Widget true, '…', ), - 'style' => 'text-align: left;min-height: 42px; - font-size: 8pt;max-height: 42px; margin-bottom: 10px', + 'style' => 'text-align: left; + min-height: 42px; font-size: 8pt; + max-height: 42px; + margin: 2px 0px 2px 0px', ], true ); @@ -466,7 +474,9 @@ class AgentHive extends Widget [ 'content' => $data['direccion'], 'style' => 'font-size: 10pt;color: #14524f; - font-weight: 600; text-align: left', + font-weight: 600; + text-align: left; + margin-top: 5px', ], true ); diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 818e523316..1e048bab85 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -663,9 +663,9 @@ form.modal-dashboard justify-content: center; align-items: start; min-width: 150px; - max-width: 150px; + max-width: 200px; min-height: 150px; - max-height: 150px; + max-height: 200px; margin: 8px; padding: 5px; border: 1px solid #eceef2; From 4579fe21d98e1215413afc262154542271e3deaa Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 14:24:42 +0100 Subject: [PATCH 244/414] update version in mr --- pandora_console/extras/mr/67.sql | 6 ++++++ pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..48d44b6255 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.vmware'; + +COMMIT; + diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9ce5355361..6813173de7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2653,7 +2653,7 @@ SET @short_name = 'pandorafms.vmware'; SET @name = 'VMware'; SET @section = 'app'; SET @description = 'Monitor ESXi hosts, datastores and VMs from a specific datacenter'; -SET @version = '1.1'; +SET @version = '1.2'; INSERT IGNORE INTO `tdiscovery_apps` (`id_app`, `short_name`, `name`, `section`, `description`, `version`) VALUES ('', @short_name, @name, @section, @description, @version); SELECT @id_app := `id_app` FROM `tdiscovery_apps` WHERE `short_name` = @short_name; From 4b0e134fba568048df1cb7f897f136033b1edca8 Mon Sep 17 00:00:00 2001 From: alejandro Date: Wed, 15 Nov 2023 15:13:08 +0100 Subject: [PATCH 245/414] update md5 hash --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 6323aec140..1ba02194d2 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=9959cc3e5cc6bfcfadd6d05b56d4a11b +pandorafms.vmware=54251ae54994c55b478867cd35a98e6c pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 804970719d502de1adb91f2b32a055a116830427 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 15 Nov 2023 16:32:02 +0100 Subject: [PATCH 246/414] #12385 Fixed group --- .../agentes/pandora_networkmap.view.php | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 5256c10871..3cbe53e815 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -1205,57 +1205,6 @@ if (is_ajax() === true) { return; } - if ($get_agents_in_group) { - $id = (int) get_parameter('id', 0); - $group = (int) get_parameter('group', -1); - - $return = []; - $return['correct'] = false; - - if ($group != -1) { - $where_id_agente = ' 1=1 '; - - $agents_in_networkmap = db_get_all_rows_filter( - 'titem', - [ - 'id_map' => $id, - 'deleted' => 0, - ] - ); - if ($agents_in_networkmap !== false) { - $ids = []; - foreach ($agents_in_networkmap as $agent) { - if ($agent['type'] == 0) { - $ids[] = $agent['source_data']; - } - } - - $where_id_agente = ' id_agente NOT IN ('.implode(',', $ids).')'; - } - - - $sql = 'SELECT id_agente, alias - FROM tagente - WHERE id_grupo = '.$group.' AND '.$where_id_agente.' - ORDER BY alias ASC'; - - $agents = db_get_all_rows_sql($sql); - - if ($agents !== false) { - $return['agents'] = []; - foreach ($agents as $agent) { - $return['agents'][$agent['id_agente']] = $agent['alias']; - } - - $return['correct'] = true; - } - } - - echo json_encode($return); - - return; - } - if ($get_agent_info) { $id_agent = (int) get_parameter('id_agent'); From 811363cbec0d8483eafac415bc3bf0147f5f218c Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 15 Nov 2023 17:07:47 +0100 Subject: [PATCH 247/414] #12200 snow effect added --- .../lib/TacticalView/GeneralTacticalView.php | 5 +- pandora_console/include/styles/pandora.css | 478 ++++++++++++++++++ pandora_console/index.php | 20 +- 3 files changed, 500 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php index d61b748bca..df259bfab2 100644 --- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -170,10 +170,11 @@ class GeneralTacticalView $name = ''; } + // 👋 if (empty($name) === true) { - $message = __('Welcome back! 👋'); + $message = __('Welcome back! 🎅'); } else { - $message = __('Welcome back %s! 👋', $name); + $message = __('Welcome back %s! 🎅', $name); } return html_print_div( diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c740bba2b..238a4a72c7 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12792,3 +12792,481 @@ tr.shown td.details-control { position: relative; top: -92px; } + +@-moz-keyframes nieve { + from { + top: -40px; + } + to { + top: 101%; + } +} +@-webkit-keyframes nieve { + from { + top: -40px; + } + to { + top: 2000px; + } +} +@keyframes nieve { + from { + top: -40px; + } + to { + top: 2000px; + } +} + +@-moz-keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@-webkit-keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@keyframes horiz2 { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(-70px); + } + 80% { + transform: translateX(0); + } +} + +@-moz-keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@-webkit-keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} +@keyframes horiz { + 20% { + transform: translateX(0); + } + 50% { + transform: translateX(150px); + } + 80% { + transform: translateX(0); + } +} + +#container-snow > div { + position: fixed; + -webkit-animation: ease-in infinite normal; + -moz-animation: ease-in infinite normal; + animation: ease-in infinite normal; +} + +#container-snow > div { + z-index: 9999999999999; + width: 15px; + height: 15px; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; + border-radius: 50%; + background-color: #e8ede5; + -webkit-animation-name: nieve, horiz; + -moz-animation-name: nieve, horiz; + animation-name: nieve, horiz; +} +#container-snow > div:nth-of-type(odd) { + width: 5px; + height: 5px; + -webkit-animation-name: nieve, horiz2; + -moz-animation-name: nieve, horiz2; + animation-name: nieve, horiz2; +} + +#container-snow > div:nth-of-type(1) { + left: 40px; + -webkit-animation-duration: 5.5s; + -moz-animation-duration: 5.5s; + animation-duration: 5.5s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(2) { + left: 120px; + -webkit-animation-duration: 7s; + -moz-animation-duration: 7s; + animation-duration: 7s; +} +#container-snow > div:nth-of-type(3) { + left: 200px; + -webkit-animation-duration: 8s; + -moz-animation-duration: 8s; + animation-duration: 8s; +} +#container-snow > div:nth-of-type(4) { + left: 20%; + -webkit-animation-duration: 6s; + -moz-animation-duration: 6s; + animation-duration: 6s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(5) { + left: 30%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; +} +#container-snow > div:nth-of-type(6) { + left: 40%; + -webkit-animation-duration: 7.2s; + -moz-animation-duration: 7.2s; + animation-duration: 7.2s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(7) { + left: 50%; + -webkit-animation-duration: 10s; + -moz-animation-duration: 10s; + animation-duration: 10s; +} +#container-snow > div:nth-of-type(8) { + left: 60%; + -webkit-animation-duration: 6.4s; + -moz-animation-duration: 6.4s; + animation-duration: 6.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(9) { + left: 70%; + -webkit-animation-duration: 10s; + -moz-animation-duration: 10s; + animation-duration: 10s; + -webkit-animation-delay: 1.4s; + -moz-animation-delay: 1.4s; + animation-delay: 1.4s; +} +#container-snow > div:nth-of-type(10) { + left: 80%; + -webkit-animation-duration: 8s; + -moz-animation-duration: 8s; + animation-duration: 8s; +} +#container-snow > div:nth-of-type(11) { + left: 90%; + -webkit-animation-duration: 7.1s; + -moz-animation-duration: 7.1s; + animation-duration: 7.1s; + -webkit-animation-delay: 2s; + -moz-animation-delay: 2s; + animation-delay: 2s; +} +#container-snow > div:nth-of-type(12) { + left: 99%; + -webkit-animation-duration: 6.6s; + -moz-animation-duration: 6.6s; + animation-duration: 6.6s; + -webkit-animation-delay: 1.6s; + -moz-animation-delay: 1.6s; + animation-delay: 1.6s; +} +#container-snow > div:nth-of-type(13) { + left: 10px; + -webkit-animation-duration: 10.2s; + -moz-animation-duration: 10.2s; + animation-duration: 10.2s; +} +#container-snow > div:nth-of-type(14) { + left: 180px; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(15) { + left: 213px; + -webkit-animation-duration: 7.3s; + -moz-animation-duration: 7.3s; + animation-duration: 7.3s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(16) { + left: 23%; + -webkit-animation-duration: 9.2s; + -moz-animation-duration: 9.2s; + animation-duration: 9.2s; +} +#container-snow > div:nth-of-type(17) { + left: 38%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(18) { + left: 45%; + -webkit-animation-duration: 15s; + -moz-animation-duration: 15s; + animation-duration: 15s; +} +#container-snow > div:nth-of-type(19) { + left: 58%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(20) { + left: 64%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(21) { + left: 76%; + -webkit-animation-duration: 5.6s; + -moz-animation-duration: 5.6s; + animation-duration: 5.6s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(22) { + left: 86%; + -webkit-animation-duration: 8.5s; + -moz-animation-duration: 8.5s; + animation-duration: 8.5s; +} +#container-snow > div:nth-of-type(23) { + left: 83%; + -webkit-animation-duration: 14.4s; + -moz-animation-duration: 14.4s; + animation-duration: 14.4s; +} +#container-snow > div:nth-of-type(24) { + left: 95%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(25) { + left: 55px; + -webkit-animation-duration: 8.7s; + -moz-animation-duration: 8.7s; + animation-duration: 8.7s; + -webkit-animation-delay: 1.2s; + -moz-animation-delay: 1.2s; + animation-delay: 1.2s; +} +#container-snow > div:nth-of-type(26) { + left: 133px; + -webkit-animation-duration: 5.2s; + -moz-animation-duration: 5.2s; + animation-duration: 5.2s; +} +#container-snow > div:nth-of-type(27) { + left: 215px; + -webkit-animation-duration: 10.4s; + -moz-animation-duration: 10.4s; + animation-duration: 10.4s; + -webkit-animation-delay: 1.6s; + -moz-animation-delay: 1.6s; + animation-delay: 1.6s; +} +#container-snow > div:nth-of-type(28) { + left: 26%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; +} +#container-snow > div:nth-of-type(29) { + left: 33%; + -webkit-animation-duration: 12s; + -moz-animation-duration: 12s; + animation-duration: 12s; +} +#container-snow > div:nth-of-type(30) { + left: 49%; + -webkit-animation-duration: 9.4s; + -moz-animation-duration: 9.4s; + animation-duration: 9.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(31) { + left: 55%; + -webkit-animation-duration: 9.1s; + -moz-animation-duration: 9.1s; + animation-duration: 9.1s; +} +#container-snow > div:nth-of-type(32) { + left: 68%; + -webkit-animation-duration: 9.6s; + -moz-animation-duration: 9.6s; + animation-duration: 9.6s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(33) { + left: 73%; + -webkit-animation-duration: 12.4s; + -moz-animation-duration: 12.4s; + animation-duration: 12.4s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(34) { + left: 85%; + -webkit-animation-duration: 9s; + -moz-animation-duration: 9s; + animation-duration: 9s; + -webkit-animation-delay: 1.5s; + -moz-animation-delay: 1.5s; + animation-delay: 1.5s; +} +#container-snow > div:nth-of-type(35) { + left: 93%; + -webkit-animation-duration: 5s; + -moz-animation-duration: 5s; + animation-duration: 5s; +} +#container-snow > div:nth-of-type(36) { + left: 99%; + -webkit-animation-duration: 10.6s; + -moz-animation-duration: 10.6s; + animation-duration: 10.6s; +} +#container-snow > div:nth-of-type(37) { + left: 15px; + -webkit-animation-duration: 9.6s; + -moz-animation-duration: 9.6s; + animation-duration: 9.6s; +} +#container-snow > div:nth-of-type(38) { + left: 99px; + -webkit-animation-duration: 7.5s; + -moz-animation-duration: 7.5s; + animation-duration: 7.5s; +} +#container-snow > div:nth-of-type(39) { + left: 260px; + -webkit-animation-duration: 11s; + -moz-animation-duration: 11s; + animation-duration: 11s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(40) { + left: 28%; + -webkit-animation-duration: 19s; + -moz-animation-duration: 19s; + animation-duration: 19s; +} +#container-snow > div:nth-of-type(41) { + left: 35%; + -webkit-animation-duration: 14s; + -moz-animation-duration: 14s; + animation-duration: 14s; +} +#container-snow > div:nth-of-type(42) { + left: 43%; + -webkit-animation-duration: 5.6s; + -moz-animation-duration: 5.6s; + animation-duration: 5.6s; +} +#container-snow > div:nth-of-type(43) { + left: 53%; + -webkit-animation-duration: 8.8s; + -moz-animation-duration: 8.8s; + animation-duration: 8.8s; + -webkit-animation-delay: 1s; + -moz-animation-delay: 1s; + animation-delay: 1s; +} +#container-snow > div:nth-of-type(44) { + left: 66%; + -webkit-animation-duration: 16s; + -moz-animation-duration: 16s; + animation-duration: 16s; +} +#container-snow > div:nth-of-type(45) { + left: 78%; + -webkit-animation-duration: 6s; + -moz-animation-duration: 6s; + animation-duration: 6s; +} +#container-snow > div:nth-of-type(46) { + left: 88%; + -webkit-animation-duration: 9.5s; + -moz-animation-duration: 9.5s; + animation-duration: 9.5s; + -webkit-animation-delay: 0.5s; + -moz-animation-delay: 0.5s; + animation-delay: 0.5s; +} +#container-snow > div:nth-of-type(47) { + left: 94%; + -webkit-animation-duration: 7.6s; + -moz-animation-duration: 7.6s; + animation-duration: 7.6s; +} +#container-snow > div:nth-of-type(48) { + left: 96%; + -webkit-animation-duration: 8.2s; + -moz-animation-duration: 8.2s; + animation-duration: 8.2s; + -webkit-animation-delay: 0.3s; + -moz-animation-delay: 0.3s; + animation-delay: 0.3s; +} + +@media (max-width: 600px) { + #container-snow > div:nth-of-type(24) ~ * { + display: none; + } +} + +@media (max-width: 800px) { + #container-snow > div:nth-of-type(36) ~ * { + display: none; + } +} diff --git a/pandora_console/index.php b/pandora_console/index.php index fce3421ffe..ff6f27b152 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1198,8 +1198,18 @@ if ($config['pure'] == 0) { // Menu container prepared to autohide menu. $menuCollapsed = (isset($_SESSION['menu_type']) === true && $_SESSION['menu_type'] !== 'classic'); $menuTypeClass = ($menuCollapsed === true) ? 'collapsed' : 'classic'; + // Snow. + $string = '
+
+
+
+
+
+
+
+
'; // Container. - echo '
'; + echo '
'.$string; // Notifications content wrapper echo ''; @@ -1667,4 +1677,12 @@ require 'include/php_to_js_values.php'; $("#"+this.id+" > .subIcon.cog").addClass("rotation"); }); }); + + // Snow animations. + $(document).ready(function() { + setTimeout(() => { + $("#container-snow").addClass('invisible') ; + }, 30000); + }); + From 99c5da677d7b79b3df225b2da42a8ffd447d33e8 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 16 Nov 2023 08:37:41 +0100 Subject: [PATCH 248/414] #12137 Fix entities --- pandora_console/operation/agentes/estado_generalagente.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 4157414fee..831450f712 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -102,7 +102,7 @@ $agentCountModules = html_print_div( $table_status = new stdClass(); $table_status->id = 'agent_status_main'; -$table_status->width = 'auto'; +$table_status->width = '90%'; $table_status->height = 'auto'; $table_status->cellspacing = 0; $table_status->cellpadding = 0; @@ -113,6 +113,7 @@ $table_status->style[1] = 'height: 28px; width: 70%; padding-left: 5px; font-wei $os_agent_text = ''; $os_name = get_os_name((int) $agent['id_os']); if (empty($agent['os_version']) !== true) { + $agent['os_version'] = io_safe_output($agent['os_version']); if (strpos($agent['os_version'], '(') !== false) { $os_name = preg_split('/[0-9]|[\(]/', $agent['os_version'])[0]; $os_version = explode($os_name, explode('(', $agent['os_version'])[0])[1]; @@ -158,7 +159,7 @@ $table_status->data['agent_version'][0] = __('Agent Version'); $table_status->data['agent_version'][1] = (empty($agent['agent_version']) === true) ? ''.__('N/A').'' : $agent['agent_version']; $table_status->data['description'][0] = __('Description'); -$table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? ''.__('N/A').'' : ui_print_truncate_text($agent['comentarios']); +$table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? ''.__('N/A').'' : ui_print_truncate_text($agent['comentarios'], 'description', true); $agentEventsHeader = html_print_div( [ From 1a931c71b4114d4f69aa12bd42cf615d56de676e Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 16 Nov 2023 10:10:54 +0100 Subject: [PATCH 249/414] update vmwre md5 code --- .../extras/discovery/DiscoveryApplicationsMigrateCodes.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini index 1ba02194d2..c0cee7d03f 100644 --- a/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini +++ b/pandora_console/extras/discovery/DiscoveryApplicationsMigrateCodes.ini @@ -1,4 +1,4 @@ -pandorafms.vmware=54251ae54994c55b478867cd35a98e6c +pandorafms.vmware=248788e0fb2cd4e11623e4a52ee7d05b pandorafms.mysql=fadb4750d18285c0eca34f47c6aa3cfe pandorafms.mssql=1cc215409741d19080269ffba112810e pandorafms.oracle=2d9320a514d1e48a0b2804e1653c31c6 From 863561781567df6bb90a1ec18fe476a1ceba42d9 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 16 Nov 2023 10:24:03 +0100 Subject: [PATCH 250/414] #12200 The Christmas effect is added after 25 clicks on the about image --- pandora_console/include/functions_menu.php | 3 ++- .../include/javascript/pandora_events.js | 12 ++++++++++++ pandora_console/index.php | 15 +++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 346dee04b5..ac76541162 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -1328,8 +1328,9 @@ if (is_ajax()) {
'; + $output .= ''; $output .= $count; $output .= '
'; $output .= $text; From 1412480b4dd571b6c80208c75b2215aa5e97960c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 09:54:56 +0100 Subject: [PATCH 182/414] #12248 change setup netflow tab --- pandora_console/godmode/setup/setup.php | 24 +++++----- .../godmode/setup/setup_general.php | 16 +------ .../godmode/setup/setup_netflow.php | 48 ++++++++++++++++--- pandora_console/include/functions_config.php | 8 ++-- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..ac22324c79 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -141,19 +141,17 @@ $buttons['vis'] = [ ]; if (check_acl($config['id_user'], 0, 'AW')) { - if ($config['activate_netflow']) { - $buttons['net'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/op_netflow.png', - true, - [ - 'title' => __('Netflow'), - 'class' => 'invert_filter', - ] - ).'', - ]; - } + $buttons['net'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/op_netflow.png', + true, + [ + 'title' => __('Netflow'), + 'class' => 'invert_filter', + ] + ).'', + ]; if ($config['activate_sflow']) { $buttons['sflow'] = [ diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..a791b90aa4 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -391,20 +391,6 @@ $table->data[$i][] = html_print_label_input_block( ); $table->data[$i++][] = html_print_label_input_block( - __('Enable Netflow'), - html_print_checkbox_switch_extended( - 'activate_netflow', - 1, - $config['activate_netflow'], - $rbt_disabled, - '', - '', - true - ) -); - - -$table->data[$i][] = html_print_label_input_block( __('Enable Sflow'), html_print_checkbox_switch_extended( 'activate_sflow', @@ -417,7 +403,7 @@ $table->data[$i][] = html_print_label_input_block( ), ); -$table->data[$i++][] = html_print_label_input_block( +$table->data[$i][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index b939a01825..a133a2b531 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -36,49 +36,70 @@ check_login(); $update = (bool) get_parameter('update'); $table = new stdClass(); +$table->id = 'table_netflow'; $table->width = '100%'; $table->class = 'databox filter-table-adv'; $table->border = 0; $table->data = []; +// Enable Netflow. +if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $rbt_disabled = true; +} else { + $rbt_disabled = false; +} + $table->data[0][] = html_print_label_input_block( + __('Enable Netflow'), + html_print_checkbox_switch_extended( + 'activate_netflow', + 1, + $config['activate_netflow'], + $rbt_disabled, + '', + '', + true + ) +); + +$table->data[1][] = html_print_label_input_block( __('Data storage path'), html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true) ); -$table->data[0][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Daemon binary path'), html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Nfdump binary path'), html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Nfexpire binary path'), html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Maximum chart resolution'), html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Disable custom live view filters'), html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[4][] = html_print_label_input_block( __('Netflow max lifetime'), html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true) ); $onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;"; -$table->data[3][] = html_print_label_input_block( +$table->data[4][] = html_print_label_input_block( __('Name resolution for IP address'), html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); @@ -98,7 +119,20 @@ html_print_action_buttons( echo ''; ?> \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..456d1c5158 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -245,10 +245,6 @@ function config_update_config() $error_update[] = __('Enable GIS features'); } - if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { - $error_update[] = __('Enable Netflow'); - } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { $error_update[] = __('Enable Sflow'); } @@ -1579,6 +1575,10 @@ function config_update_config() break; case 'net': + if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { + $error_update[] = __('Enable Netflow'); + } + if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) { $error_update[] = __('Name storage path'); } else { From c77686807fdf78ae9839cbb5c01eb264d8744dca Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 3 Nov 2023 10:30:25 +0100 Subject: [PATCH 183/414] Fix if else --- pandora_console/extensions/agents_modules_csv.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 6ed1061c11..e1db8a6f58 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -27,17 +27,18 @@ */ global $config; -if (true) { - include_once '../include/config.php'; - include_once '../include/functions_agents.php'; - include_once '../include/functions_reporting.php'; - include_once '../include/functions_modules.php'; - include_once '../include/functions_users.php'; +if ((bool) $config['metaconsole']) { include_once $config['homedir'].'/include/config.php'; include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_reporting.php'; include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_users.php'; +} else { + include_once '../include/config.php'; + include_once '../include/functions_agents.php'; + include_once '../include/functions_reporting.php'; + include_once '../include/functions_modules.php'; + include_once '../include/functions_users.php'; } From 05be3e143efcbf95e7f19a3b7aa4e59a2dddce7f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:27:27 +0100 Subject: [PATCH 184/414] #12387 bug agent module widget edit agent --- pandora_console/include/functions_html.php | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 888531e915..7cd53ba0e8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1740,20 +1740,37 @@ function html_print_select_multiple_modules_filtered(array $data):string } } - $output .= html_print_input( - [ - 'label' => __('Agents'), - 'label_class' => 'font-title-font', - 'type' => 'select_from_sql', - 'sql' => 'SELECT `id_agente`,`nombre` FROM tagente', - 'name' => 'filtered-module-agents-'.$uniqId, - 'selected' => explode(',', $data['mAgents']), - 'return' => true, - 'multiple' => true, - 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', - ] - ); + if (is_metaconsole() === true) { + $output .= html_print_input( + [ + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select', + 'fields' => $agents, + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + ] + ); + } else { + $output .= html_print_input( + [ + 'label' => __('Agents'), + 'label_class' => 'font-title-font', + 'type' => 'select_from_sql', + 'sql' => 'SELECT `id_agente`,`nombre` FROM tagente', + 'name' => 'filtered-module-agents-'.$uniqId, + 'selected' => explode(',', $data['mAgents']), + 'return' => true, + 'multiple' => true, + 'style' => 'min-width: 200px;max-width:200px;', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', + ] + ); + } $commonModules = 0; if (empty($data['mShowCommonModules']) === false) { From 1362ff096729abf2ca380e787cd00227c61dd858 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:32:54 +0100 Subject: [PATCH 185/414] Revert "#12248 change setup netflow tab" This reverts commit 1412480b4dd571b6c80208c75b2215aa5e97960c. --- pandora_console/godmode/setup/setup.php | 24 +++++----- .../godmode/setup/setup_general.php | 16 ++++++- .../godmode/setup/setup_netflow.php | 48 +++---------------- pandora_console/include/functions_config.php | 8 ++-- 4 files changed, 39 insertions(+), 57 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index ac22324c79..0fd6bebff8 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -141,17 +141,19 @@ $buttons['vis'] = [ ]; if (check_acl($config['id_user'], 0, 'AW')) { - $buttons['net'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/op_netflow.png', - true, - [ - 'title' => __('Netflow'), - 'class' => 'invert_filter', - ] - ).'', - ]; + if ($config['activate_netflow']) { + $buttons['net'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/op_netflow.png', + true, + [ + 'title' => __('Netflow'), + 'class' => 'invert_filter', + ] + ).'', + ]; + } if ($config['activate_sflow']) { $buttons['sflow'] = [ diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index a791b90aa4..aa55893d11 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -391,6 +391,20 @@ $table->data[$i][] = html_print_label_input_block( ); $table->data[$i++][] = html_print_label_input_block( + __('Enable Netflow'), + html_print_checkbox_switch_extended( + 'activate_netflow', + 1, + $config['activate_netflow'], + $rbt_disabled, + '', + '', + true + ) +); + + +$table->data[$i][] = html_print_label_input_block( __('Enable Sflow'), html_print_checkbox_switch_extended( 'activate_sflow', @@ -403,7 +417,7 @@ $table->data[$i++][] = html_print_label_input_block( ), ); -$table->data[$i][] = html_print_label_input_block( +$table->data[$i++][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index a133a2b531..b939a01825 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -36,70 +36,49 @@ check_login(); $update = (bool) get_parameter('update'); $table = new stdClass(); -$table->id = 'table_netflow'; $table->width = '100%'; $table->class = 'databox filter-table-adv'; $table->border = 0; $table->data = []; -// Enable Netflow. -if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { - $rbt_disabled = true; -} else { - $rbt_disabled = false; -} - $table->data[0][] = html_print_label_input_block( - __('Enable Netflow'), - html_print_checkbox_switch_extended( - 'activate_netflow', - 1, - $config['activate_netflow'], - $rbt_disabled, - '', - '', - true - ) -); - -$table->data[1][] = html_print_label_input_block( __('Data storage path'), html_print_input_text('netflow_name_dir', $config['netflow_name_dir'], false, 50, 200, true) ); -$table->data[1][] = html_print_label_input_block( +$table->data[0][] = html_print_label_input_block( __('Daemon binary path'), html_print_input_text('netflow_daemon', $config['netflow_daemon'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Nfdump binary path'), html_print_input_text('netflow_nfdump', $config['netflow_nfdump'], false, 50, 200, true) ); -$table->data[2][] = html_print_label_input_block( +$table->data[1][] = html_print_label_input_block( __('Nfexpire binary path'), html_print_input_text('netflow_nfexpire', $config['netflow_nfexpire'], false, 50, 200, true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Maximum chart resolution'), html_print_input_text('netflow_max_resolution', $config['netflow_max_resolution'], false, 50, 200, true) ); -$table->data[3][] = html_print_label_input_block( +$table->data[2][] = html_print_label_input_block( __('Disable custom live view filters'), html_print_checkbox_switch('netflow_disable_custom_lvfilters', 1, $config['netflow_disable_custom_lvfilters'], true) ); -$table->data[4][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Netflow max lifetime'), html_print_input_text('netflow_max_lifetime', $config['netflow_max_lifetime'], false, 50, 200, true) ); $onclick = "if (!confirm('".__('Warning').'. '.__('IP address resolution can take a lot of time')."')) return false;"; -$table->data[4][] = html_print_label_input_block( +$table->data[3][] = html_print_label_input_block( __('Name resolution for IP address'), html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); @@ -119,20 +98,7 @@ html_print_action_buttons( echo ''; ?> \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 456d1c5158..1fe38aac0b 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -245,6 +245,10 @@ function config_update_config() $error_update[] = __('Enable GIS features'); } + if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { + $error_update[] = __('Enable Netflow'); + } + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { $error_update[] = __('Enable Sflow'); } @@ -1575,10 +1579,6 @@ function config_update_config() break; case 'net': - if (config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'), true) === false) { - $error_update[] = __('Enable Netflow'); - } - if (config_update_value('netflow_name_dir', get_parameter('netflow_name_dir'), true) === false) { $error_update[] = __('Name storage path'); } else { From 54514b043d6039a413f8de583af503fd61b155ed Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:35:22 +0100 Subject: [PATCH 186/414] #12248 move nflow to netflow config --- pandora_console/godmode/setup/setup_general.php | 13 ------------- pandora_console/godmode/setup/setup_netflow.php | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..10ad4d007e 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -405,19 +405,6 @@ $table->data[$i++][] = html_print_label_input_block( $table->data[$i][] = html_print_label_input_block( - __('Enable Sflow'), - html_print_checkbox_switch_extended( - 'activate_sflow', - 1, - $config['activate_sflow'], - $rbt_disabled, - '', - '', - true - ), -); - -$table->data[$i++][] = html_print_label_input_block( __('General network path'), html_print_input_text( 'general_network_path', diff --git a/pandora_console/godmode/setup/setup_netflow.php b/pandora_console/godmode/setup/setup_netflow.php index b939a01825..9e6f6ee180 100644 --- a/pandora_console/godmode/setup/setup_netflow.php +++ b/pandora_console/godmode/setup/setup_netflow.php @@ -83,6 +83,19 @@ $table->data[3][] = html_print_label_input_block( html_print_checkbox_switch_extended('netflow_get_ip_hostname', 1, $config['netflow_get_ip_hostname'], false, $onclick, '', true) ); +$table->data[4][] = html_print_label_input_block( + __('Enable Sflow'), + html_print_checkbox_switch_extended( + 'activate_sflow', + 1, + $config['activate_sflow'], + $rbt_disabled, + '', + '', + true + ), +); + echo '
'; html_print_table($table); html_print_input_hidden('update_config', 1); From 495c4d861fe0966cd5ae530db823420280d949cb Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:35:30 +0100 Subject: [PATCH 187/414] #12248 move nflow to netflow config --- pandora_console/include/functions_config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..fb91c3f8fc 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -249,10 +249,6 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } - if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { - $error_update[] = __('Enable Sflow'); - } - if (config_update_value('activate_feedback', (bool) get_parameter('activate_feedback'), true) === false) { $error_update[] = __('Enable Feedback'); } @@ -1615,6 +1611,10 @@ function config_update_config() if (config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'), true) === false) { $error_update[] = __('Name resolution for IP address'); } + + if (config_update_value('activate_sflow', (bool) get_parameter('activate_sflow'), true) === false) { + $error_update[] = __('Enable Sflow'); + } break; case 'sflow': From b2257ac1b1d917af9d0b6d08ba3231beeaa8a879 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 3 Nov 2023 12:12:26 +0100 Subject: [PATCH 188/414] Fix csv agent-module pandora_enterprise#12363 --- .../extensions/agents_modules_csv.php | 20 ++++++++++++++++++- pandora_console/include/functions_modules.php | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pandora_console/extensions/agents_modules_csv.php b/pandora_console/extensions/agents_modules_csv.php index 6ed1061c11..086228b521 100644 --- a/pandora_console/extensions/agents_modules_csv.php +++ b/pandora_console/extensions/agents_modules_csv.php @@ -106,7 +106,25 @@ if ($get_agents_module_csv === '1') { foreach ($results as $result) { foreach ($result as $key => $value) { - $out_csv .= io_safe_output($value).$divider; + if (preg_match('/Linux/i', $_SERVER['HTTP_USER_AGENT'])) { + $value = preg_replace( + '/\s+/', + ' ', + io_safe_output($value) + ); + } else { + $value = mb_convert_encoding( + preg_replace( + '/\s+/', + '', + io_safe_output($value) + ), + 'UTF-16LE', + 'UTF-8' + ); + } + + $out_csv .= $value.$divider; } $out_csv .= "\n"; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index de618605c8..090bb8bdb9 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -4735,7 +4735,7 @@ function export_agents_module_csv($filters) $query_filter .= ' AND tam.nombre IN '.$module_filter.' '; } else { $module_filter = '('.implode(', ', $filter).')'; - $query_filter .= ' AND tam.id_tipo_modulo IN '.$module_filter.' '; + $query_filter .= ' AND tam.id_agente_modulo IN '.$module_filter.' '; } } break; From c676e7b03014bc6c795e6bec1ea1f8b287902259 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 3 Nov 2023 12:49:19 +0100 Subject: [PATCH 189/414] Fix add alerts pandora_enterprise#12362 --- pandora_console/include/class/AgentsAlerts.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandora_console/include/class/AgentsAlerts.class.php b/pandora_console/include/class/AgentsAlerts.class.php index e55566f469..70c1ff9e3c 100644 --- a/pandora_console/include/class/AgentsAlerts.class.php +++ b/pandora_console/include/class/AgentsAlerts.class.php @@ -457,9 +457,7 @@ class AgentsAlerts extends HTML $template2 = get_parameter('template'); $module_action_threshold = get_parameter('module_action_threshold'); $action_select = get_parameter('action_select', 0); - - $id_alert = alerts_create_alert_agent_module($this->create_alert, $template2); - + $id_alert = alerts_create_alert_agent_module($this->createAlert, $template2); if ($id_alert !== false) { if ($action_select != 0) { $values = []; From 84d450e35ed3ed40d4c6dd75d369329576f9ef4a Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 3 Nov 2023 13:10:09 +0100 Subject: [PATCH 190/414] Fix pagination interfaces pandora_enterprise#12356 --- .../operation/agentes/interface_view.functions.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandora_console/operation/agentes/interface_view.functions.php b/pandora_console/operation/agentes/interface_view.functions.php index 01f7ba75bb..00211d23f0 100644 --- a/pandora_console/operation/agentes/interface_view.functions.php +++ b/pandora_console/operation/agentes/interface_view.functions.php @@ -789,10 +789,6 @@ function print_table( } html_print_table($table); - - if (count($selected_interfaces) > $config['block_size']) { - ui_pagination(count($selected_interfaces), false, $pagination_index, 0, false, 'offset', true, ''); - } } else { ui_print_info_message(['no_close' => true, 'message' => __('No search parameters')]); } From 513a0bc2965ac9c547dd1c3fc8427b2b666713bb Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 3 Nov 2023 14:25:44 +0100 Subject: [PATCH 191/414] #8365 Added csv report for device lists. Fixed overlay for modals --- .../reporting_builder.item_editor.php | 6 +- .../godmode/reporting/reporting_builder.php | 12 +++ .../include/functions_reporting.php | 2 +- .../include/functions_reporting_html.php | 93 +++++++++++++------ pandora_console/include/functions_reports.php | 12 +-- .../include/javascript/pandora_ui.js | 9 +- .../include/styles/js/jquery-ui_custom.css | 6 ++ 7 files changed, 96 insertions(+), 44 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index d13071c60a..f50b451683 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1036,7 +1036,8 @@ switch ($action) { break; case 'ncm': - $idAgent = $item['id_agent']; + $id_agent_ncm = $item['id_agent']; + $ncm_group = $item['id_group']; break; case 'ncm_backups': @@ -7835,7 +7836,8 @@ function chooseType() { break; case 'ncm': - $("#row_agent").show(); + $("#row_ncm_group").show(); + $("#row_ncm_agent").show(); break; case 'ncm_backups': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 349bad535e..f155a89831 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2051,6 +2051,12 @@ switch ($action) { $good_format = true; break; + case 'ncm': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2995,6 +3001,12 @@ switch ($action) { $good_format = true; break; + case 'ncm': + $values['id_agent'] = get_parameter('agent_ncm'); + $values['id_group'] = get_parameter('ncm_group'); + $good_format = true; + break; + default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 19c3f80b10..54f1284a2c 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -965,7 +965,7 @@ function reporting_make_reporting_data( break; case 'ncm': - $report['contents'][] = reporting_ncm_config( + $report['contents'][] = reporting_ncm_list( $report, $content, $pdf diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 76f0920e34..a74fcb4a47 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -477,7 +477,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1, $cust break; case 'ncm': - reporting_html_ncm_config($table, $item); + reporting_html_ncm_list($table, $item); break; case 'ncm_backups': @@ -7347,41 +7347,76 @@ function reporting_html_permissions($table, $item, $pdf=0) /** - * HTML content for ncm configuration diff report. + * HTML content for ncm devices list. * - * @param array $item Content generated by reporting_ncm_config. + * @param array $item Content generated by reporting_ncm_list. * * @return string HTML code. */ -function reporting_html_ncm_config($table, $item, $pdf=0) +function reporting_html_ncm_list($table, $item, $pdf=0) { - $key = uniqid(); + // Create table diff. + $table_ncm = new stdClass(); + $table_ncm->width = '100%'; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->titleclass = 'title_table_pdf'; + + $table_ncm->align = []; + $table_ncm->align['name'] = 'left'; + $table_ncm->align['ip'] = 'left'; + $table_ncm->align['vendor'] = 'left'; + $table_ncm->align['model'] = 'left'; + $table_ncm->align['firmware'] = 'left'; + $table_ncm->align['last_backup_date'] = 'left'; + + $table_ncm->headstyle['name'] = 'text-align: left'; + $table_ncm->headstyle['ip'] = 'text-align: left'; + $table_ncm->headstyle['vendor'] = 'text-align: left'; + $table_ncm->headstyle['model'] = 'text-align: left'; + $table_ncm->headstyle['firmware'] = 'text-align: left'; + $table_ncm->headstyle['last_backup_date'] = 'text-align: left'; + + $table_ncm->head = []; + $table_ncm->head['name'] = __('Name'); + $table_ncm->head['ip'] = __('Ip'); + $table_ncm->head['vendor'] = __('Vendor'); + $table_ncm->head['model'] = __('Model'); + $table_ncm->head['firmware'] = __('Firmware'); + $table_ncm->head['last_backup_date'] = __('Last backup date'); + + $table_ncm->data = []; + foreach ($item['data'] as $key => $row) { + $title = $row['last_error']; + if (empty($title) === true) { + $title = null; + } + + $table_ncm->data[] = [ + $row['alias'], + $row['direccion'], + $row['vendor'], + $row['model'], + $row['firmware'], + $row['last_backup_date'], + ]; + } + if ($pdf === 0) { - ui_require_javascript_file('diff2html-ui.min'); - ui_require_css_file('diff2html.min'); - $script = "$(document).ready(function() { - const configuration = { - drawFileList: false, - collapsed: true, - matching: 'lines', - outputFormat: 'side-by-side', - }; - const diff2htmlUi = new Diff2HtmlUI( - document.getElementById('".$key."'), - atob('".base64_encode($item['data'])."'), - configuration - ); - diff2htmlUi.draw(); - });"; - $content = '
'; - $content .= ''; - $table->data[1] = $content; - $table->colspan[1][0] = 2; + $table->colspan['data']['cell'] = 3; + $table->cellstyle['data']['cell'] = 'text-align: left;'; + $table->data['data']['cell'] = html_print_table( + $table_ncm, + true + ); } else { - $content = '
'; - $content .= str_replace("\n", '
', $item['data']); - $content .= '
'; - return $content; + $table_ncm->titleclass = 'title_table_pdf'; + $table_ncm->titlestyle = 'text-align:left;'; + + return html_print_table( + $table_ncm, + true + ); } } diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 8956e3adc9..c3f6427ac2 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -963,14 +963,14 @@ function reports_get_report_types($template=false, $not_editor=false) ]; } - $types['ncm'] = [ - 'optgroup' => __('NCM'), - 'name' => __('Network configuration changes'), - ]; - $types['ncm_backups'] = [ 'optgroup' => __('NCM'), - 'name' => __('Network backups'), + 'name' => __('NCM configuration changes'), + ]; + + $types['ncm'] = [ + 'optgroup' => __('NCM'), + 'name' => __('NCM devices list'), ]; if (enterprise_installed() === true) { diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 45ca47e92b..80ddfd06f5 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -104,11 +104,8 @@ function load_modal(settings) { width = settings.onshow.width; } - if (settings.modal.overlay == undefined) { - settings.modal.overlay = { - opacity: 0.5, - background: "black" - }; + if (settings.modal.overlay === true) { + $("body").append(""); } if (settings.beforeClose == undefined) { @@ -496,7 +493,6 @@ function load_modal(settings) { settings.onshow.maxHeight != undefined ? settings.onshow.maxHeight : "auto", - overlay: settings.modal.overlay, position: { my: "top+20%", at: "top", @@ -518,6 +514,7 @@ function load_modal(settings) { if (settings.cleanup != undefined) { settings.cleanup(); } + $("#modal_overlay").removeClass("ui-widget-overlay"); }, beforeClose: settings.beforeClose() }); diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index 9c17d7fdab..905c3d5d67 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -371,3 +371,9 @@ input[type="submit"].ui-button-dialog { .ui_tpicker_time { margin-left: 10px !important; } + +.ui-widget-overlay { + background: #aaa !important; + opacity: 0.3 !important; + z-index: 1114; +} From 92ee718f918c4730e784a089f02b4417661ad5df Mon Sep 17 00:00:00 2001 From: Calvo Date: Fri, 3 Nov 2023 17:48:15 +0100 Subject: [PATCH 192/414] Optimiized monitors view --- .../operation/agentes/status_monitor.php | 115 +++++++++--------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 046fbc5222..5868b73707 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -27,6 +27,7 @@ */ // Begin. +use PandoraFMS\Enterprise\Metaconsole\Node; global $config; check_login(); @@ -188,7 +189,7 @@ $sql_from = ' FROM tagente_modulo INNER JOIN tagente ON tagente_modulo.id_agente = tagente.id_agente LEFT JOIN tagent_secondary_group tasg - ON tagente.id_agente = tasg.id_agent + ON tagente_modulo.id_agente = tasg.id_agent INNER JOIN tagente_estado ON tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo INNER JOIN tmodule @@ -436,12 +437,22 @@ if ($moduletype != '') { // Freestring selector. if ($ag_freestring != '') { - $sql_conditions .= ' AND (tagente.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente.alias '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' - OR tagente_modulo.descripcion '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\')'; + $sql_conditions .= ' AND EXISTS ( + SELECT 1 + FROM tagente + WHERE tagente.id_agente = tagente_modulo.id_agente + AND ( + tagente.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' OR tagente.alias '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + ) + AND ( + tagente_modulo.nombre '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\' + OR tagente_modulo.descripcion '.$not_condition.' LIKE \'%%'.$ag_freestring.'%%\') + )'; } + + + // Status selector. if ($status == AGENT_MODULE_STATUS_NORMAL) { // Normal. @@ -1348,15 +1359,10 @@ $sql = 'SELECT tagente.nombre AS agent_name, tagente_modulo.nombre AS module_name, tagente_modulo.history_data, - tagente_modulo.flag AS flag, tagente.id_grupo AS id_group, tagente.id_agente AS id_agent, tagente_modulo.id_tipo_modulo AS module_type, tagente_modulo.module_interval, - tagente_modulo.tcp_send, - tagente_modulo.ip_target, - tagente_modulo.snmp_community, - tagente_modulo.snmp_oid, tagente_estado.datos, tagente_estado.estado, tagente_estado.last_status_change, @@ -1370,13 +1376,12 @@ $sql = 'SELECT tagente_modulo.extended_info, tagente_modulo.critical_inverse, tagente_modulo.warning_inverse, - tagente_modulo.critical_instructions, - tagente_modulo.warning_instructions, - tagente_modulo.unknown_instructions, tagente_estado.utimestamp AS utimestamp'.$sql_from.$sql_conditions_all.' GROUP BY tagente_modulo.id_agente_modulo ORDER BY '.$order['field'].' '.$order['order'].' - LIMIT '.$offset.','.$limit_sql; + LIMIT '.$limit_sql.' OFFSET '.$offset; + + hd($sql); // We do not show the modules until the user searches with the filter. if ($autosearch) { @@ -1402,53 +1407,53 @@ if ($autosearch) { $result = []; $count_modules = 0; foreach ($servers as $server) { - // If connection was good then retrieve all data server. - if (metaconsole_connect($server) === NOERR) { - $connection = true; - } else { - $connection = false; - } + try { + $node = new Node((int) $server['id']); + $node->connect(); - $result_server = db_get_all_rows_sql($sql); + $result_server = db_get_all_rows_sql($sql); - if (empty($result_server) === false) { - // Create HASH login info. - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd, true); + if (empty($result_server) === false) { + // Create HASH login info. + $pwd = $server['auth_token']; + $auth_serialized = json_decode($pwd, true); - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; + if (is_array($auth_serialized)) { + $pwd = $auth_serialized['auth_token']; + $api_password = $auth_serialized['api_password']; + $console_user = $auth_serialized['console_user']; + $console_password = $auth_serialized['console_password']; + } + + $user = $config['id_user']; + $user_rot13 = str_rot13($config['id_user']); + $hashdata = $user.$pwd; + $hashdata = md5($hashdata); + + foreach ($result_server as $result_element_key => $result_element_value) { + $result_server[$result_element_key]['server_id'] = $server['id']; + $result_server[$result_element_key]['server_name'] = $server['server_name']; + $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; + $result_server[$result_element_key]['hashdata'] = $hashdata; + $result_server[$result_element_key]['user'] = $config['id_user']; + $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( + $result_element_value['id_agent'], + $result_element_value['id_group'] + ); + + $count_modules++; + } + + $result = array_merge($result, $result_server); } - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&'.'loginhash=auto&'.'loginhash_data='.$hashdata.'&'.'loginhash_user='.$user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - $result_server[$result_element_key]['groups_in_server'] = agents_get_all_groups_agent( - $result_element_value['id_agent'], - $result_element_value['id_group'] - ); - - $count_modules++; - } - - $result = array_merge($result, $result_server); + usort($result, arrayOutputSorting($sort, $fieldForSorting)); + } catch (\Exception $e) { + $node->disconnect(); + return; + } finally { + $node->disconnect(); } - - usort($result, arrayOutputSorting($sort, $fieldForSorting)); - - metaconsole_restore_db(); } if ($count_modules > $config['block_size']) { From de22886cec066620ab88307d6be36889a5b0fabc Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 6 Nov 2023 08:55:21 +0100 Subject: [PATCH 193/414] #11679 Fix edit module link in search and fix checkbox switch bug in edit module --- .../godmode/agentes/module_manager_editor_common.php | 3 +-- pandora_console/operation/search_modules.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index ca74b7d171..881704f809 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1387,11 +1387,10 @@ $table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( 'made_enabled', 1, (bool) $made_enabled, - false, + true, false, '', false, - false, 'wp100 static' ); diff --git a/pandora_console/operation/search_modules.php b/pandora_console/operation/search_modules.php index 41d545928f..e2ae260d3c 100644 --- a/pandora_console/operation/search_modules.php +++ b/pandora_console/operation/search_modules.php @@ -79,7 +79,7 @@ if (!$modules || !$searchModules) { $module['datos'] = modules_get_last_value($module['id_agente_modulo']); $module['module_name'] = $module['nombre']; - $linked_module_name = ''; + $linked_module_name = ''; $linked_module_name .= $module['module_name']; $linked_module_name .= ''; // To search the monitor status @@ -219,7 +219,7 @@ if (!$modules || !$searchModules) { $url_edit = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$module['id_agente'].'&tab=module&id_agent_module='.$module['id_agente_modulo'].'&edit_module=1'; - $edit_module = ''.html_print_image('images/edit.svg', true).''; + $edit_module = ''.html_print_image('images/edit.svg', true, ['class' => 'invert_filter main_menu_icon']).''; } else { $edit_module = ''; } From f71479033d8074513fd8342867803728030c9e03 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 6 Nov 2023 13:06:38 +0100 Subject: [PATCH 194/414] Hide test button and setup in ITSM pandora_enterprise#12243 --- pandora_console/godmode/setup/setup_ITSM.php | 3 ++- pandora_console/include/lib/ITSM/Manager.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index 3196ef677c..012d80f849 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -187,7 +187,8 @@ $button_test .= ' '; $row['control'] = html_print_label_input_block( __('Test connection pandora to ITSM'), - $button_test + $button_test, + ['div_class' => 'ITSM-remote-setup-ITSM_token'] ); $table_remote->data['ITSM_test'] = $row; diff --git a/pandora_console/include/lib/ITSM/Manager.php b/pandora_console/include/lib/ITSM/Manager.php index 14bd693ed7..eebf3f665e 100644 --- a/pandora_console/include/lib/ITSM/Manager.php +++ b/pandora_console/include/lib/ITSM/Manager.php @@ -1120,7 +1120,10 @@ class Manager } $onheader = []; - $onheader['configure'] = $setup_tab; + if (users_is_admin() === true) { + $onheader['configure'] = $setup_tab; + } + $onheader['dashboard'] = $dashboard_tab; $onheader['list'] = $list_tab; if ($idIncidence !== 0) { From 3506ba1b5a3e6ffe37beb33f0d72d6b65c0bb5bd Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 15:06:16 +0100 Subject: [PATCH 195/414] Added default NCM templates --- pandora_console/extras/mr/67.sql | 1007 ++++++++++++++++++++++++++++ pandora_console/pandoradb_data.sql | 146 +++- 2 files changed, 1148 insertions(+), 5 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index b2b34e5ce4..2a604941e0 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -29,5 +29,1012 @@ ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_i ALTER TABLE `tncm_agent` ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +-- Add new vendor and model +SET @vendor_name = 'Cisco'; +SET @model_name = 'Cisco-Generic'; +SET @template_name = 'Cisco-Generic'; +SET @agent_data_template_name = 'Cisco-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'; +SET @script_set_config = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'; +SET @script_set_firmware = 'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Juniper'; +SET @model_name = 'Juniper-Generic'; +SET @template_name = 'Juniper-Generic'; +SET @agent_data_template_name = 'Juniper-Generic'; +SET @script_test = 'expect:root@% cli\n exit\n'; +SET @script_get_config = 'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'; +SET @script_set_config = 'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'; +SET @script_get_firmware = 'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'; +SET @script_set_firmware = 'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Palo Alto'; +SET @model_name = 'Palo Alto-Generic'; +SET @template_name = 'Palo Alto-Generic'; +SET @agent_data_template_name = 'Palo Alto-Generic'; +SET @script_test = 'sleep:1 exit\n'; +SET @script_get_config = 'set cli pager off \n capture:show config running\n exit\n'; +SET @script_set_config = 'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'; +SET @script_get_firmware = 'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'; +SET @script_set_firmware = 'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'A10'; +SET @model_name = 'A10-Generic'; +SET @template_name = 'A10-Generic'; +SET @agent_data_template_name = 'A10-Generic'; +SET @script_test = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n'; +SET @script_get_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'; +SET @script_get_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Alcatel-Lucent Enterprise'; +SET @model_name = 'Alcatel-Generic'; +SET @template_name = 'Alcatel-Generic'; +SET @agent_data_template_name = 'Alcatel-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'; +SET @script_set_config = ''; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'; +SET @script_set_firmware = ''; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Aruba'; +SET @model_name = 'Aruba-Generic'; +SET @template_name = 'Aruba-Generic'; +SET @agent_data_template_name = 'Aruba-Generic'; +SET @script_test = 'enable\n expect:Password:\s* _enablepass_\n exit\n'; +SET @script_get_config = 'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'; +SET @script_set_config = 'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'; +SET @script_get_firmware = 'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'; +SET @script_set_firmware = 'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); + +-- Add new vendor and model +SET @vendor_name = 'Mikrotik'; +SET @model_name = 'Mikrotik-Generic'; +SET @template_name = 'Mikrotik-Generic'; +SET @agent_data_template_name = 'Mikrotik-Generic'; +SET @script_test = 'sleep:1 exit\n\r'; +SET @script_get_config = 'sleep:1 capture:system resource print\n\r exit\n\r'; +SET @script_set_config = 'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'; +SET @script_get_firmware = 'sleep:1 capture:/system package print\n\r exit\n\r'; +SET @script_set_firmware = 'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'; +SET @script_custom = ''; +SET @script_os_version = @script_get_firmware; + +-- Try to insert vendor +INSERT IGNORE INTO `tncm_vendor` (`id`, `name`, `icon`) VALUES ('', @vendor_name, ''); +-- Get vendor ID +SELECT @id_vendor := `id` FROM `tncm_vendor` WHERE `name` = @vendor_name; + +-- Try to insert model +INSERT IGNORE INTO `tncm_model` (`id`, `id_vendor`, `name`) VALUES ('', @id_vendor, @model_name); +-- Get model ID +SELECT @id_model := `id` FROM `tncm_model` WHERE `id_vendor` = @id_vendor AND `name` = @model_name; + +-- Get template ID if exists +SET @id_template = NULL; +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; +-- Try to insert template +INSERT IGNORE INTO `tncm_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_template, @template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get template ID again if inserted +SELECT @id_template := `id` FROM `tncm_template` WHERE `name` = @template_name; + +-- Get agent data template ID if exists +SET @id_agent_data_template = NULL; +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; +-- Try to insert agent data template +INSERT IGNORE INTO `tncm_agent_data_template` (`id`, `name`, `vendors`, `models`) VALUES (@id_agent_data_template, @agent_data_template_name, CONCAT('[',@id_vendor,']'), CONCAT('[',@id_model,']')); +-- Get agent data template ID again if inserted +SELECT @id_agent_data_template := `id` FROM `tncm_agent_data_template` WHERE `name` = @agent_data_template_name; + +-- Get test script ID if exists +SET @id_script_test = NULL; +SET @script_type = 0; +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; +-- Try to insert test script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_test, @script_type, @script_test); +-- Get test script ID again if inserted +SELECT @id_script_test := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_test; + +-- Get get_config script ID if exists +SET @id_script_get_config = NULL; +SET @script_type = 1; +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; +-- Try to insert get_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_config, @script_type, @script_get_config); +-- Get get_config script ID again if inserted +SELECT @id_script_get_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_config; + +-- Get set_config script ID if exists +SET @id_script_set_config = NULL; +SET @script_type = 2; +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; +-- Try to insert set_config script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_config, @script_type, @script_set_config); +-- Get set_config script ID again if inserted +SELECT @id_script_set_config := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_config; + +-- Get get_firmware script ID if exists +SET @id_script_get_firmware = NULL; +SET @script_type = 3; +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; +-- Try to insert get_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_get_firmware, @script_type, @script_get_firmware); +-- Get get_firmware script ID again if inserted +SELECT @id_script_get_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_get_firmware; + +-- Get set_firmware script ID if exists +SET @id_script_set_firmware = NULL; +SET @script_type = 4; +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; +-- Try to insert set_firmware script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_set_firmware, @script_type, @script_set_firmware); +-- Get set_firmware script ID again if inserted +SELECT @id_script_set_firmware := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_set_firmware; + +-- Get custom script ID if exists +SET @id_script_custom = NULL; +SET @script_type = 5; +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; +-- Try to insert custom script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_custom, @script_type, @script_custom); +-- Get custom script ID again if inserted +SELECT @id_script_custom := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_custom; + +-- Get os_version script ID if exists +SET @id_script_os_version = NULL; +SET @script_type = 7; +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; +-- Try to insert os_version script +INSERT IGNORE INTO `tncm_script` (`id`, `type`, `content`) VALUES (@id_script_os_version, @script_type, @script_os_version); +-- Get os_version script ID again if inserted +SELECT @id_script_os_version := `id` FROM `tncm_script` WHERE `type` = @script_type AND `content` = @script_os_version; + +-- Get template scripts ID if exists +SET @id_ts_test = NULL; +SELECT @id_ts_test := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_test; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_test, @id_template, @id_script_test); + +-- Get template scripts ID if exists +SET @id_ts_get_config = NULL; +SELECT @id_ts_get_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_config, @id_template, @id_script_get_config); + +-- Get template scripts ID if exists +SET @id_ts_set_config = NULL; +SELECT @id_ts_set_config := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_config; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_config, @id_template, @id_script_set_config); + +-- Get template scripts ID if exists +SET @id_ts_get_firmware = NULL; +SELECT @id_ts_get_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_get_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_get_firmware, @id_template, @id_script_get_firmware); + +-- Get template scripts ID if exists +SET @id_ts_set_firmware = NULL; +SELECT @id_ts_set_firmware := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_set_firmware; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_set_firmware, @id_template, @id_script_set_firmware); + +-- Get template scripts ID if exists +SET @id_ts_custom = NULL; +SELECT @id_ts_custom := `id` FROM `tncm_template_scripts` WHERE `id_template` = @id_template AND `id_script` = @id_script_custom; +-- Try to insert +INSERT IGNORE INTO `tncm_template_scripts` (`id`, `id_template`, `id_script`) VALUES (@id_ts_custom, @id_template, @id_script_custom); + +-- Get template scripts ID if exists +SET @id_ts_os_version = NULL; +SELECT @id_ts_os_version := `id` FROM `tncm_agent_data_template_scripts` WHERE `id_agent_data_template` = @id_template AND `id_script` = @id_script_os_version; +-- Try to insert +INSERT IGNORE INTO `tncm_agent_data_template_scripts` (`id`, `id_agent_data_template`, `id_script`) VALUES (@id_ts_os_version, @id_agent_data_template, @id_script_os_version); COMMIT; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 47365fcc6e..8229c96ee7 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2512,11 +2512,32 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (11, 'Netlink'), (12, 'Ascom'), (13, 'Synology Inc.'), - (14, 'Fujitsu Network Communications, Inc.'); + (14, 'Fujitsu Network Communications, Inc.'), + (15, 'Juniper'), + (16, 'Palo Alto'), + (17, 'A10'), + (18, 'Aruba'), + (19, 'Mikrotik'); -INSERT INTO `tncm_model` VALUES (1,1,'7200'); +INSERT INTO `tncm_model` VALUES + (1,1,'7200'), + (2,1,'Cisco-Generic'), + (3,15,'Juniper-Generic'), + (4,16,'Palo Alto-Generic'), + (5,17,'A10-Generic'), + (6,4,'Alcatel-Generic'), + (7,18,'Aruba-Generic'), + (8,19,'Mikrotik-Generic'); -INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'); +INSERT INTO `tncm_template` VALUES + (1,'cisco-base','[\"1\"]','[\"1\"]'), + (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (5,'A10-Generic','[\"17\"]','[\"5\"]'), + (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), @@ -2524,9 +2545,124 @@ INSERT INTO `tncm_script` VALUES (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), - (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'); + (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), + (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), + (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), + (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), + (12,5,''), + (13,7,''), + (14,0,'expect:root@% cli\n exit\n'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), + (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), + (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), + (19,5,''), + (20,7,''), + (21,0,'sleep:1 exit\n'), + (22,1,'set cli pager off \n capture:show config running\n exit\n'), + (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), + (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), + (26,5,''), + (27,7,''), + (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), + (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), + (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), + (33,5,''), + (34,7,''), + (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), + (37,2,''), + (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (39,4,''), + (40,5,''), + (41,7,''), + (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), + (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), + (47,5,''), + (48,7,''), + (49,0,'sleep:1 exit\n\r'), + (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), + (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), + (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), + (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), + (54,5,''), + (55,7,''); -INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6); +INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES + (1,1), + (1,2), + (1,3), + (1,4), + (1,5), + (1,6), + (2,7), + (2,8), + (2,9), + (2,10), + (2,11), + (2,12), + (3,14), + (3,15), + (3,16), + (3,17), + (3,18), + (3,19), + (4,21), + (4,22), + (4,23), + (4,24), + (4,25), + (4,26), + (5,28), + (5,29), + (5,30), + (5,31), + (5,32), + (5,33), + (6,35), + (6,36), + (6,37), + (6,38), + (6,39), + (6,40), + (7,42), + (7,43), + (7,44), + (7,45), + (7,46), + (7,47), + (8,49), + (8,50), + (8,51), + (8,52), + (8,53), + (8,54); + +INSERT INTO `tncm_agent_data_template` VALUES + (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (4,'A10-Generic','[\"17\"]','[\"5\"]'), + (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + +INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES + (1,13), + (2,20), + (3,27), + (4,34), + (5,41), + (6,48), + (7,55), INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From c266640f39c64c1b747ff6cb8f934b4c8972dadc Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 15:07:43 +0100 Subject: [PATCH 196/414] Fixed syntax error in SQL --- pandora_console/pandoradb_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 8229c96ee7..7f3664620a 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2662,7 +2662,7 @@ INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_scr (4,34), (5,41), (6,48), - (7,55), + (7,55); INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From afa18d22213009e184da0d6ffe59c4f4a10f5b81 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 6 Nov 2023 15:32:20 +0100 Subject: [PATCH 197/414] #12082 Fix inventory widget --- pandora_console/include/lib/Dashboard/Widgets/inventory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/inventory.php b/pandora_console/include/lib/Dashboard/Widgets/inventory.php index 1df7f8cc50..fd27a581e6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/inventory.php +++ b/pandora_console/include/lib/Dashboard/Widgets/inventory.php @@ -1091,9 +1091,11 @@ class InventoryWidget extends Widget __('Values Custom Fields'), ]; + $basic_info_id = 'id_'.$row['id_module_inventory'].'_'.$cellId; + ui_print_datatable( [ - 'id' => 'basic_info', + 'id' => $basic_info_id, 'class' => $class, 'style' => $style, 'columns' => $columns, From 26ed76b82109a765bfda684fb0bd98932178bf0f Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 16:41:37 +0100 Subject: [PATCH 198/414] Fixed SQL issue --- pandora_console/pandoradb_data.sql | 302 ++++++++++++++--------------- 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7f3664620a..7e4bee1954 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -369,11 +369,11 @@ INSERT INTO `tusuario_perfil` (`id_up`, `id_usuario`, `id_perfil`, `id_grupo`, ` -- INSERT INTO `tperfil` VALUES - (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), - (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), - (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), - (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), - (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); + (1,'Operator (Read)',1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0), + (2,'Operator (Write)',1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,0), + (3,'Chief Operator',1,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0), + (4,'Group coordinator',1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0), + (5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -- -- Dumping data for table `tnews` @@ -388,7 +388,7 @@ INSERT INTO tmodule VALUES (5,'Prediction module'); INSERT INTO tmodule VALUES (6,'WMI module'); INSERT INTO tmodule VALUES (7, 'Web module'); INSERT INTO tmodule VALUES (8, 'Wux module'); -INSERT INTO tmodule VALUES (9, 'Wizard module'); +INSERT INTO tmodule VALUES (9, 'Wizard module'); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (1,'OS Total process','Total process in Operating System (UNIX MIB)',13,15,0,0,300,0,'','','public','HOST-RESOURCES-MIB::hrSystemProcesses.0 ',4,2,0,NULL,NULL,NULL,0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -732,11 +732,11 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (513,'MSDTC TransactionsPersec','Transactions performed per second.',22,1,0,0,300,0,'','','','select TransactionsPersec from Win32_PerfRawData_MSDTC_DistributedTransactionCoordinator',3,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (514,'c2900InfoPeakBuffersUsed','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.2.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (515,'c2900InfoTotalBufferDepth','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.1.3.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (516,'c2900BandwidthUsageCurrent ','ftp://ftp.cisco.com/pub/mibs/oid/CISCO-C2900-MIB.oid',23,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.87.1.5.1.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (517,'Latest Message ','Get the last message sent in Syslog',2,17,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.5.12',1,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (518,'Latest Message date','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.9.41.1.2.3.1.6.12',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (519,'CPU avgBusy1min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.57.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (520,'CPU avgBusy5min ','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.2.1.58.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (521,'Software Image running ','',2,17,0,0,1800,0,'','','public','1.3.6.1.4.1.9.2.1.73.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (522,'nvRAMUsed','',2,15,0,0,300,0,'','','public','1.3.6.1.4.1.9.3.6.8.0',2,2,0,'','','0',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (523,'Printers BytesPrintedPersec','Number of bytes per second printed on a print queue.',24,1,0,0,300,0,'','','','select BytesPrintedPersec from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); @@ -748,7 +748,7 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (529,'Printers OutofPaperErrors','Total number of out-of-paper errors in a print queue after the last restart.',24,1,0,0,300,0,'','','','select OutofPaperErrors from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (530,'Printers TotalJobsPrinted','Total number of jobs printed on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalJobsPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (531,'Printers TotalPagesPrinted','Total number of pages printed through GDI on a print queue after the last restart.',24,1,0,0,300,0,'','','','select TotalPagesPrinted from Win32_PerfRawData_Spooler_PrintQueue where NAME = '_total'',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); -INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); +INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (532,'Printers Availability','Availability and status of the device\r\n\r\nValue Meaning\r\n\r\n10x1 Other\r\n\r\n20x2 Unknown\r\n\r\n30x3 Running or Full Power\r\n\r\n40x4 Warning\r\n\r\n50x5 In Test\r\n\r\n60x6 Not Applicable\r',24,3,0,0,300,0,'','','','select Availability from Win32_Printer',5,6,0,'','','10',0,1,0.00,0.00,NULL,0.00,0.00,NULL,0,NULL,NULL,NULL,0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (533,'Serv_IISAdmin','IIS Administration Server service status.',26,2,0,0,300,0,'','','Running','Select State from Win32_Service WHERE name = 'IISAdmin'',3,6,0,'Administrador','6683','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (534,'Serv_MSSQL_server','Displays if MS SQL SERVER is running',27,2,0,0,0,0,'','','Running','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`, `id_modulo`, `id_plugin`, `plugin_user`, `plugin_pass`, `plugin_parameter`, `max_timeout`, `history_data`, `min_warning`, `max_warning`, `str_warning`, `min_critical`, `max_critical`, `str_critical`, `min_ff_event`, `custom_string_1`, `custom_string_2`, `custom_string_3`, `custom_integer_1`, `custom_integer_2`, `post_process`, `wizard_level`, `critical_instructions`, `warning_instructions`, `unknown_instructions`, `tags`, `disabled_types_event`, `module_macros`) VALUES (535,'SQLServer_DataFilesSizeKB','Sql database size in kb ',27,1,0,0,0,0,'','','','select state from Win32_Service where name = "MSSQLSERVER"',7,6,0,'','','',0,1,0.00,0.00,'',0.00,0.00,'',0,'','','',0,0,0.0000000000000,'basic','','','','','',''); @@ -1290,8 +1290,8 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; -- Dumping data for table `tlog_graph_models` -- INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', - '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', - 'pagina, html_err_code, _tiempo_', 1); + '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', + 'pagina, html_err_code, _tiempo_', 1); INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', '(.*?)\ -.*1.1"\ (\d+)\ \d+', @@ -1347,13 +1347,13 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System INSERT INTO `tpen` VALUES - (9,'cisco','Cisco System'), - (11,'hp','Hewlett Packard'), - (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), - (2636,'juniper','Juniper Networks'), - (3375,'f5','F5 Labs'), - (8072,'general_snmp','Net SNMP'), - (12356,'fortinet','Fortinet') + (9,'cisco','Cisco System'), + (11,'hp','Hewlett Packard'), + (2021,'general_snmp','U.C. Davis, ECE Dept. Tom'), + (2636,'juniper','Juniper Networks'), + (3375,'f5','F5 Labs'), + (8072,'general_snmp','Net SNMP'), + (12356,'fortinet','Fortinet') ; -- @@ -2500,7 +2500,7 @@ INSERT IGNORE INTO `tpen` VALUES (171,'dlink','D-Link Systems, Inc.'),(14988,'mi INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (1,'Cisco'), - (2, 'D-Link Systems, Inc.'), + (2, 'D-Link Systems, Inc.'), (3, 'MikroTik'), (4, 'Alcatel-Lucent Enterprise'), (5, 'Ubiquiti Networks, Inc.'), @@ -2520,149 +2520,149 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (19, 'Mikrotik'); INSERT INTO `tncm_model` VALUES - (1,1,'7200'), - (2,1,'Cisco-Generic'), - (3,15,'Juniper-Generic'), - (4,16,'Palo Alto-Generic'), - (5,17,'A10-Generic'), - (6,4,'Alcatel-Generic'), - (7,18,'Aruba-Generic'), - (8,19,'Mikrotik-Generic'); + (1,1,'7200'), + (2,1,'Cisco-Generic'), + (3,15,'Juniper-Generic'), + (4,16,'Palo Alto-Generic'), + (5,17,'A10-Generic'), + (6,4,'Alcatel-Generic'), + (7,18,'Aruba-Generic'), + (8,19,'Mikrotik-Generic'); INSERT INTO `tncm_template` VALUES - (1,'cisco-base','[\"1\"]','[\"1\"]'), - (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), - (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), - (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), - (5,'A10-Generic','[\"17\"]','[\"5\"]'), - (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), - (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (1,'cisco-base','[\"1\"]','[\"1\"]'), + (2,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (3,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (4,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (5,'A10-Generic','[\"17\"]','[\"5\"]'), + (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), (2,1,'enable expect:Password:\s* _enablepass_ term length 0 capture:show running-config exit '), - (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), - (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), - (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), - (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), - (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), - (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), - (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), - (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), - (12,5,''), - (13,7,''), - (14,0,'expect:root@% cli\n exit\n'), - (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), - (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), - (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), - (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), - (19,5,''), - (20,7,''), - (21,0,'sleep:1 exit\n'), - (22,1,'set cli pager off \n capture:show config running\n exit\n'), - (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), - (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), - (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), - (26,5,''), - (27,7,''), - (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), - (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), - (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), - (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), - (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), - (33,5,''), - (34,7,''), - (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), - (37,2,''), - (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), - (39,4,''), - (40,5,''), - (41,7,''), - (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), - (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), - (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), - (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), - (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), - (47,5,''), - (48,7,''), - (49,0,'sleep:1 exit\n\r'), - (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), - (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), - (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), - (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), - (54,5,''), - (55,7,''); + (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), + (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), + (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '), + (6,4,'copy tftp flash expect:\]\? _TFTP_SERVER_IP_ expect:\]\? _SOURCE_FILE_NAME_ expect:\]\? _DESTINATION_FILE_NAME_ show flash reload expect:confirm y config terminal boot system _DESTINATION_FILE_NAME_'), + (7,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (8,1,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show running-config\n exit\n'), + (9,2,'enable\n expect:Password:\s* _enablepass_\n term length 0\n config terminal\n _applyconfigbackup_\n exit\n'), + (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), + (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), + (12,5,''), + (13,7,''), + (14,0,'expect:root@% cli\n exit\n'), + (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), + (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), + (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), + (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), + (19,5,''), + (20,7,''), + (21,0,'sleep:1 exit\n'), + (22,1,'set cli pager off \n capture:show config running\n exit\n'), + (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), + (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), + (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), + (26,5,''), + (27,7,''), + (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), + (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), + (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), + (33,5,''), + (34,7,''), + (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), + (37,2,''), + (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), + (39,4,''), + (40,5,''), + (41,7,''), + (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), + (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), + (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), + (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), + (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), + (47,5,''), + (48,7,''), + (49,0,'sleep:1 exit\n\r'), + (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), + (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), + (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), + (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), + (54,5,''), + (55,7,''); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES - (1,1), - (1,2), - (1,3), - (1,4), - (1,5), - (1,6), - (2,7), - (2,8), - (2,9), - (2,10), - (2,11), - (2,12), - (3,14), - (3,15), - (3,16), - (3,17), - (3,18), - (3,19), - (4,21), - (4,22), - (4,23), - (4,24), - (4,25), - (4,26), - (5,28), - (5,29), - (5,30), - (5,31), - (5,32), - (5,33), - (6,35), - (6,36), - (6,37), - (6,38), - (6,39), - (6,40), - (7,42), - (7,43), - (7,44), - (7,45), - (7,46), - (7,47), - (8,49), - (8,50), - (8,51), - (8,52), - (8,53), - (8,54); + (1,1), + (1,2), + (1,3), + (1,4), + (1,5), + (1,6), + (2,7), + (2,8), + (2,9), + (2,10), + (2,11), + (2,12), + (3,14), + (3,15), + (3,16), + (3,17), + (3,18), + (3,19), + (4,21), + (4,22), + (4,23), + (4,24), + (4,25), + (4,26), + (5,28), + (5,29), + (5,30), + (5,31), + (5,32), + (5,33), + (6,35), + (6,36), + (6,37), + (6,38), + (6,39), + (6,40), + (7,42), + (7,43), + (7,44), + (7,45), + (7,46), + (7,47), + (8,49), + (8,50), + (8,51), + (8,52), + (8,53), + (8,54); INSERT INTO `tncm_agent_data_template` VALUES - (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), - (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), - (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), - (4,'A10-Generic','[\"17\"]','[\"5\"]'), - (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), - (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (1,'Cisco-Generic','[\"1\"]','[\"2\"]'), + (2,'Juniper-Generic','[\"15\"]','[\"3\"]'), + (3,'Palo Alto-Generic','[\"16\"]','[\"4\"]'), + (4,'A10-Generic','[\"17\"]','[\"5\"]'), + (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), + (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), + (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES - (1,13), - (2,20), - (3,27), - (4,34), - (5,41), - (6,48), - (7,55); + (1,13), + (2,20), + (3,27), + (4,34), + (5,41), + (6,48), + (7,55); INSERT INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); From 86804398fe8b619aab7a488b6728be41993082f2 Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Mon, 6 Nov 2023 16:50:54 +0100 Subject: [PATCH 199/414] Fixed SQL issue --- pandora_console/pandoradb_data.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7e4bee1954..e7327e578b 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2516,8 +2516,7 @@ INSERT INTO `tncm_vendor` (`id`, `name`) VALUES (15, 'Juniper'), (16, 'Palo Alto'), (17, 'A10'), - (18, 'Aruba'), - (19, 'Mikrotik'); + (18, 'Aruba'); INSERT INTO `tncm_model` VALUES (1,1,'7200'), @@ -2527,7 +2526,7 @@ INSERT INTO `tncm_model` VALUES (5,17,'A10-Generic'), (6,4,'Alcatel-Generic'), (7,18,'Aruba-Generic'), - (8,19,'Mikrotik-Generic'); + (8,3,'Mikrotik-Generic'); INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'), @@ -2537,7 +2536,7 @@ INSERT INTO `tncm_template` VALUES (5,'A10-Generic','[\"17\"]','[\"5\"]'), (6,'Alcatel-Generic','[\"4\"]','[\"6\"]'), (7,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (8,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (8,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); INSERT INTO `tncm_script` VALUES (1,0,'enable expect:Password:\s* _enablepass_ exit'), @@ -2653,7 +2652,7 @@ INSERT INTO `tncm_agent_data_template` VALUES (4,'A10-Generic','[\"17\"]','[\"5\"]'), (5,'Alcatel-Generic','[\"4\"]','[\"6\"]'), (6,'Aruba-Generic','[\"18\"]','[\"7\"]'), - (7,'Mikrotik-Generic','[\"19\"]','[\"8\"]'); + (7,'Mikrotik-Generic','[\"3\"]','[\"8\"]'); INSERT INTO `tncm_agent_data_template_scripts`(`id_agent_data_template`, `id_script`) VALUES (1,13), From 545316e9a8f1ef55e9edddf2b48e71ada47a1cd5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 08:35:49 +0100 Subject: [PATCH 200/414] #11763 regex fix html entities --- pandora_console/operation/events/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 57c7111885..e4aa2aa5fe 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -132,7 +132,7 @@ $severity = get_parameter( ); $regex = get_parameter( 'filter[regex]', - ($filter['regex'] ?? '') + (io_safe_output($filter['regex']) ?? '') ); unset($filter['regex']); $status = get_parameter( From aaa590b65fd8ac0ee75e4b2e0ca52c9f7ecca8e6 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 7 Nov 2023 09:20:48 +0100 Subject: [PATCH 201/414] VC Public links pandora_enterprise#12329 --- pandora_console/ajax.php | 4 +- .../javascript/pandora_visual_console.js | 4 +- .../rest-api/models/VisualConsole/Item.php | 8 ++-- .../operation/visual_console/public_view.php | 48 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index b3b9463ee6..a5dcf2cb0d 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true $_SESSION = []; session_destroy(); header_remove('Set-Cookie'); - setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + if (isset($_COOKIE[session_name()]) === true) { + setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + } if ($config['auth'] === 'saml' && empty($public_hash) === true) { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js index adcbd3ce0c..0e16bb303f 100755 --- a/pandora_console/include/javascript/pandora_visual_console.js +++ b/pandora_console/include/javascript/pandora_visual_console.js @@ -808,8 +808,8 @@ function loadVisualConsoleData( getVisualConsoleItems: 1, size: size, visualConsoleId: vcId, - id_user: typeof id_user == undefined ? id_user : null, - auth_hash: typeof hash == undefined ? hash : null, + id_user: typeof id_user !== undefined ? id_user : null, + auth_hash: typeof hash !== undefined ? hash : null, mode: mode, widthScreen: widthScreen }, diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index 0db9d999c2..411d605c0e 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1196,7 +1196,7 @@ class Item extends CachedModel 'operation/visual_console/view', ['id' => $vcId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'page' => 'visualmap', @@ -1302,7 +1302,7 @@ class Item extends CachedModel 'enterprise/operation/services/services', ['id_service' => $serviceId], // No autologin from the public view. - !$config['public_view'] + !$config['public_access'] ); } else { // A regular module. @@ -1312,7 +1312,7 @@ class Item extends CachedModel 'operation/agentes/status_monitor', ['id_module' => $moduleId], // No autologin from the public view. - !((isset($config['public_view']) === true) ? $config['public_view'] : false), + !((isset($config['public_access']) === true) ? $config['public_access'] : false), $mobile_navigation, [ 'id' => $moduleId, @@ -1377,7 +1377,7 @@ class Item extends CachedModel 'operation/agentes/ver_agente', ['id_agente' => $agentId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'id' => $agentId, diff --git a/pandora_console/operation/visual_console/public_view.php b/pandora_console/operation/visual_console/public_view.php index 46dd4e43b4..64529133b4 100644 --- a/pandora_console/operation/visual_console/public_view.php +++ b/pandora_console/operation/visual_console/public_view.php @@ -33,7 +33,7 @@ require_once $config['homedir'].'/vendor/autoload.php'; ui_require_css_file('register', 'include/styles/', true); // Connection lost alert. -ui_require_javascript_file('connection_check', 'include/javascript/', true); +// ui_require_javascript_file('connection_check', 'include/javascript/', true); set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false)); $conn_title = __('Connection with console has been lost'); $conn_text = __('Connection to the console has been lost. Please check your internet connection.'); @@ -47,7 +47,7 @@ global $vc_public_view; global $config; $vc_public_view = true; -$config['public_view'] = true; +$config['public_access'] = true; // This starts the page head. In the call back function, // things from $page['head'] array will be processed into the head. @@ -62,12 +62,6 @@ require_once 'include/functions_visual_map.php'; $hash = (string) get_parameter('hash'); -// For public link issue. -$force_instant_logout = true; -if (isset($config['id_user']) === true) { - $force_instant_logout = false; -} - // Check input hash. // DO NOT move it after of get parameter user id. if (User::validatePublicHash($hash) !== true) { @@ -256,17 +250,17 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( if (menuLinks !== null) { menuLinks.forEach(function (menuLink) { menuLink.href = menuLink.href.replace(regex, replacement); - menuLink.href = menuLink.href.replace( - regex_hash, - replacement_hash - ); + //menuLink.href = menuLink.href.replace( + // regex_hash, + // replacement_hash + //); }); } // Change the URL (if the browser has support). if ("history" in window) { var href = window.location.href.replace(regex, replacement); - href = href.replace(regex_hash, replacement_hash); + //href = href.replace(regex_hash, replacement_hash); window.history.replaceState({}, document.title, href); } } @@ -321,20 +315,24 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( } } }); - - - // No click enabled when user not logged. - $( "a" ).on( "click", function( event ) { - event.preventDefault(); - $('#visual-console-container').removeClass('is-updating'); - $('.div-visual-console-spinner').remove(); - }); - 0) { + ob_end_flush(); } \ No newline at end of file From 5cc31e26db8202b00089394bbbc00dbe88d0f61e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 09:38:40 +0100 Subject: [PATCH 202/414] #12268 add tooltip redirect message --- .../include/lib/Dashboard/Widgets/EventCardboard.php | 7 ++++++- pandora_console/include/styles/dashboards.css | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php index 13028b3c57..b13995c28e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php +++ b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php @@ -331,8 +331,13 @@ class EventCardboard extends Widget $return_all_group = true; } + $help_tip = ui_print_help_tip( + __('Only the first group selected will be used on the redirect to events view.'), + true + ); + $inputs['inputs']['row1'][] = [ - 'label' => __('Groups'), + 'label' => __('Groups').$help_tip, 'arguments' => [ 'type' => 'select_groups', 'name' => 'groupId[]', diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 818e523316..9f1b4f9bd7 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -953,3 +953,7 @@ input.resize_button { .parent_graph > .graph { margin-left: 10px; } + +.event-cardboard-widget td { + cursor: pointer; +} From d2390979aa68f36dc973824e28026c4d698792bd Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 7 Nov 2023 10:15:00 +0100 Subject: [PATCH 203/414] #12219 Fix icons and metaconsole delete profile --- .../godmode/users/configure_user.php | 116 ++++++++---------- pandora_console/include/functions_profile.php | 20 ++- 2 files changed, 70 insertions(+), 66 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index b313589403..fb774e674c 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -158,92 +158,84 @@ if (is_ajax() === true) { return; } - if ($delete_profile) { - $id2 = (string) get_parameter('id_user'); + if ($delete_profile === true) { + // Get parameters. + $result = false; + $id_user = (string) get_parameter('id_user'); $id_up = (int) get_parameter('id_user_profile'); + $delete_user = (bool) get_parameter('delete_user', false); + $user_is_global_admin = users_is_admin($id_user); + $perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up); $id_perfil = $perfilUser['id_perfil']; - $perfil = db_get_row('tperfil', 'id_perfil', $id_perfil); db_pandora_audit( AUDIT_LOG_USER_MANAGEMENT, - 'Deleted profile for user '.io_safe_output($id2), + 'Deleted profile for user '.io_safe_output($id_user), false, false, 'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo'] ); + // Delete profile. + $profile_deleted = profile_delete_user_profile($id_user, $id_up); + // Check if exists more profiles. + $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id_user); + if ($profile_deleted === true) { + if ($has_profile === false && $user_is_global_admin === false && $delete_user === true) { + if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + foreach ($servers as $server) { + // Connect to the remote console. + metaconsole_connect($server); - $return = profile_delete_user_profile($id2, $id_up); - ui_print_result_message( - $return, - __('Successfully deleted'), - __('Could not be deleted') - ); + // Delete the user. + $result = delete_user($id_user); + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __('Deleted user %s from metaconsole', io_safe_output($id_user)) + ); + } + // Restore the db connection. + metaconsole_restore_db(); - $has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2); - $user_is_global_admin = users_is_admin($id2); - $delete_user_profile = (bool) get_parameter('delete_user_profile', false); + // Log to the metaconsole too. + if ($result === true) { + db_pandora_audit( + AUDIT_LOG_USER_MANAGEMENT, + __( + 'Deleted user %s from %s', + io_safe_input($id_user), + io_safe_input($server['server_name']) + ) + ); + } + } - if ($has_profile === false && $user_is_global_admin === false && $delete_user_profile === true) { - $result = delete_user($id2); + $result = delete_user((string) $id_user); - if ($result === true) { - db_pandora_audit( - AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s', io_safe_output($id_user)) - ); - } - - ui_print_result_message( - $result, - __('Successfully deleted'), - __('There was a problem deleting the user') - ); - - // Delete the user in all the consoles. - if (is_metaconsole() === true) { - $servers = metaconsole_get_servers(); - foreach ($servers as $server) { - // Connect to the remote console. - metaconsole_connect($server); - - // Delete the user. - $result = delete_user($id_user); if ($result === true) { db_pandora_audit( AUDIT_LOG_USER_MANAGEMENT, - __('Deleted user %s from metaconsole', io_safe_output($id_user)) + __('Deleted user %s', io_safe_output($id_user)) ); } - - // Restore the db connection. - metaconsole_restore_db(); - - // Log to the metaconsole too. + } else { + $result = delete_user((string) $id_user); if ($result === true) { db_pandora_audit( AUDIT_LOG_USER_MANAGEMENT, - __( - 'Deleted user %s from %s', - io_safe_input($id_user), - io_safe_input($server['server_name']) - ) + __('Deleted user %s', io_safe_output($id_user)) ); } - - ui_print_result_message( - $result, - __('Successfully deleted from %s', io_safe_input($server['server_name'])), - __('There was a problem deleting the user from %s', io_safe_input($server['server_name'])) - ); } + } else { + $result = $profile_deleted; } - - return $result; } - return $return; + return $result; } } @@ -2014,7 +2006,7 @@ if (is_metaconsole() === false) { id_user_profile = id_user_profile[1].value; var row = $(this).closest('tr'); - if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') { + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') { $("#delete_profile_modal") .empty() .html(""); @@ -2061,7 +2053,7 @@ if (is_metaconsole() === false) { } }); } else { - if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { + if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') { if (!confirm('' + '. ' + '')) { return false; } else { @@ -2080,11 +2072,10 @@ if (is_metaconsole() === false) { }); function delete_user_profile(id_user_profile, row, id_user, deleteuser){ - var params = []; params.push("delete_profile=1"); params.push("edit_user=1"); - params.push("delete_user_profile=" + deleteuser); + params.push("delete_user=" + deleteuser); params.push("id_user=" + id_user); params.push("id_user_profile=" + id_user_profile); params.push("page=godmode/users/configure_user"); @@ -2095,10 +2086,9 @@ if (is_metaconsole() === false) { success: function(data) { row.remove(); var rows = $("#table_profiles tr").length; - if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); - } else if (is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1') { + } else if (is_metaconsole === '1' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') { window.location.replace(""); } } diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index e4415b3ca1..d97edf17aa 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -308,7 +308,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c 'del', 'images/delete.svg', 1, - '', + 'background-color: transparent !important;', true, [ 'onclick' => 'delete_profile(event, this)', @@ -317,7 +317,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ); } else { $data['actions'] = ''; - $data['actions'] .= html_print_input_image('del', 'images/delete.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']); + $data['actions'] .= html_print_input_image( + 'del', + 'images/delete.svg', + 1, + 'background-color: transparent !important;', + true, + ['class' => 'main_menu_icon invert_filter'] + ); $data['actions'] .= html_print_input_hidden('delete_profile', 1, true); $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true); $data['actions'] .= html_print_input_hidden('id_user', $id, true); @@ -391,7 +398,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $data['last_hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true); - $data['last_actions'] = html_print_input_image('add', 'images/validate.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']); + $data['last_actions'] = html_print_input_image( + 'add', + 'images/validate.svg', + 1, + 'background-color: transparent !important;', + true, + ['class' => 'main_menu_icon invert_filter'] + ); $data['last_actions'] .= html_print_input_hidden('id', $id, true); $data['last_actions'] .= html_print_input_hidden('add_profile', 1, true); $data['last_actions'] .= ''; From 194a3ca8c4668d73dceb3f2d472b8d6a56c3fb8e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 12:36:05 +0100 Subject: [PATCH 204/414] #12381 fix dropdown select2 modal position --- .../godmode/agentes/module_manager_editor_common.php | 2 +- pandora_console/include/styles/pandora.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index ca74b7d171..de08a299de 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1387,7 +1387,7 @@ $table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( 'made_enabled', 1, (bool) $made_enabled, - false, + true, false, '', false, diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 63179618b1..dd6723dfb2 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12798,3 +12798,7 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.tags_selected_container > span.select2 { + background-color: white !important; +} From 8700d1146117c2b303bd9ea3eb238ff6355bea6c Mon Sep 17 00:00:00 2001 From: Enrique Martin Date: Tue, 7 Nov 2023 13:13:45 +0100 Subject: [PATCH 205/414] Fixed agent data scripts on pandoradb_data.sql --- pandora_console/pandoradb_data.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index e7327e578b..123940c22e 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -2551,49 +2551,49 @@ INSERT INTO `tncm_script` VALUES (10,3,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), (11,4,'copy tftp flash\n expect:\]\? _TFTP_SERVER_IP_\n expect:\]\? _SOURCE_FILE_NAME_\n expect:\]\? _DESTINATION_FILE_NAME_\n show flash\n reload\n expect:confirm y\n config terminal\n boot system _DESTINATION_FILE_NAME_\n'), (12,5,''), - (13,7,''), + (13,7,'enable\n expect:Password:\s* _enablepass_\n term length 0\n capture:show version | i IOS Software\n exit\n'), (14,0,'expect:root@% cli\n exit\n'), (15,1,'expect:root@% cli\n expect:root> capture:show configuration\n capture:\n quit\n expect:root@% exit\n'), (16,2,'expect:root@% cli\n expect:root> configure\n load override terminal\n _applyconfigbackup_\n commit\n exit\n'), (17,3,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), (18,4,'expect:root@% cli\n expect:root> save software from tftp _TFTP_SERVER_IP_ _FIRMWARE_NAME_ to flash\n reset\n exit\n'), (19,5,''), - (20,7,''), + (20,7,'expect:root@% cli\n expect:root> capture:show version|match Junos:\n capture: \n quit\n expect:root@% exit\n'), (21,0,'sleep:1 exit\n'), (22,1,'set cli pager off \n capture:show config running\n exit\n'), (23,2,'set cli terminal width 500\n set cli scripting-mode on\n configure\n _applyconfigbackup_\n commit\n'), (24,3,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), (25,4,'tftp import software from _TFTP_SERVER_IP_ file _FIRMWARE_NAME_\n request system software install version\n reboot\n exit\n'), (26,5,''), - (27,7,''), + (27,7,'set cli pager off \n capture:show system info | match app-version:\n sleep:1 expect:app-version:\s* exit \n'), (28,0,'sleep:1 enable\n expect:Password:\s* _enablepass_\n'), (29,1,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), (30,2,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n _applyconfigbackup_\n exit\n'), (31,3,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (32,4,'sleep:1 enable\n expect:Password:\s* _enablepass_\n configure\n expect:(config) restore _TFTP_SERVER_IP_/_FIRMWARE_NAME_\n expect:Password:\s* _enablepass_\n expect:skip port map yes\n expect: see the diff yes\n sleep:1 expect:Proceed with reboot yes\n expect:eof'), (33,5,''), - (34,7,''), + (34,7,'sleep:1 enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (35,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), (36,1,'enable\n expect:Password:\s* _enablepass_\n capture:admin display-config\n logout\n'), (37,2,''), (38,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), (39,4,''), (40,5,''), - (41,7,''), + (41,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n logout\n'), (42,0,'enable\n expect:Password:\s* _enablepass_\n exit\n'), (43,1,'enable\n expect:Password:\s* _enablepass_\n capture:show running-config\n exit\n'), (44,2,'configure terminal\n load replace /var/tmp/file.conf\n end\n write memory\n exit\n'), (45,3,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (46,4,'copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_.swi secondary\n boot system flash secondary\n copy tftp flash _TFTP_SERVER_IP_ _DESTINATION_FILE_NAME_ primary\n boot system flash primary\n'), (47,5,''), - (48,7,''), + (48,7,'enable\n expect:Password:\s* _enablepass_\n capture:show version\n exit\n'), (49,0,'sleep:1 exit\n\r'), (50,1,'sleep:1 capture:system resource print\n\r exit\n\r'), (51,2,'sleep:1 system backup load name=_nameBackup_ password=_passwordBackup_\n\r expect:Restore yes\n\r exit\n\r'), (52,3,'sleep:1 capture:/system package print\n\r exit\n\r'), (53,4,'sleep:1 /system routerboard upgrade\n\r expect:Do yes\n\r exit\n\r'), (54,5,''), - (55,7,''); + (55,7,'sleep:1 capture:/system package print\n\r exit\n\r'); INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1), From 46a74c2e220efaad8e520bef24cf61bdb33c1378 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 7 Nov 2023 13:35:08 +0100 Subject: [PATCH 206/414] #12345 Fixed enable/disable --- .../godmode/agentes/configurar_agente.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 88d4b0e4ed..baf0a24524 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2149,6 +2149,28 @@ if ($update_module || $create_module || ($module_in_policy && !$module_linked) ) { if ($success_action > 0) { + if (empty($old_configuration_data) === true + && empty($configuration_data) === true && $disabled === '0' + && ($enable_module || $disable_module) + ) { + $modulo_nombre = io_safe_output( + db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + (empty($disable_module) === false) ? $disable_module : $enable_module + ) + ); + + $old_configuration_data = config_agents_get_module_from_conf( + $id_agente, + $modulo_nombre + ); + $configuration_data = $old_configuration_data; + + $disabled = (empty($disable_module) === false) ? true : false; + } + enterprise_hook( 'config_agents_write_module_in_conf', [ @@ -2297,7 +2319,6 @@ if ($disable_module) { $modulo_nombre = io_safe_output($modulo_nombre['nombre']); if ($result === NOERR) { - enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]); db_pandora_audit( AUDIT_LOG_MODULE_MANAGEMENT, 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias'] From 2d7895b39b7a4a258da9698bd133185b39220247 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 7 Nov 2023 15:22:22 +0100 Subject: [PATCH 207/414] #8365 Fixed ncm reports of html type --- .../godmode/reporting/reporting_builder.item_editor.php | 7 +++++++ pandora_console/include/functions_reporting_html.php | 7 ++++++- pandora_console/include/styles/pandora.css | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index f50b451683..c16cbd4a05 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -8146,10 +8146,17 @@ function filterNcmAgentChange() { }, success: function(data) { $("#agent_ncm").empty(); + var optionAny = $("") + .attr("value",0) + .html("Any"); + // Add any option. + $("#agent_ncm").append(optionAny); + data.map(item => { var option = $("") .attr("value", item.id_agent) .html(item.alias); + // Add agents options. $("#agent_ncm").append(option); }); }, diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index a74fcb4a47..d2d4f5850f 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7437,6 +7437,7 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ui_require_javascript_file('highlight.min'); ui_require_javascript_file('highlightjs-line-numbers.min'); ui_require_javascript_file('languages/plaintext.min'); + ui_require_javascript_file('jquery', ENTERPRISE_DIR.'/include/javascript/'); ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); // Create table diff. @@ -7448,6 +7449,8 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) $table_ncm->head = []; $table_ncm->head[0] = __('Date'); $table_ncm->head[1] = __('Diff'); + $table_ncm->caption = $item['caption']; + $table_ncm->id = 'ncm_backups'; $table_ncm->data = []; @@ -7459,7 +7462,9 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ]; } - return $table->data[] = html_print_table( + $table->colspan['ncm_backups']['cell'] = 3; + $table->cellstyle['ncm_backups']['cell'] = 'text-align: left;'; + $table->data['ncm_backups']['cell'] = html_print_table( $table_ncm, true ); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 63179618b1..7e9669bc21 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12798,3 +12798,7 @@ tr.shown td.details-control { position: relative; top: -92px; } + +#ncm_backups > caption > h4 { + color: black; +} From 84ee69b435846510fc38ba6e6fab4194ef43be3d Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 7 Nov 2023 15:56:23 +0100 Subject: [PATCH 208/414] #12095 remove user_comment --- pandora_console/extras/mr/67.sql | 6 ++++++ pandora_console/pandoradb.sql | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..235a5b3580 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +ALTER TABLE `tevent_rule` DROP COLUMN `user_comment`; +ALTER TABLE `tevent_rule` DROP COLUMN `operator_user_comment`; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 1d7374bc03..eb3810a4f1 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3029,7 +3029,6 @@ CREATE TABLE IF NOT EXISTS `tevent_rule` ( `module` TEXT, `alert` TEXT, `criticity` TEXT, - `user_comment` TEXT, `id_tag` TEXT, `name` TEXT, `group_recursion` TEXT, @@ -3044,7 +3043,6 @@ CREATE TABLE IF NOT EXISTS `tevent_rule` ( `operator_module` TEXT COMMENT 'Operator for module', `operator_alert` TEXT COMMENT 'Operator for alert', `operator_criticity` TEXT COMMENT 'Operator for criticity', - `operator_user_comment` TEXT COMMENT 'Operator for user_comment', `operator_id_tag` TEXT COMMENT 'Operator for id_tag', `operator_log_content` TEXT COMMENT 'Operator for log_content', `operator_log_source` TEXT COMMENT 'Operator for log_source', From 161b0e8a34782a36397e14590b2c7dc7cb2e7635 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 8 Nov 2023 10:31:42 +0100 Subject: [PATCH 209/414] Add filter eventcardboard pandora_enterprise#11760 --- pandora_console/include/functions_events.php | 40 ++++++++++++++++--- .../lib/Dashboard/Widgets/EventCardboard.php | 6 +-- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index abfee036cb..c814e137eb 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -6016,17 +6016,47 @@ function get_count_event_criticity( $type = 'AND event_type = "'.$eventType.'"'; } - $groups = ' '; + $groups = ' '; if ((int) $groupId !== 0) { $groups = 'AND id_grupo IN ('.$groupId.')'; } - $status = ' '; - if ((int) $eventStatus !== -1) { - $status = 'AND estado = '.$eventStatus; + $status = ' '; + if (empty($eventStatus) === false) { + switch ($eventStatus) { + case EVENT_ALL: + default: + // Do not filter. + break; + + case EVENT_NEW: + case EVENT_VALIDATE: + case EVENT_PROCESS: + $status = sprintf( + ' AND estado = %d', + $eventStatus + ); + break; + + case EVENT_NO_VALIDATED: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_PROCESS + ); + break; + + case EVENT_NO_PROCESS: + $status = sprintf( + ' AND (estado = %d OR estado = %d)', + EVENT_NEW, + EVENT_VALIDATE + ); + break; + } } - $criticity = ' '; + $criticity = ' '; if (empty($criticityId) === false) { $criticity = 'AND criticity IN ('.$criticityId.')'; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php index fa2f8bb023..8ca7571790 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php +++ b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php @@ -296,11 +296,7 @@ class EventCardboard extends Widget ]; // Event status. - $fields = [ - -1 => __('All event'), - 1 => __('Only validated'), - 0 => __('Only pending'), - ]; + $fields = events_get_all_status(true); $inputs['inputs']['row1'][] = [ 'label' => __('Event status'), From 14fff848760653ab06d9b61f2b65e99479dcf873 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 8 Nov 2023 11:56:32 +0100 Subject: [PATCH 210/414] queries remove field transactional_agent pandora_enterprise#12334 --- pandora_console/extras/mr/67.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..0a5fcd9fb0 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,13 @@ +START TRANSACTION; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tmetaconsole_agent' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tmetaconsole_agent` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +SET @exist = (SELECT count(*) FROM information_schema.columns WHERE TABLE_NAME='tagente' AND COLUMN_NAME='transactional_agent' AND table_schema = DATABASE()); +SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_agent`', 'SELECT ""'); +prepare stmt from @sqlstmt; +execute stmt; + +COMMIT; From 98bc73a83ab0b6308703b90132187392a9a8e2ae Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Wed, 8 Nov 2023 14:40:47 +0100 Subject: [PATCH 211/414] #8365 Fix ncm report for multiple agents --- pandora_console/extras/mr/67.sql | 3 + .../reporting_builder.item_editor.php | 6 +- .../godmode/reporting/reporting_builder.php | 11 ++- .../include/functions_reporting_html.php | 71 ++++++++++--------- pandora_console/pandoradb.sql | 1 + 5 files changed, 54 insertions(+), 38 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 2a604941e0..2913cd8248 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -29,6 +29,9 @@ ADD COLUMN `agent_data_cron_interval` VARCHAR(100) NULL DEFAULT '' AFTER `cron_i ALTER TABLE `tncm_agent` ADD COLUMN `agent_data_event_on_change` INT UNSIGNED NULL DEFAULT NULL AFTER `event_on_change`; +ALTER TABLE `treport_content` +ADD COLUMN `ncm_agents` MEDIUMTEXT NULL AFTER `status_of_check`; + -- Add new vendor and model SET @vendor_name = 'Cisco'; SET @model_name = 'Cisco-Generic'; diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index c16cbd4a05..49c7ac7f80 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1036,12 +1036,12 @@ switch ($action) { break; case 'ncm': - $id_agent_ncm = $item['id_agent']; + $id_agent_ncm = json_decode($item['ncm_agents']); $ncm_group = $item['id_group']; break; case 'ncm_backups': - $id_agent_ncm = $item['id_agent']; + $id_agent_ncm = json_decode($item['ncm_agents']); $ncm_group = $item['id_group']; break; @@ -1973,7 +1973,7 @@ if (is_metaconsole() === true) { $all_agents = agents_get_agents_selected($ncm_group); html_print_select( $all_agents, - 'agent_ncm', + 'agent_ncm[]', $id_agent_ncm, '', __('Any'), diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index f155a89831..e449b766ff 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -2046,13 +2046,15 @@ switch ($action) { break; case 'ncm_backups': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; case 'ncm': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; @@ -2996,12 +2998,15 @@ switch ($action) { break; case 'ncm_backups': - $values['id_agent'] = get_parameter('agent_ncm'); + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; break; case 'ncm': + $agents_ncm = get_parameter('agent_ncm'); + $values['ncm_agents'] = json_encode($agents_ncm); $values['id_agent'] = get_parameter('agent_ncm'); $values['id_group'] = get_parameter('ncm_group'); $good_format = true; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index d2d4f5850f..0fbae441ec 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -7441,45 +7441,52 @@ function reporting_html_ncm_backups($table, $item, $pdf=0) ui_require_javascript_file('functions_ncm', ENTERPRISE_DIR.'/include/javascript/'); // Create table diff. - $table_ncm = new stdClass(); - $table_ncm->width = '100%'; - $table_ncm->class = 'info_table'; - $table_ncm->styleTable = 'table-layout: fixed;'; - $table_ncm->headstyle[0] = 'width: 250px'; - $table_ncm->head = []; - $table_ncm->head[0] = __('Date'); - $table_ncm->head[1] = __('Diff'); - $table_ncm->caption = $item['caption']; - $table_ncm->id = 'ncm_backups'; - - $table_ncm->data = []; - - if ($pdf === 0) { - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - $row['diff'], - ]; + foreach ($item['data'] as $ncm_agent_key => $ncm_agent) { + $table_ncm = new stdClass(); + if ($pdf === 1) { + $table_ncm->width = '100%'; } - $table->colspan['ncm_backups']['cell'] = 3; - $table->cellstyle['ncm_backups']['cell'] = 'text-align: left;'; - $table->data['ncm_backups']['cell'] = html_print_table( - $table_ncm, - true - ); - } else { - foreach ($item['data'] as $key => $row) { - $table_ncm->data[] = [ - $row['updated_at'], - ($row['diffstr'] === '') ? $row['diff'] : str_replace("\n", '
', $row['diffstr']), - ]; + $table_ncm->class = 'info_table'; + $table_ncm->styleTable = 'table-layout: fixed;'; + $table_ncm->headstyle[0] = 'width: 250px'; + $table_ncm->head = []; + $table_ncm->head[0] = __('Date'); + $table_ncm->head[1] = __('Diff'); + $table_ncm->id = 'ncm_backups'; + $table_ncm->name = 'ncm_backups'; + $table_ncm->title = $ncm_agent['caption']; + $row = []; + foreach ($ncm_agent['data'] as $ncm_agent_data) { + if ($pdf === 1) { + $row[] = [ + $ncm_agent_data['updated_at'], + ($ncm_agent_data['diffstr'] === '') ? $ncm_agent_data['diff'] : str_replace("\n", '
', $ncm_agent_data['diffstr']), + ]; + } else { + $row[] = [ + $ncm_agent_data['updated_at'], + $ncm_agent_data['diff'], + ]; + } + + $table_ncm->data = $row; } - return html_print_table( + $table->colspan[$ncm_agent_key]['cell'] = 3; + $table->cellstyle[$ncm_agent_key]['cell'] = 'text-align: left;'; + $table->data[$ncm_agent_key]['cell'] = html_print_table( $table_ncm, true ); } + if ($pdf === 1) { + $table->width = '100%'; + return html_print_table( + $table, + true + ); + } + } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 8b83b26011..334afe02b2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1645,6 +1645,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `cat_security_hardening` INT NOT NULL DEFAULT 0, `ignore_skipped` INT NOT NULL DEFAULT 0, `status_of_check` TINYTEXT, + `ncm_agents` MEDIUMTEXT, PRIMARY KEY(`id_rc`), FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) ON UPDATE CASCADE ON DELETE CASCADE From 82759ae12f247d48a77a89831fdf04db344d21d2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 8 Nov 2023 15:24:47 +0100 Subject: [PATCH 212/414] #11763 regex events --- pandora_console/operation/events/events.php | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index e4aa2aa5fe..f4eb499a79 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -471,29 +471,12 @@ if (is_ajax() === true) { $events = $events['data']; } - if (!empty($events) && $regex !== '') { - foreach ($events as $key => $event) { - $regex_validation = false; - foreach ($event as $field) { - if (preg_match('/'.$regex.'/', $field)) { - $regex_validation = true; - } - } - - if ($regex_validation === false) { - unset($events[$key]); - } - } - - $count = count($events); - } - if (empty($events) === false) { $redirection_form_id = 0; $data = array_reduce( $events, - function ($carry, $item) use ($table_id, &$redirection_form_id, $filter, $compact_date, $external_url) { + function ($carry, $item) use ($table_id, &$redirection_form_id, $filter, $compact_date, $external_url, $regex) { global $config; $tmp = (object) $item; @@ -1241,12 +1224,34 @@ if (is_ajax() === true) { } } + if (empty($tmp) === false && $regex !== '') { + $regex_validation = false; + foreach (json_decode(json_encode($tmp), true) as $key => $field) { + if (preg_match('/'.$regex.'/', $field)) { + $regex_validation = true; + } + } + + if ($regex_validation === false) { + unset($tmp); + } + } + $carry[] = $tmp; return $carry; } ); } + $data = array_values( + array_filter( + $data, + function ($item) { + return (bool) (array) $item; + } + ) + ); + $count = count($data); // RecordsTotal && recordsfiltered resultados totales. echo json_encode( [ From f773230ebf3851f65c85f339017650d817c5f8fc Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 9 Nov 2023 16:18:06 -0500 Subject: [PATCH 213/414] Modify pandora_cps_enabled function --- pandora_server/lib/PandoraFMS/Core.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index afd3e8e865..797268f032 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -5778,9 +5778,9 @@ sub pandora_inhibit_alerts { sub pandora_cps_enabled($$) { my ($agent, $module) = @_; - return 1 if ($agent->{'cps'} > 0); + return 1 if ($agent->{'cps'} >= 0); - return 1 if ($module->{'cps'} > 0); + return 1 if ($module->{'cps'} >= 0); return 0; } From 611e93ea7e6f0912be41f38ebf5fef6feb134b4c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 10 Nov 2023 09:27:22 +0100 Subject: [PATCH 214/414] #12417 fix graph no show on string when FF change --- .../godmode/agentes/module_manager_editor_common.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index de08a299de..9c318b4e9f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -2000,7 +2000,11 @@ ui_require_jquery_file('json'); $('#' + thisLabel).prop('checked', true); $('#' + thisLabel).siblings().prop('checked', false); - if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { + var type_selected = $("#id_module_type").val(); + var type_names = jQuery.parseJSON(Base64.decode($('#hidden-type_names').val())); + var type_name_selected = type_names[type_selected]; + + if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true || type_name_selected == 'generic_data_string') { $("#svg_dinamic").hide(); } else { paint_graph_values(); From 748238a7ea8da8a814db373d4e1e3536ab6c83af Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Fri, 10 Nov 2023 10:03:13 +0100 Subject: [PATCH 215/414] #11791 Prevent any user from changing another user's notification settings in AJAX --- pandora_console/include/ajax/notifications.ajax.php | 4 ++++ pandora_console/include/functions_notifications.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/ajax/notifications.ajax.php b/pandora_console/include/ajax/notifications.ajax.php index 36ea95900d..a69ad1b56e 100644 --- a/pandora_console/include/ajax/notifications.ajax.php +++ b/pandora_console/include/ajax/notifications.ajax.php @@ -38,6 +38,10 @@ if ($change_label === '1') { $source = get_parameter('source', 0); $user = get_parameter('user', ''); $value = get_parameter('value', 0) ? 1 : 0; + $user_info = get_user_info($config['id_user']); + if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { + return false; + } // Update the label value. ob_clean(); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ea29c2c98a..4838f3c954 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -661,7 +661,8 @@ function notifications_set_user_label_status($source, $user, $label, $value) { global $config; - if ((bool) check_acl($config['id_user'], 0, 'PM') === false && $config['id_user'] !== $user) { + $user_info = get_user_info($config['id_user']); + if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { return false; } From 584a31147f48a88e92de1721848fc1f76b3959c4 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 11:46:13 +0100 Subject: [PATCH 216/414] fixed link --- pandora_console/views/tacticalView/view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/views/tacticalView/view.php b/pandora_console/views/tacticalView/view.php index 308c9626e9..29b1c923fc 100644 --- a/pandora_console/views/tacticalView/view.php +++ b/pandora_console/views/tacticalView/view.php @@ -268,7 +268,7 @@
loading(); ?>
From d04a554cc7b672771093331450dd84f838f43241 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 12:42:26 +0100 Subject: [PATCH 217/414] fix api check url --- pandora_console/extensions/api_checker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index fce3e1a00f..38488fc9e4 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -99,7 +99,7 @@ function api_execute( if (empty($token) === true) { $data['apipass'] = $apipass; $data['user'] = $user; - $data['password'] = $password; + $data['pass'] = $password; } } From 5eb5df61906cdf0f1e98aa6213af79660fa00eaf Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 10 Nov 2023 13:13:57 +0100 Subject: [PATCH 218/414] change url pandorarc name --- pandora_console/godmode/setup/setup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 0fd6bebff8..c0d59fbde9 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -184,7 +184,7 @@ $buttons['ITSM'] = [ $buttons['ehorus'] = [ 'active' => false, - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/RC.png', true, [ @@ -297,7 +297,7 @@ switch ($section) { $help_header = 'setup_flow_tab'; break; - case 'ehorus': + case 'pandorarc': $buttons['ehorus']['active'] = true; $subpage = __('Pandora RC'); $help_header = 'setup_ehorus_tab'; @@ -438,7 +438,7 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_visuals.php'; break; - case 'ehorus': + case 'pandorarc': include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; From b100d34985404ad9402f1f4762df9463b92b970e Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Nov 2023 09:38:24 +0100 Subject: [PATCH 219/414] #12249 new view vulnerabilities agent --- pandora_console/include/functions_ui.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 3b193b8975..cbe3314289 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -8230,3 +8230,23 @@ function ui_update_name_fav_element($id_element, $section, $label) ] ); } + + +function ui_print_status_vulnerability_div(float $score) +{ + $return = ''; + $class = 'status_rounded_rectangles forced_title'; + if (((float) $score) <= 5) { + return ui_print_div('group_view_ok '.$class, $score); + } + + if (((float) $score) > 5 && ((float) $score) <= 7.5) { + return ui_print_div('group_view_warn '.$class, $score); + } + + if (((float) $score) > 7.5) { + return ui_print_div('group_view_crit '.$class, $score); + } + + return $return; +} \ No newline at end of file From 813bc4b851c8f97578d8dc6b8a5a48e481a2ef3b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Nov 2023 09:49:19 +0100 Subject: [PATCH 220/414] #12424 class error input ranges warning critical --- .../godmode/agentes/module_manager_editor_common.php | 3 +++ pandora_console/include/javascript/pandora.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index de08a299de..884696c932 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -2368,6 +2368,9 @@ ui_require_jquery_file('json'); ); } } else { + if (max_c !== 0 && max_c < min_c) { + error_c = 2; + } error_w = 1; paint_graph_status( 0, 0, 0, 0, 0, 0, error_w, error_c, diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 7da7aed2a5..332502d6b6 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1652,6 +1652,10 @@ function paint_graph_status( max_c = 0; } + // Remove Error class. + $("#text-max_warning").removeClass("input_error"); + $("#text-max_critical").removeClass("input_error"); + //if haven't errors if (error_w == 0 && error_c == 0) { //parse element @@ -1957,6 +1961,9 @@ function paint_graph_status( .html(message_error_critical) .style("text-anchor", "first"); } + if (error_c == 2) { + $("#text-max_critical").addClass("input_error"); + } } } From ad90fb74b2b3615cbb2be60ba5bc08b0e2a8e752 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Nov 2023 10:42:25 +0100 Subject: [PATCH 221/414] #12390 Fixed group --- pandora_console/include/class/Heatmap.class.php | 6 +++++- pandora_console/include/lib/Dashboard/Widgets/heatmap.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php index 05d6152030..3ed4b3cc72 100644 --- a/pandora_console/include/class/Heatmap.class.php +++ b/pandora_console/include/class/Heatmap.class.php @@ -549,8 +549,12 @@ class Heatmap global $config; $filter_group = ''; - if (empty($this->filter) === false && current($this->filter) != -1) { + if (empty($this->filter) === false && current($this->filter) != -1 + && implode(',', $this->filter) !== '' + ) { $filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')'; + } else { + return false; } $filter_name = ''; diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php index 363ea1489e..e199a80ad8 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -320,6 +320,10 @@ class HeatmapWidget extends Widget $module_groups[$module_group['id_mg']] = $module_group['name']; } + if (empty($values['module_groups'][0]) === true) { + $values['module_groups'][0] = 0; + } + $inputs[] = [ 'label' => __('Module group'), 'style' => ($values['type'] === '2') ? '' : 'display:none', @@ -332,7 +336,7 @@ class HeatmapWidget extends Widget 'return' => true, 'multiple' => true, 'nothing' => __('Not assigned'), - 'nothing_value' => 0, + 'nothing_value' => '0', ], ]; From d312b0d81388d613b17249ab6c12b9f373165928 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 13 Nov 2023 13:08:28 +0100 Subject: [PATCH 222/414] #12400 Fixed date format --- pandora_console/include/functions_html.php | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 888531e915..d9c60589ce 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -7305,8 +7305,10 @@ function html_print_select_date_range( $time_end='', $date_text=SECONDS_1DAY, $class='w100p', - $date_format='Y/m/d', - $time_format='H:i:s' + $date_format_php='Y/m/d', + $time_format_php='H:i:s', + $date_format_js='yy/mm/dd', + $time_format_js='HH:mm:ss' ) { global $config; @@ -7328,21 +7330,21 @@ function html_print_select_date_range( } if ($date_end === '') { - $date_end = date($date_format); + $date_end = date($date_format_php); } if ($date_init === '') { - $date_init = date($date_format, strtotime($date_end.' -1 days')); + $date_init = date($date_format_php, strtotime($date_end.' -1 days')); } - $date_init = date($date_format, strtotime($date_init)); + $date_init = date($date_format_php, strtotime($date_init)); if ($time_init === '') { - $time_init = date($time_format); + $time_init = date($time_format_php); } if ($time_end === '') { - $time_end = date($time_format); + $time_end = date($time_format_php); } $fields[SECONDS_1DAY] = __('Last 24hr'); @@ -7508,7 +7510,7 @@ function html_print_select_date_range( } $('#text-date').datepicker({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown' @@ -7516,7 +7518,7 @@ function html_print_select_date_range( $('[id^=text-time_init]').timepicker({ showSecond: true, - timeFormat: '".TIME_FORMAT_JS."', + timeFormat: '".$time_format_js."', timeOnlyTitle: '".__('Choose time')."', timeText: '".__('Time')."', hourText: '".__('Hour')."', @@ -7527,7 +7529,7 @@ function html_print_select_date_range( }); $('[id^=text-date_init]').datepicker ({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown', @@ -7549,7 +7551,7 @@ function html_print_select_date_range( }); $('[id^=text-date_end]').datepicker ({ - dateFormat: '".DATE_FORMAT_JS."', + dateFormat: '".$date_format_js."', changeMonth: true, changeYear: true, showAnim: 'slideDown', @@ -7572,7 +7574,7 @@ function html_print_select_date_range( $('[id^=text-time_end]').timepicker({ showSecond: true, - timeFormat: '".TIME_FORMAT_JS."', + timeFormat: '".$time_format_js."', timeOnlyTitle: '".__('Choose time')."', timeText: '".__('Time')."', hourText: '".__('Hour')."', From ca66efb4f4b7630d711df558a5c32df4e5ad5ca1 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 13:20:55 +0100 Subject: [PATCH 223/414] change service modules async to generic pandora_enterprise#11681 --- pandora_console/extras/mr/67.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..4a031e6044 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,10 @@ +START TRANSACTION; + +SELECT @generic_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_data"; +SELECT @generic_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "generic_proc"; +SELECT @async_data := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_data"; +SELECT @async_proc := `id_tipo` FROM `ttipo_modulo` WHERE `nombre` = "async_proc"; +UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_data WHERE `tagente_modulo`.`id_tipo_modulo` = @async_data; +UPDATE `tagente_modulo` INNER JOIN `tservice` ON `tagente_modulo`.`custom_integer_1` = `tservice`.`id` SET `tagente_modulo`.`id_tipo_modulo` = @generic_proc WHERE `tagente_modulo`.`id_tipo_modulo` = @async_proc; + +COMMIT; \ No newline at end of file From 04649dee00d8d0b25ffa8cab410d7f687a6768d3 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 13 Nov 2023 13:41:47 +0100 Subject: [PATCH 224/414] #12168 Fixed sql bringing main services --- .../include/class/TreeService.class.php | 16 ++++++---------- .../include/javascript/tree/TreeController.js | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index b218468de3..a627794f0e 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -738,19 +738,15 @@ class TreeService extends Tree $filterResult = db_get_all_rows_sql($sqlFilter); + $services = []; foreach ($filterResult as $key => $result) { - $ancestors = services_get_services_ancestors($result['id']); - $idAncestors = implode(',', $ancestors); - $numAncestors = count($ancestors); - if ($numAncestors > 1) { - $whereAncestors = ' AND tse.id_service_child in ('.$idAncestors.')'; - } else if ($numAncestors == 1) { - $whereAncestors = ' AND ts.id ='.$idAncestors; - } else { - $whereAncestors = ' AND ts.id ='.$result['id']; - } + $services_ancestors = services_get_services_ancestors($result['id']); + $services[] = array_pop($services_ancestors); } + $services_list = array_unique($services, SORT_NUMERIC); + $whereAncestors = ' AND tse.id_service IN ('.implode(',', $services_list).')'; + return $whereAncestors; } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index d8a6daf468..4f850e32d5 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1561,6 +1561,7 @@ var TreeController = { * Filter the tree based on a search criterion */ function _filterItems(rawTree, searched) { + console.log(rawTree); const ancestors = []; const father = []; const newTree = []; From 6bc013a12492058067c44657d2d0e1d0d8d15962 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 13 Nov 2023 13:47:01 +0100 Subject: [PATCH 225/414] #10807 fixed layer visible --- pandora_console/godmode/gis_maps/configure_gis_map.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index f3f7d06d21..524ab245fb 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -68,7 +68,7 @@ foreach ($layer_ids as $layer_id) { $layer_list[] = [ 'id' => (strpos($layer_id, 'new_') === false) ? (int) $layer_id : null, 'layer_name' => $trimmed_name, - 'layer_visible' => ((int) $layers[$layer_id]['visible'] === 1), + 'layer_visible' => ($layers[$layer_id]['visible'] === 'true'), 'layer_group' => (int) $layers[$layer_id]['agents_from_group'], 'layer_agent_list' => $layers[$layer_id]['agents'], 'layer_group_list' => $layers[$layer_id]['groups'], From d49c5e4954336fa79371fc7eb6a8e965bd4d6641 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 15:12:55 +0100 Subject: [PATCH 226/414] delete agents pandora_db pandora_enterprise#12293 --- pandora_server/util/pandora_db.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 92c6c5f9ce..b68e71c469 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -142,10 +142,18 @@ sub pandora_purgedb ($$$) { # Delete manually disabled agents after some period if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) { log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days)."); - db_do ($dbh, "DELETE FROM tagente - WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) - AND disabled = 1 - AND modo != 2", $conf->{'_delete_disabled_agents'} * 8600); + my @agents_to_delete = get_db_rows ( + $dbh, + "SELECT id_agente FROM tagente + WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) + AND disabled = 1 + AND modo != 2", + $conf->{'_delete_disabled_agents'} * 8600 + ); + + foreach my $agent_to_delete (@agents_to_delete) { + pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'}); + } } # Delete old data From dc714a5b9f9e1a82d9647305c7398fa25bbe3e24 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Nov 2023 15:27:07 +0100 Subject: [PATCH 227/414] #12249 column secmon --- pandora_console/include/functions_ui.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index cbe3314289..05eeeb483d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -8249,4 +8249,21 @@ function ui_print_status_vulnerability_div(float $score) } return $return; +} + + +function ui_print_status_secmon_div($status) +{ + $class = 'status_rounded_rectangles forced_title'; + if (($status) === 'normal') { + return ui_print_div('group_view_ok '.$class, __('normal')); + } + + if (($status) === 'warning') { + return ui_print_div('group_view_warn '.$class, __('warning')); + } + + if (($status) === 'critical') { + return ui_print_div('group_view_crit '.$class, __('critical')); + } } \ No newline at end of file From 5ba07153e29e365abded6e3b60b942f649a81497 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Nov 2023 15:28:20 +0100 Subject: [PATCH 228/414] #12424 #12441 #12442 module view adjusted --- .../agentes/module_manager_editor_common.php | 67 +++++++------------ 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 884696c932..ab087f215c 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -2000,23 +2000,14 @@ ui_require_jquery_file('json'); $('#' + thisLabel).prop('checked', true); $('#' + thisLabel).siblings().prop('checked', false); - if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { + if ($('#radius-percentage_warning').prop('checked') === true && $('#radius-percentage_critical').prop('checked') === true) { + paint_graph_values(); $("#svg_dinamic").hide(); } else { paint_graph_values(); $("#svg_dinamic").show(); } - if ($('#radius-percentage_warning').prop('checked') === true) { - $('#radius-warning_inverse').hide(); - $('#label-radius-warning_inverse').hide(); - } - - if ($('#radius-warning_inverse').prop('checked') === true) { - $('#radius-percentage_warning').hide(); - $('#label-radius-percentage_warning').hide(); - } - if ($('#radius-normal_warning').prop('checked') === true) { $('#radius-warning_inverse').show(); $('#label-radius-warning_inverse').show(); @@ -2024,17 +2015,6 @@ ui_require_jquery_file('json'); $('#label-radius-percentage_warning').show(); } - - if ($('#radius-percentage_critical').prop('checked') === true) { - $('#radius-critical_inverse').hide(); - $('#label-radius-critical_inverse').hide(); - } - - if ($('#radius-critical_inverse').prop('checked') === true) { - $('#radius-percentage_critical').hide(); - $('#label-radius-percentage_critical').hide(); - } - if ($('#radius-normal_critical').prop('checked') === true) { $('#radius-critical_inverse').show(); $('#label-radius-critical_inverse').show(); @@ -2351,33 +2331,38 @@ ui_require_jquery_file('json'); var message_error_percentage = ''; //if haven't error - if (max_w == 0 || max_w > min_w) { - if (max_c == 0 || max_c > min_c) { - paint_graph_status( - min_w, max_w, min_c, max_c, inverse_w, - inverse_c, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + if (max_w == 0 || max_w > min_w || $('#radius-percentage_warning').is(':checked') === true) { + if (max_c == 0 || max_c > min_c || $('#radius-percentage_critical').is(':checked') === true) { + error_c = 0; + error_w = 0; } else { error_c = 1; - paint_graph_status( - 0, 0, 0, 0, 0, 0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + min_w = 0; + max_w = 0; + min_c = 0; + max_c = 0; + inverse_w = 0; + inverse_c = 0; } } else { - if (max_c !== 0 && max_c < min_c) { + if (max_c !== 0 && max_c < min_c && $('#radius-percentage_critical').is(':checked') === false) { error_c = 2; } error_w = 1; - paint_graph_status( - 0, 0, 0, 0, 0, 0, error_w, error_c, - legend_normal, legend_warning, legend_critical, - message_error_warning, message_error_critical - ); + min_w = 0; + max_w = 0; + min_c = 0; + max_c = 0; + inverse_w = 0; + inverse_c = 0; } + + paint_graph_status( + min_w, max_w, min_c, max_c, inverse_w, + inverse_c, error_w, error_c, + legend_normal, legend_warning, legend_critical, + message_error_warning, message_error_critical + ); } /* ]]> */ From c2bf6e6bf52614c88448dd83e4035cfb65c93b40 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 13 Nov 2023 17:34:38 +0100 Subject: [PATCH 229/414] fix pgrep process in ubuntu --- pandora_console/include/functions_cron_task.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 9de0520ccd..40a6e159cc 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -459,17 +459,17 @@ function cron_task_start_gotty(bool $restart_mode=true) // Check prev process running and kill it (only if port changed in setup params). if (empty($config['restart_gotty_next_cron_port']) === false) { - config_update_value('restart_gotty_next_cron_port', ''); - - $prevProcessRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); + $prevProcessRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."' | grep -v 'pgrep'"); if (empty($prevProcessRunning) === false) { shell_exec("pkill -f 'pandora_gotty.*-p ".$config['restart_gotty_next_cron_port']."'"); } + + config_update_value('restart_gotty_next_cron_port', ''); } // Check if gotty is running on the configured port. - $processRunning = shell_exec("pgrep -f 'pandora_gotty.*-p ".$config['gotty_port']."'"); + $processRunning = shell_exec("pgrep -af 'pandora_gotty.*-p ".$config['gotty_port']."' | grep -v 'pgrep'"); $start_proc = true; From e38246521db38ce88f20174061b5353e9fd62fd6 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Nov 2023 09:33:04 +0100 Subject: [PATCH 230/414] #12251 added info in security in agent contact --- pandora_console/include/functions_agents.php | 40 ++++++++++++++++++++ pandora_console/include/functions_ui.php | 11 ++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 720b0e6e55..4fb61875d5 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4845,6 +4845,46 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; + // SecurityMon line. + $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); + $modules = db_get_all_rows_filter( + 'tagente_modulo', + [ + 'id_agente' => $agent['id_agente'], + 'id_module_group' => $id_module_group, + ] + ); + + if (is_array($modules) === true && count($modules) > 0) { + $secmon_status = secmon_status($agent['id_agente']); + $data = []; + $data[0] = ''.__('SecurityMon').''; + $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); + $table_contact->data[] = $data; + } + + // Hardening line. + $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); + $hardening = ''; + if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { + $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); + $hardening = format_numeric($raw_data_score[0]['datos'], 2); + $data = []; + $data[0] = ''.__('Hardening').''; + $data[1] = $hardening.' %'; + $table_contact->data[] = $data; + } + + // Vulnerabilities line. + $vuls = get_vulnerabilities($agent['id_agente']); + if (is_array($vuls) === true && count($vuls) > 0) { + $score = get_score($vuls); + $data = []; + $data[0] = ''.__('Vulnerability').''; + $data[1] = ui_print_status_vulnerability_div($score); + $table_contact->data[] = $data; + } + $agent_contact = html_print_div( [ 'class' => 'agent_details_header', diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 05eeeb483d..c3d14778d4 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -8252,18 +8252,21 @@ function ui_print_status_vulnerability_div(float $score) } -function ui_print_status_secmon_div($status) +function ui_print_status_secmon_div($status, $title=false) { $class = 'status_rounded_rectangles forced_title'; if (($status) === 'normal') { - return ui_print_div('group_view_ok '.$class, __('normal')); + $title = ($title === false) ? __('normal') : $title; + return ui_print_div('group_view_ok '.$class, $title); } if (($status) === 'warning') { - return ui_print_div('group_view_warn '.$class, __('warning')); + $title = ($title === false) ? __('warning') : $title; + return ui_print_div('group_view_warn '.$class, $title); } if (($status) === 'critical') { - return ui_print_div('group_view_crit '.$class, __('critical')); + $title = ($title === false) ? __('critical') : $title; + return ui_print_div('group_view_crit '.$class, $title); } } \ No newline at end of file From 636f76258e4fe017a4d38dcab6aa7ce85eca2c5b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Nov 2023 10:12:48 +0100 Subject: [PATCH 231/414] #12249 fixed black theme view --- pandora_console/include/styles/pandora_black.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/styles/pandora_black.css b/pandora_console/include/styles/pandora_black.css index c2afb2c737..e2f5eb1639 100644 --- a/pandora_console/include/styles/pandora_black.css +++ b/pandora_console/include/styles/pandora_black.css @@ -1871,3 +1871,8 @@ a.pandora_pagination, #general-tactical-view #horizontalBar .labels .label span { color: black; } + +#score-bar .labels-bar span, +#score-bar .labels-bar div { + color: white; +} From a2031559a016a5e24abb5f52d58093d1dcbb6b8d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Nov 2023 10:37:07 +0100 Subject: [PATCH 232/414] #12442 module view adjusted --- .../godmode/agentes/module_manager_editor_common.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index ab087f215c..278c6670bb 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -2357,6 +2357,16 @@ ui_require_jquery_file('json'); inverse_c = 0; } + if ($('#radius-percentage_warning').is(':checked') === true){ + min_w = 0; + max_w = 0; + } + + if ($('#radius-percentage_critical').is(':checked') === true){ + min_c = 0; + max_c = 0; + } + paint_graph_status( min_w, max_w, min_c, max_c, inverse_w, inverse_c, error_w, error_c, From b241200be687e6390a2f20253cbcbfcd7a619e62 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Nov 2023 10:46:06 +0100 Subject: [PATCH 233/414] #12251 check if enterprise is installed in open --- pandora_console/include/functions_agents.php | 72 ++++++++++---------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 4fb61875d5..2e2988f662 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4845,44 +4845,46 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; - // SecurityMon line. - $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); - $modules = db_get_all_rows_filter( - 'tagente_modulo', - [ - 'id_agente' => $agent['id_agente'], - 'id_module_group' => $id_module_group, - ] - ); + if (enterprise_installed() === true) { + // SecurityMon line. + $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); + $modules = db_get_all_rows_filter( + 'tagente_modulo', + [ + 'id_agente' => $agent['id_agente'], + 'id_module_group' => $id_module_group, + ] + ); - if (is_array($modules) === true && count($modules) > 0) { - $secmon_status = secmon_status($agent['id_agente']); - $data = []; - $data[0] = ''.__('SecurityMon').''; - $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); - $table_contact->data[] = $data; - } + if (is_array($modules) === true && count($modules) > 0) { + $secmon_status = secmon_status($agent['id_agente']); + $data = []; + $data[0] = ''.__('SecurityMon').''; + $data[1] = ui_print_status_secmon_div($secmon_status, __('Total security modules: %s', count($modules))); + $table_contact->data[] = $data; + } - // Hardening line. - $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); - $hardening = ''; - if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { - $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); - $hardening = format_numeric($raw_data_score[0]['datos'], 2); - $data = []; - $data[0] = ''.__('Hardening').''; - $data[1] = $hardening.' %'; - $table_contact->data[] = $data; - } + // Hardening line. + $module_score = modules_get_agentmodule_id(io_safe_input('Hardening - Score'), $agent['id_agente']); + $hardening = ''; + if (is_array($module_score) === true && key_exists('id_agente_modulo', $module_score) == true) { + $raw_data_score = modules_get_raw_data($module_score['id_agente_modulo'], 0, time()); + $hardening = format_numeric($raw_data_score[0]['datos'], 2); + $data = []; + $data[0] = ''.__('Hardening').''; + $data[1] = $hardening.' %'; + $table_contact->data[] = $data; + } - // Vulnerabilities line. - $vuls = get_vulnerabilities($agent['id_agente']); - if (is_array($vuls) === true && count($vuls) > 0) { - $score = get_score($vuls); - $data = []; - $data[0] = ''.__('Vulnerability').''; - $data[1] = ui_print_status_vulnerability_div($score); - $table_contact->data[] = $data; + // Vulnerabilities line. + $vuls = get_vulnerabilities($agent['id_agente']); + if (is_array($vuls) === true && count($vuls) > 0) { + $score = get_score($vuls); + $data = []; + $data[0] = ''.__('Vulnerability').''; + $data[1] = ui_print_status_vulnerability_div($score); + $table_contact->data[] = $data; + } } $agent_contact = html_print_div( From 4e3fa66c2bccd52ddf251e785f92055729c9b7c9 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 14 Nov 2023 11:44:51 +0100 Subject: [PATCH 234/414] fix error move agents to metaconsole pandora_enterprise#12086 --- pandora_console/include/api.php | 2 +- pandora_console/include/functions_api.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 0d105d5994..c10d111471 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -70,7 +70,7 @@ $otherSerialize = get_parameter('other'); $otherMode = get_parameter('other_mode', 'url_encode'); $returnType = get_parameter('return_type', 'string'); $info = get_parameter('info', ''); -$raw_decode = (bool) get_parameter('raw_decode', false); +$raw_decode = (bool) get_parameter('raw_decode', true); $other = parseOtherParameter($otherSerialize, $otherMode, $raw_decode); $apiPassword = io_output_password( diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index f6d1674022..7f96ee79ab 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -82,7 +82,7 @@ function parseOtherParameter($other, $otherType, $rawDecode) case 'url_encode': $returnVar = [ 'type' => 'string', - 'data' => urldecode($other), + 'data' => $rawDecode ? rawurldecode($other) : urldecode($other), ]; break; From f725752f3201b52645c6360cddbad5a6e5d2b45e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 12:33:29 +0100 Subject: [PATCH 235/414] #12168 fixed filter in service tree genealogy --- .../include/javascript/tree/TreeController.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 4f850e32d5..06274600ed 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1561,27 +1561,21 @@ var TreeController = { * Filter the tree based on a search criterion */ function _filterItems(rawTree, searched) { - console.log(rawTree); const ancestors = []; const father = []; const newTree = []; + const tmpTree = []; rawTree.map((raw, index) => { if (raw.type === "services") { if (raw.servicesChildren.length !== 0) { // search at parent level - let findedPadre = raw.description.indexOf(searched); + let descr = raw.description.toLowerCase(); + let sear = searched.toLowerCase(); + let findedPadre = descr.indexOf(sear); if (findedPadre === -1) { - // search for children - raw.servicesChildren.map(child => { - let finded = child.description.indexOf(searched); - if (finded === 0) { - //we keep the father of the child that contains it - ancestors.push(child.ancestor); - } else if (findedPadre === -1 && finded === -1) { - //we save the father - father.push(raw.id); - } - }); + father.push(raw.id); + } else if (findedPadre >= 0) { + ancestors.push(raw.id); } else { //we mark the father as found controller.finded = 1; @@ -1607,9 +1601,16 @@ var TreeController = { if (father.length >= 1) { let filterfather = [...new Set(father)]; - const newTree = rawTree.filter( - item => !filterfather.includes(item.id) - ); + + filterfather.map(father => { + tmpTree.push(rawTree.filter(raw => raw.id == father)); + }); + + let tree = [...new Set(tmpTree)]; + tree.map(item => { + let tmpItem = item[0]; + newTree.push(tmpItem); + }); return newTree; } From 2336e7c8da54b0cf5e201074ede5220306b8fda0 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 12:49:27 +0100 Subject: [PATCH 236/414] #12372 fixed link advanced_editor for remote conf server --- pandora_console/godmode/servers/servers.build_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 101a99d955..a2cde656c2 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -273,7 +273,7 @@ foreach ($servers as $server) { $data[8] .= ''; if (($names_servers[$safe_server_name] === true) && ($ext === '_server' || $server['type'] === 'enterprise satellite')) { - $data[8] .= ''; + $data[8] .= ''; $data[8] .= html_print_image( 'images/agents@svg.svg', true, From 0aece464f80ae31fc0ab484445ec064cf7b34b63 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 14 Nov 2023 13:38:09 +0100 Subject: [PATCH 237/414] fix sound alerts severity filter pandora_enterprise#12378 --- pandora_console/include/ajax/events.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 7e8341c4a1..7d643f8bbd 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -2642,6 +2642,8 @@ if ($get_events_fired) { $filter['date_to'] = date('Y-m-d', $end); $filter['time_from'] = date('H:i:s', $start); $filter['time_to'] = date('H:i:s', $end); + $filter['severity'] = explode(',', $filter['severity']); + $data = events_get_all( ['te.*'], $filter From db91fe3127b02def0205f13385b5f9785ea0bfd5 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 15:34:14 +0100 Subject: [PATCH 238/414] #12451 fixed default alert action for Telegram and Vonage. --- pandora_console/extras/mr/67.sql | 10 ++++++++++ pandora_console/pandoradb_data.sql | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 pandora_console/extras/mr/67.sql diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql new file mode 100644 index 0000000000..3644bdb080 --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,10 @@ +START TRANSACTION; + +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=9; +UPDATE talert_actions + SET field2='[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_' + WHERE id=11; + +COMMIT; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9ce5355361..f7e57d99f5 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1167,9 +1167,9 @@ INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`) VALUES (6,'Create Pandora ITSM ticket',16); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (7, 'Pandora Google chat', 17, "", "data=_data_", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", "", 0, 0, "", "data=_data_", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", ""); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (8, 'Pandora Slack', 18, "data=_data_", "", ":red_circle:", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", 0, 0, "data=_data_", "", ":green_circle:", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", ""); -INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (9, 'Pandora Telegram', 19, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", ""); +INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (9, 'Pandora Telegram', 19, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _timestamp_ / _data_", "", "", "", "", "", "", "", ""); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (10, 'Pandora ilert', 20, "alert", "", "[PANDORA] Alert FIRED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", "", 0, 0, "resolved", "", "[PANDORA] Alert RECOVERED on _agent_ / _module_", "_agent_ | _module_ | _data_ | _timestamp_", "", "", "", "", "", ""); -INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (11, 'Pandora Vonage', 21, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _tiemstamp_ / _data_", "", "", "", "", "", "", "", ""); +INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (11, 'Pandora Vonage', 21, "", "[PANDORA] Alert FIRED on _agent_ / _module_ / _timestamp_ / _data_", "", "", "", "", "", "", "", "", 0, 0, "", "[PANDORA] Alert RECOVERED on _agent_ / _module_ / _timestamp_ / _data_", "", "", "", "", "", "", "", ""); -- alert templates (default) From 4fec6a1ccbef81a0c4bbe9721d32ff635f6a73f9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Nov 2023 17:04:31 +0100 Subject: [PATCH 239/414] #12296 restyling agent detail filters --- pandora_console/include/styles/pandora.css | 16 ++++++++ .../operation/agentes/estado_agente.php | 41 +++++++++++++------ 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7c740bba2b..43b3823153 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -10214,6 +10214,14 @@ div#err_msg_centralised { align-items: flex-start; } +.div-col-4 { + width: 25%; + display: flex; + flex-direction: column; + align-items: flex-start; + margin-top: 10px; +} + .div-span { width: 100%; color: #161628; @@ -12792,3 +12800,11 @@ tr.shown td.details-control { position: relative; top: -92px; } + +.span_as_label { + font-size: 13px; + line-height: 16px; + color: #161628; + font-weight: bold; + margin-bottom: 10px; +} diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index d126b19144..d3543b0a7c 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -320,6 +320,7 @@ $table->size[0] = '50%'; $table->size[1] = '50%'; $table->class = 'filter-table-adv'; +$table->cellstyle['group'][0] = 'display: flex;width: 95% !important;'; $table->data['group'][0] = html_print_label_input_block( __('Group'), html_print_select_groups( @@ -336,7 +337,8 @@ $table->data['group'][0] = html_print_label_input_block( true, '', false - ) + ), + ['div_class' => 'w100p'] ); $table->data['group'][0] .= html_print_label_input_block( @@ -346,11 +348,7 @@ $table->data['group'][0] .= html_print_label_input_block( 1, $recursion, true - ), - [ - 'div_class' => 'add-input-reverse', - 'label_class' => 'label-thin', - ] + ) ); $table->data['group'][1] = html_print_label_input_block( @@ -405,7 +403,7 @@ foreach ($pre_fields as $key => $value) { $table->data[1][0] = html_print_label_input_block( __('Operating System'), - html_print_select($fields, 'os', $os, '', 'All', 0, true) + html_print_select($fields, 'os', $os, '', 'All', 0, true, false, true, 'w100p', false, 'width:100%') ); $table->data[1][1] = html_print_label_input_block( @@ -428,9 +426,22 @@ if (function_exists('policies_get_policies') === true) { } } -$table->data[2][0] = html_print_label_input_block( +$table->data[2][1] = html_print_label_input_block( __('Policies'), - html_print_select($fields, 'policies[]', $policies, '', 'All', 0, true, true) + html_print_select( + $fields, + 'policies', + $policies, + 'this.form.submit()', + __('All'), + 0, + true, + false, + true, + 'w100p', + false, + 'width: 100%' + ) ); $custom_fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -438,7 +449,7 @@ if ($custom_fields === false) { $custom_fields = []; } -$div_custom_fields = '
'; +$div_custom_fields = '
'; foreach ($custom_fields as $custom_field) { $custom_field_value = ''; if (empty($ag_custom_fields) === false) { @@ -448,10 +459,10 @@ foreach ($custom_fields as $custom_field) { } } - $div_custom_fields .= '
'; + $div_custom_fields .= '
'; $div_custom_fields .= '
'; - $div_custom_fields .= ''.$custom_field['name'].''; + $div_custom_fields .= ''.$custom_field['name'].''; $div_custom_fields .= '
'; $div_custom_fields .= '
'; @@ -890,7 +901,11 @@ if ($group_id > 0) { $groups = array_keys($user_groups); } -$all_policies = in_array(0, ($policies ?? [])); +if (is_array($policies)) { + $all_policies = in_array(0, ($policies ?? [])); +} else { + $all_policies = []; +} $id_os_sql = ''; $policies_sql = ''; From 78a5a3bfe8116b0c10b11b8c725301a0eaf102ae Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 17:12:22 +0100 Subject: [PATCH 240/414] #12168 Hierarchy is added to the title of services --- .../include/class/TreeService.class.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index a627794f0e..177a45a54f 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -333,6 +333,7 @@ class TreeService extends Tree $services[$service['id']]['id'] = $service['id']; $services[$service['id']]['description'] = $service['description']; $services[$service['id']]['serviceDetail'] = 'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int) $service['id']; + $services[$service['id']]['title'] = services_get_parents_title((int) $service['id']); } return $services; @@ -732,20 +733,8 @@ class TreeService extends Tree if (isset($this->filter['searchService']) === true && empty($this->filter['searchService']) === false ) { - $sqlFilter = 'SELECT ts.id FROM tservice ts - where ts.name LIKE "%'.$this->filter['searchService'].'%" - OR ts.description LIKE "%'.$this->filter['searchService'].'%"'; - - $filterResult = db_get_all_rows_sql($sqlFilter); - - $services = []; - foreach ($filterResult as $key => $result) { - $services_ancestors = services_get_services_ancestors($result['id']); - $services[] = array_pop($services_ancestors); - } - - $services_list = array_unique($services, SORT_NUMERIC); - $whereAncestors = ' AND tse.id_service IN ('.implode(',', $services_list).')'; + $whereAncestors = ' AND ts.name LIKE "%'.$this->filter['searchService'].'%" + OR ts.description LIKE "%'.$this->filter['searchService'].'%"'; return $whereAncestors; } From b45c967919d862b1f02161e55a915628f4c3299b Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 15 Nov 2023 08:30:24 +0100 Subject: [PATCH 241/414] add code lost inventory server pandora_enterprise#12188 --- .../lib/PandoraFMS/InventoryServer.pm | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/InventoryServer.pm b/pandora_server/lib/PandoraFMS/InventoryServer.pm index 5f0f90e95d..515d875788 100644 --- a/pandora_server/lib/PandoraFMS/InventoryServer.pm +++ b/pandora_server/lib/PandoraFMS/InventoryServer.pm @@ -183,15 +183,22 @@ sub data_consumer ($$) { # No code to run return if ($module->{'interpreter'} eq ''); - - # Save script in a temporary file + + my $command; my ($fh, $temp_file) = tempfile(); - $fh->print (decode_base64($module->{'code'})); - close ($fh); - set_file_permissions($pa_config, $temp_file, "0777"); - # Run the script - my $command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"'; + if ($module->{'script_mode'} == '1') { + my $script_file = $module->{'script_path'}; + $command = $module->{'interpreter'} . ' ' . $script_file; + } else { + # Save script in a temporary file + $fh->print (decode_base64($module->{'code'})); + close ($fh); + set_file_permissions($pa_config, $temp_file, "0777"); + + # Run the script + $command = $module->{'interpreter'} . ' ' . $temp_file . ' "' . $module->{'target'} . '"'; + } # Try to read the custom fields to use them as arguments into the command if (defined($module->{'custom_fields'}) && $module->{'custom_fields'} ne '') { @@ -206,7 +213,11 @@ sub data_consumer ($$) { if (!defined ($decoded_cfields)) { logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed because the custom fields can't be read", 6); - unlink ($temp_file); + + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + return; } @@ -237,11 +248,18 @@ sub data_consumer ($$) { # Check for errors if ($? != 0) { logger ($pa_config, "Remote inventory module ".$module->{'name'}." has failed with error level $?", 6); - unlink ($temp_file); + + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + return; } - unlink ($temp_file); + if ($module->{'script_mode'} == '2') { + unlink ($temp_file); + } + my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); eval { From 2db0d05a3703bbce023ea08c93e2d1eb8d7ee408 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 15 Nov 2023 09:46:40 +0100 Subject: [PATCH 242/414] #12250 new report detail security --- .../reporting_builder.item_editor.php | 90 +++++++++++++++++++ .../godmode/reporting/reporting_builder.php | 20 +++++ .../include/functions_reporting.php | 8 ++ .../include/functions_reporting_html.php | 68 ++++++++++++++ pandora_console/include/functions_reports.php | 5 ++ 5 files changed, 191 insertions(+) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index bb06d3a800..013b623c8b 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -1084,6 +1084,15 @@ switch ($action) { $period = $item['period']; break; + case 'vuls_by_agent': + $group = $item['id_group']; + $es = json_decode($item['external_source'], true); + $selected_agent_custom_field_filter = $es['agent_custom_field_filter']; + $security_hardening_score = $es['security_hardening_score']; + $vulnerabilities_status = $es['vulnerabilities_status']; + $secmon_status = $es['secmon_status']; + break; + default: // It's not possible. break; @@ -3913,6 +3922,76 @@ if (is_metaconsole() === true) { ?>
+ + + __('ALL'), + 'critical' => __('CRITICAL'), + 'warning' => __('WARNING'), + ], + 'secmon_status', + $secmon_status, + ); + ?> +
+ + + __('ALL'), + '90' => __('< 90%'), + '80' => __('< 80%'), + '70' => __('< 70%'), + '60' => __('< 60%'), + '50' => __('< 50%'), + '40' => __('< 40%'), + '30' => __('< 30%'), + '20' => __('< 20%'), + '10' => __('< 10%'), + ], + 'security_hardening_score', + (empty($security_hardening_score) === false) ? $security_hardening_score : 'all', + ); + ?> +
+ + + __('ALL'), + 'crit' => __('CRITICAL'), + 'warn' => __('WARNING'), + ], + 'vulnerabilities_status', + $vulnerabilities_status, + ); + ?> +
- + logo + diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 86b84376c5..4c1364c54c 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1483,6 +1483,18 @@ function show_dialog(dialog) { }, 50); } +function christmas_click() { + let counter = $("#count_click").val(); + counter++; + $("#count_click").val(counter); + if (counter == 25) { + $("#container-snow").removeClass("invisible"); + setTimeout(() => { + $("#container-snow").addClass("invisible"); + }, 30000); + } +} + /* ############################################################################# ## diff --git a/pandora_console/index.php b/pandora_console/index.php index ff6f27b152..63f063c02d 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1199,7 +1199,7 @@ if ($config['pure'] == 0) { $menuCollapsed = (isset($_SESSION['menu_type']) === true && $_SESSION['menu_type'] !== 'classic'); $menuTypeClass = ($menuCollapsed === true) ? 'collapsed' : 'classic'; // Snow. - $string = '
+ $string = '