Greenbone Vulnerability Management Libraries 22.10.0
|
Knowledge base management API - Redis backend. More...
Go to the source code of this file.
Data Structures | |
struct | kb_item |
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked list. More... | |
struct | kb |
Top-level KB. This is to be inherited by KB implementations. More... | |
struct | kb_operations |
KB interface. Functions provided by an implementation. All functions have to be provided, there is no default/fallback. These functions should be called via the corresponding static inline wrappers below. See the wrappers for the documentation. More... | |
Macros | |
#define | KB_PATH_DEFAULT "/run/redis/redis.sock" |
Default KB location. | |
Typedefs | |
typedef struct kb * | kb_t |
type abstraction to hide KB internals. | |
Enumerations | |
enum | kb_item_type { KB_TYPE_UNSPEC , KB_TYPE_INT , KB_TYPE_STR , KB_TYPE_CNT } |
Possible type of a kb_item. More... | |
enum | kb_nvt_pos { NVT_FILENAME_POS , NVT_REQUIRED_KEYS_POS , NVT_MANDATORY_KEYS_POS , NVT_EXCLUDED_KEYS_POS , NVT_REQUIRED_UDP_PORTS_POS , NVT_REQUIRED_PORTS_POS , NVT_DEPENDENCIES_POS , NVT_TAGS_POS , NVT_CVES_POS , NVT_BIDS_POS , NVT_XREFS_POS , NVT_CATEGORY_POS , NVT_FAMILY_POS , NVT_NAME_POS , NVT_TIMESTAMP_POS , NVT_OID_POS } |
Possible positions of nvt values in cache list. More... | |
Functions | |
void | kb_item_free (struct kb_item *) |
Release a KB item (or a list). | |
static int | kb_new (kb_t *kb, const char *kb_path) |
Initialize a new Knowledge Base object. | |
static kb_t | kb_direct_conn (const char *kb_path, const int kb_index) |
Connect to a Knowledge Base object which has the given kb_index. | |
static kb_t | kb_find (const char *kb_path, const char *key) |
Find an existing Knowledge Base object with key. | |
static int | kb_delete (kb_t kb) |
Delete all entries and release ownership on the namespace. | |
static struct kb_item * | kb_item_get_single (kb_t kb, const char *name, enum kb_item_type type) |
Get a single KB element. | |
static char * | kb_item_get_str (kb_t kb, const char *name) |
Get a single KB string item. | |
static int | kb_item_get_int (kb_t kb, const char *name) |
Get a single KB integer item. | |
static struct kb_item * | kb_item_get_all (kb_t kb, const char *name) |
Get all items stored under a given name. | |
static struct kb_item * | kb_item_get_pattern (kb_t kb, const char *pattern) |
Get all items stored under a given pattern. | |
static int | kb_item_push_str (kb_t kb, const char *name, const char *value) |
Push a new value under a given key. | |
static char * | kb_item_pop_str (kb_t kb, const char *name) |
Pop a single KB string item. | |
static size_t | kb_item_count (kb_t kb, const char *pattern) |
Count all items stored under a given pattern. | |
static int | kb_item_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 | kb_item_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 | kb_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 | 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. | |
static int | kb_item_add_int (kb_t kb, const char *name, int val) |
Insert (append) a new entry under a given name. | |
static int | kb_item_add_int_unique (kb_t kb, const char *name, int val) |
Insert (append) a new unique entry under a given name. | |
static int | kb_add_int_unique_volatile (kb_t kb, const char *name, int val, int expire) |
Insert (append) a new unique and volatile entry under a given name. | |
static int | kb_item_set_int (kb_t kb, const char *name, int val) |
Set (replace) a new entry under a given name. | |
static int | kb_nvt_add (kb_t kb, const nvti_t *nvt, const char *filename) |
Insert a new nvt. | |
static char * | kb_nvt_get (kb_t kb, const char *oid, enum kb_nvt_pos position) |
Get field of a NVT. | |
static nvti_t * | kb_nvt_get_all (kb_t kb, const char *oid) |
Get a full NVT. | |
static GSList * | kb_nvt_get_oids (kb_t kb) |
Get list of NVT OIDs. | |
static int | kb_del_items (kb_t kb, const char *name) |
Delete all entries under a given name. | |
static int | kb_save (kb_t kb) |
Save all the KB's content. | |
static int | kb_lnk_reset (kb_t kb) |
Reset connection to the KB. This is called after each fork() to make. | |
static int | kb_flush (kb_t kb, const char *except) |
Flush all the KB's content. Delete all namespaces. | |
static int | kb_get_kb_index (kb_t kb) |
Return the kb index. | |
Variables | |
const struct kb_operations * | KBDefaultOperations |
Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based). | |
Knowledge base management API - Redis backend.
#define KB_PATH_DEFAULT "/run/redis/redis.sock" |
Default KB location.
enum kb_item_type |
Possible type of a kb_item.
enum kb_nvt_pos |
Possible positions of nvt values in cache list.
|
inlinestatic |
Insert (append) a new unique and volatile entry under a given name.
[in] | kb | Reference to a kb_t to initialize. |
[in] | name | Item name. |
[in] | val | Item value. |
[in] | expire | Item expire. |
|
inlinestatic |
Insert (append) a new unique and volatile entry under a given name.
[in] | kb | Reference to a kb_t to initialize. |
[in] | name | Item name. |
[in] | str | String to add. |
[in] | len | Value length. Used for blobs. |
[in] | expire | Item expire. |
[in] | pos | Which position the value is appended to. 0 for right, 1 for left position in the list. |
|
inlinestatic |
Delete all entries under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
|
inlinestatic |
Delete all entries and release ownership on the namespace.
[in] | kb | KB handle to release. |
|
inlinestatic |
Connect to a Knowledge Base object which has the given kb_index.
[in] | kb_path | Path to KB. |
[in] | kb_index | DB index |
|
inlinestatic |
Find an existing Knowledge Base object with key.
[in] | kb_path | Path to KB. |
[in] | key | Marker key to search for in KB objects. |
|
inlinestatic |
Flush all the KB's content. Delete all namespaces.
[in] | kb | KB handle. |
[in] | except | Don't flush DB with except key. |
|
inlinestatic |
Return the kb index.
[in] | kb | KB handle. |
|
inlinestatic |
Insert (append) a new entry under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
[in] | val | Item value. |
|
inlinestatic |
Insert (append) a new unique entry under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
[in] | val | Item value. |
|
inlinestatic |
Insert (append) a new entry under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
[in] | str | Item value. |
[in] | len | Value length. Used for blobs. |
|
inlinestatic |
Insert (append) a new unique entry under a given name.
[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. |
|
inlinestatic |
Count all items stored under a given pattern.
[in] | kb | KB handle where to count the items. |
[in] | pattern | '*' pattern of the elements to count. |
void kb_item_free | ( | struct kb_item * | item | ) |
Release a KB item (or a list).
[in] | item | Item or list to be release |
Get all items stored under a given name.
[in] | kb | KB handle where to fetch the items. |
[in] | name | Name of the elements to retrieve. |
|
inlinestatic |
Get a single KB integer item.
[in] | kb | KB handle where to fetch the item. |
[in] | name | Name of the element to retrieve. |
Get all items stored under a given pattern.
[in] | kb | KB handle where to fetch the items. |
[in] | pattern | '*' pattern of the elements to retrieve. |
|
inlinestatic |
Get a single KB element.
[in] | kb | KB handle where to fetch the item. |
[in] | name | Name of the element to retrieve. |
[in] | type | Desired element type. |
|
inlinestatic |
Get a single KB string item.
[in] | kb | KB handle where to fetch the item. |
[in] | name | Name of the element to retrieve. |
|
inlinestatic |
Pop a single KB string item.
[in] | kb | KB handle where to fetch the item. |
[in] | name | Name of the element to retrieve. |
|
inlinestatic |
Push a new value under a given key.
[in] | kb | KB handle where to store the item. |
[in] | name | Key to push to. |
[in] | value | Value to push. |
|
inlinestatic |
Set (replace) a new entry under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
[in] | val | Item value. |
|
inlinestatic |
Set (replace) a new entry under a given name.
[in] | kb | KB handle where to store the item. |
[in] | name | Item name. |
[in] | str | Item value. |
[in] | len | Value length. Used for blobs. |
|
inlinestatic |
Reset connection to the KB. This is called after each fork() to make.
sure connections aren't shared between concurrent processes.
[in] | kb | KB handle. |
|
inlinestatic |
Initialize a new Knowledge Base object.
[in] | kb | Reference to a kb_t to initialize. |
[in] | kb_path | Path to KB. |
Insert a new nvt.
[in] | kb | KB handle where to store the nvt. |
[in] | nvt | nvt to store. |
[in] | filename | Path to nvt to store. |
|
inlinestatic |
Get field of a NVT.
[in] | kb | KB handle where to store the nvt. |
[in] | oid | OID of NVT to get from. |
[in] | position | Position of field to get. |
Get a full NVT.
[in] | kb | KB handle where to store the nvt. |
[in] | oid | OID of NVT to get. |
|
inlinestatic |
Get list of NVT OIDs.
[in] | kb | KB handle where NVTs are stored. |
|
inlinestatic |
Save all the KB's content.
[in] | kb | KB handle. |
|
extern |
Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based).