From e3a4c7a5a3229fd0f77103ac02324375e4e098f3 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Thu, 10 Sep 2020 23:19:50 +0200 Subject: [PATCH 01/23] Remove autofp from result_iterator_opts_table(). --- src/manage_sql.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 5fa4dc4da..743e4e70a 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21682,14 +21682,13 @@ where_qod (int min_qod) /** * @brief Generate the extra_tables string for a result iterator. * - * @param[in] autofp Whether to apply auto FP filter. * @param[in] override Whether to apply overrides. * @param[in] dynamic Whether to use dynamic severity scores. * * @return Newly allocated string with the extra_tables clause. */ static gchar* -result_iterator_opts_table (int autofp, int override, int dynamic) +result_iterator_opts_table (int override, int dynamic) { user_t user_id; gchar *user_zone, *quoted_user_zone, *ret; @@ -21724,12 +21723,10 @@ result_iterator_opts_table (int autofp, int override, int dynamic) (", (SELECT" " '%s'::text AS user_zone," " %llu AS user_id," - " %d AS autofp," " %d AS override," " %d AS dynamic) AS opts", quoted_user_zone, user_id, - autofp, override, dynamic); @@ -22009,7 +22006,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, if (autofp == 0) columns[0].select = "0"; - extra_tables = result_iterator_opts_table (autofp, apply_overrides, + extra_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); extra_where = results_extra_where (get->trash, report, host, @@ -22127,8 +22124,7 @@ init_result_get_iterator (iterator_t* iterator, const get_data_t *get, autofp = filter_term_autofp (filter ? filter : get->filter); dynamic_severity = setting_dynamic_severity_int (); - opts_tables - = result_iterator_opts_table (autofp, apply_overrides, dynamic_severity); + opts_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); extra_tables = g_strdup_printf (" LEFT OUTER JOIN nvts" " ON results.nvt = nvts.oid %s", opts_tables); @@ -22198,8 +22194,7 @@ result_count (const get_data_t *get, report_t report, const char* host) autofp = filter_term_autofp (filter ? filter : get->filter); dynamic_severity = setting_dynamic_severity_int (); - opts_tables - = result_iterator_opts_table (autofp, apply_overrides, dynamic_severity); + opts_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); extra_tables = g_strdup_printf (" LEFT OUTER JOIN nvts" " ON results.nvt = nvts.oid %s", opts_tables); @@ -54453,8 +54448,7 @@ type_opts_table (const char *type, const char *filter) return report_iterator_opts_table (filter_term_apply_overrides (filter), filter_term_min_qod (filter)); if (strcasecmp (type, "RESULT") == 0) - return result_iterator_opts_table (filter_term_autofp (filter), - filter_term_apply_overrides (filter), + return result_iterator_opts_table (filter_term_apply_overrides (filter), setting_dynamic_severity_int ()); if (strcasecmp (type, "VULN") == 0) { From 9eb68907bee94a62793e1310323ffb365b9050e4 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Thu, 10 Sep 2020 23:38:22 +0200 Subject: [PATCH 02/23] Remove autofp from results_extra_where(). --- src/manage_sql.c | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 743e4e70a..37dcd21cb 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21741,7 +21741,6 @@ result_iterator_opts_table (int override, int dynamic) * @param[in] trash Whether to get results from trashcan. * @param[in] report Report to restrict returned results to. * @param[in] host Host to restrict returned results to. - * @param[in] autofp Whether to apply auto FP filter. * @param[in] apply_overrides Whether to apply overrides. * @param[in] dynamic_severity Whether to use dynamic severity. * @param[in] filter Filter string. @@ -21750,7 +21749,7 @@ result_iterator_opts_table (int override, int dynamic) */ static gchar* results_extra_where (int trash, report_t report, const gchar* host, - int autofp, int apply_overrides, int dynamic_severity, + int apply_overrides, int dynamic_severity, const gchar *filter) { gchar *extra_where; @@ -21768,25 +21767,7 @@ results_extra_where (int trash, report_t report, const gchar* host, // Build clause fragments - switch (autofp) - { - case 1: - auto_type_sql = g_strdup_printf - ("(SELECT autofp FROM results_autofp" - " WHERE result = results.id" - " AND autofp_selection = 1)"); - break; - case 2: - auto_type_sql = g_strdup_printf - ("(SELECT autofp FROM results_autofp" - " WHERE result = results.id" - " AND autofp_selection = 2)"); - break; - - default: - auto_type_sql = g_strdup ("NULL"); - break; - } + auto_type_sql = g_strdup ("NULL"); new_severity_sql = g_strdup_printf ("(SELECT new_severity FROM result_new_severities" @@ -22010,7 +21991,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, dynamic_severity); extra_where = results_extra_where (get->trash, report, host, - autofp, apply_overrides, dynamic_severity, + apply_overrides, dynamic_severity, filter ? filter : get->filter); free (filter); @@ -22102,7 +22083,7 @@ init_result_get_iterator (iterator_t* iterator, const get_data_t *get, static column_t columns_no_cert[] = RESULT_ITERATOR_COLUMNS_NO_CERT; int ret; gchar *filter, *extra_tables, *extra_where, *opts_tables; - int autofp, apply_overrides, dynamic_severity; + int apply_overrides, dynamic_severity; if (report == -1) { @@ -22121,7 +22102,6 @@ init_result_get_iterator (iterator_t* iterator, const get_data_t *get, apply_overrides = filter_term_apply_overrides (filter ? filter : get->filter); - autofp = filter_term_autofp (filter ? filter : get->filter); dynamic_severity = setting_dynamic_severity_int (); opts_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); @@ -22131,7 +22111,7 @@ init_result_get_iterator (iterator_t* iterator, const get_data_t *get, g_free (opts_tables); extra_where = results_extra_where (get->trash, report, host, - autofp, apply_overrides, dynamic_severity, + apply_overrides, dynamic_severity, filter ? filter : get->filter); free (filter); @@ -22175,7 +22155,7 @@ result_count (const get_data_t *get, report_t report, const char* host) static column_t columns_no_cert[] = RESULT_ITERATOR_COLUMNS_NO_CERT; int ret; gchar *filter, *extra_tables, *extra_where, *opts_tables; - int apply_overrides, autofp, dynamic_severity; + int apply_overrides, dynamic_severity; if (report == -1) return 0; @@ -22191,7 +22171,6 @@ result_count (const get_data_t *get, report_t report, const char* host) apply_overrides = filter_term_apply_overrides (filter ? filter : get->filter); - autofp = filter_term_autofp (filter ? filter : get->filter); dynamic_severity = setting_dynamic_severity_int (); opts_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); @@ -22201,7 +22180,7 @@ result_count (const get_data_t *get, report_t report, const char* host) g_free (opts_tables); extra_where = results_extra_where (get->trash, report, host, - autofp, apply_overrides, dynamic_severity, + apply_overrides, dynamic_severity, filter ? filter : get->filter); ret = count ("result", get, @@ -54546,7 +54525,7 @@ type_extra_where (const char *type, int trash, const char *filter, } else if (strcasecmp (type, "RESULT") == 0) { - int autofp, apply_overrides; + int apply_overrides; gchar *report_id; report_t report; @@ -54573,11 +54552,10 @@ type_extra_where (const char *type, int trash, const char *filter, } g_free (report_id); - autofp = filter_term_autofp (filter); apply_overrides = filter_term_apply_overrides (filter); extra_where = results_extra_where (trash, report, NULL, - autofp, apply_overrides, + apply_overrides, setting_dynamic_severity_int (), filter); } From 4fa2d39360ff320b2eb4fe648fce0ffc7375d4f9 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Thu, 10 Sep 2020 23:45:47 +0200 Subject: [PATCH 03/23] Remove autofp from manage_report_filter_control() --- src/gmp.c | 1 - src/manage.h | 2 +- src/manage_sql.c | 19 ++++--------------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index 3595d0e0c..f500e3ee8 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -15275,7 +15275,6 @@ handle_get_results (gmp_parser_t *gmp_parser, GError **error) NULL, /* delta_states */ NULL, /* search_phrase */ NULL, /* search_phrase_exact */ - NULL, /* autofp */ ¬es, &overrides, NULL, /* apply_overrides */ diff --git a/src/manage.h b/src/manage.h index b1c3be71e..699bf7097 100644 --- a/src/manage.h +++ b/src/manage.h @@ -1536,7 +1536,7 @@ manage_filter_controls (const gchar *, int *, int *, gchar **, int *); void manage_report_filter_controls (const gchar *, int *, int *, gchar **, int *, int *, gchar **, gchar **, gchar **, gchar **, - int *, int *, int *, int *, int *, gchar **); + int *, int *, int *, int *, gchar **); gchar * manage_clean_filter (const gchar *); diff --git a/src/manage_sql.c b/src/manage_sql.c index 37dcd21cb..86cea5400 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -2010,7 +2010,6 @@ filter_control_str (keyword_t **point, const char *column, gchar **string) * @param[out] search_phrase Phrase that results must include. All results * if NULL or "". * @param[out] search_phrase_exact Whether search phrase is exact. - * @param[out] autofp Whether to apply auto FP filter. * @param[out] notes Whether to include notes. * @param[out] overrides Whether to include overrides. * @param[out] apply_overrides Whether to apply overrides. @@ -2022,7 +2021,7 @@ manage_report_filter_controls (const gchar *filter, int *first, int *max, int *result_hosts_only, gchar **min_qod, gchar **levels, gchar **delta_states, gchar **search_phrase, int *search_phrase_exact, - int *autofp, int *notes, int *overrides, + int *notes, int *overrides, int *apply_overrides, gchar **zone) { keyword_t **point; @@ -2147,16 +2146,6 @@ manage_report_filter_controls (const gchar *filter, int *first, int *max, *result_hosts_only = val; } - if (autofp) - { - if (filter_control_int ((keyword_t **) split->pdata, - "autofp", - &val)) - *autofp = 0; - else - *autofp = val; - } - if (notes) { if (filter_control_int ((keyword_t **) split->pdata, @@ -26968,7 +26957,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, int result_hosts_only; int notes, overrides; - int first_result, max_results, sort_order, autofp; + int first_result, max_results, sort_order; FILE *out; gchar *clean, *term, *sort_field, *levels, *search_phrase; @@ -27058,7 +27047,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, &sort_order, &result_hosts_only, &min_qod, &levels, &delta_states, &search_phrase, &search_phrase_exact, - &autofp, ¬es, &overrides, + ¬es, &overrides, &apply_overrides, &zone); } else @@ -27070,7 +27059,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, &sort_order, &result_hosts_only, &min_qod, &levels, &delta_states, &search_phrase, &search_phrase_exact, - &autofp, ¬es, &overrides, + ¬es, &overrides, &apply_overrides, &zone); } From 63bd3a40eec822f3eaba0922177917b5703afda1 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sat, 12 Sep 2020 17:59:33 +0200 Subject: [PATCH 04/23] Remove autofp handling from report_severity_data() --- src/manage_sql.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 86cea5400..f8536dd20 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -23583,7 +23583,7 @@ report_severity_data (report_t report, const char *host, iterator_t results; gchar *filter; - int apply_overrides, autofp; + int apply_overrides ; if (report == 0) return; @@ -23597,13 +23597,12 @@ report_severity_data (report_t report, const char *host, apply_overrides = filter_term_apply_overrides (filter ? filter : get->filter); - autofp = filter_term_autofp (filter ? filter : get->filter); if (severity_data) { get_data_t *get_all; - get_all = report_results_get_data (1, -1, apply_overrides, autofp, 0); + get_all = report_results_get_data (1, -1, apply_overrides, 0, 0); ignore_max_rows_per_page = 1; init_result_get_iterator_severity (&results, get_all, report, host, NULL); ignore_max_rows_per_page = 0; From b2f64c3db75280917ba2663c1326688ffa973c1e Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:20:37 +0200 Subject: [PATCH 05/23] Remove autofp from report_counts() --- src/gmp.c | 9 +++------ src/manage.h | 4 ++-- src/manage_sql.c | 5 ++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index f500e3ee8..276af5654 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -17140,8 +17140,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) if (report_counts (first_report_id, &debugs, &holes_2, &infos_2, &logs, &warnings_2, &false_positives, - &severity_2, apply_overrides, - 0, min_qod)) + &severity_2, apply_overrides, min_qod)) g_error ("%s: GET_TASKS: error getting counts for" " first report, aborting", __func__); @@ -17158,8 +17157,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) &debugs, &holes_2, &infos_2, &logs, &warnings_2, &false_positives, &severity_2, - apply_overrides, - 0, min_qod)) + apply_overrides, min_qod)) g_error ("%s: GET_TASKS: error getting counts for" " second report, aborting", __func__); @@ -17212,8 +17210,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error) (last_report_id, &debugs, &holes, &infos, &logs, &warnings, &false_positives, &severity, - apply_overrides, - 0, min_qod)) + apply_overrides, min_qod)) g_error ("%s: GET_TASKS: error getting counts for" " last report, aborting", __func__); diff --git a/src/manage.h b/src/manage.h index 699bf7097..294fcfa5c 100644 --- a/src/manage.h +++ b/src/manage.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2019 Greenbone Networks GmbH +/* Copyright (C) 2009-2020 Greenbone Networks GmbH * * SPDX-License-Identifier: AGPL-3.0-or-later * @@ -1247,7 +1247,7 @@ report_scan_result_count (report_t, const char*, const char*, int, const char*, int report_counts (const char*, int*, int*, int*, int*, int*, int*, double*, - int, int, int); + int, int); int report_counts_id (report_t, int*, int*, int*, int*, int*, int*, double*, diff --git a/src/manage_sql.c b/src/manage_sql.c index f8536dd20..2f1eab9ee 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -23671,7 +23671,6 @@ report_severity_data (report_t report, const char *host, * @param[out] false_positives Number of false positives. * @param[out] severity Maximum severity score. * @param[in] override Whether to override the threat. - * @param[in] autofp Whether to apply the auto FP filter. * @param[in] min_qod Min QOD. * * @return 0 on success, -1 on error. @@ -23679,7 +23678,7 @@ report_severity_data (report_t report, const char *host, int report_counts (const char* report_id, int* debugs, int* holes, int* infos, int* logs, int* warnings, int* false_positives, double* severity, - int override, int autofp, int min_qod) + int override, int min_qod) { report_t report; int ret; @@ -23689,7 +23688,7 @@ report_counts (const char* report_id, int* debugs, int* holes, int* infos, return -1; // TODO Check if report was found. - get = report_results_get_data (1, -1, override, autofp, min_qod); + get = report_results_get_data (1, -1, override, 0, min_qod); ret = report_counts_id (report, debugs, holes, infos, logs, warnings, false_positives, severity, get, NULL); get_data_reset (get); From 9e39b9c1344210aca5e8ca7a80f97c7ae3bc97fe Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:28:08 +0200 Subject: [PATCH 06/23] Remove filter_term_autofp() --- src/manage_sql.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 2f1eab9ee..56efbfa60 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21971,7 +21971,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, columns[2].filter = NULL; columns[2].type = KEYWORD_TYPE_UNKNOWN; - autofp = filter_term_autofp (filter ? filter : get->filter); + autofp = 0; if (autofp == 0) columns[0].select = "0"; @@ -44382,31 +44382,6 @@ filter_term_apply_overrides (const char *term) return APPLY_OVERRIDES_DEFAULT; } -/** - * @brief Return the value of the autofp keyword of a filter term. - * - * @param[in] term Filter term. - * - * @return Value of autofp if it exists, else 0. - */ -int -filter_term_autofp (const char *term) -{ - if (term) - { - int ret; - gchar *autofp_str; - - autofp_str = filter_term_value (term, "autofp"); - ret = autofp_str ? atoi (autofp_str) : 0; - - g_free (autofp_str); - return ret; - } - else - return 0; -} - /** * @brief Return the value of the min_qod keyword of a filter term. * From 3bf8c8f63a41a3f6febd7f188a8c8188ab8178a3 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:34:09 +0200 Subject: [PATCH 07/23] Remove handling of "autofp" in filter string. --- src/manage_sql.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 56efbfa60..5d8676f15 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -1315,23 +1315,6 @@ cleanup_keyword (keyword_t *keyword) } keyword->relation = KEYWORD_RELATION_COLUMN_EQUAL; } - else if (strcasecmp (keyword->column, "autofp") == 0) - { - /* autofp must be either 0, 1 or 2) */ - if (keyword->integer_value < 0) - { - g_free (keyword->string); - keyword->integer_value = 0; - keyword->string = g_strdup ("0"); - } - else if (keyword->integer_value > 2) - { - g_free (keyword->string); - keyword->integer_value = 0; - keyword->string = g_strdup ("0"); - } - keyword->relation = KEYWORD_RELATION_COLUMN_EQUAL; - } else if (strcasecmp (keyword->column, "apply_overrides") == 0 || strcasecmp (keyword->column, "overrides") == 0 || strcasecmp (keyword->column, "notes") == 0 @@ -1434,21 +1417,6 @@ keyword_applies (array_t *array, const keyword_t *keyword) } } - if (keyword->column - && (strcmp (keyword->column, "autofp") == 0)) - { - int index; - - index = array->len; - while (index--) - { - keyword_t *item; - item = (keyword_t*) g_ptr_array_index (array, index); - if (item->column && (strcmp (item->column, "autofp") == 0)) - return 0; - } - } - if (keyword->column && (strcmp (keyword->column, "delta_states") == 0)) { @@ -23969,15 +23937,6 @@ report_counts_id_full (report_t report, int* debugs, int* holes, int* infos, || sscanf (keyword->string, "%d", &min_qod_int) != 1) min_qod_int = MIN_QOD_DEFAULT; } - else if (strcasecmp (keyword->column, "autofp") == 0) - { - if (keyword->string - && strcmp (keyword->string, "") - && strcmp (keyword->string, "0")) - { - filter_cacheable = FALSE; - } - } else { filter_cacheable = FALSE; From 811a5ba966581cc07828db705720c905be32f8d0 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:43:51 +0200 Subject: [PATCH 08/23] Remove autofp for columns. The columns array for index 0 was reserved for autofp. So, for removing autofp the index 1 need to become 0 and 2 become 1. --- src/manage_sql.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 5d8676f15..c464461ed 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21791,7 +21791,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, report_t report, const char* host, const gchar *extra_order) { - column_t columns[3]; + column_t columns[2]; static column_t static_filterable_columns[] = RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE; static column_t static_filterable_columns_no_cert[] @@ -21800,19 +21800,13 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, column_t *filterable_columns; int ret; gchar *filter; - int autofp, apply_overrides, dynamic_severity; + int apply_overrides, dynamic_severity; gchar *extra_tables, *extra_where, *owned_clause, *with_clause; gchar *with_clauses; char *user_id; assert (report); - columns[0].select - = "(SELECT autofp FROM results_autofp" - " WHERE (result = results.id) AND (autofp_selection = opts.autofp))"; - columns[0].filter = "auto_type"; - columns[0].type = KEYWORD_TYPE_INTEGER; - dynamic_severity = setting_dynamic_severity_int (); if (get->filt_id && strcmp (get->filt_id, FILT_ID_NONE)) @@ -21847,7 +21841,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, if (dynamic_severity) { if (apply_overrides) - columns[1].select + columns[0].select = "(SELECT coalesce ((SELECT new_severity FROM valid_overrides" " WHERE valid_overrides.result_nvt" " = results.result_nvt" @@ -21892,7 +21886,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, " END)," " results.severity)))"; else - columns[1].select + columns[0].select = "(SELECT coalesce ((CASE WHEN results.severity" " > " G_STRINGIFY (SEVERITY_LOG) " THEN (SELECT CAST (cvss_base" @@ -21906,7 +21900,7 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, else { if (apply_overrides) - columns[1].select + columns[0].select = "(SELECT coalesce ((SELECT new_severity FROM valid_overrides" " WHERE valid_overrides.result_nvt" " = results.result_nvt" @@ -21928,21 +21922,16 @@ init_result_get_iterator_severity (iterator_t* iterator, const get_data_t *get, " LIMIT 1)," " results.severity))"; else - columns[1].select + columns[0].select = "(SELECT results.severity)"; } - columns[1].filter = "severity"; - columns[1].type = KEYWORD_TYPE_DOUBLE; - - columns[2].select = NULL; - columns[2].filter = NULL; - columns[2].type = KEYWORD_TYPE_UNKNOWN; - - autofp = 0; + columns[0].filter = "severity"; + columns[0].type = KEYWORD_TYPE_DOUBLE; - if (autofp == 0) - columns[0].select = "0"; + columns[1].select = NULL; + columns[1].filter = NULL; + columns[1].type = KEYWORD_TYPE_UNKNOWN; extra_tables = result_iterator_opts_table (apply_overrides, dynamic_severity); From 72b304113cc91034b03223f2b40791c4bafafb26 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:49:19 +0200 Subject: [PATCH 09/23] Remove unneeded proto. --- src/manage.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/manage.h b/src/manage.h index 294fcfa5c..9f4aa33ba 100644 --- a/src/manage.h +++ b/src/manage.h @@ -2966,9 +2966,6 @@ filter_term_value (const char *, const char *); int filter_term_apply_overrides (const char *); -int -filter_term_autofp (const char *); - int filter_term_min_qod (const char *); From 99a66082e0c7757f012c3c4f548b166ca91e0547 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:57:31 +0200 Subject: [PATCH 10/23] Drop param autofp from report_results_get_data() --- src/gmp.c | 4 +--- src/manage.c | 5 ++--- src/manage.h | 2 +- src/manage_sql.c | 12 ++++++------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gmp.c b/src/gmp.c index 276af5654..31d50af83 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2019 Greenbone Networks GmbH +/* Copyright (C) 2009-2020 Greenbone Networks GmbH * * SPDX-License-Identifier: AGPL-3.0-or-later * @@ -8273,7 +8273,6 @@ buffer_notes_xml (GString *buffer, iterator_t *notes, int include_notes_details, get_data_t *result_get; result_get = report_results_get_data (1, 1, 1, /* apply_overrides */ - 0, /* autofp*/ 0 /* min_qod */); result_get->id = g_strdup (uuid_result); init_result_get_iterator (&results, result_get, @@ -8556,7 +8555,6 @@ buffer_overrides_xml (GString *buffer, iterator_t *overrides, get_data_t *result_get; result_get = report_results_get_data (1, 1, 1, /* apply_overrides */ - 0, /* autofp */ 0 /* min_qod */); result_get->id = g_strdup (uuid_result); init_result_get_iterator (&results, result_get, diff --git a/src/manage.c b/src/manage.c index 8929fa673..154214c23 100644 --- a/src/manage.c +++ b/src/manage.c @@ -998,20 +998,19 @@ report_results_filter_term (int first, int rows, * @param[in] first First row. * @param[in] rows Number of rows. * @param[in] apply_overrides Whether to apply overrides. - * @param[in] autofp Auto-FP value. * @param[in] min_qod Minimum QOD. * * @return GET data struct. */ get_data_t* report_results_get_data (int first, int rows, - int apply_overrides, int autofp, int min_qod) + int apply_overrides, int min_qod) { get_data_t* get = g_malloc (sizeof (get_data_t)); memset (get, 0, sizeof (get_data_t)); get->type = g_strdup ("result"); get->filter = report_results_filter_term (first, rows, - apply_overrides, autofp, min_qod); + apply_overrides, 0, min_qod); return get; } diff --git a/src/manage.h b/src/manage.h index 9f4aa33ba..379b750aa 100644 --- a/src/manage.h +++ b/src/manage.h @@ -1258,7 +1258,7 @@ report_counts_id_no_filt (report_t, int*, int*, int*, int*, int*, int*, double*, const get_data_t*, const char*); get_data_t* -report_results_get_data (int, int, int, int, int); +report_results_get_data (int, int, int, int); int scan_start_time_epoch (report_t); diff --git a/src/manage_sql.c b/src/manage_sql.c index c464461ed..29029856d 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2019 Greenbone Networks GmbH +/* Copyright (C) 2009-2020 Greenbone Networks GmbH * * SPDX-License-Identifier: AGPL-3.0-or-later * @@ -19894,7 +19894,7 @@ report_cache_counts (report_t report, int clear_original, int clear_overridden, user); manage_session_init (current_credentials.uuid); - get = report_results_get_data (1, -1, override, 0, min_qod); + get = report_results_get_data (1, -1, override, min_qod); if ((clear_original && override == 0) || (clear_overridden && override)) { @@ -23559,7 +23559,7 @@ report_severity_data (report_t report, const char *host, { get_data_t *get_all; - get_all = report_results_get_data (1, -1, apply_overrides, 0, 0); + get_all = report_results_get_data (1, -1, apply_overrides, 0); ignore_max_rows_per_page = 1; init_result_get_iterator_severity (&results, get_all, report, host, NULL); ignore_max_rows_per_page = 0; @@ -23645,7 +23645,7 @@ report_counts (const char* report_id, int* debugs, int* holes, int* infos, return -1; // TODO Check if report was found. - get = report_results_get_data (1, -1, override, 0, min_qod); + get = report_results_get_data (1, -1, override, min_qod); ret = report_counts_id (report, debugs, holes, infos, logs, warnings, false_positives, severity, get, NULL); get_data_reset (get); @@ -24056,7 +24056,7 @@ report_severity (report_t report, int overrides, int min_qod) else { g_debug ("%s: could not get max from cache", __func__); - get_data_t *get = report_results_get_data (1, -1, overrides, 0, min_qod); + get_data_t *get = report_results_get_data (1, -1, overrides, min_qod); report_counts_id (report, NULL, NULL, NULL, NULL, NULL, NULL, &severity, get, NULL); get_data_reset (get); @@ -27130,7 +27130,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, int total_warnings, total_false_positives; get_data_t *all_results_get; - all_results_get = report_results_get_data (1, -1, 0, 0, 0); + all_results_get = report_results_get_data (1, -1, 0, 0); report_counts_id (report, &total_debugs, &total_holes, &total_infos, &total_logs, &total_warnings, &total_false_positives, NULL, all_results_get, From 46d66302610de3c415810266a42133b9f18793df Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 14:59:18 +0200 Subject: [PATCH 11/23] Drop autofp from report_results_filter_term() --- src/manage.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/manage.c b/src/manage.c index 154214c23..56edcc359 100644 --- a/src/manage.c +++ b/src/manage.c @@ -983,12 +983,11 @@ delete_reports (task_t task) */ static gchar * report_results_filter_term (int first, int rows, - int apply_overrides, int autofp, int min_qod) + int apply_overrides, int min_qod) { return g_strdup_printf ("first=%d rows=%d" - " apply_overrides=%d autofp=%d min_qod=%d", - first, rows, - apply_overrides, autofp, min_qod); + " apply_overrides=%d min_qod=%d", + first, rows, apply_overrides, min_qod); } @@ -1010,7 +1009,7 @@ report_results_get_data (int first, int rows, memset (get, 0, sizeof (get_data_t)); get->type = g_strdup ("result"); get->filter = report_results_filter_term (first, rows, - apply_overrides, 0, min_qod); + apply_overrides, min_qod); return get; } From 6a29f12cef5040e740c03b3881faa3237aec862a Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 15:24:14 +0200 Subject: [PATCH 12/23] For type do not consider autofp anymore. In the result iterator for severity type, the autofp was preferred if exists. Now only the overriden alone is applied. This makes the iterator element number 5 unneeded. --- src/manage.c | 1 - src/manage_sql.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/manage.c b/src/manage.c index 56edcc359..0bba6eb44 100644 --- a/src/manage.c +++ b/src/manage.c @@ -976,7 +976,6 @@ delete_reports (task_t task) * @param[in] first First row. * @param[in] rows Number of rows. * @param[in] apply_overrides Whether to apply overrides. - * @param[in] autofp Auto-FP value. * @param[in] min_qod Minimum QOD. * * @return Filter term. diff --git a/src/manage_sql.c b/src/manage_sql.c index 29029856d..65291baeb 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -22355,7 +22355,7 @@ DEF_ACCESS (result_iterator_original_type, GET_ITERATOR_COLUMN_COUNT + 3); /** * @brief Get the type from a result iterator. * - * This is the the autofp adjusted overridden type. + * This is the overridden type. * * @param[in] iterator Iterator. * @@ -22366,9 +22366,6 @@ static const char* result_iterator_type (iterator_t *iterator) { if (iterator->done) return NULL; - /* auto_type */ - if (iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 5)) - return "False Positive"; /* new_type */ return iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 4); } From 2b112aa18ee5f78b61ed105a18311e406e309fd6 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 15:35:17 +0200 Subject: [PATCH 13/23] Remove autfp from results interator. Autofp was number 5 in the iterator count, so decrease any iterator element beyond 5 by 1. --- src/manage_sql.c | 70 +++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 65291baeb..c4eef770d 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21492,10 +21492,6 @@ where_qod (int min_qod) " LIMIT 1))", \ "type", \ KEYWORD_TYPE_STRING }, \ - { "(SELECT autofp FROM results_autofp" \ - " WHERE (result = results.id) AND (autofp_selection = opts.autofp))", \ - "auto_type", \ - KEYWORD_TYPE_INTEGER }, \ { "description", NULL, KEYWORD_TYPE_STRING }, \ { "task", NULL, KEYWORD_TYPE_INTEGER }, \ { "report", "report_rowid", KEYWORD_TYPE_INTEGER }, \ @@ -22378,7 +22374,7 @@ result_iterator_type (iterator_t *iterator) * @return The descr of the result. Caller must only use before calling * cleanup_iterator. */ -DEF_ACCESS (result_iterator_descr, GET_ITERATOR_COLUMN_COUNT + 6); +DEF_ACCESS (result_iterator_descr, GET_ITERATOR_COLUMN_COUNT + 5); /** * @brief Get the task from a result iterator. @@ -22391,7 +22387,7 @@ task_t result_iterator_task (iterator_t* iterator) { if (iterator->done) return 0; - return (task_t) iterator_int64 (iterator, GET_ITERATOR_COLUMN_COUNT + 7); + return (task_t) iterator_int64 (iterator, GET_ITERATOR_COLUMN_COUNT + 6); } /** @@ -22405,7 +22401,7 @@ report_t result_iterator_report (iterator_t* iterator) { if (iterator->done) return 0; - return (task_t) iterator_int64 (iterator, GET_ITERATOR_COLUMN_COUNT + 8); + return (task_t) iterator_int64 (iterator, GET_ITERATOR_COLUMN_COUNT + 7); } /** @@ -22425,14 +22421,14 @@ result_iterator_scan_nvt_version (iterator_t *iterator) return NULL; /* nvt_version */ - ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 10); + ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 9); return ret ? ret : ""; } /** * @brief Get the original severity from a result iterator. * - * This is the original severity without overrides and autofp. + * This is the original severity without overrides. * * @param[in] iterator Iterator. * @@ -22448,14 +22444,14 @@ result_iterator_original_severity (iterator_t *iterator) return NULL; /* severity */ - ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 11); + ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 10); return ret ? ret : ""; } /** * @brief Get the severity from a result iterator. * - * This is the the autofp adjusted overridden severity. + * This is the the overridden severity. * * @param[in] iterator Iterator. * @@ -22470,19 +22466,15 @@ result_iterator_severity (iterator_t *iterator) if (iterator->done) return NULL; - /* auto_type */ - if (iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 5)) - return G_STRINGIFY (SEVERITY_FP); - /* new_severity */ - ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 12); + ret = iterator_string (iterator, GET_ITERATOR_COLUMN_COUNT + 11); return ret ? ret : ""; } /** * @brief Get the severity from a result iterator as double. * - * This is the the autofp adjusted overridden severity. + * This is the the overridden severity. * * @param[in] iterator Iterator. * @@ -22495,17 +22487,13 @@ result_iterator_severity_double (iterator_t *iterator) if (iterator->done) return 0.0; - /* auto_type */ - if (iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 5)) - return SEVERITY_FP; - - return iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 12); + return iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 11); } /** * @brief Get the original severity/threat level from a result iterator. * - * This is the original level without overrides and autofp. + * This is the original level without overrides. * * @param[in] iterator Iterator. * @@ -22521,11 +22509,11 @@ result_iterator_original_level (iterator_t *iterator) if (iterator->done) return NULL; - if (iterator_null (iterator, GET_ITERATOR_COLUMN_COUNT + 11)) + if (iterator_null (iterator, GET_ITERATOR_COLUMN_COUNT + 10)) return NULL; /* severity */ - severity = iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 11); + severity = iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 10); ret = severity_to_level (severity, 0); return ret ? ret : ""; @@ -22534,7 +22522,7 @@ result_iterator_original_level (iterator_t *iterator) /** * @brief Get the severity/threat level from a result iterator. * - * This is the the autofp adjusted overridden level. + * This is the the overridden level. * * @param[in] iterator Iterator. * @@ -22550,15 +22538,11 @@ result_iterator_level (iterator_t *iterator) if (iterator->done) return ""; - /* auto_type */ - if (iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 5)) - return "False Positive"; - /* new_severity */ - if (iterator_null (iterator, GET_ITERATOR_COLUMN_COUNT + 12)) + if (iterator_null (iterator, GET_ITERATOR_COLUMN_COUNT + 11)) return ""; - severity = iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 12); + severity = iterator_double (iterator, GET_ITERATOR_COLUMN_COUNT + 11); ret = severity_to_level (severity, 0); return ret ? ret : ""; @@ -22572,7 +22556,7 @@ result_iterator_level (iterator_t *iterator) * @return The solution type of the result. Caller must only use before calling * cleanup_iterator. */ -DEF_ACCESS (result_iterator_solution_type, GET_ITERATOR_COLUMN_COUNT + 16); +DEF_ACCESS (result_iterator_solution_type, GET_ITERATOR_COLUMN_COUNT + 15); /** * @brief Get the qod from a result iterator. @@ -22582,7 +22566,7 @@ DEF_ACCESS (result_iterator_solution_type, GET_ITERATOR_COLUMN_COUNT + 16); * @return The qod of the result. Caller must only use before calling * cleanup_iterator. */ -DEF_ACCESS (result_iterator_qod, GET_ITERATOR_COLUMN_COUNT + 17); +DEF_ACCESS (result_iterator_qod, GET_ITERATOR_COLUMN_COUNT + 16); /** * @brief Get the qod_type from a result iterator. @@ -22592,7 +22576,7 @@ DEF_ACCESS (result_iterator_qod, GET_ITERATOR_COLUMN_COUNT + 17); * @return The qod type of the result. Caller must only use before calling * cleanup_iterator. */ -DEF_ACCESS (result_iterator_qod_type, GET_ITERATOR_COLUMN_COUNT + 18); +DEF_ACCESS (result_iterator_qod_type, GET_ITERATOR_COLUMN_COUNT + 17); /** * @brief Get the host from a result iterator. @@ -22602,7 +22586,7 @@ DEF_ACCESS (result_iterator_qod_type, GET_ITERATOR_COLUMN_COUNT + 18); * @return The host of the result. Caller must only use before calling * cleanup_iterator. */ -DEF_ACCESS (result_iterator_hostname, GET_ITERATOR_COLUMN_COUNT + 19); +DEF_ACCESS (result_iterator_hostname, GET_ITERATOR_COLUMN_COUNT + 18); /** * @brief Get the path from a result iterator. @@ -22612,7 +22596,7 @@ DEF_ACCESS (result_iterator_hostname, GET_ITERATOR_COLUMN_COUNT + 19); * @return The path of the result. Caller must only use before * calling cleanup_iterator. */ -DEF_ACCESS (result_iterator_path, GET_ITERATOR_COLUMN_COUNT + 22); +DEF_ACCESS (result_iterator_path, GET_ITERATOR_COLUMN_COUNT + 21); /** * @brief Get the asset host ID from a result iterator. @@ -22622,7 +22606,7 @@ DEF_ACCESS (result_iterator_path, GET_ITERATOR_COLUMN_COUNT + 22); * @return The ID of the asset host. Caller must only use before * calling cleanup_iterator. */ -DEF_ACCESS (result_iterator_asset_host_id, GET_ITERATOR_COLUMN_COUNT + 23); +DEF_ACCESS (result_iterator_asset_host_id, GET_ITERATOR_COLUMN_COUNT + 22); /** * @brief Get whether notes may exist from a result iterator. @@ -22635,7 +22619,7 @@ int result_iterator_may_have_notes (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 24); + return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 23); } /** @@ -22649,7 +22633,7 @@ int result_iterator_may_have_overrides (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 25); + return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 24); } /** @@ -22663,7 +22647,7 @@ int result_iterator_may_have_tickets (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 26); + return iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 25); } /** @@ -22677,7 +22661,7 @@ gchar ** result_iterator_cert_bunds (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_array (iterator, GET_ITERATOR_COLUMN_COUNT + 35); + return iterator_array (iterator, GET_ITERATOR_COLUMN_COUNT + 34); } /** @@ -22691,7 +22675,7 @@ gchar ** result_iterator_dfn_certs (iterator_t* iterator) { if (iterator->done) return 0; - return iterator_array (iterator, GET_ITERATOR_COLUMN_COUNT + 36); + return iterator_array (iterator, GET_ITERATOR_COLUMN_COUNT + 35); } /** From 5116bd97a7d141ef1836e05877df1dc18f5e30ff Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Sun, 13 Sep 2020 15:38:04 +0200 Subject: [PATCH 14/23] Remove SQL view for autofp. --- src/manage_pg.c | 62 ------------------------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/manage_pg.c b/src/manage_pg.c index a311cae52..ee92cd302 100644 --- a/src/manage_pg.c +++ b/src/manage_pg.c @@ -2739,68 +2739,6 @@ create_tables () " (SELECT 0 AS override UNION SELECT 1 AS override) AS override_opts," " (SELECT 0 AS dynamic UNION SELECT 1 AS dynamic) AS dynamic_opts;"); - sql ("CREATE OR REPLACE VIEW results_autofp AS" - " SELECT results.id as result, autofp_selection," - " (CASE autofp_selection" - " WHEN 1 THEN" - " (CASE WHEN" - " (((SELECT family FROM nvts WHERE oid = results.nvt)" - " IN (" LSC_FAMILY_LIST "))" - " OR EXISTS" - " (SELECT id FROM nvts" - " WHERE oid = results.nvt" - " AND" - " (cve = ''" - " OR cve NOT IN (SELECT cve FROM nvts" - " WHERE oid" - " IN (SELECT source_name" - " FROM report_host_details" - " WHERE report_host" - " = (SELECT id" - " FROM report_hosts" - " WHERE report = %llu" - " AND host" - " = results.host)" - " AND name = 'EXIT_CODE'" - " AND value = 'EXIT_NOTVULN')" - " AND family IN (" LSC_FAMILY_LIST ")))))" - " THEN NULL" - " WHEN severity = " G_STRINGIFY (SEVERITY_ERROR) " THEN NULL" - " ELSE 1 END)" - " WHEN 2 THEN" - " (CASE WHEN" - " (((SELECT family FROM nvts WHERE oid = results.nvt)" - " IN (" LSC_FAMILY_LIST "))" - " OR EXISTS" - " (SELECT id FROM nvts AS outer_nvts" - " WHERE oid = results.nvt" - " AND" - " (cve = ''" - " OR NOT EXISTS" - " (SELECT cve FROM nvts" - " WHERE oid IN (SELECT source_name" - " FROM report_host_details" - " WHERE report_host" - " = (SELECT id" - " FROM report_hosts" - " WHERE report = results.report" - " AND host = results.host)" - " AND name = 'EXIT_CODE'" - " AND value = 'EXIT_NOTVULN')" - " AND family IN (" LSC_FAMILY_LIST ")" - /* The CVE of the result NVT is outer_nvts.cve. The CVE of the - * NVT that has registered the "closed" host detail is nvts.cve. - * Either can be a list of CVEs. */ - " AND common_cve (nvts.cve, outer_nvts.cve)))))" - " THEN NULL" - " WHEN severity = " G_STRINGIFY (SEVERITY_ERROR) " THEN NULL" - " ELSE 1 END)" - " ELSE 0 END) AS autofp" - " FROM results," - " (SELECT 0 AS autofp_selection" - " UNION SELECT 1 AS autofp_selection" - " UNION SELECT 2 AS autofp_selection) AS autofp_opts;"); - sql ("CREATE OR REPLACE VIEW tls_certificate_source_origins AS" " SELECT sources.id AS source_id, tls_certificate," " origin_id, origin_type, origin_data" From 45921c51fba5325a89745d8d2654ea80b1fa3026 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Mon, 14 Sep 2020 23:46:08 +0200 Subject: [PATCH 15/23] Remove auto_type_sql from where_levels_auto() --- src/manage_sql.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index c4eef770d..fa28a6f7b 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21129,13 +21129,11 @@ next_report (iterator_t* iterator, report_t* report) * High, Medium, Low, loG and Debug). All levels if * NULL. * @param[in] new_severity_sql SQL for new severity. - * @param[in] auto_type_sql SQL for auto type. * * @return WHERE clause for levels if one is required, else NULL. */ static GString * -where_levels_auto (const char *levels, const char *new_severity_sql, - const char *auto_type_sql) +where_levels_auto (const char *levels, const char *new_severity_sql) { int count; GString *levels_sql; @@ -21227,11 +21225,10 @@ where_levels_auto (const char *levels, const char *new_severity_sql, { levels_sql = g_string_new (""); g_string_append_printf (levels_sql, - " AND (((%s IS NULL)" - " AND ((%s" - " = " G_STRINGIFY - (SEVERITY_DEBUG) ")", - auto_type_sql, + " AND ((" + " ((%s" + " = " G_STRINGIFY + (SEVERITY_DEBUG) ")", new_severity_sql); } else @@ -21250,23 +21247,20 @@ where_levels_auto (const char *levels, const char *new_severity_sql, { levels_sql = g_string_new (""); g_string_append_printf (levels_sql, - " AND (((%s IS NULL)" - " AND %s" - " = " G_STRINGIFY - (SEVERITY_FP) ")" - " OR %s = 1)", - auto_type_sql, - new_severity_sql, - auto_type_sql); + " AND ((" + " %s" + " = " G_STRINGIFY + (SEVERITY_FP) ")" + " )", + new_severity_sql); } else g_string_append_printf (levels_sql, " OR %s" " = " G_STRINGIFY (SEVERITY_FP) "))" - " OR %s = 1)", - new_severity_sql, - auto_type_sql); + " )", + new_severity_sql); count++; } else if (count) @@ -21710,7 +21704,7 @@ results_extra_where (int trash, report_t report, const gchar* host, gchar *levels; gchar *report_clause, *host_clause, *min_qod_clause; GString *levels_clause; - gchar *new_severity_sql, *auto_type_sql; + gchar *new_severity_sql; // Get filter values min_qod = filter_term_min_qod (filter); @@ -21720,8 +21714,6 @@ results_extra_where (int trash, report_t report, const gchar* host, // Build clause fragments - auto_type_sql = g_strdup ("NULL"); - new_severity_sql = g_strdup_printf ("(SELECT new_severity FROM result_new_severities" " WHERE result_new_severities.result = results.id" @@ -21751,7 +21743,7 @@ results_extra_where (int trash, report_t report, const gchar* host, min_qod_clause = where_qod (min_qod); levels_clause = where_levels_auto (levels ? levels : "hmlgdf", - new_severity_sql, auto_type_sql); + new_severity_sql); g_free (levels); g_free (new_severity_sql); @@ -21761,7 +21753,6 @@ results_extra_where (int trash, report_t report, const gchar* host, levels_clause->str, min_qod_clause ? min_qod_clause : ""); - g_free (auto_type_sql); g_free (min_qod_clause); g_string_free (levels_clause, TRUE); g_free (report_clause); From f3f0e85908c5c366df8f4b7d69aa6187addf2ab4 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Wed, 16 Sep 2020 14:49:36 +0200 Subject: [PATCH 16/23] Drop auto_type from REPORT_ITERATOR_FILTER_COLUMNS Apparently there was no direct reference into the column numbers, so this patch is short and there is no need to adjust index numbers. --- src/manage_sql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index fa28a6f7b..80ecd98e0 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -21314,7 +21314,7 @@ where_qod (int min_qod) */ #define RESULT_ITERATOR_FILTER_COLUMNS \ { GET_ITERATOR_FILTER_COLUMNS, "host", "location", "nvt", \ - "type", "original_type", "auto_type", \ + "type", "original_type", \ "description", "task", "report", "cvss_base", "nvt_version", \ "severity", "original_severity", "vulnerability", "date", "report_id", \ "solution_type", "qod", "qod_type", "task_id", "cve", "hostname", \ @@ -27200,7 +27200,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, * which may be used as a sort field. These could be added to * result_cmp. For now sort by vulnerability. */ #if 0 - "uuid", "comment", "created", "modified", "_owner", "auto_type", + "uuid", "comment", "created", "modified", "_owner", "cvss_base", "nvt_version", "original_severity", "date", "solution_type", "qod", "qod_type", "cve", "hostname", "path" #endif From 46f95ab7f2ce1c67d16280b6f5cfe3be7b360bde Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Wed, 16 Sep 2020 14:58:26 +0200 Subject: [PATCH 17/23] Drop the elements from GMP XML spec. Document the removal of "autofp" and "auto_type". --- src/schema_formats/XML/GMP.xml.in | 60 ++++++++----------------------- 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/src/schema_formats/XML/GMP.xml.in b/src/schema_formats/XML/GMP.xml.in index 490bf0968..c15929fea 100644 --- a/src/schema_formats/XML/GMP.xml.in +++ b/src/schema_formats/XML/GMP.xml.in @@ -2060,7 +2060,6 @@ along with this program. If not, see . apply_overrides result_hosts_only min_qod - autofp filter delta @@ -2115,13 +2114,6 @@ along with this program. If not, see . text - - autofp - - Whether to trust vendor security updates. 1 full match, 2 partial - - xsd:token { pattern = "0|1|2" } - filter Level filter @@ -14861,18 +14853,6 @@ along with this program. If not, see . boolean Whether to apply Overrides - -