';
if ($id_agent_module) {
html_print_submit_button(
@@ -659,38 +769,84 @@ ui_require_javascript_file('pandora_modules');
diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php
index 5a4653fc29..08f930c95f 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_common.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_common.php
@@ -132,7 +132,7 @@ function add_component_selection($id_network_component_type)
require_once 'include/functions_network_components.php';
enterprise_include_once('include/functions_policies.php');
-// If code comes from policies disable export select
+// If code comes from policies disable export select.
global $__code_from;
$disabledBecauseInPolicy = false;
@@ -209,8 +209,7 @@ $table_simple->data[0][1] = html_print_input_text_extended(
$largeClassDisabledBecauseInPolicy,
true
);
-// $table_simple->data[0][1] = html_print_input_text ('name',
-// io_safe_output($name), '', 45, 100, true, $disabledBecauseInPolicy);
+
if (!empty($id_agent_module) && isset($id_agente)) {
$table_simple->data[0][1] .= '
'.__('ID').' '.$id_agent_module.' ';
@@ -237,7 +236,13 @@ if ($policy_link != 0) {
}
$table_simple->data[0][2] = __('Disabled');
-$table_simple->data[0][2] .= html_print_checkbox('disabled', 1, $disabled, true, $disabled_enable);
+$table_simple->data[0][2] .= html_print_checkbox(
+ 'disabled',
+ 1,
+ $disabled,
+ true,
+ $disabled_enable
+);
$table_simple->data[0][3] = __('Module group');
$table_simple->data[0][3] .= html_print_select_from_sql(
'SELECT id_mg, name FROM tmodule_group ORDER BY name',
@@ -260,12 +265,18 @@ if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) {
$in_policy = strstr($page, 'policy_modules');
if (!$in_policy) {
- // Cannot select the current module to be itself parent
- $module_parent_filter = $id_agent_module ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : '';
+ // Cannot select the current module to be itself parent.
+ $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : '';
$table_simple->data[1][0] = __('Module parent');
- $modules_can_be_parent = agents_get_modules($id_agente, false, $module_parent_filter);
- // If the user cannot have access to parent module, only print the name
- if ($parent_module_id != 0 && !in_array($parent_module_id, array_keys($modules_can_be_parent))) {
+ $modules_can_be_parent = agents_get_modules(
+ $id_agente,
+ false,
+ $module_parent_filter
+ );
+ // If the user cannot have access to parent module, only print the name.
+ if ($parent_module_id != 0
+ && !in_array($parent_module_id, array_keys($modules_can_be_parent))
+ ) {
$table_simple->data[1][1] = db_get_value(
'nombre',
'tagente_modulo',
@@ -305,7 +316,11 @@ if (!$edit) {
}
$table_simple->data[2][1] = '
'.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')';
- $table_simple->data[2][1] .= html_print_input_hidden('type_names', base64_encode(io_json_mb_encode($type_names_hash)), true);
+ $table_simple->data[2][1] .= html_print_input_hidden(
+ 'type_names',
+ base64_encode(io_json_mb_encode($type_names_hash)),
+ true
+ );
} else {
if (isset($id_module_type)) {
$idModuleType = $id_module_type;
@@ -313,12 +328,13 @@ if (!$edit) {
$idModuleType = '';
}
- // Removed web analysis and log4x from select
+ // Removed web analysis and log4x from select.
$sql = sprintf(
- 'SELECT id_tipo, descripcion, nombre
+ 'SELECT id_tipo, descripcion, nombre, categoria
FROM ttipo_modulo
- WHERE categoria IN (%s) AND id_tipo NOT IN (24, 25)
- ORDER BY descripcion',
+ WHERE categoria IN (%s)
+ AND id_tipo NOT IN (24, 25)
+ ORDER BY id_tipo ASC',
implode(',', $categories)
);
@@ -326,7 +342,9 @@ if (!$edit) {
$type_names_hash = [];
$type_description_hash = [];
- if (isset($type_names) && is_array($type_names)) {
+ if (isset($type_names) === true
+ && is_array($type_names) === true
+ ) {
foreach ($type_names as $tn) {
$type_names_hash[$tn['id_tipo']] = $tn['nombre'];
$type_description_hash[$tn['id_tipo']] = $tn['descripcion'];
@@ -342,7 +360,7 @@ if (!$edit) {
0,
true,
false,
- true,
+ false,
'',
false,
false,
@@ -350,8 +368,12 @@ if (!$edit) {
100
);
- // Store the relation between id and name of the types on a hidden field
- $table_simple->data[2][1] .= html_print_input_hidden('type_names', base64_encode(io_json_mb_encode($type_names_hash)), true);
+ // Store the relation between id and name of the types on a hidden field.
+ $table_simple->data[2][1] .= html_print_input_hidden(
+ 'type_names',
+ base64_encode(io_json_mb_encode($type_names_hash)),
+ true
+ );
}
if ($edit_module) {
@@ -380,15 +402,32 @@ if ($edit_module) {
$help_header = 'webserver_module_tab';
}
- $table_simple->data[2][0] = __('Type').' '.ui_print_help_icon($help_header, true);
+ $table_simple->data[2][0] = __('Type').' ';
+ $table_simple->data[2][0] .= ui_print_help_icon($help_header, true);
}
if ($disabledBecauseInPolicy) {
- $table_simple->data[2][3] .= html_print_input_hidden('id_module_group', $id_module_group, true);
+ $table_simple->data[2][3] .= html_print_input_hidden(
+ 'id_module_group',
+ $id_module_group,
+ true
+ );
}
$table_simple->data[3][0] = __('Dynamic Threshold Interval');
-$table_simple->data[3][1] = html_print_extended_select_for_time('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px', false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy);
+$table_simple->data[3][1] = html_print_extended_select_for_time(
+ 'dynamic_interval',
+ $dynamic_interval,
+ '',
+ 'None',
+ '0',
+ 10,
+ true,
+ 'width:150px',
+ false,
+ $classdisabledBecauseInPolicy,
+ $disabledBecauseInPolicy
+);
$table_simple->data[3][1] .= '
'.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).'';
if ($in_policy) {
$table_simple->cellclass[2][2] = 'hide_dinamic';
diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php
index c0a6181a8e..a5763e101a 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_network.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_network.php
@@ -1,30 +1,50 @@
";
-// This line does not run with the dinamic loader editor in policies.
-// ui_require_javascript_file ('pandora_snmp_browser');
-// WARNING REPEAT input hidden errors in console
-// Save some variables for javascript functions
-// html_print_input_hidden ('ajax_url', ui_get_full_url("ajax.php"), false);
-// html_print_input_hidden ('search_matches_translation', __("Search matches"), false);
-// Define a custom action to save the OID selected in the SNMP browser to the form
-html_print_input_hidden('custom_action', urlencode(base64_encode('
.'/input_filter.disabled.png)
')), false);
+echo "";
+
+// Define a custom action to save the OID selected
+// in the SNMP browser to the form.
+html_print_input_hidden(
+ 'custom_action',
+ urlencode(
+ base64_encode(
+ '
.'/input_filter.disabled.png)
'
+ )
+ ),
+ false
+);
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
@@ -50,17 +70,15 @@ if (strstr($page, 'policy_modules') === false) {
define('ID_NETWORK_COMPONENT_TYPE', 2);
if (empty($update_module_id)) {
- // Function in module_manager_editor_common.php
+ // Function in module_manager_editor_common.php.
add_component_selection(ID_NETWORK_COMPONENT_TYPE);
-} else {
- // TODO: Print network component if available
}
$extra_title = __('Network server module');
$data = [];
$data[0] = __('Target IP');
-// show agent_for defect;
+// Show agent_for defect.
if ($page == 'enterprise/godmode/policies/policy_modules') {
if ($ip_target != 'auto' && $ip_target != '') {
$custom_ip_target = $ip_target;
@@ -100,7 +118,7 @@ if ($page == 'enterprise/godmode/policies/policy_modules') {
$data[1] = html_print_input_text('ip_target', $ip_target, '', 15, 60, true);
}
-// In ICMP modules, port is not configurable
+// In ICMP modules, port is not configurable.
if ($id_module_type >= 6 && $id_module_type <= 7) {
$data[2] = '';
$data[3] = '';
@@ -148,7 +166,15 @@ if (!$adopt) {
$classdisabledBecauseInPolicy
);
} else {
- $data[1] = html_print_input_text('snmp_community', $snmp_community, '', 15, 60, true, false);
+ $data[1] = html_print_input_text(
+ 'snmp_community',
+ $snmp_community,
+ '',
+ 15,
+ 60,
+ true,
+ false
+ );
}
$data[2] = _('SNMP version');
@@ -213,8 +239,27 @@ $data[1] .= html_print_input_text(
$classdisabledBecauseInPolicy
);
$data[1] .= '
';
-$data[1] .= html_print_select([], 'select_snmp_oid', $snmp_oid, '', '', 0, true, false, false, '', $disabledBecauseInPolicy);
-$data[1] .= html_print_image('images/edit.png', true, ['class' => 'invisible clickable', 'id' => 'edit_oid']);
+$data[1] .= html_print_select(
+ [],
+ 'select_snmp_oid',
+ $snmp_oid,
+ '',
+ '',
+ 0,
+ true,
+ false,
+ false,
+ '',
+ $disabledBecauseInPolicy
+);
+$data[1] .= html_print_image(
+ 'images/edit.png',
+ true,
+ [
+ 'class' => 'invisible clickable',
+ 'id' => 'edit_oid',
+ ]
+);
$data[1] .= '';
$data[1] .= '
';
$data[1] .= html_print_button(
@@ -231,42 +276,50 @@ $table_simple->colspan['snmp_2'][1] = 3;
push_table_simple($data, 'snmp_2');
-// Advanced stuff
+// Advanced stuff.
$data = [];
$data[0] = __('TCP send');
-$data[1] = html_print_textarea('tcp_send', 2, 65, $tcp_send, $disabledTextBecauseInPolicy, true, $largeclassdisabledBecauseInPolicy);
+$data[1] = html_print_textarea(
+ 'tcp_send',
+ 2,
+ 65,
+ $tcp_send,
+ $disabledTextBecauseInPolicy,
+ true,
+ $largeclassdisabledBecauseInPolicy
+);
$table_simple->colspan['tcp_send'][1] = 3;
push_table_simple($data, 'tcp_send');
$data[0] = __('TCP receive');
-$data[1] = html_print_textarea('tcp_rcv', 2, 65, $tcp_rcv, $disabledTextBecauseInPolicy, true, $largeclassdisabledBecauseInPolicy);
+$data[1] = html_print_textarea(
+ 'tcp_rcv',
+ 2,
+ 65,
+ $tcp_rcv,
+ $disabledTextBecauseInPolicy,
+ true,
+ $largeclassdisabledBecauseInPolicy
+);
$table_simple->colspan['tcp_receive'][1] = 3;
push_table_simple($data, 'tcp_receive');
if ($id_module_type < 8 || $id_module_type > 11) {
- // NOT TCP
+ // NOT TCP.
$table_simple->rowstyle['tcp_send'] = 'display: none;';
$table_simple->rowstyle['tcp_receive'] = 'display: none;';
}
if ($id_module_type < 15 || $id_module_type > 18) {
- // NOT SNMP
+ // NOT SNMP.
$table_simple->rowstyle['snmp_1'] = 'display: none';
$table_simple->rowstyle['snmp_2'] = 'display: none';
}
-// For a policy
-if (!isset($id_agent_module)) {
- $snmp3_auth_user = '';
- $snmp3_auth_pass = '';
- $snmp_version = 1;
- $snmp3_privacy_method = '';
- $snmp3_privacy_pass = '';
- $snmp3_auth_method = '';
- $snmp3_security_level = '';
-} else if ($id_agent_module === false) {
+// For a policy.
+if (isset($id_agent_module) === false || $id_agent_module === false) {
$snmp3_auth_user = '';
$snmp3_auth_pass = '';
$snmp_version = 1;
@@ -274,6 +327,9 @@ if (!isset($id_agent_module)) {
$snmp3_privacy_pass = '';
$snmp3_auth_method = '';
$snmp3_security_level = '';
+ $command_text = '';
+ $command_os = 'inherited';
+ $command_credential_identifier = '';
}
$data = [];
@@ -333,7 +389,22 @@ push_table_simple($data, 'field_snmpv3_row2');
$data = [];
$data[0] = __('Auth method');
-$data[1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp3_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', $disabledBecauseInPolicy);
+$data[1] = html_print_select(
+ [
+ 'MD5' => __('MD5'),
+ 'SHA' => __('SHA'),
+ ],
+ 'snmp3_auth_method',
+ $snmp3_auth_method,
+ '',
+ '',
+ '',
+ true,
+ false,
+ false,
+ '',
+ $disabledBecauseInPolicy
+);
$data[2] = __('Security level');
$data[3] = html_print_select(
[
@@ -358,13 +429,84 @@ if ($snmp_version != 3) {
push_table_simple($data, 'field_snmpv3_row3');
+$data = [];
+$data[0] = __('Command');
+$data[1] = html_print_input_text_extended(
+ 'command_text',
+ $command_text,
+ 'command_text',
+ '',
+ 100,
+ 10000,
+ $disabledBecauseInPolicy,
+ '',
+ $largeClassDisabledBecauseInPolicy,
+ true
+);
+$table_simple->colspan['row-cmd-row-1'][1] = 3;
+push_table_simple($data, 'row-cmd-row-1');
+
+require_once $config['homedir'].'/include/class/CredentialStore.class.php';
+$array_credential_identifier = CredentialStore::getKeys('CUSTOM');
+
+$data[0] = __('Credential identifier');
+$data[1] = html_print_select(
+ $array_credential_identifier,
+ 'command_credential_identifier',
+ $command_credential_identifier,
+ '',
+ __('None'),
+ '',
+ true,
+ false,
+ false,
+ '',
+ $disabledBecauseInPolicy
+);
+
+$array_os = [
+ 'inherited' => __('Inherited'),
+ 'linux' => __('Linux'),
+ 'windows' => __('Windows'),
+];
+
+$data[2] = __('Target OS');
+$data[3] = html_print_select(
+ $array_os,
+ 'command_os',
+ $command_os,
+ '',
+ '',
+ '',
+ true,
+ false,
+ false,
+ '',
+ $disabledBecauseInPolicy
+);
+
+push_table_simple($data, 'row-cmd-row-2');
+
+if ($id_module_type !== 34
+ && $id_module_type !== 35
+ && $id_module_type !== 36
+ && $id_module_type !== 37
+) {
+ $table_simple->rowstyle['row-cmd-row-1'] = 'display: none;';
+ $table_simple->rowstyle['row-cmd-row-2'] = 'display: none;';
+}
+
snmp_browser_print_container(false, '100%', '60%', 'none');
?>
diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php
index fd922046d1..1ee435f57a 100644
--- a/pandora_console/godmode/modules/manage_network_components_form.php
+++ b/pandora_console/godmode/modules/manage_network_components_form.php
@@ -1,17 +1,32 @@
$id_agentmodule]);
+ $data_module = db_get_row_filter(
+ 'tagente_modulo',
+ ['id_agente_modulo' => $id_agentmodule]
+ );
$name = $data_module['nombre'];
$description = $data_module['descripcion'];
@@ -139,16 +160,25 @@ if (isset($id)) {
$each_ff = $component['each_ff'];
if ($type >= 15 && $type <= 18) {
- // New support for snmp v3
+ // New support for snmp v3.
$snmp_version = $component['tcp_send'];
$snmp3_auth_user = $component['plugin_user'];
$snmp3_auth_pass = io_output_password($component['plugin_pass']);
$snmp3_auth_method = $component['plugin_parameter'];
$snmp3_privacy_method = $component['custom_string_1'];
- $snmp3_privacy_pass = io_output_password($component['custom_string_2']);
+ $snmp3_privacy_pass = io_output_password(
+ $component['custom_string_2']
+ );
$snmp3_security_level = $component['custom_string_3'];
+ } else if ($type >= 34 && $type <= 37) {
+ $command_text = $component['tcp_send'];
+ $command_credential_identifier = $component['custom_string_1'];
+ $command_os = $component['custom_string_2'];
}
- } else if (isset($new_component) && $new_component && !$create_network_from_snmp_browser) {
+ } else if (isset($new_component)
+ && $new_component
+ && !$create_network_from_snmp_browser
+ ) {
$name = '';
$snmp_oid = '';
$description = '';
@@ -204,21 +234,13 @@ if (isset($id)) {
$snmp3_privacy_pass = '';
$snmp3_auth_method = '';
$snmp3_security_level = '';
+
+ $command_text = '';
+ $command_os = 'inherited';
+ $command_credential_identifier = '';
}
}
-if ($create_network_from_snmp_browser) {
-}
-
-/*
- * $id_component_type has these values:
- * 6 - Module WMI
- * 4 - Plugin component
- * 2 - network component
- *
- * You can see this values in file godmode/modules/manage_network_components.php
- * in the last lines (in the call function "html_print_select").
- */
$table = new stdClass();
if ($id_component_type == 6) {
@@ -243,6 +265,10 @@ if ($id_component_type == 6) {
4,
5,
];
+ if (enterprise_installed()) {
+ $categories[] = 10;
+ }
+
include $config['homedir'].'/godmode/modules/manage_network_components_form_common.php';
include $config['homedir'].'/godmode/modules/manage_network_components_form_network.php';
} else {
@@ -253,7 +279,7 @@ echo '