From 8a425e092263ad673d45e15df93d14a2fec6a0d1 Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 23 Mar 2020 16:39:18 +0100 Subject: [PATCH 1/3] Add function to set and get the NVT QoD. --- base/nvti.c | 40 ++++++++++++++++++++++++++++++++++++++++ base/nvti.h | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/base/nvti.c b/base/nvti.c index c91b386ea..86ce8c6f5 100644 --- a/base/nvti.c +++ b/base/nvti.c @@ -296,6 +296,7 @@ typedef struct nvti gchar *detection; /**< @brief Detection description */ gchar *qod_type; /**< @brief Quality of detection type */ + gchar *qod; /**< @brief Quality of detection */ GSList *refs; /**< @brief Collection of VT references */ GSList *prefs; /**< @brief Collection of NVT preferences */ @@ -486,6 +487,7 @@ nvti_free (nvti_t *n) g_free (n->required_udp_ports); g_free (n->detection); g_free (n->qod_type); + g_free (n->qod); g_free (n->family); g_slist_free_full (n->refs, (void (*) (void *)) vtref_free); g_slist_free_full (n->prefs, (void (*) (void *)) nvtpref_free); @@ -942,6 +944,20 @@ nvti_qod_type (const nvti_t *n) return n ? n->qod_type : NULL; } +/** + * @brief Get the QoD. + * + * @param n The NVT Info structure of which the QoD should + * be returned. + * + * @return The QoD as string. Don't free this. + */ +gchar * +nvti_qod (const nvti_t *n) +{ + return n ? n->qod : NULL; +} + /** * @brief Get the family name. * @@ -1534,6 +1550,30 @@ nvti_set_qod_type (nvti_t *n, const gchar *qod_type) return 0; } +/** + * @brief Set the QoD of a NVT. + * + * @param n The NVT Info structure. + * + * @param qod The QoD to set. A copy will be created from this. + * The string is not checked, any string is accepted as type. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_set_qod (nvti_t *n, const gchar *qod) +{ + if (!n) + return -1; + + g_free (n->qod); + if (qod && qod[0]) + n->qod = g_strdup (qod); + else + n->qod = NULL; + return 0; +} + /** * @brief Set the family of a NVT. * diff --git a/base/nvti.h b/base/nvti.h index 6d79a0c9e..88b125090 100644 --- a/base/nvti.h +++ b/base/nvti.h @@ -128,6 +128,8 @@ gchar * nvti_detection (const nvti_t *); gchar * nvti_qod_type (const nvti_t *); +gchar * +nvti_qod (const nvti_t *); gint nvti_timeout (const nvti_t *); gint @@ -184,6 +186,8 @@ nvti_set_detection (nvti_t *, const gchar *); int nvti_set_qod_type (nvti_t *, const gchar *); int +nvti_set_qod (nvti_t *, const gchar *); +int nvti_set_timeout (nvti_t *, const gint); int nvti_set_category (nvti_t *, const gint); From b6ca202e90591c43509649ac4781a0b633582406 Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 23 Mar 2020 16:42:14 +0100 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f6c8968..97915293b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Extend osp with target's reverse_lookup_* options.[#314](https://github.com/greenbone/gvm-libs/pull/314) - Add unit tests for osp. [#315](https://github.com/greenbone/gvm-libs/pull/315) - Add support for test_alive_hosts_only feature of openvas. [#320](https://github.com/greenbone/gvm-libs/pull/320) +- Add function to set and get the NVT QoD. [#321](https://github.com/greenbone/gvm-libs/pull/321) [20.4]: https://github.com/greenbone/gvm-libs/compare/gvm-libs-11.0...master From 17697b04a842941a777ddb27bdb14150940c9300 Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 23 Mar 2020 17:09:09 +0100 Subject: [PATCH 3/3] Fix format --- base/nvti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/nvti.c b/base/nvti.c index 86ce8c6f5..8d7aabc5f 100644 --- a/base/nvti.c +++ b/base/nvti.c @@ -296,7 +296,7 @@ typedef struct nvti gchar *detection; /**< @brief Detection description */ gchar *qod_type; /**< @brief Quality of detection type */ - gchar *qod; /**< @brief Quality of detection */ + gchar *qod; /**< @brief Quality of detection */ GSList *refs; /**< @brief Collection of VT references */ GSList *prefs; /**< @brief Collection of NVT preferences */