From 021fc1dbfdd27576acd49805fa0d4895d78e0b93 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 9 Apr 2019 10:46:37 +0200 Subject: [PATCH 1/2] Fixed bug in unlinked modules Former-commit-id: 08279c7f8605b54ae7ecaba32cc7d3c501b3ad5f --- .../godmode/agentes/configurar_agente.php | 216 +++++++++--------- 1 file changed, 113 insertions(+), 103 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 74a5c3dc9f..6976d103c1 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -11,7 +11,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Load global vars +// Load global vars. global $config; enterprise_include('godmode/agentes/configurar_agente.php'); @@ -23,10 +23,10 @@ ui_require_javascript_file('encode_decode_base64'); check_login(); -// Get tab parameter to check ACL in each tabs +// Get tab parameter to check ACL in each tabs. $tab = get_parameter('tab', 'main'); -// See if id_agente is set (either POST or GET, otherwise -1 +// See if id_agente is set (either POST or GET, otherwise -1. $id_agente = (int) get_parameter('id_agente'); $group = 0; $all_groups = [$group]; @@ -46,6 +46,7 @@ if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { break; default: + // Default. break; } @@ -63,11 +64,11 @@ require_once 'include/functions_modules.php'; require_once 'include/functions_alerts.php'; require_once 'include/functions_reporting.php'; -// Get passed variables +// Get passed variables. $alerttype = get_parameter('alerttype'); $id_agent_module = (int) get_parameter('id_agent_module'); -// Init vars +// Init vars. $descripcion = ''; $comentarios = ''; $campo_1 = ''; @@ -137,7 +138,7 @@ $alert_priority = 0; $server_name = ''; $grupo = 0; $id_os = 9; -// Windows +// Windows. $custom_id = ''; $cascade_protection = 0; $cascade_protection_modules = 0; @@ -156,7 +157,7 @@ $cps = 0; $create_agent = (bool) get_parameter('create_agent'); $module_macros = []; -// Create agent +// Create agent. if ($create_agent) { $mssg_warning = 0; $alias_safe_output = io_safe_output(get_parameter('alias', '')); @@ -165,14 +166,14 @@ if ($create_agent) { $direccion_agente = (string) get_parameter_post('direccion', ''); $unique_ip = (int) get_parameter_post('unique_ip', 0); - // safe_output only validate ip + // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); if (!validate_address($direccion_agente)) { $mssg_warning = 1; } - // safe-input before validate ip + // Safe-input before validate ip. $direccion_agente = io_safe_input($direccion_agente); $nombre_agente = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); @@ -208,7 +209,7 @@ if ($create_agent) { $field_values[$field['id_field']] = (string) get_parameter_post('customvalue_'.$field['id_field'], ''); } - // Check if agent exists (BUG WC-50518-2) + // Check if agent exists (BUG WC-50518-2). if ($alias == '') { $agent_creation_error = __('No agent alias specified'); $agent_created_ok = 0; @@ -256,7 +257,7 @@ if ($create_agent) { } if ($id_agente !== false) { - // Create custom fields for this agent + // Create custom fields for this agent. foreach ($field_values as $key => $value) { $update_custom = db_process_sql_insert( 'tagent_custom_data', @@ -268,7 +269,7 @@ if ($create_agent) { ); } - // Create address for this agent in taddress + // Create address for this agent in taddress. if ($direccion_agente != '') { agents_add_address($id_agente, $direccion_agente); } @@ -311,7 +312,7 @@ if ($create_agent) { "Quiet":"'.(int) $quiet.'", "Cps":"'.(int) $cps.'"}'; - // Create the secondary groups + // Create the secondary groups. enterprise_hook( 'agents_update_secondary_groups', [ @@ -341,14 +342,14 @@ if ($create_agent) { } } -// Show tabs +// Show tabs. $img_style = [ 'class' => 'top', 'width' => 16, ]; if ($id_agente) { - // View tab + // View tab. $viewtab['text'] = ''.html_print_image('images/operation.png', true, ['title' => __('View')]).''; if ($tab == 'view') { @@ -359,7 +360,7 @@ if ($id_agente) { $viewtab['operation'] = 1; - // Main tab + // Main tab. $maintab['text'] = ''.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).''; if ($tab == 'main') { $maintab['active'] = true; @@ -367,7 +368,7 @@ if ($id_agente) { $maintab['active'] = false; } - // Module tab + // Module tab. $moduletab['text'] = ''.html_print_image('images/gm_modules.png', true, ['title' => __('Modules')]).''; if ($tab == 'module') { @@ -376,7 +377,7 @@ if ($id_agente) { $moduletab['active'] = false; } - // Alert tab + // Alert tab. $alerttab['text'] = ''.html_print_image('images/gm_alerts.png', true, ['title' => __('Alerts')]).''; if ($tab == 'alert') { @@ -385,7 +386,7 @@ if ($id_agente) { $alerttab['active'] = false; } - // Template tab + // Template tab. $templatetab['text'] = ''.html_print_image('images/templates.png', true, ['title' => __('Module templates')]).''; if ($tab == 'template') { @@ -395,7 +396,7 @@ if ($id_agente) { } - // Inventory + // Inventory. $inventorytab = enterprise_hook('inventory_tab'); if ($inventorytab == -1) { @@ -412,7 +413,7 @@ if ($id_agente) { } if ($has_remote_conf === true) { - // Plugins + // Plugins. $pluginstab = enterprise_hook('plugins_tab'); if ($pluginstab == -1) { $pluginstab = ''; @@ -421,21 +422,21 @@ if ($id_agente) { $pluginstab = ''; } - // Collection + // Collection. $collectiontab = enterprise_hook('collection_tab'); if ($collectiontab == -1) { $collectiontab = ''; } - // Group tab + // Group tab. $grouptab['text'] = ''.html_print_image('images/group.png', true, [ 'title' => __('Group')]).''; $grouptab['active'] = false; $gistab = []; - // GIS tab + // GIS tab. if ($config['activate_gis']) { $gistab['text'] = ''.html_print_image('images/gm_gis.png', true, [ 'title' => __('GIS data')]).''; @@ -446,10 +447,10 @@ if ($id_agente) { } } - // Agent wizard tab + // Agent wizard tab. $agent_wizard['text'] = ''.html_print_image('images/wand_agent.png', true, [ 'title' => __('Agent wizard')]).''; - // Hidden subtab layer + // Hidden subtab layer. $agent_wizard['sub_menu'] = '