diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index eeb3b8d797..fcb157f964 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -10,4 +10,33 @@ ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEF ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct'; +CREATE TABLE `ttask_credentials` ( + `id_rt` int(10) unsigned NOT NULL, + `identifier` varchar(100) NOT NULL, + PRIMARY KEY (`id_rt`,`identifier`), + KEY `identifier` (`identifier`), + FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '', + `desired_agent_version` VARCHAR(100) DEFAULT '', + `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 60e19998e8..fa3cc03741 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2219,3 +2219,38 @@ CREATE TABLE IF NOT EXISTS `tcredential_store` ( -- Table `treport_content_sla_combined` -- --------------------------------------------------------------------- ALTER TABLE `treport_content_sla_combined` ADD `id_agent_module_failover` int(10) unsigned NOT NULL; + +-- ---------------------------------------------------------------------- +-- Table `ttask_credentials` +-- ---------------------------------------------------------------------- +CREATE TABLE `ttask_credentials` ( + `id_rt` int(10) unsigned NOT NULL, + `identifier` varchar(100) NOT NULL, + PRIMARY KEY (`id_rt`,`identifier`), + KEY `identifier` (`identifier`), + FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`identifier`) REFERENCES `tcredential_store` (`identifier`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tdeployment_hosts` +-- ---------------------------------------------------------------------- +CREATE TABLE `tdeployment_hosts` ( + `id` SERIAL, + `id_cs` VARCHAR(100), + `ip` VARCHAR(100) NOT NULL, + `id_os` INT(10) UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `arch` ENUM('x64', 'x86') DEFAULT 'x64', + `current_agent_version` VARCHAR(100) DEFAULT '', + `desired_agent_version` VARCHAR(100) DEFAULT '', + `deployed` bigint(20) unsigned COMMENT "When it was deployed", + `last_err` text, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store` (`identifier`) + ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 3ea3a7f0c2..d7c783c5d4 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -514,8 +514,10 @@ if (enterprise_installed()) { ); $safe_mode_modules = []; $safe_mode_modules[0] = __('Any'); - foreach ($sql_modules as $m) { - $safe_mode_modules[$m['id_module']] = $m['name']; + if (is_array($sql_modules)) { + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } } $table_adv_safe = '

'.__('Safe operation mode').': '.ui_print_help_tip( diff --git a/pandora_console/godmode/groups/credential_store.php b/pandora_console/godmode/groups/credential_store.php index 8c9540d581..9334cd6065 100644 --- a/pandora_console/godmode/groups/credential_store.php +++ b/pandora_console/godmode/groups/credential_store.php @@ -522,12 +522,10 @@ echo '

'; function calculate_inputs() { if ($('#product :selected').val() == "CUSTOM") { - $('#div-username label').text(''); + $('#div-username label').text(''); $('#div-password label').text(''); - $('#div-extra_1 label').text(''); - $('#div-extra_2 label').text(''); - $('#div-extra_1').show(); - $('#div-extra_2').show(); + $('#div-extra_1').hide(); + $('#div-extra_2').hide(); } else if ($('#product :selected').val() == "AWS") { $('#div-username label').text(''); $('#div-password label').text(''); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 3cc2e3f71d..8982d76d4b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/class/CustomNetScan.class.php'; require_once $config['homedir'].'/include/class/ManageNetScanScripts.class.php'; enterprise_include_once('include/class/CSVImportAgents.class.php'); +enterprise_include_once('include/class/DeploymentCenter.class.php'); enterprise_include_once('include/functions_hostdevices.php'); /** @@ -127,6 +128,12 @@ class HostDevices extends Wizard 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', 'label' => __('Import CSV'), ]; + + $buttons[] = [ + 'url' => $this->url.'&mode=deploy', + 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png', + 'label' => __('Agent deployment'), + ]; } $buttons[] = [ @@ -167,6 +174,14 @@ class HostDevices extends Wizard ); return $csv_importer->runCSV(); } + + if ($mode === 'deploy') { + $deployObject = new DeploymentCenter( + $this->page, + $this->breadcrum + ); + return $deployObject->run(); + } } if ($mode === 'customnetscan') { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 2524f6d93c..d6bd9eaee3 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -296,241 +296,20 @@ class Wizard */ public function printInput($data) { + global $config; + + include_once $config['homedir'].'/include/functions_html.php'; + if (is_array($data) === false) { return ''; } - switch ($data['type']) { - case 'text': - return html_print_input_text( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((isset($data['return']) === true) ? $data['return'] : true), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['function']) === true) ? $data['function'] : ''), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['onChange']) === true) ? $data['onChange'] : ''), - ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') - ); - - case 'image': - return html_print_input_image( - $data['name'], - $data['src'], - $data['value'], - ((isset($data['style']) === true) ? $data['style'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'text_extended': - return html_print_input_text_extended( - $data['name'], - $data['value'], - $data['id'], - $data['alt'], - $data['size'], - $data['maxlength'], - $data['disabled'], - $data['script'], - $data['attributes'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['password']) === true) ? $data['password'] : false), - ((isset($data['function']) === true) ? $data['function'] : '') - ); - - case 'password': - return html_print_input_password( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['class']) === true) ? $data['class'] : '') - ); - - case 'text': - return html_print_input_text( - $data['name'], - $data['value'], - ((isset($data['alt']) === true) ? $data['alt'] : ''), - ((isset($data['size']) === true) ? $data['size'] : 50), - ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['required']) === true) ? $data['required'] : false), - ((isset($data['function']) === true) ? $data['function'] : ''), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['onChange']) === true) ? $data['onChange'] : ''), - ((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '') - ); - - case 'image': - return html_print_input_image( - $data['name'], - $data['src'], - $data['value'], - ((isset($data['style']) === true) ? $data['style'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'hidden': - return html_print_input_hidden( - $data['name'], - $data['value'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : false) - ); - - case 'hidden_extended': - return html_print_input_hidden_extended( - $data['name'], - $data['value'], - $data['id'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : false) - ); - - case 'color': - return html_print_input_color( - $data['name'], - $data['value'], - ((isset($data['class']) === true) ? $data['class'] : false), - ((isset($data['return']) === true) ? $data['return'] : false) - ); - - case 'file': - return html_print_input_file( - $data['name'], - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['options']) === true) ? $data['options'] : false) - ); - - case 'select': - return html_print_select( - $data['fields'], - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['option_style']) === true) ? $data['option_style'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['modal']) === true) ? $data['modal'] : false), - ((isset($data['message']) === true) ? $data['message'] : ''), - ((isset($data['select_all']) === true) ? $data['select_all'] : false) - ); - - case 'select_from_sql': - return html_print_select_from_sql( - $data['sql'], - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT) - ); - - case 'select_groups': - return html_print_select_groups( - ((isset($data['id_user']) === true) ? $data['id_user'] : false), - ((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'), - ((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true), - $data['name'], - ((isset($data['selected']) === true) ? $data['selected'] : ''), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['multiple']) === true) ? $data['multiple'] : false), - ((isset($data['sort']) === true) ? $data['sort'] : true), - ((isset($data['class']) === true) ? $data['class'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['style']) === true) ? $data['style'] : false), - ((isset($data['option_style']) === true) ? $data['option_style'] : false), - ((isset($data['id_group']) === true) ? $data['id_group'] : false), - ((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'), - ((isset($data['strict_user']) === true) ? $data['strict_user'] : false), - ((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false), - ((isset($data['include_groups']) === true) ? $data['include_groups'] : false), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false) - ); - - case 'submit': - return '
'.html_print_submit_button( - ((isset($data['label']) === true) ? $data['label'] : 'OK'), - ((isset($data['name']) === true) ? $data['name'] : ''), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['attributes']) === true) ? $data['attributes'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false) - ).'
'; - - case 'checkbox': - return html_print_checkbox( - $data['name'], - $data['value'], - ((isset($data['checked']) === true) ? $data['checked'] : false), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['disabled']) === true) ? $data['disabled'] : false), - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false) - ); - - case 'switch': - return html_print_switch($data); - - case 'interval': - return html_print_extended_select_for_time( - $data['name'], - $data['value'], - ((isset($data['script']) === true) ? $data['script'] : ''), - ((isset($data['nothing']) === true) ? $data['nothing'] : ''), - ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), - ((isset($data['size']) === true) ? $data['size'] : false), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['style']) === true) ? $data['selected'] : false), - ((isset($data['unique']) === true) ? $data['unique'] : false) - ); - - case 'textarea': - return html_print_textarea( - $data['name'], - $data['rows'], - $data['columns'], - ((isset($data['value']) === true) ? $data['value'] : ''), - ((isset($data['attributes']) === true) ? $data['attributes'] : ''), - ((isset($data['return']) === true) ? $data['return'] : false), - ((isset($data['class']) === true) ? $data['class'] : '') - ); - - default: - // Ignore. - break; + $input = html_print_input(($data + ['return' => true]), 'div', true); + if ($input === false) { + return ''; } - return ''; + return $input; } @@ -800,7 +579,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = '
'; if ($return === false) { @@ -872,7 +651,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { @@ -967,7 +746,7 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output_head = ''; if ($return === false) { diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index c0a03ea34d..899b5b609b 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -583,6 +583,7 @@ define('DISCOVERY_APP_ORACLE', 5); define('DISCOVERY_CLOUD_AWS_EC2', 6); define('DISCOVERY_CLOUD_AWS_RDS', 7); define('DISCOVERY_CLOUD_AZURE_COMPUTE', 8); +define('DISCOVERY_DEPLOY_AGENTS', 9); // Discovery types matching definition. diff --git a/pandora_console/include/functions_credential_store.php b/pandora_console/include/functions_credential_store.php index eaf756f7b1..ea7b3d5c72 100644 --- a/pandora_console/include/functions_credential_store.php +++ b/pandora_console/include/functions_credential_store.php @@ -295,9 +295,9 @@ function print_inputs($values=null) 'type' => 'select', 'script' => 'calculate_inputs()', 'fields' => [ - // 'CUSTOM' => __('Custom'), - 'AWS' => __('Aws'), - 'AZURE' => __('Azure'), + 'CUSTOM' => __('Custom'), + 'AWS' => __('Aws'), + 'AZURE' => __('Azure'), // 'GOOGLE' => __('Google'), ], 'selected' => $values['product'], @@ -331,6 +331,8 @@ function print_inputs($values=null) case 'GOOGLE': // Need further investigation. case 'CUSTOM': + $user_label = __('Account ID'); + $pass_label = __('Password'); default: // Use defaults. break; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 533822f069..18ee4d3940 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -3071,11 +3071,13 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='') /** * Print input using functions html lib. * - * @param array $data Input definition. + * @param array $data Input definition. + * @param string $wrapper Wrapper 'div' or 'li'. + * @param boolean $input_only Return or print only input or also label. * * @return string HTML code for desired input. */ -function html_print_input($data) +function html_print_input($data, $wrapper='div', $input_only=false) { if (is_array($data) === false) { return ''; @@ -3083,8 +3085,8 @@ function html_print_input($data) $output = ''; - if ($data['label']) { - $output = '
'; $output .= '
'; + if ($data['label'] && $input_only === false) { + $output .= ''; if (!$data['return']) { - echo ''; + echo ''; } } return $output; } - - diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0050ccdf9d..6a9620f3e8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3094,38 +3094,7 @@ function ui_print_datatable(array $parameters) $filter .= '