Greenbone Vulnerability Manager
22.4.0~dev1
|
GVM management layer: Config SQL. More...
#include "manage_configs.h"
#include "manage_acl.h"
#include "manage_sql.h"
#include "manage_sql_configs.h"
#include "manage_sql_nvts.h"
#include "sql.h"
#include <assert.h>
#include <errno.h>
#include <glib/gstdio.h>
#include <stdlib.h>
#include <string.h>
#include <gvm/util/uuidutils.h>
Macros | |
#define | G_LOG_DOMAIN "md manage" |
GLib log domain. | |
Functions | |
int | sync_configs_with_feed (gboolean) |
Sync all configs with the feed. More... | |
static int | switch_representation (config_t config, int constraining) |
Switch between constraining and generating representation. More... | |
static void | update_config_caches (config_t config) |
Update the cached count and growing information in every config. More... | |
static int | member (GPtrArray *array, const char *string) |
Test whether a string equal to a given string exists in an array. More... | |
int | nvt_selector_family_count (const char *quoted_selector, int families_growing) |
Get the number of families selected by an NVT selector. More... | |
static int | nvt_selector_families_growing (const char *selector) |
Get the family growth status of an NVT selector. More... | |
static int | nvt_selector_nvts_growing_2 (const char *quoted_selector, int families_growing) |
Get the NVT growth status of an NVT selector. More... | |
int | config_nvts_growing (config_t config) |
Get the NVT growth status of a config. More... | |
int | config_families_growing (config_t config) |
Get the family growth status of a config. More... | |
void | init_nvt_selector_iterator (iterator_t *iterator, const char *selector, config_t config, int type) |
Initialise an NVT selector iterator. More... | |
int | nvt_selector_iterator_include (iterator_t *iterator) |
Get whether the selector rule is an include rule. More... | |
int | nvt_selector_iterator_type (iterator_t *iterator) |
Get the type from an NVT selector. More... | |
void | init_family_iterator (iterator_t *iterator, int all, const char *selector, int ascending) |
Initialise an NVT selector family iterator. More... | |
static int | nvt_selector_entire_and_growing (const char *selector, const char *family, int all) |
Get whether an NVT selector selects every NVT in a family. More... | |
int | nvt_selector_family_growing (const char *selector, const char *family, int all) |
Get whether an NVT selector family is growing. More... | |
int | nvt_selector_nvt_count (const char *selector, const char *family, int growing) |
Get the number of NVTs selected by an NVT selector. More... | |
static void | nvt_selector_remove (const char *quoted_selector, const char *quoted_family, int type) |
Remove all selectors of a certain family from an NVT selector. More... | |
static void | nvt_selector_remove_selector (const char *quoted_selector, const char *family_or_nvt, int type) |
Remove all selectors of a certain type from an NVT selector. More... | |
static void | nvt_selector_add (const char *quoted_selector, const char *quoted_family_or_nvt, const char *quoted_family, int exclude) |
Add a selector to an NVT selector. More... | |
static void | nvt_selector_set_family (const char *quoted_selector, const char *family_or_nvt, int type, const char *family) |
Set the family of an NVT selector. More... | |
static int | family_is_selected (const char *quoted_selector, const char *quoted_family) |
Check whether a family is selected. More... | |
static int | nvt_selector_has (const char *quoted_selector, const char *family_or_nvt, int type, int exclude) |
Check whether an NVT selector has a particular selector. More... | |
int | manage_modify_config_start (const char *config_id, config_t *config_out) |
Starts the SQL transaction for modify_config and finds the config. More... | |
void | manage_modify_config_cancel () |
Cancels a manage_config command and rolls back the changes. | |
void | manage_modify_config_commit () |
Commits the changes of a manage_config command. | |
int | manage_set_config_families (config_t config, GPtrArray *growing_all_families, GPtrArray *static_all_families, GPtrArray *growing_families, int grow_families, gchar **rejected_family) |
Refresh NVT selection of a config from given families. More... | |
static int | insert_nvt_selectors (const char *quoted_name, const array_t *selectors, int allow_errors) |
Insert NVT selectors. More... | |
static int | config_update_nvt_family (resource_t config, const char *oid, const char *old_family, const char *new_family) |
Change the family of an NVT in a config. More... | |
static int | update_nvt_family (const char *oid, const char *old_family, const char *new_family) |
Change the family of an NVT in all configs. More... | |
int | check_config_families () |
Ensure that all configs refer to the right NVT families. More... | |
void | manage_nvt_preference_add (const char *name, const char *value) |
Add/replace an NVT preference. More... | |
void | init_nvt_preference_iterator (iterator_t *iterator, const char *oid) |
Initialise an NVT preference iterator. More... | |
char * | nvt_preference_iterator_real_name (iterator_t *iterator) |
Get the real name from an NVT preference iterator. More... | |
char * | nvt_preference_iterator_type (iterator_t *iterator) |
Get the type from an NVT preference iterator. More... | |
char * | nvt_preference_iterator_oid (iterator_t *iterator) |
Get the NVT from an NVT preference iterator. More... | |
char * | nvt_preference_iterator_id (iterator_t *iterator) |
Get the ID from an NVT preference iterator. More... | |
char * | nvt_preference_iterator_config_value (iterator_t *iterator, config_t config) |
Get the config value from an NVT preference iterator. More... | |
int | nvt_preference_count (const char *oid) |
Get the number preferences available for an NVT. More... | |
char * | task_preference_value (task_t task, const char *name) |
Get the value of a task preference. More... | |
int | set_task_preferences (task_t task, array_t *preferences) |
Set the preferences of a task. More... | |
gboolean | find_config_with_permission (const char *uuid, config_t *config, const char *permission) |
Find a config for a set of permissions, given a UUID. More... | |
gboolean | find_config_no_acl (const char *uuid, config_t *config) |
Find a config given a UUID. More... | |
gboolean | find_trash_config_no_acl (const char *uuid, config_t *config) |
Find a trash config given a UUID. More... | |
preference_t * | get_nvt_preference_by_id (const char *nvt_oid, const char *find_id, const char *check_name, const char *check_type, const char *value) |
Gets an NVT preference by id or by name. More... | |
static int | config_insert_preferences (config_t config, const array_t *preferences) |
Insert preferences into a config. More... | |
static int | create_config_internal (int check_access, const char *config_id, const char *proposed_name, int make_name_unique, const char *comment, int all_selector, const array_t *selectors, const array_t *preferences, const char *usage_type, int allow_errors, int predefined, config_t *config, char **name) |
Create a config. More... | |
int | create_config (const char *config_id, const char *proposed_name, int make_name_unique, const char *comment, int all_selector, const array_t *selectors, const array_t *preferences, const char *usage_type, config_t *config, char **name) |
Create a config. More... | |
int | create_config_no_acl (const char *config_id, const char *proposed_name, int make_name_unique, const char *comment, int all_selector, const array_t *selectors, const array_t *preferences, const char *usage_type, config_t *config, char **name) |
Create a config. More... | |
gchar * | configs_extra_where (const char *usage_type) |
Generate an extra WHERE clause for selecting configs. More... | |
char * | config_uuid (config_t config) |
Return the UUID of a config. More... | |
int | config_predefined (config_t config) |
Return whether a config is predefined. More... | |
int | trash_config_predefined (config_t config) |
Return whether a trash config is predefined. More... | |
char * | config_nvt_timeout (config_t config, const char *oid) |
Get the timeout value for an NVT in a config. More... | |
int | create_task_check_scanner_type (scanner_t scanner) |
Check if the scanner type is valid for a task. More... | |
int | modify_task_check_config_scanner (task_t task, const char *config_id, const char *scanner_id) |
Check scanner and config values match for a task. More... | |
int | copy_config (const char *name, const char *comment, const char *config_id, const char *usage_type, config_t *new_config) |
Create a config from an existing config. More... | |
int | delete_config (const char *config_id, int ultimate) |
Delete a config. More... | |
int | config_count (const get_data_t *get) |
Count the number of scan configs. More... | |
void | init_user_config_iterator (iterator_t *iterator, config_t config, int trash, int ascending, const char *sort_field) |
Initialise a config iterator, limited to user's configs. More... | |
int | init_config_iterator (iterator_t *iterator, const get_data_t *get) |
Initialise a scan config iterator. More... | |
int | config_iterator_family_count (iterator_t *iterator) |
Get the family count from a config iterator. More... | |
int | config_iterator_nvt_count (iterator_t *iterator) |
Get the nvt count from a config iterator. More... | |
int | config_iterator_families_growing (iterator_t *iterator) |
Get the families growing state from a config iterator. More... | |
int | config_iterator_nvts_growing (iterator_t *iterator) |
Get the NVTs growing state from a config iterator. More... | |
int | config_iterator_predefined (iterator_t *iterator) |
Get predefined status from a config iterator. More... | |
int | config_in_use (config_t config) |
Return whether a config is referenced by a task. More... | |
int | config_writable (config_t config) |
Return whether a config can be modified. More... | |
int | trash_config_in_use (config_t config) |
Return whether a trashcan config is referenced by a task. More... | |
int | trash_config_writable (config_t config) |
Return whether a trashcan config is writable. More... | |
int | trash_config_readable_uuid (const gchar *config_id) |
Return whether a trashcan config is readable. More... | |
void | init_config_preference_iterator (iterator_t *iterator, config_t config) |
Initialise a preference iterator. More... | |
void | init_preference_iterator (iterator_t *iterator, config_t config, const char *section) |
Initialise a config preference iterator, with defaults. More... | |
char * | config_nvt_selector (config_t config) |
Return the NVT selector associated with a config. More... | |
static int | modify_config_preference (config_t config, const char *nvt, const char *name, const char *value_64) |
Update a preference of a config. More... | |
int | manage_set_config_preference (config_t config, const char *nvt, const char *name, const char *value_64) |
Set a preference of a config. More... | |
int | manage_set_config (config_t config, const char *name, const char *comment) |
Set the name and comment of a config. More... | |
int | family_whole_only (const gchar *family) |
Check whether a family is "whole-only". More... | |
int | config_family_entire_and_growing (config_t config, const char *family) |
Get whether a config selects every NVT in a given family. More... | |
int | manage_set_config_nvts (config_t config, const char *family, GPtrArray *selected_nvts) |
Set the NVT's selected for a single family of a config. More... | |
void | init_config_task_iterator (iterator_t *iterator, config_t config, int ascending) |
Initialise a config task iterator. More... | |
int | config_task_iterator_readable (iterator_t *iterator) |
Get the read permission status from a GET iterator. More... | |
void | init_config_timeout_iterator (iterator_t *iterator, config_t config) |
Initialise a config timeout iterator. More... | |
void | update_config_preference (const char *config_id, const char *type, const char *preference_name, const char *new_value, gboolean insert) |
Update or optionally insert a NVT preference. More... | |
static void | update_config_cache (iterator_t *configs) |
Update the cached count and growing information in a config. More... | |
void | update_all_config_caches () |
Update count and growing info in every config across all users. More... | |
void | update_config_cache_init (const char *uuid) |
Update count and growing info in config, without checking user. More... | |
void | migrate_predefined_configs () |
Migrate old ownerless configs to the Feed Owner. | |
int | config_updated_in_feed (config_t config, const gchar *path) |
Check if a config has been updated in the feed. More... | |
void | update_config (config_t config, const gchar *name, const gchar *comment, const gchar *usage_type, int all_selector, const array_t *selectors, const array_t *preferences) |
Update a config from an XML file. More... | |
void | check_db_configs () |
Check configs, for startup. | |
void | check_whole_only_in_configs () |
Check whole-only families. More... | |
int | cleanup_config_sequences () |
Cleans up scan config related id sequences likely to run out. More... | |
GVM management layer: Config SQL.
The Config SQL for the GVM management layer.
int check_config_families | ( | ) |
Ensure that all configs refer to the right NVT families.
When the family of an NVT is changed in the feed, then the config refers to the wrong family.
void check_whole_only_in_configs | ( | ) |
Check whole-only families.
Called after NVT sync.
int cleanup_config_sequences | ( | ) |
Cleans up scan config related id sequences likely to run out.
int config_count | ( | const get_data_t * | get | ) |
Count the number of scan configs.
[in] | get | GET params. |
int config_families_growing | ( | config_t | config | ) |
Get the family growth status of a config.
[in] | config | Config. |
int config_family_entire_and_growing | ( | config_t | config, |
const char * | family | ||
) |
Get whether a config selects every NVT in a given family.
[in] | config | Config. |
[in] | family | Family name. |
int config_in_use | ( | config_t | config | ) |
Return whether a config is referenced by a task.
[in] | config | Config. |
|
static |
Insert preferences into a config.
[in] | config | Config. |
[in] | preferences | Preferences. |
int config_iterator_families_growing | ( | iterator_t * | iterator | ) |
Get the families growing state from a config iterator.
[in] | iterator | Iterator. |
int config_iterator_family_count | ( | iterator_t * | iterator | ) |
Get the family count from a config iterator.
[in] | iterator | Iterator. |
int config_iterator_nvt_count | ( | iterator_t * | iterator | ) |
Get the nvt count from a config iterator.
[in] | iterator | Iterator. |
int config_iterator_nvts_growing | ( | iterator_t * | iterator | ) |
Get the NVTs growing state from a config iterator.
[in] | iterator | Iterator. |
int config_iterator_predefined | ( | iterator_t * | iterator | ) |
Get predefined status from a config iterator.
[in] | iterator | Iterator. |
char* config_nvt_selector | ( | config_t | config | ) |
Return the NVT selector associated with a config.
[in] | config | Config. |
char* config_nvt_timeout | ( | config_t | config, |
const char * | oid | ||
) |
Get the timeout value for an NVT in a config.
[in] | config | Config. |
[in] | oid | ID of NVT. |
int config_nvts_growing | ( | config_t | config | ) |
Get the NVT growth status of a config.
[in] | config | Config. |
int config_predefined | ( | config_t | config | ) |
Return whether a config is predefined.
[in] | config | Config. |
int config_task_iterator_readable | ( | iterator_t * | iterator | ) |
Get the read permission status from a GET iterator.
[in] | iterator | Iterator. |
|
static |
Change the family of an NVT in a config.
[in] | config | Config. |
[in] | oid | NVT OID. |
[in] | old_family | Name of old family. |
[in] | new_family | Name of new family. |
int config_updated_in_feed | ( | config_t | config, |
const gchar * | path | ||
) |
Check if a config has been updated in the feed.
[in] | path | Full path to config XML in feed. |
[in] | config | Config. |
char* config_uuid | ( | config_t | config | ) |
Return the UUID of a config.
[in] | config | Config. |
int config_writable | ( | config_t | config | ) |
Return whether a config can be modified.
[in] | config | Config. |
gchar* configs_extra_where | ( | const char * | usage_type | ) |
Generate an extra WHERE clause for selecting configs.
[in] | usage_type | The usage type to limit the selection to. |
int copy_config | ( | const char * | name, |
const char * | comment, | ||
const char * | config_id, | ||
const char * | usage_type, | ||
config_t * | new_config | ||
) |
Create a config from an existing config.
[in] | name | Name of new config and NVT selector. |
[in] | comment | Comment on new config. |
[in] | config_id | UUID of existing config. |
[in] | usage_type | Optional new usage type for the new config. |
[out] | new_config | New config. |
int create_config | ( | const char * | config_id, |
const char * | proposed_name, | ||
int | make_name_unique, | ||
const char * | comment, | ||
int | all_selector, | ||
const array_t * | selectors, | ||
const array_t * | preferences, | ||
const char * | usage_type, | ||
config_t * | config, | ||
char ** | name | ||
) |
Create a config.
If a config with the same name exists already then add a unique integer suffix onto the name.
[in] | config_id | ID if one is required, else NULL. |
[in] | proposed_name | Proposed name of config. |
[in] | make_name_unique | Whether to make name unique. |
[in] | comment | Comment on config. |
[in] | all_selector | Whether to use "all" selector instead of selectors. |
[in] | selectors | NVT selectors. |
[in] | preferences | Preferences. |
[in] | usage_type | The usage type ("scan" or "policy") |
[out] | config | On success the config. |
[out] | name | On success the name of the config. |
|
static |
Create a config.
If a config with the same name exists already then add a unique integer suffix onto the name.
[in] | check_access | Whether to check for create_config permission. |
[in] | config_id | ID if one is required, else NULL. |
[in] | proposed_name | Proposed name of config. |
[in] | make_name_unique | Whether to make name unique. |
[in] | comment | Comment on config. |
[in] | all_selector | Whether to use "all" selector instead of selectors. |
[in] | selectors | NVT selectors. |
[in] | preferences | Preferences. |
[in] | usage_type | The usage type ("scan" or "policy") |
[in] | allow_errors | Whether certain errors are allowed. |
[in] | predefined | Whether config is predefined. |
[out] | config | On success the config. |
[out] | name | On success the name of the config. |
int create_config_no_acl | ( | const char * | config_id, |
const char * | proposed_name, | ||
int | make_name_unique, | ||
const char * | comment, | ||
int | all_selector, | ||
const array_t * | selectors, | ||
const array_t * | preferences, | ||
const char * | usage_type, | ||
config_t * | config, | ||
char ** | name | ||
) |
Create a config.
If a config with the same name exists already then add a unique integer suffix onto the name.
[in] | config_id | ID if one is required, else NULL. |
[in] | proposed_name | Proposed name of config. |
[in] | make_name_unique | Whether to make name unique. |
[in] | comment | Comment on config. |
[in] | all_selector | Whether to use "all" selector instead of selectors. |
[in] | selectors | NVT selectors. |
[in] | preferences | Preferences. |
[in] | usage_type | The usage type ("scan" or "policy") |
[out] | config | On success the config. |
[out] | name | On success the name of the config. |
int create_task_check_scanner_type | ( | scanner_t | scanner | ) |
Check if the scanner type is valid for a task.
[in] | scanner | Scanner. |
int delete_config | ( | const char * | config_id, |
int | ultimate | ||
) |
Delete a config.
[in] | config_id | UUID of config. |
[in] | ultimate | Whether to remove entirely, or to trashcan. |
|
static |
Check whether a family is selected.
Only works for "generating from empty" selection.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | quoted_family | SQL-quoted family name (NULL for families). |
int family_whole_only | ( | const gchar * | family | ) |
Check whether a family is "whole-only".
[in] | family | Family name. |
gboolean find_config_no_acl | ( | const char * | uuid, |
config_t * | config | ||
) |
Find a config given a UUID.
This does not do any permission checks.
[in] | uuid | UUID of resource. |
[out] | config | Config return, 0 if no such config. |
gboolean find_config_with_permission | ( | const char * | uuid, |
config_t * | config, | ||
const char * | permission | ||
) |
Find a config for a set of permissions, given a UUID.
[in] | uuid | UUID of config. |
[out] | config | Config return, 0 if successfully failed to find config. |
[in] | permission | Permission. |
gboolean find_trash_config_no_acl | ( | const char * | uuid, |
config_t * | config | ||
) |
Find a trash config given a UUID.
This does not do any permission checks.
[in] | uuid | UUID of resource. |
[out] | config | Config return, 0 if no such config. |
preference_t* get_nvt_preference_by_id | ( | const char * | nvt_oid, |
const char * | find_id, | ||
const char * | check_name, | ||
const char * | check_type, | ||
const char * | value | ||
) |
Gets an NVT preference by id or by name.
Note: This currently only gets the fields needed by create_config.
[in] | nvt_oid | OID of the NVT the preference belongs to. |
[in] | find_id | Preference id to find, or NULL. |
[in] | check_name | Preference name to check. |
[in] | check_type | Preference name to check. |
[in] | value | Value to assign to the preference. |
int init_config_iterator | ( | iterator_t * | iterator, |
const get_data_t * | get | ||
) |
Initialise a scan config iterator.
[in] | iterator | Iterator. |
[in] | get | GET data. |
void init_config_preference_iterator | ( | iterator_t * | iterator, |
config_t | config | ||
) |
Initialise a preference iterator.
Assume the caller has permission to access the config.
[in] | iterator | Iterator. |
[in] | config | Config. |
void init_config_task_iterator | ( | iterator_t * | iterator, |
config_t | config, | ||
int | ascending | ||
) |
Initialise a config task iterator.
Iterate over all tasks that use the config.
[in] | iterator | Iterator. |
[in] | config | Config. |
[in] | ascending | Whether to sort ascending or descending. |
void init_config_timeout_iterator | ( | iterator_t * | iterator, |
config_t | config | ||
) |
Initialise a config timeout iterator.
Iterate over all timeout preferences of NVTs that have timeouts.
[in] | iterator | Iterator. |
[in] | config | Config. |
void init_family_iterator | ( | iterator_t * | iterator, |
int | all, | ||
const char * | selector, | ||
int | ascending | ||
) |
Initialise an NVT selector family iterator.
[in] | iterator | Iterator. |
[in] | all | True if families are growing in the selector, else 0. Only considered with a selector. |
[in] | selector | Name of NVT selector. NULL for all families. |
[in] | ascending | Whether to sort ascending or descending. |
void init_nvt_preference_iterator | ( | iterator_t * | iterator, |
const char * | oid | ||
) |
Initialise an NVT preference iterator.
[in] | iterator | Iterator. |
[in] | oid | OID of NVT, NULL for all preferences. |
void init_nvt_selector_iterator | ( | iterator_t * | iterator, |
const char * | selector, | ||
config_t | config, | ||
int | type | ||
) |
Initialise an NVT selector iterator.
[in] | iterator | Iterator. |
[in] | selector | Name of single selector to iterate over, NULL for all. |
[in] | config | Config to limit iteration to, 0 for all. |
[in] | type | Type of selector. All if config is given. |
void init_preference_iterator | ( | iterator_t * | iterator, |
config_t | config, | ||
const char * | section | ||
) |
Initialise a config preference iterator, with defaults.
Assume the caller has permission to access the config.
This version substitutes the NVT preference when the config preference is missing.
[in] | iterator | Iterator. |
[in] | config | Config containing preferences. |
[in] | section | Preference section. |
void init_user_config_iterator | ( | iterator_t * | iterator, |
config_t | config, | ||
int | trash, | ||
int | ascending, | ||
const char * | sort_field | ||
) |
Initialise a config iterator, limited to user's configs.
[in] | iterator | Iterator. |
[in] | config | Config. 0 for all. |
[in] | trash | Whether to iterate over trashcan configs. |
[in] | ascending | Whether to sort ascending or descending. |
[in] | sort_field | Field to sort on, or NULL for "id". |
|
static |
Insert NVT selectors.
[in] | quoted_name | Name of NVT selector. |
[in] | selectors | NVT selectors. |
[in] | allow_errors | Whether certain errors are allowed. |
int manage_modify_config_start | ( | const char * | config_id, |
config_t * | config_out | ||
) |
Starts the SQL transaction for modify_config and finds the config.
[in] | config_id | UUID of the config to find. |
[out] | config_out | Row ID of the config or 0 if not found. |
void manage_nvt_preference_add | ( | const char * | name, |
const char * | value | ||
) |
Add/replace an NVT preference.
[in] | name | The name of the preference. |
[in] | value | The value of the preference. |
int manage_set_config | ( | config_t | config, |
const char * | name, | ||
const char * | comment | ||
) |
Set the name and comment of a config.
[in] | config | Config to modify. |
[in] | name | New name, not updated if NULL. |
[in] | comment | New comment, not updated if NULL. |
int manage_set_config_families | ( | config_t | config, |
GPtrArray * | growing_all_families, | ||
GPtrArray * | static_all_families, | ||
GPtrArray * | growing_families, | ||
int | grow_families, | ||
gchar ** | rejected_family | ||
) |
Refresh NVT selection of a config from given families.
[in] | config | Config to modify. |
[in] | growing_all_families | Growing families with all selection. |
[in] | static_all_families | Static families with all selection. |
[in] | growing_families | The rest of the growing families. |
[in] | grow_families | 1 if families should grow, else 0. |
[out] | rejected_family | Return of family if one was rejected. |
int manage_set_config_nvts | ( | config_t | config, |
const char * | family, | ||
GPtrArray * | selected_nvts | ||
) |
Set the NVT's selected for a single family of a config.
[in] | config | Config to modify. |
[in] | family | Family name. |
[in] | selected_nvts | NVT's. |
int manage_set_config_preference | ( | config_t | config, |
const char * | nvt, | ||
const char * | name, | ||
const char * | value_64 | ||
) |
Set a preference of a config.
[in] | config | Config to modify. |
[in] | nvt | UUID of NVT. NULL for scanner preference. |
[in] | name | Preference name, including NVT name and preference type. |
[in] | value_64 | Preference value in base64. NULL for an NVT preference removes the preference from the config. |
|
static |
Test whether a string equal to a given string exists in an array.
[in] | array | Array of gchar* pointers. |
[in] | string | String. |
|
static |
Update a preference of a config.
[in] | config | Config. |
[in] | nvt | UUID of NVT. NULL for scanner preference. |
[in] | name | Preference name, including NVT name and preference type. |
[in] | value_64 | Preference value in base64. NULL for an NVT preference removes the preference from the config. |
int modify_task_check_config_scanner | ( | task_t | task, |
const char * | config_id, | ||
const char * | scanner_id | ||
) |
Check scanner and config values match for a task.
[in] | task | Task. |
[in] | config_id | ID of config. "0" to use task's config. |
[in] | scanner_id | ID of scanner. |
int nvt_preference_count | ( | const char * | oid | ) |
Get the number preferences available for an NVT.
[in] | oid | OID of NVT. |
char* nvt_preference_iterator_config_value | ( | iterator_t * | iterator, |
config_t | config | ||
) |
Get the config value from an NVT preference iterator.
[in] | iterator | Iterator. |
[in] | config | Config. |
char* nvt_preference_iterator_id | ( | iterator_t * | iterator | ) |
Get the ID from an NVT preference iterator.
[in] | iterator | Iterator. |
char* nvt_preference_iterator_oid | ( | iterator_t * | iterator | ) |
Get the NVT from an NVT preference iterator.
[in] | iterator | Iterator. |
char* nvt_preference_iterator_real_name | ( | iterator_t * | iterator | ) |
Get the real name from an NVT preference iterator.
[in] | iterator | Iterator. |
char* nvt_preference_iterator_type | ( | iterator_t * | iterator | ) |
Get the type from an NVT preference iterator.
[in] | iterator | Iterator. |
|
static |
Add a selector to an NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | quoted_family_or_nvt | SQL-quoted family or NVT name. |
[in] | quoted_family | SQL-quoted family name (NULL for families). |
[in] | exclude | 1 exclude selector, 0 include selector. |
|
static |
Get whether an NVT selector selects every NVT in a family.
[in] | selector | NVT selector. |
[in] | family | Family name. |
[in] | all | True if selector is an "all" selector, else 0. |
|
static |
Get the family growth status of an NVT selector.
[in] | selector | NVT selector. |
int nvt_selector_family_count | ( | const char * | quoted_selector, |
int | families_growing | ||
) |
Get the number of families selected by an NVT selector.
A growing family which has all current NVT's excluded is still considered as selected by the NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | families_growing | 1 if families are growing, else 0. |
int nvt_selector_family_growing | ( | const char * | selector, |
const char * | family, | ||
int | all | ||
) |
Get whether an NVT selector family is growing.
[in] | selector | NVT selector. |
[in] | family | Family name. |
[in] | all | True if selector is an "all" selector, else 0. |
|
static |
Check whether an NVT selector has a particular selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | family_or_nvt | SQL-quoted UUID of NVT, or family name. |
[in] | type | Selector type. |
[in] | exclude | 1 exclude, 0 include. |
int nvt_selector_iterator_include | ( | iterator_t * | iterator | ) |
Get whether the selector rule is an include rule.
[in] | iterator | Iterator. |
int nvt_selector_iterator_type | ( | iterator_t * | iterator | ) |
Get the type from an NVT selector.
[in] | iterator | Iterator. |
int nvt_selector_nvt_count | ( | const char * | selector, |
const char * | family, | ||
int | growing | ||
) |
Get the number of NVTs selected by an NVT selector.
[in] | selector | NVT selector. |
[in] | family | Family name. NULL for all. |
[in] | growing | True if the given family is growing, else 0. If family is NULL, true if the the families are growing, else 0. |
|
static |
Get the NVT growth status of an NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | families_growing | 1 if families are growing, else 0. |
|
static |
Remove all selectors of a certain family from an NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | quoted_family | SQL-quoted family name. |
[in] | type | Selector type to remove. |
|
static |
Remove all selectors of a certain type from an NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | family_or_nvt | SQL-quoted family name or NVT UUID. |
[in] | type | Selector type to remove. |
|
static |
Set the family of an NVT selector.
[in] | quoted_selector | SQL-quoted selector name. |
[in] | family_or_nvt | Family name or NVT OID of selector. |
[in] | type | Selector type to remove. |
[in] | family | New family. |
int set_task_preferences | ( | task_t | task, |
array_t * | preferences | ||
) |
Set the preferences of a task.
Only the given preferences are affected. A NULL value means to remove the preference (reverts to using scanner value).
[in] | task | Task. |
[in] | preferences | Preferences. |
|
static |
Switch between constraining and generating representation.
It's up to the caller to start and end a transaction.
[in] | config | Config name. |
[in] | constraining | 1 families currently growing, 0 families currently static. |
int sync_configs_with_feed | ( | gboolean | rebuild | ) |
Sync all configs with the feed.
Create configs that exists in the feed but not in the db. Update configs in the db that have changed on the feed. Do nothing to configs in db that have been removed from the feed.
[in] | rebuild | Whether ignore timestamps to force a rebuild. |
char* task_preference_value | ( | task_t | task, |
const char * | name | ||
) |
Get the value of a task preference.
[in] | task | Task. |
[in] | name | Preference name. |
int trash_config_in_use | ( | config_t | config | ) |
Return whether a trashcan config is referenced by a task.
[in] | config | Config. |
int trash_config_predefined | ( | config_t | config | ) |
Return whether a trash config is predefined.
[in] | config | Config. |
int trash_config_readable_uuid | ( | const gchar * | config_id | ) |
Return whether a trashcan config is readable.
[in] | config_id | Config UUID. |
int trash_config_writable | ( | config_t | config | ) |
Return whether a trashcan config is writable.
[in] | config | Config. |
void update_all_config_caches | ( | ) |
Update count and growing info in every config across all users.
It's up to the caller to organise a transaction.
void update_config | ( | config_t | config, |
const gchar * | name, | ||
const gchar * | comment, | ||
const gchar * | usage_type, | ||
int | all_selector, | ||
const array_t * | selectors, | ||
const array_t * | preferences | ||
) |
Update a config from an XML file.
[in] | config | Existing config. |
[in] | name | New name. |
[in] | comment | New comment. |
[in] | usage_type | New usage type. |
[in] | all_selector | Whether to use "all" selector instead of selectors. |
[in] | selectors | New NVT selectors. |
[in] | preferences | New preferences. |
|
static |
Update the cached count and growing information in a config.
It's up to the caller to organise a transaction.
[in] | configs | Config to update. |
void update_config_cache_init | ( | const char * | uuid | ) |
Update count and growing info in config, without checking user.
For use during initialisation.
[in] | uuid | Config UUID. |
It's up to the caller to organise a transaction.
|
static |
Update the cached count and growing information in every config.
Only consider configs for the current user.
It's up to the caller to organise a transaction.
[in] | config | Config to update. 0 for all. |
void update_config_preference | ( | const char * | config_id, |
const char * | type, | ||
const char * | preference_name, | ||
const char * | new_value, | ||
gboolean | insert | ||
) |
Update or optionally insert a NVT preference.
[in] | config_id | UUID of the config to set the preference in |
[in] | type | Type of the preference, e.g. "PLUGINS_PREFS" |
[in] | preference_name | Full name of the preference |
[in] | new_value | The new value to set |
[in] | insert | Whether to insert the preference if missing |
|
static |
Change the family of an NVT in all configs.
[in] | oid | NVT OID. |
[in] | old_family | Name of old family. |
[in] | new_family | Name of new family. |