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/108] #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/108] #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 aead8d006e84f01f30607e32d7d4f7f5ea90631e Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 29 Aug 2023 14:11:32 +0200 Subject: [PATCH 003/108] #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 6323102631c4f6903a1bbcbdfa28c8a888646d30 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 4 Sep 2023 08:30:14 +0200 Subject: [PATCH 004/108] #11652 Fixed fc-calendar size --- pandora_console/godmode/alerts/alert_view.php | 2 +- pandora_console/include/styles/pandora.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 8d4d07e578..7809742221 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -256,7 +256,7 @@ $schedule = io_safe_output( $data[0] = ''; $data[0] .= html_print_input_hidden('schedule', $schedule, true); -$data[0] .= '
'; +$data[0] .= '
'; $data[1] = ''; $table_conditions->data[] = $data; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index abbb50c927..3a6a4d9ba9 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12562,3 +12562,7 @@ tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { flex-wrap: nowrap; justify-content: flex-start !important; } + +.alert_view_calendar > .fc-view-harness > .fc-view > .fc-scrollgrid { + width: auto !important; +} From d8e0df19122f2b12f84029e09beab960066ab40f Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 6 Sep 2023 08:52:46 +0200 Subject: [PATCH 005/108] #10983 new function for get date parameter and added parent date in dashboard --- pandora_console/extras/mr/66.sql | 5 ++ pandora_console/include/functions.php | 64 +++++++++++++++++++ pandora_console/include/functions_html.php | 14 ++++ .../include/lib/Dashboard/Manager.php | 11 ++++ .../include/lib/Dashboard/Widget.php | 51 +++++++++++++++ .../lib/Dashboard/Widgets/BlockHistogram.php | 3 + .../lib/Dashboard/Widgets/single_graph.php | 4 ++ pandora_console/pandoradb.sql | 3 + .../views/dashboard/formDashboard.php | 39 +++++++++++ 9 files changed, 194 insertions(+) diff --git a/pandora_console/extras/mr/66.sql b/pandora_console/extras/mr/66.sql index 8161c4c2b6..a30bcb4565 100644 --- a/pandora_console/extras/mr/66.sql +++ b/pandora_console/extras/mr/66.sql @@ -44,4 +44,9 @@ ADD COLUMN `time_init` VARCHAR(45) NULL AFTER `date_init`, ADD COLUMN `date_end` VARCHAR(45) NULL AFTER `time_init`, ADD COLUMN `time_end` VARCHAR(45) NULL AFTER `date_end`; +ALTER TABLE `tdashboard` +ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`, +ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`, +ADD COLUMN `date_to` INT NOT NULL DEFAULT 0 AFTER `date_from`; + COMMIT; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 0895325ef5..0a166a28d2 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -990,6 +990,70 @@ function get_parameter($name, $default='') } +function get_parameter_date($name, $default='', $date_format='Y/m/d') +{ + $date_end = get_parameter('date_end', 0); + $time_end = get_parameter('time_end'); + $datetime_end = strtotime($date_end.' '.$time_end); + + $custom_date = get_parameter('custom_date', 0); + $range = get_parameter('range', SECONDS_1DAY); + $date_text = get_parameter('range_text', SECONDS_1DAY); + $date_init_less = (strtotime(date('Y/m/d')) - SECONDS_1DAY); + $date_init = get_parameter('date_init', date(DATE_FORMAT, $date_init_less)); + $time_init = get_parameter('time_init', date(TIME_FORMAT, $date_init_less)); + $datetime_init = strtotime($date_init.' '.$time_init); + if ($custom_date === '1') { + if ($datetime_init >= $datetime_end) { + $datetime_init = $date_init_less; + } + + $date_init = date('Y/m/d H:i:s', $datetime_init); + $date_end = date('Y/m/d H:i:s', $datetime_end); + $period = ($datetime_end - $datetime_init); + } else if ($custom_date === '2') { + $date_units = get_parameter('range_units'); + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - ((int) $date_text * (int) $date_units))); + $period = (strtotime($date_end) - strtotime($date_init)); + } else if (in_array($range, ['this_week', 'this_month', 'past_week', 'past_month'])) { + if ($range === 'this_week') { + $monday = date('Y/m/d', strtotime('last monday')); + + $sunday = date('Y/m/d', strtotime($monday.' +6 days')); + $period = (strtotime($sunday) - strtotime($monday)); + $date_init = $monday; + $date_end = $sunday; + } else if ($range === 'this_month') { + $date_end = date('Y/m/d', strtotime('last day of this month')); + $first_of_month = date('Y/m/d', strtotime('first day of this month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_month') { + $date_end = date('Y/m/d', strtotime('last day of previous month')); + $first_of_month = date('Y/m/d', strtotime('first day of previous month')); + $date_init = $first_of_month; + $period = (strtotime($date_end) - strtotime($first_of_month)); + } else if ($range === 'past_week') { + $date_end = date('Y/m/d', strtotime('sunday', strtotime('last week'))); + $first_of_week = date('Y/m/d', strtotime('monday', strtotime('last week'))); + $date_init = $first_of_week; + $period = (strtotime($date_end) - strtotime($first_of_week)); + } + } else { + $date_end = date('Y/m/d H:i:s'); + $date_init = date('Y/m/d H:i:s', (strtotime($date_end) - $range)); + $period = (strtotime($date_end) - strtotime($date_init)); + } + + return [ + 'date_init' => date($date_format, strtotime($date_init)), + 'date_end' => date($date_format, strtotime($date_end)), + 'period' => $period, + ]; +} + + /** * Get a parameter from a get request. * diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 3d8eb231b9..1f33023bf9 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -6280,6 +6280,20 @@ function html_print_input($data, $wrapper='div', $input_only=false) ); break; + case 'date_range': + $output .= html_print_select_date_range( + $data['name'], + true, + (isset($data['selected']) === true) ? $data['selected'] : SECONDS_1DAY, + (isset($data['date_init']) === true) ? $data['date_init'] : '', + (isset($data['time_init']) === true) ? $data['time_init'] : '', + (isset($data['date_end']) === true) ? $data['date_end'] : '', + (isset($data['time_end']) === true) ? $data['time_end'] : '', + (isset($data['date_text']) === true) ? $data['date_text'] : SECONDS_1DAY, + (isset($data['class']) === true) ? $data['class'] : 'w100p', + ); + break; + default: // Ignore. break; diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 40b6d2d1a0..10ab96986c 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -458,6 +458,12 @@ class Manager implements PublicLogin $this->publicLink ); + if ((bool) $this->dashboardFields['date_range'] === true) { + $dateFrom = $this->dashboardFields['date_from']; + $dateTo = $this->dashboardFields['date_to']; + $instance->setDateRange($dateFrom, $dateTo); + } + return $instance; } @@ -1015,6 +1021,8 @@ class Manager implements PublicLogin $id_group = \get_parameter('id_group'); $slideshow = \get_parameter_switch('slideshow'); $favourite = \get_parameter_switch('favourite'); + $dateRange = \get_parameter_switch('date_range'); + $dateData = \get_parameter_date('range', '', 'U'); $id_user = (empty($private) === false) ? $config['id_user'] : ''; @@ -1024,6 +1032,9 @@ class Manager implements PublicLogin 'id_group' => $id_group, 'cells_slideshow' => $slideshow, 'active' => $favourite, + 'date_range' => $dateRange, + 'date_from' => $dateData['date_init'], + 'date_to' => $dateData['date_end'], ]; if ($this->dashboardId === 0) { diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index b9364fcd31..acd9f4c94f 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -51,6 +51,20 @@ class Widget */ private $showSelectNodeMeta; + /** + * Date from init for filter widget. + * + * @var integer + */ + private $dateFrom; + + /** + * Date from end for filter widget. + * + * @var integer + */ + private $dateTo; + /** * Contructor widget. @@ -804,4 +818,41 @@ class Widget } + /** + * Set the date range of parent configuration. + * + * @param integer $dateFrom Date from init for filter widget. + * @param integer $dateTo Date from end for filter widget. + * + * @return void + */ + public function setDateRange(int $dateFrom, int $dateTo) + { + $this->dateFrom = $dateFrom; + $this->dateTo = $dateTo; + } + + + public function getDateFrom() + { + return $this->dateFrom; + } + + + public function getDateTo() + { + return $this->dateTo; + } + + + public function getPeriod():mixed + { + if (empty($this->dateFrom) === false && empty($this->dateTo) === false) { + return ($this->dateTo - $this->dateFrom); + } else { + return null; + } + } + + } diff --git a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php index a3ff215c76..1484823518 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/BlockHistogram.php @@ -520,6 +520,9 @@ class BlockHistogram extends Widget global $config; $size = parent::getSize(); + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } // Desactive scroll bars only this item. $id_agent = $data['agent_id']; diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index 72ad55309b..013faf1e67 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -399,6 +399,10 @@ class SingleGraphWidget extends Widget $module_name = \modules_get_agentmodule_name($this->values['moduleId']); $units_name = \modules_get_unit($this->values['moduleId']); + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + $trickHight = 0; if ($this->values['showLegend'] === 1) { // Needed for legend. diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b50a5ba149..a92eb3b2c5 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2665,6 +2665,9 @@ CREATE TABLE IF NOT EXISTS `tdashboard` ( `active` TINYINT NOT NULL DEFAULT 0, `cells` INT UNSIGNED DEFAULT 0, `cells_slideshow` TINYINT NOT NULL DEFAULT 0, + `date_range` TINYINT NOT NULL DEFAULT 0, + `date_from` INT NOT NULL DEFAULT 0, + `date_to` INT NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; diff --git a/pandora_console/views/dashboard/formDashboard.php b/pandora_console/views/dashboard/formDashboard.php index c36df6cf06..fafacd583d 100644 --- a/pandora_console/views/dashboard/formDashboard.php +++ b/pandora_console/views/dashboard/formDashboard.php @@ -102,6 +102,31 @@ $inputs = [ ], ], ], + [ + 'label' => __('Date range'), + 'arguments' => [ + 'name' => 'date_range', + 'id' => 'date_range', + 'type' => 'switch', + 'value' => $arrayDashboard['date_range'], + 'onchange' => 'handle_date_range(this)', + ], + ], + [ + 'label' => __('Select range'), + 'style' => 'display: none;', + 'class' => 'row_date_range', + 'arguments' => [ + 'name' => 'range', + 'id' => 'range', + 'selected' => ($arrayDashboard['date_to'] - $arrayDashboard['date_from']), + 'type' => 'date_range', + 'date_init' => $arrayDashboard['date_from'], + 'time_init' => $arrayDashboard['date_from'], + 'date_end' => $arrayDashboard['date_to'], + 'time_end' => $arrayDashboard['date_to'], + ], + ], [ 'block_id' => 'private', 'direct' => 1, @@ -135,3 +160,17 @@ HTML::printForm( 'inputs' => $inputs, ] ); + +?> + + \ No newline at end of file From d48cd703bc28fb050d5d747622f0373cda493b01 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 7 Sep 2023 10:25:09 +0200 Subject: [PATCH 006/108] 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 c3184cecd161b26164e059dce5a9f92a0bde6fcd Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 11 Sep 2023 11:38:25 +0200 Subject: [PATCH 007/108] #11832 Fixed domain name change in pandoradb_data.sql file --- pandora_console/pandoradb_data.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1962582965..b47990b6ff 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1183,7 +1183,7 @@ INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALU INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALUES (2, 'Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); -- IPAM is 3. -INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALUES (4, 'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); +INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALUES (4, 'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@pandorafms.com> Usage: ./ipmi-recon.pl <task_id> <group_id> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); INSERT INTO `trecon_script` (`type`,`name`,`description`,`script`,`macros`) VALUES (3, 'IPAM Recon', 'This script is used to automatically detect network hosts availability and name, used as Recon Custom Script in the recon task. Parameters used are:\n\n* custom_field1 = network. i.e.: 192.168.100.0/24\n* custom_field2 = associated IPAM network id. i.e.: 4. Please do not change this value, it is assigned automatically in IPAM management.\n\nSee documentation for more information.', '/usr/share/pandora_server/util/recon_scripts/IPAMrecon.pl', '{"1":{"macro":"_field1_","desc":"Network","help":"i.e.: 192.168.100.0/24","value":"","hide":""}}'); @@ -1203,7 +1203,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries` INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,'',0),(2,'Department',0,0,'',0),(3,'Additional ID',0,0,'',0),(4,'eHorusID',0,0,'',0); -INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','',''); +INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://pandorafms.com','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','',''); INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90,0),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90,0),(5,'Restart agent','Restart the agent with using UDP protocol. To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90,0),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90,0); From d94670c34d1f6b43c420c81a07ffe86df6d3477c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 19 Sep 2023 10:47:49 +0200 Subject: [PATCH 008/108] #12052 Fix secondary groups --- pandora_console/include/functions_alerts.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 8d51a3b536..16cb31c63c 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2116,6 +2116,11 @@ function get_group_alerts( $group_query = ''; if (!empty($idGroup)) { $group_query = ' AND id_grupo = '.$idGroup; + + $has_secondary = enterprise_hook('agents_is_using_secondary_groups'); + if ((bool) $has_secondary === true) { + $group_query .= ' OR tasg.id_group = '.$idGroup; + } } if (is_array($filter)) { From d83c1a81d23ed15c80b8f93526b88a96516bbef4 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 19 Sep 2023 13:50:06 +0200 Subject: [PATCH 009/108] #12052 Fix filter alter detail view --- .../include/ajax/alert_list.ajax.php | 10 +++---- pandora_console/include/functions_alerts.php | 8 +++--- .../agentes/alerts_status.functions.php | 26 +++++++++++++++---- .../operation/agentes/alerts_status.php | 10 ++++++- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index d742f952e8..fd00f2eaee 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -435,6 +435,7 @@ if ($get_agent_alerts_datatable === true) { } $idGroup = $filter_alert['ag_group']; + $search_sg = $filter_alert['search_sg']; $tag_filter = $filter_alert['tag']; $action_filter = $filter_alert['action']; @@ -658,10 +659,9 @@ if ($get_agent_alerts_datatable === true) { $id_groups = array_keys( users_get_groups($config['id_user'], 'AR', false) ); + $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, $search_sg); - $alerts['alerts_simple'] = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); - - $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); + $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, $search_sg); } } else { if ($idAgent !== 0) { @@ -673,9 +673,9 @@ if ($get_agent_alerts_datatable === true) { users_get_groups($config['id_user'], $access, false) ); - $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false); + $alerts['alerts_simple'] = get_group_alerts($id_groups, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter, false, $search_sg); - $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false); + $countAlertsSimple = get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter, false, $search_sg); } } diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 16cb31c63c..656138a20a 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2109,16 +2109,14 @@ function get_group_alerts( $strict_user=false, $tag=false, $action_filter=false, - $alert_action=true + $alert_action=true, + $search_sg=false ) { global $config; - $group_query = ''; if (!empty($idGroup)) { $group_query = ' AND id_grupo = '.$idGroup; - - $has_secondary = enterprise_hook('agents_is_using_secondary_groups'); - if ((bool) $has_secondary === true) { + if ((bool) $search_sg === true) { $group_query .= ' OR tasg.id_group = '.$idGroup; } } diff --git a/pandora_console/operation/agentes/alerts_status.functions.php b/pandora_console/operation/agentes/alerts_status.functions.php index 2e54b2f941..25e8b73472 100755 --- a/pandora_console/operation/agentes/alerts_status.functions.php +++ b/pandora_console/operation/agentes/alerts_status.functions.php @@ -56,8 +56,19 @@ function validateAlert($ids) } -function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_standby=false, $tag_filter=false, $action_filter=false, $return=false, $strict_user=false, $access='AR') -{ +function printFormFilterAlert( + $id_group, + $filter, + $free_search, + $url, + $filter_standby=false, + $tag_filter=false, + $action_filter=false, + $return=false, + $strict_user=false, + $access='AR', + $search_sg=0 +) { global $config; include_once $config['homedir'].'/include/functions_tags.php'; @@ -147,7 +158,12 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st $callbackTag ); - $table->data[1][0] = html_print_label_input_block( + $table->data[3][0] = html_print_label_input_block( + __('Also search in secondary groups'), + html_print_checkbox_switch_extended('search_sg', 0, 0, false, '', '', true) + ); + + $table->data[2][0] = html_print_label_input_block( __('Free text for search').ui_print_help_tip( __('Filter by agent name, module name, template name or action name'), true @@ -155,7 +171,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st html_print_input_text('free_search', $free_search, '', 20, 40, true) ); - $table->data[1][1] = html_print_label_input_block( + $table->data[2][1] = html_print_label_input_block( __('Standby'), html_print_select( $alert_standby, @@ -174,7 +190,7 @@ function printFormFilterAlert($id_group, $filter, $free_search, $url, $filter_st ); $alert_action = alerts_get_alert_actions_filter(); - $table->data[1][2] = html_print_label_input_block( + $table->data[2][2] = html_print_label_input_block( __('Action'), html_print_select( $alert_action, diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 176ac6bce8..19f7494779 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -58,7 +58,7 @@ $filter_standby = get_parameter('standby', 'all'); $id_group = (int) get_parameter('ag_group', 0); // 0 is the All group (selects all groups) $free_search = get_parameter('free_search', ''); - +$search_sg = get_parameter('search_sg', 0); $user_tag_array = tags_get_user_tags($config['id_user'], 'AR', true); if ($user_tag_array) { @@ -557,6 +557,14 @@ $(document).ready ( function () { }); }); +$('#checkbox-search_sg').click(function(){ + if ($('#checkbox-search_sg').val() == 0) { + $('#checkbox-search_sg').val(1); + }else { + $('#checkbox-search_sg').val(0); + } +}); + $('table.alert-status-filter #ag_group').change (function () { var strict_user = $("#text-strict_user_hidden").val(); var is_meta = $("#text-is_meta_hidden").val(); From 458e5ffd21daef4a6c5f7061c8186da53ef86f4e Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 20 Sep 2023 13:47:28 +0200 Subject: [PATCH 010/108] #12078 Add hide grid --- pandora_console/include/graphs/fgraph.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index fd5258e2c2..ddb9050b15 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -988,6 +988,13 @@ function get_build_setup_charts($type, $options, $data) } } + // Set display grid true or false. + if (isset($options['grid']) === true) { + $scales = $chart->options()->getScales(); + $scales->getX()->grid()->setDrawOnChartArea($options['grid']); + $scales->getY()->grid()->setDrawOnChartArea($options['grid']); + } + // Radius is null maximum possible. if (isset($options['radius']) === true && empty($options['radius']) === false From cce958e3484b15e9115395d40d85f4b88ef38fd3 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Thu, 21 Sep 2023 15:53:14 +0200 Subject: [PATCH 011/108] #11074 The warning message is adjusted on the plugin page. --- pandora_console/godmode/servers/plugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 315702528e..39acc45c21 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -860,8 +860,10 @@ if (empty($create) === false || empty($view) === false) { if ($management_allowed === false) { ui_print_warning_message( __( - 'This console is not manager of this environment, - please manage this feature from centralized manager console (Metaconsole).' + 'This console is not manager of this environment, please manage this feature from feature from %s.', + ''.__('metaconsole').'' ) ); } From 79fe89c3c54059094f1b5c1d069f09ca4cdd9648 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 22 Sep 2023 12:24:15 +0200 Subject: [PATCH 012/108] #11705 new custom_field tevento --- pandora_console/extras/mr/67.sql | 6 ++ .../godmode/events/custom_events.php | 1 + pandora_console/include/ajax/events.php | 48 ++++++++++++ pandora_console/include/functions_api.php | 42 +++++++++++ pandora_console/include/functions_events.php | 74 +++++++++++++++++++ .../include/javascript/pandora_events.js | 31 ++++++++ .../lib/Dashboard/Widgets/events_list.php | 1 + pandora_console/operation/events/events.php | 1 + pandora_console/pandoradb.sql | 1 + 9 files changed, 205 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..92db1c919c --- /dev/null +++ b/pandora_console/extras/mr/67.sql @@ -0,0 +1,6 @@ +START TRANSACTION; + +ALTER TABLE `tevento` +ADD COLUMN `custom_field` TEXT NULL AFTER `module_status`; + +COMMIT; diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index c91a2df8fe..bfa6dce937 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -115,6 +115,7 @@ $fields_available['module_status'] = __('Module Status'); $fields_available['mini_severity'] = __('Severity mini'); $fields_available['module_custom_id'] = __('Module custom ID'); $fields_available['custom_data'] = __('Custom data'); +$fields_available['custom_field'] = __('Custom field'); // Remove fields already selected. diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index f9bf50b7ae..517777aacc 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -92,6 +92,7 @@ $get_id_source_event = get_parameter('get_id_source_event'); $node_id = (int) get_parameter('node_id', 0); $settings_modal = get_parameter('settings', 0); $parameters_modal = get_parameter('parameters', 0); +$update_custom_field = get_parameter('update_custom_field', 0); // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); @@ -2759,3 +2760,50 @@ if ($draw_row_response_info === true) { echo $output; return; } + +if ($update_custom_field) { + $custom_field = get_parameter('custom_field_value'); + $event_id = get_parameter('event_id'); + $server_id = 0; + if (is_metaconsole() === true) { + $server_id = (int) get_parameter('server_id'); + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($custom_field))) { + $return = false; + } else { + try { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node = new Node($server_id); + $node->connect(); + } + + $return = events_custom_field( + $event_id, + $custom_field + ); + } catch (\Exception $e) { + // Unexistent agent. + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + + $return = false; + } finally { + if (is_metaconsole() === true + && $server_id > 0 + ) { + $node->disconnect(); + } + } + } + + echo ($return === true) ? 'update_ok' : 'update_error'; + + return; +} \ No newline at end of file diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7e22befbee..dc6bdeb30f 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -17783,3 +17783,45 @@ function api_token_check(string $token) return db_get_value('id_user', 'tusuario', 'api_token', $token); } } + + +/** + * Set custom field value in tevento + * + * @param mixed $id_event Event id. + * @param mixed $custom_field Custom field to set. + * @return void + */ +function api_set_event_custom_field($id, $value) +{ + // Get the event + $event = events_get_event($id, false, is_metaconsole()); + // If event not exists, end the execution. + if ($event === false) { + returnError( + 'event_not_exists', + 'Event not exists' + ); + $result = false; + } + + // Safe custom fields for hacks. + if (preg_match('/script/i', io_safe_output($value))) { + $result = false; + } + + $result = events_custom_field( + $id, + $value + ); + + // If update results failed + if (empty($result) === true || $result === false) { + returnError( + 'The event could not be updated' + ); + return false; + } else { + returnData('string', ['data' => 'Event updated.']); + } +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 7068d554e6..c40a1eb9c7 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -219,6 +219,7 @@ function events_get_all_fields() $columns['module_status'] = __('Module status'); $columns['module_custom_id'] = __('Module custom id'); $columns['custom_data'] = __('Custom data'); + $columns['custom_field'] = __('Custom field'); return $columns; } @@ -322,6 +323,9 @@ function events_get_column_name($field, $table_alias=false) case 'custom_data': return __('Custom data'); + case 'custom_field': + return __('Custom field'); + default: return __($field); } @@ -4632,6 +4636,22 @@ function events_page_details($event, $server_id=0) $table_details->data[] = $data; + $data = []; + $data[0] = __('Custom Field'); + $data[1] = '
'.html_print_input_text('custom_field', $event['custom_field'], '', false, 255, true, false, false, '', 'w60p'); + $data[1] .= html_print_button( + __('Update'), + 'update_custom_field', + false, + 'update_custom_field('.$event['id_evento'].', '.$event['server_id'].');', + [ + 'icon' => 'next', + 'mode' => 'link', + ], + true + ).'
'; + $table_details->data[] = $data; + $details = '
'.html_print_table($table_details, true).'
'; if (is_metaconsole() === true && empty($server_id) === false) { @@ -6203,3 +6223,57 @@ function event_get_counter_extraId(array $event, ?array $filters) return $counters; } + + +/** + * Update event detail custom field + * + * @param mixed $id_event Event ID or array of events. + * @param string $custom_field Custom_field to be update. + * + * @return boolean Whether or not it was successful + */ +function events_custom_field( + $id_event, + $custom_field, +) { + global $config; + // Cleans up the selection for all unwanted values also casts any single + // values as an array. + $id_event = (array) safe_int($id_event, 1); + // Check ACL. + foreach ($id_event as $k => $id) { + $event_group = events_get_group($id); + if (check_acl($config['id_user'], $event_group, 'EW') == 0) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Attempted updating event #'.$id + ); + + unset($id_event[$k]); + } + } + + if (empty($id_event) === true) { + return false; + } + + // Get the current event comments. + $first_event = $id_event; + if (is_array($id_event) === true) { + $first_event = reset($id_event); + } + + // Update comment. + $ret = db_process_sql_update( + 'tevento', + ['custom_field' => $custom_field], + ['id_evento' => $first_event] + ); + + if (($ret === false) || ($ret === 0)) { + return false; + } + + return true; +} diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 940fd3ce5d..ce782769cb 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -492,6 +492,37 @@ function event_comment(current_event) { return false; } +// Save custom_field into an event. +function update_custom_field(event_id, server_id) { + var custom_field_value = $("#text-custom_field").val(); + + var params = { + page: "include/ajax/events", + update_custom_field: 1, + custom_field_value: custom_field_value, + event_id: event_id, + server_id: server_id + }; + + $("#button-update_custom_field").attr("disabled", "disabled"); + $("#response_loading").show(); + + jQuery.ajax({ + data: params, + type: "POST", + url: getUrlAjax(), + dataType: "html", + success: function(data) { + if (data === "update_error") { + alert("Custom field not valid"); + } + $("#button-update_custom_field").removeAttr("disabled"); + $("#response_loading").hide(); + $("#button-events_form_search_bt").trigger("click"); + } + }); +} + var processed = 0; function update_event(table, id_evento, type, event_rep, row, server_id) { var inputs = $("#events_form :input"); diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index b7ad581dc0..b84f11aa4a 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -837,6 +837,7 @@ class EventsListWidget extends Widget 'mini_severity' => __('Severity mini'), 'module_custom_id' => __('Module custom ID'), 'custom_data' => __('Custom data'), + 'custom_field' => __('Custom field'), ]; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 059c8f90ec..bde20209a4 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -377,6 +377,7 @@ if (is_ajax() === true) { 'te.owner_user', 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp', 'te.custom_data', + 'te.custom_field', 'te.data', 'te.module_status', 'ta.alias as agent_name', diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 662beb93af..030ef3a76f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -723,6 +723,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `custom_data` TEXT, `data` TINYTEXT, `module_status` INT NOT NULL DEFAULT 0, + `custom_field` TEXT, PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), From 01bf91f21380dedb58d773caf8c698614e47e511 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Fri, 22 Sep 2023 13:13:06 +0200 Subject: [PATCH 013/108] #11127 Added token Number of modules in queue --- pandora_console/godmode/setup/setup_general.php | 10 ++++++++++ pandora_console/include/functions_config.php | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..22737da3d7 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -766,6 +766,16 @@ $table->data[$i][] = html_print_label_input_block( true ) ); +$table->data[$i++][] = html_print_label_input_block( + __('Number of modules in queue'), + html_print_input_number( + [ + 'name' => 'number_modules_queue', + 'min' => 0, + 'value' => $config['number_modules_queue'], + ] + ) +); echo '
'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 393c6a2610..55b50997aa 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -382,6 +382,10 @@ function config_update_config() $error_update[] = __('show_experimental_features'); } + if (config_update_value('number_modules_queue', get_parameter('number_modules_queue'), true) === false) { + $error_update[] = __('number_modules_queue'); + } + if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) { $error_update[] = __('Console log enabled'); } @@ -2440,6 +2444,10 @@ function config_process_config() config_update_value('show_experimental_features', 0); } + if (!isset($config['number_modules_queue'])) { + config_update_value('number_modules_queue', 500); + } + if (!isset($config['console_log_enabled'])) { config_update_value('console_log_enabled', 0); } From e5c5f91576801803f0c743e3f3233b71b8708375 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 25 Sep 2023 10:32:23 +0200 Subject: [PATCH 014/108] #11705 change name event_custom_id --- pandora_console/extras/mr/67.sql | 2 +- .../godmode/events/custom_events.php | 2 +- pandora_console/include/ajax/events.php | 12 +++++----- pandora_console/include/functions_api.php | 4 ++-- pandora_console/include/functions_events.php | 24 +++++++++---------- .../include/javascript/pandora_events.js | 10 ++++---- .../lib/Dashboard/Widgets/events_list.php | 2 +- pandora_console/operation/events/events.php | 2 +- pandora_console/pandoradb.sql | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pandora_console/extras/mr/67.sql b/pandora_console/extras/mr/67.sql index 92db1c919c..7e598f9bd9 100644 --- a/pandora_console/extras/mr/67.sql +++ b/pandora_console/extras/mr/67.sql @@ -1,6 +1,6 @@ START TRANSACTION; ALTER TABLE `tevento` -ADD COLUMN `custom_field` TEXT NULL AFTER `module_status`; +ADD COLUMN `event_custom_id` TEXT NULL AFTER `module_status`; COMMIT; diff --git a/pandora_console/godmode/events/custom_events.php b/pandora_console/godmode/events/custom_events.php index bfa6dce937..4ab84fa76b 100644 --- a/pandora_console/godmode/events/custom_events.php +++ b/pandora_console/godmode/events/custom_events.php @@ -115,7 +115,7 @@ $fields_available['module_status'] = __('Module Status'); $fields_available['mini_severity'] = __('Severity mini'); $fields_available['module_custom_id'] = __('Module custom ID'); $fields_available['custom_data'] = __('Custom data'); -$fields_available['custom_field'] = __('Custom field'); +$fields_available['event_custom_id'] = __('Event Custom ID'); // Remove fields already selected. diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 517777aacc..0a1d32825f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -92,7 +92,7 @@ $get_id_source_event = get_parameter('get_id_source_event'); $node_id = (int) get_parameter('node_id', 0); $settings_modal = get_parameter('settings', 0); $parameters_modal = get_parameter('parameters', 0); -$update_custom_field = get_parameter('update_custom_field', 0); +$update_event_custom_id = get_parameter('update_event_custom_id', 0); // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); @@ -2761,8 +2761,8 @@ if ($draw_row_response_info === true) { return; } -if ($update_custom_field) { - $custom_field = get_parameter('custom_field_value'); +if ($update_event_custom_id) { + $event_custom_id = get_parameter('event_custom_id'); $event_id = get_parameter('event_id'); $server_id = 0; if (is_metaconsole() === true) { @@ -2770,7 +2770,7 @@ if ($update_custom_field) { } // Safe custom fields for hacks. - if (preg_match('/script/i', io_safe_output($custom_field))) { + if (preg_match('/script/i', io_safe_output($event_custom_id))) { $return = false; } else { try { @@ -2781,9 +2781,9 @@ if ($update_custom_field) { $node->connect(); } - $return = events_custom_field( + $return = events_event_custom_id( $event_id, - $custom_field + $event_custom_id ); } catch (\Exception $e) { // Unexistent agent. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index dc6bdeb30f..6271864b5d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -17792,7 +17792,7 @@ function api_token_check(string $token) * @param mixed $custom_field Custom field to set. * @return void */ -function api_set_event_custom_field($id, $value) +function api_set_event_custom_id($id, $value) { // Get the event $event = events_get_event($id, false, is_metaconsole()); @@ -17810,7 +17810,7 @@ function api_set_event_custom_field($id, $value) $result = false; } - $result = events_custom_field( + $result = events_event_custom_id( $id, $value ); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index c40a1eb9c7..95f81b90bd 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -219,7 +219,7 @@ function events_get_all_fields() $columns['module_status'] = __('Module status'); $columns['module_custom_id'] = __('Module custom id'); $columns['custom_data'] = __('Custom data'); - $columns['custom_field'] = __('Custom field'); + $columns['event_custom_id'] = __('Event Custom ID'); return $columns; } @@ -323,8 +323,8 @@ function events_get_column_name($field, $table_alias=false) case 'custom_data': return __('Custom data'); - case 'custom_field': - return __('Custom field'); + case 'event_custom_id': + return __('Event Custom ID'); default: return __($field); @@ -4637,13 +4637,13 @@ function events_page_details($event, $server_id=0) $table_details->data[] = $data; $data = []; - $data[0] = __('Custom Field'); - $data[1] = '
'.html_print_input_text('custom_field', $event['custom_field'], '', false, 255, true, false, false, '', 'w60p'); + $data[0] = __('Event Custom ID'); + $data[1] = '
'.html_print_input_text('event_custom_id', $event['event_custom_id'], '', false, 255, true, false, false, '', 'w60p'); $data[1] .= html_print_button( __('Update'), - 'update_custom_field', + 'update_event_custom_id', false, - 'update_custom_field('.$event['id_evento'].', '.$event['server_id'].');', + 'update_event_custom_id('.$event['id_evento'].', '.$event['server_id'].');', [ 'icon' => 'next', 'mode' => 'link', @@ -6228,14 +6228,14 @@ function event_get_counter_extraId(array $event, ?array $filters) /** * Update event detail custom field * - * @param mixed $id_event Event ID or array of events. - * @param string $custom_field Custom_field to be update. + * @param mixed $id_event Event ID or array of events. + * @param string $event_custom_id Event custom ID to be update. * * @return boolean Whether or not it was successful */ -function events_custom_field( +function events_event_custom_id( $id_event, - $custom_field, + $event_custom_id, ) { global $config; // Cleans up the selection for all unwanted values also casts any single @@ -6267,7 +6267,7 @@ function events_custom_field( // Update comment. $ret = db_process_sql_update( 'tevento', - ['custom_field' => $custom_field], + ['event_custom_id' => $event_custom_id], ['id_evento' => $first_event] ); diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index ce782769cb..96f01c2c0d 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -493,13 +493,13 @@ function event_comment(current_event) { } // Save custom_field into an event. -function update_custom_field(event_id, server_id) { - var custom_field_value = $("#text-custom_field").val(); +function update_event_custom_id(event_id, server_id) { + var event_custom_id = $("#text-event_custom_id").val(); var params = { page: "include/ajax/events", - update_custom_field: 1, - custom_field_value: custom_field_value, + update_event_custom_id: 1, + event_custom_id: event_custom_id, event_id: event_id, server_id: server_id }; @@ -514,7 +514,7 @@ function update_custom_field(event_id, server_id) { dataType: "html", success: function(data) { if (data === "update_error") { - alert("Custom field not valid"); + alert("Event Custom ID not valid"); } $("#button-update_custom_field").removeAttr("disabled"); $("#response_loading").hide(); diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index b84f11aa4a..47250e83ac 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -837,7 +837,7 @@ class EventsListWidget extends Widget 'mini_severity' => __('Severity mini'), 'module_custom_id' => __('Module custom ID'), 'custom_data' => __('Custom data'), - 'custom_field' => __('Custom field'), + 'event_custom_id' => __('Event Custom ID'), ]; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index bde20209a4..28d9d9eae3 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -377,7 +377,7 @@ if (is_ajax() === true) { 'te.owner_user', 'if(te.ack_utimestamp > 0, te.ack_utimestamp,"") as ack_utimestamp', 'te.custom_data', - 'te.custom_field', + 'te.event_custom_id', 'te.data', 'te.module_status', 'ta.alias as agent_name', diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 030ef3a76f..36fbc4716b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -723,7 +723,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `custom_data` TEXT, `data` TINYTEXT, `module_status` INT NOT NULL DEFAULT 0, - `custom_field` TEXT, + `event_custom_id` TEXT, PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), From 70e3707b64805144d4288a4695b53faac9942220 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 25 Sep 2023 12:22:10 +0200 Subject: [PATCH 015/108] #11705 group extra id heredity event custom id --- pandora_console/godmode/setup/setup_general.php | 2 +- pandora_console/include/functions_api.php | 6 ++++-- pandora_console/include/functions_events.php | 4 +++- pandora_server/lib/PandoraFMS/Core.pm | 6 ++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index aa55893d11..3f4c24fbbf 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -733,7 +733,7 @@ $table->data[$i++][] = html_print_label_input_block( ); $help_tip = ui_print_help_tip( - __('If there are any "In process" events with a specific Extra ID and a New event with that Extra ID is received, it will be created as "In process" instead.'), + __('If there are any "In process" events with a specific Extra ID and a New event with that Extra ID is received, it will be created as "In process" instead. The new events also inherit Event Custom ID'), true ); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 6271864b5d..ee17d7df6d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13130,7 +13130,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario + $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id FROM tevento WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";'; @@ -13145,6 +13145,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['status'] = 2; $ack_utimestamp = $val['ack_utimestamp']; $values['id_usuario'] = $val['id_usuario']; + $values['event_custom_id'] = $val['event_custom_id']; } api_set_validate_event_by_id($val['id_evento']); @@ -13175,7 +13176,8 @@ function api_set_create_event($id, $trash1, $other, $returnType) $custom_data, $values['server_id'], $values['id_extra'], - $ack_utimestamp + $ack_utimestamp, + $values['event_custom_id'] ?? null ); if ($other['data'][12] != '') { diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 95f81b90bd..4f016f4f82 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2339,7 +2339,8 @@ function events_create_event( $custom_data='', $server_id=0, $id_extra='', - $ack_utimestamp=0 + $ack_utimestamp=0, + $event_custom_id=null ) { if ($source === false) { $source = get_product_name(); @@ -2371,6 +2372,7 @@ function events_create_event( 'custom_data' => $custom_data, 'data' => '', 'module_status' => 0, + 'event_custom_id' => $event_custom_id, ]; return (int) db_process_sql_insert('tevento', $values); diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index e7ac485a1d..b2faac90df 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4160,6 +4160,7 @@ sub pandora_event { my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); + my $event_custom_id = undef; $id_agentmodule = 0 unless defined ($id_agentmodule); # Validate events with the same event id @@ -4177,6 +4178,7 @@ sub pandora_event { logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10); $ack_utimestamp = get_db_value ($dbh, 'SELECT ack_utimestamp FROM tevento WHERE id_extra=? AND estado=2', $id_extra); $event_status = 2; + $event_custom_id = get_db_value ($dbh, 'SELECT event_custom_id FROM tevento WHERE id_extra=? AND estado=2', $id_extra); } } @@ -4188,8 +4190,8 @@ sub pandora_event { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); - $event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status); + $event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status, event_custom_id) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status, $event_custom_id); if(defined($event_id) && $comment ne '') { my $comment_id = db_insert ($dbh, 'id','INSERT INTO tevent_comment (id_event, utimestamp, comment, id_user, action) From 538cb4f04dc7b259b8f9f0e321e2d8a55b5c2266 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 25 Sep 2023 13:12:07 +0200 Subject: [PATCH 016/108] #11705 cli function update_event_custom_id --- pandora_server/util/pandora_manage.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index c63d923402..c35a426e12 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -201,6 +201,7 @@ sub help_screen{ help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); print "\nEVENTS:\n\n" unless $param ne ''; help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); + help_screen_line('--update_event_custom_id', " ", 'Update Event Custom ID'); help_screen_line('--validate_event', " \n\t []", 'Validate events'); help_screen_line('--validate_event_id', '', 'Validate event given a event id'); help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); @@ -4549,6 +4550,17 @@ sub cli_create_event() { } } +############################################################################## +# Update event custom id +# Related option: --update_event_custom_id +############################################################################## + +sub cli_update_event_custom_id() { + my ($id_event, $event_custom_id) = @ARGV[2..3]; + my $result = api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); + print "\n$result\n"; +} + ############################################################################## # Validate event. # Related option: --validate_event @@ -8318,6 +8330,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 4, 0); cli_insert_gis_data(); } + elsif ($param eq '--update_event_custom_id'){ + param_check($ltotal, 2); + cli_update_event_custom_id(); + } else { print_log "[ERROR] Invalid option '$param'.\n\n"; $param = ''; From bcecfbfdccb22c720c0fb8ae112a25918cbeee57 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 26 Sep 2023 09:37:48 +0200 Subject: [PATCH 017/108] #12123 Clear html tag characters to prevent XSS attacks --- pandora_console/godmode/reporting/visual_console_builder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 986dcb423b..35b5e81dfc 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -164,6 +164,8 @@ switch ($activeTab) { $width = (int) get_parameter('width'); $height = (int) get_parameter('height'); $visualConsoleName = (string) get_parameter('name'); + $visualConsoleName = str_replace('<', '', $visualConsoleName); + $visualConsoleName = str_replace('>', '', $visualConsoleName); $is_favourite = (int) get_parameter('is_favourite_sent'); $auto_adjust = (int) get_parameter('auto_adjust_sent'); From e747e4ef741b3c47f718e3f53380067cf1543fa7 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 26 Sep 2023 13:02:07 +0200 Subject: [PATCH 018/108] #12088 Fix notification --- pandora_console/include/class/ConsoleSupervisor.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index a434a30e7f..3aaf7a261e 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -2411,13 +2411,17 @@ class ConsoleSupervisor { global $config; include_once $config['homedir'].'/include/functions_update_manager.php'; - + $server_name = db_get_value_filter( + 'name', + 'tserver', + [ 'server_type' => '1' ] + ); if (update_manager_verify_api() === false) { $this->notify( [ 'type' => 'NOTIF.API.ACCESS', 'title' => __('Cannot access the Pandora FMS API '), - 'message' => __('Please check the configuration, some components may fail due to this misconfiguration.'), + 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), ] ); } else { From 4eb0e69e29814620ca4ab7e2646ddee60e0f8cad Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 28 Sep 2023 10:11:55 +0200 Subject: [PATCH 019/108] #11763 new regex filter events --- pandora_console/operation/events/events.php | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 059c8f90ec..5567eecd60 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -130,6 +130,11 @@ $severity = get_parameter( 'filter[severity]', ($filter['severity'] ?? '') ); +$regex = get_parameter( + 'filter[regex]', + ($filter['regex'] ?? '') +); +unset($filter['regex']); $status = get_parameter( 'filter[status]', ($filter['status'] ?? '') @@ -466,6 +471,23 @@ 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; @@ -2078,6 +2100,12 @@ $in = '
'; $in .= $data.'
'; $inputs[] = $in; +// REGEX search datatable. +$in = '
'; +$in .= html_print_input_text('regex', $regex, '', '', 255, true); +$in .= '
'; +$inputs[] = $in; + // User private filter. $inputs[] = html_print_input_hidden('private_filter_event', $private_filter_event, true); // Trick view in table. @@ -3434,7 +3462,10 @@ $(document).ready( function() { $("#button-remove_without").click(function() { click_button_remove_tag("without"); }); - + + $('#myInputTextField').keyup(function(){ + $("#table_events").search($(this).val()).draw() ; + }) //Autorefresh in fullscreen var pure = ''; From 340288d7855c5880a8078723f0261d6c6777dd2b Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 2 Oct 2023 15:25:24 +0200 Subject: [PATCH 020/108] #12137 visual refactoring for main agent view --- pandora_console/include/functions_agents.php | 99 ++++++++++++++++--- .../include/functions_reporting.php | 15 ++- pandora_console/include/styles/agent_view.css | 4 + pandora_console/include/styles/pandora.css | 40 ++++++-- .../agentes/estado_generalagente.php | 61 +++++------- 5 files changed, 159 insertions(+), 60 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index f1cb4e1f0e..c65b0b21e0 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4738,7 +4738,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $secondaryLinks = []; if (empty($secondary_groups['for_select']) === true) { - $secondaryLinks[] = ''.__('N/A').''; + $secondaryLinks = []; } else { foreach ($secondary_groups['for_select'] as $id => $name) { $secondaryLinks[] = html_print_anchor( @@ -4797,22 +4797,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) 'content' => groups_get_name($agent['id_grupo']), ], true - ); + ).' '.ui_print_group_icon($agent['id_grupo'], true, '', '', true, false, false, '', true); $table_contact->data[] = $data; // Secondary groups. $data = []; - $data[0] = ''.__('Secondary groups').''; - $data[1] = implode(', ', $secondaryLinks); - $table_contact->data[] = $data; + if (!empty($secondaryLinks) === true) { + $data[0] = ''.__('Secondary groups').''; + $data[1] = implode(', ', $secondaryLinks); + $table_contact->data[] = $data; + } // Parent agent line. if (enterprise_installed() === true) { - $data = []; - $data[0] = ''.__('Parent').''; - if ((int) $agent['id_parent'] === 0) { - $data[1] = ''.__('N/A').''; - } else { + if ((int) $agent['id_parent'] !== 0) { + $data = []; + $data[0] = ''.__('Parent').''; $data[1] = html_print_anchor( [ 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_parent'], @@ -4820,9 +4820,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) ], true ); - } - $table_contact->data[] = $data; + $table_contact->data[] = $data; + } } // Last status change line. @@ -4831,6 +4831,81 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) $data[1] = $time_elapsed; $table_contact->data[] = $data; + $has_remote_conf = enterprise_hook( + 'config_agents_has_remote_configuration', + [$agent['id_agente']] + ); + + $data = []; + if ((bool) $has_remote_conf) { + $data[0] = __('Remote configuration'); + $data[1] = ''.__('Enabled').''; + $data[1] .= html_print_menu_button( + [ + 'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'), + 'image' => 'images/remote-configuration@svg.svg', + 'title' => __('Edit remote config'), + ], + true + ); + + $satellite_server = (int) db_get_value_filter( + 'satellite_server', + 'tagente', + ['id_agente' => $id_agente] + ); + + if (empty($satellite_server) === false) { + $satellite_name = db_get_value_filter( + 'name', + 'tserver', + ['id_server' => $satellite_server] + ); + + $data[0] = __('Satellite server'); + $data[1] = $satellite_name; + } + } + + $table_contact->data[] = $data; + + // Optional data + // Position Information. + if ((bool) $config['activate_gis'] === true) { + $data = []; + + $dataPositionAgent = gis_get_data_last_position_agent( + $agent['id_agente'] + ); + if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') { + $data[0] = __('Position (Long, Lat)'); + + $dataOptionalOutput = html_print_anchor( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=gis&id_agente='.$id_agente, + 'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'], + ], + true + ); + + if (empty($dataPositionAgent['description']) === false) { + $dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')'; + } + + $data[1] = $dataOptionalOutput; + } + + $table_contact->data[] = $data; + } + + // Timezone Offset. + if ((int) $agent['timezone_offset'] !== 0) { + $data = []; + $data[0] = __('Timezone Offset'); + $data[1] = $agent['timezone_offset']; + $table_contact->data[] = $data; + } + $agent_contact = html_print_div( [ 'class' => 'agent_details_header', diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index eab4e761d3..463b058176 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -13503,38 +13503,47 @@ function reporting_tiny_stats( } if ($modern === true) { - $out .= '
'; if (isset($fired_count) && $fired_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$fired_count.'
'; + $out .= '
'; } if (isset($critical_count) && $critical_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$critical_count.'
'; + $out .= '
'; } if (isset($warning_count) && $warning_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$warning_count.'
'; + $out .= '
'; } if (isset($unknown_count) && $unknown_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$unknown_count.'
'; + $out .= '
'; } if (isset($not_init_count) && $not_init_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$not_init_count.'
'; + $out .= '
'; } if (isset($normal_count) && $normal_count > 0) { + $out .= '
'; $out .= '
'; $out .= ''.$normal_count.'
'; + $out .= '
'; } - - $out .= '
'; } else { // Classic ones. $out .= ''.$total_count.''; diff --git a/pandora_console/include/styles/agent_view.css b/pandora_console/include/styles/agent_view.css index d4a1d89a4e..1df8efdb84 100644 --- a/pandora_console/include/styles/agent_view.css +++ b/pandora_console/include/styles/agent_view.css @@ -6,6 +6,10 @@ div#bullets_modules span { font-weight: 700; } +div.bullets_modules span { + font-weight: 700; +} + div.agent_details_agent_caption { flex: 1; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 45cacafb6b..21ac227110 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -6037,18 +6037,18 @@ div.switch_radio_button label:last-of-type { margin-top: -2px; } -/* -div#bullets_modules { - display: flex; - margin-left: 2em; -} -*/ div#bullets_modules div { display: flex; align-items: center; margin: 0 5px; } +div.bullets_modules div { + display: flex; + align-items: center; + margin: 0 5px; +} + .orange_background { background: #ffa631; } @@ -6309,6 +6309,7 @@ div#status_pie { flex-direction: column; justify-content: center; align-items: center; + width: 100%; } .agent_details_agent_data { @@ -6338,23 +6339,45 @@ div#status_pie { justify-content: flex-start; } +.agent_details_bullets .bullets_modules { + display: flex; + justify-content: flex-start; +} + .agent_details_bullets_cluster #bullets_modules { display: flex; justify-content: flex-start; flex-direction: column; } +.agent_details_bullets_cluster .bullets_modules { + display: flex; + justify-content: flex-start; + flex-direction: column; +} + .agent_details_bullets_cluster #bullets_modules > div { padding: 0px; margin-bottom: 10px; } +.agent_details_bullets_cluster .bullets_modules > div { + padding: 0px; + margin-bottom: 10px; +} + .agent_details_bullets #bullets_modules > div { display: flex; align-items: center; padding-bottom: 20px; } +.agent_details_bullets .bullets_modules > div { + display: flex; + align-items: center; + padding-bottom: 20px; +} + #agent_contact_main tr td img { max-width: 100%; } @@ -6406,6 +6429,11 @@ div#status_pie { float: right; } +.white_table_graph_header div.bullets_modules { + display: flex; + float: right; +} + .white_table_graph_header img, .white_table_graph_header span { vertical-align: middle; diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 62963f6b29..c25ff3a5c1 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -124,8 +124,15 @@ foreach ($addresses as $k => $add) { } if (empty($address) === false) { + $address_text = ''.$address.''; + if (!empty($addresses) === true) { + foreach ($addresses as $sec_address) { + $address_text .= '
'.$sec_address.''; + } + } + $table_status->data['ip_address'][0] = __('IP address'); - $table_status->data['ip_address'][1] = (empty($address) === true) ? ''.__('N/A').'' : $address; + $table_status->data['ip_address'][1] = (empty($address) === true) ? ''.__('N/A').'' : $address_text; } $table_status->data['agent_version'][0] = __('Agent Version'); @@ -134,34 +141,6 @@ $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']; -$has_remote_conf = enterprise_hook( - 'config_agents_has_remote_configuration', - [$agent['id_agente']] -); - -if ((bool) $has_remote_conf) { - $table_status->data['remote_config'][0] = __('Remote configuration'); - $table_status->data['remote_config'][1] = __('Enabled'); - - $satellite_server = (int) db_get_value_filter( - 'satellite_server', - 'tagente', - ['id_agente' => $id_agente] - ); - - if (empty($satellite_server) === false) { - $satellite_name = db_get_value_filter( - 'name', - 'tserver', - ['id_server' => $satellite_server] - ); - - $table_status->data['remote_config'][0] = __('Satellite server'); - $table_status->data['remote_config'][1] = $satellite_name; - } -} - - $table_agent = $agentStatusHeader.'
@@ -189,11 +168,12 @@ $data_opcional->class = 'floating_form'; // Gis and url address. $agentAdditionalContent = ''; // Position Information. -if ((bool) $config['activate_gis'] === true) { +/* + if ((bool) $config['activate_gis'] === true) { $dataPositionAgent = gis_get_data_last_position_agent( $agent['id_agente'] ); - if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_longitude'] !== '') { + if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') { $data_opcional->data['agent_position'][0] = __('Position (Long, Lat)'); $dataOptionalOutput = html_print_anchor( @@ -210,10 +190,11 @@ if ((bool) $config['activate_gis'] === true) { $data_opcional->data['agent_position'][1] = $dataOptionalOutput; } -} +}*/ // If the url description is set. -if (empty($agent['url_address']) === false) { +/* + if (empty($agent['url_address']) === false) { $data_opcional->data['url_address'][0] = __('Url address'); $data_opcional->data['url_address'][1] = html_print_anchor( [ @@ -222,11 +203,12 @@ if (empty($agent['url_address']) === false) { ], true ); -} +}*/ // Other IP address and timezone offset. -if (empty($addresses) === false) { +/* + if (empty($addresses) === false) { $data_opcional->data['other_ip_address'][0] = __('Other IP addresses'); $data_opcional->data['other_ip_address'][1] = html_print_div( [ @@ -235,13 +217,14 @@ if (empty($addresses) === false) { ], true ); -} - + } +*/ // Timezone Offset. -if ((int) $agent['timezone_offset'] !== 0) { +/* + if ((int) $agent['timezone_offset'] !== 0) { $data_opcional->data['timezone_offset'][0] = __('Timezone Offset'); $data_opcional->data['timezone_offset'][1] = $agent['timezone_offset']; -} +}*/ // Custom fields. $fields = db_get_all_rows_filter( From 384a66dc0d597796d0f86bbe6739a0c24ef409c2 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 3 Oct 2023 09:35:10 +0200 Subject: [PATCH 021/108] #12137 Fix refact --- pandora_console/include/functions_agents.php | 2 +- pandora_console/include/styles/pandora.css | 4 ++++ .../agentes/estado_generalagente.php | 20 +++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c65b0b21e0..1511ee9f01 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -4797,7 +4797,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent) 'content' => groups_get_name($agent['id_grupo']), ], true - ).' '.ui_print_group_icon($agent['id_grupo'], true, '', '', true, false, false, '', true); + ).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true); $table_contact->data[] = $data; // Secondary groups. diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 21ac227110..93717aa12c 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12685,3 +12685,7 @@ 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 c25ff3a5c1..eb044e8f85 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -110,8 +110,24 @@ $table_status->style[0] = 'height: 32px; width: 30%; padding-right: 5px; text-al $table_status->style[1] = 'height: 32px; width: 70%; padding-left: 5px; font-weight: lighter; vertical-align: top'; $table_status->data['agent_os'][0] = __('OS'); $agentOS = []; -$agentOS[] = html_print_div([ 'content' => (empty($agent['os_version']) === true) ? get_os_name((int) $agent['id_os']) : $agent['os_version']], true); -$agentOS[] = html_print_div([ 'style' => 'width: 16px;padding-left: 5px', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true); + +$os_agent_text = get_os_name((int) $agent['id_os']).' '.__('OS Version: Unknown'); +if (empty($agent['os_version']) !== true) { + if (strpos($agent['os_version'], '(') !== false) { + $os_version_name = preg_split('/[0-9]|[\(]/', $agent['os_version'])[0]; + $os_version_num = explode($os_version_name, explode('(', $agent['os_version'])[0])[1]; + $os_version_secondary_name = preg_split('/[\(]|[\)]/', $agent['os_version']); + $os_agent_text = $os_version_name.' '.__('OS Version:').' '.$os_version_num.' ('.$os_version_secondary_name[1].')'; + } else { + $os_version_name = preg_split('/[0-9]/', $agent['os_version'])[0]; + $os_version_num = explode($os_version_name, explode('(', $agent['os_version'])[0])[1]; + $os_agent_text = $os_version_name.' '.__('OS Version:').' '.$os_version_num; + } +} + +// (empty($agent['os_version']) === true) ? get_os_name((int) $agent['id_os']) : $agent['os_version'] +$agentOS[] = html_print_div([ 'style' => 'width: 16px;padding-right: 10px', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true); +$agentOS[] = html_print_div([ 'content' => $os_agent_text], true); $table_status->data['agent_os'][1] = html_print_div(['class' => 'agent_details_agent_data', 'content' => implode('', $agentOS)], true); $addresses = agents_get_addresses($id_agente); From 2a2a1b6e3ebe88b5f9c5ae5528bac600c1536f16 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 3 Oct 2023 10:46:31 +0200 Subject: [PATCH 022/108] #10316 hover ip custom field get value --- pandora_console/godmode/agentes/module_manager.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 5c21fa71a0..3e76a1baef 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -949,7 +949,14 @@ if ($modules !== false) { ); if (strlen($module['ip_target']) !== 0) { - $title .= '
IP: '.$module['ip_target']; + // Check if value is custom field. + if ($module['ip_target'][0] == '_' && $module['ip_target'][(strlen($module['ip_target']) - 1)] == '_') { + $custom_field_name = substr($module['ip_target'], 1, -1); + $custom_value = agents_get_agent_custom_field($id_agente, $custom_field_name); + $title .= '
IP: '.$custom_value; + } else { + $title .= '
IP: '.$module['ip_target']; + } } // This module is initialized ? (has real data). From f27d4176ea60a93227f095f041d9eb4d22d862ed Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 3 Oct 2023 10:58:59 +0200 Subject: [PATCH 023/108] #12137 Fix OS version --- .../agentes/estado_generalagente.php | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index eb044e8f85..1b91cf84c1 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -103,32 +103,35 @@ $agentCountModules = html_print_div( $table_status = new stdClass(); $table_status->id = 'agent_status_main'; $table_status->width = '100%'; +$table_status->height = 'auto'; $table_status->cellspacing = 0; $table_status->cellpadding = 0; $table_status->class = 'floating_form'; -$table_status->style[0] = 'height: 32px; width: 30%; padding-right: 5px; text-align: end; vertical-align: top'; -$table_status->style[1] = 'height: 32px; width: 70%; padding-left: 5px; font-weight: lighter; vertical-align: top'; -$table_status->data['agent_os'][0] = __('OS'); -$agentOS = []; +$table_status->style[0] = 'height: 28px; width: 30%; padding-right: 5px; text-align: end; vertical-align: top'; +$table_status->style[1] = 'height: 28px; width: 70%; padding-left: 5px; font-weight: lighter; vertical-align: top'; -$os_agent_text = get_os_name((int) $agent['id_os']).' '.__('OS Version: Unknown'); +$os_agent_text = ''; +$os_name = get_os_name((int) $agent['id_os']); if (empty($agent['os_version']) !== true) { if (strpos($agent['os_version'], '(') !== false) { - $os_version_name = preg_split('/[0-9]|[\(]/', $agent['os_version'])[0]; - $os_version_num = explode($os_version_name, explode('(', $agent['os_version'])[0])[1]; - $os_version_secondary_name = preg_split('/[\(]|[\)]/', $agent['os_version']); - $os_agent_text = $os_version_name.' '.__('OS Version:').' '.$os_version_num.' ('.$os_version_secondary_name[1].')'; + $os_name = preg_split('/[0-9]|[\(]/', $agent['os_version'])[0]; + $os_version = explode($os_name, explode('(', $agent['os_version'])[0])[1]; + $os_version_name = preg_split('/[\(]|[\)]/', $agent['os_version']); + $os_agent_text = $os_version.' ('.$os_version_name[1].')'; } else { - $os_version_name = preg_split('/[0-9]/', $agent['os_version'])[0]; - $os_version_num = explode($os_version_name, explode('(', $agent['os_version'])[0])[1]; - $os_agent_text = $os_version_name.' '.__('OS Version:').' '.$os_version_num; + $os_name = preg_split('/[0-9]/', $agent['os_version'])[0]; + $os_version = explode($os_name, explode('(', $agent['os_version'])[0])[1]; + $os_agent_text = $os_version; } } -// (empty($agent['os_version']) === true) ? get_os_name((int) $agent['id_os']) : $agent['os_version'] -$agentOS[] = html_print_div([ 'style' => 'width: 16px;padding-right: 10px', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true); -$agentOS[] = html_print_div([ 'content' => $os_agent_text], true); -$table_status->data['agent_os'][1] = html_print_div(['class' => 'agent_details_agent_data', 'content' => implode('', $agentOS)], true); +$table_status->data['agent_os'][0] = html_print_div([ 'style' => 'width: 16px; position: relative; left: 75%', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true); +$table_status->data['agent_os'][1] = $os_name; + +if (empty($agent['os_version']) !== true) { + $table_status->data['agent_os_version'][0] = __('OS Version'); + $table_status->data['agent_os_version'][1] = $os_agent_text; +} $addresses = agents_get_addresses($id_agente); $address = agents_get_address($id_agente); From eacecb4b8f55f0de38ec37c6c46c56c113b663e7 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 10 Oct 2023 10:50:56 +0200 Subject: [PATCH 024/108] #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 025/108] #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 f058ec5df83826d538aa30cb353d1b714e1e5964 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 11 Oct 2023 08:12:55 +0200 Subject: [PATCH 026/108] #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 027/108] #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 be99b512e23cbd717299b6ca5cbb27b40f2c62c3 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 08:41:06 +0200 Subject: [PATCH 028/108] #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 7b443414ca133830dce996ecc5bc5bf246634bfa Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 17 Oct 2023 09:52:56 +0200 Subject: [PATCH 029/108] #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 0e58c64a390e57ff06696d42c117f534fb7da762 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Mon, 23 Oct 2023 11:14:30 +0200 Subject: [PATCH 030/108] #12260 Adjusted icon path depending on icon extension --- pandora_console/godmode/groups/group_list.php | 3 +++ .../include/javascript/jquery.pandora.controls.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 00bbdddb39..49638d2100 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -84,6 +84,9 @@ if (is_ajax() === true) { } $group = db_get_row('tgrupo', 'id_grupo', $id_group); + if (str_contains($group['icon'], '.png') === true) { + $group['folder'] = 'groups_small/'; + } echo json_encode($group); return; diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index c42f205b60..640e83c26d 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -331,9 +331,13 @@ id_group: id_group }, function(data) { + let routeImg = + typeof data.folder === "undefined" + ? "images/" + : "images/" + data.folder; $("img", config.spanPreview).attr( "src", - "images/" + data["icon"] + routeImg + data["icon"] ); $("a", config.spanPreview).attr("href", hrefNew); }, From dbf315e4079fd9359b7b8f87560ad1a36c46c5fb Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 23 Oct 2023 14:48:34 +0200 Subject: [PATCH 031/108] #10983 revised widgets with intervals --- .../lib/Dashboard/Widgets/BasicChart.php | 4 ++++ .../lib/Dashboard/Widgets/DataMatrix.php | 4 ++++ .../lib/Dashboard/Widgets/custom_graph.php | 4 ++++ .../Widgets/graph_module_histogram.php | 4 ++++ .../include/lib/Dashboard/Widgets/netflow.php | 6 +++++ .../Dashboard/Widgets/security_hardening.php | 6 +++++ .../lib/Dashboard/Widgets/single_graph.php | 4 ++++ .../include/lib/Dashboard/Widgets/top_n.php | 4 ++++ .../views/dashboard/formDashboard.php | 23 +++++++++++++++---- 9 files changed, 54 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php index c3b9ddf9ad..a140d7fcb4 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php +++ b/pandora_console/include/lib/Dashboard/Widgets/BasicChart.php @@ -637,6 +637,10 @@ class BasicChart extends Widget $color_status = $this->values['colorValue']; } + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + $params = [ 'agent_module_id' => $this->values['moduleId'], 'period' => $this->values['period'], diff --git a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php index be38c31bb4..770a3152fe 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php +++ b/pandora_console/include/lib/Dashboard/Widgets/DataMatrix.php @@ -473,6 +473,10 @@ class DataMatrix extends Widget return $output; } + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + if (is_metaconsole() === true) { $modules_nodes = array_reduce( $this->values['moduleDataMatrix'], diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index 377ca145a0..4cb4734105 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -472,6 +472,10 @@ class CustomGraphWidget extends Widget $size = parent::getSize(); + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + switch ($this->values['type']) { case CUSTOM_GRAPH_STACKED_LINE: case CUSTOM_GRAPH_STACKED_AREA: diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php index b0382ba273..38967c2e47 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php @@ -302,6 +302,10 @@ class GraphModuleHistogramWidget extends Widget $values['period'] = SECONDS_1DAY; } + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + if (isset($values['sizeLabel']) === false) { $values['sizeLabel'] = 30; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/netflow.php b/pandora_console/include/lib/Dashboard/Widgets/netflow.php index 13a15bf6a0..6c0aa76eca 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/netflow.php +++ b/pandora_console/include/lib/Dashboard/Widgets/netflow.php @@ -309,6 +309,12 @@ class Netflow extends Widget $start_date = (time() - $this->values['period']); $end_date = time(); + + if (empty(parent::getPeriod()) === false) { + $start_date = parent::getDateFrom(); + $end_date = parent::getDateTo(); + } + if ($this->values['chart_type'] === 'usage_map') { $map_data = netflow_build_map_data( $start_date, diff --git a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php index 2c936728ed..14afbcfb20 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php +++ b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php @@ -134,6 +134,7 @@ class SecurityHardening extends Widget // Includes. include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php'; + include_once $config['homedir'].'/include/graphs/fgraph.php'; // WARNING: Do not edit. This chunk must be in the constructor. parent::__construct( $cellId, @@ -325,6 +326,11 @@ class SecurityHardening extends Widget $id_groups = $this->checkAcl($values['group']); $output .= ''.$this->elements[$data_type].''; + if (empty(parent::getPeriod()) === false) { + $values['date_init'] = parent::getDateFrom(); + $values['date_end'] = parent::getDateTo(); + } + switch ($data_type) { case 'top_n_agents_sh': $output .= $this->loadTopNAgentsSh($id_groups, $values['limit']); diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index 236b19c554..280bf3226f 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -300,6 +300,10 @@ class SingleGraphWidget extends Widget $values['period'] = SECONDS_1DAY; } + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + if (isset($values['showLegend']) === false) { $values['showLegend'] = 1; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index 5a603501c0..f732f8b264 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -374,6 +374,10 @@ class TopNWidget extends Widget $size = parent::getSize(); + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } + $quantity = $this->values['quantity']; $period = $this->values['period']; diff --git a/pandora_console/views/dashboard/formDashboard.php b/pandora_console/views/dashboard/formDashboard.php index fafacd583d..be21a3142e 100644 --- a/pandora_console/views/dashboard/formDashboard.php +++ b/pandora_console/views/dashboard/formDashboard.php @@ -119,12 +119,12 @@ $inputs = [ 'arguments' => [ 'name' => 'range', 'id' => 'range', - 'selected' => ($arrayDashboard['date_to'] - $arrayDashboard['date_from']), + 'selected' => ($arrayDashboard['date_from'] === '0' && $arrayDashboard['date_to'] === '0') ? 300 : 'chose_range', 'type' => 'date_range', - 'date_init' => $arrayDashboard['date_from'], - 'time_init' => $arrayDashboard['date_from'], - 'date_end' => $arrayDashboard['date_to'], - 'time_end' => $arrayDashboard['date_to'], + 'date_init' => date('Y/m/d', $arrayDashboard['date_from']), + 'time_init' => date('H:i:s', $arrayDashboard['date_from']), + 'date_end' => date('Y/m/d', $arrayDashboard['date_to']), + 'time_end' => date('H:i:s', $arrayDashboard['date_to']), ], ], [ @@ -167,6 +167,19 @@ HTML::printForm( function handle_date_range(element){ if(element.checked) { $(".row_date_range").show(); + var def_state_range = $('#range_range').is(':visible'); + var def_state_default = $('#range_default').is(':visible'); + var def_state_extend = $('#range_extend').is(':visible'); + if ( + def_state_range === false + && def_state_default === false + && def_state_extend === false + && $('#range').val() !== 'chose_range' + ) { + $('#range_default').show(); + } else if ($('#range').val() === 'chose_range') { + $('#range_range').show(); + } } else { $(".row_date_range").hide(); } From a23bc00d171ce805393c078a8cf2008d555cb682 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 23 Oct 2023 17:17:22 +0200 Subject: [PATCH 032/108] #10983 added control time in graphs --- .../include/lib/Dashboard/Widgets/single_graph.php | 4 ---- pandora_console/include/lib/Dashboard/Widgets/sla_percent.php | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index 280bf3226f..236b19c554 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -300,10 +300,6 @@ class SingleGraphWidget extends Widget $values['period'] = SECONDS_1DAY; } - if (empty(parent::getPeriod()) === false) { - $this->values['period'] = parent::getPeriod(); - } - if (isset($values['showLegend']) === false) { $values['showLegend'] = 1; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php index 4dfefbf292..f3c7fb826e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php +++ b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php @@ -459,6 +459,9 @@ class SLAPercentWidget extends Widget global $config; $size = parent::getSize(); + if (empty(parent::getPeriod()) === false) { + $this->values['period'] = parent::getPeriod(); + } $output .= ''; $id_agent = $this->values['agentId']; From 47aeb3cc39ead3adf6fa5dc0ad714084b5f2829c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 2 Nov 2023 13:22:42 +0100 Subject: [PATCH 033/108] #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 034/108] #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 035/108] #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 1412480b4dd571b6c80208c75b2215aa5e97960c Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 09:54:56 +0100 Subject: [PATCH 036/108] #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 05be3e143efcbf95e7f19a3b7aa4e59a2dddce7f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 3 Nov 2023 11:27:27 +0100 Subject: [PATCH 037/108] #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 038/108] 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 039/108] #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 040/108] #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 f71479033d8074513fd8342867803728030c9e03 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 6 Nov 2023 13:06:38 +0100 Subject: [PATCH 041/108] 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 545316e9a8f1ef55e9edddf2b48e71ada47a1cd5 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 7 Nov 2023 08:35:49 +0100 Subject: [PATCH 042/108] #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 84ee69b435846510fc38ba6e6fab4194ef43be3d Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 7 Nov 2023 15:56:23 +0100 Subject: [PATCH 043/108] #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 82759ae12f247d48a77a89831fdf04db344d21d2 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 8 Nov 2023 15:24:47 +0100 Subject: [PATCH 044/108] #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 813bc4b851c8f97578d8dc6b8a5a48e481a2ef3b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Nov 2023 09:49:19 +0100 Subject: [PATCH 045/108] #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 ca66efb4f4b7630d711df558a5c32df4e5ad5ca1 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 13:20:55 +0100 Subject: [PATCH 046/108] 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 d49c5e4954336fa79371fc7eb6a8e965bd4d6641 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 15:12:55 +0100 Subject: [PATCH 047/108] 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 5ba07153e29e365abded6e3b60b942f649a81497 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Nov 2023 15:28:20 +0100 Subject: [PATCH 048/108] #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 a2031559a016a5e24abb5f52d58093d1dcbb6b8d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 14 Nov 2023 10:37:07 +0100 Subject: [PATCH 049/108] #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 4e3fa66c2bccd52ddf251e785f92055729c9b7c9 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 14 Nov 2023 11:44:51 +0100 Subject: [PATCH 050/108] 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 2336e7c8da54b0cf5e201074ede5220306b8fda0 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 14 Nov 2023 12:49:27 +0100 Subject: [PATCH 051/108] #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 052/108] 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 053/108] #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 b45c967919d862b1f02161e55a915628f4c3299b Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 15 Nov 2023 08:30:24 +0100 Subject: [PATCH 054/108] 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 055/108] #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, + ); + ?> + + @@ -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 99c5da677d7b79b3df225b2da42a8ffd447d33e8 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 16 Nov 2023 08:37:41 +0100 Subject: [PATCH 056/108] #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 0f9facb99955d940572b06239a5a4be56043fd02 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 16 Nov 2023 13:17:25 +0100 Subject: [PATCH 057/108] fix chart_generator pdf pandora_enterprise#12382 --- .../extras/delete_files/delete_files.txt | 1 + pandora_console/include/chart_generator.php | 324 ------------------ pandora_console/include/functions.php | 263 +++++++++++--- pandora_console/include/functions_ui.php | 27 +- .../include/graphs/functions_d3.php | 4 +- .../include/graphs/functions_flot.php | 6 +- 6 files changed, 241 insertions(+), 384 deletions(-) delete mode 100644 pandora_console/include/chart_generator.php diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index 234ec4e997..03db82db4e 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -1720,3 +1720,4 @@ include/functions_integriaims.php include/ajax/integria_incidents.ajax.php enterprise/operation/log/log_source.php enterprise/include/class/LogSource.class.php +include/chart_generator.php \ No newline at end of file diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php deleted file mode 100644 index 529684569d..0000000000 --- a/pandora_console/include/chart_generator.php +++ /dev/null @@ -1,324 +0,0 @@ - 'api_password'] - ) - ); - - - if ($apiPassword === $data_decoded['apipass']) { - $bypassLogin = true; - } -} - -if (!isset($config[$slicebar])) { - $config[$slicebar] = $slicebar_value; -} - -// Try to initialize session using existing php session id. -$user = new PandoraFMS\User(['phpsessionid' => $session_id]); - -if (check_login(false) === false && $bypassLogin !== true) { - // Error handler. - ?> - - - - - Access denied - - - - - - - - - -

Access is not granted

-