Greenbone Vulnerability Management Libraries  10.0.0
nvti.h File Reference

Protos and data structures for NVT Information data sets. More...

#include <glib.h>
Include dependency graph for nvti.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nvtpref
 The structure for a preference of a NVT. More...
 
struct  nvti
 The structure of a information record that corresponds to a NVT. More...
 

Typedefs

typedef struct nvtpref nvtpref_t
 The structure for a preference of a NVT. More...
 
typedef struct nvti nvti_t
 The structure of a information record that corresponds to a NVT. More...
 
typedef GHashTable nvtis_t
 A collection of information records corresponding to NVTs. More...
 

Functions

nvtpref_tnvtpref_new (gchar *, gchar *, gchar *)
 Create a new nvtpref structure filled with the given values. More...
 
void nvtpref_free (nvtpref_t *)
 Free memory of a nvtpref structure. More...
 
gchar * nvtpref_name (const nvtpref_t *)
 Get the Name of a NVT Preference. More...
 
gchar * nvtpref_type (const nvtpref_t *)
 Get the Type of a NVT Preference. More...
 
gchar * nvtpref_default (const nvtpref_t *)
 Get the Default of a NVT Preference. More...
 
nvti_tnvti_new (void)
 Create a new (empty) nvti structure. More...
 
void nvti_free (nvti_t *)
 Free memory of a nvti structure. More...
 
gchar * nvti_oid (const nvti_t *)
 Get the OID string. More...
 
gchar * nvti_name (const nvti_t *)
 Get the name. More...
 
gchar * nvti_cve (const nvti_t *)
 Get the CVE references. More...
 
gchar * nvti_bid (const nvti_t *)
 Get the bid references. More...
 
gchar * nvti_xref (const nvti_t *)
 Get the xref's. More...
 
gchar * nvti_tag (const nvti_t *)
 Get the tag. More...
 
gchar * nvti_cvss_base (const nvti_t *)
 Get the CVSS base. More...
 
gchar * nvti_dependencies (const nvti_t *)
 Get the dependencies list. More...
 
gchar * nvti_required_keys (const nvti_t *)
 Get the required keys list. More...
 
gchar * nvti_mandatory_keys (const nvti_t *)
 Get the mandatory keys list. More...
 
gchar * nvti_excluded_keys (const nvti_t *)
 Get the excluded keys list. More...
 
gchar * nvti_required_ports (const nvti_t *)
 Get the required ports list. More...
 
gchar * nvti_required_udp_ports (const nvti_t *)
 Get the required udp ports list. More...
 
gint nvti_timeout (const nvti_t *)
 Get the timeout for this NVT. More...
 
gint nvti_category (const nvti_t *)
 Get the category for this NVT. More...
 
gchar * nvti_family (const nvti_t *)
 Get the family name. More...
 
guint nvti_pref_len (const nvti_t *)
 Get the number of preferences of the NVT. More...
 
const nvtpref_tnvti_pref (const nvti_t *, guint)
 Get the n'th preferences of the NVT. More...
 
int nvti_set_oid (nvti_t *, const gchar *)
 Set the OID of a NVT Info. More...
 
int nvti_set_name (nvti_t *, const gchar *)
 Set the name of a NVT. More...
 
int nvti_set_cve (nvti_t *, const gchar *)
 Set the CVE references of a NVT. More...
 
int nvti_set_bid (nvti_t *, const gchar *)
 Set the bid references of a NVT. More...
 
int nvti_set_xref (nvti_t *, const gchar *)
 Set the xrefs of a NVT. More...
 
int nvti_set_tag (nvti_t *, const gchar *)
 Set the tags of a NVT. More...
 
int nvti_set_cvss_base (nvti_t *, const gchar *)
 Set the CVSS base of an NVT. More...
 
int nvti_set_dependencies (nvti_t *, const gchar *)
 Set the dependencies of a NVT. More...
 
int nvti_set_required_keys (nvti_t *, const gchar *)
 Set the required keys of a NVT. More...
 
int nvti_set_mandatory_keys (nvti_t *, const gchar *)
 Set the mandatory keys of a NVT. More...
 
int nvti_set_excluded_keys (nvti_t *, const gchar *)
 Set the excluded keys of a NVT. More...
 
int nvti_set_required_ports (nvti_t *, const gchar *)
 Set the required ports of a NVT. More...
 
int nvti_set_required_udp_ports (nvti_t *, const gchar *)
 Set the required udp ports of a NVT. More...
 
int nvti_set_timeout (nvti_t *, const gint)
 Set the timeout of a NVT Info. More...
 
int nvti_set_category (nvti_t *, const gint)
 Set the category type of a NVT Info. More...
 
int nvti_set_family (nvti_t *, const gchar *)
 Set the family of a NVT. More...
 
int nvti_add_cve (nvti_t *, const gchar *)
 Add a single CVE ID of a NVT. More...
 
int nvti_add_bid (nvti_t *, const gchar *)
 Add a single BID ID of a NVT. More...
 
int nvti_add_required_keys (nvti_t *, const gchar *)
 Add a required key of a NVT. More...
 
int nvti_add_mandatory_keys (nvti_t *, const gchar *)
 Add a mandatory key of a NVT. More...
 
int nvti_add_excluded_keys (nvti_t *, const gchar *)
 Add a excluded key of a NVT. More...
 
int nvti_add_required_ports (nvti_t *, const gchar *)
 Add a required port of a NVT. More...
 
int nvti_add_required_udp_ports (nvti_t *, const gchar *)
 Add a required udp port of a NVT. More...
 
int nvti_add_pref (nvti_t *, nvtpref_t *)
 Add a preference to the NVT Info. More...
 
nvtis_tnvtis_new (void)
 Make a collection of NVT Infos. More...
 
void nvtis_free (nvtis_t *)
 Free a collection of NVT Infos. More...
 
void nvtis_add (nvtis_t *, nvti_t *)
 Add an NVT Info to a collection of NVT Infos. More...
 
nvti_tnvtis_lookup (nvtis_t *, const char *)
 Add an NVT Info to a collection of NVT Infos. More...
 

Detailed Description

Protos and data structures for NVT Information data sets.

This file contains the protos for nvti.c

Definition in file nvti.h.

Typedef Documentation

◆ nvti_t

typedef struct nvti nvti_t

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

The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.

◆ nvtis_t

typedef GHashTable nvtis_t

A collection of information records corresponding to NVTs.

Definition at line 188 of file nvti.h.

◆ nvtpref_t

typedef struct nvtpref nvtpref_t

The structure for a preference of a NVT.

The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.

Function Documentation

◆ nvti_add_bid()

int nvti_add_bid ( nvti_t n,
const gchar *  bid_id 
)

Add a single BID ID of a NVT.

Parameters
nThe NVT Info structure.
bid_idThe BID ID to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL. 2 if bid_id was NULL.

Definition at line 868 of file nvti.c.

869 {
870  gchar *old;
871 
872  if (!n)
873  return (1);
874  if (!bid_id)
875  return (2);
876 
877  old = n->bid;
878 
879  if (old)
880  {
881  n->bid = g_strdup_printf ("%s, %s", old, bid_id);
882  g_free (old);
883  }
884  else
885  n->bid = g_strdup (bid_id);
886 
887  return (0);
888 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:68

References nvti::bid.

◆ nvti_add_cve()

int nvti_add_cve ( nvti_t n,
const gchar *  cve_id 
)

Add a single CVE ID of a NVT.

Parameters
nThe NVT Info structure.
cve_idThe CVE ID to add. A copy will be created from this.
Returns
0 for success. 1 if n was NULL, 2 if cve_id was NULL.

Definition at line 836 of file nvti.c.

837 {
838  gchar *old;
839 
840  if (!n)
841  return (1);
842  if (!cve_id)
843  return (2);
844 
845  old = n->cve;
846 
847  if (old)
848  {
849  n->cve = g_strdup_printf ("%s, %s", old, cve_id);
850  g_free (old);
851  }
852  else
853  n->cve = g_strdup (cve_id);
854 
855  return (0);
856 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:67

References nvti::cve.

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

965 {
966  gchar *old;
967 
968  if (!n)
969  return (1);
970  if (!key)
971  return (2);
972 
973  old = n->excluded_keys;
974 
975  if (old)
976  {
977  n->excluded_keys = g_strdup_printf ("%s, %s", old, key);
978  g_free (old);
979  }
980  else
981  n->excluded_keys = g_strdup (key);
982 
983  return (0);
984 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:78

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

933 {
934  gchar *old;
935 
936  if (!n)
937  return (1);
938  if (!key)
939  return (2);
940 
941  old = n->mandatory_keys;
942 
943  if (old)
944  {
945  n->mandatory_keys = g_strdup_printf ("%s, %s", old, key);
946  g_free (old);
947  }
948  else
949  n->mandatory_keys = g_strdup (key);
950 
951  return (0);
952 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:77

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

1061 {
1062  if (!n)
1063  return (-1);
1064 
1065  n->prefs = g_slist_append (n->prefs, np);
1066  return (0);
1067 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:83

References nvti::prefs.

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

901 {
902  gchar *old;
903 
904  if (!n)
905  return (1);
906  if (!key)
907  return (2);
908 
909  old = n->required_keys;
910 
911  if (old)
912  {
913  n->required_keys = g_strdup_printf ("%s, %s", old, key);
914  g_free (old);
915  }
916  else
917  n->required_keys = g_strdup (key);
918 
919  return (0);
920 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:76

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

997 {
998  gchar *old;
999 
1000  if (!n)
1001  return (1);
1002  if (!port)
1003  return (2);
1004 
1005  old = n->required_ports;
1006 
1007  if (old)
1008  {
1009  n->required_ports = g_strdup_printf ("%s, %s", old, port);
1010  g_free (old);
1011  }
1012  else
1013  n->required_ports = g_strdup (port);
1014 
1015  return (0);
1016 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:79

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

1029 {
1030  gchar *old;
1031 
1032  if (!n)
1033  return (1);
1034  if (!port)
1035  return (2);
1036 
1037  old = n->required_udp_ports;
1038 
1039  if (old)
1040  {
1041  n->required_udp_ports = g_strdup_printf ("%s, %s", old, port);
1042  g_free (old);
1043  }
1044  else
1045  n->required_udp_ports = g_strdup (port);
1046 
1047  return (0);
1048 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:81

References nvti::required_udp_ports.

◆ nvti_bid()

gchar* nvti_bid ( const nvti_t n)

Get the bid references.

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

Definition at line 261 of file nvti.c.

262 {
263  return (n ? n->bid : NULL);
264 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:68

References nvti::bid.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

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

457 {
458  return (n ? n->category : -1);
459 }
gint category
The category, this NVT belongs to.
Definition: nvti.h:87

References nvti::category.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_cve()

gchar* nvti_cve ( const nvti_t n)

Get the CVE references.

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

Definition at line 247 of file nvti.c.

248 {
249  return (n ? n->cve : NULL);
250 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:67

References nvti::cve.

Referenced by redis_add_nvt().

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

304 {
305  return (n ? n->cvss_base : NULL);
306 }
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:73

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

318 {
319  return (n ? n->dependencies : NULL);
320 }
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:75

References nvti::dependencies.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

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

360 {
361  return (n ? n->excluded_keys : NULL);
362 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:78

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

402 {
403  return (n ? n->family : NULL);
404 }
gchar * family
Family the NVT belongs to.
Definition: nvti.h:88

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

168 {
169  if (!n)
170  return;
171 
172  if (n->oid)
173  g_free (n->oid);
174  if (n->name)
175  g_free (n->name);
176  if (n->cve)
177  g_free (n->cve);
178  if (n->bid)
179  g_free (n->bid);
180  if (n->xref)
181  g_free (n->xref);
182  if (n->tag)
183  g_free (n->tag);
184  if (n->cvss_base)
185  g_free (n->cvss_base);
186  if (n->dependencies)
187  g_free (n->dependencies);
188  if (n->required_keys)
189  g_free (n->required_keys);
190  if (n->mandatory_keys)
191  g_free (n->mandatory_keys);
192  if (n->excluded_keys)
193  g_free (n->excluded_keys);
194  if (n->required_ports)
195  g_free (n->required_ports);
196  if (n->required_udp_ports)
197  g_free (n->required_udp_ports);
198  if (n->family)
199  g_free (n->family);
200  if (n->prefs)
201  {
202  int i, len = g_slist_length (n->prefs);
203  for (i = 0; i < len; i++)
204  nvtpref_free (g_slist_nth_data (n->prefs, i));
205  g_slist_free (n->prefs);
206  }
207  g_free (n);
208 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:76
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:73
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:68
gchar * name
The name.
Definition: nvti.h:65
void nvtpref_free(nvtpref_t *np)
Free memory of a nvtpref structure.
Definition: nvti.c:91
gchar * oid
Object ID.
Definition: nvti.h:64
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:81
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:67
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:78
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:75
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:79
gchar * family
Family the NVT belongs to.
Definition: nvti.h:88
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:77
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:72
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:70
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:83

References nvti::bid, nvti::cve, nvti::cvss_base, nvti::dependencies, nvti::excluded_keys, nvti::family, nvti::mandatory_keys, nvti::name, nvtpref_free(), nvti::oid, nvti::prefs, nvti::required_keys, nvti::required_ports, nvti::required_udp_ports, nvti::tag, and nvti::xref.

Referenced by free_nvti_for_hash_table().

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

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

346 {
347  return (n ? n->mandatory_keys : NULL);
348 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:77

References nvti::mandatory_keys.

Referenced by redis_add_nvt().

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

234 {
235  return (n ? n->name : NULL);
236 }
gchar * name
The name.
Definition: nvti.h:65

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

157 {
158  return ((nvti_t *) g_malloc0 (sizeof (nvti_t)));
159 }
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:62

Referenced by 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 219 of file nvti.c.

220 {
221  return (n ? n->oid : NULL);
222 }
gchar * oid
Object ID.
Definition: nvti.h:64

References nvti::oid.

Referenced by 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 number of preferences. NULL if

Definition at line 429 of file nvti.c.

430 {
431  return (n ? g_slist_nth_data (n->prefs, p) : NULL);
432 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:83

References nvti::prefs.

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

415 {
416  return (n ? g_slist_length (n->prefs) : 0);
417 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:83

References nvti::prefs.

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

332 {
333  return (n ? n->required_keys : NULL);
334 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:76

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

374 {
375  return (n ? n->required_ports : NULL);
376 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:79

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

388 {
389  return (n ? n->required_udp_ports : NULL);
390 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:81

References nvti::required_udp_ports.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_set_bid()

int nvti_set_bid ( nvti_t n,
const gchar *  bid 
)

Set the bid references of a NVT.

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

Definition at line 534 of file nvti.c.

535 {
536  if (!n)
537  return (-1);
538 
539  if (n->bid)
540  g_free (n->bid);
541  n->bid = g_strdup (bid);
542  return (0);
543 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:68

References nvti::bid.

Referenced by redis_get_nvt_all().

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

818 {
819  if (!n)
820  return (-1);
821 
822  n->category = category;
823  return (0);
824 }
gint category
The category, this NVT belongs to.
Definition: nvti.h:87

References nvti::category.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_cve()

int nvti_set_cve ( nvti_t n,
const gchar *  cve 
)

Set the CVE references of a NVT.

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

Definition at line 513 of file nvti.c.

514 {
515  if (!n)
516  return (-1);
517 
518  if (n->cve)
519  g_free (n->cve);
520  n->cve = g_strdup (cve);
521  return (0);
522 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:67

References nvti::cve.

Referenced by redis_get_nvt_all().

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

604 {
605  if (!n)
606  return (-1);
607 
608  if (n->cvss_base)
609  g_free (n->cvss_base);
610  if (cvss_base && cvss_base[0])
611  n->cvss_base = g_strdup (cvss_base);
612  else
613  n->cvss_base = NULL;
614  return (0);
615 }
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:73

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

629 {
630  if (!n)
631  return (-1);
632 
633  if (n->dependencies)
634  g_free (n->dependencies);
635  if (dependencies && dependencies[0])
636  n->dependencies = g_strdup (dependencies);
637  else
638  n->dependencies = NULL;
639  return (0);
640 }
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:75

References nvti::dependencies.

Referenced by redis_get_nvt_all().

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

704 {
705  if (!n)
706  return (-1);
707 
708  if (n->excluded_keys)
709  g_free (n->excluded_keys);
710  if (excluded_keys && excluded_keys[0])
711  n->excluded_keys = g_strdup (excluded_keys);
712  else
713  n->excluded_keys = NULL;
714  return (0);
715 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:78

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

778 {
779  if (!n)
780  return (-1);
781 
782  if (n->family)
783  g_free (n->family);
784  n->family = g_strdup (family);
785  return (0);
786 }
gchar * family
Family the NVT belongs to.
Definition: nvti.h:88

References nvti::family.

Referenced by redis_get_nvt_all().

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

679 {
680  if (!n)
681  return (-1);
682 
683  if (n->mandatory_keys)
684  g_free (n->mandatory_keys);
685  if (mandatory_keys && mandatory_keys[0])
686  n->mandatory_keys = g_strdup (mandatory_keys);
687  else
688  n->mandatory_keys = NULL;
689  return (0);
690 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:77

References nvti::mandatory_keys.

Referenced by redis_get_nvt_all().

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

493 {
494  if (!n)
495  return (-1);
496 
497  if (n->name)
498  g_free (n->name);
499  n->name = g_strdup (name);
500  return (0);
501 }
gchar * name
The name.
Definition: nvti.h:65

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

472 {
473  if (!n)
474  return (-1);
475 
476  if (n->oid)
477  g_free (n->oid);
478  n->oid = g_strdup (oid);
479  return (0);
480 }
gchar * oid
Object ID.
Definition: nvti.h:64

References nvti::oid.

Referenced by redis_get_nvt_all().

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

654 {
655  if (!n)
656  return (-1);
657 
658  if (n->required_keys)
659  g_free (n->required_keys);
660  if (required_keys && required_keys[0])
661  n->required_keys = g_strdup (required_keys);
662  else
663  n->required_keys = NULL;
664  return (0);
665 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:76

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

729 {
730  if (!n)
731  return (-1);
732 
733  if (n->required_ports)
734  g_free (n->required_ports);
735  if (required_ports && required_ports[0])
736  n->required_ports = g_strdup (required_ports);
737  else
738  n->required_ports = NULL;
739  return (0);
740 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:79

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

754 {
755  if (!n)
756  return (-1);
757 
758  if (n->required_udp_ports)
759  g_free (n->required_udp_ports);
760  if (required_udp_ports && required_udp_ports[0])
761  n->required_udp_ports = g_strdup (required_udp_ports);
762  else
763  n->required_udp_ports = NULL;
764  return (0);
765 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:81

References nvti::required_udp_ports.

Referenced by redis_get_nvt_all().

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

580 {
581  if (!n)
582  return (-1);
583 
584  if (n->tag)
585  g_free (n->tag);
586  if (tag && tag[0])
587  n->tag = g_strdup (tag);
588  else
589  n->tag = NULL;
590  return (0);
591 }
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:72

References nvti::tag.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_timeout()

int nvti_set_timeout ( nvti_t n,
const gint  timeout 
)

Set the timeout of a NVT Info.

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

Definition at line 798 of file nvti.c.

799 {
800  if (!n)
801  return (-1);
802 
803  n->timeout = timeout;
804  return (0);
805 }
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:86

References nvti::timeout.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_set_xref()

int nvti_set_xref ( nvti_t n,
const gchar *  xref 
)

Set the xrefs of a NVT.

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

Definition at line 555 of file nvti.c.

556 {
557  if (!n)
558  return (-1);
559 
560  if (n->xref)
561  g_free (n->xref);
562  if (xref && xref[0])
563  n->xref = g_strdup (xref);
564  else
565  n->xref = NULL;
566  return (0);
567 }
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:70

References nvti::xref.

Referenced by redis_get_nvt_all().

Here is the caller graph for this function:

◆ nvti_tag()

gchar* nvti_tag ( const nvti_t n)

Get the tag.

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

Definition at line 289 of file nvti.c.

290 {
291  return (n ? n->tag : NULL);
292 }
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:72

References nvti::tag.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_timeout()

gint nvti_timeout ( const nvti_t n)

Get the timeout for this NVT.

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

Definition at line 443 of file nvti.c.

444 {
445  return (n ? n->timeout : -1);
446 }
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:86

References nvti::timeout.

Referenced by redis_add_nvt().

Here is the caller graph for this function:

◆ nvti_xref()

gchar* nvti_xref ( const nvti_t n)

Get the xref's.

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

Definition at line 275 of file nvti.c.

276 {
277  return (n ? n->xref : NULL);
278 }
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:70

References nvti::xref.

Referenced by redis_add_nvt().

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

1114 {
1115  if (nvti)
1116  g_hash_table_insert (nvtis, (gpointer) nvti_oid (nvti), (gpointer) nvti);
1117 }
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:62
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition: nvti.c:219

References nvti_oid().

Here is the call 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 1100 of file nvti.c.

1101 {
1102  if (nvtis)
1103  g_hash_table_destroy (nvtis);
1104 }

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

1129 {
1130  return g_hash_table_lookup (nvtis, oid);
1131 }

◆ nvtis_new()

nvtis_t* nvtis_new ( void  )

Make a collection of NVT Infos.

Returns
An empty collection of NVT Infos.

Definition at line 1088 of file nvti.c.

1089 {
1090  return g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
1092 }
static void free_nvti_for_hash_table(gpointer nvti)
Free an NVT Info, for g_hash_table_destroy.
Definition: nvti.c:1077

References free_nvti_for_hash_table().

Here is the call 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 142 of file nvti.c.

143 {
144  return (np ? np->dflt : NULL);
145 }
gchar * dflt
Default value of the preference.
Definition: nvti.h:42

References nvtpref::dflt.

◆ nvtpref_free()

void nvtpref_free ( nvtpref_t np)

Free memory of a nvtpref structure.

Parameters
npThe structure to be freed.

Definition at line 91 of file nvti.c.

92 {
93  if (!np)
94  return;
95 
96  if (np->name)
97  g_free (np->name);
98  if (np->type)
99  g_free (np->type);
100  if (np->dflt)
101  g_free (np->dflt);
102  g_free (np);
103 }
gchar * name
Name of the preference.
Definition: nvti.h:41
gchar * type
Preference type.
Definition: nvti.h:40
gchar * dflt
Default value of the preference.
Definition: nvti.h:42

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

Referenced by nvti_free().

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

115 {
116  return (np ? np->name : NULL);
117 }
gchar * name
Name of the preference.
Definition: nvti.h:41

References nvtpref::name.

◆ nvtpref_new()

nvtpref_t* nvtpref_new ( gchar *  name,
gchar *  type,
gchar *  dflt 
)

Create a new nvtpref structure filled with the given values.

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

69 {
70  nvtpref_t *np = g_malloc0 (sizeof (nvtpref_t));
71 
72  if (!np)
73  return NULL;
74 
75  if (name)
76  np->name = g_strdup (name);
77  if (type)
78  np->type = g_strdup (type);
79  if (dflt)
80  np->dflt = g_strdup (dflt);
81 
82  return (np);
83 }
gchar * name
Name of the preference.
Definition: nvti.h:41
gchar * type
Preference type.
Definition: nvti.h:40
gchar * dflt
Default value of the preference.
Definition: nvti.h:42
The structure for a preference of a NVT.
Definition: nvti.h:38

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

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

129 {
130  return (np ? np->type : NULL);
131 }
gchar * type
Preference type.
Definition: nvti.h:40

References nvtpref::type.