kb.c File Reference

Knowledge base management API - Redis backend. More...

`#include "kb.h"`
`#include <errno.h>`
`#include <glib.h>`
`#include <hiredis/hiredis.h>`
`#include <stdbool.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`

Go to the source code of this file.

## Data Structures

struct | kb_redis
| Subclass of struct kb, it contains the redis-specific fields, such as the redis context, current DB (namespace) id and the server socket path. More...

## Macros

#define | _GNU_SOURCE
#define | G_LOG_DOMAIN "libgvm util"
| GLib logging domain.
#define | memdup g_memdup
#define | GLOBAL_DBINDEX_NAME "GVM.__GlobalDBIndex"
| Name of the namespace usage bitmap in redis.
#define | redis_kb(__kb)

## Functions

static int | redis_delete_all (struct kb_redis *kbr)
| Delete all the KB's content.
static int | redis_lnk_reset (kb_t kb)
| Reset connection to the KB. This is called after each fork() to make sure connections aren't shared between concurrent processes.
static int | redis_flush_all (kb_t kb, const char *except)
| Flush all the KB's content. Delete all namespaces.
static redisReply * | redis_cmd (struct kb_redis *kbr, const char *fmt,...)
| Execute a redis command and get a redis reply.
static int | try_database_index (struct kb_redis *kbr, int index)
| Attempt to atomically acquire ownership of a database.
static int | fetch_max_db_index (struct kb_redis *kbr)
| Set the number of databases have been configured into kbr struct.
static int | select_database (struct kb_redis *kbr)
| Select DB.
static int | redis_release_db (struct kb_redis *kbr)
| Release DB.
static char * | parse_port_of_addr (const char *addr, int tcp_indicator_len)
static redisContext * | connect_redis (const char *addr, int len)
static int | get_redis_ctx (struct kb_redis *kbr)
| Get redis context if it is already connected or do a a connection.
static int | redis_test_connection (struct kb_redis *kbr)
| Test redis connection.
static int | redis_delete (kb_t kb)
| Delete all entries and release ownership on the namespace.
static int | redis_get_kb_index (kb_t kb)
| Return the kb index.
static int | redis_memory_purge (kb_t kb)
| Attempt to purge dirty pages.
static int | redis_new (kb_t *kb, const char *kb_path)
| Initialize a new Knowledge Base object.
static kb_t | redis_direct_conn (const char *kb_path, const int kb_index)
| Connect to a Knowledge Base object with the given kb_index.
static kb_t | redis_find (const char *kb_path, const char *key)
| Find an existing Knowledge Base object with key.
void | kb_item_free (struct kb_item *item)
| Release a KB item (or a list).
static struct kb_item * | redis2kbitem_single (const char *name, const redisReply *elt, int force_int)
| Give a single KB item.
static struct kb_item * | redis2kbitem (const char *name, const redisReply *rep)
| Fetch a KB item or list from a redis Reply.
static struct kb_item * | redis_get_single (kb_t kb, const char *name, enum kb_item_type type)
| Get a single KB element.
static char * | redis_get_str (kb_t kb, const char *name)
| Get a single KB string item.
static int | redis_push_str (kb_t kb, const char *name, const char *value)
| Push a new entry under a given key.
static char * | redis_pop_str (kb_t kb, const char *name)
| Pops a single KB string item.
static int | redis_get_int (kb_t kb, const char *name)
| Get a single KB integer item.
static char * | redis_get_nvt (kb_t kb, const char *oid, enum kb_nvt_pos position)
| Get field of a NVT.
static nvti_t * | redis_get_nvt_all (kb_t kb, const char *oid)
| Get a full NVT.
static struct kb_item * | redis_get_all (kb_t kb, const char *name)
| Get all items stored under a given name.
static struct kb_item * | redis_get_pattern (kb_t kb, const char *pattern)
| Get all items stored under a given pattern.
static GSList * | redis_get_oids (kb_t kb)
| Get all NVT OIDs.
static size_t | redis_count (kb_t kb, const char *pattern)
| Count all items stored under a given pattern.
static int | redis_del_items (kb_t kb, const char *name)
| Delete all entries under a given name.
static int | redis_add_str_unique_volatile (kb_t kb, const char *name, const char *str, int expire, size_t len, int pos)
| Insert (append) a new unique and volatile entry under a given name.
static int | redis_add_str_unique (kb_t kb, const char *name, const char *str, size_t len, int pos)
| Insert (append) a new unique entry under a given name.
static int | redis_add_str (kb_t kb, const char *name, const char *str, size_t len)
| Insert (append) a new entry under a given name.
static int | redis_set_str (kb_t kb, const char *name, const char *val, size_t len)
| Set (replace) a new entry under a given name.
static int | redis_add_int_unique_volatile (kb_t kb, const char *name, int val, int expire)
| Insert (append) a new unique entry under a given name.
static int | redis_add_int_unique (kb_t kb, const char *name, int val)
| Insert (append) a new unique entry under a given name.
static int | redis_add_int (kb_t kb, const char *name, int val)
| Insert (append) a new entry under a given name.
static int | redis_set_int (kb_t kb, const char *name, int val)
| Set (replace) a new entry under a given name.
static int | redis_add_nvt (kb_t kb, const nvti_t *nvt, const char *filename)
| Insert a new nvt.
static int | redis_save (kb_t kb)
| Save all the elements from the KB.

## Variables

static const struct kb_operations | KBRedisOperations
| Default KB operations.
const struct kb_operations * | KBDefaultOperations = &KBRedisOperations
| Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based).

## Detailed Description

Knowledge base management API - Redis backend.

Contains specialized structures and functions to use redis as a KB server.

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

## G_LOG_DOMAIN

#define G_LOG_DOMAIN "libgvm util"

GLib logging domain.

## GLOBAL_DBINDEX_NAME

#define GLOBAL_DBINDEX_NAME "GVM.__GlobalDBIndex"

Name of the namespace usage bitmap in redis.

## memdup

#define memdup g_memdup

## redis_kb

#define redis_kb | ( |  | __kb | ) |

Value:
((struct kb_redis *) (__kb))
kb_redis
Subclass of struct kb, it contains the redis-specific fields, such as the redis context,...
Definition kb.c:55

## Function Documentation

## connect_redis()

redisContext * connect_redis | ( | const char * | addr,
|  | int | len )

static

## fetch_max_db_index()

int fetch_max_db_index | ( | struct kb_redis * | kbr | ) |

static

Set the number of databases have been configured into kbr struct.

Parameters

  [in] | kbr | Subclass of struct kb where to save the max db index founded.

Returns
  0 on success, -1 on error.

## get_redis_ctx()

int get_redis_ctx | ( | struct kb_redis * | kbr | ) |

static

Get redis context if it is already connected or do a a connection.

Parameters

  [in] | kbr | Subclass of struct kb where to fetch the context. or where it is saved in case of a new connection.

Returns
  0 on success, -1 on connection error, -2 on unavailable DB slot.

## kb_item_free()

void kb_item_free | ( | struct kb_item * | item | ) |

Release a KB item (or a list).

Parameters

  [in] | item | Item or list to be release

## parse_port_of_addr()

char * parse_port_of_addr | ( | const char * | addr,
|  | int | tcp_indicator_len )

inline static

## redis2kbitem()

struct kb_item * redis2kbitem | ( | const char * | name,
|  | const redisReply * | rep )

static

Fetch a KB item or list from a redis Reply.

Parameters

  [in] | name | Name of the item.
  [in] | rep | A redisReply element where to fetch the item.

Returns
  kb_item or list on success, NULL otherwise.

## redis2kbitem_single()

struct kb_item * redis2kbitem_single | ( | const char * | name,
|  | const redisReply * | elt,
|  | int | force_int )

static

Give a single KB item.

Parameters

  [in] | name | Name of the item.
  [in] | elt | A redisReply element where to fetch the item.
  [in] | force_int | To force string to integer conversion.

Returns
  Single retrieve kb_item on success, NULL otherwise.

## redis_add_int()

int redis_add_int | ( | kb_t | kb,
|  | const char * | name,
|  | int | val )

static

Insert (append) a new entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | val | Item value.

Returns
  0 on success, non-null on error.

## redis_add_int_unique()

int redis_add_int_unique | ( | kb_t | kb,
|  | const char * | name,
|  | int | val )

static

Insert (append) a new unique entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | val | Item value.

Returns
  0 on success, non-null on error.

## redis_add_int_unique_volatile()

int redis_add_int_unique_volatile | ( | kb_t | kb,
|  | const char * | name,
|  | int | val,
|  | int | expire )

static

Insert (append) a new unique entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | val | Item value.
  [in] | expire | Item expire.

Returns
  0 on success, non-null on error.

## redis_add_nvt()

int redis_add_nvt | ( | kb_t | kb,
|  | const nvti_t * | nvt,
|  | const char * | filename )

static

Insert a new nvt.

Parameters

  [in] | kb | KB handle where to store the nvt.
  [in] | nvt | nvt to store.
  [in] | filename | Path to nvt to store.

Returns
  0 on success, non-null on error.

## redis_add_str()

int redis_add_str | ( | kb_t | kb,
|  | const char * | name,
|  | const char * | str,
|  | size_t | len )

static

Insert (append) a new entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | str | Item value.
  [in] | len | Value length. Used for blobs.

Returns
  0 on success, non-null on error.

## redis_add_str_unique()

int redis_add_str_unique | ( | kb_t | kb,
|  | const char * | name,
|  | const char * | str,
|  | size_t | len,
|  | int | pos )

static

Insert (append) a new unique entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | str | Item value.
  [in] | len | Value length. Used for blobs.
  [in] | pos | Which position the value is appended to. 0 for right, 1 for left position in the list.

Returns
  0 on success, non-null on error.

## redis_add_str_unique_volatile()

int redis_add_str_unique_volatile | ( | kb_t | kb,
|  | const char * | name,
|  | const char * | str,
|  | int | expire,
|  | size_t | len,
|  | int | pos )

static

Insert (append) a new unique and volatile entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | str | Item value.
  [in] | expire | Item expire.
  [in] | len | Value length. Used for blobs.
  [in] | pos | Which position the value is appended to. 0 for right, 1 for left position in the list.

Returns
  0 on success, -1 on error.

## redis_cmd()

redisReply * redis_cmd | ( | struct kb_redis * | kbr,
|  | const char * | fmt,
|  |  | ... )

static

Execute a redis command and get a redis reply.

Parameters

  [in] | kbr | Subclass of struct kb to connect to.
  [in] | fmt | Formatted variable argument list with the cmd to be executed.

Returns
  Redis reply on success, NULL otherwise.

## redis_count()

size_t redis_count | ( | kb_t | kb,
|  | const char * | pattern )

static

Count all items stored under a given pattern.

Parameters

  [in] | kb | KB handle where to count the items.
  [in] | pattern | '*' pattern of the elements to count.

Returns
  Count of items.

## redis_del_items()

int redis_del_items | ( | kb_t | kb,
|  | const char * | name )

static

Delete all entries under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.

Returns
  0 on success, non-null on error.

## redis_delete()

int redis_delete | ( | kb_t | kb | ) |

static

Delete all entries and release ownership on the namespace.

Parameters

  [in] | kb | KB handle to release.

Returns
  0 on success, non-null on error.

## redis_delete_all()

int redis_delete_all | ( | struct kb_redis * | kbr | ) |

static

Delete all the KB's content.

Parameters

  [in] | kbr | Subclass of struct kb.

Returns
  0 on success, non-null on error.

## redis_direct_conn()

kb_t redis_direct_conn | ( | const char * | kb_path,
|  | const int | kb_index )

static

Connect to a Knowledge Base object with the given kb_index.

Parameters

  [in] | kb_path | Path to KB.
  [in] | kb_index | DB index

Returns
  Knowledge Base object, NULL otherwise.

## redis_find()

kb_t redis_find | ( | const char * | kb_path,
|  | const char * | key )

static

Find an existing Knowledge Base object with key.

Parameters

  [in] | kb_path | Path to KB.
  [in] | key | Marker key to search for in KB objects.

Returns
  Knowledge Base object, NULL otherwise.

## redis_flush_all()

int redis_flush_all | ( | kb_t | kb,
|  | const char * | except )

static

Flush all the KB's content. Delete all namespaces.

Parameters

  [in] | kb | KB handle.
  [in] | except | Don't flush DB with except key.

Returns
  0 on success, non-null on error.

## redis_get_all()

struct kb_item * redis_get_all | ( | kb_t | kb,
|  | const char * | name )

static

Get all items stored under a given name.

Parameters

  [in] | kb | KB handle where to fetch the items.
  [in] | name | Name of the elements to retrieve.

Returns
  Linked struct kb_item instances to be freed with kb_item_free() or NULL if no element was found or on error.

## redis_get_int()

int redis_get_int | ( | kb_t | kb,
|  | const char * | name )

static

Get a single KB integer item.

Parameters

  [in] | kb | KB handle where to fetch the item.
  [in] | name | Name of the element to retrieve.

Returns
  An integer.

## redis_get_kb_index()

int redis_get_kb_index | ( | kb_t | kb | ) |

static

Return the kb index.

Parameters

  [in] | kb | KB handle.

Returns
  kb_index on success, null on error.

## redis_get_nvt()

char * redis_get_nvt | ( | kb_t | kb,
|  | const char * | oid,
|  | enum kb_nvt_pos | position )

static

Get field of a NVT.

Parameters

  [in] | kb | KB handle where to store the nvt.
  [in] | oid | OID of NVT to get from.
  [in] | position | Position of field to get.

Returns
  Value of field, NULL otherwise.

## redis_get_nvt_all()

nvti_t * redis_get_nvt_all | ( | kb_t | kb,
|  | const char * | oid )

static

Get a full NVT.

Parameters

  [in] | kb | KB handle where to store the nvt.
  [in] | oid | OID of NVT to get.

Returns
  nvti_t of NVT, NULL otherwise.

## redis_get_oids()

GSList * redis_get_oids | ( | kb_t | kb | ) |

static

Get all NVT OIDs.

Parameters

  [in] | kb | KB handle where to fetch the items.

Returns
  Linked list of all OIDs or NULL.

## redis_get_pattern()

struct kb_item * redis_get_pattern | ( | kb_t | kb,
|  | const char * | pattern )

static

Get all items stored under a given pattern.

Parameters

  [in] | kb | KB handle where to fetch the items.
  [in] | pattern | '*' pattern of the elements to retrieve.

Returns
  Linked struct kb_item instances to be freed with kb_item_free() or NULL if no element was found or on error.

## redis_get_single()

struct kb_item * redis_get_single | ( | kb_t | kb,
|  | const char * | name,
|  | enum kb_item_type | type )

static

Get a single KB element.

Parameters

  [in] | kb | KB handle where to fetch the item.
  [in] | name | Name of the element to retrieve.
  [in] | type | Desired element type.

Returns
  A struct kb_item to be freed with kb_item_free() or NULL if no element was found or on error.

## redis_get_str()

char * redis_get_str | ( | kb_t | kb,
|  | const char * | name )

static

Get a single KB string item.

Parameters

  [in] | kb | KB handle where to fetch the item.
  [in] | name | Name of the element to retrieve.

Returns
  A struct kb_item to be freed with kb_item_free() or NULL if no element was found or on error.

## redis_lnk_reset()

int redis_lnk_reset | ( | kb_t | kb | ) |

static

Reset connection to the KB. This is called after each fork() to make sure connections aren't shared between concurrent processes.

Parameters

  [in] | kb | KB handle.

Returns
  0 on success, non-null on error.

## redis_memory_purge()

int redis_memory_purge | ( | kb_t | kb | ) |

static

Attempt to purge dirty pages.

Attempt to purge dirty pages so these can be reclaimed by the allocator. This command only works when using jemalloc as an allocator, and evaluates to a benign NOOP for all others. Command is applied to complete redis instance and not only single db.

Parameters

  [in] | kb | KB handle where to run the command.

Returns
  0 on success, non-null on error.

## redis_new()

int redis_new | ( | kb_t * | kb,
|  | const char * | kb_path )

static

Initialize a new Knowledge Base object.

Parameters

  [in] | kb | Reference to a kb_t to initialize.
  [in] | kb_path | Path to KB.

Returns
  0 on success, -1 on connection error, -2 when no DB is available, -3 when given kb_path was NULL.

## redis_pop_str()

char * redis_pop_str | ( | kb_t | kb,
|  | const char * | name )

static

Pops a single KB string item.

Parameters

  [in] | kb | KB handle where to fetch the item.
  [in] | name | Name of the key from where to retrieve.

Returns
  A string to be freed or NULL if list is empty or on error.

## redis_push_str()

int redis_push_str | ( | kb_t | kb,
|  | const char * | name,
|  | const char * | value )

static

Push a new entry under a given key.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Key to push to.
  [in] | value | Value to push.

Returns
  0 on success, non-null on error.

## redis_release_db()

int redis_release_db | ( | struct kb_redis * | kbr | ) |

static

Release DB.

Parameters

  [in] | kbr | Subclass of struct kb.

Returns
  0 on success, -1 on error.

## redis_save()

int redis_save | ( | kb_t | kb | ) |

static

Save all the elements from the KB.

Parameters

  [in] | kb | KB handle.

Returns
  0 on success, -1 on error.

## redis_set_int()

int redis_set_int | ( | kb_t | kb,
|  | const char * | name,
|  | int | val )

static

Set (replace) a new entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | val | Item value.

Returns
  0 on success, non-null on error.

## redis_set_str()

int redis_set_str | ( | kb_t | kb,
|  | const char * | name,
|  | const char * | val,
|  | size_t | len )

static

Set (replace) a new entry under a given name.

Parameters

  [in] | kb | KB handle where to store the item.
  [in] | name | Item name.
  [in] | val | Item value.
  [in] | len | Value length. Used for blobs.

Returns
  0 on success, non-null on error.

## redis_test_connection()

int redis_test_connection | ( | struct kb_redis * | kbr | ) |

static

Test redis connection.

Parameters

  [in] | kbr | Subclass of struct kb to test.

Returns
  0 on success, negative integer on error.

## select_database()

int select_database | ( | struct kb_redis * | kbr | ) |

static

Select DB.

WARNING: do not call redis_cmd in here, since our context is not fully acquired yet!

Parameters

  [in] | kbr | Subclass of struct kb where to save the db index.

Returns
  0 on success, -1 on error.

## try_database_index()

int try_database_index | ( | struct kb_redis * | kbr,
|  | int | index )

static

Attempt to atomically acquire ownership of a database.

Returns
  0 on success, negative integer otherwise.

## Variable Documentation

## KBDefaultOperations

const struct kb_operations* KBDefaultOperations = &KBRedisOperations

Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based).

## KBRedisOperations

const struct kb_operations KBRedisOperations

static

Initial value:
= {
.kb_new = redis_new,
.kb_find = redis_find,
.kb_delete = redis_delete,
.kb_get_single = redis_get_single,
.kb_get_str = redis_get_str,
.kb_get_int = redis_get_int,
.kb_get_nvt = redis_get_nvt,
.kb_get_nvt_all = redis_get_nvt_all,
.kb_get_nvt_oids = redis_get_oids,
.kb_push_str = redis_push_str,
.kb_pop_str = redis_pop_str,
.kb_get_all = redis_get_all,
.kb_get_pattern = redis_get_pattern,
.kb_count = redis_count,
.kb_add_str = redis_add_str,
.kb_add_str_unique = redis_add_str_unique,
.kb_add_str_unique_volatile = redis_add_str_unique_volatile,
.kb_set_str = redis_set_str,
.kb_add_int = redis_add_int,
.kb_add_int_unique = redis_add_int_unique,
.kb_add_int_unique_volatile = redis_add_int_unique_volatile,
.kb_set_int = redis_set_int,
.kb_add_nvt = redis_add_nvt,
.kb_del_items = redis_del_items,
.kb_lnk_reset = redis_lnk_reset,
.kb_save = redis_save,
.kb_flush = redis_flush_all,
.kb_direct_conn = redis_direct_conn,
.kb_get_kb_index = redis_get_kb_index}
redis_lnk_reset
static int redis_lnk_reset(kb_t)
Reset connection to the KB. This is called after each fork() to make sure connections aren't shared b...
Definition kb.c:1675
redis_push_str
static int redis_push_str(kb_t kb, const char *name, const char *value)
Push a new entry under a given key.
Definition kb.c:874
redis_set_str
static int redis_set_str(kb_t kb, const char *name, const char *val, size_t len)
Set (replace) a new entry under a given name.
Definition kb.c:1411
redis_add_str_unique_volatile
static int redis_add_str_unique_volatile(kb_t kb, const char *name, const char *str, int expire, size_t len, int pos)
Insert (append) a new unique and volatile entry under a given name.
Definition kb.c:1230
redis_get_nvt
static char * redis_get_nvt(kb_t kb, const char *oid, enum kb_nvt_pos position)
Get field of a NVT.
Definition kb.c:956
redis_find
static kb_t redis_find(const char *kb_path, const char *key)
Find an existing Knowledge Base object with key.
Definition kb.c:564
redis_delete
static int redis_delete(kb_t kb)
Delete all entries and release ownership on the namespace.
Definition kb.c:394
redis_add_str
static int redis_add_str(kb_t kb, const char *name, const char *str, size_t len)
Insert (append) a new entry under a given name.
Definition kb.c:1381
redis_add_int_unique_volatile
static int redis_add_int_unique_volatile(kb_t kb, const char *name, int val, int expire)
Insert (append) a new unique entry under a given name.
Definition kb.c:1452
redis_get_all
static struct kb_item * redis_get_all(kb_t kb, const char *name)
Get all items stored under a given name.
Definition kb.c:1038
redis_add_int
static int redis_add_int(kb_t kb, const char *name, int val)
Insert (append) a new entry under a given name.
Definition kb.c:1546
redis_direct_conn
static kb_t redis_direct_conn(const char *kb_path, const int kb_index)
Connect to a Knowledge Base object with the given kb_index.
Definition kb.c:516
redis_add_str_unique
static int redis_add_str_unique(kb_t kb, const char *name, const char *str, size_t len, int pos)
Insert (append) a new unique entry under a given name.
Definition kb.c:1323
redis_get_str
static char * redis_get_str(kb_t kb, const char *name)
Get a single KB string item.
Definition kb.c:847
redis_get_pattern
static struct kb_item * redis_get_pattern(kb_t kb, const char *pattern)
Get all items stored under a given pattern.
Definition kb.c:1067
redis_get_oids
static GSList * redis_get_oids(kb_t kb)
Get all NVT OIDs.
Definition kb.c:1131
redis_save
static int redis_save(kb_t kb)
Save all the elements from the KB.
Definition kb.c:1777
redis_get_int
static int redis_get_int(kb_t kb, const char *name)
Get a single KB integer item.
Definition kb.c:930
redis_pop_str
static char * redis_pop_str(kb_t kb, const char *name)
Pops a single KB string item.
Definition kb.c:903
redis_new
static int redis_new(kb_t *kb, const char *kb_path)
Initialize a new Knowledge Base object.
Definition kb.c:468
redis_get_kb_index
static int redis_get_kb_index(kb_t kb)
Return the kb index.
Definition kb.c:422
redis_add_int_unique
static int redis_add_int_unique(kb_t kb, const char *name, int val)
Insert (append) a new unique entry under a given name.
Definition kb.c:1505
redis_flush_all
static int redis_flush_all(kb_t, const char *)
Flush all the KB's content. Delete all namespaces.
Definition kb.c:1699
redis_count
static size_t redis_count(kb_t kb, const char *pattern)
Count all items stored under a given pattern.
Definition kb.c:1166
redis_get_single
static struct kb_item * redis_get_single(kb_t kb, const char *name, enum kb_item_type type)
Get a single KB element.
Definition kb.c:812
redis_set_int
static int redis_set_int(kb_t kb, const char *name, int val)
Set (replace) a new entry under a given name.
Definition kb.c:1570
redis_add_nvt
static int redis_add_nvt(kb_t kb, const nvti_t *nvt, const char *filename)
Insert a new nvt.
Definition kb.c:1607
redis_get_nvt_all
static nvti_t * redis_get_nvt_all(kb_t kb, const char *oid)
Get a full NVT.
Definition kb.c:988
redis_del_items
static int redis_del_items(kb_t kb, const char *name)
Delete all entries under a given name.
Definition kb.c:1198

Default KB operations.

No selection mechanism is provided yet since there's only one implementation (redis-based).