From fcacebddbb969eb0b0848c21909cc829c45b2a11 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 1 May 2023 14:54:43 +0200 Subject: [PATCH] Add nvti set functions that use the given string --- base/nvti.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++ base/nvti.h | 16 ++++++ 2 files changed, 176 insertions(+) diff --git a/base/nvti.c b/base/nvti.c index 232d08e7..6044d2e8 100644 --- a/base/nvti.c +++ b/base/nvti.c @@ -1294,6 +1294,26 @@ nvti_set_name (nvti_t *n, const gchar *name) return 0; } +/** + * @brief Set the name of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param name The name to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_name (nvti_t *n, gchar *name) +{ + if (!n) + return -1; + + g_free (n->name); + n->name = name; + return 0; +} + /** * @brief Set the summary of a NVT. * @@ -1314,6 +1334,26 @@ nvti_set_summary (nvti_t *n, const gchar *summary) return 0; } +/** + * @brief Set the summary of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param solution The summary to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_summary (nvti_t *n, gchar *summary) +{ + if (!n) + return -1; + + g_free (n->summary); + n->summary = summary; + return 0; +} + /** * @brief Set the insight text of a NVT. * @@ -1334,6 +1374,26 @@ nvti_set_insight (nvti_t *n, const gchar *insight) return 0; } +/** + * @brief Set the insight text of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param insight The insight text to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_insight (nvti_t *n, gchar *insight) +{ + if (!n) + return -1; + + g_free (n->insight); + n->insight = insight; + return 0; +} + /** * @brief Set the affected text of a NVT. * @@ -1354,6 +1414,26 @@ nvti_set_affected (nvti_t *n, const gchar *affected) return 0; } +/** + * @brief Set the affected text of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param affected The affected text to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_affected (nvti_t *n, gchar *affected) +{ + if (!n) + return -1; + + g_free (n->affected); + n->affected = affected; + return 0; +} + /** * @brief Set the impact text of a NVT. * @@ -1374,6 +1454,26 @@ nvti_set_impact (nvti_t *n, const gchar *impact) return 0; } +/** + * @brief Set the impact text of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param affected The impact text to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_impact (nvti_t *n, gchar *impact) +{ + if (!n) + return -1; + + g_free (n->impact); + n->impact = impact; + return 0; +} + /** * @brief Set the creation time of a NVT. * @@ -1432,6 +1532,26 @@ nvti_set_solution (nvti_t *n, const gchar *solution) return 0; } +/** + * @brief Set the solution of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param solution The solution to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_solution (nvti_t *n, gchar *solution) +{ + if (!n) + return -1; + + g_free (n->solution); + n->solution = solution; + return 0; +} + /** * @brief Set the solution type of a NVT. * @@ -1755,6 +1875,26 @@ nvti_set_detection (nvti_t *n, const gchar *detection) return 0; } +/** + * @brief Set the detection text of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param detection The detection text to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_detection (nvti_t *n, gchar *detection) +{ + if (!n) + return -1; + + g_free (n->detection); + n->detection = detection; + return 0; +} + /** * @brief Set the QoD type of a NVT. * @@ -1823,6 +1963,26 @@ nvti_set_family (nvti_t *n, const gchar *family) return 0; } +/** + * @brief Set the family of a NVT, using the given memory. + * + * @param n The NVT Info structure. + * + * @param family The family to set. The string will be used directly. + * + * @return 0 for success. Anything else indicates an error. + */ +int +nvti_put_family (nvti_t *n, gchar *family) +{ + if (!n) + return -1; + + g_free (n->family); + n->family = family; + return 0; +} + /** * @brief Set the category type of a NVT Info. * diff --git a/base/nvti.h b/base/nvti.h index 5935c115..859ff4f1 100644 --- a/base/nvti.h +++ b/base/nvti.h @@ -179,20 +179,32 @@ nvti_set_oid (nvti_t *, const gchar *); int nvti_set_name (nvti_t *, const gchar *); int +nvti_put_name (nvti_t *, gchar *); +int nvti_set_summary (nvti_t *, const gchar *); int +nvti_put_summary (nvti_t *, gchar *); +int nvti_set_insight (nvti_t *, const gchar *); int +nvti_put_insight (nvti_t *, gchar *); +int nvti_set_affected (nvti_t *, const gchar *); int +nvti_put_affected (nvti_t *, gchar *); +int nvti_set_impact (nvti_t *, const gchar *); int +nvti_put_impact (nvti_t *, gchar *); +int nvti_set_creation_time (nvti_t *, const time_t); int nvti_set_modification_time (nvti_t *, const time_t); int nvti_set_solution (nvti_t *, const gchar *); int +nvti_put_solution (nvti_t *, gchar *); +int nvti_set_solution_type (nvti_t *, const gchar *); int nvti_set_solution_method (nvti_t *, const gchar *); @@ -217,6 +229,8 @@ nvti_set_required_udp_ports (nvti_t *, const gchar *); int nvti_set_detection (nvti_t *, const gchar *); int +nvti_put_detection (nvti_t *, gchar *); +int nvti_set_qod_type (nvti_t *, const gchar *); int nvti_set_qod (nvti_t *, const gchar *); @@ -226,6 +240,8 @@ int nvti_set_category (nvti_t *, const gint); int nvti_set_family (nvti_t *, const gchar *); +int +nvti_put_family (nvti_t *, gchar *); int nvti_add_refs (nvti_t *, const gchar *, const gchar *, const gchar *);