Greenbone Vulnerability Manager
8.0.1~git
|
GVM management layer: NVTs. More...
#include "manage_sql_nvts.h"
#include "manage_sql.h"
#include "sql.h"
#include "utils.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Macros | |
#define | _GNU_SOURCE |
Enable extra GNU functions. | |
#define | G_LOG_DOMAIN "md manage" |
GLib log domain. | |
#define | CHUNK_SIZE 100 |
Size of chunk for insert_nvts_list. | |
Functions | |
static void | refresh_nvt_cves () |
Refresh nvt_cves table. More... | |
void | check_db_nvts () |
Ensures the sanity of nvts cache in DB. | |
char * | manage_nvt_name (nvt_t nvt) |
Get the name of an NVT. More... | |
char * | nvt_oid (const char *name) |
Guess the OID of an NVT given a name. More... | |
char * | nvts_feed_version () |
Return feed version of the plugins in the plugin cache. More... | |
void | set_nvts_feed_version (const char *feed_version) |
Set the feed version of the plugins in the plugin cache. More... | |
gboolean | find_nvt (const char *oid, nvt_t *nvt) |
Find an NVT given an identifier. More... | |
static nvt_t | make_nvt_from_nvti (const nvti_t *nvti) |
Make an nvt from an nvti. More... | |
int | init_nvt_info_iterator (iterator_t *iterator, get_data_t *get, const char *name) |
Initialise an NVT iterator. More... | |
static gchar * | nvt_iterator_columns () |
Get NVT iterator SELECT columns. More... | |
static gchar * | nvt_iterator_columns_nvts () |
Get NVT iterator SELECT columns. More... | |
int | nvt_info_count (const get_data_t *get) |
Count number of nvt. More... | |
static gchar * | select_config_nvts (const config_t config, const char *family, int ascending, const char *sort_field) |
Return SQL for selecting NVT's of a config from one family. More... | |
void | init_nvt_iterator (iterator_t *iterator, nvt_t nvt, config_t config, const char *family, const char *category, int ascending, const char *sort_field) |
Initialise an NVT iterator. More... | |
void | init_cve_nvt_iterator (iterator_t *iterator, const char *cve, int ascending, const char *sort_field) |
Initialise an NVT iterator, for NVTs of a certain CVE. More... | |
int | nvt_iterator_category (iterator_t *iterator) |
Get the category from an NVT iterator. More... | |
char * | nvt_default_timeout (const char *oid) |
Get the default timeout of an NVT. More... | |
int | family_nvt_count (const char *family) |
Get the number of NVTs in one or all families. More... | |
int | family_count () |
Get the number of families. More... | |
static void | insert_nvt_from_nvti (gpointer nvti, gpointer dummy) |
Insert an NVT from an nvti structure. More... | |
static void | insert_nvt_preference (gpointer nvt_preference, gpointer dummy) |
Insert a NVT preferences. More... | |
static void | insert_nvts_list (GList *nvts_list) |
Inserts NVTs in DB from a list of nvti_t structures. More... | |
static void | insert_nvt_preferences_list (GList *nvt_preferences_list) |
Inserts NVT preferences in DB from a list of nvt_preference_t structures. More... | |
static void | check_for_new_nvts () |
Check for new NVTs after an update. | |
static void | check_for_updated_nvts () |
Check for updated NVTS after an update. | |
void | manage_complete_nvt_cache_update (GList *nvts_list, GList *nvt_preferences_list) |
Complete an update of the NVT cache. More... | |
void | manage_sync_nvts (int(*fork_update_nvt_cache)()) |
Sync NVTs if newer NVTs are available. More... | |
Variables | |
static int | chunk_count = 0 |
Counter for chunking in insert_nvts_list. | |
GVM management layer: NVTs.
The NVT parts of the GVM management layer.
int family_count | ( | ) |
Get the number of families.
int family_nvt_count | ( | const char * | family | ) |
Get the number of NVTs in one or all families.
[in] | family | Family name. NULL for all families. |
gboolean find_nvt | ( | const char * | oid, |
nvt_t * | nvt | ||
) |
Find an NVT given an identifier.
[in] | oid | An NVT identifier. |
[out] | nvt | NVT return, 0 if successfully failed to find task. |
void init_cve_nvt_iterator | ( | iterator_t * | iterator, |
const char * | cve, | ||
int | ascending, | ||
const char * | sort_field | ||
) |
Initialise an NVT iterator, for NVTs of a certain CVE.
[in] | iterator | Iterator. |
[in] | cve | CVE name. |
[in] | ascending | Whether to sort ascending or descending. |
[in] | sort_field | Field to sort on, or NULL for "id". |
int init_nvt_info_iterator | ( | iterator_t * | iterator, |
get_data_t * | get, | ||
const char * | name | ||
) |
Initialise an NVT iterator.
[in] | iterator | Iterator. |
[in] | get | GET data. |
[in] | name | Name of the info |
void init_nvt_iterator | ( | iterator_t * | iterator, |
nvt_t | nvt, | ||
config_t | config, | ||
const char * | family, | ||
const char * | category, | ||
int | ascending, | ||
const char * | sort_field | ||
) |
Initialise an NVT iterator.
[in] | iterator | Iterator. |
[in] | nvt | NVT to iterate over, all if 0. |
[in] | config | Config to limit selection to. NULL for all NVTs. Overridden by
|
[in] | family | Family to limit selection to. NULL for all NVTs. Overridden by
|
[in] | category | Category to limit selection to. NULL for all. |
[in] | ascending | Whether to sort ascending or descending. |
[in] | sort_field | Field to sort on, or NULL for "id". |
|
static |
Insert an NVT from an nvti structure.
[in] | nvti | nvti_t to insert in nvts table. |
[in] | dummy | Dummy arg for g_list_foreach. |
|
static |
Insert a NVT preferences.
[in] | nvt_preference | Preference. |
[in] | dummy | Dummy arg for g_list_foreach. |
|
static |
Inserts NVT preferences in DB from a list of nvt_preference_t structures.
[in] | nvt_preferences_list | List of nvts to be inserted. |
|
static |
Inserts NVTs in DB from a list of nvti_t structures.
[in] | nvts_list | List of nvts to be inserted. |
|
static |
Make an nvt from an nvti.
[in] | nvti | NVTI. |
void manage_complete_nvt_cache_update | ( | GList * | nvts_list, |
GList * | nvt_preferences_list | ||
) |
Complete an update of the NVT cache.
[in] | nvts_list | List of nvti_t to insert. |
[in] | nvt_preferences_list | List of preference_t to insert. |
char* manage_nvt_name | ( | nvt_t | nvt | ) |
Get the name of an NVT.
[in] | nvt | NVT. |
void manage_sync_nvts | ( | int(*)() | fork_update_nvt_cache | ) |
Sync NVTs if newer NVTs are available.
[in] | fork_update_nvt_cache | Function to do the update. |
char* nvt_default_timeout | ( | const char * | oid | ) |
Get the default timeout of an NVT.
[in] | oid | The OID of the NVT to get the timeout of. |
int nvt_info_count | ( | const get_data_t * | get | ) |
Count number of nvt.
[in] | get | GET params. |
int nvt_iterator_category | ( | iterator_t * | iterator | ) |
Get the category from an NVT iterator.
[in] | iterator | Iterator. |
|
static |
Get NVT iterator SELECT columns.
|
static |
Get NVT iterator SELECT columns.
char* nvt_oid | ( | const char * | name | ) |
Guess the OID of an NVT given a name.
[in] | name | Name of NVT. |
char* nvts_feed_version | ( | ) |
Return feed version of the plugins in the plugin cache.
|
static |
Refresh nvt_cves table.
Caller must organise transaction.
|
static |
Return SQL for selecting NVT's of a config from one family.
[in] | config | Config. |
[in] | family | Family to limit selection to. |
[in] | ascending | Whether to sort ascending or descending. |
[in] | sort_field | Field to sort on, or NULL for "nvts.id". |
void set_nvts_feed_version | ( | const char * | feed_version | ) |
Set the feed version of the plugins in the plugin cache.
[in] | feed_version | New feed version. |
Also queue an update to the nvti cache.