Greenbone Vulnerability Management Libraries  22.8.0
nvticache.c File Reference

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

#include "nvticache.h"
#include "kb.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
Include dependency graph for nvticache.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "libgvm util"
 GLib logging domain. More...
 

Functions

int nvticache_initialized (void)
 Return whether the nvt cache is initialized. More...
 
int nvticache_init (const char *src, const char *kb_path)
 Initializes the nvti cache. More...
 
kb_t nvticache_get_kb (void)
 Return the nvticache kb. More...
 
int nvticache_check (const gchar *filename)
 Check if the nvt for the given filename exists in cache. More...
 
void nvticache_reset (void)
 Reset connection to KB. To be called after a fork(). More...
 
static char * nvt_feed_version ()
 Determine the version of the NVT feed. More...
 
void nvticache_save (void)
 Save the nvticache to disk. More...
 
int nvticache_add (const nvti_t *nvti, const char *filename)
 Add a NVT Information to the cache. More...
 
char * nvticache_get_src (const char *oid)
 Get the full source filename of an OID. More...
 
char * nvticache_get_oid (const char *filename)
 Get the OID from a plugin filename. More...
 
char * nvticache_get_filename (const char *oid)
 Get the filename from a plugin OID. More...
 
char * nvticache_get_required_keys (const char *oid)
 Get the Required Keys from a plugin OID. More...
 
char * nvticache_get_mandatory_keys (const char *oid)
 Get the Mandatory Keys from a plugin OID. More...
 
char * nvticache_get_excluded_keys (const char *oid)
 Get the Excluded Keys from a plugin OID. More...
 
char * nvticache_get_required_udp_ports (const char *oid)
 Get the Required udp ports from a plugin OID. More...
 
char * nvticache_get_required_ports (const char *oid)
 Get the Required ports from a plugin OID. More...
 
char * nvticache_get_dependencies (const char *oid)
 Get the Dependencies from a plugin OID. More...
 
int nvticache_get_category (const char *oid)
 Get the Category from a plugin OID. More...
 
char * nvticache_get_name (const char *oid)
 Get the name from a plugin OID. More...
 
char * nvticache_get_cves (const char *oid)
 Get the cves from a plugin OID. More...
 
char * nvticache_get_bids (const char *oid)
 Get the bids from a plugin OID. More...
 
char * nvticache_get_xrefs (const char *oid)
 Get the xrefs from a plugin OID. More...
 
char * nvticache_get_family (const char *oid)
 Get the family from a plugin OID. More...
 
char * nvticache_get_tags (const char *oid)
 Get the tags from a plugin OID. More...
 
nvti_tnvticache_get_nvt (const char *oid)
 Get the nvti from a plugin OID. More...
 
GSList * nvticache_get_prefs (const char *oid)
 Get the prefs from a plugin OID. More...
 
GSList * nvticache_get_oids ()
 Get the list of nvti OIDs. More...
 
size_t nvticache_count ()
 Get the number of nvt's in the cache. More...
 
void nvticache_delete (const char *oid)
 Delete NVT from the cache. More...
 
char * nvticache_feed_version (void)
 Get the NVT feed version. More...
 
int nvticache_check_feed (void)
 Check if the plugins feed was newer than cached feed. More...
 

Variables

char * src_path = NULL
 
kb_t cache_kb = NULL
 
int cache_saved = 1
 

Detailed Description

Implementation of API to handle NVT Info Cache.

This file contains all methods to handle NVT Information Cache (nvticache_t).

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

Definition in file nvticache.c.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "libgvm util"

GLib logging domain.

Definition at line 33 of file nvticache.c.

Function Documentation

◆ nvt_feed_version()

static char* nvt_feed_version ( )
static

Determine the version of the NVT feed.

Returns
Feed version string if success, NULL otherwise.

Definition at line 134 of file nvticache.c.

135 {
136  char filename[2048], *fcontent = NULL, *plugin_set;
137  GError *error = NULL;
138  static int msg_shown = 0;
139 
140  g_snprintf (filename, sizeof (filename), "%s/plugin_feed_info.inc", src_path);
141  if (!g_file_get_contents (filename, &fcontent, NULL, &error))
142  {
143  if (error && msg_shown == 0)
144  {
145  g_warning ("nvt_feed_version: %s", error->message);
146  msg_shown = 1;
147  }
148  g_error_free (error);
149  return NULL;
150  }
151  plugin_set = g_strrstr (fcontent, "PLUGIN_SET = ");
152  if (!plugin_set)
153  {
154  g_warning ("nvt_feed_version: Erroneous %s format", filename);
155  g_free (fcontent);
156  return NULL;
157  }
158  msg_shown = 0;
159  plugin_set = g_strndup (plugin_set + 14, 12);
160  if (g_strstr_len (plugin_set, -1, "\"") || g_strstr_len (plugin_set, -1, ";"))
161  {
162  g_warning ("nvt_feed_version: Erroneous %s format. Format of PLUGIN_SET "
163  "has to be yyyymmddhhmm. It has to be exactly 12 chars long.",
164  filename);
165  g_free (plugin_set);
166  g_free (fcontent);
167  return NULL;
168  }
169 
170  g_free (fcontent);
171  return plugin_set;
172 }

References src_path.

Referenced by nvticache_check_feed(), and nvticache_save().

Here is the caller graph for this function:

◆ nvticache_add()

int nvticache_add ( const nvti_t nvti,
const char *  filename 
)

Add a NVT Information to the cache.

Parameters
nvtiThe NVT Information to add
filenameThe name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )
Returns
0 in case of success, anything else indicates an error.

Definition at line 207 of file nvticache.c.

208 {
209  char *oid, *dummy;
210 
211  assert (cache_kb);
212  /* Check for duplicate OID. */
213  oid = nvti_oid (nvti);
214  dummy = nvticache_get_filename (oid);
215  if (dummy && strcmp (filename, dummy))
216  {
217  struct stat src_stat;
218  char *src_file = g_build_filename (src_path, dummy, NULL);
219 
220  /* If .nasl file was duplicated, not moved. */
221  if (src_file && stat (src_file, &src_stat) >= 0)
222  g_warning ("NVT %s with duplicate OID %s will be replaced with %s",
223  src_file, oid, filename);
224  g_free (src_file);
225  }
226  if (dummy)
227  nvticache_delete (oid);
228 
229  g_free (dummy);
230 
231  if (kb_nvt_add (cache_kb, nvti, filename))
232  goto kb_fail;
233  cache_saved = 0;
234 
235  return 0;
236 kb_fail:
237  return -1;
238 }

References cache_kb, cache_saved, kb_nvt_add(), nvti_oid(), nvticache_delete(), nvticache_get_filename(), and src_path.

Here is the call graph for this function:

◆ nvticache_check()

int nvticache_check ( const gchar *  filename)

Check if the nvt for the given filename exists in cache.

Parameters
filenameThe name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )
Returns
1 if nvt is in cache and up to date, 0 otherwise.

Definition at line 101 of file nvticache.c.

102 {
103  assert (cache_kb);
104  char *src_file, *time_s;
105  struct stat src_stat;
106  int ret = 0;
107 
108  src_file = g_build_filename (src_path, filename, NULL);
109  time_s = kb_nvt_get (cache_kb, filename, NVT_TIMESTAMP_POS);
110  if (time_s && src_file && stat (src_file, &src_stat) >= 0
111  && atoi (time_s) > src_stat.st_mtime)
112  ret = 1;
113  g_free (time_s);
114  g_free (src_file);
115  return ret;
116 }

References cache_kb, kb_nvt_get(), NVT_TIMESTAMP_POS, and src_path.

Here is the call graph for this function:

◆ nvticache_check_feed()

int nvticache_check_feed ( void  )

Check if the plugins feed was newer than cached feed.

Returns
1 if new feed, 0 if matching feeds or error.

Definition at line 599 of file nvticache.c.

600 {
601  char *cached, *current;
602  int ret;
603 
604  if (!(current = nvt_feed_version ()))
605  return 0;
607  ret = strcmp (cached, current);
608  g_free (cached);
609  g_free (current);
610  return ret;
611 }

References cache_kb, kb_item_get_str(), nvt_feed_version(), and NVTICACHE_STR.

Here is the call graph for this function:

◆ nvticache_count()

size_t nvticache_count ( void  )

Get the number of nvt's in the cache.

Returns
Number of nvt's.

Definition at line 547 of file nvticache.c.

548 {
549  assert (cache_kb);
550 
551  return kb_item_count (cache_kb, "nvt:*");
552 }

References cache_kb, and kb_item_count().

Here is the call graph for this function:

◆ nvticache_delete()

void nvticache_delete ( const char *  oid)

Delete NVT from the cache.

Parameters
[in]oidOID to match.

Definition at line 560 of file nvticache.c.

561 {
562  char pattern[4096];
563  char *filename;
564 
565  assert (cache_kb);
566  assert (oid);
567 
568  filename = nvticache_get_filename (oid);
569  g_snprintf (pattern, sizeof (pattern), "oid:%s:prefs", oid);
570  kb_del_items (cache_kb, pattern);
571  g_snprintf (pattern, sizeof (pattern), "nvt:%s", oid);
572  kb_del_items (cache_kb, pattern);
573 
574  if (filename)
575  {
576  g_snprintf (pattern, sizeof (pattern), "filename:%s", filename);
577  kb_del_items (cache_kb, pattern);
578  }
579  g_free (filename);
580 }

References cache_kb, kb_del_items(), and nvticache_get_filename().

Referenced by nvticache_add().

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

◆ nvticache_feed_version()

char* nvticache_feed_version ( void  )

Get the NVT feed version.

Returns
Feed version.

Definition at line 588 of file nvticache.c.

589 {
591 }

References cache_kb, kb_item_get_str(), and NVTICACHE_STR.

Referenced by nvticache_save().

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

◆ nvticache_get_bids()

char* nvticache_get_bids ( const char *  oid)

Get the bids from a plugin OID.

Parameters
[in]oidOID to match.
Returns
BIDs matching OID, NULL otherwise.

Definition at line 431 of file nvticache.c.

432 {
433  assert (cache_kb);
434  return kb_nvt_get (cache_kb, oid, NVT_BIDS_POS);
435 }

References cache_kb, kb_nvt_get(), and NVT_BIDS_POS.

Here is the call graph for this function:

◆ nvticache_get_category()

int nvticache_get_category ( const char *  oid)

Get the Category from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Category matching OID, -1 otherwise.

Definition at line 383 of file nvticache.c.

384 {
385  int category;
386  char *category_s;
387 
388  assert (cache_kb);
389  category_s = kb_nvt_get (cache_kb, oid, NVT_CATEGORY_POS);
390  category = atoi (category_s);
391  g_free (category_s);
392  return category;
393 }

References cache_kb, kb_nvt_get(), and NVT_CATEGORY_POS.

Here is the call graph for this function:

◆ nvticache_get_cves()

char* nvticache_get_cves ( const char *  oid)

Get the cves from a plugin OID.

Parameters
[in]oidOID to match.
Returns
CVEs matching OID, NULL otherwise.

Definition at line 417 of file nvticache.c.

418 {
419  assert (cache_kb);
420  return kb_nvt_get (cache_kb, oid, NVT_CVES_POS);
421 }

References cache_kb, kb_nvt_get(), and NVT_CVES_POS.

Here is the call graph for this function:

◆ nvticache_get_dependencies()

char* nvticache_get_dependencies ( const char *  oid)

Get the Dependencies from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Dependencies matching OID, NULL otherwise.

Definition at line 369 of file nvticache.c.

370 {
371  assert (cache_kb);
373 }

References cache_kb, kb_nvt_get(), and NVT_DEPENDENCIES_POS.

Here is the call graph for this function:

◆ nvticache_get_excluded_keys()

char* nvticache_get_excluded_keys ( const char *  oid)

Get the Excluded Keys from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Excluded Keys matching OID, NULL otherwise.

Definition at line 327 of file nvticache.c.

328 {
329  assert (cache_kb);
331 }

References cache_kb, kb_nvt_get(), and NVT_EXCLUDED_KEYS_POS.

Here is the call graph for this function:

◆ nvticache_get_family()

char* nvticache_get_family ( const char *  oid)

Get the family from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Family matching OID, NULL otherwise.

Definition at line 459 of file nvticache.c.

460 {
461  assert (cache_kb);
462  return kb_nvt_get (cache_kb, oid, NVT_FAMILY_POS);
463 }

References cache_kb, kb_nvt_get(), and NVT_FAMILY_POS.

Here is the call graph for this function:

◆ nvticache_get_filename()

char* nvticache_get_filename ( const char *  oid)

Get the filename from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Filanem matching OID, NULL otherwise.

Definition at line 285 of file nvticache.c.

286 {
287  assert (cache_kb);
288  return kb_nvt_get (cache_kb, oid, NVT_FILENAME_POS);
289 }

References cache_kb, kb_nvt_get(), and NVT_FILENAME_POS.

Referenced by nvticache_add(), and nvticache_delete().

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

◆ nvticache_get_kb()

kb_t nvticache_get_kb ( void  )

Return the nvticache kb.

Returns
Cache kb.

Definition at line 84 of file nvticache.c.

85 {
86  assert (cache_kb);
87  return cache_kb;
88 }

References cache_kb.

◆ nvticache_get_mandatory_keys()

char* nvticache_get_mandatory_keys ( const char *  oid)

Get the Mandatory Keys from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Mandatory Keys matching OID, NULL otherwise.

Definition at line 313 of file nvticache.c.

314 {
315  assert (cache_kb);
317 }

References cache_kb, kb_nvt_get(), and NVT_MANDATORY_KEYS_POS.

Here is the call graph for this function:

◆ nvticache_get_name()

char* nvticache_get_name ( const char *  oid)

Get the name from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Name matching OID, NULL otherwise.

Definition at line 403 of file nvticache.c.

404 {
405  assert (cache_kb);
406  return kb_nvt_get (cache_kb, oid, NVT_NAME_POS);
407 }

References cache_kb, kb_nvt_get(), and NVT_NAME_POS.

Here is the call graph for this function:

◆ nvticache_get_nvt()

nvti_t* nvticache_get_nvt ( const char *  oid)

Get the nvti from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Full nvti matching OID, NULL otherwise.

Definition at line 487 of file nvticache.c.

488 {
489  assert (cache_kb);
490  return kb_nvt_get_all (cache_kb, oid);
491 }

References cache_kb, and kb_nvt_get_all().

Here is the call graph for this function:

◆ nvticache_get_oid()

char* nvticache_get_oid ( const char *  filename)

Get the OID from a plugin filename.

Parameters
filenameFilename to lookup.
Returns
OID matching filename if found, NULL otherwise.

Definition at line 270 of file nvticache.c.

271 {
272  assert (cache_kb);
273 
274  return kb_nvt_get (cache_kb, filename, NVT_OID_POS);
275 }

References cache_kb, kb_nvt_get(), and NVT_OID_POS.

Here is the call graph for this function:

◆ nvticache_get_oids()

GSList* nvticache_get_oids ( void  )

Get the list of nvti OIDs.

Returns
OIDs list.

Definition at line 534 of file nvticache.c.

535 {
536  assert (cache_kb);
537 
538  return kb_nvt_get_oids (cache_kb);
539 }

References cache_kb, and kb_nvt_get_oids().

Here is the call graph for this function:

◆ nvticache_get_prefs()

GSList* nvticache_get_prefs ( const char *  oid)

Get the prefs from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Prefs matching OID, NULL otherwise.

Definition at line 501 of file nvticache.c.

502 {
503  char pattern[4096];
504  struct kb_item *prefs, *element;
505  GSList *list = NULL;
506 
507  assert (cache_kb);
508 
509  g_snprintf (pattern, sizeof (pattern), "oid:%s:prefs", oid);
510  prefs = element = kb_item_get_all (cache_kb, pattern);
511  while (element)
512  {
513  nvtpref_t *np;
514  char **array = g_strsplit (element->v_str, "|||", -1);
515 
516  assert (array[3]);
517  assert (!array[4]);
518  np = nvtpref_new (atoi (array[0]), array[1], array[2], array[3]);
519  g_strfreev (array);
520  list = g_slist_append (list, np);
521  element = element->next;
522  }
523  kb_item_free (prefs);
524 
525  return list;
526 }

References cache_kb, kb_item_free(), kb_item_get_all(), kb_item::next, nvtpref_new(), and kb_item::v_str.

Here is the call graph for this function:

◆ nvticache_get_required_keys()

char* nvticache_get_required_keys ( const char *  oid)

Get the Required Keys from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Required Keys matching OID, NULL otherwise.

Definition at line 299 of file nvticache.c.

300 {
301  assert (cache_kb);
303 }

References cache_kb, kb_nvt_get(), and NVT_REQUIRED_KEYS_POS.

Here is the call graph for this function:

◆ nvticache_get_required_ports()

char* nvticache_get_required_ports ( const char *  oid)

Get the Required ports from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Required ports matching OID, NULL otherwise.

Definition at line 355 of file nvticache.c.

356 {
357  assert (cache_kb);
359 }

References cache_kb, kb_nvt_get(), and NVT_REQUIRED_PORTS_POS.

Here is the call graph for this function:

◆ nvticache_get_required_udp_ports()

char* nvticache_get_required_udp_ports ( const char *  oid)

Get the Required udp ports from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Required udp ports matching OID, NULL otherwise.

Definition at line 341 of file nvticache.c.

342 {
343  assert (cache_kb);
345 }

References cache_kb, kb_nvt_get(), and NVT_REQUIRED_UDP_PORTS_POS.

Here is the call graph for this function:

◆ nvticache_get_src()

char* nvticache_get_src ( const char *  oid)

Get the full source filename of an OID.

Parameters
oidThe OID to look up.
Returns
Filename with full path matching OID if found, NULL otherwise.

Definition at line 248 of file nvticache.c.

249 {
250  char *filename, *src;
251 
252  assert (cache_kb);
253 
254  filename = kb_nvt_get (cache_kb, oid, NVT_FILENAME_POS);
255  if (!filename)
256  return NULL;
257  src = g_build_filename (src_path, filename, NULL);
258  g_free (filename);
259  return src;
260 }

References cache_kb, kb_nvt_get(), NVT_FILENAME_POS, and src_path.

Here is the call graph for this function:

◆ nvticache_get_tags()

char* nvticache_get_tags ( const char *  oid)

Get the tags from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Tags matching OID, NULL otherwise.

Definition at line 473 of file nvticache.c.

474 {
475  assert (cache_kb);
476  return kb_nvt_get (cache_kb, oid, NVT_TAGS_POS);
477 }

References cache_kb, kb_nvt_get(), and NVT_TAGS_POS.

Here is the call graph for this function:

◆ nvticache_get_xrefs()

char* nvticache_get_xrefs ( const char *  oid)

Get the xrefs from a plugin OID.

Parameters
[in]oidOID to match.
Returns
XREFs matching OID, NULL otherwise.

Definition at line 445 of file nvticache.c.

446 {
447  assert (cache_kb);
448  return kb_nvt_get (cache_kb, oid, NVT_XREFS_POS);
449 }

References cache_kb, kb_nvt_get(), and NVT_XREFS_POS.

Here is the call graph for this function:

◆ nvticache_init()

int nvticache_init ( const char *  src,
const char *  kb_path 
)

Initializes the nvti cache.

Parameters
srcThe directory that contains the nvt files.
kb_pathPath to kb socket.
Returns
0 in case of success, anything else indicates an error.

Definition at line 59 of file nvticache.c.

60 {
61  assert (src);
62 
63  if (src_path)
64  g_free (src_path);
65  src_path = g_strdup (src);
66  if (cache_kb)
68  cache_kb = kb_find (kb_path, NVTICACHE_STR);
69  if (cache_kb)
70  return 0;
71 
72  if (kb_new (&cache_kb, kb_path)
74  return -1;
75  return 0;
76 }

References cache_kb, kb_find(), kb_item_set_str(), kb_lnk_reset(), kb_new(), NVTICACHE_STR, and src_path.

Here is the call graph for this function:

◆ nvticache_initialized()

int nvticache_initialized ( void  )

Return whether the nvt cache is initialized.

Returns
1 if cache is initialized, 0 otherwise.

Definition at line 45 of file nvticache.c.

46 {
47  return !!cache_kb;
48 }

References cache_kb.

◆ nvticache_reset()

void nvticache_reset ( void  )

Reset connection to KB. To be called after a fork().

Definition at line 122 of file nvticache.c.

123 {
124  if (cache_kb)
126 }

References cache_kb, and kb_lnk_reset().

Here is the call graph for this function:

◆ nvticache_save()

void nvticache_save ( void  )

Save the nvticache to disk.

Definition at line 178 of file nvticache.c.

179 {
180  char *feed_version, *old_version;
181 
182  old_version = nvticache_feed_version ();
183  feed_version = nvt_feed_version ();
184  if (feed_version && g_strcmp0 (old_version, feed_version))
185  {
186  kb_item_set_str (cache_kb, NVTICACHE_STR, feed_version, 0);
187  g_message ("Updated NVT cache from version %s to %s", old_version,
188  feed_version);
189  }
190  g_free (old_version);
191  g_free (feed_version);
192 }

References cache_kb, kb_item_set_str(), nvt_feed_version(), nvticache_feed_version(), and NVTICACHE_STR.

Here is the call graph for this function:

Variable Documentation

◆ cache_kb

◆ cache_saved

int cache_saved = 1

If cache was saved.

Definition at line 37 of file nvticache.c.

Referenced by nvticache_add().

◆ src_path

char* src_path = NULL

The directory of the source files.

Definition at line 35 of file nvticache.c.

Referenced by nvt_feed_version(), nvticache_add(), nvticache_check(), nvticache_get_src(), and nvticache_init().

NVT_EXCLUDED_KEYS_POS
@ NVT_EXCLUDED_KEYS_POS
Definition: kb.h:49
NVT_BIDS_POS
@ NVT_BIDS_POS
Definition: kb.h:55
nvticache_feed_version
char * nvticache_feed_version(void)
Get the NVT feed version.
Definition: nvticache.c:588
kb_find
static kb_t kb_find(const char *kb_path, const char *key)
Find an existing Knowledge Base object with key.
Definition: kb.h:280
kb_item_get_str
static char * kb_item_get_str(kb_t kb, const char *name)
Get a single KB string item.
Definition: kb.h:334
nvticache_delete
void nvticache_delete(const char *oid)
Delete NVT from the cache.
Definition: nvticache.c:560
NVT_NAME_POS
@ NVT_NAME_POS
Definition: kb.h:59
kb_lnk_reset
static int kb_lnk_reset(kb_t kb)
Reset connection to the KB. This is called after each fork() to make.
Definition: kb.h:747
nvti_oid
gchar * nvti_oid(const nvti_t *n)
Get the OID string.
Definition: nvti.c:649
nvt_feed_version
static char * nvt_feed_version()
Determine the version of the NVT feed.
Definition: nvticache.c:134
kb_nvt_get_all
static nvti_t * kb_nvt_get_all(kb_t kb, const char *oid)
Get a full NVT.
Definition: kb.h:673
NVT_FILENAME_POS
@ NVT_FILENAME_POS
Definition: kb.h:46
kb_nvt_get_oids
static GSList * kb_nvt_get_oids(kb_t kb)
Get list of NVT OIDs.
Definition: kb.h:690
kb_item
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
Definition: kb.h:69
nvti
The structure of a information record that corresponds to a NVT.
Definition: nvti.c:394
NVT_REQUIRED_UDP_PORTS_POS
@ NVT_REQUIRED_UDP_PORTS_POS
Definition: kb.h:50
kb_item_set_str
static int kb_item_set_str(kb_t kb, const char *name, const char *str, size_t len)
Set (replace) a new entry under a given name.
Definition: kb.h:538
NVT_TIMESTAMP_POS
@ NVT_TIMESTAMP_POS
Definition: kb.h:60
kb_item::v_str
char * v_str
Definition: kb.h:74
NVT_OID_POS
@ NVT_OID_POS
Definition: kb.h:61
NVT_XREFS_POS
@ NVT_XREFS_POS
Definition: kb.h:56
kb_item_free
void kb_item_free(struct kb_item *item)
Release a KB item (or a list).
Definition: kb.c:639
nvticache_get_filename
char * nvticache_get_filename(const char *oid)
Get the filename from a plugin OID.
Definition: nvticache.c:285
cache_kb
kb_t cache_kb
Definition: nvticache.c:36
nvtpref
The structure for a preference of a NVT.
Definition: nvti.c:477
NVT_CATEGORY_POS
@ NVT_CATEGORY_POS
Definition: kb.h:57
NVT_DEPENDENCIES_POS
@ NVT_DEPENDENCIES_POS
Definition: kb.h:52
kb_item::next
struct kb_item * next
Definition: kb.h:79
src_path
char * src_path
Definition: nvticache.c:35
NVT_FAMILY_POS
@ NVT_FAMILY_POS
Definition: kb.h:58
NVTICACHE_STR
#define NVTICACHE_STR
Definition: nvticache.h:22
kb_del_items
static int kb_del_items(kb_t kb, const char *name)
Delete all entries under a given name.
Definition: kb.h:708
kb_item_get_all
static struct kb_item * kb_item_get_all(kb_t kb, const char *name)
Get all items stored under a given name.
Definition: kb.h:371
NVT_CVES_POS
@ NVT_CVES_POS
Definition: kb.h:54
NVT_MANDATORY_KEYS_POS
@ NVT_MANDATORY_KEYS_POS
Definition: kb.h:48
cache_saved
int cache_saved
Definition: nvticache.c:37
kb_nvt_add
static int kb_nvt_add(kb_t kb, const nvti_t *nvt, const char *filename)
Insert a new nvt.
Definition: kb.h:636
kb_item_count
static size_t kb_item_count(kb_t kb, const char *pattern)
Count all items stored under a given pattern.
Definition: kb.h:448
NVT_REQUIRED_KEYS_POS
@ NVT_REQUIRED_KEYS_POS
Definition: kb.h:47
kb_new
static int kb_new(kb_t *kb, const char *kb_path)
Initialize a new Knowledge Base object.
Definition: kb.h:243
NVT_TAGS_POS
@ NVT_TAGS_POS
Definition: kb.h:53
kb_nvt_get
static char * kb_nvt_get(kb_t kb, const char *oid, enum kb_nvt_pos position)
Get field of a NVT.
Definition: kb.h:655
NVT_REQUIRED_PORTS_POS
@ NVT_REQUIRED_PORTS_POS
Definition: kb.h:51
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.
Definition: nvti.c:500