Greenbone Vulnerability Management Libraries 22.8.0
nvti.c File Reference

Implementation of API to handle NVT Info datasets. More...

#include "nvti.h"
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <time.h>
Include dependency graph for nvti.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vtref
 The structure for a cross reference of a VT. More...
 
struct  vtseverity
 The structure for a severity of a VT. More...
 
struct  nvti
 The structure of a information record that corresponds to a NVT. More...
 
struct  nvtpref
 The structure for a preference of a NVT. More...
 

Macros

#define _XOPEN_SOURCE
 
#define G_LOG_DOMAIN   "libgvm base"
 GLib log domain.
 

Typedefs

typedef struct vtref vtref_t
 The structure for a cross reference of a VT.
 
typedef struct vtseverity vtseverity_t
 The structure for a severity of a VT.
 
typedef struct nvti nvti_t
 The structure of a information record that corresponds to a NVT.
 
typedef struct nvtpref nvtpref_t
 The structure for a preference of a NVT.
 

Functions

vtref_tvtref_new (const gchar *type, const gchar *ref_id, const gchar *ref_text)
 Create a new vtref structure filled with the given values.
 
void vtref_free (vtref_t *ref)
 Free memory of a vtref structure.
 
const gchar * vtref_type (const vtref_t *r)
 Get the type of a reference.
 
const gchar * vtref_id (const vtref_t *r)
 Get the id of a reference.
 
const gchar * vtref_text (const vtref_t *r)
 Get the text of a reference.
 
vtseverity_tvtseverity_new (const gchar *type, const gchar *origin, int date, double score, const gchar *value)
 Create a new vtseverity structure filled with the given values.
 
void vtseverity_free (vtseverity_t *s)
 Free memory of a vtseverity structure.
 
const gchar * vtseverity_type (const vtseverity_t *s)
 Get the type of a severity.
 
const gchar * vtseverity_origin (const vtseverity_t *s)
 Get the origin of a severity.
 
const gchar * vtseverity_value (const vtseverity_t *s)
 Get the value of a severity.
 
int vtseverity_date (const vtseverity_t *s)
 Get the date of a severity.
 
double vtseverity_score (const vtseverity_t *s)
 Get the score of a severity.
 
static time_t parse_nvt_timestamp (const gchar *str_time)
 Try convert an NVT tag time string into epoch time or return 0 upon parse errors.
 
int nvti_add_vtref (nvti_t *vt, vtref_t *ref)
 Add a reference to the VT Info.
 
int nvti_add_vtseverity (nvti_t *vt, vtseverity_t *s)
 Add a severity to the VT Info.
 
nvtpref_tnvtpref_new (int id, const gchar *name, const gchar *type, const gchar *dflt)
 Create a new nvtpref structure filled with the given values.
 
void nvtpref_free (nvtpref_t *np)
 Free memory of a nvtpref structure.
 
int nvtpref_id (const nvtpref_t *np)
 Get the ID of a NVT Preference.
 
gchar * nvtpref_name (const nvtpref_t *np)
 Get the Name of a NVT Preference.
 
gchar * nvtpref_type (const nvtpref_t *np)
 Get the Type of a NVT Preference.
 
gchar * nvtpref_default (const nvtpref_t *np)
 Get the Default of a NVT Preference.
 
nvti_tnvti_new (void)
 Create a new (empty) nvti structure.
 
void nvti_free (nvti_t *n)
 Free memory of a nvti structure.
 
gchar * nvti_oid (const nvti_t *n)
 Get the OID string.
 
gchar * nvti_name (const nvti_t *n)
 Get the name.
 
gchar * nvti_summary (const nvti_t *n)
 Get the summary.
 
gchar * nvti_insight (const nvti_t *n)
 Get the text about insight.
 
gchar * nvti_affected (const nvti_t *n)
 Get the text about affected systems.
 
gchar * nvti_impact (const nvti_t *n)
 Get the text about impact.
 
time_t nvti_creation_time (const nvti_t *n)
 Get the creation time.
 
time_t nvti_modification_time (const nvti_t *n)
 Get the modification time.
 
guint nvti_vtref_len (const nvti_t *n)
 Get the number of references of the NVT.
 
vtref_tnvti_vtref (const nvti_t *n, guint p)
 Get the n'th reference of the NVT.
 
gchar * nvti_refs (const nvti_t *n, const gchar *type, const gchar *exclude_types, guint use_types)
 Get references as string.
 
guint nvti_vtseverities_len (const nvti_t *n)
 Get the number of severities of the NVT.
 
vtseverity_tnvti_vtseverity (const nvti_t *n, guint p)
 Get the n'th reference of the NVT.
 
double nvti_severity_score (const nvti_t *n)
 Get the maximum severity score.
 
gchar * nvti_severity_vector_from_tag (const nvti_t *n)
 Get the severity score.
 
gchar * nvti_solution (const nvti_t *n)
 Get the solution.
 
gchar * nvti_solution_type (const nvti_t *n)
 Get the solution type.
 
gchar * nvti_solution_method (const nvti_t *n)
 Get the solution method.
 
gchar * nvti_tag (const nvti_t *n)
 Get the tags.
 
gchar * nvti_get_tag (const nvti_t *n, const gchar *name)
 Get a tag value by a tag name.
 
gchar * nvti_cvss_base (const nvti_t *n)
 Get the CVSS base.
 
gchar * nvti_dependencies (const nvti_t *n)
 Get the dependencies list.
 
gchar * nvti_required_keys (const nvti_t *n)
 Get the required keys list.
 
gchar * nvti_mandatory_keys (const nvti_t *n)
 Get the mandatory keys list.
 
gchar * nvti_excluded_keys (const nvti_t *n)
 Get the excluded keys list.
 
gchar * nvti_required_ports (const nvti_t *n)
 Get the required ports list.
 
gchar * nvti_required_udp_ports (const nvti_t *n)
 Get the required udp ports list.
 
gchar * nvti_detection (const nvti_t *n)
 Get the text about detection.
 
gchar * nvti_qod_type (const nvti_t *n)
 Get the QoD type.
 
gchar * nvti_qod (const nvti_t *n)
 Get the QoD.
 
gchar * nvti_family (const nvti_t *n)
 Get the family name.
 
guint nvti_pref_len (const nvti_t *n)
 Get the number of preferences of the NVT.
 
const nvtpref_tnvti_pref (const nvti_t *n, guint p)
 Get the n'th preferences of the NVT.
 
gint nvti_category (const nvti_t *n)
 Get the category for this NVT.
 
int nvti_set_oid (nvti_t *n, const gchar *oid)
 Set the OID of a NVT Info.
 
int nvti_set_name (nvti_t *n, const gchar *name)
 Set the name of a NVT.
 
int nvti_put_name (nvti_t *n, gchar *name)
 Set the name of a NVT, using the given memory.
 
int nvti_set_summary (nvti_t *n, const gchar *summary)
 Set the summary of a NVT.
 
int nvti_put_summary (nvti_t *n, gchar *summary)
 Set the summary of a NVT, using the given memory.
 
int nvti_set_insight (nvti_t *n, const gchar *insight)
 Set the insight text of a NVT.
 
int nvti_put_insight (nvti_t *n, gchar *insight)
 Set the insight text of a NVT, using the given memory.
 
int nvti_set_affected (nvti_t *n, const gchar *affected)
 Set the affected text of a NVT.
 
int nvti_put_affected (nvti_t *n, gchar *affected)
 Set the affected text of a NVT, using the given memory.
 
int nvti_set_impact (nvti_t *n, const gchar *impact)
 Set the impact text of a NVT.
 
int nvti_put_impact (nvti_t *n, gchar *impact)
 Set the impact text of a NVT, using the given memory.
 
int nvti_set_creation_time (nvti_t *n, const time_t creation_time)
 Set the creation time of a NVT.
 
int nvti_set_modification_time (nvti_t *n, const time_t modification_time)
 Set the modification time of a NVT.
 
int nvti_set_solution (nvti_t *n, const gchar *solution)
 Set the solution of a NVT.
 
int nvti_put_solution (nvti_t *n, gchar *solution)
 Set the solution of a NVT, using the given memory.
 
int nvti_set_solution_type (nvti_t *n, const gchar *solution_type)
 Set the solution type of a NVT.
 
int nvti_set_solution_method (nvti_t *n, const gchar *solution_method)
 Set the solution method of a NVT.
 
int nvti_add_tag (nvti_t *n, const gchar *name, const gchar *value)
 Add a tag to the NVT tags. The tag names "severity_date", "last_modification" and "creation_date" are treated special: The value is expected to be a timestamp and it is being converted to seconds since epoch before added as a tag value. The tag name "cvss_base" will be ignored and not added.
 
int nvti_set_tag (nvti_t *n, const gchar *tag)
 Set the tags of a NVT.
 
int nvti_set_cvss_base (nvti_t *n, const gchar *cvss_base)
 Set the CVSS base of an NVT.
 
int nvti_set_dependencies (nvti_t *n, const gchar *dependencies)
 Set the dependencies of a NVT.
 
int nvti_set_required_keys (nvti_t *n, const gchar *required_keys)
 Set the required keys of a NVT.
 
int nvti_set_mandatory_keys (nvti_t *n, const gchar *mandatory_keys)
 Set the mandatory keys of a NVT.
 
int nvti_set_excluded_keys (nvti_t *n, const gchar *excluded_keys)
 Set the excluded keys of a NVT.
 
int nvti_set_required_ports (nvti_t *n, const gchar *required_ports)
 Set the required ports of a NVT.
 
int nvti_set_required_udp_ports (nvti_t *n, const gchar *required_udp_ports)
 Set the required udp ports of a NVT.
 
int nvti_set_detection (nvti_t *n, const gchar *detection)
 Set the detection text of a NVT.
 
int nvti_put_detection (nvti_t *n, gchar *detection)
 Set the detection text of a NVT, using the given memory.
 
int nvti_set_qod_type (nvti_t *n, const gchar *qod_type)
 Set the QoD type of a NVT.
 
int nvti_set_qod (nvti_t *n, const gchar *qod)
 Set the QoD of a NVT.
 
int nvti_set_family (nvti_t *n, const gchar *family)
 Set the family of a NVT.
 
int nvti_put_family (nvti_t *n, gchar *family)
 Set the family of a NVT, using the given memory.
 
int nvti_set_category (nvti_t *n, const gint category)
 Set the category type of a NVT Info.
 
int nvti_add_refs (nvti_t *n, const gchar *type, const gchar *ref_ids, const gchar *ref_text)
 Add many new vtref from a comma-separated list.
 
int nvti_add_required_keys (nvti_t *n, const gchar *key)
 Add a required key of a NVT.
 
int nvti_add_mandatory_keys (nvti_t *n, const gchar *key)
 Add a mandatory key of a NVT.
 
int nvti_add_excluded_keys (nvti_t *n, const gchar *key)
 Add a excluded key of a NVT.
 
int nvti_add_required_ports (nvti_t *n, const gchar *port)
 Add a required port of a NVT.
 
int nvti_add_required_udp_ports (nvti_t *n, const gchar *port)
 Add a required udp port of a NVT.
 
int nvti_add_pref (nvti_t *n, nvtpref_t *np)
 Add a preference to the NVT Info.
 
static void free_nvti_for_hash_table (gpointer nvti)
 Free an NVT Info, for g_hash_table_destroy.
 
nvtis_tnvtis_new (void)
 Make a collection of NVT Infos.
 
void nvtis_free (nvtis_t *nvtis)
 Free a collection of NVT Infos.
 
void nvtis_add (nvtis_t *nvtis, nvti_t *nvti)
 Add an NVT Info to a collection of NVT Infos.
 
nvti_tnvtis_lookup (nvtis_t *nvtis, const char *oid)
 Add an NVT Info to a collection of NVT Infos.
 

Detailed Description

Implementation of API to handle NVT Info datasets.

This file contains all methods to handle NVT Information datasets (nvti_t).

The module consequently uses glib datatypes and api for memory management etc.

Definition in file nvti.c.

Macro Definition Documentation

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE

Definition at line 35 of file nvti.c.

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "libgvm base"

GLib log domain.

Definition at line 47 of file nvti.c.

Typedef Documentation

◆ nvti_t

typedef struct nvti nvti_t

The structure of a information record that corresponds to a NVT.

◆ nvtpref_t

typedef struct nvtpref nvtpref_t

The structure for a preference of a NVT.

◆ vtref_t

typedef struct vtref vtref_t

The structure for a cross reference of a VT.

The elements of this structure should only be accessed by the respective functions.

◆ vtseverity_t

typedef struct vtseverity vtseverity_t

The structure for a severity of a VT.

VTs can have one or several severities.

Function Documentation

◆ free_nvti_for_hash_table()

static void free_nvti_for_hash_table ( gpointer  nvti)
static

Free an NVT Info, for g_hash_table_destroy.

Parameters
nvtiThe NVT Info.

Definition at line 2235 of file nvti.c.

2236{
2237 nvti_free ((nvti_t *) nvti);
2238}
void nvti_free(nvti_t *n)
Free memory of a nvti structure.
Definition: nvti.c:608
The structure of a information record that corresponds to a NVT.
Definition: nvti.c:394

References nvti_free().

Referenced by nvtis_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvti_add_excluded_keys()

int nvti_add_excluded_keys ( nvti_t n,
const gchar *  key 
)

Add a excluded key of a NVT.

Parameters
nThe NVT Info structure.
keyThe excluded key to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if key was NULL.

Definition at line 2122 of file nvti.c.

2123{
2124 gchar *old;
2125
2126 if (!n)
2127 return 1;
2128 if (!key)
2129 return 2;
2130
2131 old = n->excluded_keys;
2132
2133 if (old)
2134 {
2135 n->excluded_keys = g_strdup_printf ("%s, %s", old, key);
2136 g_free (old);
2137 }
2138 else
2139 n->excluded_keys = g_strdup (key);
2140
2141 return 0;
2142}
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.c:416

References nvti::excluded_keys.

◆ nvti_add_mandatory_keys()

int nvti_add_mandatory_keys ( nvti_t n,
const gchar *  key 
)

Add a mandatory key of a NVT.

Parameters
nThe NVT Info structure.
keyThe mandatory key to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if key was NULL.

Definition at line 2090 of file nvti.c.

2091{
2092 gchar *old;
2093
2094 if (!n)
2095 return 1;
2096 if (!key)
2097 return 2;
2098
2099 old = n->mandatory_keys;
2100
2101 if (old)
2102 {
2103 n->mandatory_keys = g_strdup_printf ("%s, %s", old, key);
2104 g_free (old);
2105 }
2106 else
2107 n->mandatory_keys = g_strdup (key);
2108
2109 return 0;
2110}
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.c:415

References nvti::mandatory_keys.

◆ nvti_add_pref()

int nvti_add_pref ( nvti_t n,
nvtpref_t np 
)

Add a preference to the NVT Info.

Parameters
nThe NVT Info structure.
npThe NVT preference to add.
Returns
0 for success. Anything else indicates an error.

Definition at line 2218 of file nvti.c.

2219{
2220 if (!n)
2221 return -1;
2222
2223 n->prefs = g_slist_append (n->prefs, np);
2224 return 0;
2225}
GSList * prefs
Collection of NVT preferences.
Definition: nvti.c:427

References nvti::prefs.

◆ nvti_add_refs()

int nvti_add_refs ( nvti_t n,
const gchar *  type,
const gchar *  ref_ids,
const gchar *  ref_text 
)

Add many new vtref from a comma-separated list.

Parameters
nThe NVTI where to add the references.
typeThe type for all references. If NULL, then for ref_ids a syntax is expected that includes the type like "type:id,type:id".
ref_idsA CSV of reference to be added.
ref_textThe optional text accompanying all references.
Returns
0 for success. 1 if n was NULL, 2 if ref_ids was NULL.

Definition at line 2006 of file nvti.c.

2008{
2009 gchar **split, **item;
2010
2011 if (!n)
2012 return 1;
2013
2014 if (!ref_ids)
2015 return 2;
2016
2017 split = g_strsplit (ref_ids, ",", 0);
2018
2019 for (item = split; *item; item++)
2020 {
2021 gchar *id;
2022
2023 id = *item;
2024 g_strstrip (id);
2025
2026 if (strcmp (id, "") == 0)
2027 continue;
2028
2029 if (type)
2030 {
2031 nvti_add_vtref (n, vtref_new (type, id, ref_text));
2032 }
2033 else
2034 {
2035 gchar **split2;
2036
2037 split2 = g_strsplit (id, ":", 2);
2038 if (split2[0] && split2[1])
2039 nvti_add_vtref (n, vtref_new (split2[0], split2[1], ""));
2040 g_strfreev (split2);
2041 }
2042 }
2043 g_strfreev (split);
2044
2045 return 0;
2046}
vtref_t * vtref_new(const gchar *type, const gchar *ref_id, const gchar *ref_text)
Create a new vtref structure filled with the given values.
Definition: nvti.c:78
int nvti_add_vtref(nvti_t *vt, vtref_t *ref)
Add a reference to the VT Info.
Definition: nvti.c:444

References nvti_add_vtref(), and vtref_new().

Referenced by redis_get_nvt_all().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvti_add_required_keys()

int nvti_add_required_keys ( nvti_t n,
const gchar *  key 
)

Add a required key of a NVT.

Parameters
nThe NVT Info structure.
keyThe required key to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if key was NULL.

Definition at line 2058 of file nvti.c.

2059{
2060 gchar *old;
2061
2062 if (!n)
2063 return 1;
2064 if (!key)
2065 return 2;
2066
2067 old = n->required_keys;
2068
2069 if (old)
2070 {
2071 n->required_keys = g_strdup_printf ("%s, %s", old, key);
2072 g_free (old);
2073 }
2074 else
2075 n->required_keys = g_strdup (key);
2076
2077 return 0;
2078}
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.c:414

References nvti::required_keys.

◆ nvti_add_required_ports()

int nvti_add_required_ports ( nvti_t n,
const gchar *  port 
)

Add a required port of a NVT.

Parameters
nThe NVT Info structure.
portThe required port to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if port was NULL.

Definition at line 2154 of file nvti.c.

2155{
2156 gchar *old;
2157
2158 if (!n)
2159 return 1;
2160 if (!port)
2161 return 2;
2162
2163 old = n->required_ports;
2164
2165 if (old)
2166 {
2167 n->required_ports = g_strdup_printf ("%s, %s", old, port);
2168 g_free (old);
2169 }
2170 else
2171 n->required_ports = g_strdup (port);
2172
2173 return 0;
2174}
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.c:417

References nvti::required_ports.

◆ nvti_add_required_udp_ports()

int nvti_add_required_udp_ports ( nvti_t n,
const gchar *  port 
)

Add a required udp port of a NVT.

Parameters
nThe NVT Info structure.
portThe required udp port to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if port was NULL.

Definition at line 2186 of file nvti.c.

2187{
2188 gchar *old;
2189
2190 if (!n)
2191 return 1;
2192 if (!port)
2193 return 2;
2194
2195 old = n->required_udp_ports;
2196
2197 if (old)
2198 {
2199 n->required_udp_ports = g_strdup_printf ("%s, %s", old, port);
2200 g_free (old);
2201 }
2202 else
2203 n->required_udp_ports = g_strdup (port);
2204
2205 return 0;
2206}
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.c:419

References nvti::required_udp_ports.

◆ nvti_add_tag()

int nvti_add_tag ( nvti_t n,
const gchar *  name,
const gchar *  value 
)

Add a tag to the NVT tags. The tag names "severity_date", "last_modification" and "creation_date" are treated special: The value is expected to be a timestamp and it is being converted to seconds since epoch before added as a tag value. The tag name "cvss_base" will be ignored and not added.

Parameters
nThe NVT Info structure.
nameThe tag name. A copy will be created from this.
valueThe tag value. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1599 of file nvti.c.

1600{
1601 gchar *newvalue = NULL;
1602
1603 if (!n)
1604 return -1;
1605
1606 if (!name || !name[0])
1607 return -2;
1608
1609 if (!value || !value[0])
1610 return -3;
1611
1612 if (!strcmp (name, "last_modification"))
1613 {
1615 newvalue = g_strdup_printf ("%i", (int) nvti_modification_time (n));
1616 }
1617 else if (!strcmp (name, "creation_date"))
1618 {
1620 newvalue = g_strdup_printf ("%i", (int) nvti_creation_time (n));
1621 }
1622 else if (!strcmp (name, "severity_date"))
1623 newvalue = g_strdup_printf ("%i", (int) parse_nvt_timestamp (value));
1624 else if (!strcmp (name, "cvss_base"))
1625 {
1626 /* Ignore this tag because it is not being used.
1627 * It is redundant with the tag cvss_base_vector from which
1628 * it is computed.
1629 * Once GOS 6 and GVM 11 are retired, all set_tag commands
1630 * in the NASL scripts can be removed that set "cvss_base".
1631 * Once this happened this exception can be removed from the code.
1632 */
1633 return 0;
1634 }
1635
1636 if (n->tag)
1637 {
1638 gchar *newtag;
1639
1640 newtag =
1641 g_strconcat (n->tag, "|", name, "=", newvalue ? newvalue : value, NULL);
1642 g_free (n->tag);
1643 n->tag = newtag;
1644 }
1645 else
1646 n->tag = g_strconcat (name, "=", newvalue ? newvalue : value, NULL);
1647
1648 g_free (newvalue);
1649
1650 return 0;
1651}
time_t nvti_creation_time(const nvti_t *n)
Get the creation time.
Definition: nvti.c:733
int nvti_set_modification_time(nvti_t *n, const time_t modification_time)
Set the modification time of a NVT.
Definition: nvti.c:1491
int nvti_set_creation_time(nvti_t *n, const time_t creation_time)
Set the creation time of a NVT.
Definition: nvti.c:1472
time_t nvti_modification_time(const nvti_t *n)
Get the modification time.
Definition: nvti.c:747
static time_t parse_nvt_timestamp(const gchar *str_time)
Try convert an NVT tag time string into epoch time or return 0 upon parse errors.
Definition: nvti.c:297
gchar * tag
List of tags attached to this NVT.
Definition: nvti.c:410

References nvti_creation_time(), nvti_modification_time(), nvti_set_creation_time(), nvti_set_modification_time(), parse_nvt_timestamp(), and nvti::tag.

Here is the call graph for this function:

◆ nvti_add_vtref()

int nvti_add_vtref ( nvti_t vt,
vtref_t ref 
)

Add a reference to the VT Info.

Parameters
vtThe VT Info structure.
refThe VT reference to add.
Returns
0 for success. Anything else indicates an error.

Definition at line 444 of file nvti.c.

445{
446 if (!vt)
447 return -1;
448
449 vt->refs = g_slist_append (vt->refs, ref);
450 return 0;
451}
GSList * refs
Collection of VT references.
Definition: nvti.c:425

References nvti::refs.

Referenced by nvti_add_refs().

Here is the caller graph for this function:

◆ nvti_add_vtseverity()

int nvti_add_vtseverity ( nvti_t vt,
vtseverity_t s 
)

Add a severity to the VT Info.

Parameters
vtThe VT Info structure.
sThe VT severity to add.
Returns
0 for success. Anything else indicates an error.

Definition at line 462 of file nvti.c.

463{
464 if (!vt)
465 return -1;
466
467 vt->severities = g_slist_append (vt->severities, s);
468 return 0;
469}
GSList * severities
Collection of VT severities.
Definition: nvti.c:426

References nvti::severities.

◆ nvti_affected()

gchar * nvti_affected ( const nvti_t n)

Get the text about affected systems.

Parameters
nThe NVT Info structure of which the affected description should be returned.
Returns
The affected string. Don't free this.

Definition at line 705 of file nvti.c.

706{
707 return n ? n->affected : NULL;
708}
gchar * affected
Affected systems.
Definition: nvti.c:400

References nvti::affected.

◆ nvti_category()

gint nvti_category ( const nvti_t n)

Get the category for this NVT.

Parameters
nThe NVT Info structure of which the category should be returned.
Returns
The category integer code. A value <= 0 indicates it is not set.

Definition at line 1237 of file nvti.c.

1238{
1239 return n ? n->category : -1;
1240}
gint category
The category, this NVT belongs to.
Definition: nvti.c:430

References nvti::category.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_creation_time()

time_t nvti_creation_time ( const nvti_t n)

Get the creation time.

Parameters
nThe NVT Info structure of which the creation time should be returned.
Returns
The creation time in seconds since epoch.

Definition at line 733 of file nvti.c.

734{
735 return n ? n->creation_time : 0;
736}
time_t creation_time
Time of creation, seconds since epoch.
Definition: nvti.c:403

References nvti::creation_time.

Referenced by nvti_add_tag().

Here is the caller graph for this function:

◆ nvti_cvss_base()

gchar * nvti_cvss_base ( const nvti_t n)

Get the CVSS base.

Parameters
nThe NVT Info structure of which the CVSS base should be returned.
Returns
The cvss_base string. Don't free this.

Definition at line 1056 of file nvti.c.

1057{
1058 return n ? n->cvss_base : NULL;
1059}
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.c:411

References nvti::cvss_base.

◆ nvti_dependencies()

gchar * nvti_dependencies ( const nvti_t n)

Get the dependencies list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The dependencies string. Don't free this.

Definition at line 1070 of file nvti.c.

1071{
1072 return n ? n->dependencies : NULL;
1073}
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.c:413

References nvti::dependencies.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_detection()

gchar * nvti_detection ( const nvti_t n)

Get the text about detection.

Parameters
nThe NVT Info structure of which the detection should be returned.
Returns
The detection string. Don't free this.

Definition at line 1154 of file nvti.c.

1155{
1156 return n ? n->detection : NULL;
1157}
gchar * detection
Detection description.
Definition: nvti.c:421

References nvti::detection.

◆ nvti_excluded_keys()

gchar * nvti_excluded_keys ( const nvti_t n)

Get the excluded keys list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The excluded keys string. Don't free this.

Definition at line 1112 of file nvti.c.

1113{
1114 return n ? n->excluded_keys : NULL;
1115}

References nvti::excluded_keys.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_family()

gchar * nvti_family ( const nvti_t n)

Get the family name.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The family name string. Don't free this.

Definition at line 1196 of file nvti.c.

1197{
1198 return n ? n->family : NULL;
1199}
gchar * family
Family the NVT belongs to.
Definition: nvti.c:431

References nvti::family.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_free()

void nvti_free ( nvti_t n)

Free memory of a nvti structure.

Parameters
nThe structure to be freed.

Definition at line 608 of file nvti.c.

609{
610 if (!n)
611 return;
612
613 g_free (n->oid);
614 g_free (n->name);
615 g_free (n->summary);
616 g_free (n->insight);
617 g_free (n->affected);
618 g_free (n->impact);
619 g_free (n->solution);
620 g_free (n->solution_type);
621 g_free (n->solution_method);
622 g_free (n->tag);
623 g_free (n->cvss_base);
624 g_free (n->dependencies);
625 g_free (n->required_keys);
626 g_free (n->mandatory_keys);
627 g_free (n->excluded_keys);
628 g_free (n->required_ports);
629 g_free (n->required_udp_ports);
630 g_free (n->detection);
631 g_free (n->qod_type);
632 g_free (n->qod);
633 g_free (n->family);
634 g_slist_free_full (n->refs, (void (*) (void *)) vtref_free);
635 g_slist_free_full (n->severities, (void (*) (void *)) vtseverity_free);
636 g_slist_free_full (n->prefs, (void (*) (void *)) nvtpref_free);
637 g_free (n);
638}
void vtseverity_free(vtseverity_t *s)
Free memory of a vtseverity structure.
Definition: nvti.c:205
void nvtpref_free(nvtpref_t *np)
Free memory of a nvtpref structure.
Definition: nvti.c:521
void vtref_free(vtref_t *ref)
Free memory of a vtref structure.
Definition: nvti.c:98
gchar * solution_method
The solution method.
Definition: nvti.c:408
gchar * insight
The insight.
Definition: nvti.c:399
gchar * solution
The solution.
Definition: nvti.c:406
gchar * impact
Impact of vulnerability.
Definition: nvti.c:401
gchar * oid
Object ID.
Definition: nvti.c:395
gchar * name
The name.
Definition: nvti.c:396
gchar * qod_type
Quality of detection type.
Definition: nvti.c:422
gchar * solution_type
The solution type.
Definition: nvti.c:407
gchar * qod
Quality of detection.
Definition: nvti.c:423
gchar * summary
The summary.
Definition: nvti.c:398

References nvti::affected, nvti::cvss_base, nvti::dependencies, nvti::detection, nvti::excluded_keys, nvti::family, nvti::impact, nvti::insight, nvti::mandatory_keys, nvti::name, nvtpref_free(), nvti::oid, nvti::prefs, nvti::qod, nvti::qod_type, nvti::refs, nvti::required_keys, nvti::required_ports, nvti::required_udp_ports, nvti::severities, nvti::solution, nvti::solution_method, nvti::solution_type, nvti::summary, nvti::tag, vtref_free(), and vtseverity_free().

Referenced by Ensure(), and free_nvti_for_hash_table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvti_get_tag()

gchar * nvti_get_tag ( const nvti_t n,
const gchar *  name 
)

Get a tag value by a tag name.

Parameters
nThe NVT Info structure from where to search for the tag name.
nameThe name of the tag for which to return the value.
Returns
The tag value string as a copy or NULL if not found. Needs to be free'd.

Definition at line 1020 of file nvti.c.

1021{
1022 gchar **split, **point;
1023
1024 if (!n || n->tag == NULL || !name)
1025 return NULL;
1026
1027 split = g_strsplit (n->tag, "|", 0);
1028 point = split;
1029
1030 while (*point)
1031 {
1032 if ((strlen (*point) > strlen (name))
1033 && (strncmp (*point, name, strlen (name)) == 0)
1034 && ((*point)[strlen (name)] == '='))
1035 {
1036 gchar *ret;
1037 ret = g_strdup (*point + strlen (name) + 1);
1038 g_strfreev (split);
1039 return ret;
1040 }
1041 point++;
1042 }
1043 g_strfreev (split);
1044 return NULL;
1045}

References nvti::tag.

Referenced by Ensure(), and nvti_severity_vector_from_tag().

Here is the caller graph for this function:

◆ nvti_impact()

gchar * nvti_impact ( const nvti_t n)

Get the text about impact.

Parameters
nThe NVT Info structure of which the impact description should be returned.
Returns
The impact string. Don't free this.

Definition at line 719 of file nvti.c.

720{
721 return n ? n->impact : NULL;
722}

References nvti::impact.

◆ nvti_insight()

gchar * nvti_insight ( const nvti_t n)

Get the text about insight.

Parameters
nThe NVT Info structure of which the insight description should be returned.
Returns
The insight string. Don't free this.

Definition at line 691 of file nvti.c.

692{
693 return n ? n->insight : NULL;
694}

References nvti::insight.

◆ nvti_mandatory_keys()

gchar * nvti_mandatory_keys ( const nvti_t n)

Get the mandatory keys list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The mandatory keys string. Don't free this.

Definition at line 1098 of file nvti.c.

1099{
1100 return n ? n->mandatory_keys : NULL;
1101}

References nvti::mandatory_keys.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_modification_time()

time_t nvti_modification_time ( const nvti_t n)

Get the modification time.

Parameters
nThe NVT Info structure of which the modification time should be returned.
Returns
The modification time in seconds since epoch.

Definition at line 747 of file nvti.c.

748{
749 return n ? n->modification_time : 0;
750}
time_t modification_time
Time of last change, sec. since epoch.
Definition: nvti.c:404

References nvti::modification_time.

Referenced by nvti_add_tag().

Here is the caller graph for this function:

◆ nvti_name()

gchar * nvti_name ( const nvti_t n)

Get the name.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The name string. Don't free this.

Definition at line 663 of file nvti.c.

664{
665 return n ? n->name : NULL;
666}

References nvti::name.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_new()

nvti_t * nvti_new ( void  )

Create a new (empty) nvti structure.

Returns
NULL in case the memory could not be allocated. Else an empty nvti structure which needs to be released using nvti_free . The whole struct is initialized with 0's.

Definition at line 597 of file nvti.c.

598{
599 return (nvti_t *) g_malloc0 (sizeof (nvti_t));
600}

Referenced by Ensure(), and redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_oid()

gchar * nvti_oid ( const nvti_t n)

Get the OID string.

Parameters
nThe NVT Info structure of which the OID should be returned.
Returns
The OID string. Don't free this.

Definition at line 649 of file nvti.c.

650{
651 return n ? n->oid : NULL;
652}

References nvti::oid.

Referenced by Ensure(), nvticache_add(), nvtis_add(), and redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_pref()

const nvtpref_t * nvti_pref ( const nvti_t n,
guint  p 
)

Get the n'th preferences of the NVT.

Parameters
nThe NVT Info structure.
pThe position of the preference to return.
Returns
The preference. NULL on error.

Definition at line 1224 of file nvti.c.

1225{
1226 return n ? g_slist_nth_data (n->prefs, p) : NULL;
1227}

References nvti::prefs.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_pref_len()

guint nvti_pref_len ( const nvti_t n)

Get the number of preferences of the NVT.

Parameters
nThe NVT Info structure.
Returns
The number of preferences.

Definition at line 1209 of file nvti.c.

1210{
1211 return n ? g_slist_length (n->prefs) : 0;
1212}

References nvti::prefs.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_put_affected()

int nvti_put_affected ( nvti_t n,
gchar *  affected 
)

Set the affected text of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
affectedThe affected text to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1412 of file nvti.c.

1413{
1414 if (!n)
1415 return -1;
1416
1417 g_free (n->affected);
1418 n->affected = affected;
1419 return 0;
1420}

References nvti::affected.

◆ nvti_put_detection()

int nvti_put_detection ( nvti_t n,
gchar *  detection 
)

Set the detection text of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
detectionThe detection text to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1873 of file nvti.c.

1874{
1875 if (!n)
1876 return -1;
1877
1878 g_free (n->detection);
1879 n->detection = detection;
1880 return 0;
1881}

References nvti::detection.

◆ nvti_put_family()

int nvti_put_family ( nvti_t n,
gchar *  family 
)

Set the family of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
familyThe family to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1961 of file nvti.c.

1962{
1963 if (!n)
1964 return -1;
1965
1966 g_free (n->family);
1967 n->family = family;
1968 return 0;
1969}

References nvti::family.

◆ nvti_put_impact()

int nvti_put_impact ( nvti_t n,
gchar *  impact 
)

Set the impact text of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
impactThe impact text to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1452 of file nvti.c.

1453{
1454 if (!n)
1455 return -1;
1456
1457 g_free (n->impact);
1458 n->impact = impact;
1459 return 0;
1460}

References nvti::impact.

◆ nvti_put_insight()

int nvti_put_insight ( nvti_t n,
gchar *  insight 
)

Set the insight text of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
insightThe insight text to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1372 of file nvti.c.

1373{
1374 if (!n)
1375 return -1;
1376
1377 g_free (n->insight);
1378 n->insight = insight;
1379 return 0;
1380}

References nvti::insight.

◆ nvti_put_name()

int nvti_put_name ( nvti_t n,
gchar *  name 
)

Set the name of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
nameThe name to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1292 of file nvti.c.

1293{
1294 if (!n)
1295 return -1;
1296
1297 g_free (n->name);
1298 n->name = name;
1299 return 0;
1300}

References nvti::name.

◆ nvti_put_solution()

int nvti_put_solution ( nvti_t n,
gchar *  solution 
)

Set the solution of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
solutionThe solution to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1530 of file nvti.c.

1531{
1532 if (!n)
1533 return -1;
1534
1535 g_free (n->solution);
1536 n->solution = solution;
1537 return 0;
1538}

References nvti::solution.

◆ nvti_put_summary()

int nvti_put_summary ( nvti_t n,
gchar *  summary 
)

Set the summary of a NVT, using the given memory.

Parameters
nThe NVT Info structure.
summaryThe summary to set. The string will be used directly.
Returns
0 for success. Anything else indicates an error.

Definition at line 1332 of file nvti.c.

1333{
1334 if (!n)
1335 return -1;
1336
1337 g_free (n->summary);
1338 n->summary = summary;
1339 return 0;
1340}

References nvti::summary.

◆ nvti_qod()

gchar * nvti_qod ( const nvti_t n)

Get the QoD.

Parameters
nThe NVT Info structure of which the QoD should be returned.
Returns
The QoD as string. Don't free this.

Definition at line 1182 of file nvti.c.

1183{
1184 return n ? n->qod : NULL;
1185}

References nvti::qod.

◆ nvti_qod_type()

gchar * nvti_qod_type ( const nvti_t n)

Get the QoD type.

Parameters
nThe NVT Info structure of which the QoD type should be returned.
Returns
The QoD type as string. Don't free this.

Definition at line 1168 of file nvti.c.

1169{
1170 return n ? n->qod_type : NULL;
1171}

References nvti::qod_type.

◆ nvti_refs()

gchar * nvti_refs ( const nvti_t n,
const gchar *  type,
const gchar *  exclude_types,
guint  use_types 
)

Get references as string.

Parameters
nThe NVT Info structure of which the references should be returned.
typeOptional type to collect. If NULL, all types are collected.
exclude_typesOptional CSC list of types to exclude from collection. If NULL, no types are excluded.
use_typesIf 0, then a simple comma separated list will be returned. If not 0, then for each reference the syntax "type:id" is applied.
Returns
The references as string. This needs to be free'd. The format of the string depends on the "use_types" parameter. If use_types is 0 it is a comma-separated list "id, id, id" is returned. If use_types is not 0 a comma-separated list like "type:id, type:id, type:id" is returned. NULL is returned in case n is NULL.

Definition at line 804 of file nvti.c.

806{
807 gchar *refs, *refs2, **exclude_item;
808 vtref_t *ref;
809 guint i, exclude;
810 gchar **exclude_split;
811
812 if (!n)
813 return NULL;
814
815 refs = NULL;
816 refs2 = NULL;
817 exclude = 0;
818
819 if (exclude_types && exclude_types[0])
820 exclude_split = g_strsplit (exclude_types, ",", 0);
821 else
822 exclude_split = NULL;
823
824 for (i = 0; i < g_slist_length (n->refs); i++)
825 {
826 ref = g_slist_nth_data (n->refs, i);
827 if (type && strcasecmp (ref->type, type) != 0)
828 continue;
829
830 if (exclude_split)
831 {
832 exclude = 0;
833 for (exclude_item = exclude_split; *exclude_item; exclude_item++)
834 {
835 if (strcasecmp (g_strstrip (*exclude_item), ref->type) == 0)
836 {
837 exclude = 1;
838 break;
839 }
840 }
841 }
842
843 if (!exclude)
844 {
845 if (use_types)
846 {
847 if (refs)
848 refs2 =
849 g_strdup_printf ("%s, %s:%s", refs, ref->type, ref->ref_id);
850 else
851 refs2 = g_strdup_printf ("%s:%s", ref->type, ref->ref_id);
852 }
853 else
854 {
855 if (refs)
856 refs2 = g_strdup_printf ("%s, %s", refs, ref->ref_id);
857 else
858 refs2 = g_strdup_printf ("%s", ref->ref_id);
859 }
860 g_free (refs);
861 refs = refs2;
862 }
863 }
864
865 g_strfreev (exclude_split);
866
867 return refs;
868}
The structure for a cross reference of a VT.
Definition: nvti.c:58
gchar * type
Reference type ("cve", "bid", ...)
Definition: nvti.c:59
gchar * ref_id
Actual reference ID ("CVE-2018-1234", etc)
Definition: nvti.c:60

References vtref::ref_id, nvti::refs, and vtref::type.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_required_keys()

gchar * nvti_required_keys ( const nvti_t n)

Get the required keys list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The required keys string. Don't free this.

Definition at line 1084 of file nvti.c.

1085{
1086 return n ? n->required_keys : NULL;
1087}

References nvti::required_keys.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_required_ports()

gchar * nvti_required_ports ( const nvti_t n)

Get the required ports list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The required ports string. Don't free this.

Definition at line 1126 of file nvti.c.

1127{
1128 return n ? n->required_ports : NULL;
1129}

References nvti::required_ports.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_required_udp_ports()

gchar * nvti_required_udp_ports ( const nvti_t n)

Get the required udp ports list.

Parameters
nThe NVT Info structure of which the name should be returned.
Returns
The required udp ports string. Don't free this.

Definition at line 1140 of file nvti.c.

1141{
1142 return n ? n->required_udp_ports : NULL;
1143}

References nvti::required_udp_ports.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_set_affected()

int nvti_set_affected ( nvti_t n,
const gchar *  affected 
)

Set the affected text of a NVT.

Parameters
nThe NVT Info structure.
affectedThe affected text to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1392 of file nvti.c.

1393{
1394 if (!n)
1395 return -1;
1396
1397 g_free (n->affected);
1398 n->affected = g_strdup (affected);
1399 return 0;
1400}

References nvti::affected.

◆ nvti_set_category()

int nvti_set_category ( nvti_t n,
const gint  category 
)

Set the category type of a NVT Info.

Parameters
nThe NVT Info structure.
categoryThe category to set. Values <= 0 will indicate it is not set.
Returns
0 for success. Anything else indicates an error.

Definition at line 1981 of file nvti.c.

1982{
1983 if (!n)
1984 return -1;
1985
1986 n->category = category;
1987 return 0;
1988}

References nvti::category.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_creation_time()

int nvti_set_creation_time ( nvti_t n,
const time_t  creation_time 
)

Set the creation time of a NVT.

Parameters
nThe NVT Info structure.
creation_timeThe creation time to set.
Returns
0 for success. Anything else indicates an error.

Definition at line 1472 of file nvti.c.

1473{
1474 if (!n)
1475 return -1;
1476
1477 n->creation_time = creation_time;
1478 return 0;
1479}

References nvti::creation_time.

Referenced by nvti_add_tag().

Here is the caller graph for this function:

◆ nvti_set_cvss_base()

int nvti_set_cvss_base ( nvti_t n,
const gchar *  cvss_base 
)

Set the CVSS base of an NVT.

Parameters
nThe NVT Info structure.
cvss_baseThe CVSS base to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1686 of file nvti.c.

1687{
1688 if (!n)
1689 return -1;
1690
1691 g_free (n->cvss_base);
1692 if (cvss_base && cvss_base[0])
1693 n->cvss_base = g_strdup (cvss_base);
1694 else
1695 n->cvss_base = NULL;
1696 return 0;
1697}

References nvti::cvss_base.

◆ nvti_set_dependencies()

int nvti_set_dependencies ( nvti_t n,
const gchar *  dependencies 
)

Set the dependencies of a NVT.

Parameters
nThe NVT Info structure.
dependenciesThe dependencies to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1710 of file nvti.c.

1711{
1712 if (!n)
1713 return -1;
1714
1715 g_free (n->dependencies);
1716 if (dependencies && dependencies[0])
1717 n->dependencies = g_strdup (dependencies);
1718 else
1719 n->dependencies = NULL;
1720 return 0;
1721}

References nvti::dependencies.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_detection()

int nvti_set_detection ( nvti_t n,
const gchar *  detection 
)

Set the detection text of a NVT.

Parameters
nThe NVT Info structure.
detectionThe detection text to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1853 of file nvti.c.

1854{
1855 if (!n)
1856 return -1;
1857
1858 g_free (n->detection);
1859 n->detection = g_strdup (detection);
1860 return 0;
1861}

References nvti::detection.

◆ nvti_set_excluded_keys()

int nvti_set_excluded_keys ( nvti_t n,
const gchar *  excluded_keys 
)

Set the excluded keys of a NVT.

Parameters
nThe NVT Info structure.
excluded_keysThe excluded keys to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1782 of file nvti.c.

1783{
1784 if (!n)
1785 return -1;
1786
1787 g_free (n->excluded_keys);
1788 if (excluded_keys && excluded_keys[0])
1789 n->excluded_keys = g_strdup (excluded_keys);
1790 else
1791 n->excluded_keys = NULL;
1792 return 0;
1793}

References nvti::excluded_keys.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_family()

int nvti_set_family ( nvti_t n,
const gchar *  family 
)

Set the family of a NVT.

Parameters
nThe NVT Info structure.
familyThe family to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1941 of file nvti.c.

1942{
1943 if (!n)
1944 return -1;
1945
1946 g_free (n->family);
1947 n->family = g_strdup (family);
1948 return 0;
1949}

References nvti::family.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_impact()

int nvti_set_impact ( nvti_t n,
const gchar *  impact 
)

Set the impact text of a NVT.

Parameters
nThe NVT Info structure.
impactThe impact text to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1432 of file nvti.c.

1433{
1434 if (!n)
1435 return -1;
1436
1437 g_free (n->impact);
1438 n->impact = g_strdup (impact);
1439 return 0;
1440}

References nvti::impact.

◆ nvti_set_insight()

int nvti_set_insight ( nvti_t n,
const gchar *  insight 
)

Set the insight text of a NVT.

Parameters
nThe NVT Info structure.
insightThe insight text to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1352 of file nvti.c.

1353{
1354 if (!n)
1355 return -1;
1356
1357 g_free (n->insight);
1358 n->insight = g_strdup (insight);
1359 return 0;
1360}

References nvti::insight.

◆ nvti_set_mandatory_keys()

int nvti_set_mandatory_keys ( nvti_t n,
const gchar *  mandatory_keys 
)

Set the mandatory keys of a NVT.

Parameters
nThe NVT Info structure.
mandatory_keysThe mandatory keys to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1758 of file nvti.c.

1759{
1760 if (!n)
1761 return -1;
1762
1763 g_free (n->mandatory_keys);
1764 if (mandatory_keys && mandatory_keys[0])
1765 n->mandatory_keys = g_strdup (mandatory_keys);
1766 else
1767 n->mandatory_keys = NULL;
1768 return 0;
1769}

References nvti::mandatory_keys.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_modification_time()

int nvti_set_modification_time ( nvti_t n,
const time_t  modification_time 
)

Set the modification time of a NVT.

Parameters
nThe NVT Info structure.
modification_timeThe modification time to set.
Returns
0 for success. Anything else indicates an error.

Definition at line 1491 of file nvti.c.

1492{
1493 if (!n)
1494 return -1;
1495
1496 n->modification_time = modification_time;
1497 return 0;
1498}

References nvti::modification_time.

Referenced by nvti_add_tag().

Here is the caller graph for this function:

◆ nvti_set_name()

int nvti_set_name ( nvti_t n,
const gchar *  name 
)

Set the name of a NVT.

Parameters
nThe NVT Info structure.
nameThe name to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1272 of file nvti.c.

1273{
1274 if (!n)
1275 return -1;
1276
1277 g_free (n->name);
1278 n->name = g_strdup (name);
1279 return 0;
1280}

References nvti::name.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_oid()

int nvti_set_oid ( nvti_t n,
const gchar *  oid 
)

Set the OID of a NVT Info.

Parameters
nThe NVT Info structure.
oidThe OID to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1252 of file nvti.c.

1253{
1254 if (!n)
1255 return -1;
1256
1257 g_free (n->oid);
1258 n->oid = g_strdup (oid);
1259 return 0;
1260}

References nvti::oid.

Referenced by Ensure(), and redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_qod()

int nvti_set_qod ( nvti_t n,
const gchar *  qod 
)

Set the QoD of a NVT.

Parameters
nThe NVT Info structure.
qodThe QoD to set. A copy will be created from this. The string is not checked, any string is accepted as type.
Returns
0 for success. Anything else indicates an error.

Definition at line 1918 of file nvti.c.

1919{
1920 if (!n)
1921 return -1;
1922
1923 g_free (n->qod);
1924 if (qod && qod[0])
1925 n->qod = g_strdup (qod);
1926 else
1927 n->qod = NULL;
1928 return 0;
1929}

References nvti::qod.

◆ nvti_set_qod_type()

int nvti_set_qod_type ( nvti_t n,
const gchar *  qod_type 
)

Set the QoD type of a NVT.

Parameters
nThe NVT Info structure.
qod_typeThe QoD type to set. A copy will be created from this. The string is not checked, any string is accepted as type.
Returns
0 for success. Anything else indicates an error.

Definition at line 1894 of file nvti.c.

1895{
1896 if (!n)
1897 return -1;
1898
1899 g_free (n->qod_type);
1900 if (qod_type && qod_type[0])
1901 n->qod_type = g_strdup (qod_type);
1902 else
1903 n->qod_type = NULL;
1904 return 0;
1905}

References nvti::qod_type.

◆ nvti_set_required_keys()

int nvti_set_required_keys ( nvti_t n,
const gchar *  required_keys 
)

Set the required keys of a NVT.

Parameters
nThe NVT Info structure.
required_keysThe required keys to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1734 of file nvti.c.

1735{
1736 if (!n)
1737 return -1;
1738
1739 g_free (n->required_keys);
1740 if (required_keys && required_keys[0])
1741 n->required_keys = g_strdup (required_keys);
1742 else
1743 n->required_keys = NULL;
1744 return 0;
1745}

References nvti::required_keys.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_required_ports()

int nvti_set_required_ports ( nvti_t n,
const gchar *  required_ports 
)

Set the required ports of a NVT.

Parameters
nThe NVT Info structure.
required_portsThe required ports to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1806 of file nvti.c.

1807{
1808 if (!n)
1809 return -1;
1810
1811 g_free (n->required_ports);
1812 if (required_ports && required_ports[0])
1813 n->required_ports = g_strdup (required_ports);
1814 else
1815 n->required_ports = NULL;
1816 return 0;
1817}

References nvti::required_ports.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_required_udp_ports()

int nvti_set_required_udp_ports ( nvti_t n,
const gchar *  required_udp_ports 
)

Set the required udp ports of a NVT.

Parameters
nThe NVT Info structure.
required_udp_portsThe required udp ports to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1830 of file nvti.c.

1831{
1832 if (!n)
1833 return -1;
1834
1835 g_free (n->required_udp_ports);
1836 if (required_udp_ports && required_udp_ports[0])
1837 n->required_udp_ports = g_strdup (required_udp_ports);
1838 else
1839 n->required_udp_ports = NULL;
1840 return 0;
1841}

References nvti::required_udp_ports.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_solution()

int nvti_set_solution ( nvti_t n,
const gchar *  solution 
)

Set the solution of a NVT.

Parameters
nThe NVT Info structure.
solutionThe solution to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1510 of file nvti.c.

1511{
1512 if (!n)
1513 return -1;
1514
1515 g_free (n->solution);
1516 n->solution = g_strdup (solution);
1517 return 0;
1518}

References nvti::solution.

◆ nvti_set_solution_method()

int nvti_set_solution_method ( nvti_t n,
const gchar *  solution_method 
)

Set the solution method of a NVT.

Parameters
nThe NVT Info structure.
solution_methodThe solution method to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1572 of file nvti.c.

1573{
1574 if (!n)
1575 return -1;
1576
1577 g_free (n->solution_method);
1578 n->solution_method = g_strdup (solution_method);
1579 return 0;
1580}

References nvti::solution_method.

Referenced by Ensure().

Here is the caller graph for this function:

◆ nvti_set_solution_type()

int nvti_set_solution_type ( nvti_t n,
const gchar *  solution_type 
)

Set the solution type of a NVT.

Parameters
nThe NVT Info structure.
solution_typeThe solution type to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1551 of file nvti.c.

1552{
1553 if (!n)
1554 return -1;
1555
1556 g_free (n->solution_type);
1557 n->solution_type = g_strdup (solution_type);
1558 return 0;
1559}

References nvti::solution_type.

◆ nvti_set_summary()

int nvti_set_summary ( nvti_t n,
const gchar *  summary 
)

Set the summary of a NVT.

Parameters
nThe NVT Info structure.
summaryThe summary to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1312 of file nvti.c.

1313{
1314 if (!n)
1315 return -1;
1316
1317 g_free (n->summary);
1318 n->summary = g_strdup (summary);
1319 return 0;
1320}

References nvti::summary.

◆ nvti_set_tag()

int nvti_set_tag ( nvti_t n,
const gchar *  tag 
)

Set the tags of a NVT.

Parameters
nThe NVT Info structure.
tagThe tags to set. A copy will be created from this.
Returns
0 for success. Anything else indicates an error.

Definition at line 1663 of file nvti.c.

1664{
1665 if (!n)
1666 return -1;
1667
1668 g_free (n->tag);
1669 if (tag && tag[0])
1670 n->tag = g_strdup (tag);
1671 else
1672 n->tag = NULL;
1673 return 0;
1674}

References nvti::tag.

Referenced by Ensure(), and redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_severity_score()

double nvti_severity_score ( const nvti_t n)

Get the maximum severity score.

Parameters
nThe NVT Info structure.
Returns
The severity score, -1 indicates an error.

Definition at line 906 of file nvti.c.

907{
908 unsigned int i;
909 double score = -1.0;
910
911 for (i = 0; i < nvti_vtseverities_len (n); i++)
912 {
913 vtseverity_t *severity;
914
915 severity = nvti_vtseverity (n, i);
916 if (vtseverity_score (severity) > score)
917 score = vtseverity_score (severity);
918 }
919
920 return score;
921}
guint nvti_vtseverities_len(const nvti_t *n)
Get the number of severities of the NVT.
Definition: nvti.c:878
double vtseverity_score(const vtseverity_t *s)
Get the score of a severity.
Definition: nvti.c:281
vtseverity_t * nvti_vtseverity(const nvti_t *n, guint p)
Get the n'th reference of the NVT.
Definition: nvti.c:893
The structure for a severity of a VT.
Definition: nvti.c:159

References nvti_vtseverities_len(), nvti_vtseverity(), and vtseverity_score().

Here is the call graph for this function:

◆ nvti_severity_vector_from_tag()

gchar * nvti_severity_vector_from_tag ( const nvti_t n)

Get the severity score.

Extended severity was introduced but still not all vts are using it. Therefore it must be checked if we can calculate the score from the severity_vector tag or if we have to calculate it from the deprecated cvss_base_vector tag.

Parameters
nThe NVT Info structure.
Returns
The severity_vector if present or cvss_base_vector otherwise. NULL indicates an error. Must be free()'d by the caller.

Definition at line 938 of file nvti.c.

939{
940 gchar *vector;
941
942 /* Currently, only one severity_vector can be stored as tag.
943 * Therfore we just check this one. */
944 vector = nvti_get_tag (n, "severity_vector");
945 if (vector)
946 return vector;
947
948 vector = nvti_get_tag (n, "cvss_base_vector");
949
950 return vector;
951}
gchar * nvti_get_tag(const nvti_t *n, const gchar *name)
Get a tag value by a tag name.
Definition: nvti.c:1020

References nvti_get_tag().

Referenced by Ensure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvti_solution()

gchar * nvti_solution ( const nvti_t n)

Get the solution.

Parameters
nThe NVT Info structure of which the solution should be returned.
Returns
The solution string. Don't free this.

Definition at line 962 of file nvti.c.

963{
964 return n ? n->solution : NULL;
965}

References nvti::solution.

◆ nvti_solution_method()

gchar * nvti_solution_method ( const nvti_t n)

Get the solution method.

Parameters
nThe NVT Info structure of which the solution method should be returned.
Returns
The solution method string. Don't free this.

Definition at line 990 of file nvti.c.

991{
992 return n ? n->solution_method : NULL;
993}

References nvti::solution_method.

Referenced by Ensure().

Here is the caller graph for this function:

◆ nvti_solution_type()

gchar * nvti_solution_type ( const nvti_t n)

Get the solution type.

Parameters
nThe NVT Info structure of which the solution type should be returned.
Returns
The solution type string. Don't free this.

Definition at line 976 of file nvti.c.

977{
978 return n ? n->solution_type : NULL;
979}

References nvti::solution_type.

◆ nvti_summary()

gchar * nvti_summary ( const nvti_t n)

Get the summary.

Parameters
nThe NVT Info structure of which the summary should be returned.
Returns
The summary string. Don't free this.

Definition at line 677 of file nvti.c.

678{
679 return n ? n->summary : NULL;
680}

References nvti::summary.

◆ nvti_tag()

gchar * nvti_tag ( const nvti_t n)

Get the tags.

Parameters
nThe NVT Info structure of which the tags should be returned.
Returns
The tags string. Don't free this.

Definition at line 1004 of file nvti.c.

1005{
1006 return n ? n->tag : NULL;
1007}

References nvti::tag.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_vtref()

vtref_t * nvti_vtref ( const nvti_t n,
guint  p 
)

Get the n'th reference of the NVT.

Parameters
nThe NVT Info structure.
pThe position of the reference to return.
Returns
The reference. NULL on error.

Definition at line 775 of file nvti.c.

776{
777 return n ? g_slist_nth_data (n->refs, p) : NULL;
778}

References nvti::refs.

◆ nvti_vtref_len()

guint nvti_vtref_len ( const nvti_t n)

Get the number of references of the NVT.

Parameters
nThe NVT Info structure.
Returns
The number of references.

Definition at line 760 of file nvti.c.

761{
762 return n ? g_slist_length (n->refs) : 0;
763}

References nvti::refs.

◆ nvti_vtseverities_len()

guint nvti_vtseverities_len ( const nvti_t n)

Get the number of severities of the NVT.

Parameters
nThe NVT Info structure.
Returns
The number of severities.

Definition at line 878 of file nvti.c.

879{
880 return n ? g_slist_length (n->severities) : 0;
881}

References nvti::severities.

Referenced by nvti_severity_score().

Here is the caller graph for this function:

◆ nvti_vtseverity()

vtseverity_t * nvti_vtseverity ( const nvti_t n,
guint  p 
)

Get the n'th reference of the NVT.

Parameters
nThe NVT Info structure.
pThe position of the reference to return.
Returns
The reference. NULL on error.

Definition at line 893 of file nvti.c.

894{
895 return n ? g_slist_nth_data (n->severities, p) : NULL;
896}

References nvti::severities.

Referenced by nvti_severity_score().

Here is the caller graph for this function:

◆ nvtis_add()

void nvtis_add ( nvtis_t nvtis,
nvti_t nvti 
)

Add an NVT Info to a collection of NVT Infos.

Parameters
nvtisThe collection of NVT Infos.
nvtiThe NVT Info to add.

Definition at line 2271 of file nvti.c.

2272{
2273 if (nvti)
2274 g_hash_table_insert (
2275 nvtis, (gpointer) (nvti_oid (nvti) ? g_strdup (nvti_oid (nvti)) : NULL),
2276 (gpointer) nvti);
2277}
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition: nvti.c:649

References nvti_oid().

Referenced by Ensure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvtis_free()

void nvtis_free ( nvtis_t nvtis)

Free a collection of NVT Infos.

Parameters
nvtisThe collection of NVT Infos.

Definition at line 2258 of file nvti.c.

2259{
2260 if (nvtis)
2261 g_hash_table_destroy (nvtis);
2262}

◆ nvtis_lookup()

nvti_t * nvtis_lookup ( nvtis_t nvtis,
const char *  oid 
)

Add an NVT Info to a collection of NVT Infos.

Parameters
nvtisThe collection of NVT Infos.
oidThe OID of the NVT.
Returns
The NVT Info, if found, else NULL.

Definition at line 2288 of file nvti.c.

2289{
2290 return g_hash_table_lookup (nvtis, oid);
2291}

Referenced by Ensure().

Here is the caller graph for this function:

◆ nvtis_new()

nvtis_t * nvtis_new ( void  )

Make a collection of NVT Infos.

Returns
An empty collection of NVT Infos.

Definition at line 2246 of file nvti.c.

2247{
2248 return g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2250}
static void free_nvti_for_hash_table(gpointer nvti)
Free an NVT Info, for g_hash_table_destroy.
Definition: nvti.c:2235

References free_nvti_for_hash_table().

Referenced by Ensure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nvtpref_default()

gchar * nvtpref_default ( const nvtpref_t np)

Get the Default of a NVT Preference.

Parameters
npThe NVT Pref structure of which the Default should be returned.
Returns
The default string. Don't free this.

Definition at line 583 of file nvti.c.

584{
585 return np ? np->dflt : NULL;
586}
gchar * dflt
Default value of the preference.
Definition: nvti.c:481

References nvtpref::dflt.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvtpref_free()

void nvtpref_free ( nvtpref_t np)

Free memory of a nvtpref structure.

Parameters
npThe structure to be freed.

Definition at line 521 of file nvti.c.

522{
523 if (!np)
524 return;
525
526 g_free (np->name);
527 g_free (np->type);
528 g_free (np->dflt);
529 g_free (np);
530}
gchar * type
Preference type.
Definition: nvti.c:479
gchar * name
Name of the preference.
Definition: nvti.c:480

References nvtpref::dflt, nvtpref::name, and nvtpref::type.

Referenced by nvti_free().

Here is the caller graph for this function:

◆ nvtpref_id()

int nvtpref_id ( const nvtpref_t np)

Get the ID of a NVT Preference.

Parameters
npThe NVT Pref structure of which the Name should be returned.
Returns
The ID value.

Definition at line 541 of file nvti.c.

542{
543 return np ? np->id : -1;
544}
int id
Preference ID.
Definition: nvti.c:478

References nvtpref::id.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvtpref_name()

gchar * nvtpref_name ( const nvtpref_t np)

Get the Name of a NVT Preference.

Parameters
npThe NVT Pref structure of which the Name should be returned.
Returns
The name string. Don't free this.

Definition at line 555 of file nvti.c.

556{
557 return np ? np->name : NULL;
558}

References nvtpref::name.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvtpref_new()

nvtpref_t * nvtpref_new ( int  id,
const gchar *  name,
const gchar *  type,
const gchar *  dflt 
)

Create a new nvtpref structure filled with the given values.

Parameters
idThe ID to be set.
nameThe name to be set. A copy will created of this.
typeThe type to be set. A copy will created of this.
dfltThe default to be set. A copy will created of this.
Returns
NULL in case the memory could not be allocated. Else a nvtpref structure which needs to be released using nvtpref_free .

Definition at line 500 of file nvti.c.

501{
502 nvtpref_t *np = g_malloc0 (sizeof (nvtpref_t));
503
504 np->id = id;
505 if (name)
506 np->name = g_strdup (name);
507 if (type)
508 np->type = g_strdup (type);
509 if (dflt)
510 np->dflt = g_strdup (dflt);
511
512 return np;
513}
The structure for a preference of a NVT.
Definition: nvti.c:477

References nvtpref::dflt, nvtpref::id, nvtpref::name, and nvtpref::type.

Referenced by nvticache_get_prefs().

Here is the caller graph for this function:

◆ nvtpref_type()

gchar * nvtpref_type ( const nvtpref_t np)

Get the Type of a NVT Preference.

Parameters
npThe NVT Pref structure of which the Type should be returned.
Returns
The type string. Don't free this.

Definition at line 569 of file nvti.c.

570{
571 return np ? np->type : NULL;
572}

References nvtpref::type.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ parse_nvt_timestamp()

static time_t parse_nvt_timestamp ( const gchar *  str_time)
static

Try convert an NVT tag time string into epoch time or return 0 upon parse errors.

Parameters
[in]str_timeTime stamp as string in one of the forms used in NVTs.
Returns
Time as seconds since the epoch.

Definition at line 297 of file nvti.c.

298{
299 time_t epoch_time;
300 int offset;
301 struct tm tm;
302
303 if ((strcmp ((char *) str_time, "") == 0)
304 || (strcmp ((char *) str_time, "$Date: $") == 0)
305 || (strcmp ((char *) str_time, "$Date$") == 0)
306 || (strcmp ((char *) str_time, "$Date:$") == 0)
307 || (strcmp ((char *) str_time, "$Date") == 0)
308 || (strcmp ((char *) str_time, "$$") == 0))
309 {
310 return 0;
311 }
312
313 /* Parse the time. */
314
315 /* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */
316 /* $Date: 2012-02-17 16:05:26 +0100 (Fr, 17. Feb 2012) $ */
317 /* $Date: Fri, 11 Nov 2011 14:42:28 +0100 $ */
318 memset (&tm, 0, sizeof (struct tm));
319 if (strptime ((char *) str_time, "%F %T %z", &tm) == NULL)
320 {
321 memset (&tm, 0, sizeof (struct tm));
322 if (strptime ((char *) str_time, "$Date: %F %T %z", &tm) == NULL)
323 {
324 memset (&tm, 0, sizeof (struct tm));
325 if (strptime ((char *) str_time, "%a %b %d %T %Y %z", &tm) == NULL)
326 {
327 memset (&tm, 0, sizeof (struct tm));
328 if (strptime ((char *) str_time, "$Date: %a, %d %b %Y %T %z", &tm)
329 == NULL)
330 {
331 memset (&tm, 0, sizeof (struct tm));
332 if (strptime ((char *) str_time, "$Date: %a %b %d %T %Y %z",
333 &tm)
334 == NULL)
335 {
336 g_warning ("%s: Failed to parse time: %s", __func__,
337 str_time);
338 return 0;
339 }
340 }
341 }
342 }
343 }
344 epoch_time = mktime (&tm);
345 if (epoch_time == -1)
346 {
347 g_warning ("%s: Failed to make time: %s", __func__, str_time);
348 return 0;
349 }
350
351 /* Get the timezone offset from the str_time. */
352
353 if ((sscanf ((char *) str_time, "%*u-%*u-%*u %*u:%*u:%*u %d%*[^]]", &offset)
354 != 1)
355 && (sscanf ((char *) str_time, "$Date: %*u-%*u-%*u %*u:%*u:%*u %d%*[^]]",
356 &offset)
357 != 1)
358 && (sscanf ((char *) str_time, "%*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
359 &offset)
360 != 1)
361 && (sscanf ((char *) str_time,
362 "$Date: %*s %*s %*s %*u %*u:%*u:%*u %d%*[^]]", &offset)
363 != 1)
364 && (sscanf ((char *) str_time,
365 "$Date: %*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]", &offset)
366 != 1))
367 {
368 g_warning ("%s: Failed to parse timezone offset: %s", __func__, str_time);
369 return 0;
370 }
371
372 /* Use the offset to convert to UTC. */
373
374 if (offset < 0)
375 {
376 epoch_time += ((-offset) / 100) * 60 * 60;
377 epoch_time += ((-offset) % 100) * 60;
378 }
379 else if (offset > 0)
380 {
381 epoch_time -= (offset / 100) * 60 * 60;
382 epoch_time -= (offset % 100) * 60;
383 }
384
385 return epoch_time;
386}

Referenced by nvti_add_tag().

Here is the caller graph for this function:

◆ vtref_free()

void vtref_free ( vtref_t ref)

Free memory of a vtref structure.

Parameters
refThe structure to be freed.

Definition at line 98 of file nvti.c.

99{
100 if (!ref)
101 return;
102
103 g_free (ref->type);
104 g_free (ref->ref_id);
105 g_free (ref->ref_text);
106 g_free (ref);
107}
gchar * ref_text
Optional additional text.
Definition: nvti.c:61

References vtref::ref_id, vtref::ref_text, and vtref::type.

Referenced by nvti_free().

Here is the caller graph for this function:

◆ vtref_id()

const gchar * vtref_id ( const vtref_t r)

Get the id of a reference.

Parameters
rThe VT Reference structure of which the id should be returned.
Returns
The id string. Don't free this.

Definition at line 132 of file nvti.c.

133{
134 return r ? r->ref_id : NULL;
135}

References vtref::ref_id.

◆ vtref_new()

vtref_t * vtref_new ( const gchar *  type,
const gchar *  ref_id,
const gchar *  ref_text 
)

Create a new vtref structure filled with the given values.

Parameters
typeThe type to be set.
ref_idThe actual reference to be set.
ref_textThe optional text accompanying a reference.
Returns
NULL in case the memory could not be allocated. Else a vtref structure which needs to be released using vtref_free .

Definition at line 78 of file nvti.c.

79{
80 vtref_t *ref = g_malloc0 (sizeof (vtref_t));
81
82 if (type)
83 ref->type = g_strdup (type);
84 if (ref_id)
85 ref->ref_id = g_strdup (ref_id);
86 if (ref_text)
87 ref->ref_text = g_strdup (ref_text);
88
89 return ref;
90}

References vtref::ref_id, vtref::ref_text, and vtref::type.

Referenced by nvti_add_refs().

Here is the caller graph for this function:

◆ vtref_text()

const gchar * vtref_text ( const vtref_t r)

Get the text of a reference.

Parameters
rThe VT Reference structure of which the id should be returned.
Returns
The id string. Don't free this.

Definition at line 146 of file nvti.c.

147{
148 return r ? r->ref_text : NULL;
149}

References vtref::ref_text.

◆ vtref_type()

const gchar * vtref_type ( const vtref_t r)

Get the type of a reference.

Parameters
rThe VT Reference structure of which the type should be returned.
Returns
The type string. Don't free this.

Definition at line 118 of file nvti.c.

119{
120 return r ? r->type : NULL;
121}

References vtref::type.

◆ vtseverity_date()

int vtseverity_date ( const vtseverity_t s)

Get the date of a severity.

Parameters
sThe VT Severity structure of which the date should be returned.
Returns
The date.

Definition at line 267 of file nvti.c.

268{
269 return s->date;
270}
int date
Timestamp in seconds since epoch, defaults to VT creation date.
Definition: nvti.c:163

References vtseverity::date.

◆ vtseverity_free()

void vtseverity_free ( vtseverity_t s)

Free memory of a vtseverity structure.

Parameters
sThe structure to be freed.

Definition at line 205 of file nvti.c.

206{
207 if (!s)
208 return;
209
210 g_free (s->type);
211 g_free (s->origin);
212 g_free (s->value);
213 g_free (s);
214}
gchar * origin
Definition: nvti.c:161
gchar * value
The value which corresponds to the type.
Definition: nvti.c:165
gchar * type
Severity type ("cvss_base_v2", ...)
Definition: nvti.c:160

References vtseverity::origin, vtseverity::type, and vtseverity::value.

Referenced by nvti_free().

Here is the caller graph for this function:

◆ vtseverity_new()

vtseverity_t * vtseverity_new ( const gchar *  type,
const gchar *  origin,
int  date,
double  score,
const gchar *  value 
)

Create a new vtseverity structure filled with the given values.

Parameters
[in]typeThe severity type to be set.
[in]originThe origin reference to be set, can be NULL.
[in]dateThe date to be set.
[in]scoreThe score to be set.
[in]valueThe value corresponding to the type.
Returns
NULL in case the memory could not be allocated. Else a vtref structure which needs to be released using vtref_free .

Definition at line 182 of file nvti.c.

184{
185 vtseverity_t *s = g_malloc0 (sizeof (vtseverity_t));
186
187 if (type)
188 s->type = g_strdup (type);
189 if (origin)
190 s->origin = g_strdup (origin);
191 s->date = date;
192 s->score = score;
193 if (value)
194 s->value = g_strdup (value);
195
196 return s;
197}
double score
The score derived from the value in range [0.0-10.0].
Definition: nvti.c:164

References vtseverity::date, vtseverity::origin, vtseverity::score, vtseverity::type, and vtseverity::value.

◆ vtseverity_origin()

const gchar * vtseverity_origin ( const vtseverity_t s)

Get the origin of a severity.

Parameters
sThe VT Severity structure of which the origin should be returned.
Returns
The origin string. Don't free this.

Definition at line 239 of file nvti.c.

240{
241 return s ? s->origin : NULL;
242}

References vtseverity::origin.

◆ vtseverity_score()

double vtseverity_score ( const vtseverity_t s)

Get the score of a severity.

Parameters
sThe VT Severity structure of which the score should be returned.
Returns
The score.

Definition at line 281 of file nvti.c.

282{
283 return s->score;
284}

References vtseverity::score.

Referenced by nvti_severity_score().

Here is the caller graph for this function:

◆ vtseverity_type()

const gchar * vtseverity_type ( const vtseverity_t s)

Get the type of a severity.

Parameters
sThe VT Severity structure of which the type should be returned.
Returns
The type string. Don't free this.

Definition at line 225 of file nvti.c.

226{
227 return s ? s->type : NULL;
228}

References vtseverity::type.

◆ vtseverity_value()

const gchar * vtseverity_value ( const vtseverity_t s)

Get the value of a severity.

Parameters
sThe VT Severity structure of which the value should be returned.
Returns
The value string. Don't free this.

Definition at line 253 of file nvti.c.

254{
255 return s ? s->value : NULL;
256}

References vtseverity::value.