From 3bb8455d396cc1751245f43d7eccaf4af14fb096 Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Tue, 4 May 2021 15:18:20 +0200 Subject: [PATCH 1/2] Remove Network Source Interface from gvmd --- CMakeLists.txt | 2 +- src/gmp.c | 12 +-------- src/manage.c | 7 +---- src/manage_migrators.c | 34 ++++++++++++++++++++++++ src/manage_pg.c | 1 - src/manage_sql.c | 44 ------------------------------- src/schema_formats/XML/GMP.xml.in | 43 ------------------------------ 7 files changed, 37 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c17166b07..2e67f6ccc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ include (CPack) ## Variables -set (GVMD_DATABASE_VERSION 242) +set (GVMD_DATABASE_VERSION 243) set (GVMD_SCAP_DATABASE_VERSION 18) diff --git a/src/gmp.c b/src/gmp.c index ed86e8431..fc4a3539a 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -16941,7 +16941,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) double severity = 0, severity_2 = 0; gchar *response; iterator_t alerts, groups, roles; - gchar *in_assets, *max_checks, *max_hosts, *source_iface; + gchar *in_assets, *max_checks, *max_hosts; gchar *auto_delete, *auto_delete_data, *assets_apply_overrides; gchar *assets_min_qod; @@ -17462,7 +17462,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) assets_min_qod = task_preference_value (index, "assets_min_qod"); max_checks = task_preference_value (index, "max_checks"); max_hosts = task_preference_value (index, "max_hosts"); - source_iface = task_preference_value (index, "source_iface"); auto_delete = task_preference_value (index, "auto_delete"); auto_delete_data = task_preference_value (index, "auto_delete_data"); @@ -17484,13 +17483,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) "" "" "" - "Network Source Interface" - "" - "source_iface" - "%s" - "" - "" - "" "Add results to Asset Management" "" "in_assets" @@ -17528,7 +17520,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) "", max_checks ? max_checks : "4", max_hosts ? max_hosts : "20", - source_iface ? source_iface : "", in_assets ? in_assets : "yes", assets_apply_overrides ? assets_apply_overrides : "yes", assets_min_qod @@ -17540,7 +17531,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) g_free (in_assets); g_free (max_checks); g_free (max_hosts); - g_free (source_iface); } count++; diff --git a/src/manage.c b/src/manage.c index 77de2ce61..ececa199f 100644 --- a/src/manage.c +++ b/src/manage.c @@ -2459,7 +2459,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id, GHashTable *vts_hash_table; osp_credential_t *ssh_credential, *smb_credential, *esxi_credential; osp_credential_t *snmp_credential; - gchar *max_checks, *max_hosts, *source_iface, *hosts_ordering; + gchar *max_checks, *max_hosts, *hosts_ordering; GHashTable *scanner_options; int ret; config_t config; @@ -2584,11 +2584,6 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id, g_hash_table_insert (scanner_options, g_strdup ("max_hosts"), max_hosts ? max_hosts : g_strdup (MAX_HOSTS_DEFAULT)); - source_iface = task_preference_value (task, "source_iface"); - if (source_iface) - g_hash_table_insert (scanner_options, g_strdup ("source_iface"), - source_iface); - hosts_ordering = task_hosts_ordering (task); if (hosts_ordering) g_hash_table_insert (scanner_options, g_strdup ("hosts_ordering"), diff --git a/src/manage_migrators.c b/src/manage_migrators.c index 2e32c99c4..459169bb2 100644 --- a/src/manage_migrators.c +++ b/src/manage_migrators.c @@ -2651,6 +2651,39 @@ migrate_241_to_242 () return 0; } +/** + * @brief Migrate the database from version 242 to version 243. + * + * @return 0 success, -1 error. + */ +int +migrate_242_to_243 () +{ + sql_begin_immediate (); + + /* Ensure that the database is currently version 242. */ + + if (manage_db_version () != 242) + { + sql_rollback (); + return -1; + } + + /* Update the database. */ + + sql ("ALTER TABLE reports DROP COLUMN source_iface;"); + + /* Set the database version to 243. */ + + set_db_version (243); + + sql_commit (); + + return 0; +} + + + #undef UPDATE_DASHBOARD_SETTINGS /** @@ -2699,6 +2732,7 @@ static migrator_t database_migrators[] = { {240, migrate_239_to_240}, {241, migrate_240_to_241}, {242, migrate_241_to_242}, + {243, migrate_242_to_243}, /* End marker. */ {-1, NULL}}; diff --git a/src/manage_pg.c b/src/manage_pg.c index 8957eb5a2..7ce29eadd 100644 --- a/src/manage_pg.c +++ b/src/manage_pg.c @@ -2308,7 +2308,6 @@ create_tables () " comment text," " scan_run_status integer," " slave_progress integer," - " source_iface text," " flags integer);"); sql ("CREATE TABLE IF NOT EXISTS report_counts" diff --git a/src/manage_sql.c b/src/manage_sql.c index 3d744387b..17265ccf2 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -20722,20 +20722,6 @@ report_compliance_by_uuid (const char *report_id, g_free (quoted_uuid); } -/** - * @brief Return the source interface of a report. - * - * @param[in] report Report. - * - * @return Source interface. - */ -static char* -report_source_iface (report_t report) -{ - return sql_string ("SELECT source_iface FROM reports WHERE id = %llu;", - report); -} - /** * @brief Add a result to a report. * @@ -27558,36 +27544,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, PRINT (out, ""); - { - char *source_iface; - - /* Info about the situation at the time of scan. */ - - PRINT (out, - "" - ""); - - source_iface = report_source_iface (report); - - if (source_iface) - /* VALUE "" means preference was not set. Missing PREFERENCE means - * we don't know. */ - PRINT (out, - "" - "" - "Network Source Interface" - "source_iface" - "%s" - "" - "", - source_iface); - - free (source_iface); - - PRINT (out, - "" - ""); - } } uuid = report_uuid (report); diff --git a/src/schema_formats/XML/GMP.xml.in b/src/schema_formats/XML/GMP.xml.in index 027cd8536..588fc3950 100644 --- a/src/schema_formats/XML/GMP.xml.in +++ b/src/schema_formats/XML/GMP.xml.in @@ -1930,7 +1930,6 @@ along with this program. If not, see . result_count severity task - scan ports results hosts @@ -2485,48 +2484,6 @@ along with this program. If not, see . - - scan - Info from scan time - - task - - - task - - preferences - - - preferences - Currently only "source_iface" - - preference - - - preference - - name - scanner_name - value - - - name - Full name of preference, suitable for end users - text - - - scanner_name - Compact name of preference, from scanner - text - - - value - text - - - - - ports From efdbb101f5b0279a51a7f1894000860c0af0bd1f Mon Sep 17 00:00:00 2001 From: Johannes Helmold Date: Tue, 4 May 2021 15:57:35 +0200 Subject: [PATCH 2/2] Adjusted CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c22c505f..50f8bcb4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix migration to DB version 242 from gvmd 20.08 [#1498](https://github.com/greenbone/gvmd/pull/1498) ### Removed +- Remove Network Source Interface from gvmd [#1511](https://github.com/greenbone/gvmd/pull/1511) [21.4]: https://github.com/greenbone/gvmd/compare/gvmd-21.04...master