|
Greenbone Vulnerability Manager
22.4.0~dev1
|
GVM management layer: NVTs. More...
#include <assert.h>#include <errno.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <gvm/base/cvss.h>#include "manage_sql_nvts.h"#include "manage_preferences.h"#include "manage_sql.h"#include "manage_sql_configs.h"#include "sql.h"#include "utils.h"Macros | |
| #define | _GNU_SOURCE |
| Enable extra GNU functions. | |
| #define | G_LOG_DOMAIN "md manage" |
| GLib log domain. | |
Functions | |
| const gchar * | get_osp_vt_update_socket () |
| Get the current file socket for OSP NVT update. More... | |
| void | set_osp_vt_update_socket (const char *new_socket) |
| Set the file socket for OSP NVT update. More... | |
| int | check_osp_vt_update_socket () |
| Check the files socket used for OSP NVT update. 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_name (const char *oid) |
| Get the name of an NVT given its OID. More... | |
| char * | nvts_feed_version () |
| Return feed version of the plugins in the plugin cache. More... | |
| time_t | nvts_feed_version_epoch () |
| Return feed version of the plugins as seconds since epoch. 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 void | insert_nvt (const nvti_t *nvti) |
| Insert an NVT. 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... | |
| int | nvt_info_count_after (const get_data_t *get, time_t count_time, gboolean get_modified) |
| Count number of nvts created or modified after a given time. 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... | |
| char * | nvt_family (const char *oid) |
| Get the family 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_preference (gpointer nvt_preference, gpointer dummy) |
| Insert a NVT preferences. 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 | set_nvts_check_time (int count_new, int count_modified) |
| Set the NVT update check time in the meta table. More... | |
| static int | update_preferences_from_vt (entity_t vt, const gchar *oid, GList **preferences) |
| Update NVT from VT XML. More... | |
| static nvti_t * | nvti_from_vt (entity_t vt) |
| Create NVTI structure from VT XML. More... | |
| static int | update_nvts_from_vts (entity_t *get_vts_response, const gchar *scanner_feed_version) |
| Update NVTs from VTs XML. More... | |
| static void | check_old_preference_names (const gchar *table) |
| Check that preference names are in the new format. More... | |
| static void | check_preference_names (int trash, time_t modification_time) |
| Update config preferences where the name has changed in the NVTs. More... | |
| void | init_nvt_severity_iterator (iterator_t *iterator, const char *oid) |
| Initialise an NVT severity iterator. More... | |
| double | nvt_severity_iterator_score (iterator_t *iterator) |
| Gets the score from an NVT severity iterator. More... | |
| static int | update_nvt_cache_osp (const gchar *update_socket, gchar *db_feed_version, gchar *scanner_feed_version) |
| Update VTs via OSP. More... | |
| static char * | osp_scanner_feed_version (const gchar *update_socket) |
| Get the VTs feed version from an OSP scanner. More... | |
| static int | nvts_feed_version_status_internal (const gchar *update_socket, gchar **db_feed_version_out, gchar **scanner_feed_version_out) |
| Check VTs feed version status via OSP, optionally get versions. More... | |
| int | nvts_feed_version_status () |
| Check VTs feed version status. More... | |
| int | manage_update_nvt_cache_osp (const gchar *update_socket) |
| Update VTs via OSP. More... | |
| void | manage_sync_nvts (int(*fork_update_nvt_cache)()) |
| Sync NVTs if newer NVTs are available. More... | |
| int | update_or_rebuild_nvts (int update) |
| Update or rebuild NVT db. More... | |
| int | manage_rebuild (GSList *log_config, const db_conn_info_t *database) |
| Rebuild NVT db. More... | |
| int | manage_dump_vt_verification (GSList *log_config, const db_conn_info_t *database) |
| Dump the string used to calculate the VTs verification hash to stdout. More... | |
| int | cleanup_nvt_sequences () |
| Cleans up NVT related id sequences likely to run out. More... | |
Variables | |
| static gchar * | osp_vt_update_socket = NULL |
| File socket for OSP NVT update. | |
GVM management layer: NVTs.
The NVT parts of the GVM management layer.
|
static |
Check that preference names are in the new format.
| [in] | table | Table name. |
| int check_osp_vt_update_socket | ( | ) |
Check the files socket used for OSP NVT update.
|
static |
Update config preferences where the name has changed in the NVTs.
| [in] | trash | Whether to update the trash table. |
| [in] | modification_time | Time NVTs considered must be modified after. |
| int cleanup_nvt_sequences | ( | ) |
Cleans up NVT related id sequences likely to run out.
| 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. |
| const gchar* get_osp_vt_update_socket | ( | ) |
Get the current file socket for OSP NVT update.
| 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". |
| void init_nvt_severity_iterator | ( | iterator_t * | iterator, |
| const char * | oid | ||
| ) |
Initialise an NVT severity iterator.
| [in] | iterator | Iterator. |
| [in] | oid | OID of NVT. |
|
static |
Insert an NVT.
| [in] | nvti | NVT Information. |
|
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. |
| int manage_dump_vt_verification | ( | GSList * | log_config, |
| const db_conn_info_t * | database | ||
| ) |
Dump the string used to calculate the VTs verification hash to stdout.
| [in] | log_config | Log configuration. |
| [in] | database | Location of manage database. |
| char* manage_nvt_name | ( | nvt_t | nvt | ) |
Get the name of an NVT.
| [in] | nvt | NVT. |
| int manage_rebuild | ( | GSList * | log_config, |
| const db_conn_info_t * | database | ||
| ) |
Rebuild NVT db.
| [in] | log_config | Log configuration. |
| [in] | database | Location of manage database. |
| 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. |
| int manage_update_nvt_cache_osp | ( | const gchar * | update_socket | ) |
Update VTs via OSP.
Expect to be called in the child after a fork.
| [in] | update_socket | Socket to use to contact ospd-openvas scanner. |
| 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. |
| char* nvt_family | ( | const char * | oid | ) |
Get the family of an NVT.
| [in] | oid | The OID of the NVT. |
| int nvt_info_count | ( | const get_data_t * | get | ) |
Count number of nvt.
| [in] | get | GET params. |
| int nvt_info_count_after | ( | const get_data_t * | get, |
| time_t | count_time, | ||
| gboolean | get_modified | ||
| ) |
Count number of nvts created or modified after a given time.
| [in] | get | GET params. |
| [in] | count_time | Time NVTs must be created or modified after. |
| [in] | get_modified | Whether to get the modification time. |
| 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_name | ( | const char * | oid | ) |
Get the name of an NVT given its OID.
| [in] | oid | OID of NVT. |
| double nvt_severity_iterator_score | ( | iterator_t * | iterator | ) |
Gets the score from an NVT severity iterator.
| [in] | iterator | Iterator. |
|
static |
Create NVTI structure from VT XML.
| [in] | vt | OSP GET_VTS VT element. |
| char* nvts_feed_version | ( | ) |
Return feed version of the plugins in the plugin cache.
| time_t nvts_feed_version_epoch | ( | ) |
Return feed version of the plugins as seconds since epoch.
| int nvts_feed_version_status | ( | ) |
Check VTs feed version status.
|
static |
Check VTs feed version status via OSP, optionally get versions.
| [in] | update_socket | Socket to use to contact ospd-openvas scanner. |
| [out] | db_feed_version_out | Output of database feed version. |
| [out] | scanner_feed_version_out | Output of scanner feed version. |
|
static |
Get the VTs feed version from an OSP scanner.
| [in] | update_socket | Socket to use to contact ospd-openvas scanner. |
|
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". |
|
static |
Set the NVT update check time in the meta table.
| [in] | count_new | Number of new VTs with current update. |
| [in] | count_modified | Number of modified VTs with current update. |
| 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.
| void set_osp_vt_update_socket | ( | const char * | new_socket | ) |
Set the file socket for OSP NVT update.
| new_socket | The new path of the file socket for OSP NVT update. |
|
static |
Update VTs via OSP.
| [in] | update_socket | Socket to use to contact scanner. |
| [in] | db_feed_version | Feed version from meta table. |
| [in] | scanner_feed_version | Feed version from scanner. |
|
static |
Update NVTs from VTs XML.
| [in] | get_vts_response | OSP GET_VTS response. |
| [in] | scanner_feed_version | Version of feed from scanner. |
| int update_or_rebuild_nvts | ( | int | update | ) |
Update or rebuild NVT db.
Caller must get the lock.
| [in] | update | 0 rebuild, else update. |
|
static |
Update NVT from VT XML.
| [in] | vt | OSP GET_VTS VT element. |
| [in] | oid | OID of NVT. |
| [in] | preferences | All NVT preferences. |