From 048defe7783cfdd3cdd3c490abf6056d735226d9 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Wed, 22 Jan 2020 16:19:10 +0100 Subject: [PATCH 1/2] Fix QoD handling in nvti cache and test_alert This loads the qod_type into the nvti cache when rebuilding it from the database so make_result can use it instead of relying on the tags string containg qod and qod_type. --- src/manage_sql.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 28c6503e6..cd94b946a 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -15456,7 +15456,7 @@ update_nvti_cache () "SELECT nvts.oid, nvts.name, nvts.family, nvts.cvss_base," " nvts.tag, nvts.solution, nvts.solution_type," " nvts.summary, nvts.insight, nvts.affected," - " nvts.impact, nvts.detection," + " nvts.impact, nvts.detection, nvts.qod_type," " vt_refs.type, vt_refs.ref_id, vt_refs.ref_text" " FROM nvts" " LEFT OUTER JOIN vt_refs ON nvts.oid = vt_refs.vt_oid;"); @@ -15481,17 +15481,18 @@ update_nvti_cache () nvti_set_affected (nvti, iterator_string (&nvts, 9)); nvti_set_impact (nvti, iterator_string (&nvts, 10)); nvti_set_detection (nvti, iterator_string (&nvts, 11)); + nvti_set_qod_type (nvti, iterator_string (&nvts, 12)); nvtis_add (nvti_cache, nvti); } - if (iterator_null (&nvts, 13)) + if (iterator_null (&nvts, 14)) /* No refs. */; else nvti_add_vtref (nvti, - vtref_new (iterator_string (&nvts, 12), - iterator_string (&nvts, 13), - iterator_string (&nvts, 14))); + vtref_new (iterator_string (&nvts, 13), + iterator_string (&nvts, 14), + iterator_string (&nvts, 15))); } cleanup_iterator (&nvts); @@ -20978,16 +20979,12 @@ make_result (task_t task, const char* host, const char *hostname, nvti = lookup_nvti (nvt); if (nvti) { - gchar *qod_str, *qod_type; - qod_str = nvti_get_tag (nvti, "qod"); - qod_type = nvti_get_tag (nvti, "qod_type"); - - if (qod_str == NULL || sscanf (qod_str, "%d", &qod) != 1) - qod = qod_from_type (qod_type); + gchar *qod_type; + qod_type = nvti_qod_type (nvti); + qod = qod_from_type (qod_type); quoted_qod_type = sql_quote (qod_type); - g_free (qod_str); g_free (qod_type); } else From e1e0050fbc7b3985a5ec7548f89f6f15be492a24 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Wed, 22 Jan 2020 16:38:02 +0100 Subject: [PATCH 2/2] Add QoD fix to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5798b9fa..bdb9b4138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add tags used for result NVTs to update_nvti_cache [#916](https://github.com/greenbone/gvmd/pull/916) - Apply usage_type of tasks in get_aggregates (9.0) [#912](https://github.com/greenbone/gvmd/pull/912) - Add target's alive test method before starting a scan. [#947](https://github.com/greenbone/gvmd/pull/947) +- Fix QoD handling in nvti cache and test_alert [#954](https://github.com/greenbone/gvmd/pull/954) ### Removed - Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)