Skip to content

Commit

Permalink
Merge pull request greenbone#321 from jjnicola/qod
Browse files Browse the repository at this point in the history
Add function to set and get the NVT QoD.
  • Loading branch information
mattmundell authored Mar 23, 2020
2 parents dbef141 + 17697b0 commit b765ef9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 40 additions & 0 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 4 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b765ef9

Please sign in to comment.