Greenbone Vulnerability Management Libraries 22.32.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()

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 2197 of file nvti.c.

2198{
2199 nvti_free ((nvti_t *) nvti);
2200}
struct nvti nvti_t
The structure of a information record that corresponds to a NVT.
void nvti_free(nvti_t *n)
Free memory of a nvti structure.
Definition nvti.c:570
The structure of a information record that corresponds to a NVT.
Definition nvti.c:358

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 2084 of file nvti.c.

2085{
2086 gchar *old;
2087
2088 if (!n)
2089 return 1;
2090 if (!key)
2091 return 2;
2092
2093 old = n->excluded_keys;
2094
2095 if (old)
2096 {
2097 n->excluded_keys = g_strdup_printf ("%s, %s", old, key);
2098 g_free (old);
2099 }
2100 else
2101 n->excluded_keys = g_strdup (key);
2102
2103 return 0;
2104}
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition nvti.c:380

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 2052 of file nvti.c.

2053{
2054 gchar *old;
2055
2056 if (!n)
2057 return 1;
2058 if (!key)
2059 return 2;
2060
2061 old = n->mandatory_keys;
2062
2063 if (old)
2064 {
2065 n->mandatory_keys = g_strdup_printf ("%s, %s", old, key);
2066 g_free (old);
2067 }
2068 else
2069 n->mandatory_keys = g_strdup (key);
2070
2071 return 0;
2072}
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition nvti.c:379

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 2180 of file nvti.c.

2181{
2182 if (!n)
2183 return -1;
2184
2185 n->prefs = g_slist_append (n->prefs, np);
2186 return 0;
2187}
GSList * prefs
Collection of NVT preferences.
Definition nvti.c:391

References nvti::prefs.

Referenced by add_preferences_to_nvt().

Here is the caller graph for this function:

◆ 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 1968 of file nvti.c.

1970{
1971 gchar **split, **item;
1972
1973 if (!n)
1974 return 1;
1975
1976 if (!ref_ids)
1977 return 2;
1978
1979 split = g_strsplit (ref_ids, ",", 0);
1980
1981 for (item = split; *item; item++)
1982 {
1983 gchar *id;
1984
1985 id = *item;
1986 g_strstrip (id);
1987
1988 if (strcmp (id, "") == 0)
1989 continue;
1990
1991 if (type)
1992 {
1993 nvti_add_vtref (n, vtref_new (type, id, ref_text));
1994 }
1995 else
1996 {
1997 gchar **split2;
1998
1999 split2 = g_strsplit (id, ":", 2);
2000 if (split2[0] && split2[1])
2001 nvti_add_vtref (n, vtref_new (split2[0], split2[1], ""));
2002 g_strfreev (split2);
2003 }
2004 }
2005 g_strfreev (split);
2006
2007 return 0;
2008}
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:77
int nvti_add_vtref(nvti_t *vt, vtref_t *ref)
Add a reference to the VT Info.
Definition nvti.c:408

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 2020 of file nvti.c.

2021{
2022 gchar *old;
2023
2024 if (!n)
2025 return 1;
2026 if (!key)
2027 return 2;
2028
2029 old = n->required_keys;
2030
2031 if (old)
2032 {
2033 n->required_keys = g_strdup_printf ("%s, %s", old, key);
2034 g_free (old);
2035 }
2036 else
2037 n->required_keys = g_strdup (key);
2038
2039 return 0;
2040}
gchar * required_keys
List of required KB keys of this NVT.
Definition nvti.c:378

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 2116 of file nvti.c.

2117{
2118 gchar *old;
2119
2120 if (!n)
2121 return 1;
2122 if (!port)
2123 return 2;
2124
2125 old = n->required_ports;
2126
2127 if (old)
2128 {
2129 n->required_ports = g_strdup_printf ("%s, %s", old, port);
2130 g_free (old);
2131 }
2132 else
2133 n->required_ports = g_strdup (port);
2134
2135 return 0;
2136}
gchar * required_ports
List of required ports of this NVT.
Definition nvti.c:381

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 2148 of file nvti.c.

2149{
2150 gchar *old;
2151
2152 if (!n)
2153 return 1;
2154 if (!port)
2155 return 2;
2156
2157 old = n->required_udp_ports;
2158
2159 if (old)
2160 {
2161 n->required_udp_ports = g_strdup_printf ("%s, %s", old, port);
2162 g_free (old);
2163 }
2164 else
2165 n->required_udp_ports = g_strdup (port);
2166
2167 return 0;
2168}
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition nvti.c:383

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 1561 of file nvti.c.

1562{
1563 gchar *newvalue = NULL;
1564
1565 if (!n)
1566 return -1;
1567
1568 if (!name || !name[0])
1569 return -2;
1570
1571 if (!value || !value[0])
1572 return -3;
1573
1574 if (!strcmp (name, "last_modification"))
1575 {
1577 newvalue = g_strdup_printf ("%i", (int) nvti_modification_time (n));
1578 }
1579 else if (!strcmp (name, "creation_date"))
1580 {
1582 newvalue = g_strdup_printf ("%i", (int) nvti_creation_time (n));
1583 }
1584 else if (!strcmp (name, "severity_date"))
1585 newvalue = g_strdup_printf ("%i", (int) parse_nvt_timestamp (value));
1586 else if (!strcmp (name, "cvss_base"))
1587 {
1588 /* Ignore this tag because it is not being used.
1589 * It is redundant with the tag cvss_base_vector from which
1590 * it is computed.
1591 * Once GOS 6 and GVM 11 are retired, all set_tag commands
1592 * in the NASL scripts can be removed that set "cvss_base".
1593 * Once this happened this exception can be removed from the code.
1594 */
1595 return 0;
1596 }
1597
1598 if (n->tag)
1599 {
1600 gchar *newtag;
1601
1602 newtag =
1603 g_strconcat (n->tag, "|", name, "=", newvalue ? newvalue : value, NULL);
1604 g_free (n->tag);
1605 n->tag = newtag;
1606 }
1607 else
1608 n->tag = g_strconcat (name, "=", newvalue ? newvalue : value, NULL);
1609
1610 g_free (newvalue);
1611
1612 return 0;
1613}
time_t nvti_creation_time(const nvti_t *n)
Get the creation time.
Definition nvti.c:695
int nvti_set_modification_time(nvti_t *n, const time_t modification_time)
Set the modification time of a NVT.
Definition nvti.c:1453
int nvti_set_creation_time(nvti_t *n, const time_t creation_time)
Set the creation time of a NVT.
Definition nvti.c:1434
time_t nvti_modification_time(const nvti_t *n)
Get the modification time.
Definition nvti.c:709
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:295
gchar * tag
List of tags attached to this NVT.
Definition nvti.c:374

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

Referenced by add_tags_to_nvt().

Here is the call graph for this function:
Here is the caller 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 408 of file nvti.c.

409{
410 if (!vt)
411 return -1;
412
413 vt->refs = g_slist_append (vt->refs, ref);
414 return 0;
415}
GSList * refs
Collection of VT references.
Definition nvti.c:389

References nvti::refs.

Referenced by nvti_add_refs(), and parse_references().

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 426 of file nvti.c.

427{
428 if (!vt)
429 return -1;
430
431 vt->severities = g_slist_append (vt->severities, s);
432 return 0;
433}
GSList * severities
Collection of VT severities.
Definition nvti.c:390

References nvti::severities.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 667 of file nvti.c.

668{
669 return n ? n->affected : NULL;
670}
gchar * affected
Affected systems.
Definition nvti.c:364

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 1199 of file nvti.c.

1200{
1201 return n ? n->category : -1;
1202}
gint category
The category, this NVT belongs to.
Definition nvti.c:394

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 695 of file nvti.c.

696{
697 return n ? n->creation_time : 0;
698}
time_t creation_time
Time of creation, seconds since epoch.
Definition nvti.c:367

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 1018 of file nvti.c.

1019{
1020 return n ? n->cvss_base : NULL;
1021}
gchar * cvss_base
CVSS base score for this NVT.
Definition nvti.c:375

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 1032 of file nvti.c.

1033{
1034 return n ? n->dependencies : NULL;
1035}
gchar * dependencies
List of dependencies of this NVT.
Definition nvti.c:377

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 1116 of file nvti.c.

1117{
1118 return n ? n->detection : NULL;
1119}
gchar * detection
Detection description.
Definition nvti.c:385

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 1074 of file nvti.c.

1075{
1076 return n ? n->excluded_keys : NULL;
1077}

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 1158 of file nvti.c.

1159{
1160 return n ? n->family : NULL;
1161}
gchar * family
Family the NVT belongs to.
Definition nvti.c:395

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 570 of file nvti.c.

571{
572 if (!n)
573 return;
574
575 g_free (n->oid);
576 g_free (n->name);
577 g_free (n->summary);
578 g_free (n->insight);
579 g_free (n->affected);
580 g_free (n->impact);
581 g_free (n->solution);
582 g_free (n->solution_type);
583 g_free (n->solution_method);
584 g_free (n->tag);
585 g_free (n->cvss_base);
586 g_free (n->dependencies);
587 g_free (n->required_keys);
588 g_free (n->mandatory_keys);
589 g_free (n->excluded_keys);
590 g_free (n->required_ports);
591 g_free (n->required_udp_ports);
592 g_free (n->detection);
593 g_free (n->qod_type);
594 g_free (n->qod);
595 g_free (n->family);
596 g_slist_free_full (n->refs, (void (*) (void *)) vtref_free);
597 g_slist_free_full (n->severities, (void (*) (void *)) vtseverity_free);
598 g_slist_free_full (n->prefs, (void (*) (void *)) nvtpref_free);
599 g_free (n);
600}
void vtseverity_free(vtseverity_t *s)
Free memory of a vtseverity structure.
Definition nvti.c:203
void nvtpref_free(nvtpref_t *np)
Free memory of a nvtpref structure.
Definition nvti.c:484
void vtref_free(vtref_t *ref)
Free memory of a vtref structure.
Definition nvti.c:97
gchar * solution_method
The solution method.
Definition nvti.c:372
gchar * insight
The insight.
Definition nvti.c:363
gchar * solution
The solution.
Definition nvti.c:370
gchar * impact
Impact of vulnerability.
Definition nvti.c:365
gchar * oid
Object ID.
Definition nvti.c:359
gchar * name
The name.
Definition nvti.c:360
gchar * qod_type
Quality of detection type.
Definition nvti.c:386
gchar * solution_type
The solution type.
Definition nvti.c:371
gchar * qod
Quality of detection.
Definition nvti.c:387
gchar * summary
The summary.
Definition nvti.c:362

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(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), free_nvti_for_hash_table(), and parse_vt_json().

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 982 of file nvti.c.

983{
984 gchar **split, **point;
985
986 if (!n || n->tag == NULL || !name)
987 return NULL;
988
989 split = g_strsplit (n->tag, "|", 0);
990 point = split;
991
992 while (*point)
993 {
994 if ((strlen (*point) > strlen (name))
995 && (strncmp (*point, name, strlen (name)) == 0)
996 && ((*point)[strlen (name)] == '='))
997 {
998 gchar *ret;
999 ret = g_strdup (*point + strlen (name) + 1);
1000 g_strfreev (split);
1001 return ret;
1002 }
1003 point++;
1004 }
1005 g_strfreev (split);
1006 return NULL;
1007}

References nvti::tag.

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), 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 681 of file nvti.c.

682{
683 return n ? n->impact : NULL;
684}

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 653 of file nvti.c.

654{
655 return n ? n->insight : NULL;
656}

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 1060 of file nvti.c.

1061{
1062 return n ? n->mandatory_keys : NULL;
1063}

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 709 of file nvti.c.

710{
711 return n ? n->modification_time : 0;
712}
time_t modification_time
Time of last change, sec. since epoch.
Definition nvti.c:368

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 625 of file nvti.c.

626{
627 return n ? n->name : NULL;
628}

References nvti::name.

Referenced by Ensure(), and 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
An empty nvti structure which needs to be released using nvti_free . The whole struct is initialized with 0's.

Definition at line 559 of file nvti.c.

560{
561 return (nvti_t *) g_malloc0 (sizeof (nvti_t));
562}

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), parse_vt_json(), 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 611 of file nvti.c.

612{
613 return n ? n->oid : NULL;
614}

References nvti::oid.

Referenced by add_tags_to_nvt(), 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 1186 of file nvti.c.

1187{
1188 return n ? g_slist_nth_data (n->prefs, p) : NULL;
1189}

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 1171 of file nvti.c.

1172{
1173 return n ? g_slist_length (n->prefs) : 0;
1174}

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 1374 of file nvti.c.

1375{
1376 if (!n)
1377 return -1;
1378
1379 g_free (n->affected);
1380 n->affected = affected;
1381 return 0;
1382}

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 1835 of file nvti.c.

1836{
1837 if (!n)
1838 return -1;
1839
1840 g_free (n->detection);
1841 n->detection = detection;
1842 return 0;
1843}

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 1923 of file nvti.c.

1924{
1925 if (!n)
1926 return -1;
1927
1928 g_free (n->family);
1929 n->family = family;
1930 return 0;
1931}

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 1414 of file nvti.c.

1415{
1416 if (!n)
1417 return -1;
1418
1419 g_free (n->impact);
1420 n->impact = impact;
1421 return 0;
1422}

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 1334 of file nvti.c.

1335{
1336 if (!n)
1337 return -1;
1338
1339 g_free (n->insight);
1340 n->insight = insight;
1341 return 0;
1342}

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 1254 of file nvti.c.

1255{
1256 if (!n)
1257 return -1;
1258
1259 g_free (n->name);
1260 n->name = name;
1261 return 0;
1262}

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 1492 of file nvti.c.

1493{
1494 if (!n)
1495 return -1;
1496
1497 g_free (n->solution);
1498 n->solution = solution;
1499 return 0;
1500}

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 1294 of file nvti.c.

1295{
1296 if (!n)
1297 return -1;
1298
1299 g_free (n->summary);
1300 n->summary = summary;
1301 return 0;
1302}

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 1144 of file nvti.c.

1145{
1146 return n ? n->qod : NULL;
1147}

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 1130 of file nvti.c.

1131{
1132 return n ? n->qod_type : NULL;
1133}

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 766 of file nvti.c.

768{
769 gchar *refs, *refs2, **exclude_item;
770 vtref_t *ref;
771 guint i, exclude;
772 gchar **exclude_split;
773
774 if (!n)
775 return NULL;
776
777 refs = NULL;
778 refs2 = NULL;
779 exclude = 0;
780
781 if (exclude_types && exclude_types[0])
782 exclude_split = g_strsplit (exclude_types, ",", 0);
783 else
784 exclude_split = NULL;
785
786 for (i = 0; i < g_slist_length (n->refs); i++)
787 {
788 ref = g_slist_nth_data (n->refs, i);
789 if (type && strcasecmp (ref->type, type) != 0)
790 continue;
791
792 if (exclude_split)
793 {
794 exclude = 0;
795 for (exclude_item = exclude_split; *exclude_item; exclude_item++)
796 {
797 if (strcasecmp (g_strstrip (*exclude_item), ref->type) == 0)
798 {
799 exclude = 1;
800 break;
801 }
802 }
803 }
804
805 if (!exclude)
806 {
807 if (use_types)
808 {
809 if (refs)
810 refs2 =
811 g_strdup_printf ("%s, %s:%s", refs, ref->type, ref->ref_id);
812 else
813 refs2 = g_strdup_printf ("%s:%s", ref->type, ref->ref_id);
814 }
815 else
816 {
817 if (refs)
818 refs2 = g_strdup_printf ("%s, %s", refs, ref->ref_id);
819 else
820 refs2 = g_strdup_printf ("%s", ref->ref_id);
821 }
822 g_free (refs);
823 refs = refs2;
824 }
825 }
826
827 g_strfreev (exclude_split);
828
829 return refs;
830}
struct vtref vtref_t
The structure for a cross reference of a VT.
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 Ensure(), and 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 1046 of file nvti.c.

1047{
1048 return n ? n->required_keys : NULL;
1049}

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 1088 of file nvti.c.

1089{
1090 return n ? n->required_ports : NULL;
1091}

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 1102 of file nvti.c.

1103{
1104 return n ? n->required_udp_ports : NULL;
1105}

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 1354 of file nvti.c.

1355{
1356 if (!n)
1357 return -1;
1358
1359 g_free (n->affected);
1360 n->affected = g_strdup (affected);
1361 return 0;
1362}

References nvti::affected.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1943 of file nvti.c.

1944{
1945 if (!n)
1946 return -1;
1947
1948 n->category = category;
1949 return 0;
1950}

References nvti::category.

Referenced by parse_vt_json(), and 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 1434 of file nvti.c.

1435{
1436 if (!n)
1437 return -1;
1438
1439 n->creation_time = creation_time;
1440 return 0;
1441}

References nvti::creation_time.

Referenced by add_tags_to_nvt(), and 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 1648 of file nvti.c.

1649{
1650 if (!n)
1651 return -1;
1652
1653 g_free (n->cvss_base);
1654 if (cvss_base && cvss_base[0])
1655 n->cvss_base = g_strdup (cvss_base);
1656 else
1657 n->cvss_base = NULL;
1658 return 0;
1659}

References nvti::cvss_base.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1672 of file nvti.c.

1673{
1674 if (!n)
1675 return -1;
1676
1677 g_free (n->dependencies);
1678 if (dependencies && dependencies[0])
1679 n->dependencies = g_strdup (dependencies);
1680 else
1681 n->dependencies = NULL;
1682 return 0;
1683}

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 1815 of file nvti.c.

1816{
1817 if (!n)
1818 return -1;
1819
1820 g_free (n->detection);
1821 n->detection = g_strdup (detection);
1822 return 0;
1823}

References nvti::detection.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1744 of file nvti.c.

1745{
1746 if (!n)
1747 return -1;
1748
1749 g_free (n->excluded_keys);
1750 if (excluded_keys && excluded_keys[0])
1751 n->excluded_keys = g_strdup (excluded_keys);
1752 else
1753 n->excluded_keys = NULL;
1754 return 0;
1755}

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 1903 of file nvti.c.

1904{
1905 if (!n)
1906 return -1;
1907
1908 g_free (n->family);
1909 n->family = g_strdup (family);
1910 return 0;
1911}

References nvti::family.

Referenced by parse_vt_json(), and 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 1394 of file nvti.c.

1395{
1396 if (!n)
1397 return -1;
1398
1399 g_free (n->impact);
1400 n->impact = g_strdup (impact);
1401 return 0;
1402}

References nvti::impact.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1314 of file nvti.c.

1315{
1316 if (!n)
1317 return -1;
1318
1319 g_free (n->insight);
1320 n->insight = g_strdup (insight);
1321 return 0;
1322}

References nvti::insight.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1720 of file nvti.c.

1721{
1722 if (!n)
1723 return -1;
1724
1725 g_free (n->mandatory_keys);
1726 if (mandatory_keys && mandatory_keys[0])
1727 n->mandatory_keys = g_strdup (mandatory_keys);
1728 else
1729 n->mandatory_keys = NULL;
1730 return 0;
1731}

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 1453 of file nvti.c.

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

References nvti::modification_time.

Referenced by add_tags_to_nvt(), and 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 1234 of file nvti.c.

1235{
1236 if (!n)
1237 return -1;
1238
1239 g_free (n->name);
1240 n->name = g_strdup (name);
1241 return 0;
1242}

References nvti::name.

Referenced by parse_vt_json(), and 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 1214 of file nvti.c.

1215{
1216 if (!n)
1217 return -1;
1218
1219 g_free (n->oid);
1220 n->oid = g_strdup (oid);
1221 return 0;
1222}

References nvti::oid.

Referenced by Ensure(), parse_vt_json(), 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 1880 of file nvti.c.

1881{
1882 if (!n)
1883 return -1;
1884
1885 g_free (n->qod);
1886 if (qod && qod[0])
1887 n->qod = g_strdup (qod);
1888 else
1889 n->qod = NULL;
1890 return 0;
1891}

References nvti::qod.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1856 of file nvti.c.

1857{
1858 if (!n)
1859 return -1;
1860
1861 g_free (n->qod_type);
1862 if (qod_type && qod_type[0])
1863 n->qod_type = g_strdup (qod_type);
1864 else
1865 n->qod_type = NULL;
1866 return 0;
1867}

References nvti::qod_type.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1696 of file nvti.c.

1697{
1698 if (!n)
1699 return -1;
1700
1701 g_free (n->required_keys);
1702 if (required_keys && required_keys[0])
1703 n->required_keys = g_strdup (required_keys);
1704 else
1705 n->required_keys = NULL;
1706 return 0;
1707}

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 1768 of file nvti.c.

1769{
1770 if (!n)
1771 return -1;
1772
1773 g_free (n->required_ports);
1774 if (required_ports && required_ports[0])
1775 n->required_ports = g_strdup (required_ports);
1776 else
1777 n->required_ports = NULL;
1778 return 0;
1779}

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 1792 of file nvti.c.

1793{
1794 if (!n)
1795 return -1;
1796
1797 g_free (n->required_udp_ports);
1798 if (required_udp_ports && required_udp_ports[0])
1799 n->required_udp_ports = g_strdup (required_udp_ports);
1800 else
1801 n->required_udp_ports = NULL;
1802 return 0;
1803}

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 1472 of file nvti.c.

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

References nvti::solution.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1534 of file nvti.c.

1535{
1536 if (!n)
1537 return -1;
1538
1539 g_free (n->solution_method);
1540 n->solution_method = g_strdup (solution_method);
1541 return 0;
1542}

References nvti::solution_method.

Referenced by add_tags_to_nvt(), and 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 1513 of file nvti.c.

1514{
1515 if (!n)
1516 return -1;
1517
1518 g_free (n->solution_type);
1519 n->solution_type = g_strdup (solution_type);
1520 return 0;
1521}

References nvti::solution_type.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1274 of file nvti.c.

1275{
1276 if (!n)
1277 return -1;
1278
1279 g_free (n->summary);
1280 n->summary = g_strdup (summary);
1281 return 0;
1282}

References nvti::summary.

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 1625 of file nvti.c.

1626{
1627 if (!n)
1628 return -1;
1629
1630 g_free (n->tag);
1631 if (tag && tag[0])
1632 n->tag = g_strdup (tag);
1633 else
1634 n->tag = NULL;
1635 return 0;
1636}

References nvti::tag.

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), 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 868 of file nvti.c.

869{
870 unsigned int i;
871 double score = -1.0;
872
873 for (i = 0; i < nvti_vtseverities_len (n); i++)
874 {
875 vtseverity_t *severity;
876
877 severity = nvti_vtseverity (n, i);
878 if (vtseverity_score (severity) > score)
879 score = vtseverity_score (severity);
880 }
881
882 return score;
883}
struct vtseverity vtseverity_t
The structure for a severity of a VT.
guint nvti_vtseverities_len(const nvti_t *n)
Get the number of severities of the NVT.
Definition nvti.c:840
double vtseverity_score(const vtseverity_t *s)
Get the score of a severity.
Definition nvti.c:279
vtseverity_t * nvti_vtseverity(const nvti_t *n, guint p)
Get the n'th reference of the NVT.
Definition nvti.c:855

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 900 of file nvti.c.

901{
902 gchar *vector;
903
904 /* Currently, only one severity_vector can be stored as tag.
905 * Therfore we just check this one. */
906 vector = nvti_get_tag (n, "severity_vector");
907 if (vector)
908 return vector;
909
910 vector = nvti_get_tag (n, "cvss_base_vector");
911
912 return vector;
913}
gchar * nvti_get_tag(const nvti_t *n, const gchar *name)
Get a tag value by a tag name.
Definition nvti.c:982

References nvti_get_tag().

Referenced by Ensure(), Ensure(), and 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 924 of file nvti.c.

925{
926 return n ? n->solution : NULL;
927}

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 952 of file nvti.c.

953{
954 return n ? n->solution_method : NULL;
955}

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 938 of file nvti.c.

939{
940 return n ? n->solution_type : NULL;
941}

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 639 of file nvti.c.

640{
641 return n ? n->summary : NULL;
642}

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 966 of file nvti.c.

967{
968 return n ? n->tag : NULL;
969}

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 737 of file nvti.c.

738{
739 return n ? g_slist_nth_data (n->refs, p) : NULL;
740}

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 722 of file nvti.c.

723{
724 return n ? g_slist_length (n->refs) : 0;
725}

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 840 of file nvti.c.

841{
842 return n ? g_slist_length (n->severities) : 0;
843}

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 855 of file nvti.c.

856{
857 return n ? g_slist_nth_data (n->severities, p) : NULL;
858}

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 2233 of file nvti.c.

2234{
2235 if (nvti)
2236 g_hash_table_insert (
2237 nvtis, (gpointer) (nvti_oid (nvti) ? g_strdup (nvti_oid (nvti)) : NULL),
2238 (gpointer) nvti);
2239}
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition nvti.c:611

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 2220 of file nvti.c.

2221{
2222 if (nvtis)
2223 g_hash_table_destroy (nvtis);
2224}

Referenced by Ensure().

Here is the caller graph for this function:

◆ 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 2250 of file nvti.c.

2251{
2252 return g_hash_table_lookup (nvtis, oid);
2253}

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 2208 of file nvti.c.

2209{
2210 return g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2212}
static void free_nvti_for_hash_table(gpointer nvti)
Free an NVT Info, for g_hash_table_destroy.
Definition nvti.c:2197

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 546 of file nvti.c.

547{
548 return np ? np->dflt : NULL;
549}
gchar * dflt
Default value of the preference.
Definition nvti.c:445

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 484 of file nvti.c.

485{
486 if (!np)
487 return;
488
489 g_free (np->name);
490 g_free (np->type);
491 g_free (np->dflt);
492 g_free (np);
493}
gchar * type
Preference type.
Definition nvti.c:443
gchar * name
Name of the preference.
Definition nvti.c:444

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 504 of file nvti.c.

505{
506 return np ? np->id : -1;
507}
int id
Preference ID.
Definition nvti.c:442

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 518 of file nvti.c.

519{
520 return np ? np->name : NULL;
521}

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
An nvtpref structure which needs to be released using nvtpref_free .

Definition at line 463 of file nvti.c.

464{
465 nvtpref_t *np = g_malloc0 (sizeof (nvtpref_t));
466
467 np->id = id;
468 if (name)
469 np->name = g_strdup (name);
470 if (type)
471 np->type = g_strdup (type);
472 if (dflt)
473 np->dflt = g_strdup (dflt);
474
475 return np;
476}
struct nvtpref nvtpref_t
The structure for a preference of a NVT.

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

Referenced by add_preferences_to_nvt(), and 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 532 of file nvti.c.

533{
534 return np ? np->type : NULL;
535}

References nvtpref::type.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ parse_nvt_timestamp()

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 295 of file nvti.c.

296{
297 time_t epoch_time;
298 int offset;
299 struct tm tm;
300
301 if (strcmp ((char *) str_time, "") == 0)
302 return 0;
303
304 /* Parse the time. */
305
306 /* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */
307 memset (&tm, 0, sizeof (struct tm));
308 if (strptime ((char *) str_time, "%F %T %z", &tm) == NULL)
309 {
310 memset (&tm, 0, sizeof (struct tm));
311 if (strptime ((char *) str_time, "%a %b %d %T %Y %z", &tm) == NULL)
312 {
313 g_warning ("%s: Failed to parse time: %s", __func__, str_time);
314 return 0;
315 }
316 }
317 epoch_time = mktime (&tm);
318 if (epoch_time == -1)
319 {
320 g_warning ("%s: Failed to make time: %s", __func__, str_time);
321 return 0;
322 }
323
324 /* Get the timezone offset from the str_time. */
325
326 if ((sscanf ((char *) str_time, "%*u-%*u-%*u %*u:%*u:%*u %d%*[^]]", &offset)
327 != 1)
328 && (sscanf ((char *) str_time, "%*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
329 &offset)
330 != 1))
331 {
332 g_warning ("%s: Failed to parse timezone offset: %s", __func__, str_time);
333 return 0;
334 }
335
336 /* Use the offset to convert to UTC. */
337
338 if (offset < 0)
339 {
340 epoch_time += ((-offset) / 100) * 60 * 60;
341 epoch_time += ((-offset) % 100) * 60;
342 }
343 else if (offset > 0)
344 {
345 epoch_time -= (offset / 100) * 60 * 60;
346 epoch_time -= (offset % 100) * 60;
347 }
348
349 return epoch_time;
350}

Referenced by Ensure(), and 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 97 of file nvti.c.

98{
99 if (!ref)
100 return;
101
102 g_free (ref->type);
103 g_free (ref->ref_id);
104 g_free (ref->ref_text);
105 g_free (ref);
106}
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 131 of file nvti.c.

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

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
A vtref structure which needs to be released using vtref_free .

Definition at line 77 of file nvti.c.

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

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

Referenced by nvti_add_refs(), and parse_references().

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 145 of file nvti.c.

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

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 117 of file nvti.c.

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

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 265 of file nvti.c.

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

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 203 of file nvti.c.

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

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
A vtref structure which needs to be released using vtref_free .

Definition at line 180 of file nvti.c.

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

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

Referenced by add_tags_to_nvt().

Here is the caller graph for this function:

◆ 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 237 of file nvti.c.

238{
239 return s ? s->origin : NULL;
240}

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 279 of file nvti.c.

280{
281 return s->score;
282}

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 223 of file nvti.c.

224{
225 return s ? s->type : NULL;
226}

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 251 of file nvti.c.

252{
253 return s ? s->value : NULL;
254}

References vtseverity::value.