Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit attributes in nvti struct #258

Merged
merged 2 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 187 additions & 1 deletion base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ typedef struct nvti
gchar *oid; /**< @brief Object ID */
gchar *name; /**< @brief The name */

gchar *summary; /**< @brief The summary */
gchar *insight; /**< @brief The insight */
gchar *affected; /**< @brief Affected systems */
gchar *impact; /**< @brief Impact of vulnerability */

gchar *solution; /**< @brief The solution */
gchar *solution_type; /**< @brief The solution type */

Expand All @@ -178,7 +183,8 @@ typedef struct nvti
gchar
*required_udp_ports; /**< @brief List of required UDP ports of this NVT*/

gchar *qod_type; /**< @brief Quality of detection type */
gchar *detection; /**< @brief Detection description */
gchar *qod_type; /**< @brief Quality of detection type */

GSList *refs; /**< @brief Collection of VT references */
GSList *prefs; /**< @brief Collection of NVT preferences */
Expand Down Expand Up @@ -341,6 +347,10 @@ nvti_free (nvti_t *n)

g_free (n->oid);
g_free (n->name);
g_free (n->summary);
g_free (n->insight);
g_free (n->affected);
g_free (n->impact);
g_free (n->solution);
g_free (n->solution_type);
g_free (n->tag);
Expand All @@ -351,6 +361,7 @@ nvti_free (nvti_t *n)
g_free (n->excluded_keys);
g_free (n->required_ports);
g_free (n->required_udp_ports);
g_free (n->detection);
g_free (n->qod_type);
g_free (n->family);
g_slist_free_full (n->refs, (void (*) (void *)) vtref_free);
Expand Down Expand Up @@ -386,6 +397,62 @@ nvti_name (const nvti_t *n)
return (n ? n->name : NULL);
}

/**
* @brief Get the summary.
*
* @param n The NVT Info structure of which the summary should
* be returned.
*
* @return The summary string. Don't free this.
*/
gchar *
nvti_summary (const nvti_t *n)
{
return (n ? n->summary : NULL);
}

/**
* @brief Get the text about insight.
*
* @param n The NVT Info structure of which the insight description should
* be returned.
*
* @return The insight string. Don't free this.
*/
gchar *
nvti_insight (const nvti_t *n)
{
return (n ? n->insight : NULL);
}

/**
* @brief Get the text about affected systems.
*
* @param n The NVT Info structure of which the affected description should
* be returned.
*
* @return The affected string. Don't free this.
*/
gchar *
nvti_affected (const nvti_t *n)
{
return (n ? n->affected : NULL);
}

/**
* @brief Get the text about impact.
*
* @param n The NVT Info structure of which the impact description should
* be returned.
*
* @return The impact string. Don't free this.
*/
gchar *
nvti_impact (const nvti_t *n)
{
return (n ? n->impact : NULL);
}

/**
* @brief Get the number of references of the NVT.
*
Expand Down Expand Up @@ -644,6 +711,20 @@ nvti_required_udp_ports (const nvti_t *n)
return (n ? n->required_udp_ports : NULL);
}

/**
* @brief Get the text about detection.
*
* @param n The NVT Info structure of which the detection should
* be returned.
*
* @return The detection string. Don't free this.
*/
gchar *
nvti_detection (const nvti_t *n)
{
return (n ? n->detection : NULL);
}

/**
* @brief Get the QoD type.
*
Expand Down Expand Up @@ -769,6 +850,90 @@ nvti_set_name (nvti_t *n, const gchar *name)
return (0);
}

/**
* @brief Set the summary of a NVT.
*
* @param n The NVT Info structure.
*
* @param solution The summary to set. A copy will be created from this.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_summary (nvti_t *n, const gchar *summary)
{
if (!n)
return (-1);

if (n->summary)
g_free (n->summary);
n->summary = g_strdup (summary);
return (0);
}

/**
* @brief Set the insight text of a NVT.
*
* @param n The NVT Info structure.
*
* @param insight The insight text to set. A copy will be created from this.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_insight (nvti_t *n, const gchar *insight)
{
if (!n)
return (-1);

if (n->insight)
g_free (n->insight);
n->insight = g_strdup (insight);
return (0);
}

/**
* @brief Set the affected text of a NVT.
*
* @param n The NVT Info structure.
*
* @param affected The affected text to set. A copy will be created from this.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_affected (nvti_t *n, const gchar *affected)
{
if (!n)
return (-1);

if (n->affected)
g_free (n->affected);
n->affected = g_strdup (affected);
return (0);
}

/**
* @brief Set the impact text of a NVT.
*
* @param n The NVT Info structure.
*
* @param affected The impact text to set. A copy will be created from this.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_impact (nvti_t *n, const gchar *impact)
{
if (!n)
return (-1);

if (n->impact)
g_free (n->impact);
n->impact = g_strdup (impact);
return (0);
}

/**
* @brief Set the solution of a NVT.
*
Expand Down Expand Up @@ -1010,6 +1175,27 @@ nvti_set_required_udp_ports (nvti_t *n, const gchar *required_udp_ports)
return (0);
}

/**
* @brief Set the detection text of a NVT.
*
* @param n The NVT Info structure.
*
* @param detection The detection text to set. A copy will be created from this.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_detection (nvti_t *n, const gchar *detection)
{
if (!n)
return (-1);

if (n->detection)
g_free (n->detection);
n->detection = g_strdup (detection);
return (0);
}

/**
* @brief Set the QoD type of a NVT.
*
Expand Down
20 changes: 20 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ nvti_oid (const nvti_t *);
gchar *
nvti_name (const nvti_t *);
gchar *
nvti_summary (const nvti_t *);
gchar *
nvti_affected (const nvti_t *);
gchar *
nvti_impact (const nvti_t *);
gchar *
nvti_insight (const nvti_t *);
gchar *
nvti_refs (const nvti_t *, const gchar *, const char *, guint);
gchar *
nvti_solution (const nvti_t *);
Expand All @@ -121,6 +129,8 @@ nvti_required_ports (const nvti_t *);
gchar *
nvti_required_udp_ports (const nvti_t *);
gchar *
nvti_detection (const nvti_t *);
gchar *
nvti_qod_type (const nvti_t *);
gint
nvti_timeout (const nvti_t *);
Expand All @@ -138,6 +148,14 @@ nvti_set_oid (nvti_t *, const gchar *);
int
nvti_set_name (nvti_t *, const gchar *);
int
nvti_set_summary (nvti_t *, const gchar *);
int
nvti_set_insight (nvti_t *, const gchar *);
int
nvti_set_affected (nvti_t *, const gchar *);
int
nvti_set_impact (nvti_t *, const gchar *);
int
nvti_set_solution (nvti_t *, const gchar *);
int
nvti_set_solution_type (nvti_t *, const gchar *);
Expand All @@ -158,6 +176,8 @@ nvti_set_required_ports (nvti_t *, const gchar *);
int
nvti_set_required_udp_ports (nvti_t *, const gchar *);
int
nvti_set_detection (nvti_t *, const gchar *);
int
nvti_set_qod_type (nvti_t *, const gchar *);
int
nvti_set_timeout (nvti_t *, const gint);
Expand Down