From 6e1fb2f0613a1cd2b1f4d223d0784bdf37560929 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Feb 2024 17:17:17 +0100 Subject: [PATCH] #12695 wip removing warnings --- .../godmode/agentes/configure_field.php | 6 ++- pandora_console/godmode/setup/demo.php | 4 ++ .../include/ajax/demo_data.ajax.php | 40 ++++++++++++++++--- pandora_console/include/class/Tree.class.php | 16 ++++++++ .../include/class/TreeGroup.class.php | 4 ++ .../include/functions_groupview.php | 2 +- pandora_console/include/functions_modules.php | 8 ++++ pandora_console/include/functions_ui.php | 4 ++ .../operation/agentes/estado_agente.php | 4 ++ .../operation/agentes/group_view.php | 7 +++- pandora_console/operation/events/events.php | 24 ++++++----- 11 files changed, 98 insertions(+), 21 deletions(-) diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 904b807bbd..44332487ce 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -55,7 +55,7 @@ if ($id_field) { $display_on_front = $field['display_on_front']; $is_password_type = $field['is_password_type']; $combo_values = $field['combo_values'] ? $field['combo_values'] : ''; - $is_combo_enable = $config['is_combo_enable']; + $is_combo_enable = (isset($config['is_combo_enable']) === true) ? $config['is_combo_enable'] : false; $is_link_enabled = $field['is_link_enabled']; $header_title = __('Update agent custom field'); } else { @@ -162,6 +162,10 @@ $table->data[2][0] = html_print_label_input_block( ) ); +if (isset($config['is_combo_enable']) === false) { + $config['is_combo_enable'] = false; +} + $table->data[2][1] = html_print_label_input_block( __('Enabled combo'), html_print_checkbox_switch_extended( diff --git a/pandora_console/godmode/setup/demo.php b/pandora_console/godmode/setup/demo.php index 62446d48a2..b64a6d7f6d 100644 --- a/pandora_console/godmode/setup/demo.php +++ b/pandora_console/godmode/setup/demo.php @@ -116,6 +116,10 @@ if ($display_loading === true || $running_create === true || $running_delete) { $table_load->size = []; $table_load->size[0] = '50%'; $table_load->size[1] = '50%'; + $list_mkup = ''; + if (isset($operation['id']) === false) { + $operation['id'] = 0; + } $table_load->data['row0'][] = progress_bar( 0, diff --git a/pandora_console/include/ajax/demo_data.ajax.php b/pandora_console/include/ajax/demo_data.ajax.php index 5d9e1ee6b8..6d6e7eccd4 100644 --- a/pandora_console/include/ajax/demo_data.ajax.php +++ b/pandora_console/include/ajax/demo_data.ajax.php @@ -186,9 +186,9 @@ if ($action === 'create_demo_data') { } $modules_data = $ini_agent_data['modules']; - $inventory = $ini_agent_data['inventory']; - $inventory_values = $ini_agent_data['inventory_values']; - $traps = $ini_agent_data['traps']; + $inventory = (isset($ini_agent_data['inventory']) === true) ? $ini_agent_data['inventory'] : ''; + $inventory_values = (isset($ini_agent_data['inventory_values']) === true) ? $ini_agent_data['inventory_values'] : ''; + $traps = (isset($ini_agent_data['traps']) === true) ? $ini_agent_data['traps'] : ''; $address_network = $agent_data['address_network']; @@ -435,11 +435,15 @@ if ($action === 'create_demo_data') { $module_description = ''; if (isset($modules_array['description']) === true && is_string($modules_array['description']) === true) { + if (isset($mac) === false) { + $mac = ''; + } + $module_description = str_replace('_mac_', $mac, $modules_array['description']); } $values = [ - 'unit' => $modules_array['unit'], + 'unit' => (isset($modules_array['unit']) === true) ? $modules_array['unit'] : '', 'descripcion' => $module_description, 'id_tipo_modulo' => $id_tipo, 'id_module_group' => ($modules_array['group'] ?? 0), @@ -597,8 +601,12 @@ if ($action === 'create_demo_data') { while (1) { // Insert in tmodule_inventory. $modules_array = []; - foreach ($inventory as $key => $value) { - $modules_array[$key] = ($value[$module_access_idx] ?? null); + if (isset($inventory) === true) { + if ($inventory !== '') { + foreach ($inventory as $key => $value) { + $modules_array[$key] = ($value[$module_access_idx] ?? null); + } + } } $module_access_idx++; @@ -3307,6 +3315,26 @@ if ($action === 'create_demo_data') { $module_values['module_interval'] = $interval; $module_values['id_modulo'] = 4; $module_values['id_plugin'] = $created_plugin_id; + if (isset($traps_target_ip) === false) { + $traps_target_ip = ''; + } + + if (isset($traps_community) === false) { + $traps_community = ''; + } + + if (isset($tentacle_target_ip) === false) { + $tentacle_target_ip = ''; + } + + if (isset($tentacle_port) === false) { + $tentacle_port = ''; + } + + if (isset($tentacle_extra_options) === false) { + $tentacle_extra_options = ''; + } + $module_values['macros'] = '{"1":{"macro":"_field1_","desc":"Agents files folder path","help":"","value":"/usr/share/pandora_server/util/plugin/demodata_agents","hide":""},"2":{"macro":"_field2_","desc":"Number of agents","help":"","value":"'.$total_agents_to_create.'","hide":""},"3":{"macro":"_field3_","desc":"Traps target IP","help":"","value":"'.$traps_target_ip.'","hide":""},"4":{"macro":"_field4_","desc":"Traps community","help":"","value":"'.$traps_community.'","hide":""},"5":{"macro":"_field5_","desc":"Tentacle target IP","help":"","value":"'.$tentacle_target_ip.'","hide":""},"6":{"macro":"_field6_","desc":"Tentacle port","help":"","value":"'.$tentacle_port.'","hide":""},"7":{"macro":"_field7_","desc":"Tentacle extra options","help":"","value":"'.$tentacle_extra_options.'","hide":""}}'; $id_plugin_module = modules_create_agent_module( diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index ed515dee87..e7481fb5f7 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -738,6 +738,22 @@ class Tree if ($module['showGraphs']) { $tresholds = true; + if (isset($module['min_warning']) === false) { + $module['min_warning'] = ''; + } + + if (isset($module['max_warning']) === false) { + $module['max_warning'] = ''; + } + + if (isset($module['min_critical']) === false) { + $module['min_critical'] = ''; + } + + if (isset($module['max_critical']) === false) { + $module['max_critical'] = ''; + } + if (empty((float) $module['min_warning']) === true && empty((float) $module['max_warning']) === true && empty($module['warning_inverse']) === true diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index 55536fe279..520748bb69 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -621,6 +621,10 @@ class TreeGroup extends Tree protected function getDisplayHierarchy() { + if (isset($this->filter['searchHirearchy']) === false) { + $this->filter['searchHirearchy'] = ''; + } + return $this->filter['searchHirearchy'] || (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); } diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index b96701ab28..7ababa9b95 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -196,7 +196,7 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat $list[$id_group]['_monitors_not_init_'] = (int) $modules_counters[$id_group]['total_module_not_init']; $list[$id_group]['_monitors_ok_'] = (int) $modules_counters[$id_group]['total_module_normal']; $list[$id_group]['_monitor_checks_'] = (int) $modules_counters[$id_group]['total_module']; - $list[$id_group]['_monitor_not_normal_'] = ($list[$group['id_grupo']]['_monitor_checks_'] - $list[$group['id_grupo']]['_monitors_ok_']); + $list[$id_group]['_monitor_not_normal_'] = ($modules_counters[$id_group]['total_module'] - $modules_counters[$id_group]['total_module_normal']); $list[$id_group]['_monitors_alerts_fired_'] = (int) $modules_counters[$id_group]['total_module_alerts']; } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 2d3b5676ec..0ab26ed1c1 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2700,6 +2700,14 @@ function modules_get_agentmodule_data_for_humans($module) if ($data_macro !== false) { $salida = $data_macro; } else { + if (isset($module['current_interval']) === false) { + $module['current_interval'] = 0; + } + + if (isset($module['module_name']) === false) { + $module['module_name'] = 0; + } + $salida = ui_print_module_string_value( $module['datos'], empty($module['id']) ? $module['id_agente_modulo'] : $module['id'], diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index bcf23c6d71..3c89cdda6a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6764,6 +6764,10 @@ function ui_print_module_string_value( $value = io_safe_input($value); } + if (isset($module) === false) { + $module['datos'] = ''; + } + $is_snapshot = is_snapshot_data($module['datos']); $is_large_image = is_text_to_black_string($module['datos']); if (($config['command_snapshot']) && ($is_snapshot || $is_large_image)) { diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index d3543b0a7c..8a392f1306 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -206,6 +206,10 @@ if ($load_filter_id > 0) { $loaded_filter = db_get_row_sql($sql); } +if (isset($loaded_filter) === false) { + $loaded_filter['id_filter'] = 0; +} + if ($loaded_filter['id_filter'] > 0) { $query_filter['id_filter'] = $load_filter_id; $filter = db_get_row_filter('tagent_filter', $query_filter, false); diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index c7bca5635a..d9b7b04368 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -80,8 +80,7 @@ if ($config['realtimestats'] == 0) { $updated_time .= __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true); $updated_time .= ''; } else { - // $updated_info = __("Updated at realtime"); - $updated_info = ''; + $updated_time = ''; } // Header. @@ -211,6 +210,10 @@ if ($count == 1) { } } +if (isset($offset) === false) { + $offset = 0; +} + if (empty($result_groups) === false) { $pagination = ui_pagination( $count, diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index f42d889c5f..192a89b539 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -962,17 +962,19 @@ if (is_ajax() === true) { $tmp->id_grupo = $tmp->group_name; } - if (strlen($tmp->id_grupo) >= 10) { - $tmp->id_grupo = ui_print_truncate_text( - $tmp->id_grupo, - 10, - false, - true, - false, - '…', - true, - true, - ); + if (isset($tmp->id_grupo) === true) { + if (strlen($tmp->id_grupo) >= 10) { + $tmp->id_grupo = ui_print_truncate_text( + $tmp->id_grupo, + 10, + false, + true, + false, + '…', + true, + true, + ); + } } // Module name.