From 0990fe672ea9265df572cf601cf186fb3310192b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 23 Feb 2023 09:48:13 +0100 Subject: [PATCH 01/27] #10324 added system fav menu in agent and events --- .../godmode/agentes/configurar_agente.php | 9 +- .../include/ajax/fav_menu.ajax.php | 82 +++++++++++++++++++ pandora_console/include/functions_ui.php | 56 ++++++++++++- .../include/javascript/pandora_ui.js | 25 ++++++ pandora_console/operation/events/events.php | 13 ++- pandora_console/operation/menu.php | 38 +++++++++ 6 files changed, 217 insertions(+), 6 deletions(-) create mode 100644 pandora_console/include/ajax/fav_menu.ajax.php diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index ab01bbf47f..1c9dc306bc 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -845,7 +845,14 @@ if ($id_agente) { __('Manage agents'), ''.$tab_name.'', ] - ) + ), + false, + [ + 'id_element' => $id_agente, + 'url' => 'godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente, + 'label' => agents_get_alias($id_agente), + 'section' => 'Agents', + ] ); } } else { diff --git a/pandora_console/include/ajax/fav_menu.ajax.php b/pandora_console/include/ajax/fav_menu.ajax.php new file mode 100644 index 0000000000..0b837ec9b3 --- /dev/null +++ b/pandora_console/include/ajax/fav_menu.ajax.php @@ -0,0 +1,82 @@ + $url, + 'id_user' => $config['id_user'], + ], + ['*'] +); +$res = false; +$action = ''; +if ($exist !== false) { + $res = db_process_sql_delete( + 'tfavmenu_user', + [ + 'url' => $url, + 'id_user' => $config['id_user'], + ] + ); + $action = 'delete'; +} else { + $res = db_process_sql_insert( + 'tfavmenu_user', + [ + 'id_element' => $id_element, + 'url' => $url, + 'label' => $label, + 'section' => $section, + 'id_user' => $id_user, + ] + ); + $action = 'create'; +} + +if ($res !== false) { + echo json_encode(['success' => true, 'action' => $action]); +} else { + echo json_encode(['success' => false, 'action' => $action]); +} diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 6a658997f6..87ae47ff31 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -4619,7 +4619,8 @@ function ui_print_standard_header( string $help='', bool $godmode=false, array $options=[], - array $breadcrumbs=[] + array $breadcrumbs=[], + array $fav_menu_config=[] ) { // For standard breadcrumbs. ui_require_css_file('discovery'); @@ -4663,7 +4664,9 @@ function ui_print_standard_header( '', GENERIC_SIZE_TEXT, '', - $headerInformation->printHeader(true) + $headerInformation->printHeader(true), + false, + $fav_menu_config ); } @@ -4705,7 +4708,8 @@ function ui_print_page_header( $numChars=GENERIC_SIZE_TEXT, $alias='', $breadcrumbs='', - $hide_left_small=false + $hide_left_small=false, + $fav_menu_config=[] ) { $title = io_safe_input_html($title); if (($icon == '') && ($godmode == true)) { @@ -4762,6 +4766,17 @@ function ui_print_page_header( } } + if (is_array($fav_menu_config) === true) { + if (count($fav_menu_config) > 0) { + $buffer .= ui_print_fav_menu( + $fav_menu_config['id_element'], + $fav_menu_config['url'], + $fav_menu_config['label'], + $fav_menu_config['section'] + ); + } + } + $buffer .= ''; if (is_metaconsole()) { @@ -7084,3 +7099,38 @@ function ui_get_inventory_module_add_form( } +function ui_print_fav_menu($id_element, $url, $label, $section) +{ + global $config; + $label = io_safe_output($label); + if (strlen($label) > 18) { + $label = io_safe_input(substr($label, 0, 18).'...'); + } + + $fav = db_get_row_filter( + 'tfavmenu_user', + [ + 'url' => $url, + 'id_user' => $config['id_user'], + ], + ['*'] + ); + $config_fav_menu = [ + 'id_element' => $id_element, + 'url' => $url, + 'label' => $label, + 'section' => $section, + ]; + + $output = ''; + $output .= html_print_input_image( + 'fav-menu-action', + (($fav !== false) ? 'images/star.png' : 'images/star_dark.png'), + base64_encode(json_encode($config_fav_menu)), + '', + true, + ['onclick' => 'favMenuAction(this)'] + ); + $output .= ''; + return $output; +} \ No newline at end of file diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 6d1cfe20c2..e65d8f382e 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -834,3 +834,28 @@ function unblockSubmit(button) { expireCookie("downloadReady"); attempts = 30; } + +function favMenuAction(e) { + var data = JSON.parse(atob(e.value)); + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "include/ajax/fav_menu.ajax", + id_element: data["id_element"], + url: data["url"], + label: data["label"], + section: data["section"] + }, + success: function(res) { + if (res.success) { + if (res.action === "create") { + $("#image-fav-menu-action1").attr("src", "images/star.png"); + } else { + $("#image-fav-menu-action1").attr("src", "images/star_dark.png"); + } + } + } + }); +} diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 8ac433d74f..79fc54565b 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1069,7 +1069,7 @@ if (is_ajax() === true) { */ $load_filter_id = (int) get_parameter('filter_id', 0); - +$fav_menu = []; if ($load_filter_id === 0) { // Load user filter. $loaded_filter = db_get_row_sql( @@ -1091,6 +1091,14 @@ if ($load_filter_id === 0) { 'id_filter', $load_filter_id ); + + // Fav menu + $fav_menu = [ + 'id_element' => $load_filter_id, + 'url' => 'operation/events/events&pure=&load_filter=1&filter_id='.$load_filter_id, + 'label' => $loaded_filter['id_name'], + 'section' => 'Events', + ]; } // Do not load the user filter if we come from the 24h event graph. @@ -1581,7 +1589,8 @@ if ($pure) { 'link' => '', 'label' => __('Events'), ], - ] + ], + $fav_menu ); } else { unset($onheader['rss']); diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index b678a810bc..22dc44f8c0 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -461,6 +461,44 @@ if ($access_console_node === true) { } } +$favorite_menu = db_get_all_rows_sql( + sprintf( + 'SELECT id_element, url, label, section + FROM tfavmenu_user + WHERE id_user = "%s" + ORDER BY section DESC', + $config['id_user'] + ) +); +// Favorite +if ($favorite_menu !== false) { + $menu_operation['favorite']['text'] = __('Favorite'); + $menu_operation['favorite']['id'] = 'fav-menu'; + + $section = ''; + $sub = []; + $sub2 = []; + foreach ($favorite_menu as $key => $row) { + if ($row['section'] !== $section) { + $section = $row['section']; + $sub2 = []; + } + + $sub[$section]['text'] = __($section); + $sub[$section]['type'] = 'direct'; + $sub[$section]['subtype'] = 'nolink'; + $sub[$section]['id'] = $row['section']; + + $sub2[$row['url']]['text'] = io_safe_output($row['label']); + $sub[$section]['sub2'] = $sub2; + } + + $menu_operation['favorite']['sub'] = $sub; +} + + + + // Workspace. $menu_operation['workspace']['text'] = __('Workspace'); $menu_operation['workspace']['sec2'] = 'operation/users/user_edit'; From c0dcc03388025b30ded773285b86fc9e84fbdea3 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 23 Feb 2023 11:00:46 +0100 Subject: [PATCH 02/27] #10324 added system fav in visual console and modules --- .../operation/agentes/status_monitor.php | 147 ++++++++++-------- pandora_console/views/dashboard/header.php | 14 +- 2 files changed, 92 insertions(+), 69 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 19193d1a1b..e9bb238688 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -50,74 +50,6 @@ enterprise_include_once('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); -if (! defined('METACONSOLE')) { - $section = (string) get_parameter('section', 'view'); - - $buttons['fields'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/custom_columns.png', - true, - [ - 'title' => __('Custom fields'), - 'class' => 'invert_filter', - ] - ).'', - 'operation' => true, - ]; - - $buttons['view'] = [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/list.png', - true, - [ - 'title' => __('View'), - 'class' => 'invert_filter', - ] - ).'', - 'operation' => true, - ]; - - switch ($section) { - case 'fields': - $buttons['fields']['active'] = true; - $subpage = ' » '.__('Custom fields'); - break; - - default: - $buttons['view']['active'] = true; - break; - } - - // Header. - ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, - [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], - ] - ); - - if ($section == 'fields') { - include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; - exit(); - } -} else { - $section = (string) get_parameter('sec', 'estado'); - ui_meta_print_header(__('Monitor view')); -} $recursion = get_parameter_switch('recursion', false); @@ -222,6 +154,7 @@ if (is_numeric($ag_group)) { } $load_filter_id = (int) get_parameter('filter_id', 0); +$fav_menu = []; if ($load_filter_id > 0) { $user_groups_fl = users_get_groups( @@ -285,6 +218,84 @@ if ($loaded_filter['id_filter'] > 0) { $ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true); } } + + // Fav menu + $fav_menu = [ + 'id_element' => $loaded_filter['id_filter'], + 'url' => 'operation/agentes/status_monitor&pure=&load_filter=1&filter_id='.$loaded_filter['id_filter'], + 'label' => $loaded_filter['id_name'], + 'section' => 'Modules', + ]; +} + +if (! defined('METACONSOLE')) { + $section = (string) get_parameter('section', 'view'); + + $buttons['fields'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/custom_columns.png', + true, + [ + 'title' => __('Custom fields'), + 'class' => 'invert_filter', + ] + ).'', + 'operation' => true, + ]; + + $buttons['view'] = [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/list.png', + true, + [ + 'title' => __('View'), + 'class' => 'invert_filter', + ] + ).'', + 'operation' => true, + ]; + + switch ($section) { + case 'fields': + $buttons['fields']['active'] = true; + $subpage = ' » '.__('Custom fields'); + break; + + default: + $buttons['view']['active'] = true; + break; + } + + // Header. + ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], + ], + $fav_menu + ); + + if ($section == 'fields') { + include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; + exit(); + } +} else { + $section = (string) get_parameter('sec', 'estado'); + ui_meta_print_header(__('Monitor view')); } // Agent group selector. diff --git a/pandora_console/views/dashboard/header.php b/pandora_console/views/dashboard/header.php index 9eac0b1b00..b6d8536bea 100644 --- a/pandora_console/views/dashboard/header.php +++ b/pandora_console/views/dashboard/header.php @@ -286,7 +286,19 @@ if ($publicLink === false) { false, '', false, - $buttons + $buttons, + false, + '', + GENERIC_SIZE_TEXT, + '', + '', + false, + [ + 'id_element' => $dashboardId, + 'url' => 'operation/dashboard/dashboard&dashboardId='.$dashboardId, + 'label' => $dashboardName, + 'section' => 'Dashboard', + ] ); } } else { From d6645ee28354c06a121fdc5659ed92f5738b3045 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Thu, 23 Feb 2023 11:37:23 +0100 Subject: [PATCH 03/27] #10324 added fav menu in network map and visual console --- .../operation/agentes/pandora_networkmap.view.php | 11 ++++++++++- pandora_console/operation/menu.php | 2 +- pandora_console/operation/visual_console/view.php | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index d85264b093..1990b4e9a0 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -2405,7 +2405,16 @@ if ($networkmap === false) { $buttons, false, '', - $config['item_title_size_text'] + $config['item_title_size_text'], + '', + '', + false, + [ + 'id_element' => $networkmap['id'], + 'url' => 'operation/agentes/pandora_networkmap&tab=view&id_networkmap='.$networkmap['id'], + 'label' => $networkmap['name'], + 'section' => 'Network_map', + ] ); } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 22dc44f8c0..11ab8d61d1 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -484,7 +484,7 @@ if ($favorite_menu !== false) { $sub2 = []; } - $sub[$section]['text'] = __($section); + $sub[$section]['text'] = __(str_replace('_', ' ', $section)); $sub[$section]['type'] = 'direct'; $sub[$section]['subtype'] = 'nolink'; $sub[$section]['id'] = $row['section']; diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index d4a5991339..312b22f043 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -231,6 +231,12 @@ if (is_metaconsole() === false) { 'link' => '', 'label' => __('Visual console'), ], + ], + [ + 'id_element' => $visualConsoleId, + 'url' => 'operation/visual_console/render_view&id='.$visualConsoleId, + 'label' => $visualConsoleName, + 'section' => 'Visual_Console', ] ); } From 032fcdeae46845a63516eb8e98b9b600b4c9259c Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 24 Feb 2023 10:23:14 +0100 Subject: [PATCH 04/27] #10324 added fav menu in reporting viewer --- pandora_console/include/functions_ui.php | 4 +++ .../include/javascript/pandora_ui.js | 25 +++++++++++++++++++ pandora_console/include/styles/discovery.css | 7 ++++++ .../operation/reporting/reporting_viewer.php | 6 +++++ 4 files changed, 42 insertions(+) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 87ae47ff31..4fc5523378 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7132,5 +7132,9 @@ function ui_print_fav_menu($id_element, $url, $label, $section) ['onclick' => 'favMenuAction(this)'] ); $output .= ''; + $output .= '
'; + $output .= '

'.__('Title').'

'; + $output .= html_print_input_text('label_fav_menu', '', '', 25, 255, true, false, true); + $output .= '
'; return $output; } \ No newline at end of file diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index e65d8f382e..7786eb97d3 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -837,6 +837,31 @@ function unblockSubmit(button) { function favMenuAction(e) { var data = JSON.parse(atob(e.value)); + if ( + data.label === "" && + $(e) + .attr("src") + .endsWith("star.png") === false + ) { + $("#dialog-fav-menu").dialog({ + title: "Please choose a title", + width: 330, + buttons: [ + { + class: + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next", + text: "Confirm", + click: function() { + data.label = $("#text-label_fav_menu").val(); + $(e).val(btoa(JSON.stringify(data))); + favMenuAction(e); + $(this).dialog("close"); + } + } + ] + }); + return; + } $.ajax({ method: "POST", url: "ajax.php", diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index b47e52e619..2ea05c7446 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -317,3 +317,10 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool bottom: -20px; top: auto; } +#dialog-fav-menu { + display: none; +} +#dialog-fav-menu p { + margin: 0px; + padding-top: 40px; +} diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 18d3ed82b4..1ac1e07a4b 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -232,6 +232,12 @@ if (is_metaconsole()) { 'link' => '', 'label' => __('Custom reports'), ], + ], + [ + 'id_element' => $id_report, + 'url' => 'operation/reporting/reporting_viewer&id='.$id_report, + 'label' => reporting_get_name($id_report), + 'section' => 'Reporting', ] ); } From 651b605f5521cb1540464eb16393cb9d0e3ce4b0 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 24 Feb 2023 11:49:42 +0100 Subject: [PATCH 05/27] #10324 added tfavmenu_user in database schema --- pandora_console/pandoradb.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index e43aaa7646..476efd5cc9 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -4177,3 +4177,15 @@ CREATE TABLE IF NOT EXISTS `tmonitor_filter` ( `ag_custom_fields` TEXT, PRIMARY KEY (`id_filter`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +-- --------------------------------------------------------------------- +-- Table `tfavmenu_user` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tfavmenu_user` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(255) NOT NULL, + `id_element` TEXT, + `url` TEXT NOT NULL, + `label` VARCHAR(255) NOT NULL, + `section` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`)); \ No newline at end of file From 728991ad9ad717374d26f3fb03bead8291bed59b Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 24 Feb 2023 13:36:13 +0100 Subject: [PATCH 06/27] #10324 delete fav menu when delete element --- pandora_console/godmode/reporting/map_builder.php | 8 ++++++++ pandora_console/include/functions_agents.php | 10 ++++++++++ pandora_console/include/functions_reports.php | 12 ++++++++++++ pandora_console/include/lib/Dashboard/Manager.php | 10 ++++++++++ .../operation/agentes/pandora_networkmap.php | 9 +++++++++ 5 files changed, 49 insertions(+) diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index f85849a4ea..3f51a2e6db 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -197,6 +197,14 @@ if ($delete_layout || $copy_layout) { 'tlayout', ['id' => $id_layout] ); + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_user' => $config['id_user'], + 'id_element' => $id_layout, + 'section' => 'Visual_Console', + ] + ); $auditMessage = ((bool) $result === true) ? 'Delete visual console' : 'Fail try to delete visual console'; db_pandora_audit( diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 6e37a1e991..26246ac96e 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2733,6 +2733,16 @@ function agents_delete_agent($id_agents, $disableACL=false) enterprise_include_once('include/functions_agents.php'); enterprise_hook('agent_delete_from_cache', [$id_agent]); + // Delete agent from fav menu. + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_user' => $config['id_user'], + 'id_element' => $id_agent, + 'section' => 'Agents', + ] + ); + // Break the loop on error. if ((bool) $error === true) { break; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 0d39f5b916..d04f781ca9 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -221,6 +221,8 @@ function reports_update_report($id_report, $values) */ function reports_delete_report($id_report) { + global $config; + $id_report = safe_int($id_report); if (empty($id_report)) { return false; @@ -231,6 +233,16 @@ function reports_delete_report($id_report) return false; } + // Delete report from fav menu. + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_user' => $config['id_user'], + 'id_element' => $id_report, + 'section' => 'Reporting', + ] + ); + @db_process_sql_delete('treport_content', ['id_report' => $id_report]); return @db_process_sql_delete('treport', ['id_report' => $id_report]); } diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index b81ab485a7..7bb02f842d 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -568,6 +568,16 @@ class Manager implements PublicLogin 'tdashboard', ['id' => $this->dashboardId] ); + + // Delete dashboard from fav menu. + \db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_user' => $config['id_user'], + 'id_element' => $this->dashboardId, + 'section' => 'Dashboard', + ] + ); } // Audit. diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index d258881d5b..7b53bf3f18 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -548,6 +548,15 @@ else if ($update_networkmap || $copy_networkmap || $delete) { $result = networkmap_delete_networkmap($id); + // Delete network map from fav menu. + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_user' => $config['id_user'], + 'id_element' => $id, + 'section' => 'Network_map', + ] + ); $result_txt = ui_print_result_message( $result, __('Succesfully deleted'), From 3dee690e42f08206c3dc908b26f7a33e35d0dce4 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Fri, 24 Feb 2023 13:58:16 +0100 Subject: [PATCH 07/27] #10324 added table tfavmenu_user in mr --- pandora_console/extras/mr/62.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pandora_console/extras/mr/62.sql diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql new file mode 100644 index 0000000000..3ab5406ecc --- /dev/null +++ b/pandora_console/extras/mr/62.sql @@ -0,0 +1,12 @@ +START TRANSACTION; + +CREATE TABLE IF NOT EXISTS `tfavmenu_user` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(255) NOT NULL, + `id_element` TEXT, + `url` TEXT NOT NULL, + `label` VARCHAR(255) NOT NULL, + `section` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`)); + +COMMIT; From e76d8606dcf76966d64deac60e6eb68edd458ef4 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 27 Feb 2023 09:45:15 +0100 Subject: [PATCH 08/27] #10324 added star in menu --- pandora_console/include/functions_ui.php | 2 +- pandora_console/include/javascript/pandora_ui.js | 2 +- pandora_console/include/styles/discovery.css | 3 +++ pandora_console/include/styles/menu.css | 6 ++++++ pandora_console/operation/menu.php | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 4fc5523378..d411884a44 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7125,7 +7125,7 @@ function ui_print_fav_menu($id_element, $url, $label, $section) $output = ''; $output .= html_print_input_image( 'fav-menu-action', - (($fav !== false) ? 'images/star.png' : 'images/star_dark.png'), + (($fav !== false) ? 'images/star_fav_menu.png' : 'images/star_dark.png'), base64_encode(json_encode($config_fav_menu)), '', true, diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 7786eb97d3..3f99e1a675 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -876,7 +876,7 @@ function favMenuAction(e) { success: function(res) { if (res.success) { if (res.action === "create") { - $("#image-fav-menu-action1").attr("src", "images/star.png"); + $("#image-fav-menu-action1").attr("src", "images/star_fav_menu.png"); } else { $("#image-fav-menu-action1").attr("src", "images/star_dark.png"); } diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 2ea05c7446..65cd93c657 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -324,3 +324,6 @@ div.ui-tooltip.ui-corner-all.ui-widget-shadow.ui-widget.ui-widget-content.uitool margin: 0px; padding-top: 40px; } +.fav-menu input { + padding: 0px; +} diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index d59f802498..b8e0b9ee60 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -149,6 +149,9 @@ li.sub_subMenu.selected { #icon_oper-events { background-image: url(../../images/menu/op_events.menu_gray.png); } +#icon_fav-menu { + background-image: url(../../images/menu/fav_menu_gray.png); +} /* users */ #icon_oper-users { @@ -336,6 +339,9 @@ ul li { .selected#icon_oper-users { background-image: url(../../images/menu/op_workspace.menu_white.png); } +.selected#icon_fav-menu { + background-image: url(../../images/menu/fav_menu_white.png); +} .selected#icon_oper-reporting { background-image: url(../../images/menu/op_reporting.menu_white.png); } diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 11ab8d61d1..154d4191be 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -470,7 +470,7 @@ $favorite_menu = db_get_all_rows_sql( $config['id_user'] ) ); -// Favorite +// Favorite. if ($favorite_menu !== false) { $menu_operation['favorite']['text'] = __('Favorite'); $menu_operation['favorite']['id'] = 'fav-menu'; From 4917b40d10de721d113338e64605c8df84a298fe Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 27 Feb 2023 10:05:16 +0100 Subject: [PATCH 09/27] 10324 fixed modal in filter title --- pandora_console/include/functions_ui.php | 5 ++++- pandora_console/include/javascript/pandora_ui.js | 9 +++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d411884a44..764427a25b 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7129,7 +7129,10 @@ function ui_print_fav_menu($id_element, $url, $label, $section) base64_encode(json_encode($config_fav_menu)), '', true, - ['onclick' => 'favMenuAction(this)'] + [ + 'onclick' => 'favMenuAction(this)', + 'class' => (($fav !== false) ? 'active' : ''), + ] ); $output .= ''; $output .= '
'; diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 3f99e1a675..17cb359818 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -837,12 +837,7 @@ function unblockSubmit(button) { function favMenuAction(e) { var data = JSON.parse(atob(e.value)); - if ( - data.label === "" && - $(e) - .attr("src") - .endsWith("star.png") === false - ) { + if (data.label === "" && $(e).hasClass("active") === false) { $("#dialog-fav-menu").dialog({ title: "Please choose a title", width: 330, @@ -877,8 +872,10 @@ function favMenuAction(e) { if (res.success) { if (res.action === "create") { $("#image-fav-menu-action1").attr("src", "images/star_fav_menu.png"); + $("#image-fav-menu-action1").addClass("active"); } else { $("#image-fav-menu-action1").attr("src", "images/star_dark.png"); + $("#image-fav-menu-action1").removeClass("active"); } } } From 08fb4e33969c5b34b43a46785e8c6349604d8b4c Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 27 Feb 2023 10:07:35 +0100 Subject: [PATCH 10/27] #10324 fixed delete element in favmenu --- pandora_console/godmode/reporting/map_builder.php | 1 - pandora_console/include/functions_agents.php | 1 - pandora_console/include/functions_reports.php | 1 - pandora_console/include/lib/Dashboard/Manager.php | 1 - pandora_console/operation/agentes/pandora_networkmap.php | 1 - 5 files changed, 5 deletions(-) diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 3f51a2e6db..8a09ded649 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -200,7 +200,6 @@ if ($delete_layout || $copy_layout) { db_process_sql_delete( 'tfavmenu_user', [ - 'id_user' => $config['id_user'], 'id_element' => $id_layout, 'section' => 'Visual_Console', ] diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 26246ac96e..f2f7bb15f4 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2737,7 +2737,6 @@ function agents_delete_agent($id_agents, $disableACL=false) db_process_sql_delete( 'tfavmenu_user', [ - 'id_user' => $config['id_user'], 'id_element' => $id_agent, 'section' => 'Agents', ] diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index d04f781ca9..ec6ec6909e 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -237,7 +237,6 @@ function reports_delete_report($id_report) db_process_sql_delete( 'tfavmenu_user', [ - 'id_user' => $config['id_user'], 'id_element' => $id_report, 'section' => 'Reporting', ] diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 7bb02f842d..00e1ef0fd1 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -573,7 +573,6 @@ class Manager implements PublicLogin \db_process_sql_delete( 'tfavmenu_user', [ - 'id_user' => $config['id_user'], 'id_element' => $this->dashboardId, 'section' => 'Dashboard', ] diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 7b53bf3f18..c880bdbe96 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -552,7 +552,6 @@ else if ($update_networkmap || $copy_networkmap || $delete) { db_process_sql_delete( 'tfavmenu_user', [ - 'id_user' => $config['id_user'], 'id_element' => $id, 'section' => 'Network_map', ] From 8a33756e3a9a66855f8179ac30d7eed742e4e2ee Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 27 Feb 2023 11:17:17 +0100 Subject: [PATCH 11/27] #10324 added limit in modal title --- pandora_console/include/javascript/pandora_ui.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 17cb359818..a96eafc32c 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -848,6 +848,10 @@ function favMenuAction(e) { text: "Confirm", click: function() { data.label = $("#text-label_fav_menu").val(); + if (data.label.length > 18) { + data.label = data.label.slice(0, 18) + "..."; + } + $(e).val(btoa(JSON.stringify(data))); favMenuAction(e); $(this).dialog("close"); From 6efa1f46d7dbbe3a2f5a761d5787c7b3f8d9f884 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 8 Mar 2023 16:01:50 +0100 Subject: [PATCH 12/27] #10324 fixed conflic wit tickets 10325 --- pandora_console/include/javascript/pandora_ui.js | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 02bc97c9ea..944c454747 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -855,6 +855,7 @@ function favMenuAction(e) { $(e).val(btoa(JSON.stringify(data))); favMenuAction(e); $(this).dialog("close"); + $("input[name='label_fav_menu']").val(""); } } ] From e3f606530a21f1aefe16a97b192b63cdb4660777 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 9 Mar 2023 13:16:28 +0100 Subject: [PATCH 13/27] changed the way of getting data out of windows to make it faster --- pandora_agents/unix/plugins/autodiscover | 243 +++++++++-------------- 1 file changed, 89 insertions(+), 154 deletions(-) diff --git a/pandora_agents/unix/plugins/autodiscover b/pandora_agents/unix/plugins/autodiscover index 03b2c3d76d..01b9bd3d96 100644 --- a/pandora_agents/unix/plugins/autodiscover +++ b/pandora_agents/unix/plugins/autodiscover @@ -6,21 +6,22 @@ # # (c) A. Kevin Rojas # +# Edited in 2023 by Alejandro Sánchez +# # TO DO LIST: # - Enable child services detection (Windows) # - Make CPU/Memory usage available for child services (Windows) # ################################################### - try: from sys import argv from sys import stderr from sys import exit + import psutil from subprocess import Popen from subprocess import PIPE from subprocess import DEVNULL from subprocess import getstatusoutput - import psutil except ModuleNotFoundError as err: print("{} error: {}. Exiting...".format(argv[0], err), file=stderr) exit(1) @@ -28,99 +29,100 @@ except ModuleNotFoundError as err: module_list = [] VERSION = "1.2" +def win_service(servicelist, option=False, memcpu=False): -######################################################################################### -# Powershell class -######################################################################################### -class PSCheck: - @staticmethod - def check_service(servicename, option=False, memcpu=False): - """Check services with powershell by parsing their DisplayName. Returns a dict\ - list with the name of the service and a boolean with its status.\n - Requires service name (case insensitive).""" - pscall = Popen(["powershell", "Get-Service", "-Name", "'*"+ str(servicename) + "*'", - "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = pscall.communicate() - result = str(result[0]).strip().split("\n") - procname = '' - if result != '': - output = [] - for element in result: - if element != '': - # Get process name - procname = PSCheck.get_serviceprocess(element) - # Get process status - parstatus = PSCheck.getstatus(element) - if memcpu and parstatus == 1: - usage = get_memcpu(str(procname), str(element)) - output += usage - # Generate module with name and status - parent = service_module(str(element), parstatus) - output += parent - if option: - children = PSCheck.getchildren(element, memcpu) - if isinstance(children, list) and len(children) > 1: - for child in children: - output += child - else: - output += children - else: - next - - if output and element and procname: - return ({"name" : element, "process" : procname, "modules": output}) + modules_default = [] + modules_percentage=[] + ## take all services + services=psutil.win_service_iter() + for service in services: + if service.name() in servicelist: + serv=service.as_dict() + if serv['status']=='running': + value=1 else: - return (None) + value=0 - @staticmethod - def getchildren(servicename, memcpu=False): - """Gets Dependent services of a given Windows service""" - pschild = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' -DS", "|", "Select-Object", "-ExpandProperty", "Name"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - children = pschild.communicate()[0].strip() - kids = [] - for child in (children.split("\n") if children != "" else []): - status = PSCheck.getstatus(child) - kids += service_module(str(child), status, "Service " + str(servicename) + " - Status") - if status: - if memcpu: - kidsusage = get_memcpu(str(child)) - for usage in kidsusage: - kids += usage + ## create module for each service + parent = build_module("Service " + str(serv['name']) + " - Status", value,"generic_proc") + modules_default +=parent + + # memory and cpu percentage + if memcpu: + ## process + srv_pid = service.pid() + process = psutil.Process(srv_pid) + proc_name = process.name() + ##cpu + value_cpu=process.cpu_percent(interval=0.5) + parent = build_module("Service " + str(proc_name) + " - CPU usage", value_cpu,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + ##mem + value_mem=process.memory_percent() + parent = build_module("Service " + str(proc_name) + " - Memory usage", value_mem,"generic_data") + parent[0].update([("unit","%"),("module_parent",str(serv['name']))]) + modules_percentage +=parent + + + for module in modules_default: + print_module(module, 1) + if memcpu: + for module in modules_percentage: + print_module(module, 1) + +def lnx_service(services_list, memcpu=False): + """Creates modules for Linux servers""" + modules = [] + sysctl = getstatusoutput("command -v systemctl")[0] + servic = getstatusoutput("command -v service")[0] + for srvc in services_list: + status = None + if sysctl == 0: + ### Systemd available + syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, + stdin=DEVNULL, universal_newlines=True) + result = syscall.communicate() + srvstatus = result[0].strip().lower().split("\n") + if srvstatus[0] == "loadstate=not-found": + next + else: + if srvstatus[1] == "activestate=active": + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif srvstatus[1] == "activestate=inactive": + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 + elif sysctl != 0 and servic == 0: + ### Systemd not available, switch to service command + syscall = Popen(["service", srvc, "status"], stdout=PIPE, + stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) + result = syscall.communicate()[0].lower() + if "is running" in result: + modules += build_module("Service " + srvc + " - Status", 1, "generic_proc") + status = 1 + elif "is stopped" in result: + modules += build_module("Service " +srvc+ " - Status", 0, "generic_proc") + status = 0 else: next - return kids - - @staticmethod - def getstatus(servicename): - """Gets the status of a given Windows service""" - running = Popen(["powershell", "Get-Service", "-Name '" + str(servicename) + - "' |", "Select-Object", "-ExpandProperty", "Status"], - stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - status = running.communicate()[0].strip() - return int(status == "Running") - - @staticmethod - def get_serviceprocess(servicename): - """Gets name of the process of the service""" - service = psutil.win_service_get(servicename) - srv_pid = service.pid() - process = psutil.Process(srv_pid) - proc_name = process.name() - return proc_name + else: + print("No systemd or service commands available. Exiting...", file=stderr) + exit() + if status: + module_list.append(srvc) + if memcpu: + modules += get_memcpu(srvc, None) + + for m in modules: + print_module(m, 1) -######################################################################################### -# Services creation -######################################################################################### - -def service_module(name, value, parent=None): +def build_module(name, value, module_type, parent=None): #print ("service_module BEGIN "+str(now(0,1))) module = [{ - "name" : "Service "+ name + " - Status", - "type" : "generic_proc", + "name" : name , + "type" : module_type, "value" : value, "module_parent" : parent, }] @@ -167,74 +169,6 @@ def proc_percentbyname(procname): ############# 03/03/2020 next #print ("proc_percentbyname END "+str(now(0,1))) return [sum(memory),sum(cpu)] - -def win_service(servicelist, option=False, memcpu=False): - """Creates modules for Windows servers.""" - modules = [] - for srvc in servicelist: - if srvc and len(srvc) > 2: - output = PSCheck.check_service(srvc, option, memcpu) - if output is not None and output["modules"]: - modules += PSCheck.check_service(srvc.strip(), option, memcpu)["modules"] - module_list.append(srvc) - #winprocess = output["name"] - #if memcpu == True: - # modules += get_memcpu(winprocess) ## Only available for parent service ATM. - else: - next - else: - next - for module in modules: - print_module(module, 1) - - -def lnx_service(services_list, memcpu=False): - """Creates modules for Linux servers""" - modules = [] - sysctl = getstatusoutput("command -v systemctl")[0] - servic = getstatusoutput("command -v service")[0] - for srvc in services_list: - status = None - if sysctl == 0: - ### Systemd available - syscall = Popen(["systemctl", "show", "-pLoadState", "-pActiveState", srvc], stdout=PIPE, - stdin=DEVNULL, universal_newlines=True) - result = syscall.communicate() - srvstatus = result[0].strip().lower().split("\n") - if srvstatus[0] == "loadstate=not-found": - next - else: - if srvstatus[1] == "activestate=active": - modules += service_module(srvc, 1) - status = 1 - elif srvstatus[1] == "activestate=inactive": - modules += service_module(srvc, 0) - status = 0 - elif sysctl != 0 and servic == 0: - ### Systemd not available, switch to service command - syscall = Popen(["service", srvc, "status"], stdout=PIPE, - stdin=DEVNULL, stderr=DEVNULL, universal_newlines=True) - result = syscall.communicate()[0].lower() - if "is running" in result: - modules += service_module(srvc, 1) - status = 1 - elif "is stopped" in result: - modules += service_module(srvc, 0) - status = 0 - else: - next - else: - print("No systemd or service commands available. Exiting...", file=stderr) - exit() - if status: - module_list.append(srvc) - if memcpu: - modules += get_memcpu(srvc, None) - - for m in modules: - print_module(m, 1) - - ######################################################################################### # print_module function ######################################################################################### @@ -356,6 +290,7 @@ def main(): service_list = ["MySQL", "postgresql", "pgsql", "oracle", "MSSQL", "IISADMIN", "apache", "nginx", "W3svc", "NTDS", "Netlogon", "DNS", "MSExchangeADTopology", "MSExchangeServiceHost", "MSExchangeSA", "MSExchangeTransport"] + discover(OS, service_list) elif psutil.LINUX: OS = "Linux" From 596ade6d3706a54b9cf5a5c9ccf185ed6b618ead Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Mar 2023 09:14:16 +0100 Subject: [PATCH 14/27] #10324 added system fav in tactical view group --- pandora_console/godmode/groups/tactical.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 037af05723..d7984c3212 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -74,6 +74,12 @@ if (is_metaconsole() === false) { 'link' => '', 'label' => __('Tactic group'), ], + ], + [ + 'id_element' => $id_group, + 'url' => 'gagent&sec2=godmode/groups/tactical&id_group='.$id_group, + 'label' => groups_get_name($id_group), + 'section' => 'Tactic_group', ] ); } From 339d7e8bfe13568a5b677bf0a5345cfb2645e2b1 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Mar 2023 12:57:09 +0100 Subject: [PATCH 15/27] #10324 fixed error 500 --- .../operation/agentes/status_monitor.php | 54 +++++++++++++------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index bc367cfd63..c94a5619a0 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -315,26 +315,48 @@ if (is_metaconsole() === false) { } } -// Header. -ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, - [ +if ($loaded_filter['id_filter'] > 0) { + // Header. + ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, [ - 'link' => '', - 'label' => __('Monitoring'), + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], ], + $fav_menu + ); +} else { + // Header. + ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, [ - 'link' => '', - 'label' => __('Views'), + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Views'), + ], ], - ], - $fav_menu -); + ); +} $all_groups = []; From bdeb2240f379e9ab8606dea0a796ecc0add7ac1f Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Mar 2023 13:01:48 +0100 Subject: [PATCH 16/27] 10324 refactor duplicity code --- .../operation/agentes/status_monitor.php | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index c94a5619a0..b1aff8bc72 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -315,48 +315,26 @@ if (is_metaconsole() === false) { } } -if ($loaded_filter['id_filter'] > 0) { - // Header. - ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, +// Header. +ui_print_standard_header( + __('Monitor detail').$subpage, + 'images/agent.png', + false, + '', + true, + $buttons, + [ [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], + 'link' => '', + 'label' => __('Monitoring'), ], - $fav_menu - ); -} else { - // Header. - ui_print_standard_header( - __('Monitor detail').$subpage, - 'images/agent.png', - false, - '', - true, - $buttons, [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Views'), - ], + 'link' => '', + 'label' => __('Views'), ], - ); -} + ], + (empty($fav_menu) === true) ? [] : $fav_menu +); $all_groups = []; From 90f0c3771feb8fc8163f6919407eadcd7275f8ed Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 13 Mar 2023 17:21:28 +0100 Subject: [PATCH 17/27] #10324 fixed deleted element fav menu --- pandora_console/godmode/groups/group_list.php | 8 ++++++++ pandora_console/godmode/reporting/map_builder.php | 1 + pandora_console/include/ajax/module.php | 8 ++++++++ pandora_console/include/functions_agents.php | 1 + pandora_console/include/functions_reports.php | 1 + pandora_console/include/lib/Dashboard/Manager.php | 1 + .../operation/agentes/pandora_networkmap.editor.php | 2 +- pandora_console/operation/agentes/pandora_networkmap.php | 1 + 8 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 95785a0edd..6e604c7e1a 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -714,6 +714,14 @@ if ($is_management_allowed === true ); if ($result && (!$usedGroup['return'])) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_group, + 'section' => 'Tactic_group', + 'id_user' => $config['id_user'], + ] + ); ui_print_success_message(__('Group successfully deleted')); } else { ui_print_error_message( diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 7b224e46fa..85d4ecb6c4 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -194,6 +194,7 @@ if ($delete_layout || $copy_layout) { [ 'id_element' => $id_layout, 'section' => 'Visual_Console', + 'id_user' => $config['id_user'], ] ); diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index bd356894ad..91c452a81e 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -2044,6 +2044,14 @@ if (check_login()) { if ($monitor_filters === false) { echo 'error'; } else { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id, + 'section' => 'Modules', + 'id_user' => $config['id_user'], + ] + ); echo 'ok'; } } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index cf8e18ada0..f8bb2fc024 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2775,6 +2775,7 @@ function agents_delete_agent($id_agents, $disableACL=false) [ 'id_element' => $id_agent, 'section' => 'Agents', + 'id_user' => $config['id_user'], ] ); diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index aa9ede2aed..0b343d449d 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -239,6 +239,7 @@ function reports_delete_report($id_report) [ 'id_element' => $id_report, 'section' => 'Reporting', + 'id_user' => $config['id_user'], ] ); diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 2ed155c697..db8235681a 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -575,6 +575,7 @@ class Manager implements PublicLogin [ 'id_element' => $this->dashboardId, 'section' => 'Dashboard_', + 'id_user' => $config['id_user'], ] ); } diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index 4450e101ea..187481c0c9 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -275,7 +275,7 @@ if ($not_found) { } else { if ($disabled_source === false) { echo '
'; - echo html_print_image('images/spinner.gif', true, 'width: 50px;height: 50px;'); + echo html_print_image('images/spinner.gif', true, ['style' => 'width: 50px;height: 50px;']); echo '
'.__('Creating map...').'
'; echo '
'; $info1 = __('To create a network map that visually recreates link-level (L2) relationships, you must first discover these relationships with Discovery Server. Network maps only reflect relationships that have already been discovered.'); diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 0e92a5882b..506f778e6d 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -554,6 +554,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { [ 'id_element' => $id, 'section' => 'Network_map', + 'id_user' => $config['id_user'], ] ); $result_txt = ui_print_result_message( From e4d6737192d36c1044292b391902f9183e5c2ebb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Mar 2023 09:42:26 +0100 Subject: [PATCH 18/27] #10324 fixed system fav in meta --- pandora_console/include/functions_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 137b9db25e..2413d872ef 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -5149,7 +5149,7 @@ function ui_print_page_header( } } - if (is_array($fav_menu_config) === true) { + if (is_array($fav_menu_config) === true && is_metaconsole() === false) { if (count($fav_menu_config) > 0) { $buffer .= ui_print_fav_menu( $fav_menu_config['id_element'], From dff82df484017890a3dab95dc79093de1d4fc119 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Tue, 14 Mar 2023 10:31:31 +0100 Subject: [PATCH 19/27] #10324 fixed deleted filter event in fav menu --- pandora_console/godmode/events/event_filter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 9a2c9df9f6..2bbbb18077 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -59,6 +59,14 @@ if ($delete) { } if ($result !== false) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id_filter, + 'section' => 'Events', + 'id_user' => $config['id_user'], + ] + ); $result = true; } else { $result = false; From c4f4d371cc615a8ce83dff0ce0f9f362d3a1dcdd Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 14 Mar 2023 17:25:58 +0100 Subject: [PATCH 20/27] fixed styles --- .../agentes/module_manager_editor_common.php | 215 +++++++----------- 1 file changed, 88 insertions(+), 127 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 2cceb5fa34..b87d508546 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -444,7 +444,8 @@ $tableBasicThresholds->data = []; $tableBasicThresholds->rowclass['caption_warning_threshold'] = 'field_half_width pdd_t_10px'; $tableBasicThresholds->rowclass['warning_threshold'] = 'field_half_width'; $tableBasicThresholds->data['caption_warning_threshold'][0] .= __('Warning threshold').' '; -if ($edit_module === false && (isset($stringTypeModule) === false || $stringTypeModule === false)) { + +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { $tableBasicThresholds->data['caption_warning_threshold'][0] .= '('.__('Min / Max').')'; $tableBasicThresholds->data['warning_threshold'][0] .= html_print_input_text( 'min_warning', @@ -482,7 +483,7 @@ if ($edit_module === false && (isset($stringTypeModule) === false || $stringType ); } -if ($edit_module === false && isset($stringTypeModule) === true && $stringTypeModule === true) { +if (isset($stringTypeModule) === true && $stringTypeModule === true) { $basicThresholdsIntervalWarning = []; $basicThresholdsIntervalWarning[] = ''.__('Inverse interval').''; $basicThresholdsIntervalWarning[] = html_print_checkbox_switch( @@ -531,7 +532,7 @@ $tableBasicThresholds->data['switch_warning_threshold'][0] .= html_print_div( $tableBasicThresholds->rowclass['caption_critical_threshold'] = 'field_half_width pdd_t_10px'; $tableBasicThresholds->rowclass['critical_threshold'] = 'field_half_width'; $tableBasicThresholds->data['caption_critical_threshold'][0] .= __('Critical threshold').' '; -if ($edit_module === false && (isset($stringTypeModule) === false || $stringTypeModule === false)) { +if ((isset($stringTypeModule) === false || $stringTypeModule === false)) { $tableBasicThresholds->data['caption_critical_threshold'][0] .= '('.__('Min / Max').')'; $tableBasicThresholds->data['critical_threshold'][0] .= html_print_input_text( 'min_critical', @@ -569,7 +570,7 @@ if ($edit_module === false && (isset($stringTypeModule) === false || $stringType ); } -if ($edit_module === false && isset($stringTypeModule) === true && $stringTypeModule === true) { +if (isset($stringTypeModule) === true && $stringTypeModule === true) { $basicThresholdsIntervalCritical = []; $basicThresholdsIntervalCritical[] = ''.__('Inverse interval').''; $basicThresholdsIntervalCritical[] = html_print_checkbox_switch( @@ -1905,78 +1906,63 @@ $(document).ready (function () { }); $('.switch_radio_button label').on('click', function(){ + console.log('primero'); var thisLabel = $(this).attr('for'); - $('#'+thisLabel).attr('checked', 'checked'); - $('#'+thisLabel).siblings().attr('checked', false); - - if ($('#radius-warning_inverse').prop('checked') === true) { - //$('#percentage_warning').hide(); - $("#svg_dinamic").show(); - } + console.log(thisLabel); + $('#'+thisLabel).prop('checked', true); + $('#'+thisLabel).siblings().prop('checked', false); - if ($('#radius-critical_inverse').prop('checked') === true) { - //$('#percentage_critical').hide(); + console.log('++++++++++Los warning++++++++++++++'); + console.log('normal_warning: '+$('#radius-normal_warning').prop('checked')); + console.log('warning_inverse: '+$('#radius-warning_inverse').prop('checked')); + console.log('percentage_warning: '+$('#radius-percentage_warning').prop('checked')); + + console.log('++++++++++Los critical++++++++++++++'); + console.log('normal_critical: '+$('#radius-normal_critical').prop('checked')); + console.log('critical_inverse: '+$('#radius-critical_inverse').prop('checked')); + console.log('percentage_critical: '+$('#radius-percentage_critical').prop('checked')); + + if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { + $("#svg_dinamic").hide(); + } else { + paint_graph_values(); $("#svg_dinamic").show(); } if ($('#radius-percentage_warning').prop('checked') === true) { - //$('#warning_inverse').hide(); - $("#svg_dinamic").hide(); + $('#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(); + $('#radius-percentage_warning').show(); + $('#label-radius-percentage_warning').show(); + } + + if ($('#radius-percentage_critical').prop('checked') === true) { - //$('#critical_inverse').hide(); - $("#svg_dinamic").hide(); + $('#radius-critical_inverse').hide(); + $('#label-radius-critical_inverse').hide(); } - $('#radius-warning_inverse').change (function() { - paint_graph_values(); - if ($('#radius-warning_inverse').prop('checked') === true){ - $('#radius-percentage_warning').prop('checked', false); - $('#percentage_warning').attr('onClick', 'return false;'); - $('#percentage_warning>em').addClass('color_666'); - } else { - $('#percentage_warning').removeAttr('onClick'); - $('#percentage_warning>em').removeClass('color_666'); - } - }); + if ($('#radius-critical_inverse').prop('checked') === true) { + $('#radius-percentage_critical').hide(); + $('#label-radius-percentage_critical').hide(); + } - $('#radius-critical_inverse').change (function() { - paint_graph_values(); - - if ($('#radius-critical_inverse').prop('checked') === true){ - $('#radius-percentage_critical').prop('checked', false); - $('#percentage_critical').attr('onClick', 'return false;'); - $('#percentage_critical>em').addClass('color_666'); - } else { - $('#percentage_critical').removeAttr('onClick'); - $('#percentage_critical>em').removeClass('color_666'); - } - }); - - $('#radius-percentage_warning').change (function() { - paint_graph_values(); - if ($('#radius-percentage_warning').prop('checked') === true){ - $('#radius-warning_inverse').prop('checked', false); - $('#warning_inverse').attr('onClick', 'return false;'); - $('#warning_inverse>em').addClass('color_666'); - } else { - $('#warning_inverse').removeAttr('onClick'); - $('#warning_inverse>em').removeClass('color_666'); - } - }); - - $('#radius-percentage_critical').change (function() { - paint_graph_values(); - if ($('#radius-percentage_critical').prop('checked') === true){ - $('#radius-critical_inverse').prop('checked', false); - $('#critical_inverse').attr('onClick', 'return false;'); - $('#critical_inverse>em').addClass('color_666'); - } else { - $('#critical_inverse').removeAttr('onClick'); - $('#critical_inverse>em').removeClass('color_666'); - } - }); + if ($('#radius-normal_critical').prop('checked') === true) { + $('#radius-critical_inverse').show(); + $('#label-radius-critical_inverse').show(); + $('#radius-percentage_critical').show(); + $('#label-radius-percentage_critical').show(); + } }); @@ -2235,91 +2221,66 @@ function validate_post_process() { } } -//function paint graph +//function paint graph. function paint_graph_values(){ - //Parse integrer var min_w = parseFloat($('#text-min_warning').val()); - if(min_w == '0.00'){ min_w = 0; } - var max_w = parseFloat($('#text-max_warning').val()); - if(max_w == '0.00'){ max_w = 0; } - var min_c = parseFloat($('#text-min_critical').val()); - if(min_c =='0.00'){ min_c = 0; } - var max_c = parseFloat($('#text-max_critical').val()); - if(max_c =='0.00'){ max_c = 0; } - var inverse_w = $('input:radio[name=warning_inverse]:checked').val(); - if(!inverse_w){ inverse_w = 0; } - var inverse_c = $('input:radio[name=critical_inverse]:checked').val(); - if(!inverse_c){ inverse_c = 0; } + if(min_w == '0.00' || isNaN(min_w)){ min_w = 0; } - //inicialiced error + var max_w = parseFloat($('#text-max_warning').val()); + if(max_w == '0.00' || isNaN(max_w)){ max_w = 0; } + + var min_c = parseFloat($('#text-min_critical').val()); + if(min_c =='0.00' || isNaN(min_c)){ min_c = 0; } + + var max_c = parseFloat($('#text-max_critical').val()); + if(max_c =='0.00' || isNaN(max_c)){ max_c = 0; } + + var inverse_w = $('input:radio[value=warning_inverse]:checked').val(); + if(!inverse_w){ inverse_w = 0; } + + var inverse_c = $('input:radio[value=critical_inverse]:checked').val(); + if(!inverse_c){ inverse_c = 0; } + + //inicialiced error. var error_w = 0; var error_c = 0; - //messages legend + + //messages legend. var legend_normal = ''; var legend_warning = ''; var legend_critical = ''; - //messages error + + //messages error. var message_error_warning = ''; var message_error_critical = ''; var message_error_percentage = ''; - - - //Percentage selector - var percentage_w = $('#checkbox-percentage_warning').prop('checked'); - var percentage_c = $('#checkbox-percentage_critical').prop('checked'); - - if(percentage_w == true || percentage_c == true) { - d3.select("#svg_dinamic rect").remove(); - //create svg - var svg = d3.select("#svg_dinamic"); - svg.selectAll("g").remove(); - if (percentage_w === true) { - if(max_w < 0 || min_w < 0) { - paint_graph_status(0,0,0,0,0,0,1,0,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage); - } else { - $("#text-max_warning").removeClass("input_error"); - $("#text-min_warning").removeClass("input_error"); - } - - } - - if(percentage_c === true) { - if(max_c < 0 || min_c < 0) { - paint_graph_status(0,0,0,0,0,0,0,1,legend_normal,legend_warning,legend_critical,message_error_percentage,message_error_percentage); - } else { - $("#text-min-critical").removeClass("input_error"); - $("#text-max_critical").removeClass("input_error"); - - } - } - - return; - - } else { - $('#svg_dinamic').show(); - } //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); + 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 + ); } 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); + 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 + ); } } else { 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); + 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 + ); } } -/* End of relationship javascript */ /* ]]> */ From 423767a32a1c82e3193eb1b8c7ddc8dca597770f Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 14 Mar 2023 17:27:01 +0100 Subject: [PATCH 21/27] fixed styles --- .../godmode/agentes/module_manager_editor_common.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index b87d508546..0231245274 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1906,21 +1906,9 @@ $(document).ready (function () { }); $('.switch_radio_button label').on('click', function(){ - console.log('primero'); var thisLabel = $(this).attr('for'); - console.log(thisLabel); $('#'+thisLabel).prop('checked', true); $('#'+thisLabel).siblings().prop('checked', false); - - console.log('++++++++++Los warning++++++++++++++'); - console.log('normal_warning: '+$('#radius-normal_warning').prop('checked')); - console.log('warning_inverse: '+$('#radius-warning_inverse').prop('checked')); - console.log('percentage_warning: '+$('#radius-percentage_warning').prop('checked')); - - console.log('++++++++++Los critical++++++++++++++'); - console.log('normal_critical: '+$('#radius-normal_critical').prop('checked')); - console.log('critical_inverse: '+$('#radius-critical_inverse').prop('checked')); - console.log('percentage_critical: '+$('#radius-percentage_critical').prop('checked')); if ($('#radius-percentage_warning').prop('checked') === true || $('#radius-percentage_critical').prop('checked') === true) { $("#svg_dinamic").hide(); From f9fe35e0c391e19432221625b290dc570982a712 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Mar 2023 17:28:17 +0100 Subject: [PATCH 22/27] log viewer and sort reporting --- .../reporting_builder.list_items.php | 2 +- pandora_console/include/functions_ui.php | 19 +++++-------------- .../javascript/elasticsearch_queryResult.js | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 15f9e391c3..6b5dda8159 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -875,7 +875,7 @@ if (defined('METACONSOLE')) { ], true ); - $form .= html_print_input_hidden('action', 'filter', true); + $form .= html_print_input_hidden('action', 'sort_items', true); $form .= ''; ui_toggle($form, __('Sort items'), '', '', false); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 1c632d6f9e..e04246a4f2 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7073,20 +7073,6 @@ function ui_query_result_editor($name='default') true ); - $editorSubContainer .= html_print_div( - [ - 'class' => 'action-buttons edit-button', - 'content' => html_print_submit_button( - __('Execute query'), - 'execute_query', - false, - ['icon' => 'next'], - true - ), - ], - true - ); - $editorContainer = html_print_div( [ 'id' => $name.'_editor_container', @@ -7144,6 +7130,11 @@ function ui_query_result_editor($name='default') 'content' => ui_get_full_url(false, false, false, false), ] ); + + $buttons = html_print_submit_button(__('Execute query'), 'execute_query', false, ['icon' => 'update'], true); + html_print_action_buttons( + $buttons + ); } diff --git a/pandora_console/include/javascript/elasticsearch_queryResult.js b/pandora_console/include/javascript/elasticsearch_queryResult.js index 6a57e266bc..c50f8955b3 100644 --- a/pandora_console/include/javascript/elasticsearch_queryResult.js +++ b/pandora_console/include/javascript/elasticsearch_queryResult.js @@ -9,7 +9,7 @@ view.renderer.setShowGutter(false); view.setReadOnly(true); view.setShowPrintMargin(false); -$("#submit-execute_query").click(function() { +$("#button-execute_query").click(function() { view.setValue(""); let text; let selectText = editor.getSelectedText(); From 4f5d3ed924fd3c334168ed43cd123be5b60151b7 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 14 Mar 2023 18:15:31 +0100 Subject: [PATCH 23/27] Netflow meta --- pandora_console/godmode/netflow/nf_edit.php | 131 +++--- .../godmode/netflow/nf_edit_form.php | 385 +++++++++++------- .../operation/netflow/nf_live_view.php | 64 ++- 3 files changed, 328 insertions(+), 252 deletions(-) diff --git a/pandora_console/godmode/netflow/nf_edit.php b/pandora_console/godmode/netflow/nf_edit.php index b267b40254..1d2bdd48ad 100644 --- a/pandora_console/godmode/netflow/nf_edit.php +++ b/pandora_console/godmode/netflow/nf_edit.php @@ -1,16 +1,31 @@ 'index.php?sec=main', - 'text' => __('Main'), + 'link' => '', + 'label' => __('Netflow'), ], - [ - 'link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', - 'text' => __('Netflow filters'), - ], - ]; + ], +); - ui_meta_print_page_header($nav_bar); - - ui_meta_print_header(__('Netflow filters')); +$is_windows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +if ($is_windows === true) { + ui_print_error_message(__('Not supported in Windows systems')); } $delete = (bool) get_parameter('delete'); @@ -190,30 +195,37 @@ foreach ($filters as $filter) { if (check_acl_restricted_all($config['id_user'], $filter['id_group'], 'AW')) { $table->cellclass[][3] = 'table_action_buttons'; - $data[3] = "".html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'invert_filter']).''; + $data[3] = ''; + $data[3] .= html_print_image('images/delete.svg', true, ['title' => __('Delete'), 'class' => 'main_menu_icon invert_filter']); + $data[3] .= ''; } array_push($table->data, $data); } -if (isset($data)) { - echo "
"; +$buttons = html_print_submit_button( + __('Create filter'), + 'crt', + false, + ['icon' => 'wand'], + true +); + +// hd($filters); +if (empty($filters) === false) { + echo ''; html_print_input_hidden('multiple_delete', 1); html_print_table($table); - echo "
"; - - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo '
'; echo '
'; + $buttons .= html_print_submit_button(__('Delete'), 'delete_btn', false, ['icon' => 'delete', 'mode' => 'secondary', 'form' => 'multiple_delete'], true); } else { ui_print_info_message(['no_close' => true, 'message' => __('There are no defined filters') ]); } echo '
'; -echo "
"; -html_print_submit_button(__('Create filter'), 'crt', false, 'class="sub wand"'); -echo '
'; +html_print_action_buttons( + $buttons +); echo '
'; ?> @@ -221,27 +233,14 @@ echo ''; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 2164aeb562..f476c30bfe 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -125,48 +125,31 @@ $draw = get_parameter('draw_button', ''); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); -if (is_metaconsole() === false) { - // Header. - ui_print_standard_header( - __('Netflow live view'), - 'images/op_netflow.png', - false, - '', - false, - [], +// Header. +ui_print_standard_header( + __('Netflow live view'), + 'images/op_netflow.png', + false, + '', + false, + [], + [ [ - [ - 'link' => '', - 'label' => __('Monitoring'), - ], - [ - 'link' => '', - 'label' => __('Network'), - ], - ] - ); + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Network'), + ], + ] +); - $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; - if ($is_windows) { - ui_print_error_message(__('Not supported in Windows systems')); - } else { - netflow_print_check_version_error(); - } +$is_windows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); +if ($is_windows === true) { + ui_print_error_message(__('Not supported in Windows systems')); } else { - $nav_bar = [ - [ - 'link' => 'index.php?sec=main', - 'text' => __('Main'), - ], - [ - 'link' => 'index.php?sec=netf&sec2=operation/netflow/nf_live_view', - 'text' => __('Netflow live view'), - ], - ]; - - ui_meta_print_page_header($nav_bar); - - ui_meta_print_header(__('Netflow live view')); + netflow_print_check_version_error(); } // Save user defined filter. @@ -390,6 +373,7 @@ if (empty($filter['advanced_filter']) === false) { $filterTable = new stdClass(); $filterTable->id = ''; +$filterTable->width = '100%'; $filterTable->class = 'filter-table-adv'; $filterTable->size = []; $filterTable->size[0] = '33%'; From b082910ca6a936644dc30fb22a7de53835170b55 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 15 Mar 2023 01:00:57 +0100 Subject: [PATCH 24/27] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index ddd948ef0e..08a656c69f 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230314 +Version: 7.0NG.769-230315 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 3329802701..5218fc92cc 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.769-230314" +pandora_version="7.0NG.769-230315" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 75a25abaea..07f62b6c54 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1023,7 +1023,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.769'; -use constant AGENT_BUILD => '230314'; +use constant AGENT_BUILD => '230315'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 8a89129bc5..e41ed8c290 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 5247de551a..ca32dc789f 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 7fc777070e..8107c738db 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230314" +PI_BUILD="230315" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index a95f663722..86c9cf1820 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230314} +{230315} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3413fd206b..6120e75fe4 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.769 Build 230314") +#define PANDORA_VERSION ("7.0NG.769 Build 230315") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ae3086b8c7..cc42f22709 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.769(Build 230314))" + VALUE "ProductVersion", "(7.0NG.769(Build 230315))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bd28cdb7c9..aa3dd4d6cc 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230314 +Version: 7.0NG.769-230315 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index def9fd150e..d51774a6b6 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.769-230314" +pandora_version="7.0NG.769-230315" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index ba4f96b678..3dc77d2a00 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC230314'; +$build_version = 'PC230315'; $pandora_version = 'v7.0NG.769'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 9b1d6590fa..35c0c798f3 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -131,7 +131,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 7509a39e71..36a3b52e2c 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 3bf0b70e97..8b81d27a4f 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.769 -%define release 230314 +%define release 230315 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index b71463cb86..400c64cc20 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230314" +PI_BUILD="230315" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index a26d4711b7..767b7ce8ea 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.769 Build 230314"; +my $version = "7.0NG.769 Build 230315"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index e48c36a8ac..feae35ab6b 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.769 Build 230314"; +my $version = "7.0NG.769 Build 230315"; # save program name for logging my $progname = basename($0); From bab3248d57dc7dfe09310ae0a03e4e4e5fb9d82c Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Wed, 15 Mar 2023 08:56:15 +0100 Subject: [PATCH 25/27] Monitor view with not normal at start --- .../operation/agentes/status_monitor.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index b1aff8bc72..6b25fd3ec2 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -152,6 +152,13 @@ if ($ag_freestring !== '' || $moduletype !== '' || $datatype !== '' $autosearch = true; } +// The execution has not been done manually. +$userRequest = (bool) get_parameter('uptbutton'); +if ($userRequest === false) { + $autosearch = true; + $status = AGENT_MODULE_STATUS_NOT_NORMAL; +} + if (is_metaconsole() === false) { $ag_group = (int) get_parameter('ag_group', 0); } else { @@ -2270,11 +2277,7 @@ if (empty($result) === false) { $tablePagination = ui_pagination($count_modules, false, $offset, 0, true, 'offset', false); } } else { - if ($first_interaction) { - ui_print_info_message(['no_close' => true, 'message' => __('This group doesn\'t have any monitor')]); - } else { - ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); - } + ui_print_info_message(['no_close' => true, 'message' => __('Sorry no search parameters')]); } if (is_metaconsole() !== true) { From 8a7b60e983411e9ffe590bceeafc9eb1a328ccda Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 15 Mar 2023 09:58:56 +0100 Subject: [PATCH 26/27] PDF changes visual --- .../reporting/reporting_builder.main.php | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.main.php b/pandora_console/godmode/reporting/reporting_builder.main.php index 702a4e670b..44199148b6 100755 --- a/pandora_console/godmode/reporting/reporting_builder.main.php +++ b/pandora_console/godmode/reporting/reporting_builder.main.php @@ -176,6 +176,31 @@ if (is_metaconsole() === true) { ); } +if (is_metaconsole() === true) { + $table->data['description'][0] = __('Description'); + $table->data['description'][1] = html_print_textarea( + 'description', + 2, + 80, + $description, + '', + true + ); +} else { + $table->colspan[1][0] = 2; + $table->data[1][0] = html_print_label_input_block( + __('Description'), + html_print_textarea( + 'description', + 2, + 1, + $description, + '', + true + ) + ); +} + if ($report_id_user == $config['id_user'] || is_user_admin($config['id_user']) ) { @@ -222,7 +247,7 @@ if ($report_id_user == $config['id_user'] $table->data['access'][1] .= '
'; $table->data['access'][1] .= ''; } else { - $table->data[1][0] = html_print_label_input_block( + $table->data[2][0] = html_print_label_input_block( __('Write Access').ui_print_help_tip( __('For example, you want a report that the people of "All" groups can see but you want to edit only for you or your group.'), true @@ -244,7 +269,7 @@ if ($report_id_user == $config['id_user'] $options['div_class'] = ''; } - $table->data[1][1] = html_print_label_input_block( + $table->data[2][1] = html_print_label_input_block( __('Group'), html_print_select_groups( false, @@ -277,7 +302,7 @@ if ($enterpriseEnable) { true ); } else { - $table->data[2][0] = html_print_label_input_block( + $table->data[2][1] = html_print_label_input_block( __('Non interactive report'), html_print_checkbox_switch( 'non_interactive', @@ -289,29 +314,6 @@ if ($enterpriseEnable) { } } -if (is_metaconsole() === true) { - $table->data['description'][0] = __('Description'); - $table->data['description'][1] = html_print_textarea( - 'description', - 2, - 80, - $description, - '', - true - ); -} else { - $table->data[2][1] = html_print_label_input_block( - __('Description'), - html_print_textarea( - 'description', - 2, - 1, - $description, - '', - true - ) - ); -} if (enterprise_installed() === true) { if (is_metaconsole() === true) { From 6ac41ed907c1de71532816f1480eb8f20145193c Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Wed, 15 Mar 2023 11:15:04 +0100 Subject: [PATCH 27/27] Icon added --- pandora_console/images/world@svg.svg | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pandora_console/images/world@svg.svg diff --git a/pandora_console/images/world@svg.svg b/pandora_console/images/world@svg.svg new file mode 100644 index 0000000000..c71297eda4 --- /dev/null +++ b/pandora_console/images/world@svg.svg @@ -0,0 +1,9 @@ + + + + Dark / 20 / web@svg + Created with Sketch. + + + + \ No newline at end of file