From aa9fefd30cf2e8ecdcf42ec0821606cbdee559ea Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 12 Apr 2023 10:25:35 +0200 Subject: [PATCH 1/5] #10899 entities inventory and correction visual style --- .../godmode/agentes/inventory_manager.php | 4 ++-- pandora_console/include/functions_ui.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/agentes/inventory_manager.php b/pandora_console/godmode/agentes/inventory_manager.php index 77feece220..0a4e84bae5 100644 --- a/pandora_console/godmode/agentes/inventory_manager.php +++ b/pandora_console/godmode/agentes/inventory_manager.php @@ -75,7 +75,7 @@ if ($add_inventory_module) { 'interval' => $interval, 'username' => $username, 'password' => $password, - 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode($custom_fields)) : '', + 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields))) : '', ]; $result = db_process_sql_insert('tagent_module_inventory', $values); @@ -119,7 +119,7 @@ if ($add_inventory_module) { 'interval' => $interval, 'username' => $username, 'password' => $password, - 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode($custom_fields)) : '', + 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields))) : '', ]; $result = db_process_sql_update('tagent_module_inventory', $values, ['id_agent_module_inventory' => $id_agent_module_inventory, 'id_agente' => $id_agente]); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 11670b33f6..767cba430f 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7559,7 +7559,7 @@ function ui_get_inventory_module_add_form( 'border' => '0', 'title' => __('Remove'), 'style' => 'cursor: pointer;', - 'class' => 'remove-custom-field invert_filter', + 'class' => 'remove-custom-field invert_filter main_menu_icon', ] ); @@ -7593,9 +7593,13 @@ function ui_get_inventory_module_add_form( 'custom_fields['.$i.'][value]', $field['value'], '', - 25, + false, 40, - true + true, + false, + false, + '', + 'w90p' ); } @@ -7607,7 +7611,7 @@ function ui_get_inventory_module_add_form( 'border' => '0', 'title' => __('Remove'), 'style' => 'cursor: pointer;', - 'class' => 'remove-custom-field invert_filter', + 'class' => 'remove-custom-field invert_filter main_menu_icon', ] ); @@ -7670,10 +7674,12 @@ function ui_get_inventory_module_add_form( $("#inventory-module-form-userpass-row").hide(); $("#inventory-module-form-custom-fields-row").show(); $("tr[id^=inventory-module-form-custom-field-row-]").show(); + $('#inventory-module-form-custom-fields-button').show(); } else { $("#inventory-module-form-userpass-row").show(); $("#inventory-module-form-custom-fields-row").hide(); $("tr[id^=inventory-module-form-custom-field-row-]").hide(); + $('#inventory-module-form-custom-fields-button').hide(); } } From f6be23c353e16d0d8afc19120d0cc90dbe47d02e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 14 Apr 2023 12:24:39 +0200 Subject: [PATCH 2/5] #10899 json_ucescaped_unicode to inventory manage and visual fix --- .../godmode/agentes/inventory_manager.php | 4 +- pandora_console/include/functions_html.php | 3 +- pandora_console/include/functions_ui.php | 190 ++++++++++-------- 3 files changed, 105 insertions(+), 92 deletions(-) diff --git a/pandora_console/godmode/agentes/inventory_manager.php b/pandora_console/godmode/agentes/inventory_manager.php index 0a4e84bae5..8ba6b5c279 100644 --- a/pandora_console/godmode/agentes/inventory_manager.php +++ b/pandora_console/godmode/agentes/inventory_manager.php @@ -75,7 +75,7 @@ if ($add_inventory_module) { 'interval' => $interval, 'username' => $username, 'password' => $password, - 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields))) : '', + 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields), JSON_UNESCAPED_UNICODE)) : '', ]; $result = db_process_sql_insert('tagent_module_inventory', $values); @@ -119,7 +119,7 @@ if ($add_inventory_module) { 'interval' => $interval, 'username' => $username, 'password' => $password, - 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields))) : '', + 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields), JSON_UNESCAPED_UNICODE)) : '', ]; $result = db_process_sql_update('tagent_module_inventory', $values, ['id_agent_module_inventory' => $id_agent_module_inventory, 'id_agente' => $id_agente]); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 37054a3e86..be1403f228 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2880,6 +2880,7 @@ function html_print_input_password( $class='', $autocomplete='off', $hide_div_eye=false, + $div_class='' ) { if ($maxlength == 0) { $maxlength = 255; @@ -2910,7 +2911,7 @@ function html_print_input_password( } } - return '
'.html_print_input_text_extended($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true, '', $autocomplete, false, $hide_div_eye).'
'; + return '
'.html_print_input_text_extended($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true, '', $autocomplete, false, $hide_div_eye).'
'; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 767cba430f..c4381fabe9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7537,59 +7537,45 @@ function ui_get_inventory_module_add_form( $table->data['userpass-row'] = $row; $row = []; - $row['hidden-title'] = ''; - $row['hidden-input'] = html_print_input_hidden('hidden-custom-field-name', '', true); - $row['hidden-input'] .= html_print_input_hidden('hidden-custom-field-is-secure', 0, true); - $row['hidden-input'] .= html_print_input_text( - 'hidden-custom-field-input', - '', - '', - 25, - 40, - true, - false, - false, - '', - 'w93p' - ); - $row['hidden-input'] .= html_print_image( - 'images/delete.svg', - true, - [ - 'border' => '0', - 'title' => __('Remove'), - 'style' => 'cursor: pointer;', - 'class' => 'remove-custom-field invert_filter main_menu_icon', - ] - ); - $table->data['hidden-custom-field-row'] = $row; + $table->data['hidden-custom-field-row'] = html_print_label_input_block( + '', + '
'.html_print_input_hidden( + 'hidden-custom-field-name', + '', + true + ).html_print_input_hidden( + 'hidden-custom-field-is-secure', + 0, + true + ).html_print_input_text( + 'hidden-custom-field-input', + '', + '', + 25, + 40, + true, + false, + false, + '', + 'w100p' + ).html_print_image( + 'images/delete.svg', + true, + [ + 'border' => '0', + 'title' => __('Remove'), + 'style' => 'cursor: pointer;', + 'class' => 'remove-custom-field invert_filter main_menu_icon', + ] + ).'
' + ); + $table->colspan['hidden-custom-field-row'][0] = 2; if ($custom_fields_enabled) { foreach ($custom_fields as $i => $field) { - $row = []; - $row['title'] = ''.$field['name'].''; - $row['input'] = html_print_input_hidden( - 'custom_fields['.$i.'][name]', - $field['name'], - true - ); - $row['input'] .= html_print_input_hidden( - 'custom_fields['.$i.'][secure]', - $field['secure'], - true - ); if ($field['secure']) { - $row['input'] .= html_print_input_password( - 'custom_fields['.$i.'][value]', - $field['value'], - '', - 25, - 40, - true - ); - } else { - $row['input'] .= html_print_input_text( + $secure = html_print_input_password( 'custom_fields['.$i.'][value]', $field['value'], '', @@ -7599,23 +7585,47 @@ function ui_get_inventory_module_add_form( false, false, '', - 'w90p' + 'off', + false, + 'w100p' + ); + } else { + $secure = html_print_input_text( + 'custom_fields['.$i.'][value]', + $field['value'], + '', + false, + 40, + true, + false, + false, + '', + 'w100p' ); } - $row['input'] .= ' '; - $row['input'] .= html_print_image( - 'images/delete.svg', - true, - [ - 'border' => '0', - 'title' => __('Remove'), - 'style' => 'cursor: pointer;', - 'class' => 'remove-custom-field invert_filter main_menu_icon', - ] + $table->colspan['custom-field-row-'.$i][0] = 2; + $table->data['custom-field-row-'.$i] = html_print_label_input_block( + $field['name'], + '
'.html_print_input_hidden( + 'custom_fields['.$i.'][name]', + $field['name'], + true + ).html_print_input_hidden( + 'custom_fields['.$i.'][secure]', + $field['secure'], + true + ).$secure.html_print_image( + 'images/delete.svg', + true, + [ + 'border' => '0', + 'title' => __('Remove'), + 'style' => 'cursor: pointer;', + 'class' => 'remove-custom-field invert_filter main_menu_icon', + ] + ).'
' ); - - $table->data['custom-field-row-'.$i] = $row; } } @@ -7684,38 +7694,40 @@ function ui_get_inventory_module_add_form( } function add_row_for_custom_field (fieldName, isSecure) { - var custom_fields_num = $("tr[id^=inventory-module-form-custom-field-row-]").length; + var custom_fields_num = $("tr[id^=inventory-module-form-custom-field-row-]").length+1; $("#inventory-module-form-hidden-custom-field-row") - .clone() - .prop("id", "inventory-module-form-custom-field-row-" + custom_fields_num) - .children("#inventory-module-form-hidden-custom-field-row-hidden-title") - .prop("id", "inventory-module-form-custom-field-row-title-" + custom_fields_num) - .html("" + fieldName + "") - .parent() - .children("#inventory-module-form-hidden-custom-field-row-hidden-input") - .prop("id", "inventory-module-form-custom-field-row-input-" + custom_fields_num) - .prop("colspan", 2) - .children("input[name=hidden-custom-field-name]") + .clone() + .prop("id", "inventory-module-form-custom-field-row-" + custom_fields_num) + .children("[id^='inventory-module-form-hidden-custom-field-row']") // go to TD + .prop("id", "inventory-module-form-hidden-custom-field-row-"+ custom_fields_num) + .children() // go to DIV + .find('label') + .html(fieldName) + .parent() // up to DIV padre + .find('div') //go to DIV no label + .children("[id^=hidden-hidden-custom-field-name]") .prop("id", "custom-field-name-" + custom_fields_num) .prop("name", "custom_fields[" + custom_fields_num + "][name]") - .val(fieldName) + .prop("value", fieldName) .parent() - .children("input[name=hidden-custom-field-is-secure]") - .prop("id", "custom-field-is-secure-" + custom_fields_num) - .prop("name", "custom_fields[" + custom_fields_num + "][secure]") - .val(isSecure ? 1 : 0) - .parent() - .children("input[name=hidden-custom-field-input]") - .prop("id", "custom-field-input-" + custom_fields_num) - .prop("type", isSecure ? "password" : "text") - .prop("name", "custom_fields[" + custom_fields_num + "][value]") - .parent() - .children("img.remove-custom-field") - .click(remove_custom_field) - .parent() - .parent() - .insertBefore($("#inventory-module-form-custom-fields-row")) - .show(); + .children("input[name=hidden-custom-field-is-secure]") + .prop("id", "custom-field-is-secure-" + custom_fields_num) + .prop("name", "custom_fields[" + custom_fields_num + "][secure]") + .val(isSecure ? 1 : 0) + .parent() + .children("input[name=hidden-custom-field-input]") + .prop("id", "custom-field-input-" + custom_fields_num) + .prop("type", isSecure ? "password" : "text") + .prop("name", "custom_fields[" + custom_fields_num + "][value]") + .parent() + .children("img.remove-custom-field") + .click(remove_custom_field) + .parent() + .parent() + .parent() // up to TD + .parent() // up to TR + .insertBefore($("#inventory-module-form-custom-fields-row")) + .show(); } function add_custom_field () { From 726ab896f168297fd38098712de84ef6e15a922f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 18 Apr 2023 09:49:35 +0200 Subject: [PATCH 3/5] #10899 remove entities from inventory custom fields --- pandora_console/godmode/agentes/inventory_manager.php | 4 ++-- pandora_console/include/functions_ui.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/agentes/inventory_manager.php b/pandora_console/godmode/agentes/inventory_manager.php index 8ba6b5c279..adadc8dd50 100644 --- a/pandora_console/godmode/agentes/inventory_manager.php +++ b/pandora_console/godmode/agentes/inventory_manager.php @@ -46,7 +46,7 @@ $custom_fields = array_map( function ($field) { $field['secure'] = (bool) $field['secure']; if ($field['secure']) { - $field['value'] = io_input_password($field['value']); + $field['value'] = io_input_password(io_safe_output($field['value'])); } return $field; @@ -119,7 +119,7 @@ if ($add_inventory_module) { 'interval' => $interval, 'username' => $username, 'password' => $password, - 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields), JSON_UNESCAPED_UNICODE)) : '', + 'custom_fields' => $custom_fields_enabled && !empty($custom_fields) ? base64_encode(json_encode(io_safe_output($custom_fields, true), JSON_UNESCAPED_UNICODE)) : '', ]; $result = db_process_sql_update('tagent_module_inventory', $values, ['id_agent_module_inventory' => $id_agent_module_inventory, 'id_agente' => $id_agente]); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index c4381fabe9..71262b1e9d 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7577,7 +7577,7 @@ function ui_get_inventory_module_add_form( if ($field['secure']) { $secure = html_print_input_password( 'custom_fields['.$i.'][value]', - $field['value'], + io_safe_input($field['value']), '', false, 40, @@ -7592,7 +7592,7 @@ function ui_get_inventory_module_add_form( } else { $secure = html_print_input_text( 'custom_fields['.$i.'][value]', - $field['value'], + io_safe_input($field['value']), '', false, 40, From d501e49f4c0b65af8690063a1183801e331a689b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 18 Apr 2023 11:36:17 +0200 Subject: [PATCH 4/5] #10899 required module inventory select --- pandora_console/include/functions_ui.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 71262b1e9d..d8fa62ffa1 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7436,13 +7436,20 @@ function ui_get_inventory_module_add_form( 0, '', __('Select inventory module'), - 0, + '', true, false, false, 'w100p', false, - 'width: 100%' + 'width: 100%', + false, + false, + false, + '', + false, + false, + true ) ); } else { From fcde5e44523ade619350dfd45499dca3c5cd137a Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 20 Apr 2023 12:25:37 +0200 Subject: [PATCH 5/5] #10899 fix custom fields server error --- pandora_console/include/functions_ui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d8fa62ffa1..ab37336cb0 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7701,7 +7701,7 @@ function ui_get_inventory_module_add_form( } function add_row_for_custom_field (fieldName, isSecure) { - var custom_fields_num = $("tr[id^=inventory-module-form-custom-field-row-]").length+1; + var custom_fields_num = $("tr[id^=inventory-module-form-custom-field-row-]").length; $("#inventory-module-form-hidden-custom-field-row") .clone() .prop("id", "inventory-module-form-custom-field-row-" + custom_fields_num)