OpenVAS Libraries  9.0.3
nvti.c File Reference

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

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <utime.h>
#include "nvti.h"
Include dependency graph for nvti.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "lib nvti"
 

Functions

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

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

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib nvti"

Definition at line 47 of file nvti.c.

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

930 {
931  gchar * old;
932 
933  if (! n) return (1);
934  if (! bid_id) return (2);
935 
936  old = n->bid;
937 
938  if (old)
939  {
940  n->bid = g_strdup_printf ("%s, %s", old, bid_id);
941  g_free (old);
942  }
943  else
944  n->bid = g_strdup (bid_id);
945 
946  return (0);
947 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:72

References nvti::bid.

Referenced by script_bugtraq_id().

Here is the caller graph for this function:

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

900 {
901  gchar * old;
902 
903  if (! n) return (1);
904  if (! cve_id) return (2);
905 
906  old = n->cve;
907 
908  if (old)
909  {
910  n->cve = g_strdup_printf ("%s, %s", old, cve_id);
911  g_free (old);
912  }
913  else
914  n->cve = g_strdup (cve_id);
915 
916  return (0);
917 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:71

References nvti::cve.

Referenced by script_cve_id().

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

1020 {
1021  gchar * old;
1022 
1023  if (! n) return (1);
1024  if (! key) return (2);
1025 
1026  old = n->excluded_keys;
1027 
1028  if (old)
1029  {
1030  n->excluded_keys = g_strdup_printf ("%s, %s", old, key);
1031  g_free (old);
1032  }
1033  else
1034  n->excluded_keys = g_strdup (key);
1035 
1036  return (0);
1037 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:82

References nvti::excluded_keys.

Referenced by script_exclude_keys().

Here is the caller graph for this function:

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

990 {
991  gchar * old;
992 
993  if (! n) return (1);
994  if (! key) return (2);
995 
996  old = n->mandatory_keys;
997 
998  if (old)
999  {
1000  n->mandatory_keys = g_strdup_printf ("%s, %s", old, key);
1001  g_free (old);
1002  }
1003  else
1004  n->mandatory_keys = g_strdup (key);
1005 
1006  return (0);
1007 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:81

References nvti::mandatory_keys.

Referenced by script_mandatory_keys().

Here is the caller graph for this function:

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

1110 {
1111  if (! n)
1112  return (-1);
1113 
1114  n->prefs = g_slist_append (n->prefs, np);
1115  return (0);
1116 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:86

References nvti::prefs.

Referenced by add_plugin_preference().

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

960 {
961  gchar * old;
962 
963  if (! n) return (1);
964  if (! key) return (2);
965 
966  old = n->required_keys;
967 
968  if (old)
969  {
970  n->required_keys = g_strdup_printf ("%s, %s", old, key);
971  g_free (old);
972  }
973  else
974  n->required_keys = g_strdup (key);
975 
976  return (0);
977 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:80

References nvti::required_keys.

Referenced by script_require_keys().

Here is the caller graph for this function:

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

1050 {
1051  gchar * old;
1052 
1053  if (! n) return (1);
1054  if (! port) return (2);
1055 
1056  old = n->required_ports;
1057 
1058  if (old)
1059  {
1060  n->required_ports = g_strdup_printf ("%s, %s", old, port);
1061  g_free (old);
1062  }
1063  else
1064  n->required_ports = g_strdup (port);
1065 
1066  return (0);
1067 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:83

References nvti::required_ports.

Referenced by script_require_ports().

Here is the caller graph for this function:

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

1080 {
1081  gchar * old;
1082 
1083  if (! n) return (1);
1084  if (! port) return (2);
1085 
1086  old = n->required_udp_ports;
1087 
1088  if (old)
1089  {
1090  n->required_udp_ports = g_strdup_printf ("%s, %s", old, port);
1091  g_free (old);
1092  }
1093  else
1094  n->required_udp_ports = g_strdup (port);
1095 
1096  return (0);
1097 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:84

References nvti::required_udp_ports.

Referenced by script_require_udp_ports().

Here is the caller graph for this function:

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

289 {
290  return (n ? n->bid : NULL);
291 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:72

References nvti::bid.

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

484 {
485  return (n ? n->category : -1);
486 }
gint category
The category, this NVT belongs to.
Definition: nvti.h:90

References nvti::category.

◆ nvti_copyright()

gchar* nvti_copyright ( const nvti_t n)

Get the copyright notice.

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

Definition at line 260 of file nvti.c.

261 {
262  return (n ? n->copyright : NULL);
263 }
gchar * copyright
Copyright for the NVT.
Definition: nvti.h:69

References nvti::copyright.

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

275 {
276  return (n ? n->cve : NULL);
277 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:71

References nvti::cve.

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

331 {
332  return (n ? n->cvss_base : NULL);
333 }
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:77

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

345 {
346  return (n ? n->dependencies : NULL);
347 }
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:79

References nvti::dependencies.

Referenced by plug_set_dep().

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

387 {
388  return (n ? n->excluded_keys : NULL);
389 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:82

References nvti::excluded_keys.

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

429 {
430  return (n ? n->family : NULL);
431 }
gchar * family
Family the NVT belongs to.
Definition: nvti.h:91

References nvti::family.

◆ nvti_free()

void nvti_free ( nvti_t n)

Free memory of a nvti structure.

Parameters
nThe structure to be freed.

Definition at line 162 of file nvti.c.

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

References nvti::bid, nvti::copyright, 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, nvti::version, and nvti::xref.

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

373 {
374  return (n ? n->mandatory_keys : NULL);
375 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:81

References nvti::mandatory_keys.

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

247 {
248  return (n ? n->name : NULL);
249 }
gchar * name
The name.
Definition: nvti.h:68

References nvti::name.

◆ 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 initalized with 0's.

Definition at line 151 of file nvti.c.

152 {
153  return ((nvti_t *) g_malloc0 (sizeof (nvti_t)));
154 }
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:64

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

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

References nvti::oid.

Referenced by nvticache_add(), and nvtis_add().

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

457 {
458  return (n ? g_slist_nth_data (n->prefs, p) : NULL);
459 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:86

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

442 {
443  return (n ? g_slist_length (n->prefs) : 0);
444 }
GSList * prefs
Collection of NVT preferences.
Definition: nvti.h:86

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

359 {
360  return (n ? n->required_keys : NULL);
361 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:80

References nvti::required_keys.

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

401 {
402  return (n ? n->required_ports : NULL);
403 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:83

References nvti::required_ports.

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

415 {
416  return (n ? n->required_udp_ports : NULL);
417 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:84

References nvti::required_udp_ports.

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

604 {
605  if (! n)
606  return (-1);
607 
608  if (n->bid)
609  g_free (n->bid);
610  n->bid = g_strdup (bid);
611  return (0);
612 }
gchar * bid
List of Bugtraq IDs, this NVT corresponds to.
Definition: nvti.h:72

References nvti::bid.

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

881 {
882  if (! n)
883  return (-1);
884 
885  n->category = category;
886  return (0);
887 }
gint category
The category, this NVT belongs to.
Definition: nvti.h:90

References nvti::category.

Referenced by script_category().

Here is the caller graph for this function:

◆ nvti_set_copyright()

int nvti_set_copyright ( nvti_t n,
const gchar *  copyright 
)

Set the copyright of a NVT.

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

Definition at line 561 of file nvti.c.

562 {
563  if (! n)
564  return (-1);
565 
566  if (n->copyright)
567  g_free (n->copyright);
568  n->copyright = g_strdup (copyright);
569  return (0);
570 }
gchar * copyright
Copyright for the NVT.
Definition: nvti.h:69

References nvti::copyright.

Referenced by script_copyright().

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

583 {
584  if (! n)
585  return (-1);
586 
587  if (n->cve)
588  g_free (n->cve);
589  n->cve = g_strdup (cve);
590  return (0);
591 }
gchar * cve
List of CVEs, this NVT corresponds to.
Definition: nvti.h:71

References nvti::cve.

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

673 {
674  if (! n)
675  return (-1);
676 
677  if (n->cvss_base)
678  g_free (n->cvss_base);
679  if (cvss_base && cvss_base[0])
680  n->cvss_base = g_strdup (cvss_base);
681  else
682  n->cvss_base = NULL;
683  return (0);
684 }
gchar * cvss_base
CVSS base score for this NVT.
Definition: nvti.h:77

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

697 {
698  if (! n)
699  return (-1);
700 
701  if (n->dependencies)
702  g_free (n->dependencies);
703  if (dependencies && dependencies[0])
704  n->dependencies = g_strdup (dependencies);
705  else
706  n->dependencies = NULL;
707  return (0);
708 }
gchar * dependencies
List of dependencies of this NVT.
Definition: nvti.h:79

References nvti::dependencies.

Referenced by plug_set_dep().

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

769 {
770  if (! n)
771  return (-1);
772 
773  if (n->excluded_keys)
774  g_free (n->excluded_keys);
775  if (excluded_keys && excluded_keys[0])
776  n->excluded_keys = g_strdup (excluded_keys);
777  else
778  n->excluded_keys = NULL;
779  return (0);
780 }
gchar * excluded_keys
List of excluded KB keys of this NVT.
Definition: nvti.h:82

References nvti::excluded_keys.

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

841 {
842  if (! n)
843  return (-1);
844 
845  if (n->family)
846  g_free (n->family);
847  n->family = g_strdup (family);
848  return (0);
849 }
gchar * family
Family the NVT belongs to.
Definition: nvti.h:91

References nvti::family.

Referenced by script_family().

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

745 {
746  if (! n)
747  return (-1);
748 
749  if (n->mandatory_keys)
750  g_free (n->mandatory_keys);
751  if (mandatory_keys && mandatory_keys[0])
752  n->mandatory_keys = g_strdup (mandatory_keys);
753  else
754  n->mandatory_keys = NULL;
755  return (0);
756 }
gchar * mandatory_keys
List of mandatory KB keys of this NVT.
Definition: nvti.h:81

References nvti::mandatory_keys.

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

541 {
542  if (! n)
543  return (-1);
544 
545  if (n->name)
546  g_free (n->name);
547  n->name = g_strdup (name);
548  return (0);
549 }
gchar * name
The name.
Definition: nvti.h:68
const char * name
Definition: nasl_init.c:524

References nvti::name, and name.

Referenced by script_name().

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

499 {
500  if (! n)
501  return (-1);
502 
503  if (n->oid)
504  g_free (n->oid);
505  n->oid = g_strdup (oid);
506  return (0);
507 }
const char * oid
gchar * oid
Object ID.
Definition: nvti.h:66

References oid, and nvti::oid.

Referenced by script_id(), and script_oid().

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

721 {
722  if (! n)
723  return (-1);
724 
725  if (n->required_keys)
726  g_free (n->required_keys);
727  if (required_keys && required_keys[0])
728  n->required_keys = g_strdup (required_keys);
729  else
730  n->required_keys = NULL;
731  return (0);
732 }
gchar * required_keys
List of required KB keys of this NVT.
Definition: nvti.h:80

References nvti::required_keys.

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

793 {
794  if (! n)
795  return (-1);
796 
797  if (n->required_ports)
798  g_free (n->required_ports);
799  if (required_ports && required_ports[0])
800  n->required_ports = g_strdup (required_ports);
801  else
802  n->required_ports = NULL;
803  return (0);
804 }
gchar * required_ports
List of required ports of this NVT.
Definition: nvti.h:83

References nvti::required_ports.

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

817 {
818  if (! n)
819  return (-1);
820 
821  if (n->required_udp_ports)
822  g_free (n->required_udp_ports);
823  if (required_udp_ports && required_udp_ports[0])
824  n->required_udp_ports = g_strdup (required_udp_ports);
825  else
826  n->required_udp_ports = NULL;
827  return (0);
828 }
gchar * required_udp_ports
List of required UDP ports of this NVT.
Definition: nvti.h:84

References nvti::required_udp_ports.

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

649 {
650  if (! n)
651  return (-1);
652 
653  if (n->tag)
654  g_free (n->tag);
655  if (tag && tag[0])
656  n->tag = g_strdup (tag);
657  else
658  n->tag = NULL;
659  return (0);
660 }
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:76

References nvti::tag.

Referenced by plug_set_tag().

Here is the caller graph for this function:

◆ nvti_set_timeout()

int nvti_set_timeout ( nvti_t n,
const gint  timeout 
)

Set the timout 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 861 of file nvti.c.

862 {
863  if (! n)
864  return (-1);
865 
866  n->timeout = timeout;
867  return (0);
868 }
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:89

References nvti::timeout.

Referenced by script_timeout().

Here is the caller graph for this function:

◆ nvti_set_version()

int nvti_set_version ( nvti_t n,
const gchar *  version 
)

Set the version of a NVT.

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

Definition at line 519 of file nvti.c.

520 {
521  if (! n)
522  return (-1);
523 
524  if (n->version)
525  g_free (n->version);
526  n->version = g_strdup (version);
527  return (0);
528 }
gchar * version
Version of the NVT.
Definition: nvti.h:67

References nvti::version.

Referenced by script_version().

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

625 {
626  if (! n)
627  return (-1);
628 
629  if (n->xref)
630  g_free (n->xref);
631  if (xref && xref[0])
632  n->xref = g_strdup (xref);
633  else
634  n->xref = NULL;
635  return (0);
636 }
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:74

References nvti::xref.

Referenced by plug_set_xref().

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

317 {
318  return (n ? n->tag : NULL);
319 }
gchar * tag
List of tags attached to this NVT.
Definition: nvti.h:76

References nvti::tag.

Referenced by plug_set_tag().

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

471 {
472  return (n ? n->timeout : -1);
473 }
gint timeout
Default timeout time for this NVT.
Definition: nvti.h:89

References nvti::timeout.

◆ nvti_version()

gchar* nvti_version ( const nvti_t n)

Get the version.

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

Definition at line 232 of file nvti.c.

233 {
234  return (n ? n->version : NULL);
235 }
gchar * version
Version of the NVT.
Definition: nvti.h:67

References nvti::version.

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

303 {
304  return (n ? n->xref : NULL);
305 }
gchar * xref
List of Cross-references, this NVT corresponds to.
Definition: nvti.h:74

References nvti::xref.

Referenced by plug_set_xref().

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

1161 {
1162  if (nvti)
1163  g_hash_table_insert (nvtis, (gpointer) nvti_oid (nvti), (gpointer) nvti);
1164 }
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:64
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition: nvti.c:218

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

1148 {
1149  if (nvtis)
1150  g_hash_table_destroy (nvtis);
1151 }

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

1176 {
1177  return g_hash_table_lookup (nvtis, oid);
1178 }
const char * oid

References oid.

◆ nvtis_new()

nvtis_t* nvtis_new ( void  )

Make a collection of NVT Infos.

Definition at line 1135 of file nvti.c.

1136 {
1137  return g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
1138  free_nvti_for_hash_table);
1139 }

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

138 {
139  return (np ? np->dflt : NULL);
140 }
gchar * dflt
Default value of the preference.
Definition: nvti.h:49

References nvtpref::dflt.

Referenced by get_plugin_preference().

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

87 {
88  if (!np)
89  return;
90 
91  if (np->name)
92  g_free (np->name);
93  if (np->type)
94  g_free (np->type);
95  if (np->dflt)
96  g_free (np->dflt);
97  g_free (np);
98 }
gchar * name
Name of the preference.
Definition: nvti.h:48
gchar * type
Preference type.
Definition: nvti.h:47
gchar * dflt
Default value of the preference.
Definition: nvti.h:49

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

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

110 {
111  return (np ? np->name : NULL);
112 }
gchar * name
Name of the preference.
Definition: nvti.h:48

References nvtpref::name.

Referenced by get_plugin_preference().

Here is the caller graph for this function:

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

64 {
65  nvtpref_t *np = g_malloc0 (sizeof (nvtpref_t));
66 
67  if (!np)
68  return NULL;
69 
70  if (name)
71  np->name = g_strdup (name);
72  if (type)
73  np->type = g_strdup (type);
74  if (dflt)
75  np->dflt = g_strdup (dflt);
76 
77  return (np);
78 }
gchar * name
Name of the preference.
Definition: nvti.h:48
enum kb_item_type type
Definition: kb.h:83
gchar * type
Preference type.
Definition: nvti.h:47
const char * name
Definition: nasl_init.c:524
gchar * dflt
Default value of the preference.
Definition: nvti.h:49
The structure for a preference of a NVT.
Definition: nvti.h:45

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

Referenced by add_plugin_preference().

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

124 {
125  return (np ? np->type : NULL);
126 }
gchar * type
Preference type.
Definition: nvti.h:47

References nvtpref::type.