From 463c393c008de5bcb06df8c4f0329c935e8b61a3 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 29 May 2017 11:48:50 +0200 Subject: [PATCH 1/6] Added changes to encrypt custom values with a new token --- pandora_console/godmode/agentes/agent_manager.php | 10 ++++++++-- pandora_console/godmode/agentes/configure_field.php | 9 +++++++-- pandora_console/godmode/agentes/fields_manager.php | 6 ++++-- .../godmode/massive/massive_edit_agents.php | 8 +++++++- pandora_console/include/functions_api.php | 13 ++++++++++++- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 0ceb381374..7042b0d15b 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -460,8 +460,14 @@ foreach ($fields as $field) { $custom_value = ''; } - $data[1] = html_print_textarea ('customvalue_'.$field['id_field'], - 2, 65, $custom_value, 'style="min-height: 30px; width:96%;"', true); + if ($field['is_password_type']) { + $data[1] = html_print_input_text_extended ('customvalue_' . $field['id_field'], $custom_value, 'customvalue_' . $field['id_field'], '', + 30, 100, $view_mode, '', '', true, true); + } + else { + $data[1] = html_print_textarea ('customvalue_'.$field['id_field'], + 2, 65, $custom_value, 'style="min-height: 30px; width:96%;"', true); + } array_push ($table->data, $data); } diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 85cce95437..d1d1044377 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -27,12 +27,14 @@ if (! check_acl ($config['id_user'], 0, "PM")) { $id_field = (int) get_parameter ('id_field', 0); $name = (string) get_parameter ('name', ''); $display_on_front = (bool) get_parameter ('display_on_front', 0); +$is_password_type = (bool) get_parameter ('is_password_type', 0); // Header if ($id_field) { $field = db_get_row_filter('tagent_custom_fields',array('id_field' => $id_field)); $name = $field['name']; $display_on_front = $field['display_on_front']; + $is_password_type = $field['is_password_type']; ui_print_page_header (__("Update agent custom field"), "images/custom_field.png", false, "", true, ""); } else { @@ -48,8 +50,11 @@ $table->data = array (); $table->data[0][0] = __('Name'); $table->data[0][1] = html_print_input_text ('name', $name, '', 35, 100, true); -$table->data[0][2] = __('Display on front').ui_print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true); -$table->data[0][3] = html_print_checkbox ('display_on_front', 1, $display_on_front, true); +$table->data[0][2] = __('Pass type').ui_print_help_tip (__('The fields with pass type enabled will be displayed like html input type pass in html'), true); +$table->data[0][3] = html_print_checkbox ('is_password_type', 1, $is_password_type, true); + +$table->data[0][4] = __('Display on front').ui_print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true); +$table->data[0][5] = html_print_checkbox ('display_on_front', 1, $display_on_front, true); echo '
'; html_print_table ($table); diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index 6491c0f9f9..042aa82e31 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -36,6 +36,7 @@ $delete_field = (bool) get_parameter ('delete_field'); $id_field = (int) get_parameter ('id_field', 0); $name = (string) get_parameter ('name', ''); $display_on_front = (int) get_parameter ('display_on_front', 0); +$is_password_type = (int) get_parameter ('is_password_type', 0); /* Create field */ if ($create_field) { @@ -48,7 +49,8 @@ if ($create_field) { } else { $result = db_process_sql_insert('tagent_custom_fields', - array('name' => $name, 'display_on_front' => $display_on_front)); + array('name' => $name, 'display_on_front' => $display_on_front, + 'is_password_type' => $is_password_type)); ui_print_success_message(__('Field successfully created')); } } @@ -57,7 +59,7 @@ if ($create_field) { if ($update_field) { /*Check if name field is empty*/ if ( $name != "") { - $values = array('name' => $name, 'display_on_front' => $display_on_front); + $values = array('name' => $name, 'display_on_front' => $display_on_front, 'is_password_type' => $is_password_type); $result = db_process_sql_update('tagent_custom_fields', $values, array('id_field' => $id_field)); } diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index 26942b9c4a..fb39f731b8 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -456,7 +456,13 @@ foreach ($fields as $field) { $custom_value = ''; } - $data[1] = html_print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true); + if ($field['is_password_type']) { + $data[1] = html_print_input_text_extended ('customvalue_' . $field['id_field'], $custom_value, 'customvalue_' . $field['id_field'], '', + 30, 100, $view_mode, '', '', true, true); + } + else { + $data[1] = html_print_textarea ('customvalue_'.$field['id_field'], 2, 65, $custom_value, 'style="min-height: 30px;"', true); + } array_push ($table->data, $data); } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 03cc57036e..6ddd8cf1f9 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1382,9 +1382,20 @@ function api_set_create_custom_field($t1, $t2, $other, $returnType) { returnError('error_parameter', 'Custom field display flag required'); return; } + + $is_password_type = 0; + + if ($other['data'][2] != '') { + $is_password_type = $other['data'][2]; + } + else { + returnError('error_parameter', 'Custom field is password type required'); + return; + } $result = db_process_sql_insert('tagent_custom_fields', - array('name' => $name, 'display_on_front' => $display_front)); + array('name' => $name, 'display_on_front' => $display_front, + 'is_password_type' => $is_password_type)); $data['type'] = "string"; $data["data"] = $result; From a4636f3435da0814b050396ae141ea95f9d7565f Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 29 May 2017 11:55:04 +0200 Subject: [PATCH 2/6] Added changes in db --- pandora_console/extras/mr/2.sql | 5 +++++ pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/2.sql diff --git a/pandora_console/extras/mr/2.sql b/pandora_console/extras/mr/2.sql new file mode 100644 index 0000000000..b7784ad87e --- /dev/null +++ b/pandora_console/extras/mr/2.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +ALTER TABLE tagent_custom_fields ADD is_password_type tinyint(1) NOT NULL DEFAULT 0; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 25ebe2bba2..eb49013776 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,7 +109,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 1), +('MR', 2), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), ('current_package_enterprise', '703'), From 1e0af6ec26f2100f5d233536635efd3e1ff35322 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 29 May 2017 11:58:42 +0200 Subject: [PATCH 3/6] Added field to db --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/pandoradb.sql | 1 + 2 files changed, 2 insertions(+) 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 924b107944..83ae59bce0 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 @@ -1219,6 +1219,7 @@ ALTER TABLE tlayout_data ADD `label_position` varchar(50) NOT NULL default 'down -- Table `tagent_custom_fields` -- --------------------------------------------------------------------- INSERT INTO `tagent_custom_fields` (`name`) VALUES ('eHorusID'); +ALTER TABLE tagent_custom_fields ADD `is_password_type` tinyint(1) NOT NULL DEFAULT 0; -- --------------------------------------------------------------------- -- Table `tagente_modulo` Fixed problems with blank space diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b448253ae1..c22bf1b475 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1702,6 +1702,7 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields` ( `id_field` int(10) unsigned NOT NULL auto_increment, `name` varchar(45) NOT NULL default '', `display_on_front` tinyint(1) NOT NULL default 0, + `is_password_type` tinyint(1) NOT NULL default 0, PRIMARY KEY (`id_field`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 9e99bc44858829f20595b55786de9c51f5bf63c4 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 29 May 2017 12:04:38 +0200 Subject: [PATCH 4/6] Added new field to pandoradb_data --- pandora_console/pandoradb_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index eb49013776..877c0aa69b 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1144,7 +1144,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `p INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (9,'Packet Loss','Checks for dropped packages after X seconds of testing. It returns % of dropped packets. It uses ping flood mode to launch 50 consecutive pings to a remote destination. On local, stable networks, value should be 0. ',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_ _field2_'); -INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0),(2,'Department',0),(3,'Additional ID',0),(4,'eHorusID',0); +INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0),(2,'Department',0,0),(3,'Additional ID',0,0),(4,'eHorusID',0,0); INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','',''); From efd28c0513b582f8e92c980a48dec24e378d0e91 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 1 Jun 2017 11:28:24 +0200 Subject: [PATCH 5/6] Added Enrique Camargo db changes to mr number 2 --- pandora_console/extras/mr/2.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/extras/mr/2.sql b/pandora_console/extras/mr/2.sql index b7784ad87e..f246a1900d 100644 --- a/pandora_console/extras/mr/2.sql +++ b/pandora_console/extras/mr/2.sql @@ -2,4 +2,6 @@ START TRANSACTION; ALTER TABLE tagent_custom_fields ADD is_password_type tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE treport_content ADD COLUMN historical_db tinyint(1) NOT NULL DEFAULT 0; + COMMIT; \ No newline at end of file From 7a9f63f2122aa2fcca72039ab0a21bfce59a5aff Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 1 Jun 2017 14:30:34 +0200 Subject: [PATCH 6/6] Added change to db --- pandora_console/extras/mr/2.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/extras/mr/2.sql b/pandora_console/extras/mr/2.sql index f246a1900d..4b1e944dc1 100644 --- a/pandora_console/extras/mr/2.sql +++ b/pandora_console/extras/mr/2.sql @@ -4,4 +4,6 @@ ALTER TABLE tagent_custom_fields ADD is_password_type tinyint(1) NOT NULL DEFAUL ALTER TABLE treport_content ADD COLUMN historical_db tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE tpolicy_modules ADD COLUMN ip_target varchar(100) default ''; + COMMIT; \ No newline at end of file