diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index a3a2b15c8a..8809b8942d 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -1202,7 +1202,10 @@ class DiscoveryTaskList extends HTML $output = ''; // Header information. - if ((int) $task['status'] <= 0 && empty($summary)) { + if ((int) $task['status'] <= 0 + && empty($summary) + && $task['id_recon_script'] == 0 + ) { $output .= ui_print_info_message( __('This task has never executed'), '', @@ -1250,6 +1253,17 @@ class DiscoveryTaskList extends HTML ], ] ); + if (count($map->nodes) <= 1) { + // No nodes detected in current task definition. + $task = db_get_row('trecon_task', 'id_rt', $id_task); + + if ((int) $task['type'] === DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE) { + ui_print_info_message( + __('Please ensure instances or regions are being monitorized and \'scan and general monitoring\' is enabled.') + ); + } + } + $map->printMap(); } diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index cf28dee942..6825a07dab 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1427,7 +1427,7 @@ class HostDevices extends Wizard include_once $config['homedir'].'/include/class/CredentialStore.class.php'; $available_keys = CredentialStore::getKeys('CUSTOM'); - if (check_acl($config['id_user'], 0, 'PM')) { + if (check_acl($config['id_user'], 0, 'UM')) { $link_to_cs = ''; diff --git a/pandora_console/include/class/CredentialStore.class.php b/pandora_console/include/class/CredentialStore.class.php index 51471f6029..1ccb364392 100644 --- a/pandora_console/include/class/CredentialStore.class.php +++ b/pandora_console/include/class/CredentialStore.class.php @@ -385,6 +385,8 @@ class CredentialStore extends Wizard // Decrypt content. $key['username'] = io_output_password($key['username']); $key['password'] = io_output_password($key['password']); + $key['extra_1'] = io_output_password($key['extra_1']); + $key['extra_2'] = io_output_password($key['extra_2']); return $key; } @@ -425,6 +427,8 @@ class CredentialStore extends Wizard function ($carry, $item) { $item['username'] = io_output_password($item['username']); $item['password'] = io_output_password($item['password']); + $item['extra_1'] = io_output_password($item['extra_1']); + $item['extra_2'] = io_output_password($item['extra_2']); $carry[$item['identifier']] = $item['identifier']; return $carry; } @@ -573,13 +577,28 @@ class CredentialStore extends Wizard $extra_1 = get_parameter('extra_1', null); $extra_2 = get_parameter('extra_2', null); - if (empty($identifier)) { + if ($product === 'GOOGLE') { + $google_creds = json_decode(io_safe_output($extra_1)); + + if (json_last_error() !== JSON_ERROR_NONE) { + $this->ajaxMsg( + 'error', + __('Not a valid JSON: %s', json_last_error_msg()) + ); + exit; + } + + $username = $google_creds->client_email; + $password = $google_creds->private_key_id; + } + + if (empty($identifier) === true) { $error = __('Key identifier is required'); } else if ($id_group === null) { $error = __('You must select a group where store this key!'); - } else if (empty($product)) { + } else if (empty($product) === true) { $error = __('You must specify a product type'); - } else if (empty($username) && (empty($password))) { + } else if (empty($username) === true && (empty($password) === true)) { $error = __('You must specify a username and/or password'); } @@ -593,10 +612,10 @@ class CredentialStore extends Wizard 'identifier' => $identifier, 'id_group' => $id_group, 'product' => $product, - 'username' => io_input_password($username), - 'password' => io_input_password($password), - 'extra_1' => $extra_1, - 'extra_2' => $extra_2, + 'username' => io_input_password(io_safe_output($username)), + 'password' => io_input_password(io_safe_output($password)), + 'extra_1' => io_input_password(io_safe_output($extra_1)), + 'extra_2' => io_input_password(io_safe_output($extra_2)), ]; // Spaces are not allowed. @@ -887,7 +906,7 @@ class CredentialStore extends Wizard 'AWS' => __('Aws'), 'AZURE' => __('Azure'), 'SAP' => __('SAP'), - // 'GOOGLE' => __('Google'), + 'GOOGLE' => __('Google'), ], 'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'), 'disabled' => (bool) $values['product'], @@ -899,6 +918,9 @@ class CredentialStore extends Wizard $pass_label = __('Password'); $extra_1_label = __('Extra'); $extra_2_label = __('Extra (2)'); + $extra1_type = 'text'; + $user = true; + $pass = true; $extra1 = true; $extra2 = true; @@ -919,7 +941,14 @@ class CredentialStore extends Wizard break; case 'GOOGLE': - // Need further investigation. + $extra_1_label = __('Auth JSON'); + $user = false; + $pass = false; + $extra1 = true; + $extra2 = false; + $extra1_type = 'textarea'; + break; + case 'CUSTOM': case 'SAP': $user_label = __('Account ID'); @@ -931,29 +960,33 @@ class CredentialStore extends Wizard break; } - $inputs[] = [ - 'label' => $user_label, - 'id' => 'div-username', - 'arguments' => [ - 'name' => 'username', - 'input_class' => 'flex-row', - 'type' => 'text', - 'value' => $values['username'], - 'return' => true, - ], - ]; + if ($user) { + $inputs[] = [ + 'label' => $user_label, + 'id' => 'div-username', + 'arguments' => [ + 'name' => 'username', + 'input_class' => 'flex-row', + 'type' => 'text', + 'value' => $values['username'], + 'return' => true, + ], + ]; + } - $inputs[] = [ - 'label' => $pass_label, - 'id' => 'div-password', - 'arguments' => [ - 'name' => 'password', - 'input_class' => 'flex-row', - 'type' => 'password', - 'value' => $values['password'], - 'return' => true, - ], - ]; + if ($pass) { + $inputs[] = [ + 'label' => $pass_label, + 'id' => 'div-password', + 'arguments' => [ + 'name' => 'password', + 'input_class' => 'flex-row', + 'type' => 'password', + 'value' => $values['password'], + 'return' => true, + ], + ]; + } if ($extra1) { $inputs[] = [ @@ -961,8 +994,9 @@ class CredentialStore extends Wizard 'id' => 'div-extra_1', 'arguments' => [ 'name' => 'extra_1', + 'id' => 'text-extra_1', 'input_class' => 'flex-row', - 'type' => 'text', + 'type' => $extra1_type, 'value' => $values['extra_1'], 'return' => true, ], @@ -1043,14 +1077,30 @@ class CredentialStore extends Wizard * Handles inputs visibility based on selected product. */ function calculate_inputs() { + if ($('#product :selected').val() != "GOOGLE") { + // Restore text-extra_1. + var val = $('#text-extra_1').val(); + if(typeof val == 'undefined') { + val = ''; + } + $('#text-extra_1').remove(); + $('#div-extra_1').append( + $('') + ); + } + if ($('#product :selected').val() == "CUSTOM") { $('#div-username label').text(''); $('#div-password label').text(''); + $('#div-username').show(); + $('#div-password').show(); $('#div-extra_1').hide(); $('#div-extra_2').hide(); } else if ($('#product :selected').val() == "AWS") { $('#div-username label').text(''); $('#div-password label').text(''); + $('#div-username').show(); + $('#div-password').show(); $('#div-extra_1').hide(); $('#div-extra_2').hide(); } else if ($('#product :selected').val() == "AZURE") { @@ -1058,13 +1108,32 @@ class CredentialStore extends Wizard $('#div-password label').text(''); $('#div-extra_1 label').text(''); $('#div-extra_2 label').text(''); + $('#div-username').show(); + $('#div-password').show(); $('#div-extra_1').show(); $('#div-extra_2').show(); } else if ($('#product :selected').val() == "SAP") { $('#div-username label').text(''); $('#div-password label').text(''); + $('#div-username').show(); + $('#div-password').show(); $('#div-extra_1').hide(); $('#div-extra_2').hide(); + } else if ($('#product :selected').val() == "GOOGLE") { + $('#div-username').hide(); + $('#div-password').hide(); + $('#div-extra_2').hide(); + $('#div-extra_1 label').text(''); + var val = $('#text-extra_1').val(); + if(typeof val == 'undefined') { + val = ''; + } + + $('#text-extra_1').remove(); + $('#div-extra_1').append( + $('') + ); + $('#div-extra_1').show(); } } diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 66b784d712..54f4c286f2 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -622,7 +622,8 @@ define('DISCOVERY_CLOUD_AZURE_COMPUTE', 8); define('DISCOVERY_DEPLOY_AGENTS', 9); define('DISCOVERY_APP_SAP', 10); define('DISCOVERY_APP_DB2', 11); - +define('DISCOVERY_APP_MICROSOFT_SQL_SERVER', 12); +define('DISCOVERY_CLOUD_GCP_COMPUTE_ENGINE', 13); // Force task build tmp results. define('DISCOVERY_REVIEW', 0); @@ -641,6 +642,7 @@ define('DISCOVERY_SCRIPT_IPMI_RECON', 4); // Discovery task descriptions. define('CLOUDWIZARD_AZURE_DESCRIPTION', 'Discovery.Cloud.Azure.Compute'); define('CLOUDWIZARD_AWS_DESCRIPTION', 'Discovery.Cloud.AWS.EC2'); +define('CLOUDWIZARD_GOOGLE_DESCRIPTION', 'Discovery.Cloud.GCP'); define('CLOUDWIZARD_VMWARE_DESCRIPTION', 'Discovery.App.VMware'); // Background options. diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 3edbea17d3..d3996bc7f8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1772,7 +1772,7 @@ function html_print_extended_select_for_time( ob_start(); // Use the no_meta parameter because this image is only in the base console. - echo '
'; + echo '
'; html_print_select( $fields, $uniq_name.'_select', @@ -2910,13 +2910,17 @@ function html_print_textarea( $attributes='', $return=false, $class='', - $disable=false + $disable=false, + $id=false ) { $disabled = ($disable) ? 'disabled' : ''; - $output = ''; - if ($return) { return $output; } @@ -4602,7 +4606,8 @@ function html_print_input($data, $wrapper='div', $input_only=false) ((isset($data['attributes']) === true) ? $data['attributes'] : ''), ((isset($data['return']) === true) ? $data['return'] : false), ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false) + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['id']) === true) ? $data['id'] : false) ); break; diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 3f66c790ae..95956b422a 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -86,6 +86,7 @@ function snmp_browser_get_html_tree( $count = 0; $total = (count(array_keys($tree['__LEAVES__'])) - 1); $last_array[$depth] = $last; + $class = 'item_'.$depth; if ($depth > 0) { $output .= '