From a73ec18867e595751f0565585598ff2a4ddf9fb5 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Thu, 21 May 2020 09:13:39 +0200 Subject: [PATCH 01/26] Fixed errors filter search with pagination --- pandora_console/godmode/reporting/reporting_builder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 60464ee953..cfd1a14b9a 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -767,9 +767,14 @@ switch ($action) { ) ); - if (count($reports)) { + $filters = [ + 'search' => $search, + 'id_group' => $id_group, + ]; + $filtersStr = http_build_query($filters, '', '&'); $url = 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder'; + $url .= '&'.$filtersStr; ui_pagination($total_reports, $url, $offset, $pagination); $table = new stdClass(); From ab8916a0daf5147638d01d35745ef444f862424a Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Fri, 22 May 2020 09:39:10 +0200 Subject: [PATCH 02/26] Fixed error functions date default type --- pandora_console/include/functions.php | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index eaea211d2a..284b8c83b7 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -477,7 +477,8 @@ function set_user_language() /** - * INTERNAL (use ui_print_timestamp for output): Transform an amount of time in seconds into a human readable + * INTERNAL (use ui_print_timestamp for output): + * Transform an amount of time in seconds into a human readable * strings of minutes, hours or days. * * @param integer $seconds Seconds elapsed time @@ -488,17 +489,11 @@ function set_user_language() */ function human_time_description_raw($seconds, $exactly=false, $units='large') { - switch ($units) { - case 'large': - $secondsString = __('seconds'); - $daysString = __('days'); - $monthsString = __('months'); - $yearsString = __('years'); - $minutesString = __('minutes'); - $hoursString = __('hours'); - $nowString = __('Now'); - break; + if (isset($units) === false || empty($units) === true) { + $units = 'large'; + } + switch ($units) { case 'tiny': $secondsString = __('s'); $daysString = __('d'); @@ -508,6 +503,17 @@ function human_time_description_raw($seconds, $exactly=false, $units='large') $hoursString = __('h'); $nowString = __('N'); break; + + default: + case 'large': + $secondsString = __('seconds'); + $daysString = __('days'); + $monthsString = __('months'); + $yearsString = __('years'); + $minutesString = __('minutes'); + $hoursString = __('hours'); + $nowString = __('Now'); + break; } if (empty($seconds)) { From 1d167d4aba0aff44b66bbfb65325544568c73540 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 25 May 2020 11:12:29 +0200 Subject: [PATCH 03/26] fixed agent id strange behavior in events table --- pandora_console/operation/events/events.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 1c91ebaf54..ba029bfb17 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1962,17 +1962,7 @@ function process_datatables_item(item) { /* Agent ID link */ if (item.id_agente > 0) { - - item.id_agente = '' + item.id_agente + ''; - - item.id_agente = '' + item.agent_name + ''; - + item.id_agente = '' + item.id_agente + ''; } else { item.id_agente = ''; } From 2481bcc669d7238c48473596be648beb9f2fd770 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 May 2020 13:56:39 +0200 Subject: [PATCH 04/26] Update default value for use_xml_timestamp --- pandora_server/lib/PandoraFMS/Config.pm | 3 ++- pandora_server/lib/PandoraFMS/DataServer.pm | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 5babae0d3c..c19aed0317 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -399,7 +399,8 @@ sub pandora_load_config { $pa_config->{'max_log_generation'} = 1; # Ignore the timestamp in the XML and use the file timestamp instead - $pa_config->{'use_xml_timestamp'} = 0; + # If 1 => uses timestamp from received XML #5763. + $pa_config->{'use_xml_timestamp'} = 1; # Server restart delay in seconds $pa_config->{'restart_delay'} = 60; diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index f82a58a120..69efd9f45a 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -234,6 +234,7 @@ sub data_consumer ($$) { } # Ignore the timestamp in the XML and use the file timestamp instead + # If 1 => uses timestamp from received XML #5763. $xml_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime((stat($file_name))[9])) if ($pa_config->{'use_xml_timestamp'} eq '0' || ! defined ($xml_data->{'timestamp'})); # Double check that the file exists From c6b1e92bda7de0322c97e55d2116721c84f0f0ae Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Jun 2020 08:44:24 +0200 Subject: [PATCH 05/26] Modified match for forbidden words. Now not allows spaces or scaped chars. Other cases must not be problemathic --- pandora_console/include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 724fe11fd6..8805a0b1e2 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2136,7 +2136,7 @@ function check_sql($sql) { // We remove "*" to avoid things like SELECT * FROM tusuario // Check that it not delete_ as "delete_pending" (this is a common field in pandora tables). - if (preg_match('/\*|delete[^_]|drop|alter|modify|password|pass|insert|update/i', $sql)) { + if (preg_match('/([ ]*(delete|drop|alter|modify|password|pass|insert|update)\b[ \\]+)/i', $sql)) { return ''; } From 82b66d567d676c65b49d7c745381868a92a80299 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Mon, 8 Jun 2020 14:14:35 +0200 Subject: [PATCH 06/26] Fixed sla graph in pdf --- pandora_console/include/chart_generator.php | 3 ++- .../include/graphs/functions_flot.php | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index edd8208b05..97fdf32b9c 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -277,7 +277,8 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { $params['ttl'], $params['sizeForTicks'], $params['show'], - $params['date_to'] + $params['date_to'], + $params['server_id'] ); break; diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 1a74f456b2..9666196a6c 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -699,6 +699,7 @@ function flot_slicesbar_graph( 'show' => $show, 'return_img_base_64' => true, 'date_to' => $date_to, + 'server_id' => $server_id, ]; $graph = '"; $return .= "//"; $return .= ''; From 11dbe46a96a82aff3a4ae5c5af469fd1bf21f816 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 8 Jun 2020 15:23:09 +0200 Subject: [PATCH 07/26] Allowed toggled rows --- .../godmode/wizards/Wizard.main.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 7320934826..9af64a7c39 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -832,7 +832,7 @@ class Wizard $first_block_printed = true; } - $output .= '
'; + $row_output = '
'; foreach ($row['columns'] as $column) { $width = isset($column['width']) ? 'width: '.$column['width'].';' : 'width: 100%;'; @@ -841,23 +841,36 @@ class Wizard $extra_styles = isset($column['style']) ? $column['style'] : ''; $class = isset($column['class']) ? $column['class'] : ''; - $output .= '
'; + $row_output .= '
'; foreach ($column['inputs'] as $input) { if (is_array($input)) { if ($input['arguments']['type'] != 'submit') { - $output .= $this->printBlockAsGrid($input, true); + $row_output .= $this->printBlockAsGrid($input, true); } else { $output_submit .= $this->printBlockAsGrid($input, true); } } else { - $output .= $input; + $row_output .= $input; } } - $output .= '
'; + $row_output .= '
'; + } + + if (isset($row['toggle'])) { + $output .= ui_print_toggle( + [ + 'content' => $row_output, + 'name' => $row['toggle_label'], + 'hidden_default' => ! (bool) $row['toggle'], + 'return' => true, + ] + ); + } else { + $output .= $row_output; } $output .= '
'; From 754023f90891ded8107f22a156cb442311b9d2c8 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 8 Jun 2020 17:12:33 +0200 Subject: [PATCH 08/26] fix XSS --- pandora_console/godmode/wizards/HostDevices.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 9cb9505a5b..80810b7cf2 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -692,9 +692,7 @@ class HostDevices extends Wizard if ($this->page == 1) { $title = __( '"%s" features', - io_safe_output( - $this->task['name'] - ) + $this->task['name'] ); } From 120b78b5c55126a41eb04e3f4c967a59749c4310 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Jun 2020 17:36:32 +0200 Subject: [PATCH 09/26] Control vulnerable fields --- pandora_console/godmode/tag/edit_tag.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/tag/edit_tag.php b/pandora_console/godmode/tag/edit_tag.php index 2db4cfed33..96b4e158e3 100644 --- a/pandora_console/godmode/tag/edit_tag.php +++ b/pandora_console/godmode/tag/edit_tag.php @@ -31,11 +31,10 @@ $id_tag = (int) get_parameter('id_tag', 0); $update_tag = (int) get_parameter('update_tag', 0); $create_tag = (int) get_parameter('create_tag', 0); $name_tag = (string) get_parameter('name_tag', ''); -$description_tag = (string) get_parameter('description_tag', ''); -$description_tag = io_safe_input(strip_tags(io_safe_output($description_tag))); +$description_tag = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description_tag')))); $url_tag = (string) get_parameter('url_tag', ''); -$email_tag = (string) get_parameter('email_tag', ''); -$phone_tag = (string) get_parameter('phone_tag', ''); +$email_tag = io_safe_input(strip_tags(io_safe_output(((string) get_parameter('email_tag'))))); +$phone_tag = io_safe_input(strip_tags(io_safe_output(((string) get_parameter('phone_tag'))))); $tab = (string) get_parameter('tab', 'list'); if (defined('METACONSOLE')) { From 73cf98fc02d03b13586f8d5cb77b2c7091b84325 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 9 Jun 2020 10:22:54 +0200 Subject: [PATCH 10/26] Cleaned tags for affected fields --- 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 96f266fc1e..b7d23fbb7d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1212,8 +1212,8 @@ function config_update_config() // -------------------------------------------------- // CUSTOM VALUES POST PROCESS // -------------------------------------------------- - $custom_value = get_parameter('custom_value'); - $custom_text = get_parameter('custom_text'); + $custom_value = io_safe_input(strip_tags(io_safe_output(get_parameter('custom_value')))); + $custom_text = io_safe_input(strip_tags(io_safe_output(get_parameter('custom_text')))); $custom_value_add = (bool) get_parameter('custom_value_add', 0); $custom_value_to_delete = get_parameter('custom_value_to_delete', 0); @@ -1284,8 +1284,8 @@ function config_update_config() // -------------------------------------------------- // MODULE CUSTOM UNITS // -------------------------------------------------- - $custom_unit = get_parameter('custom_module_unit'); - $custom_unit_to_delete = get_parameter('custom_module_unit_to_delete', ''); + $custom_unit = io_safe_input(strip_tags(io_safe_output(get_parameter('custom_module_unit')))); + $custom_unit_to_delete = io_safe_input(strip_tags(io_safe_output(get_parameter('custom_module_unit_to_delete', '')))); if (!empty($custom_unit)) { if (!add_custom_module_unit( From cfe30d5b7d5431141b211fa8666bde6fe7f8b4cf Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 9 Jun 2020 10:37:11 +0200 Subject: [PATCH 11/26] fixed vulnerability on special days --- .../godmode/alerts/alert_special_days.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index 7dd02c28bd..d3f2c41ed1 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -118,6 +118,10 @@ if ($create_special_day) { $values['id_group'] = (string) get_parameter('id_group'); $values['description'] = (string) get_parameter('description'); + $aviable_description = true; + if (preg_match('