Removed autofill proxi in auth server

Former-commit-id: 448622c39e6697ead1a3a515da3e573abfc0384d
This commit is contained in:
manuel 2019-04-16 12:37:06 +02:00
parent 8bf92720ee
commit bac1e44608
2 changed files with 113 additions and 91 deletions

View File

@ -23,10 +23,10 @@ ui_require_javascript_file('encode_decode_base64');
check_login(); 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'); $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'); $id_agente = (int) get_parameter('id_agente');
$group = 0; $group = 0;
$all_groups = [$group]; $all_groups = [$group];
@ -46,6 +46,7 @@ if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
break; break;
default: default:
// Default.
break; break;
} }
@ -63,11 +64,11 @@ require_once 'include/functions_modules.php';
require_once 'include/functions_alerts.php'; require_once 'include/functions_alerts.php';
require_once 'include/functions_reporting.php'; require_once 'include/functions_reporting.php';
// Get passed variables // Get passed variables.
$alerttype = get_parameter('alerttype'); $alerttype = get_parameter('alerttype');
$id_agent_module = (int) get_parameter('id_agent_module'); $id_agent_module = (int) get_parameter('id_agent_module');
// Init vars // Init vars.
$descripcion = ''; $descripcion = '';
$comentarios = ''; $comentarios = '';
$campo_1 = ''; $campo_1 = '';
@ -137,7 +138,7 @@ $alert_priority = 0;
$server_name = ''; $server_name = '';
$grupo = 0; $grupo = 0;
$id_os = 9; $id_os = 9;
// Windows // Windows.
$custom_id = ''; $custom_id = '';
$cascade_protection = 0; $cascade_protection = 0;
$cascade_protection_modules = 0; $cascade_protection_modules = 0;
@ -156,7 +157,7 @@ $cps = 0;
$create_agent = (bool) get_parameter('create_agent'); $create_agent = (bool) get_parameter('create_agent');
$module_macros = []; $module_macros = [];
// Create agent // Create agent.
if ($create_agent) { if ($create_agent) {
$mssg_warning = 0; $mssg_warning = 0;
$alias_safe_output = io_safe_output(get_parameter('alias', '')); $alias_safe_output = io_safe_output(get_parameter('alias', ''));
@ -165,14 +166,14 @@ if ($create_agent) {
$direccion_agente = (string) get_parameter_post('direccion', ''); $direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0); $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)); $direccion_agente = trim(io_safe_output($direccion_agente));
if (!validate_address($direccion_agente)) { if (!validate_address($direccion_agente)) {
$mssg_warning = 1; $mssg_warning = 1;
} }
// safe-input before validate ip // Safe-input before validate ip.
$direccion_agente = io_safe_input($direccion_agente); $direccion_agente = io_safe_input($direccion_agente);
$nombre_agente = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); $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'], ''); $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 == '') { if ($alias == '') {
$agent_creation_error = __('No agent alias specified'); $agent_creation_error = __('No agent alias specified');
$agent_created_ok = 0; $agent_created_ok = 0;
@ -256,7 +257,7 @@ if ($create_agent) {
} }
if ($id_agente !== false) { if ($id_agente !== false) {
// Create custom fields for this agent // Create custom fields for this agent.
foreach ($field_values as $key => $value) { foreach ($field_values as $key => $value) {
$update_custom = db_process_sql_insert( $update_custom = db_process_sql_insert(
'tagent_custom_data', '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 != '') { if ($direccion_agente != '') {
agents_add_address($id_agente, $direccion_agente); agents_add_address($id_agente, $direccion_agente);
} }
@ -311,7 +312,7 @@ if ($create_agent) {
"Quiet":"'.(int) $quiet.'", "Quiet":"'.(int) $quiet.'",
"Cps":"'.(int) $cps.'"}'; "Cps":"'.(int) $cps.'"}';
// Create the secondary groups // Create the secondary groups.
enterprise_hook( enterprise_hook(
'agents_update_secondary_groups', 'agents_update_secondary_groups',
[ [
@ -341,14 +342,14 @@ if ($create_agent) {
} }
} }
// Show tabs // Show tabs.
$img_style = [ $img_style = [
'class' => 'top', 'class' => 'top',
'width' => 16, 'width' => 16,
]; ];
if ($id_agente) { if ($id_agente) {
// View tab // View tab.
$viewtab['text'] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>'; $viewtab['text'] = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>';
if ($tab == 'view') { if ($tab == 'view') {
@ -359,7 +360,7 @@ if ($id_agente) {
$viewtab['operation'] = 1; $viewtab['operation'] = 1;
// Main tab // Main tab.
$maintab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).'</a>'; $maintab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=main&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).'</a>';
if ($tab == 'main') { if ($tab == 'main') {
$maintab['active'] = true; $maintab['active'] = true;
@ -367,7 +368,7 @@ if ($id_agente) {
$maintab['active'] = false; $maintab['active'] = false;
} }
// Module tab // Module tab.
$moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_modules.png', true, ['title' => __('Modules')]).'</a>'; $moduletab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=module&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_modules.png', true, ['title' => __('Modules')]).'</a>';
if ($tab == 'module') { if ($tab == 'module') {
@ -376,7 +377,7 @@ if ($id_agente) {
$moduletab['active'] = false; $moduletab['active'] = false;
} }
// Alert tab // Alert tab.
$alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_alerts.png', true, ['title' => __('Alerts')]).'</a>'; $alerttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=alert&amp;id_agente='.$id_agente.'">'.html_print_image('images/gm_alerts.png', true, ['title' => __('Alerts')]).'</a>';
if ($tab == 'alert') { if ($tab == 'alert') {
@ -385,7 +386,7 @@ if ($id_agente) {
$alerttab['active'] = false; $alerttab['active'] = false;
} }
// Template tab // Template tab.
$templatetab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">'.html_print_image('images/templates.png', true, ['title' => __('Module templates')]).'</a>'; $templatetab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">'.html_print_image('images/templates.png', true, ['title' => __('Module templates')]).'</a>';
if ($tab == 'template') { if ($tab == 'template') {
@ -395,7 +396,7 @@ if ($id_agente) {
} }
// Inventory // Inventory.
$inventorytab = enterprise_hook('inventory_tab'); $inventorytab = enterprise_hook('inventory_tab');
if ($inventorytab == -1) { if ($inventorytab == -1) {
@ -412,7 +413,7 @@ if ($id_agente) {
} }
if ($has_remote_conf === true) { if ($has_remote_conf === true) {
// Plugins // Plugins.
$pluginstab = enterprise_hook('plugins_tab'); $pluginstab = enterprise_hook('plugins_tab');
if ($pluginstab == -1) { if ($pluginstab == -1) {
$pluginstab = ''; $pluginstab = '';
@ -421,21 +422,21 @@ if ($id_agente) {
$pluginstab = ''; $pluginstab = '';
} }
// Collection // Collection.
$collectiontab = enterprise_hook('collection_tab'); $collectiontab = enterprise_hook('collection_tab');
if ($collectiontab == -1) { if ($collectiontab == -1) {
$collectiontab = ''; $collectiontab = '';
} }
// Group tab // Group tab.
$grouptab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">'.html_print_image('images/group.png', true, [ 'title' => __('Group')]).'</a>'; $grouptab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group.'">'.html_print_image('images/group.png', true, [ 'title' => __('Group')]).'</a>';
$grouptab['active'] = false; $grouptab['active'] = false;
$gistab = []; $gistab = [];
// GIS tab // GIS tab.
if ($config['activate_gis']) { if ($config['activate_gis']) {
$gistab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente.'">'.html_print_image('images/gm_gis.png', true, [ 'title' => __('GIS data')]).'</a>'; $gistab['text'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente.'">'.html_print_image('images/gm_gis.png', true, [ 'title' => __('GIS data')]).'</a>';
@ -446,10 +447,10 @@ if ($id_agente) {
} }
} }
// Agent wizard tab // Agent wizard tab.
$agent_wizard['text'] = '<a href="javascript:" class="agent_wizard_tab">'.html_print_image('images/wand_agent.png', true, [ 'title' => __('Agent wizard')]).'</a>'; $agent_wizard['text'] = '<a href="javascript:" class="agent_wizard_tab">'.html_print_image('images/wand_agent.png', true, [ 'title' => __('Agent wizard')]).'</a>';
// Hidden subtab layer // Hidden subtab layer.
$agent_wizard['sub_menu'] = '<ul class="mn subsubmenu" style="display:none; float:none;">'; $agent_wizard['sub_menu'] = '<ul class="mn subsubmenu" style="display:none; float:none;">';
$agent_wizard['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">'; $agent_wizard['sub_menu'] .= '<li class="nomn tab_godmode" style="text-align: center;">';
$agent_wizard['sub_menu'] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente='.$id_agente.'">'.html_print_image('images/wand_snmp.png', true, [ 'title' => __('SNMP Wizard')]).'</a>'; $agent_wizard['sub_menu'] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=agent_wizard&wizard_section=snmp_explorer&id_agente='.$id_agente.'">'.html_print_image('images/wand_snmp.png', true, [ 'title' => __('SNMP Wizard')]).'</a>';
@ -471,7 +472,7 @@ if ($id_agente) {
$total_incidents = agents_get_count_incidents($id_agente); $total_incidents = agents_get_count_incidents($id_agente);
// Incident tab // Incident tab.
if ($total_incidents > 0) { if ($total_incidents > 0) {
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">'.html_print_image('images/book_edit.png', true, ['title' => __('Incidents')]).'</a>'; $incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">'.html_print_image('images/book_edit.png', true, ['title' => __('Incidents')]).'</a>';
@ -532,7 +533,7 @@ if ($id_agente) {
]; ];
} }
// Only if the agent has incidents associated show incidents tab // Only if the agent has incidents associated show incidents tab.
if ($total_incidents) { if ($total_incidents) {
$onheader['incident'] = $incidenttab; $onheader['incident'] = $incidenttab;
} }
@ -545,7 +546,7 @@ if ($id_agente) {
]; ];
} }
// Extensions tabs // Extensions tabs.
foreach ($config['extensions'] as $extension) { foreach ($config['extensions'] as $extension) {
if (isset($extension['extension_god_tab'])) { if (isset($extension['extension_god_tab'])) {
if (check_acl($config['id_user'], $group, $extension['extension_god_tab']['acl'])) { if (check_acl($config['id_user'], $group, $extension['extension_god_tab']['acl'])) {
@ -574,7 +575,7 @@ if ($id_agente) {
} }
$help_header = ''; $help_header = '';
// This add information to the header // This add information to the header.
switch ($tab) { switch ($tab) {
case 'main': case 'main':
$tab_description = '- '.__('Setup'); $tab_description = '- '.__('Setup');
@ -639,6 +640,10 @@ if ($id_agente) {
case 'wmi_explorer': case 'wmi_explorer':
$tab_description = '- '.__('WMI Wizard'); $tab_description = '- '.__('WMI Wizard');
break; break;
default:
// Default.
break;
} }
break; break;
@ -649,10 +654,15 @@ if ($id_agente) {
$tab_description = '- '.__('SNMP explorer'); $tab_description = '- '.__('SNMP explorer');
$help_header = 'snmp_explorer'; $help_header = 'snmp_explorer';
break; break;
default:
// Default.
break;
} }
break; break;
default: default:
// Default.
break; break;
} }
@ -668,7 +678,7 @@ if ($id_agente) {
$config['item_title_size_text'] $config['item_title_size_text']
); );
} else { } else {
// Create agent // Create agent.
ui_print_page_header( ui_print_page_header(
__('Agent manager'), __('Agent manager'),
'images/bricks.png', 'images/bricks.png',
@ -682,12 +692,12 @@ $delete_conf_file = (bool) get_parameter('delete_conf_file');
if ($delete_conf_file) { if ($delete_conf_file) {
$correct = false; $correct = false;
// Delete remote configuration // Delete remote configuration.
if (isset($config['remote_config'])) { if (isset($config['remote_config'])) {
$agent_md5 = md5(io_safe_output(agents_get_name($id_agente, 'none')), false); $agent_md5 = md5(io_safe_output(agents_get_name($id_agente, 'none')), false);
if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) { if (file_exists($config['remote_config'].'/md5/'.$agent_md5.'.md5')) {
// Agent remote configuration editor // Agent remote configuration editor.
$file_name = $config['remote_config'].'/conf/'.$agent_md5.'.conf'; $file_name = $config['remote_config'].'/conf/'.$agent_md5.'.conf';
$correct = @unlink($file_name); $correct = @unlink($file_name);
@ -703,7 +713,7 @@ if ($delete_conf_file) {
); );
} }
// Show agent creation results // Show agent creation results.
if ($create_agent) { if ($create_agent) {
if (!isset($agent_creation_error)) { if (!isset($agent_creation_error)) {
$agent_creation_error = __('Could not be created'); $agent_creation_error = __('Could not be created');
@ -720,17 +730,17 @@ if ($create_agent) {
} }
} }
// Fix / Normalize module data // Fix / Normalize module data.
if (isset($_GET['fix_module'])) { if (isset($_GET['fix_module'])) {
$id_module = get_parameter_get('fix_module', 0); $id_module = get_parameter_get('fix_module', 0);
// get info about this module // Get info about this module.
$media = reporting_get_agentmodule_data_average($id_module, 30758400); $media = reporting_get_agentmodule_data_average($id_module, 30758400);
// Get average over the year // Get average over the year.
$media *= 1.3; $media *= 1.3;
$error = ''; $error = '';
$result = true; $result = true;
// If the value of media is 0 or something went wrong, don't delete // If the value of media is 0 or something went wrong, don't delete.
if (!empty($media)) { if (!empty($media)) {
$where = [ $where = [
'datos' => '>'.$media, 'datos' => '>'.$media,
@ -759,9 +769,9 @@ if (isset($_GET['fix_module'])) {
$update_agent = (bool) get_parameter('update_agent'); $update_agent = (bool) get_parameter('update_agent');
// Update AGENT // Update AGENT.
if ($update_agent) { if ($update_agent) {
// if modified some agent paramenter // If modified some agent paramenter.
$mssg_warning = 0; $mssg_warning = 0;
$id_agente = (int) get_parameter_post('id_agente'); $id_agente = (int) get_parameter_post('id_agente');
$nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', '')); $nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', ''));
@ -770,14 +780,14 @@ if ($update_agent) {
$alias_as_name = (int) get_parameter_post('alias_as_name', 0); $alias_as_name = (int) get_parameter_post('alias_as_name', 0);
$direccion_agente = (string) get_parameter_post('direccion', ''); $direccion_agente = (string) get_parameter_post('direccion', '');
$unique_ip = (int) get_parameter_post('unique_ip', 0); $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)); $direccion_agente = trim(io_safe_output($direccion_agente));
if (!validate_address($direccion_agente)) { if (!validate_address($direccion_agente)) {
$mssg_warning = 1; $mssg_warning = 1;
} }
// safe-input before validate ip // Safe-input before validate ip.
$direccion_agente = io_safe_input($direccion_agente); $direccion_agente = io_safe_input($direccion_agente);
$address_list = (string) get_parameter_post('address_list', ''); $address_list = (string) get_parameter_post('address_list', '');
@ -789,7 +799,7 @@ if ($update_agent) {
// If we selected another IP in the drop down list to be 'primary': // If we selected another IP in the drop down list to be 'primary':
// a) field is not the same as selectbox // a) field is not the same as selectbox
// b) field has not changed from current IP // b) field has not changed from current IP
// c) selectbox is not the current IP // c) selectbox is not the current IP.
if (!empty($address_list)) { if (!empty($address_list)) {
$direccion_agente = $address_list; $direccion_agente = $address_list;
} }
@ -799,7 +809,7 @@ if ($update_agent) {
$intervalo = (int) get_parameter_post('intervalo', SECONDS_5MINUTES); $intervalo = (int) get_parameter_post('intervalo', SECONDS_5MINUTES);
$comentarios = str_replace('`', '&lsquo;', (string) get_parameter_post('comentarios', '')); $comentarios = str_replace('`', '&lsquo;', (string) get_parameter_post('comentarios', ''));
$modo = (int) get_parameter_post('modo', 0); $modo = (int) get_parameter_post('modo', 0);
// Mode: Learning, Normal or Autodisabled // Mode: Learning, Normal or Autodisabled.
$id_os = (int) get_parameter_post('id_os'); $id_os = (int) get_parameter_post('id_os');
$disabled = (bool) get_parameter_post('disabled'); $disabled = (bool) get_parameter_post('disabled');
$server_name = (string) get_parameter_post('server_name', ''); $server_name = (string) get_parameter_post('server_name', '');
@ -837,7 +847,7 @@ if ($update_agent) {
); );
if ($old_value === false) { if ($old_value === false) {
// Create custom field if not exist // Create custom field if not exist.
$update_custom = db_process_sql_insert( $update_custom = db_process_sql_insert(
'tagent_custom_data', 'tagent_custom_data',
[ [
@ -866,10 +876,10 @@ if ($update_agent) {
ui_print_warning_message(__('The ip or dns name entered cannot be resolved')); ui_print_warning_message(__('The ip or dns name entered cannot be resolved'));
} }
// Verify if there is another agent with the same name but different ID // Verify if there is another agent with the same name but different ID.
if ($alias == '') { if ($alias == '') {
ui_print_error_message(__('No agent alias specified')); ui_print_error_message(__('No agent alias specified'));
// If there is an agent with the same name, but a different ID // If there is an agent with the same name, but a different ID.
} }
if ($unique_ip && $direccion_agente != '') { if ($unique_ip && $direccion_agente != '') {
@ -882,7 +892,7 @@ if ($update_agent) {
} else if ($exists_ip) { } else if ($exists_ip) {
ui_print_error_message(__('Duplicate main IP address')); ui_print_error_message(__('Duplicate main IP address'));
} else { } else {
// If different IP is specified than previous, add the IP // If different IP is specified than previous, add the IP.
if ($direccion_agente != '' if ($direccion_agente != ''
&& $direccion_agente != agents_get_address($id_agente) && $direccion_agente != agents_get_address($id_agente)
) { ) {
@ -890,7 +900,7 @@ if ($update_agent) {
} }
$action_delete_ip = (bool) get_parameter('delete_ip', false); $action_delete_ip = (bool) get_parameter('delete_ip', false);
// If IP is set for deletion, delete first // If IP is set for deletion, delete first.
if ($action_delete_ip) { if ($action_delete_ip) {
$delete_ip = get_parameter_post('address_list'); $delete_ip = get_parameter_post('address_list');
@ -939,11 +949,11 @@ if ($update_agent) {
__('There was a problem updating the agent') __('There was a problem updating the agent')
); );
} else { } else {
// Update the agent from the metaconsole cache // Update the agent from the metaconsole cache.
enterprise_include_once('include/functions_agents.php'); enterprise_include_once('include/functions_agents.php');
enterprise_hook('agent_update_from_cache', [$id_agente, $values, $server_name]); enterprise_hook('agent_update_from_cache', [$id_agente, $values, $server_name]);
// Update the configuration files // Update the configuration files.
if ($old_values['intervalo'] != $intervalo) { if ($old_values['intervalo'] != $intervalo) {
enterprise_hook( enterprise_hook(
'config_agents_update_config_token', 'config_agents_update_config_token',
@ -1057,9 +1067,9 @@ if ($update_agent) {
} }
// Read agent data // Read agent data
// This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved // This should be at the end of all operation checks, to read the changes - $id_agente doesn't have to be retrieved.
if ($id_agente) { if ($id_agente) {
// This has been done in the beginning of the page, but if an agent was created, this id might change // This has been done in the beginning of the page, but if an agent was created, this id might change.
$id_grupo = agents_get_agent_group($id_agente); $id_grupo = agents_get_agent_group($id_agente);
if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') && !check_acl_one_of_groups($config['id_user'], $all_groups, 'AD')) { if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') && !check_acl_one_of_groups($config['id_user'], $all_groups, 'AD')) {
db_pandora_audit('ACL Violation', 'Trying to admin an agent without access'); db_pandora_audit('ACL Violation', 'Trying to admin an agent without access');
@ -1069,13 +1079,13 @@ if ($id_agente) {
$agent = db_get_row('tagente', 'id_agente', $id_agente); $agent = db_get_row('tagente', 'id_agente', $id_agente);
if (empty($agent)) { if (empty($agent)) {
// Close out the page // Close out the page.
ui_print_error_message(__('There was a problem loading the agent')); ui_print_error_message(__('There was a problem loading the agent'));
return; return;
} }
$intervalo = $agent['intervalo']; $intervalo = $agent['intervalo'];
// Define interval in seconds // Define interval in seconds.
$nombre_agente = $agent['nombre']; $nombre_agente = $agent['nombre'];
if (empty($alias)) { if (empty($alias)) {
$alias = $agent['alias']; $alias = $agent['alias'];
@ -1111,11 +1121,11 @@ $create_module = (bool) get_parameter('create_module');
$delete_module = (bool) get_parameter('delete_module'); $delete_module = (bool) get_parameter('delete_module');
$enable_module = (int) get_parameter('enable_module'); $enable_module = (int) get_parameter('enable_module');
$disable_module = (int) get_parameter('disable_module'); $disable_module = (int) get_parameter('disable_module');
// It is the id_agent_module to duplicate // It is the id_agent_module to duplicate.
$duplicate_module = (int) get_parameter('duplicate_module'); $duplicate_module = (int) get_parameter('duplicate_module');
$edit_module = (bool) get_parameter('edit_module'); $edit_module = (bool) get_parameter('edit_module');
// GET DATA for MODULE UPDATE OR MODULE INSERT // GET DATA for MODULE UPDATE OR MODULE INSERT.
if ($update_module || $create_module) { if ($update_module || $create_module) {
$id_grupo = agents_get_agent_group($id_agente); $id_grupo = agents_get_agent_group($id_agente);
$all_groups = agents_get_all_groups_agent($id_agente, $id_grupo); $all_groups = agents_get_all_groups_agent($id_agente, $id_grupo);
@ -1138,7 +1148,7 @@ if ($update_module || $create_module) {
// Don't read as (float) because it lost it's decimals when put into MySQL // Don't read as (float) because it lost it's decimals when put into MySQL
// where are very big and PHP uses scientific notation, p.e: // where are very big and PHP uses scientific notation, p.e:
// 1.23E-10 is 0.000000000123 // 1.23E-10 is 0.000000000123.
$post_process = (string) get_parameter('post_process', 0.0); $post_process = (string) get_parameter('post_process', 0.0);
if (get_parameter('prediction_module')) { if (get_parameter('prediction_module')) {
$prediction_module = 1; $prediction_module = 1;
@ -1160,7 +1170,7 @@ if ($update_module || $create_module) {
$tcp_send = (string) get_parameter('tcp_send'); $tcp_send = (string) get_parameter('tcp_send');
$tcp_rcv = (string) get_parameter('tcp_rcv'); $tcp_rcv = (string) get_parameter('tcp_rcv');
$tcp_port = (int) get_parameter('tcp_port'); $tcp_port = (int) get_parameter('tcp_port');
// Correction in order to not insert 0 as port // Correction in order to not insert 0 as port.
$is_port_empty = get_parameter('tcp_port', ''); $is_port_empty = get_parameter('tcp_port', '');
if ($is_port_empty === '') { if ($is_port_empty === '') {
$tcp_port = null; $tcp_port = null;
@ -1186,7 +1196,7 @@ if ($update_module || $create_module) {
} }
if ($id_module_type == 25) { if ($id_module_type == 25) {
// web analysis, from MODULE_WUX // web analysis, from MODULE_WUX.
$custom_string_1 = base64_encode((string) get_parameter('custom_string_1', $custom_string_1_default)); $custom_string_1 = base64_encode((string) get_parameter('custom_string_1', $custom_string_1_default));
$custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default); $custom_integer_1 = (int) get_parameter('custom_integer_1', $custom_integer_1_default);
} else { } else {
@ -1198,7 +1208,7 @@ if ($update_module || $create_module) {
$custom_string_3 = (string) get_parameter('custom_string_3', $custom_string_3_default); $custom_string_3 = (string) get_parameter('custom_string_3', $custom_string_3_default);
$custom_integer_2 = (int) get_parameter('custom_integer_2', 0); $custom_integer_2 = (int) get_parameter('custom_integer_2', 0);
// Get macros // Get macros.
$macros = (string) get_parameter('macros'); $macros = (string) get_parameter('macros');
if (!empty($macros)) { if (!empty($macros)) {
@ -1225,7 +1235,7 @@ if ($update_module || $create_module) {
if (preg_match('/^module_name\s*(.*)/', $line, $match)) { if (preg_match('/^module_name\s*(.*)/', $line, $match)) {
$new_configuration_data .= 'module_name '.io_safe_output($name)."\n"; $new_configuration_data .= 'module_name '.io_safe_output($name)."\n";
} }
// We delete from conf all the module macros starting with _field // We delete from conf all the module macros starting with _field.
else if (!preg_match('/^module_macro_field.*/', $line, $match)) { else if (!preg_match('/^module_macro_field.*/', $line, $match)) {
$new_configuration_data .= "$line\n"; $new_configuration_data .= "$line\n";
} }
@ -1269,16 +1279,16 @@ if ($update_module || $create_module) {
$snmp_community = (string) get_parameter('snmp_community'); $snmp_community = (string) get_parameter('snmp_community');
$snmp_oid = (string) get_parameter('snmp_oid'); $snmp_oid = (string) get_parameter('snmp_oid');
// Change double quotes by single // Change double quotes by single.
$snmp_oid = preg_replace('/&quot;/', '&#039;', $snmp_oid); $snmp_oid = preg_replace('/&quot;/', '&#039;', $snmp_oid);
if (empty($snmp_oid)) { if (empty($snmp_oid)) {
// The user did not set any OID manually but did a SNMP walk // The user did not set any OID manually but did a SNMP walk.
$snmp_oid = (string) get_parameter('select_snmp_oid'); $snmp_oid = (string) get_parameter('select_snmp_oid');
} }
if ($id_module_type >= 15 && $id_module_type <= 18) { if ($id_module_type >= 15 && $id_module_type <= 18) {
// New support for snmp v3 // New support for snmp v3.
$tcp_send = (string) get_parameter('snmp_version'); $tcp_send = (string) get_parameter('snmp_version');
$plugin_user = (string) get_parameter('snmp3_auth_user'); $plugin_user = (string) get_parameter('snmp3_auth_user');
$plugin_pass = io_input_password((string) get_parameter('snmp3_auth_pass')); $plugin_pass = io_input_password((string) get_parameter('snmp3_auth_pass'));
@ -1300,7 +1310,11 @@ if ($update_module || $create_module) {
$parent_module_id = (int) get_parameter('parent_module_id'); $parent_module_id = (int) get_parameter('parent_module_id');
$ip_target = (string) get_parameter('ip_target'); $ip_target = (string) get_parameter('ip_target');
if ($ip_target == '') { // No autofill if the module is a webserver module.
if ($ip_target == ''
&& $id_module_type < MODULE_WEBSERVER_CHECK_LATENCY
&& $id_module_type > MODULE_WEBSERVER_RETRIEVE_STRING_DATA
) {
$ip_target = 'auto'; $ip_target = 'auto';
} }
@ -1410,7 +1424,7 @@ if ($update_module || $create_module) {
$module_macro_values = (array) get_parameter('module_macro_values', []); $module_macro_values = (array) get_parameter('module_macro_values', []);
$module_macros = modules_get_module_macros_json($module_macro_names, $module_macro_values); $module_macros = modules_get_module_macros_json($module_macro_names, $module_macro_values);
// Make changes in the conf file if necessary // Make changes in the conf file if necessary.
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
$module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]); $module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]);
@ -1431,7 +1445,7 @@ if ($update_module || $create_module) {
} }
} }
// MODULE UPDATE // MODULE UPDATE.
if ($update_module) { if ($update_module) {
$id_agent_module = (int) get_parameter('id_agent_module'); $id_agent_module = (int) get_parameter('id_agent_module');
@ -1517,7 +1531,7 @@ if ($update_module) {
} }
} }
// In local modules, the interval is updated by agent // In local modules, the interval is updated by agent.
$module_kind = (int) get_parameter('moduletype'); $module_kind = (int) get_parameter('moduletype');
if ($module_kind == MODULE_DATA) { if ($module_kind == MODULE_DATA) {
unset($values['module_interval']); unset($values['module_interval']);
@ -1586,7 +1600,7 @@ if ($update_module) {
); );
} }
// Update the module interval // Update the module interval.
cron_update_module_interval($id_agent_module, $cron_interval); cron_update_module_interval($id_agent_module, $cron_interval);
ui_print_success_message(__('Module successfully updated')); ui_print_success_message(__('Module successfully updated'));
@ -1606,7 +1620,7 @@ if ($update_module) {
} }
// MODULE INSERT // MODULE INSERT
// ================= // =================.
if ($create_module) { if ($create_module) {
if (isset($_POST['combo_snmp_oid'])) { if (isset($_POST['combo_snmp_oid'])) {
$combo_snmp_oid = get_parameter_post('combo_snmp_oid'); $combo_snmp_oid = get_parameter_post('combo_snmp_oid');
@ -1619,7 +1633,7 @@ if ($create_module) {
$id_module = (int) get_parameter('id_module'); $id_module = (int) get_parameter('id_module');
// Commented because can't create prediction modules // Commented because can't create prediction modules
/* /*
if ($id_module == 5) { If ($id_module == 5) {
$prediction_module = 1; $prediction_module = 1;
} }
*/ */
@ -1630,6 +1644,10 @@ if ($create_module) {
$description = ' '; $description = ' ';
} }
break; break;
default:
// Default.
break;
} }
$values = [ $values = [
@ -1755,7 +1773,7 @@ if ($create_module) {
enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]); enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]);
} }
// Update the module interval // Update the module interval.
cron_update_module_interval($id_agent_module, $cron_interval); cron_update_module_interval($id_agent_module, $cron_interval);
ui_print_success_message(__('Module added successfully')); ui_print_success_message(__('Module added successfully'));
@ -1776,7 +1794,7 @@ if ($create_module) {
} }
// MODULE DELETION // MODULE DELETION
// ================= // =================.
if ($delete_module) { if ($delete_module) {
// DELETE agent module ! // DELETE agent module !
$id_borrar_modulo = (int) get_parameter_get('delete_module', 0); $id_borrar_modulo = (int) get_parameter_get('delete_module', 0);
@ -1812,7 +1830,7 @@ if ($delete_module) {
enterprise_include_once('include/functions_config_agents.php'); enterprise_include_once('include/functions_config_agents.php');
enterprise_hook('config_agents_delete_module_in_conf', [modules_get_agentmodule_agent($id_borrar_modulo), modules_get_agentmodule_name($id_borrar_modulo)]); enterprise_hook('config_agents_delete_module_in_conf', [modules_get_agentmodule_agent($id_borrar_modulo), modules_get_agentmodule_name($id_borrar_modulo)]);
// Init transaction // Init transaction.
$error = 0; $error = 0;
// First delete from tagente_modulo -> if not successful, increment // First delete from tagente_modulo -> if not successful, increment
@ -1831,7 +1849,7 @@ if ($delete_module) {
if ($result === false) { if ($result === false) {
$error++; $error++;
} else { } else {
// Set flag to update module status count // Set flag to update module status count.
db_process_sql( db_process_sql(
'UPDATE tagente 'UPDATE tagente
SET update_module_count = 1, update_alert_count = 1 SET update_module_count = 1, update_alert_count = 1
@ -1873,7 +1891,7 @@ if ($delete_module) {
} }
// Trick to detect if we are deleting a synthetic module (avg or arithmetic) // Trick to detect if we are deleting a synthetic module (avg or arithmetic)
// If result is empty then module doesn't have this type of submodules // If result is empty then module doesn't have this type of submodules.
$ops_json = enterprise_hook('modules_get_synthetic_operations', [$id_borrar_modulo]); $ops_json = enterprise_hook('modules_get_synthetic_operations', [$id_borrar_modulo]);
$result_ops_synthetic = json_decode($ops_json); $result_ops_synthetic = json_decode($ops_json);
if (!empty($result_ops_synthetic)) { if (!empty($result_ops_synthetic)) {
@ -1881,18 +1899,17 @@ if ($delete_module) {
if ($result === false) { if ($result === false) {
$error++; $error++;
} }
} //end if } else {
else {
$result_components = enterprise_hook('modules_get_synthetic_components', [$id_borrar_modulo]); $result_components = enterprise_hook('modules_get_synthetic_components', [$id_borrar_modulo]);
$count_components = 1; $count_components = 1;
if (!empty($result_components)) { if (!empty($result_components)) {
// Get number of components pending to delete to know when it's needed to update orders // Get number of components pending to delete to know when it's needed to update orders.
$num_components = count($result_components); $num_components = count($result_components);
$last_target_module = 0; $last_target_module = 0;
foreach ($result_components as $id_target_module) { foreach ($result_components as $id_target_module) {
// Detects change of component or last component to update orders // Detects change of component or last component to update orders.
if (($count_components == $num_components) if (($count_components == $num_components)
or ($last_target_module != $id_target_module) || ($last_target_module != $id_target_module)
) { ) {
$update_orders = true; $update_orders = true;
} else { } else {
@ -1911,7 +1928,7 @@ if ($delete_module) {
} }
} }
// Check for errors // Check for errors.
if ($error != 0) { if ($error != 0) {
ui_print_error_message(__('There was a problem deleting the module')); ui_print_error_message(__('There was a problem deleting the module'));
} else { } else {
@ -1928,8 +1945,7 @@ if ($delete_module) {
} }
} }
// MODULE DUPLICATION // MODULE DUPLICATION.
// ==================
if (!empty($duplicate_module)) { if (!empty($duplicate_module)) {
// DUPLICATE agent module ! // DUPLICATE agent module !
$id_duplicate_module = $duplicate_module; $id_duplicate_module = $duplicate_module;
@ -1975,8 +1991,7 @@ if (!empty($duplicate_module)) {
} }
} }
// MODULE ENABLE/DISABLE // MODULE ENABLE/DISABLE.
// =====================
if ($enable_module) { if ($enable_module) {
$result = modules_change_disabled($enable_module, 0); $result = modules_change_disabled($enable_module, 0);
$modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.''); $modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.'');
@ -2015,8 +2030,7 @@ if ($disable_module) {
); );
} }
// UPDATE GIS // UPDATE GIS.
// ==========
$updateGIS = get_parameter('update_gis', 0); $updateGIS = get_parameter('update_gis', 0);
if ($updateGIS) { if ($updateGIS) {
$updateGisData = get_parameter('update_gis_data'); $updateGisData = get_parameter('update_gis_data');
@ -2105,8 +2119,10 @@ switch ($tab) {
case 'alert': case 'alert':
/* /*
Because $id_agente is set, it will show only agent alerts */ * Because $id_agente is set, it will show only agent alerts
// This var is for not display create button on alert list * This var is for not display create button on alert list
*/
$dont_display_alert_create_bttn = true; $dont_display_alert_create_bttn = true;
include 'godmode/alerts/alert_list.php'; include 'godmode/alerts/alert_list.php';
break; break;
@ -2155,7 +2171,7 @@ switch ($tab) {
default: default:
if (enterprise_hook('switch_agent_tab', [$tab])) { if (enterprise_hook('switch_agent_tab', [$tab])) {
// This will make sure that blank pages will have at least some // This will make sure that blank pages will have at least some
// debug info in them - do not translate debug // debug info in them - do not translate debug.
ui_print_error_message(__('Invalid tab specified')); ui_print_error_message(__('Invalid tab specified'));
} }
break; break;

View File

@ -354,6 +354,12 @@ define('MODULE_PREDICTION_CLUSTER', 5);
define('MODULE_PREDICTION_CLUSTER_AA', 6); define('MODULE_PREDICTION_CLUSTER_AA', 6);
define('MODULE_PREDICTION_CLUSTER_AP', 7); define('MODULE_PREDICTION_CLUSTER_AP', 7);
// Type of Webserver Modules.
define('MODULE_WEBSERVER_CHECK_LATENCY', 30);
define('MODULE_WEBSERVER_CHECK_SERVER_RESPONSE', 31);
define('MODULE_WEBSERVER_RETRIEVE_NUMERIC_DATA', 32);
define('MODULE_WEBSERVER_RETRIEVE_STRING_DATA', 33);
// SNMP CONSTANTS. // SNMP CONSTANTS.
define('SNMP_DIR_MIBS', 'attachment/mibs'); define('SNMP_DIR_MIBS', 'attachment/mibs');