Greenbone Vulnerability Manager  8.0.1~git
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
manage_sql.c File Reference

The Greenbone Vulnerability Manager management library (SQLite implementation). More...

#include "manage_sql.h"
#include "manage_sql_secinfo.h"
#include "manage_sql_nvts.h"
#include "manage_tickets.h"
#include "manage_sql_tickets.h"
#include "manage_acl.h"
#include "lsc_user.h"
#include "sql.h"
#include "scanner.h"
#include "utils.h"
#include "gmp_get.h"
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <glib/gstdio.h>
#include <locale.h>
#include <pwd.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/time.h>
#include <grp.h>
#include <gpgme.h>
#include <gvm/base/hosts.h>
#include <gvm/base/pwpolicy.h>
#include <gvm/base/logging.h>
#include <gvm/base/proctitle.h>
#include <gvm/util/fileutils.h>
#include <gvm/util/gpgmeutils.h>
#include <gvm/util/serverutils.h>
#include <gvm/util/uuidutils.h>
#include <gvm/util/radiusutils.h>
#include <gvm/util/sshutils.h>
#include <gvm/util/authutils.h>
#include <gvm/util/ldaputils.h>
#include <gvm/gmp/gmp.h>

Data Structures

struct  result_buffer
 Some result info, for sorting. More...
 

Macros

#define _GNU_SOURCE
 Enable extra GNU functions.
 
#define G_LOG_DOMAIN   "md manage"
 GLib log domain.
 
#define OPENVASSD_ADDRESS   GVM_RUN_DIR "/openvassd.sock"
 Scanner (openvassd) address.
 
#define MAX_CONTENT_LENGTH   20000
 Default max number of bytes of reports included in email alerts.
 
#define MAX_ATTACH_LENGTH   1048576
 Default max number of bytes of reports attached to email alerts.
 
#define MAX_EMAIL_MESSAGE_LENGTH   2000
 Default max number of bytes of user-defined message in email alerts.
 
#define AGGREGATE_ITERATOR_OFFSET   3
 Offset for aggregate iterator.
 
#define AGGREGATE_ITERATOR_N_STATS   4
 Number of stats, for aggregate iterator.
 
#define ALERT_ITERATOR_FILTER_COLUMNS
 Filter columns for alert iterator. More...
 
#define ALERT_ITERATOR_COLUMNS
 Alert iterator columns. More...
 
#define ALERT_ITERATOR_TRASH_COLUMNS
 Alert iterator columns for trash case. More...
 
#define APPEND_VFIRE_PARAM(param)
 Checks a mandatory vFire parameter and adds it to the config XML. More...
 
#define SIMPLE_NOTICE_FORMAT
 Format string for simple notice alert email. More...
 
#define SECINFO_SIMPLE_NOTICE_FORMAT
 Format string for simple notice alert email. More...
 
#define NEW_NVTS_HEADER
 Header for "New NVTs" alert message. More...
 
#define NEW_NVTS_HEADER_OID
 Header for "New NVTs" alert message, when there's an OID. More...
 
#define NEW_CVES_HEADER
 Header for "New CVEs" alert message. More...
 
#define NEW_CPES_HEADER
 Header for "New CPEs" alert message. More...
 
#define NEW_CERT_BUNDS_HEADER
 Header for "New CERT-Bund Advisories" alert message. More...
 
#define NEW_DFN_CERTS_HEADER
 Header for "New DFN-CERT Advisories" alert message. More...
 
#define NEW_OVAL_DEFS_HEADER
 Header for "New CERT-Bund Advisories" alert message. More...
 
#define TASK_ITERATOR_FILTER_COLUMNS
 Filter columns for task iterator. More...
 
#define TASK_ITERATOR_COLUMNS_INNER
 Task iterator columns.
 
#define TASK_ITERATOR_WHERE_COLUMNS_INNER
 Task iterator WHERE columns.
 
#define TASK_ITERATOR_WHERE_COLUMNS
 Task iterator WHERE columns. More...
 
#define TASK_ITERATOR_COLUMNS
 Task iterator columns. More...
 
#define TASK_ITERATOR_COLUMNS_MIN
 Task iterator minimal columns. More...
 
#define TASK_ITERATOR_WHERE_COLUMNS_MIN
 Task iterator minimal WHERE columns. More...
 
#define RANGE(type, start, end)
 Insert a port range. More...
 
#define CREATE_REPORT_INSERT_SIZE   300
 Maximum number of values per insert, when uploading report.
 
#define CREATE_REPORT_CHUNK_SIZE   10
 Number of results per transaction, when uploading report.
 
#define CREATE_REPORT_CHUNK_SLEEP   1000
 Number of microseconds to sleep between insert chunks.
 
#define REPORT_ITERATOR_FILTER_COLUMNS
 Filter columns for report iterator. More...
 
#define REPORT_ITERATOR_COLUMNS
 Report iterator columns. More...
 
#define REPORT_ITERATOR_WHERE_COLUMNS
 Report iterator columns.
 
#define CVSS_BASE_SQL   "(SELECT cvss_base FROM nvts WHERE nvts.oid = results.nvt)"
 SQL for retrieving CVSS base.
 
#define RESULT_ITERATOR_FILTER_COLUMNS
 Filter columns for result iterator. More...
 
#define BASE_RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE
 Result iterator filterable columns, for severity only version .
 
#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE
 Result iterator columns. More...
 
#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE_NO_CERT
 Result iterator columns, when CERT db is not loaded. More...
 
#define BASE_RESULT_ITERATOR_COLUMNS
 Result iterator columns.
 
#define RESULT_ITERATOR_COLUMNS
 Result iterator columns. More...
 
#define RESULT_ITERATOR_COLUMNS_NO_CERT
 Result iterator columns, when CERT db is not loaded. More...
 
#define PRINT(stream, format, args...)
 Write to a file or close stream and exit. More...
 
#define PRINT_XML(stream, xml)
 Write XML to a file or close stream and return. More...
 
#define PRINT_REPORT_ERROR(stream, errors, asset_id)
 Write report error message to file stream. More...
 
#define MANAGE_SEND_REPORT_CHUNK64_SIZE   262144
 Size of base64 chunk in manage_send_report.
 
#define MANAGE_SEND_REPORT_CHUNK_SIZE   (MANAGE_SEND_REPORT_CHUNK64_SIZE * 3 / 4)
 Size of file chunk in manage_send_report.
 
#define TARGET_ITERATOR_FILTER_COLUMNS
 Filter columns for target iterator. More...
 
#define TARGET_ITERATOR_COLUMNS
 Target iterator columns.
 
#define TARGET_ITERATOR_TRASH_COLUMNS
 Target iterator columns for trash case.
 
#define CONFIG_ITERATOR_FILTER_COLUMNS
 Filter columns for scan configs iterator. More...
 
#define CONFIG_ITERATOR_COLUMNS
 Scan config iterator columns. More...
 
#define CONFIG_ITERATOR_TRASH_COLUMNS
 Scan config iterator columns for trash case. More...
 
#define PASSWORD_LENGTH   10
 Length of password generated in create_credential.
 
#define CREDENTIAL_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "login", "type", "allow_insecure", NULL }
 Filter columns for LSC Credential iterator.
 
#define CREDENTIAL_ITERATOR_COLUMNS
 LSC Credential iterator columns.
 
#define CREDENTIAL_ITERATOR_TRASH_COLUMNS
 LSC Credential iterator columns for trash case.
 
#define AGENT_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "trust", NULL }
 Filter columns for agent iterator.
 
#define AGENT_ITERATOR_COLUMNS
 Agent iterator columns. More...
 
#define AGENT_ITERATOR_TRASH_COLUMNS
 Agent iterator columns for trash case. More...
 
#define NOTE_ITERATOR_FILTER_COLUMNS
 Filter columns for note iterator. More...
 
#define NOTE_ITERATOR_COLUMNS
 Note iterator columns.
 
#define NOTE_ITERATOR_TRASH_COLUMNS
 Note iterator columns for trash case.
 
#define OVERRIDE_ITERATOR_FILTER_COLUMNS
 Filter columns for override iterator. More...
 
#define OVERRIDE_ITERATOR_COLUMNS
 Override iterator columns.
 
#define OVERRIDE_ITERATOR_TRASH_COLUMNS
 Override iterator columns for trash case.
 
#define SCANNER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "host", "port", "type", NULL }
 Filter columns for scanner iterator.
 
#define SCANNER_ITERATOR_COLUMNS
 Scanner iterator columns. More...
 
#define SCANNER_ITERATOR_TRASH_COLUMNS
 Scanner iterator columns for trash case. More...
 
#define SCHEDULE_ITERATOR_FILTER_COLUMNS
 Filter columns for schedule iterator. More...
 
#define SCHEDULE_ITERATOR_COLUMNS
 Schedule iterator columns. More...
 
#define SCHEDULE_ITERATOR_TRASH_COLUMNS
 Schedule iterator columns for trash case. More...
 
#define REPORT_FORMAT_ITERATOR_FILTER_COLUMNS
 
#define REPORT_FORMAT_ITERATOR_COLUMNS
 
#define REPORT_FORMAT_ITERATOR_TRASH_COLUMNS
 
#define GROUP_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }
 
#define GROUP_ITERATOR_COLUMNS
 
#define GROUP_ITERATOR_TRASH_COLUMNS
 
#define PERMISSION_ITERATOR_FILTER_COLUMNS
 
#define PERMISSION_ITERATOR_COLUMNS
 
#define PERMISSION_ITERATOR_TRASH_COLUMNS
 
#define PORT_LIST_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "total", "tcp", "udp", NULL }
 
#define PORT_LIST_ITERATOR_COLUMNS
 
#define PORT_LIST_ITERATOR_TRASH_COLUMNS
 
#define ROLE_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }
 
#define ROLE_ITERATOR_COLUMNS
 
#define ROLE_ITERATOR_TRASH_COLUMNS
 
#define FILTER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "type", "term", NULL }
 
#define FILTER_ITERATOR_COLUMNS
 
#define FILTER_ITERATOR_TRASH_COLUMNS
 
#define WHERE_OWNER
 
#define HOST_ITERATOR_FILTER_COLUMNS
 
#define HOST_ITERATOR_COLUMNS
 
#define HOST_ITERATOR_WHERE_COLUMNS
 
#define OS_ITERATOR_FILTER_COLUMNS
 
#define OS_ITERATOR_COLUMNS
 
#define OS_ITERATOR_WHERE_COLUMNS
 
#define SETTING_ITERATOR_FILTER_COLUMNS   { "name", "comment", "value", NULL }
 
#define SETTING_ITERATOR_COLUMNS
 
#define USER_ITERATOR_FILTER_COLUMNS
 
#define USER_ITERATOR_COLUMNS
 
#define USER_ITERATOR_TRASH_COLUMNS
 
#define VULN_ITERATOR_FILTER_COLUMNS
 
#define VULN_RESULTS_WHERE
 
#define VULN_ITERATOR_COLUMNS
 
#define TAG_ITERATOR_FILTER_COLUMNS
 
#define TAG_ITERATOR_COLUMNS
 
#define TAG_ITERATOR_TRASH_COLUMNS
 
#define TAG_NAME_ITERATOR_FILTER_COLUMNS   { "name", "resource_type", NULL }
 
#define TAG_NAME_ITERATOR_COLUMNS
 

Typedefs

typedef struct result_buffer result_buffer_t
 Buffer host type.
 

Enumerations

enum  compare_results_t {
  COMPARE_RESULTS_CHANGED, COMPARE_RESULTS_ERROR, COMPARE_RESULTS_GONE, COMPARE_RESULTS_NEW,
  COMPARE_RESULTS_SAME
}
 Comparison returns.
 
enum  report_format_flag_t { REPORT_FORMAT_FLAG_ACTIVE = 1 }
 Possible port types.
 

Functions

int manage_create_sql_functions ()
 Create functions. More...
 
void create_tables ()
 Create all tables.
 
void check_db_sequences ()
 Ensure sequences for automatic ids are in a consistent state. More...
 
static int check_db_encryption_key ()
 Ensure that there is an encryption key. More...
 
void manage_attach_databases ()
 Attach external databases.
 
const char * threat_message_type (const char *)
 Get the message type of a threat. More...
 
const char * message_type_threat (const char *)
 Get the threat of a message type. More...
 
int delete_reports (task_t)
 Delete all the reports for a task. More...
 
int delete_slave_task (const gchar *, int, const gchar *, const gchar *, const char *)
 Delete a task on a slave. More...
 
int set_certs (const char *, const char *, const char *)
 Initialise OpenVAS scanner variables, checking for defaults. More...
 
gchar * predefined_report_format_dir (const gchar *)
 Get the directory of a report format. More...
 
int stop_task_internal (task_t)
 Initiate stopping a task. More...
 
int validate_username (const gchar *)
 Validates a username. More...
 
void set_task_interrupted (task_t, const gchar *)
 Set a task to interrupted. More...
 
void make_port_ranges_iana_tcp_2012 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_iana_tcp_udp_2012 (port_list_t)
 Make port ranges for IANA TCP and UDP 2012. More...
 
void make_port_ranges_all_tcp_nmap_5_51_top_100 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_all_tcp_nmap_5_51_top_1000 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_nmap_5_51_top_2000_top_100 (port_list_t)
 Make port ranges for Nmap top 2000 top 100. More...
 
void make_config_discovery (char *const, char *const)
 Make Discovery Scan Config. More...
 
void make_config_discovery_service_detection (char *const)
 Make Discovery Scan Config. More...
 
void make_config_host_discovery (char *const, char *const)
 Make Host Discovery Scan Config. More...
 
void make_config_system_discovery (char *const, char *const)
 Make System Discovery Scan Config. More...
 
int check_config_discovery (const char *)
 Ensure the Discovery config is up to date. More...
 
void check_config_host_discovery (const char *)
 Ensure the Host Discovery config is up to date. More...
 
int check_config_system_discovery (const char *)
 Ensure the Discovery config is up to date. 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_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 update_config_caches (config_t config)
 Update the cached count and growing information in every config. More...
 
int family_count ()
 Get the number of families. More...
 
static int report_counts_cache_exists (report_t report, int override, int min_qod)
 Test if a counts cache exists for a report and the current user. More...
 
static void report_severity_data (report_t report, const char *host, const get_data_t *get, severity_data_t *severity_data, severity_data_t *filtered_severity_data)
 Get the result severity counts for a report. More...
 
static gchar * apply_report_format (gchar *report_format_id, gchar *xml_start, gchar *xml_file, gchar *xml_dir, GList **used_rfps)
 Applies a report format to an XML report. More...
 
static int cache_report_counts (report_t report, int override, int min_qod, severity_data_t *data)
 Cache the message counts for a report. More...
 
static char * task_owner_uuid (task_t task)
 Return the name of the owner of a task. More...
 
static int insert_nvt_selectors (const char *quoted_name, const array_t *selectors)
 Insert NVT selectors. More...
 
static int validate_param_value (report_format_t report_format, report_format_param_t param, const char *name, const char *value)
 Validate a value for a report format param. More...
 
gchar * clean_hosts (const char *given_hosts, int *max)
 Clean a hosts string. More...
 
static int create_port_list_unique (const char *, const char *, const char *, port_list_t *)
 
static int valid_type (const char *type)
 Check whether a resource type name is valid. More...
 
static gboolean find_user_by_name (const char *, user_t *user)
 
static gboolean find_role_with_permission (const char *, role_t *, const char *)
 
static int user_ensure_in_db (const gchar *name, const gchar *method)
 Ensure the user exists in the database. More...
 
static int verify_report_format_internal (report_format_t)
 
static void cleanup_prognosis_iterator ()
 Cleanup the prognosis iterator prepared statement.
 
static int set_password (const gchar *, const gchar *, const gchar *, gchar **)
 
static void permissions_set_subjects (const char *, resource_t, resource_t, int)
 
static resource_t permission_resource (permission_t)
 
static resource_t permission_subject (permission_t)
 
static char * permission_subject_type (permission_t)
 
static int role_is_predefined (role_t)
 
static int role_is_predefined_id (const char *)
 
static int task_second_last_report (task_t task, report_t *report)
 Get the report from second most recently completed invocation of task. More...
 
static gchar * new_secinfo_message (event_t event, const void *event_data, alert_t alert)
 Create message for New NVTs event. More...
 
static gchar * new_secinfo_list (event_t event, const void *event_data, alert_t alert, int *count_return)
 Create message for New NVTs event. More...
 
static void check_for_new_scap ()
 Check for new SCAP SecInfo after an update.
 
static void check_for_new_cert ()
 Check for new CERT SecInfo after an update.
 
static void check_for_updated_scap ()
 Check for updated SCAP SecInfo after an update.
 
static void check_for_updated_cert ()
 Check for updated CERT SecInfo after an update.
 
static gchar * results_extra_where (int trash, report_t report, const gchar *host, int autofp, int apply_overrides, int dynamic_severity, const gchar *filter)
 Get extra_where string for a result iterator or count. More...
 
static int report_counts_id_full (report_t report, int *debugs, int *holes, int *infos, int *logs, int *warnings, int *false_positives, double *severity, const get_data_t *get, const char *host, int *filtered_debugs, int *filtered_holes, int *filtered_infos, int *filtered_logs, int *filtered_warnings, int *filtered_false_positives, double *filtered_severity)
 Get the message counts for a report. More...
 
static int check_report_format (const gchar *)
 
static gboolean find_group_with_permission (const char *, group_t *, const char *)
 
static gchar * vulns_extra_where ()
 
static gboolean lookup_report_format (const char *name, report_format_t *report_format)
 Find a report format given a name. More...
 
static int task_last_report_any_status (task_t task, report_t *report)
 Get the report from the most recently invocation of task. More...
 
static int task_report_previous (task_t task, report_t report, report_t *previous)
 Get most recently completed report that precedes a report. More...
 
static gboolean find_trash_task (const char *uuid, task_t *task)
 Find a task in the trashcan, given an identifier. More...
 
static gboolean find_trash_report_with_permission (const char *uuid, report_t *report, const char *permission)
 Find a report in the trashcan for a specific permission, given a UUID. More...
 
static int cleanup_schedule_times ()
 Fixes the DST offset in schedule_next_time of tasks. 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...
 
static char * permission_name (permission_t)
 
static int port_list_is_predefined (port_list_t)
 
static void cache_permissions_for_resource (const char *, resource_t, GArray *)
 
static port_protocol_t port_range_iterator_type_int (iterator_t *iterator)
 
static void cache_all_permissions_for_users (GArray *)
 
static void report_cache_counts (report_t report, int clear_original, int clear_overridden, const char *users_where)
 Cache report counts and clear existing caches if requested. More...
 
static int report_host_dead (report_host_t)
 
static int report_host_result_count (report_host_t)
 
static int set_credential_data (credential_t credential, const char *type, const char *value)
 Set data for a credential. More...
 
static void set_credential_name (credential_t credential, const char *name)
 Set the name of a Credential. More...
 
static void set_credential_comment (credential_t credential, const char *comment)
 Set the comment of a Credential. More...
 
static void set_credential_login (credential_t credential, const char *login)
 Set the login of a Credential. More...
 
static void set_credential_certificate (credential_t credential, const char *certificate)
 Set the certificate of a Credential. More...
 
static void set_credential_auth_algorithm (credential_t credential, const char *algorithm)
 Set the auth_algorithm of a Credential. More...
 
static void set_credential_private_key (credential_t credential, const char *private_key, const char *passphrase)
 Set the private key and passphrase of a Credential. More...
 
static void set_credential_password (credential_t credential, const char *password)
 Set the password of a Credential. More...
 
static void set_credential_snmp_secret (credential_t credential, const char *community, const char *password, const char *privacy_password)
 Set the community, password and privacy password of a Credential. More...
 
static int setting_value_int (const char *, int *)
 
static int setting_auto_cache_rebuild_int ()
 
static double setting_default_severity_dbl ()
 
static int setting_dynamic_severity_int ()
 
static char * setting_timezone ()
 
static int setting_value (const char *, char **)
 
static void set_report_format_name (report_format_t report_format, const char *name)
 Set the name of the report format. More...
 
static void set_report_format_summary (report_format_t report_format, const char *summary)
 Set the summary of the report format. More...
 
static void set_report_format_active (report_format_t report_format, int active)
 Set the active flag of a report format. More...
 
static int set_report_format_param (report_format_t, const char *, const char *)
 
static double task_severity_double (task_t task, int overrides, int min_qod, int offset)
 Return the severity score of a task, taking overrides into account. More...
 
static char * target_comment (target_t target)
 Return the comment of a target. More...
 
static column_ttype_select_columns (const char *type)
 
static column_ttype_where_columns (const char *type)
 
static char * trash_filter_uuid (filter_t)
 
static char * trash_filter_name (filter_t)
 
static char * trash_target_hosts (target_t target)
 Return the hosts associated with a trashcan target. More...
 
static char * trash_target_exclude_hosts (target_t target)
 Return the excluded hosts associated with a trashcan target. More...
 
static char * trash_target_comment (target_t target)
 Return the comment of a trashcan target. More...
 
static int user_resources_in_use (user_t, const char *, int(*)(resource_t), const char *, int(*)(resource_t))
 
static const char ** type_filter_columns (const char *)
 
static int type_build_select (const char *, const char *, const get_data_t *, gboolean, gboolean, const char *, const char *, const char *, gchar **)
 
int valid_gmp_command (const char *name)
 Check whether a command name is valid. More...
 
static gchar * gmp_command_type (const char *name)
 Get the type associated with a GMP command. More...
 
static int gmp_command_takes_resource (const char *name)
 Check whether a GMP command takes a resource. More...
 
gboolean resource_with_name_exists (const char *name, const char *type, resource_t resource)
 Check if a resource with a certain name exists already. More...
 
static gboolean resource_with_name_exists_global (const char *name, const char *type, resource_t resource)
 Check if a resource with a certain name exists already. More...
 
static int member (GPtrArray *array, const char *string)
 Test whether a string equal to a given string exists in an array. More...
 
static void array_add_new_string (array_t *array, const gchar *string)
 Ensure a string is in an array. More...
 
gboolean find_trash (const char *type, const char *uuid, resource_t *resource)
 Find a resource in the trashcan given a UUID. More...
 
int parse_iso_time (const char *text_time)
 Convert an ISO time into seconds since epoch. More...
 
static gchar * array_find_string (array_t *array, const gchar *string)
 Find a string in an array. More...
 
static const gchar * vector_find_string (const gchar **vector, const gchar *string)
 Find a string in a glib style string vector. More...
 
static int vector_find_filter (const gchar **vector, const gchar *string)
 Find a filter string in a glib style string vector. More...
 
gchar * tag_value (const gchar *tags, const gchar *tag)
 Extract a tag from an OTP tag list. More...
 
static int nvts_check_time ()
 Get last time NVT alerts were checked. More...
 
static int scap_check_time ()
 Get last time SCAP SecInfo alerts were checked. More...
 
static int cert_check_time ()
 Get last time CERT SecInfo alerts were checked. More...
 
int manage_option_setup (GSList *log_config, const gchar *database)
 Setup for an option process. More...
 
void manage_option_cleanup ()
 Cleanup for an option process.
 
static column_tcolumn_array_copy (column_t *columns)
 Copy an array of columns. More...
 
static void column_array_free (column_t *columns)
 Free an array of columns. More...
 
static void column_array_set (column_t *columns, const gchar *filter, gchar *select)
 Set the select clause of a column in an array of columns. More...
 
const char * keyword_relation_symbol (keyword_relation_t relation)
 Get the symbol of a keyword relation. More...
 
static void keyword_free (keyword_t *keyword)
 Free a keyword. More...
 
int keyword_special (keyword_t *keyword)
 Get whether a keyword is special (like "and"). More...
 
static keyword_relation_t parse_column_relation (const char relation)
 Parse a filter column relation. More...
 
static void parse_keyword (keyword_t *keyword)
 Parse a filter keyword. More...
 
static void cleanup_keyword (keyword_t *keyword)
 Cleans up keywords with special conditions and relations. More...
 
static int keyword_applies (array_t *array, const keyword_t *keyword)
 Check whether a keyword has any effect in the filter. More...
 
void filter_free (array_t *split)
 Free a split filter. More...
 
void split_filter_add_specials (array_t *parts, const gchar *given_filter)
 Ensure filter parts contains the special keywords. More...
 
array_t * split_filter (const gchar *given_filter)
 Split the filter term into parts. More...
 
void manage_filter_controls (const gchar *filter, int *first, int *max, gchar **sort_field, int *sort_order)
 Get info from a filter. More...
 
static int filter_control_int (keyword_t **point, const char *column, int *val)
 Get an int column from a filter split. More...
 
static int filter_control_str (keyword_t **point, const char *column, gchar **string)
 Get a string column from a filter split. More...
 
void manage_report_filter_controls (const gchar *filter, int *first, int *max, gchar **sort_field, int *sort_order, int *result_hosts_only, gchar **min_qod, gchar **levels, gchar **delta_states, gchar **search_phrase, int *search_phrase_exact, int *autofp, int *notes, int *overrides, int *apply_overrides, gchar **zone)
 Get info from a filter for report. More...
 
static void append_relation (GString *clean, keyword_t *keyword, const char relation)
 Append relation to filter. More...
 
gchar * manage_clean_filter_remove (const gchar *filter, const gchar *column)
 Clean a filter, removing a keyword in the process. More...
 
gchar * manage_clean_filter (const gchar *filter)
 Clean a filter. More...
 
static const char * get_join (int first, int last_was_and, int last_was_not)
 Return SQL join words for filter_clause. More...
 
static gchar * columns_select_column_single (column_t *select_columns, const char *filter_column, keyword_type_t *type)
 Get the column expression for a filter column. More...
 
static gchar * columns_select_column (column_t *select_columns, column_t *where_columns, const char *filter_column)
 Get the selection term for a filter column. More...
 
static gchar * columns_select_column_with_type (column_t *select_columns, column_t *where_columns, const char *filter_column, keyword_type_t *type)
 Get the selection term for a filter column. More...
 
gchar * columns_build_select (column_t *select_columns)
 Return column list for SELECT statement. More...
 
static int keyword_applies_to_column (keyword_t *keyword, const char *column)
 Check whether a keyword applies to a column. More...
 
static void filter_clause_append_tag (GString *clause, keyword_t *keyword, const char *type, int first_keyword, int last_was_and, int last_was_not)
 Append parts for a "tag" keyword to a filter clause. More...
 
static void filter_clause_append_tag_id (GString *clause, keyword_t *keyword, const char *type, int first_keyword, int last_was_and, int last_was_not)
 Append parts for a "tag_id" keyword to a filter clause. More...
 
gchar * filter_clause (const char *type, const char *filter, const char **filter_columns, column_t *select_columns, column_t *where_columns, int trash, gchar **order_return, int *first_return, int *max_return, array_t **permissions, gchar **owner_filter)
 Return SQL WHERE clause for restricting a SELECT to a filter term. More...
 
static const char * type_db_name (const char *type)
 Return DB name of type. More...
 
static int type_is_asset_subtype (const char *type)
 Check whether a resource type is an asset subtype. More...
 
static int type_is_info_subtype (const char *type)
 Check whether a resource type is an info subtype, excluding allinfo. More...
 
static int type_named (const char *type)
 Check whether a type has a name and comment. More...
 
static int type_has_comment (const char *type)
 Check whether a type has a comment. More...
 
static int type_has_trash (const char *type)
 Check whether a resource type uses the trashcan. More...
 
static int type_owned (const char *type)
 Check whether a resource type has an owner. More...
 
static int type_trash_in_table (const char *type)
 Check whether the trash is in the real table. More...
 
gboolean find_resource (const char *type, const char *uuid, resource_t *resource)
 Find a resource given a UUID. More...
 
gboolean find_resource_with_permission (const char *type, const char *uuid, resource_t *resource, const char *permission, int trash)
 Find a resource given a UUID and a permission. More...
 
static gboolean find_resource_by_name (const char *type, const char *name, resource_t *resource)
 Find a resource given a name. More...
 
static gboolean find_resource_by_name_with_permission (const char *type, const char *name, resource_t *resource, const char *permission)
 Find a resource given a UUID and a permission. More...
 
static int copy_resource_lock (const char *type, const char *name, const char *comment, const char *resource_id, const char *columns, int make_name_unique, resource_t *new_resource, resource_t *old_resource)
 Create a resource from an existing resource. More...
 
int copy_resource (const char *type, const char *name, const char *comment, const char *resource_id, const char *columns, int make_name_unique, resource_t *new_resource, resource_t *old_resource)
 Create a resource from an existing resource. More...
 
int resource_exists (const char *type, resource_t resource, int location)
 Get whether a resource exists. More...
 
int resource_name (const char *type, const char *uuid, int location, char **name)
 Get the name of a resource. More...
 
int manage_resource_name (const char *type, const char *uuid, char **name)
 Get the name of a resource. More...
 
int manage_trash_resource_name (const char *type, const char *uuid, char **name)
 Get the name of a trashcan resource. More...
 
gchar * resource_uuid (const gchar *type, resource_t resource)
 Get the UUID of a resource. More...
 
static int init_get_iterator2_with (iterator_t *iterator, const char *type, const get_data_t *get, column_t *select_columns, column_t *trash_select_columns, column_t *where_columns, column_t *trash_where_columns, const char **filter_columns, int distinct, const char *extra_tables, const char *extra_where, int owned, int ignore_id, const char *extra_order, const char *extra_with, int assume_permitted)
 Initialise a GET iterator, including observed resources. More...
 
static int init_get_iterator2 (iterator_t *iterator, const char *type, const get_data_t *get, column_t *select_columns, column_t *trash_select_columns, column_t *where_columns, column_t *trash_where_columns, const char **filter_columns, int distinct, const char *extra_tables, const char *extra_where, int owned, int ignore_id, const char *extra_order)
 Initialise a GET iterator, including observed resources. More...
 
int init_get_iterator (iterator_t *iterator, const char *type, const get_data_t *get, column_t *select_columns, column_t *trash_select_columns, const char **filter_columns, int distinct, const char *extra_tables, const char *extra_where, int owned)
 Initialise a GET iterator, including observed resources. More...
 
static void append_column (GArray *columns, const gchar *column_name, column_t *select_columns, column_t *where_columns)
 Append expression for a column to an array. More...
 
int init_aggregate_iterator (iterator_t *iterator, const char *type, const get_data_t *get, int distinct, GArray *data_columns, const char *group_column, const char *subgroup_column, GArray *text_columns, GArray *sort_data, int first_group, int max_groups, const char *extra_tables, const char *given_extra_where)
 Initialise a GET_AGGREGATES iterator, including observed resources. More...
 
int aggregate_iterator_count (iterator_t *iterator)
 Get the count from an aggregate iterator. More...
 
double aggregate_iterator_min (iterator_t *iterator, int data_column_index)
 Get the minimum from an aggregate iterator. More...
 
double aggregate_iterator_max (iterator_t *iterator, int data_column_index)
 Get the maximum from an aggregate iterator. More...
 
double aggregate_iterator_mean (iterator_t *iterator, int data_column_index)
 Get the mean from an aggregate iterator. More...
 
double aggregate_iterator_sum (iterator_t *iterator, int data_column_index)
 Get the sum from a statistics iterator. More...
 
const char * aggregate_iterator_text (iterator_t *iterator, int text_column_index, int data_columns)
 Get the value of a text column from an aggregate iterator. More...
 
const char * aggregate_iterator_value (iterator_t *iterator)
 Get the value of the group column from a statistics iterator. More...
 
const char * aggregate_iterator_subgroup_value (iterator_t *iterator)
 Get the value of the subgroup column from an aggregate iterator. More...
 
static int count2 (const char *type, const get_data_t *get, column_t *select_columns, column_t *trash_select_columns, column_t *where_columns, column_t *trash_where_columns, const char **filter_columns, int distinct, const char *extra_tables, const char *extra_where, int owned)
 Count number of a particular resource. More...
 
int count (const char *type, const get_data_t *get, column_t *select_columns, column_t *trash_select_columns, const char **filter_columns, int distinct, const char *extra_tables, const char *extra_where, int owned)
 Count number of a particular resource. More...
 
int info_name_count (const char *type, const char *name)
 Count number of info of a given subtype with a given name. More...
 
static int resource_predefined (const gchar *type, resource_t resource)
 Return whether a resource is predefined. More...
 
static void resource_set_predefined (const gchar *type, resource_t resource, int enable)
 Mark a resource as predefined. More...
 
int manage_db_supported_version ()
 Return the database version supported by this manager. More...
 
int manage_db_version ()
 Return the database version of the actual database. More...
 
int manage_scap_db_supported_version ()
 Return the database version supported by this manager. More...
 
int manage_scap_db_version ()
 Return the database version of the actual database. More...
 
int manage_cert_db_supported_version ()
 Return the database version supported by this manager. More...
 
int manage_cert_db_version ()
 Return the database version of the actual database. More...
 
char * manage_port_name (int number, const char *protocol)
 Returns associated name for a tcp/ip port. More...
 
gchar * port_name_formatted (const char *field)
 Returns formatted port number, protocol and iana name from. More...
 
void set_db_version (int version)
 Set the database version of the actual database. More...
 
static int encrypt_all_credentials (gboolean decrypt_flag)
 Encrypt, re-encrypt or decrypt all credentials. More...
 
int manage_encrypt_all_credentials (GSList *log_config, const gchar *database)
 Encrypt or re-encrypt all credentials. More...
 
int manage_decrypt_all_credentials (GSList *log_config, const gchar *database)
 Decrypt all credentials. More...
 
static int collate_ip_compare (const char *one_arg, const char *two_arg)
 Compare two number strings for collate_ip. More...
 
static int collate_ip (void *data, int one_len, const void *arg_one, int two_len, const void *arg_two)
 Collate two IP addresses. More...
 
static void init_task_user_iterator (iterator_t *iterator, task_t task)
 Initialise a task user iterator. More...
 
void init_task_group_iterator (iterator_t *iterator, task_t task)
 Initialise a task group iterator. More...
 
void init_task_role_iterator (iterator_t *iterator, task_t task)
 Initialise a task role iterator. More...
 
void check_alerts ()
 Check if any SecInfo alerts are due. More...
 
int manage_check_alerts (GSList *log_config, const gchar *database)
 Check if any SecInfo alerts are due. More...
 
gboolean find_alert_with_permission (const char *uuid, alert_t *alert, const char *permission)
 Find a alert for a specific permission, given a UUID. More...
 
static int validate_email (const char *address)
 Validate an email address. More...
 
static int validate_email_list (const char *list)
 Validate an email address list. More...
 
static int validate_alert_condition_data (gchar *name, gchar *data, alert_condition_t condition)
 Validate condition data for an alert. More...
 
static int validate_alert_event_data (gchar *name, gchar *data, event_t event)
 Validate event data for an alert. More...
 
int validate_email_data (alert_method_t method, const gchar *name, gchar **data, int for_modify)
 Validate method data for the email method. More...
 
static int validate_scp_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the SCP method. More...
 
static int validate_send_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the Send method. More...
 
static int validate_smb_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the Send method. More...
 
static int validate_tippingpoint_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the TippingPoint method. More...
 
static int validate_vfire_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the vFire alert method. More...
 
static int validate_sourcefire_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the Sourcefire method. More...
 
static int check_alert_params (event_t event, alert_condition_t condition, alert_method_t method)
 Check alert params. More...
 
int create_alert (const char *name, const char *comment, const char *filter_id, const char *active, event_t event, GPtrArray *event_data, alert_condition_t condition, GPtrArray *condition_data, alert_method_t method, GPtrArray *method_data, alert_t *alert)
 Create an alert. More...
 
int copy_alert (const char *name, const char *comment, const char *alert_id, alert_t *new_alert)
 Create an alert from an existing alert. More...
 
int modify_alert (const char *alert_id, const char *name, const char *comment, const char *filter_id, const char *active, event_t event, GPtrArray *event_data, alert_condition_t condition, GPtrArray *condition_data, alert_method_t method, GPtrArray *method_data)
 Modify an alert. More...
 
int delete_alert (const char *alert_id, int ultimate)
 Delete an alert. More...
 
char * alert_uuid (alert_t alert)
 Return the UUID of an alert. More...
 
static char * alert_name (alert_t alert)
 Return the name of an alert. More...
 
static user_t alert_owner (alert_t alert)
 Return the owner of an alert. More...
 
static char * alert_owner_uuid (alert_t alert)
 Return the UUID of the owner of an alert. More...
 
static char * alert_filter_id (alert_t alert)
 Return the UUID of the filter of an alert. More...
 
static alert_condition_t alert_condition (alert_t alert)
 Return the condition associated with an alert. More...
 
static alert_method_t alert_method (alert_t alert)
 Return the method associated with an alert. More...
 
static event_t alert_event (alert_t alert)
 Return the event associated with an alert. More...
 
int alert_count (const get_data_t *get)
 Count the number of alerts. More...
 
int alert_in_use (alert_t alert)
 Return whether a alert is in use by a task. More...
 
int trash_alert_in_use (alert_t alert)
 Return whether a trashcan alert is in use by a task. More...
 
int alert_writable (alert_t alert)
 Return whether a alert is writable. More...
 
int trash_alert_writable (alert_t alert)
 Return whether a trashcan alert is writable. More...
 
int init_alert_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise an alert iterator, including observed alerts. More...
 
int alert_iterator_event (iterator_t *iterator)
 Return the event from an alert iterator. More...
 
int alert_iterator_condition (iterator_t *iterator)
 Return the condition from an alert iterator. More...
 
int alert_iterator_method (iterator_t *iterator)
 Return the method from an alert iterator. More...
 
static filter_t alert_iterator_filter (iterator_t *iterator)
 Return the filter from an alert iterator. More...
 
char * alert_iterator_filter_uuid (iterator_t *iterator)
 Return the filter UUID from an alert iterator. More...
 
char * alert_iterator_filter_name (iterator_t *iterator)
 Return the filter name from an alert iterator. More...
 
int alert_iterator_filter_trash (iterator_t *iterator)
 Return the location of an alert iterator filter. More...
 
int alert_iterator_filter_readable (iterator_t *iterator)
 Return the filter readable state from an alert iterator. More...
 
int alert_iterator_active (iterator_t *iterator)
 Return the active state from an alert. More...
 
void init_alert_data_iterator (iterator_t *iterator, alert_t alert, int trash, const char *table)
 Initialise an alert data iterator. More...
 
const char * alert_data_iterator_name (iterator_t *iterator)
 Return the name from an alert data iterator. More...
 
const char * alert_data_iterator_data (iterator_t *iterator)
 Return the data from an alert data iterator. More...
 
char * alert_data (alert_t alert, const char *type, const char *name)
 Return data associated with an alert. More...
 
static int alert_applies_to_task (alert_t alert, task_t task)
 Check whether an alert applies to a task. More...
 
void init_task_alert_iterator (iterator_t *iterator, task_t task)
 Initialise a task alert iterator. More...
 
static void init_event_alert_iterator (iterator_t *iterator, event_t event)
 Initialise an event alert iterator. More...
 
static alert_t event_alert_iterator_alert (iterator_t *iterator)
 Get the alert from a event alert iterator. More...
 
static int event_alert_iterator_active (iterator_t *iterator)
 Get the active state from an event alert iterator. More...
 
static int email_write_content (FILE *content_file, const char *to_address, const char *from_address, const char *subject, const char *body, const gchar *attachment, const char *attachment_type, const char *attachment_name, const char *attachment_extension)
 Write the content of a plain text email to a stream. More...
 
static int email_encrypt_gpg (FILE *plain_file, FILE *encrypted_file, const char *public_key, const char *to_address, const char *from_address, const char *subject)
 Create a PGP encrypted email from a plain text one. More...
 
static int email_encrypt_smime (FILE *plain_file, FILE *encrypted_file, const char *certificate, const char *to_address, const char *from_address, const char *subject)
 Create an S/MIME encrypted email from a plain text one. More...
 
static int email (const char *to_address, const char *from_address, const char *subject, const char *body, const gchar *attachment, const char *attachment_type, const char *attachment_name, const char *attachment_extension, credential_t recipient_credential)
 Send an email. More...
 
static int http_get (const char *url)
 GET an HTTP resource. More...
 
static int alert_script_init (const char *report_filename, const char *report, size_t report_size, const char *extra_content, size_t extra_size, char *report_dir, gchar **report_path, gchar **error_path, gchar **extra_path)
 Initialize common files and variables for an alert script. More...
 
static int alert_script_exec (const char *alert_id, const char *command_args, const char *report_path, const char *report_dir, const char *error_path, const char *extra_path, gchar **message)
 Execute the alert script. More...
 
static int alert_script_cleanup (const char *report_dir, gchar *report_path, gchar *error_path, gchar *extra_path)
 Clean up common files and variables for running alert script. More...
 
static int run_alert_script (const char *alert_id, const char *command_args, const char *report_filename, const char *report, size_t report_size, const char *extra_content, size_t extra_size, gchar **message)
 Run an alert's "alert" script with one file of extra data. More...
 
static int snmp_to_host (const char *community, const char *agent, const char *message, gchar **script_message)
 Send an SNMP TRAP to a host. More...
 
static int send_to_host (const char *host, const char *port, const char *report, int report_size, gchar **script_message)
 Send a report to a host via TCP. More...
 
static int scp_to_host (const char *password, const char *username, const char *host, const char *path, const char *known_hosts, const char *report, int report_size, gchar **script_message)
 Send a report to a host via TCP. More...
 
static int smb_send_to_host (const char *password, const char *username, const char *share_path, const char *file_path, const char *report, gsize report_size, gchar **script_message)
 Send a report to a host via SMB. More...
 
static int send_to_sourcefire (const char *ip, const char *port, const char *pkcs12_64, const char *pkcs12_password, const char *report)
 Send a report to a Sourcefire Defense Center. More...
 
static int send_to_verinice (const char *url, const char *username, const char *password, const char *archive, int archive_size)
 Send a report to a verinice.PRO server. More...
 
gboolean buffer_vfire_call_input (gchar *key, gchar *value, GString *buffer)
 Appends an XML fragment for vFire call input to a string buffer. More...
 
static int send_to_vfire (const char *base_url, const char *client_id, const char *session_type, const char *username, const char *password, GPtrArray *report_data, GTree *call_data, const char *description_template, gchar **message)
 Create a new call on an Alemba vFire server. More...
 
static int send_to_tippingpoint (const char *report, size_t report_size, const char *username, const char *password, const char *hostname, const char *certificate, int cert_workaround, gchar **message)
 Convert an XML report and send it to a TippingPoint SMS. More...
 
static gchar * alert_subject_print (const gchar *subject, event_t event, const void *event_data, alert_t alert, task_t task, int total)
 Print an alert subject. More...
 
static gchar * alert_message_print (const gchar *message, event_t event, const void *event_data, task_t task, alert_t alert, alert_condition_t condition, gchar *format_name, filter_t filter, const gchar *term, const gchar *zone, const gchar *host_summary, const gchar *content, gsize content_length, int truncated, int total, int max_length)
 Print an alert message. More...
 
static gchar * scp_alert_path_print (const gchar *message, task_t task)
 Print an SCP alert file path. More...
 
static int email_ticket (alert_t alert, ticket_t ticket, event_t event, const void *event_data, alert_method_t method, alert_condition_t condition, const gchar *to_address, const gchar *from_address, const gchar *subject)
 Build and send email for a ticket alert. More...
 
static int email_secinfo (alert_t alert, task_t task, event_t event, const void *event_data, alert_method_t method, alert_condition_t condition, const gchar *to_address, const gchar *from_address)
 Build and send email for SecInfo alert. More...
 
static report_t get_delta_report (alert_t alert, task_t task, report_t report)
 Get the delta report to be used for an alert. More...
 
static int generate_alert_filter_get (alert_t alert, const get_data_t *base_get_data, get_data_t **alert_filter_get, filter_t *filter_return)
 Generates report results get data for an alert. More...
 
static int report_content_for_alert (alert_t alert, report_t report, task_t task, const get_data_t *get, const char *report_format_data_name, const char *report_format_lookup, const char *fallback_format_id, int notes_details, int overrides_details, gchar **content, gsize *content_length, gchar **extension, gchar **content_type, gchar **term, gchar **report_zone, gchar **host_summary, report_format_t *used_report_format, filter_t *filter_return)
 Generate report content for alert. More...
 
static gchar * generate_report_filename (report_t report, report_format_t report_format, const char *custom_format, gboolean add_extension)
 Generates a filename or path for a report. More...
 
static int escalate_to_vfire (alert_t alert, task_t task, report_t report, event_t event, const void *event_data, alert_method_t method, alert_condition_t condition, const get_data_t *get, int notes_details, int overrides_details, gchar **script_message)
 Escalate an event. More...
 
static int escalate_2 (alert_t alert, task_t task, report_t report, event_t event, const void *event_data, alert_method_t method, alert_condition_t condition, const get_data_t *get, int notes_details, int overrides_details, gchar **script_message)
 Escalate an event. More...
 
static int escalate_1 (alert_t alert, task_t task, report_t report, event_t event, const void *event_data, alert_method_t method, alert_condition_t condition, gchar **script_message)
 Escalate an event with preset report filtering. More...
 
int manage_alert (const char *alert_id, const char *task_id, event_t event, const void *event_data, gchar **script_message)
 Escalate an alert with task and event data. More...
 
int manage_test_alert (const char *alert_id, gchar **script_message)
 Test an alert. More...
 
static int event_applies (event_t event, const void *event_data, resource_t event_resource, alert_t alert)
 Return whether an event applies to a task and an alert. More...
 
static int condition_met (task_t task, report_t report, alert_t alert, alert_condition_t condition)
 Return whether the condition of an alert is met by a task. More...
 
void event (event_t event, void *event_data, resource_t resource_1, resource_t resource_2)
 Produce an event. More...
 
void init_alert_task_iterator (iterator_t *iterator, alert_t alert, int ascending)
 Initialise an alert task iterator. More...
 
const char * alert_task_iterator_name (iterator_t *iterator)
 Return the name from an alert task iterator. More...
 
const char * alert_task_iterator_uuid (iterator_t *iterator)
 Return the uuid from an alert task iterator. More...
 
int alert_task_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
static void append_to_task_string (task_t task, const char *field, const char *value)
 Append value to field of task. More...
 
static gchar * task_iterator_opts_table (int override, int min_qod, int ignore_severity)
 Generate the extra_tables string for a task iterator. More...
 
static void init_user_task_iterator (iterator_t *iterator, int trash, int ignore_severity)
 Initialise a task iterator, limited to current user's tasks. More...
 
int init_task_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a task iterator. More...
 
task_status_t task_iterator_run_status (iterator_t *iterator)
 Get the run status from a task iterator. More...
 
int task_iterator_total_reports (iterator_t *iterator)
 Get the number of reports of a task iterator. More...
 
const char * task_iterator_first_report (iterator_t *iterator)
 Get the first report UUID from a task iterator. More...
 
const char * task_iterator_run_status_name (iterator_t *iterator)
 Get the run status name from a task iterator. More...
 
const char * task_iterator_last_report (iterator_t *iterator)
 Get the last report UUID from a task iterator. More...
 
int task_iterator_finished_reports (iterator_t *iterator)
 Get the number of reports of a task iterator. More...
 
const char * task_iterator_hosts_ordering (iterator_t *iterator)
 Get the hosts ordering value from a task iterator. More...
 
scanner_t task_iterator_scanner (iterator_t *iterator)
 Get the UUID of task scanner from a task iterator. More...
 
int task_in_use (task_t task)
 Return whether a task is in use by a task. More...
 
int trash_task_in_use (task_t task)
 Return whether a trashcan task is referenced by a task. More...
 
int task_alterable (task_t task)
 Return whether a task is an Alterable Task. More...
 
int task_writable (task_t task)
 Return whether a task is writable. More...
 
int trash_task_writable (task_t task)
 Return whether a trashcan task is writable. More...
 
int task_average_scan_duration (task_t task)
 Get the average duration of all finished reports of a task. More...
 
void init_manage_process (int update_nvt_cache, const gchar *database)
 Initialize the manage library for a process. More...
 
void reinit_manage_process ()
 Reinitialize the manage library for a process. More...
 
static void setup_full_config_prefs (config_t config, int safe_checks, int optimize_test, int port_range)
 Setup config preferences for a config. More...
 
static void update_nvti_cache ()
 Update the memory cache of NVTs.
 
int manage_update_nvti_cache ()
 Update the memory cache of NVTs, if this has been requested. More...
 
static void make_port_ranges_openvas_default (port_list_t list)
 Make port ranges. More...
 
static int check_db_scanners ()
 Ensure the predefined scanner exists. More...
 
static void check_db_port_lists ()
 Ensure that the predefined port lists exist.
 
static void update_report_format_uuid (const char *old, const char *new)
 Bring UUIDs for single predefined report format up to date. More...
 
static void update_report_format_uuids ()
 Bring report format UUIDs in database up to date.
 
static void check_db_settings ()
 Initialize the default settings. More...
 
static void add_role_permission (const gchar *role, const gchar *permission)
 Add command permission to role. More...
 
static void add_role_permission_resource (const gchar *role_id, const gchar *permission, const gchar *type, const gchar *resource_id)
 Add resource permission to role. More...
 
static int check_db_versions (int nvt_cache_mode)
 Ensure that the databases are the right versions. More...
 
static void check_db_nvt_selectors ()
 Ensures the sanity of nvts cache in DB.
 
static void check_db_configs ()
 Ensure the predefined configs exist.
 
static int make_report_format_uuids_unique ()
 Ensure every report format has a unique UUID. More...
 
static int check_db_trash_report_formats ()
 Check that trash report formats are correct. More...
 
static int check_db_report_formats ()
 Ensure the predefined report formats exist. More...
 
static gchar * report_format_trash_dir (const gchar *report_format_id)
 Get trash directory of a report format. More...
 
static int check_db_report_formats_trash ()
 Ensure that the report formats trash directory matches the database. More...
 
static void add_permissions_on_globals (const gchar *role_uuid)
 Add permissions for all global resources. More...
 
static void check_db_permissions ()
 Ensure the predefined permissions exists.
 
static void check_db_roles ()
 Ensure the predefined roles exists.
 
static void clean_auth_cache ()
 Cleanup the auth_cache table.
 
static int check_db (int check_encryption_key)
 Ensure that the database is in order. More...
 
void check_generate_scripts ()
 Ensure the generate scripts are all executable. More...
 
static void stop_active_tasks ()
 Stop any active tasks.
 
static void cleanup_tables ()
 Clean up database tables. More...
 
static int init_manage_internal (GSList *log_config, int nvt_cache_mode, const gchar *database, int max_ips_per_target, int max_email_attachment_size, int max_email_include_size, int max_email_message_size, int stop_tasks, manage_connection_forker_t fork_connection, int skip_db_check, int check_encryption_key)
 Initialize the manage library. More...
 
int init_manage (GSList *log_config, int nvt_cache_mode, const gchar *database, int max_ips_per_target, int max_email_attachment_size, int max_email_include_size, int max_email_message_size, manage_connection_forker_t fork_connection, int skip_db_check)
 Initialize the manage library. More...
 
int init_manage_helper (GSList *log_config, const gchar *database, int max_ips_per_target)
 Initialize the manage library for a helper program. More...
 
void cleanup_manage_process (gboolean cleanup)
 Cleanup the manage library. More...
 
void manage_cleanup_process_error (int signal)
 Cleanup as immediately as possible. More...
 
void manage_reset_currents ()
 Cleanup as immediately as possible.
 
gchar * manage_user_hash (const gchar *username)
 Get user hash. More...
 
static gchar * user_uuid_method (const gchar *username, auth_method_t method)
 Get user uuid. More...
 
static int ldap_auth_enabled ()
 Check whether LDAP is enabled. More...
 
static int radius_auth_enabled ()
 Check whether RADIUS is enabled. More...
 
static int user_exists_method (const gchar *name, auth_method_t method)
 Check if user exists. More...
 
static gchar * user_uuid_any_method (const gchar *name)
 Get user uuid, trying all authentication methods. More...
 
static int user_exists (const gchar *name)
 Check if user exists. More...
 
static int manage_scanner_set (const char *uuid)
 Set the address of scanner to connect to. More...
 
int manage_scanner_set_default ()
 Set the default scanner as the scanner to connect to. More...
 
static int credentials_setup (credentials_t *credentials)
 Set credentials for authenticate. More...
 
static int auth_cache_find (const char *username, const char *password, int method)
 Search for LDAP or RADIUS credentials in the recently-used authentication cache. More...
 
static void auth_cache_insert (const char *username, const char *password, int method)
 Add LDAP or RADIUS credentials to the recently-used authentication cache. More...
 
static int authenticate_any_method (const gchar *username, const gchar *password, auth_method_t *auth_method)
 Authenticate, trying any method. More...
 
int authenticate (credentials_t *credentials)
 Authenticate credentials. More...
 
int resource_count (const char *type, const get_data_t *get)
 Return number of resources of a certain type for current user. More...
 
unsigned int task_count (const get_data_t *get)
 Return the number of tasks associated with the current user. More...
 
int task_uuid (task_t task, char **id)
 Return the UUID of a task. More...
 
int task_in_trash (task_t task)
 Return whether a task is in the trashcan. More...
 
int task_in_trash_id (const gchar *task_id)
 Return whether a task is in the trashcan. More...
 
char * task_owner_name (task_t task)
 Return the name of the owner of a task. More...
 
char * task_name (task_t task)
 Return the name of a task. More...
 
char * task_comment (task_t task)
 Return the comment of a task. More...
 
char * task_hosts_ordering (task_t task)
 Return the hosts ordering of a task. More...
 
char * task_observers (task_t task)
 Return the observers of a task. More...
 
config_t task_config (task_t task)
 Return the config of a task. More...
 
char * task_config_uuid (task_t task)
 Return the UUID of the config of a task. More...
 
char * task_config_name (task_t task)
 Return the name of the config of a task. More...
 
int task_config_in_trash (task_t task)
 Return whether the config of a task is in the trashcan. More...
 
void set_task_config (task_t task, config_t config)
 Set the config of a task. More...
 
target_t task_target (task_t task)
 Return the target of a task. More...
 
void set_task_target (task_t task, target_t target)
 Set the target of a task. More...
 
void set_task_hosts_ordering (task_t task, const char *ordering)
 Set the hosts ordering of a task. More...
 
int task_target_in_trash (task_t task)
 Return whether the target of a task is in the trashcan. More...
 
scanner_t task_scanner (task_t task)
 Return the scanner of a task. More...
 
void set_task_scanner (task_t task, scanner_t scanner)
 Set the scanner of a task. More...
 
int task_scanner_in_trash (task_t task)
 Return whether the scanner of a task is in the trashcan. More...
 
task_status_t task_run_status (task_t task)
 Return the run state of a task. More...
 
void set_report_scheduled (report_t report)
 Set a report's scheduled flag. More...
 
static int report_scheduled (report_t report)
 Get a report's scheduled flag. More...
 
static void set_task_run_status_internal (task_t task, task_status_t status)
 Set the run state of a task. More...
 
void set_task_run_status (task_t task, task_status_t status)
 Set the run state of a task. More...
 
int set_task_requested (task_t task, task_status_t *status)
 Atomically set the run state of a task to requested. More...
 
int task_result_count (task_t task, int min_qod)
 Return number of results in a task. More...
 
report_t task_running_report (task_t task)
 Return the running report of a task. More...
 
report_t task_iterator_current_report (iterator_t *iterator)
 Return the current report of a task. More...
 
int task_upload_progress (task_t task)
 Return the upload progress of a task. More...
 
static void set_task_start_time (task_t task, char *time)
 Set the start time of a task. More...
 
void set_task_start_time_epoch (task_t task, int time)
 Set the start time of a task. More...
 
void set_task_start_time_otp (task_t task, char *time)
 Set the start time of a task. More...
 
int task_last_report (task_t task, report_t *report)
 Get the report from the most recently completed invocation of task. More...
 
int task_last_resumable_report (task_t task, report_t *report)
 Get the report from the most recently stopped invocation of task. More...
 
gchar * task_second_last_report_id (task_t task)
 Get report ID from second most recently completed invocation of task. More...
 
void add_task_alert (task_t task, alert_t alert)
 Add an alert to a task. More...
 
static int set_task_alerts (task_t task, array_t *alerts, gchar **alert_id_return)
 Set the alerts on a task, removing any previous alerts. More...
 
void set_task_alterable (task_t task, int alterable)
 Set the alterable state of a task. More...
 
int set_task_groups (task_t task, array_t *groups, gchar **group_id_return)
 Set observer groups on a task, removing any previous groups. More...
 
int set_task_schedule (task_t task, schedule_t schedule, int periods)
 Set the schedule of a task. More...
 
int set_task_schedule_uuid (const gchar *task_id, schedule_t schedule, int periods)
 Set the schedule of a task. More...
 
int set_task_schedule_periods (const gchar *task_id, int periods)
 Set the schedule periods of a task, given a UUID. More...
 
int set_task_schedule_periods_id (task_t task, int periods)
 Set the schedule periods of a task, given an ID. More...
 
schedule_t task_schedule (task_t task)
 Return the schedule of a task. More...
 
schedule_t task_schedule_uuid (const gchar *task_id)
 Return the schedule of a task. More...
 
int task_schedule_in_trash (task_t task)
 Get whether the task schedule is in the trash. More...
 
int task_schedule_periods (task_t task)
 Get the number of times the period schedule should run on the task. More...
 
int task_schedule_periods_uuid (const gchar *task_id)
 Set the next time a scheduled task will be due. More...
 
int task_schedule_next_time (task_t task)
 Get next time a scheduled task will run, following schedule timezone. More...
 
time_t task_schedule_next_time_uuid (const gchar *task_id)
 Get the next time a scheduled task will be due. More...
 
void set_task_schedule_next_time (task_t task, time_t time)
 Set the next time a scheduled task will be due. More...
 
void set_task_schedule_next_time_uuid (const gchar *task_id, time_t time)
 Set the next time a scheduled task will be due. More...
 
char * task_severity (task_t task, int overrides, int min_qod, int offset)
 Return the severity score of a task, taking overrides into account. More...
 
int set_task_observers (task_t task, const gchar *observers)
 Set the observers of a task. More...
 
void clear_duration_schedules (task_t task)
 Clear once-off schedules from tasks where the duration has passed. More...
 
void update_duration_schedule_periods (task_t task)
 Update tasks with limited run schedules which have durations. More...
 
void auto_delete_reports ()
 Auto delete reports.
 
static char * task_definitions_file (task_t task)
 Get definitions file from a task's config. More...
 
void reschedule_task (const gchar *task_id)
 Set a task's schedule so that it runs again next scheduling round. More...
 
gboolean find_result_with_permission (const char *uuid, result_t *result, const char *permission)
 Find a result for a set of permissions, given a UUID. More...
 
static void result_nvt_notice (const gchar *nvt)
 Ensure an NVT occurs in the result_nvts table. More...
 
result_t make_osp_result (task_t task, const char *host, const char *nvt, const char *type, const char *description, const char *port, const char *severity, int qod)
 Make an OSP result. More...
 
int qod_from_type (const char *qod_type)
 Get QoD percentage for a qod_type string. More...
 
static host_t host_identify (const char *host_name, const char *identifier_name, const char *identifier_value, const char *source_type, const char *source)
 Identify a host, given an identifier. More...
 
host_t host_notice (const char *host_name, const char *identifier_type, const char *identifier_value, const char *source_type, const char *source_id, int check_add_to_assets, int check_for_existing_identifier)
 Notice a host. More...
 
static char * nvt_severity (const char *nvt_id, const char *type)
 Get a severity string from an nvt and result type. More...
 
result_t make_result (task_t task, const char *host, const char *hostname, const char *port, const char *nvt, const char *type, const char *description)
 Make a result. More...
 
result_t make_cve_result (task_t task, const char *host, const char *nvt, double cvss, const char *description)
 Make a CVE result. More...
 
int result_uuid (result_t result, char **id)
 Return the UUID of a result. More...
 
int result_detection_reference (result_t result, report_t report, const gchar *host, const char *oid, char **ref, char **product, char **location, char **name)
 Get product detection results corresponding to a given vulnerability detection result. More...
 
static double cpe_highest_cvss (const char *cpe)
 Return highest CVSS for an App. More...
 
static void init_prognosis_iterator (iterator_t *iterator, const char *cpe)
 Initialise a prognosis iterator. More...
 
double prognosis_iterator_cvss_double (iterator_t *iterator)
 Get the CVSS from a result iterator as a double. More...
 
gchar * app_location (report_host_t report_host, const gchar *app)
 Get the location of an App for a report's host. More...
 
static GString * prognosis_where_search_phrase (const char *search_phrase)
 Return SQL WHERE for restricting a SELECT to a search phrase. More...
 
static const char * prognosis_where_levels (const char *levels)
 Return SQL WHERE for restricting a SELECT to levels. More...
 
static GString * prognosis_order_by (const char *sort_field, int ascending)
 Return SQL ORDER BY for sorting results in a prognostic report. More...
 
void init_host_prognosis_iterator (iterator_t *iterator, report_host_t report_host, int first_result, int max_results, const char *levels, const char *search_phrase, int sort_order, const char *sort_field)
 Initialise a report host prognosis iterator. More...
 
static GHashTable * new_resources_hashtable ()
 Create a new GHashTable for containing resource rowids. More...
 
static void reports_add_for_override (GHashTable *reports_table, override_t override)
 Add reports affected by an override to an existing GHashtable. This is used to add more reports to the hashtable from reports_for_override. More...
 
static GHashTable * reports_for_override (override_t override)
 Get reports affected by an override in a GHashTable. More...
 
static void reports_add_all (GHashTable *reports_table)
 Add all reports to an existing GHashtable. More...
 
static GHashTable * reports_hashtable ()
 Get all reports in a GHashTable. More...
 
static void reports_build_count_cache (int clear, int *changes_out)
 Rebuild the report count cache for all reports and users. More...
 
void init_report_counts_build_iterator (iterator_t *iterator, report_t report, int min_qod_limit, int add_defaults, const char *users_where)
 Initializes an iterator for updating the report cache. More...
 
static int report_counts_build_iterator_min_qod (iterator_t *iterator)
 Get the min_qod from a report_counts build iterator. More...
 
static int report_counts_build_iterator_override (iterator_t *iterator)
 Get the override flag from a report_counts build iterator. More...
 
static user_t report_counts_build_iterator_user (iterator_t *iterator)
 Get the user from a report_counts build iterator. More...
 
static void report_clear_count_cache (report_t report, int clear_original, int clear_overridden, const char *users_where)
 Clear report counts . More...
 
report_t make_report (task_t task, const char *uuid, task_status_t status)
 Make a report. More...
 
int create_current_report (task_t task, char **report_id, task_status_t status)
 Create the current report for a task. More...
 
void host_detail_free (host_detail_t *detail)
 Free a host detail. More...
 
void insert_report_host_detail (report_t report, const char *host, const char *s_type, const char *s_name, const char *s_desc, const char *name, const char *value)
 Insert a host detail into a report. More...
 
int create_report (array_t *results, const char *task_id, const char *task_name, const char *task_comment, const char *in_assets, const char *scan_start, const char *scan_end, array_t *host_starts, array_t *host_ends, array_t *details, char **report_id)
 Create a report from an array of results. More...
 
char * report_uuid (report_t report)
 Return the UUID of a report. More...
 
gboolean report_task (report_t report, task_t *task)
 Return the task of a report. More...
 
static char * report_slave_uuid (report_t report)
 Return the UUID of a report's slave. More...
 
static char * report_slave_name (report_t report)
 Return the name of a report's slave. More...
 
static char * report_slave_host (report_t report)
 Return the host of a report's slave. More...
 
static char * report_slave_port (report_t report)
 Return the port of a report's slave. More...
 
static int report_slave_port_int (report_t report)
 Return the port of a report's slave. More...
 
static char * report_source_iface (report_t report)
 Return the source interface of a report. More...
 
void report_set_slave_uuid (report_t report, const gchar *uuid)
 Set the UUID of the slave on a report. More...
 
void report_set_slave_name (report_t report, const gchar *name)
 Set the name of the slave on a report. More...
 
void report_set_slave_host (report_t report, const gchar *host)
 Set the host of the slave of a report. More...
 
void report_set_slave_port (report_t report, int port)
 Set the port of the slave of a report. More...
 
void report_set_source_iface (report_t report, const gchar *iface)
 Set the source interface of a report. More...
 
static void report_add_result_for_buffer (report_t report, result_t result)
 Add a result to a report. More...
 
void report_add_result (report_t report, result_t result)
 Add a result to a report. More...
 
static gchar * report_iterator_opts_table (int override, int min_qod)
 Generate the extra_tables string for a report iterator. More...
 
int report_count (const get_data_t *get)
 Count number of reports. More...
 
int init_report_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a report iterator, including observed reports. More...
 
void init_report_iterator_task (iterator_t *iterator, task_t task)
 Initialise a report iterator. More...
 
gboolean next_report (iterator_t *iterator, report_t *report)
 Read the next report from an iterator. More...
 
static GString * where_levels (const char *levels, const char *new_severity_sql)
 Return SQL WHERE for restricting a SELECT to levels. More...
 
static GString * where_levels_auto (const char *levels, const char *new_severity_sql, const char *auto_type_sql)
 Return SQL WHERE for restricting a SELECT to levels. More...
 
static gchar * where_qod (int min_qod)
 Return SQL WHERE for restricting a SELECT to a minimum QoD. More...
 
static gchar * result_iterator_opts_table (int autofp, int override, int dynamic)
 Generate the extra_tables string for a result iterator. More...
 
static int init_result_get_iterator_severity (iterator_t *iterator, const get_data_t *get, report_t report, const char *host, const gchar *extra_order)
 Initialise the severity-only result iterator. More...
 
int init_result_get_iterator (iterator_t *iterator, const get_data_t *get, report_t report, const char *host, const gchar *extra_order)
 Initialise a result iterator. More...
 
int result_count (const get_data_t *get, report_t report, const char *host)
 Count the number of results. More...
 
result_t result_iterator_result (iterator_t *iterator)
 Get the result from a result iterator. More...
 
const char * result_iterator_nvt_name (iterator_t *iterator)
 Get the NVT name from a result iterator. More...
 
const char * result_iterator_nvt_family (iterator_t *iterator)
 Get the NVT family from a result iterator. More...
 
const char * result_iterator_nvt_cvss_base (iterator_t *iterator)
 Get the NVT CVSS base value from a result iterator. More...
 
const char * result_iterator_nvt_cve (iterator_t *iterator)
 Get the NVT CVE from a result iterator. More...
 
const char * result_iterator_nvt_bid (iterator_t *iterator)
 Get the NVT BID from a result iterator. More...
 
const char * result_iterator_nvt_xref (iterator_t *iterator)
 Get the NVT XREF from a result iterator. More...
 
const char * result_iterator_nvt_tag (iterator_t *iterator)
 Get the NVT tags from a result iterator. More...
 
static const char * result_iterator_type (iterator_t *iterator)
 Get the type from a result iterator. More...
 
task_t result_iterator_task (iterator_t *iterator)
 Get the task from a result iterator. More...
 
report_t result_iterator_report (iterator_t *iterator)
 Get the report from a result iterator. More...
 
const char * result_iterator_scan_nvt_version (iterator_t *iterator)
 Get the NVT version used during the scan from a result iterator. More...
 
const char * result_iterator_original_severity (iterator_t *iterator)
 Get the original severity from a result iterator. More...
 
static const char * result_iterator_severity (iterator_t *iterator)
 Get the severity from a result iterator. More...
 
double result_iterator_severity_double (iterator_t *iterator)
 Get the severity from a result iterator as double. More...
 
const char * result_iterator_original_level (iterator_t *iterator)
 Get the original severity/threat level from a result iterator. More...
 
const char * result_iterator_level (iterator_t *iterator)
 Get the severity/threat level from a result iterator. More...
 
int result_iterator_may_have_notes (iterator_t *iterator)
 Get whether notes may exist from a result iterator. More...
 
int result_iterator_may_have_overrides (iterator_t *iterator)
 Get whether overrides may exist from a result iterator. More...
 
int result_iterator_may_have_tickets (iterator_t *iterator)
 Get whether tickets may exist from a result iterator. More...
 
int result_iterator_has_cert_bunds (iterator_t *iterator)
 Get whether CERT-Bunds may exist from a result iterator. More...
 
int result_iterator_has_dfn_certs (iterator_t *iterator)
 Get whether DFN-CERTs may exist from a result iterator. More...
 
void init_report_host_iterator (iterator_t *iterator, report_t report, const char *host, report_host_t report_host)
 Initialise a host iterator. More...
 
static report_host_t host_iterator_report_host (iterator_t *iterator)
 Get the report host from a host iterator. More...
 
int host_iterator_current_port (iterator_t *iterator)
 Get the current port from a host iterator. More...
 
int host_iterator_max_port (iterator_t *iterator)
 Get the max port from a host iterator. More...
 
static report_t host_iterator_report (iterator_t *iterator)
 Get the report from a host iterator. More...
 
void init_report_errors_iterator (iterator_t *iterator, report_t report)
 Initialise a report errors iterator. More...
 
static result_t report_errors_iterator_result (iterator_t *iterator)
 Get the result from a report error messages iterator. More...
 
static void init_report_host_details_iterator (iterator_t *iterator, report_host_t report_host)
 Initialise a report host details iterator. More...
 
static void init_classic_asset_iterator (iterator_t *iterator, int first_result, int max_results, const char *levels, const char *search_phrase, int apply_overrides)
 Initialise an asset iterator. More...
 
void set_task_end_time (task_t task, char *time)
 Set the end time of a task. More...
 
void set_task_end_time_epoch (task_t task, time_t time)
 Set the end time of a task. More...
 
static char * scan_start_time (report_t report)
 Get the start time of a scan. More...
 
int scan_start_time_epoch (report_t report)
 Get the start time of a scan, in seconds since the epoch. More...
 
char * scan_start_time_uuid (const char *uuid)
 Get the start time of a scan. More...
 
static void set_scan_start_time (report_t report, const char *timestamp)
 Set the start time of a scan. More...
 
void set_scan_start_time_epoch (report_t report, time_t timestamp)
 Set the start time of a scan. More...
 
void set_scan_start_time_otp (report_t report, const char *timestamp)
 Set the start time of a scan. More...
 
static char * scan_end_time (report_t report)
 Get the end time of a scan. More...
 
char * scan_end_time_uuid (const char *uuid)
 Get the end time of a scan. More...
 
void set_scan_end_time_epoch (report_t report, time_t timestamp)
 Set the end time of a scan. More...
 
void set_scan_end_time (report_t report, const char *timestamp)
 Set the end time of a scan. More...
 
void set_scan_end_time_otp (report_t report, const char *timestamp)
 Set the end time of a scan. More...
 
int scan_host_end_time (report_t report, const char *host)
 Get the end time of a scanned host. More...
 
void set_scan_host_end_time (report_t report, const char *host, const char *timestamp)
 Set the end time of a scanned host. More...
 
void set_scan_host_end_time_otp (report_t report, const char *host, const char *timestamp)
 Set the end time of a scanned host. More...
 
static void set_scan_host_start_time (report_t report, const char *host, const char *timestamp)
 Set the start time of a scanned host. More...
 
void set_scan_host_start_time_otp (report_t report, const char *host, const char *timestamp)
 Set the start time of a scanned host. More...
 
int report_timestamp (const char *report_id, gchar **timestamp)
 Get the timestamp of a report. More...
 
static int report_scan_run_status (report_t report, task_status_t *status)
 Return the run status of the scan associated with a report. More...
 
int set_report_scan_run_status (report_t report, task_status_t status)
 Return the run status of the scan associated with a report. More...
 
int report_counts (const char *report_id, int *debugs, int *holes, int *infos, int *logs, int *warnings, int *false_positives, double *severity, int override, int autofp, int min_qod)
 Get the message counts for a report given the UUID. More...
 
static void report_counts_from_cache (report_t report, int override, int min_qod, severity_data_t *data)
 Get cached result counts for a report and the current user. More...
 
int report_counts_id (report_t report, int *debugs, int *holes, int *infos, int *logs, int *warnings, int *false_positives, double *severity, const get_data_t *get, const char *host)
 Get only the filtered message counts for a report. More...
 
double report_severity (report_t report, int overrides, int min_qod)
 Get the maximum severity of a report. More...
 
int delete_report_internal (report_t report)
 Delete a report. More...
 
int modify_report (const char *report_id, const char *comment)
 Modify a report. More...
 
int delete_report (const char *report_id, int dummy)
 Delete a report. More...
 
static int report_slave_progress (report_t report)
 Return the slave progress of a report. More...
 
int set_report_slave_progress (report_t report, int progress)
 Set slave progress of a report. More...
 
char * report_slave_task_uuid (report_t report)
 Return the UUID of the task on the slave. More...
 
void set_report_slave_task_uuid (report_t report, const char *uuid)
 Set the UUID of the slave task, on the local task. More...
 
void trim_report (report_t report)
 Prepare a partial report for restarting the scan from the beginning. More...
 
void trim_partial_report (report_t report)
 Prepare a partial report for resumption of the scan. More...
 
static gint compare_severity_desc (gconstpointer arg_one, gconstpointer arg_two)
 Compares two textual port representations, sorting descending. More...
 
static gint compare_severity_asc (gconstpointer arg_one, gconstpointer arg_two)
 Compares two textual port representations, sorting descending. More...
 
static result_buffer_tresult_buffer_new (const gchar *host, const gchar *port, const gchar *severity, double severity_double)
 Create a result buffer. More...
 
static void result_buffer_free (result_buffer_t *result_buffer)
 Free a result buffer. More...
 
static gint compare_port_severity (gconstpointer arg_one, gconstpointer arg_two)
 Compares two buffered results, sorting by host, port then severity. More...
 
void buffer_results_xml (GString *, iterator_t *, task_t, int, int, int, int, int, int, int, const char *, iterator_t *, int, int)
 Buffer XML for some results. More...
 
static compare_results_t result_cmp (iterator_t *results, iterator_t *delta_results, int sort_order, const char *sort_field)
 Return the sort order of two results. More...
 
static compare_results_t compare_results (iterator_t *results, iterator_t *delta_results, int sort_order, const char *sort_field)
 Compare two results. More...
 
static compare_results_t compare_and_buffer_results (GString *buffer, iterator_t *results, iterator_t *delta_results, task_t task, int notes, int notes_details, int overrides, int overrides_details, int sort_order, const char *sort_field, int changed, int gone, int new, int same, int *max_results, int *first_result, int *used, int *would_use)
 Compare two results, writing associated XML to a buffer. More...
 
static void add_port (GTree *ports, iterator_t *results)
 Add a port to a port tree. More...
 
static gboolean print_host_port (gpointer key, gpointer value, gpointer data)
 Print delta host ports. More...
 
static gboolean print_host_ports (gpointer key, gpointer value, gpointer stream)
 Print delta ports. More...
 
static gboolean array_add_port (gpointer key, gpointer value, gpointer ports)
 Add port to ports array. More...
 
static gboolean print_host_ports_desc (gpointer key, gpointer value, gpointer stream)
 Print delta ports, in descending order. More...
 
static gint compare_ports_severity (gconstpointer one, gconstpointer two)
 Compare port severities, ascending. More...
 
static gint compare_ports_severity_desc (gconstpointer one, gconstpointer two)
 Compare port severities, descending. More...
 
static gboolean print_host_ports_by_severity (gpointer key, gpointer value, gpointer stream, int ascending)
 Print delta ports, ordering by severity. More...
 
static gboolean print_host_ports_by_severity_desc (gpointer key, gpointer value, gpointer stream)
 Print delta ports, ordering by severity descending. More...
 
static gboolean print_host_ports_by_severity_asc (gpointer key, gpointer value, gpointer stream)
 Print delta ports, ordering by severity ascending. More...
 
static gboolean free_host_ports (GTree *host_ports, gpointer dummy)
 Free delta host ports. More...
 
gboolean host_nthlast_report_host (const char *host, report_host_t *report_host, int position)
 Get N'th last report_host given a host. More...
 
static int host_report_count (const char *host)
 Count host reports. More...
 
static int host_count ()
 Count hosts. More...
 
static int filtered_host_count (const char *levels, const char *search_phrase, int apply_overrides)
 Count hosts with filtering. More...
 
int report_host_count (report_t report)
 Count a report's total number of hosts. More...
 
int report_result_host_count (report_t report, int min_qod)
 Count a report's total number of hosts with results. More...
 
static int report_port_count (report_t report)
 Count a report's total number of tcp/ip ports. More...
 
static int report_closed_cve_count (report_t report)
 Count a report's total number of closed cves. More...
 
static int report_vuln_count (report_t report)
 Count a report's total number of vulnerabilities. More...
 
static int report_os_count (report_t report)
 Count a report's total number of detected Operating Systems. More...
 
static int report_app_count (report_t report)
 Count a report's total number of detected Apps. More...
 
static int report_ssl_cert_count (report_t report)
 Count a report's total number of found SSL Certificates. More...
 
static int report_error_count (report_t report)
 Count a report's total number of error messages. More...
 
static int print_report_host_detail (FILE *stream, iterator_t *details)
 Write report host detail to file stream. More...
 
static int print_report_host_details_xml (report_host_t report_host, FILE *stream)
 Print the XML for a report's host details to a file stream. More...
 
static int print_report_errors_xml (report_t report, FILE *stream)
 Print the XML for a report's error messages to a file stream. More...
 
static int print_report_assets_xml (FILE *out, const char *host, int first_result, int max_results, gchar *levels, gchar *search_phrase, int pos, const get_data_t *get, int apply_overrides, int autofp)
 Print the XML for a report of type assets. More...
 
static int print_report_port_xml (report_t report, FILE *out, const get_data_t *get, int first_result, int max_results, int sort_order, const char *sort_field, GHashTable *host_ports)
 Print the XML for a report port summary to a file. More...
 
static int report_active (report_t report)
 Check whether the scan of a report is active. More...
 
static int report_progress_active (report_t report, long maximum_hosts, gchar **hosts_xml)
 Get progress for active report. More...
 
int report_progress (report_t report, task_t task, gchar **hosts_xml)
 Calculate the progress of a report. More...
 
static gchar * severity_class_xml (const gchar *severity)
 Buffer XML for a severity class. More...
 
static int tz_revert (gchar *zone, char *tz, char *old_tz_override)
 Restore original TZ. More...
 
static void host_summary_append (GString *host_summary_buffer, const char *host, const char *start_iso, const char *end_iso)
 Print the XML for a report to a file. More...
 
static int init_delta_iterators (report_t report, iterator_t *results, report_t delta, iterator_t *delta_results, const get_data_t *get, const char *term, const char *sort_field)
 Init delta iterators for print_report_xml. More...
 
static int print_report_delta_xml (FILE *out, iterator_t *results, iterator_t *delta_results, const char *delta_states, int first_result, int max_results, task_t task, int notes, int notes_details, int overrides, int overrides_details, int sort_order, const char *sort_field, int result_hosts_only, int *orig_filtered_result_count, int *filtered_result_count, int *orig_f_debugs, int *f_debugs, int *orig_f_holes, int *f_holes, int *orig_f_infos, int *f_infos, int *orig_f_logs, int *f_logs, int *orig_f_warnings, int *f_warnings, int *orig_f_false_positives, int *f_false_positives, array_t *result_hosts)
 Print delta results for print_report_xml. More...
 
static int print_report_xml_start (report_t report, report_t delta, task_t task, gchar *xml_start, const get_data_t *get, const char *type, int notes_details, int overrides_details, int result_tags, const char *host, int pos, const char *host_search_phrase, const char *host_levels, int host_first_result, int host_max_results, int ignore_pagination, gchar **filter_term_return, gchar **zone_return, gchar **host_summary)
 Print the main XML content for a report to a file. More...
 
static int print_report_xml_end (gchar *xml_start, gchar *xml_full, report_format_t report_format)
 Completes a report by adding report format info. More...
 
gchar * manage_report (report_t report, report_t delta_report, const get_data_t *get, const report_format_t report_format, int notes_details, int overrides_details, const char *type, gsize *output_length, gchar **extension, gchar **content_type, gchar **filter_term_return, gchar **zone_return, gchar **host_summary)
 Generate a report. More...
 
static int run_report_format_script (gchar *report_format_id, gchar *xml_file, gchar *xml_dir, gchar *report_format_extra, gchar *output_file)
 Runs the script of a report format. More...
 
int manage_send_report (report_t report, report_t delta_report, report_format_t report_format, const get_data_t *get, int notes_details, int overrides_details, int result_tags, int ignore_pagination, int base64, gboolean(*send)(const char *, int(*)(const char *, void *), void *), int(*send_data_1)(const char *, void *), void *send_data_2, const char *alert_id, const char *type, const char *host, int pos, const char *host_search_phrase, const char *host_levels, int host_first_result, int host_max_results, const gchar *prefix)
 Generate a report. More...
 
gchar * report_host_ip (const char *host)
 Get the IP of a host, using the 'hostname' report host details. More...
 
int report_host_noticeable (report_t report, const gchar *host)
 Check if a report host is alive and has at least one result. More...
 
void parse_osp_report (task_t task, report_t report, const char *report_xml)
 Parse an OSP report. More...
 
static unsigned int task_finished_report_count (task_t task)
 Return the number of finished reports associated with a task. More...
 
static const char * task_trend_calc (int holes_a, int warns_a, int infos_a, double severity_a, int holes_b, int warns_b, int infos_b, double severity_b)
 Return the trend of a task, given counts. More...
 
const char * task_iterator_trend_counts (iterator_t *iterator, int holes_a, int warns_a, int infos_a, double severity_a, int holes_b, int warns_b, int infos_b, double severity_b)
 Return the trend of a task, given counts. More...
 
const char * task_trend (task_t task, int override, int min_qod)
 Return the trend of a task. More...
 
task_t make_task (char *name, char *comment, int in_assets, int event)
 Make a task. More...
 
void make_task_complete (task_t task)
 Complete the creation of a task. More...
 
void set_task_name (task_t task, const char *name)
 Set the name of a task. More...
 
static void set_task_comment (task_t task, const char *comment)
 Set the comment of a task. More...
 
int copy_task (const char *name, const char *comment, const char *task_id, int alterable, task_t *new_task)
 Create a task from an existing task. More...
 
int request_delete_task (task_t *task_pointer)
 Request deletion of a task. More...
 
int request_delete_task_uuid (const char *task_id, int ultimate)
 Request deletion of a task. More...
 
int delete_task (task_t task, int ultimate)
 Complete deletion of a task. More...
 
int delete_task_lock (task_t task, int ultimate)
 Complete deletion of a task. More...
 
static int delete_trash_tasks ()
 Delete all trash tasks. More...
 
void append_to_task_comment (task_t task, const char *text, int length)
 Append text to the comment associated with a task. More...
 
void set_scan_ports (report_t report, const char *host, unsigned int current, unsigned int max)
 Set the ports for a particular host in a scan. More...
 
gboolean find_task_with_permission (const char *uuid, task_t *task, const char *permission)
 Find a task for a specific permission, given a UUID. More...
 
gboolean find_trash_task_with_permission (const char *uuid, task_t *task, const char *permission)
 Find a task in the trashcan for a specific permission, given a UUID. More...
 
gboolean find_report_with_permission (const char *uuid, report_t *report, const char *permission)
 Find a report for a specific permission, given a UUID. More...
 
void reset_task (task_t task)
 Reset all running information for a task. More...
 
int manage_task_update_file (const gchar *task_id, const char *name, const void *content)
 Add a file to a task, or update the file on the task. More...
 
int manage_task_remove_file (const gchar *task_id, const char *name)
 Remove a file on a task. More...
 
void init_task_file_iterator (iterator_t *iterator, task_t task, const char *file)
 Initialise a task file iterator. More...
 
int modify_task (const gchar *task_id, const gchar *name, const gchar *comment, const gchar *scanner_id, const gchar *target_id, const gchar *config_id, const gchar *observers, array_t *alerts, const gchar *alterable, array_t *groups, const gchar *schedule_id, const gchar *schedule_periods, array_t *preferences, const gchar *hosts_ordering, gchar **fail_alert_id, gchar **fail_group_id)
 Modify a task. More...
 
int manage_max_hosts ()
 Get the maximum allowed number of hosts per target. More...
 
static void manage_set_max_hosts (int new_max)
 Set the maximum allowed number of hosts per target. More...
 
gboolean find_target_with_permission (const char *uuid, target_t *target, const char *permission)
 Find a target for a specific permission, given a UUID. More...
 
int manage_count_hosts (const char *given_hosts, const char *exclude_hosts)
 Return number of hosts described by a hosts string. More...
 
static gchar * trim_hosts (gchar *string)
 Trim leading and trailing space from a hosts string. More...
 
void manage_transaction_start ()
 Start a new IMMEDIATE transaction.
 
void manage_transaction_stop (gboolean force_commit)
 Commit the current transaction, if any. More...
 
static int validate_port (const char *port)
 Validate a single port. More...
 
static int validate_results_port (const char *port)
 Validate a single port. More...
 
static int alive_test_from_string (const char *alive_tests)
 Convert alive test name to alive test bitfield. More...
 
static int set_target_login_data (target_t target, const char *type, credential_t credential, int port)
 Set login data for a target. More...
 
credential_t target_credential (target_t target, const char *type)
 Get a credential from a target. More...
 
credential_t trash_target_credential (target_t target, const char *type)
 Get a credential from a target in the trashcan. More...
 
int trash_target_credential_location (target_t target, const char *type)
 Get whether a credential of a trash target is in trashcan. More...
 
int target_login_port (target_t target, const char *type)
 Get a login port from a target. More...
 
int trash_target_login_port (target_t target, const char *type)
 Get a port from a target in the trashcan. More...
 
int create_target (const char *name, const char *asset_hosts_filter, const char *hosts, const char *exclude_hosts, const char *comment, const char *port_list_id, const char *port_range, credential_t ssh_credential, const char *ssh_port, credential_t smb_credential, credential_t esxi_credential, credential_t snmp_credential, const char *reverse_lookup_only, const char *reverse_lookup_unify, const char *alive_tests, target_t *target)
 Create a target. More...
 
int copy_target (const char *name, const char *comment, const char *target_id, target_t *new_target)
 Create a target from an existing target. More...
 
int delete_target (const char *target_id, int ultimate)
 Delete a target. More...
 
int modify_target (const char *target_id, const char *name, const char *hosts, const char *exclude_hosts, const char *comment, const char *port_list_id, const char *ssh_credential_id, const char *ssh_port, const char *smb_credential_id, const char *esxi_credential_id, const char *snmp_credential_id, const char *reverse_lookup_only, const char *reverse_lookup_unify, const char *alive_tests)
 Modify a target. More...
 
int target_count (const get_data_t *get)
 Count number of targets. More...
 
void init_target_iterator_one (iterator_t *iterator, target_t target)
 Initialise a target iterator, given a single target. More...
 
int init_target_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a target iterator, including observed targets. More...
 
int target_iterator_ssh_credential (iterator_t *iterator)
 Get the SSH LSC credential from a target iterator. More...
 
int target_iterator_smb_credential (iterator_t *iterator)
 Get the SMB LSC credential from a target iterator. More...
 
int target_iterator_ssh_trash (iterator_t *iterator)
 Get the location of the SSH LSC credential from a target iterator. More...
 
int target_iterator_smb_trash (iterator_t *iterator)
 Get the location of the SMB LSC credential from a target iterator. More...
 
int target_iterator_port_list_trash (iterator_t *iterator)
 Get the location of the port list from a target iterator. More...
 
const char * target_iterator_alive_tests (iterator_t *iterator)
 Get the alive test description from a target iterator. More...
 
int target_iterator_esxi_credential (iterator_t *iterator)
 Get the ESXi LSC credential from a target iterator. More...
 
int target_iterator_esxi_trash (iterator_t *iterator)
 Get the ESXi LSC credential from a target iterator. More...
 
int target_iterator_snmp_credential (iterator_t *iterator)
 Get the SNMP LSC credential from a target iterator. More...
 
int target_iterator_snmp_trash (iterator_t *iterator)
 Get the SNMP LSC credential location from a target iterator. More...
 
char * tag_uuid (tag_t tag)
 Return the UUID of a tag. More...
 
char * target_uuid (target_t target)
 Return the UUID of a target. More...
 
char * trash_target_uuid (target_t target)
 Return the UUID of a trashcan target. More...
 
char * target_name (target_t target)
 Return the name of a target. More...
 
char * trash_target_name (target_t target)
 Return the name of a trashcan target. More...
 
int trash_target_readable (target_t target)
 Return whether a trashcan target is readable. More...
 
char * target_hosts (target_t target)
 Return the hosts associated with a target. More...
 
char * target_exclude_hosts (target_t target)
 Return the excluded hosts associated with a target. More...
 
char * target_reverse_lookup_only (target_t target)
 Return the reverse_lookup_only value of a target. More...
 
char * target_reverse_lookup_unify (target_t target)
 Return the reverse_lookup_unify value of a target. More...
 
char * target_ssh_port (target_t target)
 Return the SSH LSC port of a target. More...
 
credential_t target_ssh_credential (target_t target)
 Return the SSH credential associated with a target, if any. More...
 
credential_t target_smb_credential (target_t target)
 Return the SMB credential associated with a target, if any. More...
 
credential_t target_esxi_credential (target_t target)
 Return the ESXi credential associated with a target, if any. More...
 
port_list_t target_port_list (target_t target)
 Return the port list associated with a target, if any. More...
 
char * target_port_range (target_t target)
 Return the port range of a target, in OTP format. More...
 
alive_test_t target_alive_tests (target_t target)
 Return a target's alive tests. More...
 
int target_in_use (target_t target)
 Return whether a target is in use by a task. More...
 
int trash_target_in_use (target_t target)
 Return whether a trashcan target is referenced by a task. More...
 
int target_writable (target_t target)
 Return whether a target is writable. More...
 
int trash_target_writable (target_t target)
 Return whether a trashcan target is writable. More...
 
void init_target_task_iterator (iterator_t *iterator, target_t target)
 Initialise a target task iterator. More...
 
int target_task_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. 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...
 
static int config_insert_preferences (config_t config, const array_t *preferences, const char *config_type)
 Insert preferences into a config. More...
 
int create_config (const char *proposed_name, const char *comment, const array_t *selectors, const array_t *preferences, const char *config_type, config_t *config, char **name)
 Create a config. More...
 
static GSList * get_scanner_params (scanner_t scanner)
 Get list of OSP Scanner parameters. More...
 
static int insert_osp_parameter (osp_param_t *param, config_t config)
 Insert an OSP parameter into a config if not already present. More...
 
int create_config_from_scanner (const char *scanner_id, const char *name, const char *comment, char **uuid)
 Create a config from an OSP scanner. More...
 
char * config_uuid (config_t config)
 Return the UUID of a config. More...
 
int config_type (config_t config)
 Return the type of a config. More...
 
static scanner_t config_scanner (config_t config)
 Return the scanner associated with a config, if any. 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_config_scanner (config_t config, scanner_t scanner)
 Check scanner and config values match 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, 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...
 
static void update_config_params (config_t config, const char *config_id, GSList *params)
 Update a config with a list of parameters. More...
 
int sync_config (const char *config_id)
 Synchronize 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_type (iterator_t *iterator)
 Get the type from a config iterator. More...
 
scanner_t config_iterator_scanner (iterator_t *iterator)
 Get the scanner from a config iterator. More...
 
int config_iterator_scanner_trash (iterator_t *iterator)
 Get whether scanner is in trash 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_preference_iterator (iterator_t *iterator, config_t config)
 Initialise a preference iterator. More...
 
void init_otp_pref_iterator (iterator_t *iterator, config_t config, const char *section)
 Initialise an "OTP" preference iterator. More...
 
char * config_nvt_selector (config_t config)
 Return the NVT selector associated with a config. More...
 
int manage_set_config_preference (const gchar *config_id, const char *nvt, const char *name, const char *value_64)
 Set a preference of a config. More...
 
int manage_set_config (const gchar *config_id, const char *name, const char *comment, const char *scanner_id)
 Set the name, comment and scanner of a config. More...
 
int manage_set_config_nvts (const gchar *config_id, const char *family, GPtrArray *selected_nvts)
 Set the NVT's selected for a single family of a config. More...
 
static int switch_representation (config_t config, int constraining)
 Switch between constraining and generating representation. 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...
 
static gchar * alert_url_print (const gchar *url, const gchar *oid, const gchar *type)
 Print an URL for a New NVTs alert. More...
 
static gchar * new_nvts_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for New NVTs event. More...
 
static gchar * new_cves_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for New CVEs event. More...
 
static gchar * new_cpes_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for New CPEs event. More...
 
static gchar * new_cert_bunds_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for "New CERT-Bund Advisories" event message. More...
 
static gchar * new_dfn_certs_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for "New DFN-CERT Advisories" event message. More...
 
static gchar * new_oval_defs_list (event_t event, const void *event_data, alert_t alert, int example, int *count_return)
 Create list for "New OVAL Definitions" event. More...
 
int nvt_selector_family_count (const char *quoted_selector, int families_growing)
 Get the number of families selected by 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...
 
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_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_set_config_families (const gchar *config_id, GPtrArray *growing_all_families, GPtrArray *static_all_families, GPtrArray *growing_families, int grow_families)
 Refresh NVT selection of a config from given families. 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 an NVT preference. More...
 
void manage_nvt_preferences_enable ()
 Enable the NVT preferences.
 
void init_nvt_preference_iterator (iterator_t *iterator, const char *name)
 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_nvt (iterator_t *iterator)
 Get the NVT 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 *name)
 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_credential_with_permission (const char *uuid, credential_t *credential, const char *permission)
 Find a credential for a specific permission, given a UUID. More...
 
static int validate_credential_username (const gchar *username)
 Test if a username is valid to use in a credential. More...
 
static gboolean validate_credential_username_for_format (const gchar *username, credential_format_t format)
 Test if a username is valid for a credential export format. More...
 
int create_credential (const char *name, const char *comment, const char *login, const char *given_password, const char *key_private, const char *key_public, const char *certificate, const char *community, const char *auth_algorithm, const char *privacy_password, const char *privacy_algorithm, const char *given_type, const char *allow_insecure, credential_t *credential)
 Create a Credential. More...
 
int copy_credential (const char *name, const char *comment, const char *credential_id, credential_t *new_credential)
 Create an LSC Credential from an existing one. More...
 
int modify_credential (const char *credential_id, const char *name, const char *comment, const char *login, const char *password, const char *key_private, const char *key_public, const char *certificate, const char *community, const char *auth_algorithm, const char *privacy_password, const char *privacy_algorithm, const char *allow_insecure)
 Modify a Credential. More...
 
int delete_credential (const char *credential_id, int ultimate)
 Delete a Credential. More...
 
int credential_count (const get_data_t *get)
 Count number of LSC Credentials. More...
 
int credential_in_use (credential_t credential)
 Check whether a Credential is in use. More...
 
int trash_credential_in_use (credential_t credential)
 Check whether a trashcan Credential is in use. More...
 
int credential_writable (credential_t credential)
 Check whether a Credential is writable. More...
 
int trash_credential_writable (credential_t credential)
 Check whether a trashcan Credential is writable. More...
 
gchar * credential_value (credential_t credential, const char *value_name)
 Get a value from a credential. More...
 
gchar * credential_encrypted_value (credential_t credential, const char *value_name)
 Get a possibly encrypted credential value in decrypted form. More...
 
void set_credential_privacy_algorithm (credential_t credential, const char *algorithm)
 Set the privacy_algorithm of a Credential. More...
 
void set_credential_public_key (credential_t credential, const char *public_key)
 Set the public key of a Credential. More...
 
void init_credential_iterator_one (iterator_t *iterator, credential_t credential)
 Initialise a Credential iterator, given a single Credential. More...
 
int init_credential_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a Credential iterator. More...
 
static const char * credential_iterator_encrypted_data (iterator_t *iterator, const char *type)
 Get possibly encrypted data from credentials. More...
 
int credential_iterator_allow_insecure (iterator_t *iterator)
 Get the login from a Credential iterator. More...
 
const char * credential_iterator_password (iterator_t *iterator)
 Get the password from a Credential iterator. More...
 
const char * credential_iterator_private_key (iterator_t *iterator)
 Get the private_key from a Credential iterator. More...
 
const char * credential_iterator_community (iterator_t *iterator)
 Get the SNMP community from a Credential iterator. More...
 
const char * credential_iterator_privacy_password (iterator_t *iterator)
 Get the privacy password from a Credential iterator. More...
 
char * credential_iterator_rpm (iterator_t *iterator)
 Get the rpm from a Credential iterator. More...
 
char * credential_iterator_deb (iterator_t *iterator)
 Get the deb from a Credential iterator. More...
 
char * credential_iterator_exe (iterator_t *iterator)
 Get the exe from a Credential iterator. More...
 
gboolean credential_iterator_format_available (iterator_t *iterator, credential_format_t format)
 Test if a credential format is available for an iterator. More...
 
gchar * credential_iterator_formats_xml (iterator_t *iterator)
 Get XML of available formats for a credential iterator. More...
 
char * credential_uuid (credential_t credential)
 Get the UUID of a Credential. More...
 
char * trash_credential_uuid (credential_t credential)
 Get the UUID of a Credential in the trashcan. More...
 
char * credential_name (credential_t credential)
 Get the name of an LSC credential. More...
 
char * trash_credential_name (credential_t credential)
 Get the name of an LSC credential in the trashcan. More...
 
char * credential_type (credential_t credential)
 Get the type of a Credential. More...
 
int trash_credential_readable (credential_t credential)
 Return whether a trashcan credential is readable. More...
 
void init_credential_target_iterator (iterator_t *iterator, credential_t credential, int ascending)
 Initialise a Credential target iterator. More...
 
int credential_target_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
void init_credential_scanner_iterator (iterator_t *iterator, credential_t credential, int ascending)
 Initialise a Credential scanner iterator. More...
 
int credential_scanner_iterator_readable (iterator_t *iterator)
 Get the read permission status from a Credential Scanner iterator. More...
 
static gboolean find_agent_with_permission (const char *uuid, agent_t *agent, const char *permission)
 Find a agent for a specific permission, given a UUID. More...
 
static int find_signature (const gchar *location, const gchar *installer_filename, gchar **signature, gsize *signature_size, gchar **uuid)
 Find a signature in a feed. More...
 
static const char * get_sysconf_gpghome ()
 Return the name of the sysconf GnuPG home directory. More...
 
static const char * get_trustedkeys_name ()
 Return the name of the trusted keys file name. More...
 
static int verify_signature (const gchar *installer, gsize installer_size, const gchar *signature, gsize signature_size, int *trust)
 Execute gpg to verify an installer signature. More...
 
int create_agent (const char *name, const char *comment, const char *installer_64, const char *installer_filename, const char *installer_signature_64, const char *howto_install, const char *howto_use, agent_t *agent)
 Create an agent entry. More...
 
int copy_agent (const char *name, const char *comment, const char *agent_id, agent_t *new_agent)
 Create an agent from an existing agent. More...
 
int modify_agent (const char *agent_id, const char *name, const char *comment)
 Modify an agent. More...
 
int delete_agent (const char *agent_id, int ultimate)
 Delete an agent. More...
 
int agent_in_use (agent_t agent)
 Check whether an agent is in use. More...
 
int trash_agent_in_use (agent_t agent)
 Check whether a trashcan agent is writable. More...
 
int agent_writable (agent_t agent)
 Check whether a agent is writable. More...
 
int trash_agent_writable (agent_t agent)
 Check whether a trashcan agent is writable. More...
 
char * agent_uuid (agent_t agent)
 Return the UUID of an agent. More...
 
resource_t get_iterator_resource (iterator_t *iterator)
 Get the resource from a GET iterator. More...
 
const char * get_iterator_comment (iterator_t *iterator)
 Get the comment from a GET iterator. More...
 
user_t get_iterator_owner (iterator_t *iterator)
 Get the owner from a GET iterator. More...
 
int init_agent_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise an agent iterator. More...
 
static gsize agent_iterator_installer_size (iterator_t *iterator)
 Get the installer size from an agent iterator. More...
 
const char * agent_iterator_trust (iterator_t *iterator)
 Get the trust value from an agent iterator. More...
 
time_t agent_iterator_trust_time (iterator_t *iterator)
 Get the installer trust time from a agent iterator. More...
 
int agent_count (const get_data_t *get)
 Count number of agents. More...
 
int verify_agent (const char *agent_id)
 Verify an agent. More...
 
gboolean find_note_with_permission (const char *uuid, note_t *note, const char *permission)
 Find a note for a specific permission, given a UUID. More...
 
static gboolean nvt_exists (const char *nvt)
 Check if an NVT exists. More...
 
int create_note (const char *active, const char *nvt, const char *text, const char *hosts, const char *port, const char *severity, const char *threat, task_t task, result_t result, note_t *note)
 Create a note. More...
 
int copy_note (const char *note_id, note_t *new_note)
 Create a note from an existing note. More...
 
int delete_note (const char *note_id, int ultimate)
 Delete a note. More...
 
int note_uuid (note_t note, char **id)
 Return the UUID of a note. More...
 
int modify_note (const gchar *note_id, const char *active, const char *nvt, const char *text, const char *hosts, const char *port, const char *severity, const char *threat, const gchar *task_id, const gchar *result_id)
 Modify a note. More...
 
int note_count (const get_data_t *get, nvt_t nvt, result_t result, task_t task)
 Count number of notes. More...
 
int init_note_iterator (iterator_t *iterator, const get_data_t *get, nvt_t nvt, result_t result, task_t task)
 Initialise a note iterator. More...
 
const char * note_iterator_threat (iterator_t *iterator)
 Get the threat from a note iterator. More...
 
task_t note_iterator_task (iterator_t *iterator)
 Get the task from a note iterator. More...
 
result_t note_iterator_result (iterator_t *iterator)
 Get the result from a note iterator. More...
 
time_t note_iterator_end_time (iterator_t *iterator)
 Get the end time from an note iterator. More...
 
int note_iterator_active (iterator_t *iterator)
 Get the active status from an note iterator. More...
 
const char * note_iterator_nvt_type (iterator_t *iterator)
 Get the NVT type from a note iterator. More...
 
gboolean find_override_with_permission (const char *uuid, override_t *override, const char *permission)
 Find a override for a specific permission, given a UUID. More...
 
int create_override (const char *active, const char *nvt, const char *text, const char *hosts, const char *port, const char *threat, const char *new_threat, const char *severity, const char *new_severity, task_t task, result_t result, override_t *override)
 Create an override. More...
 
int override_uuid (override_t override, char **id)
 Return the UUID of an override. More...
 
int copy_override (const char *override_id, override_t *new_override)
 Create a override from an existing override. More...
 
int delete_override (const char *override_id, int ultimate)
 Delete a override. More...
 
int modify_override (const gchar *override_id, const char *active, const char *nvt, const char *text, const char *hosts, const char *port, const char *threat, const char *new_threat, const char *severity, const char *new_severity, const gchar *task_id, const gchar *result_id)
 Modify an override. More...
 
int override_count (const get_data_t *get, nvt_t nvt, result_t result, task_t task)
 Count number of overrides. More...
 
int init_override_iterator (iterator_t *iterator, const get_data_t *get, nvt_t nvt, result_t result, task_t task)
 Initialise an override iterator. More...
 
const char * override_iterator_threat (iterator_t *iterator)
 Get the threat from a override iterator. More...
 
const char * override_iterator_new_threat (iterator_t *iterator)
 Get the threat from an override iterator. More...
 
task_t override_iterator_task (iterator_t *iterator)
 Get the task from a override iterator. More...
 
result_t override_iterator_result (iterator_t *iterator)
 Get the result from a override iterator. More...
 
time_t override_iterator_end_time (iterator_t *iterator)
 Get the end time from an override iterator. More...
 
int override_iterator_active (iterator_t *iterator)
 Get the active status from an override iterator. More...
 
const char * override_iterator_nvt_type (iterator_t *iterator)
 Get the NVT type from a override iterator. More...
 
int manage_create_scanner (GSList *log_config, const gchar *database, const char *name, const char *host, const char *port, const char *type, const char *ca_pub_path, const char *key_pub_path, const char *key_priv_path)
 Create the given scanner. More...
 
int manage_delete_scanner (GSList *log_config, const gchar *database, const gchar *uuid)
 Delete the given scanner. More...
 
int manage_modify_scanner (GSList *log_config, const gchar *database, const char *scanner_id, const char *name, const char *host, const char *port, const char *type, const char *ca_pub_path, const char *key_pub_path, const char *key_priv_path)
 Modify the given scanner. More...
 
int manage_verify_scanner (GSList *log_config, const gchar *database, const gchar *uuid)
 Verify the given scanner. More...
 
gboolean find_scanner_with_permission (const char *uuid, scanner_t *scanner, const char *permission)
 Find a scanner for a specific permission, given a UUID. More...
 
static void insert_scanner (const char *name, const char *comment, const char *host, const char *ca_pub, int iport, int itype, scanner_t *new_scanner)
 Insert a scanner for create_scanner. More...
 
int create_scanner (const char *name, const char *comment, const char *host, const char *port, const char *type, scanner_t *new_scanner, const char *ca_pub, const char *credential_id)
 Create a scanner. More...
 
int copy_scanner (const char *name, const char *comment, const char *scanner_id, scanner_t *new_scanner)
 Create a scanner from an existing scanner. More...
 
int modify_scanner (const char *scanner_id, const char *name, const char *comment, const char *host, const char *port, const char *type, const char *ca_pub, const char *credential_id)
 Modify an scanner. More...
 
int delete_scanner (const char *scanner_id, int ultimate)
 Delete a scanner. More...
 
int init_scanner_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise an scanner iterator. More...
 
int scanner_iterator_port (iterator_t *iterator)
 Get the port from an scanner iterator. More...
 
int scanner_iterator_type (iterator_t *iterator)
 Get the type from an scanner iterator. More...
 
credential_t scanner_iterator_credential (iterator_t *iterator)
 Get the credential of the scanner from a scanner iterator. More...
 
int scanner_iterator_credential_trash (iterator_t *iterator)
 Get the credential location of the scanner from a scanner iterator. More...
 
static const char * scanner_iterator_key_priv (iterator_t *iterator)
 Get the Scanner private key from a scanner iterator. More...
 
void init_scanner_config_iterator (iterator_t *iterator, scanner_t scanner)
 Initialise a scanner config iterator. More...
 
int scanner_config_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
void init_scanner_task_iterator (iterator_t *iterator, scanner_t scanner)
 Initialise a scanner task iterator. More...
 
int scanner_task_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
int scanner_in_use (scanner_t scanner)
 Check whether an scanner is in use. More...
 
int trash_scanner_in_use (scanner_t scanner)
 Check whether a trashcan scanner is writable. More...
 
int scanner_writable (scanner_t scanner)
 Check whether a scanner is writable. More...
 
int trash_scanner_writable (scanner_t scanner)
 Check whether a trashcan scanner is writable. More...
 
int trash_scanner_readable (scanner_t scanner)
 Return whether a trashcan scanner is readable. More...
 
char * scanner_name (scanner_t scanner)
 Return the name of a scanner. More...
 
char * scanner_uuid (scanner_t scanner)
 Return the UUID of a scanner. More...
 
const char * scanner_uuid_default ()
 Return the UUID of the default scanner. More...
 
char * scanner_host (scanner_t scanner)
 Return the host of a scanner. More...
 
int scanner_port (scanner_t scanner)
 Return the port of a scanner. More...
 
int scanner_type (scanner_t scanner)
 Return the type of a scanner. More...
 
char * scanner_ca_pub (scanner_t scanner)
 Return the CA Certificate of a scanner. More...
 
char * scanner_key_pub (scanner_t scanner)
 Return the Certificate of a scanner. More...
 
char * scanner_key_priv (scanner_t scanner)
 Return the private key of a scanner. More...
 
char * scanner_login (scanner_t scanner)
 Return the login associated with a scanner. More...
 
char * scanner_password (scanner_t scanner)
 Return the password associated with a scanner. More...
 
char * trash_scanner_name (scanner_t scanner)
 Return the name of a scanner in the trashcan. More...
 
char * trash_scanner_uuid (scanner_t scanner)
 Return the UUID of a scanner in the trashcan. More...
 
int scanner_count (const get_data_t *get)
 Count number of scanners. More...
 
osp_connection_t * osp_scanner_connect (scanner_t scanner)
 Create a new connection to an OSP scanner. More...
 
int osp_get_version_from_iterator (iterator_t *iterator, char **s_name, char **s_ver, char **d_name, char **d_ver, char **p_name, char **p_ver)
 Get an OSP Scanner's get_version info. More...
 
int osp_get_details_from_iterator (iterator_t *iterator, char **desc, GSList **params)
 Get an OSP Scanner's get_scanner_details info. More...
 
static int connect_unix (const gchar *path)
 Connect a UNIX socket. More...
 
static int connection_open (gvm_connection_t *connection, const gchar *address, int port)
 Connect to an address. More...
 
int verify_scanner (const char *scanner_id, char **version)
 Verify a scanner. More...
 
int manage_get_scanners (GSList *log_config, const gchar *database)
 List scanners. More...
 
gboolean find_schedule_with_permission (const char *uuid, schedule_t *schedule, const char *permission)
 Find a schedule for a specific permission, given a UUID. More...
 
static int byday_from_string (const char *byday)
 Get Byday mask from ical style string. More...
 
int create_schedule (const char *name, const char *comment, const char *ical_string, time_t first_time, time_t period, time_t period_months, const char *byday, time_t duration, const char *zone, schedule_t *schedule, gchar **error_out)
 Create a schedule. More...
 
int copy_schedule (const char *name, const char *comment, const char *schedule_id, schedule_t *new_schedule)
 Create a schedule from an existing schedule. More...
 
int delete_schedule (const char *schedule_id, int ultimate)
 Delete a schedule. More...
 
int schedule_in_use (schedule_t schedule)
 Return whether a schedule is in use by a task. More...
 
int trash_schedule_in_use (schedule_t schedule)
 Return whether a trashcan schedule is in use by a task. More...
 
int schedule_writable (schedule_t schedule)
 Return whether a schedule is writable. More...
 
int trash_schedule_writable (schedule_t schedule)
 Return whether a trashcan schedule is writable. More...
 
int trash_schedule_readable (schedule_t schedule)
 Return whether a trashcan schedule is readable. More...
 
char * schedule_uuid (schedule_t schedule)
 Return the UUID of a schedule. More...
 
char * trash_schedule_uuid (schedule_t schedule)
 Return the UUID of a trash schedule. More...
 
char * schedule_name (schedule_t schedule)
 Return the name of a schedule. More...
 
char * trash_schedule_name (schedule_t schedule)
 Return the name of a trash schedule. More...
 
int schedule_period (schedule_t schedule)
 Return the period of a schedule. More...
 
int schedule_duration (schedule_t schedule)
 Return the duration of a schedule. More...
 
int schedule_info (schedule_t schedule, int trash, time_t *first_time, time_t *next_time, int *period, int *period_months, int *duration, gchar **icalendar, gchar **zone)
 Return info about a schedule. More...
 
int schedule_count (const get_data_t *get)
 Count the number of schedules. More...
 
int init_schedule_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a schedule iterator. More...
 
time_t schedule_iterator_first_time (iterator_t *iterator)
 Get the first time from a schedule iterator. More...
 
time_t schedule_iterator_period (iterator_t *iterator)
 Get the period from a schedule iterator. More...
 
time_t schedule_iterator_period_months (iterator_t *iterator)
 Get the period months from a schedule iterator. More...
 
gchar * schedule_iterator_byday_string (iterator_t *iterator)
 Get the byday string from a schedule iterator. More...
 
time_t schedule_iterator_duration (iterator_t *iterator)
 Get the duration from a schedule iterator. More...
 
time_t schedule_iterator_next_time (iterator_t *iterator)
 Get the next time a schedule could be schedulable. More...
 
int init_task_schedule_iterator (iterator_t *iterator)
 Initialise a task schedule iterator. More...
 
void cleanup_task_schedule_iterator (iterator_t *iterator)
 Cleanup a task schedule iterator. More...
 
task_t task_schedule_iterator_task (iterator_t *iterator)
 Get the task from a task schedule iterator. More...
 
static time_t task_schedule_iterator_next_time (iterator_t *iterator)
 Get the next time from a task schedule iterator. More...
 
static time_t task_schedule_iterator_duration (iterator_t *iterator)
 Get the next time from a task schedule iterator. More...
 
gboolean task_schedule_iterator_start_due (iterator_t *iterator)
 Get the start due state from a task schedule iterator. More...
 
gboolean task_schedule_iterator_stop_due (iterator_t *iterator)
 Get the stop due state from a task schedule iterator. More...
 
gboolean task_schedule_iterator_timed_out (iterator_t *iterator)
 Get if schedule of task in iterator is timed out. More...
 
void init_schedule_task_iterator (iterator_t *iterator, schedule_t schedule)
 Initialise a schedule task iterator. More...
 
int schedule_task_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
int modify_schedule (const char *schedule_id, const char *name, const char *comment, const char *ical_string, time_t first_time, time_t period, time_t period_months, const char *byday, time_t duration, const char *zone, gchar **error_out)
 Modify a schedule. More...
 
gboolean find_report_format_with_permission (const char *uuid, report_format_t *report_format, const char *permission)
 Find a reportformat for a specific permission, given a UUID. More...
 
static gint compare_files (gconstpointer one, gconstpointer two)
 Compare files for create_report_format. More...
 
int create_report_format (const char *uuid, const char *name, const char *content_type, const char *extension, const char *summary, const char *description, int global, array_t *files, array_t *params, array_t *params_options, const char *signature, report_format_t *report_format)
 Create a report format. More...
 
int copy_report_format (const char *name, const char *source_uuid, report_format_t *new_report_format)
 Create Report Format from an existing Report Format. More...
 
int modify_report_format (const char *report_format_id, const char *name, const char *summary, const char *active, const char *param_name, const char *param_value, const char *predefined)
 Modify a report format. More...
 
static int move_report_format_dir (const char *dir, const char *new_dir)
 Move a report format directory. More...
 
static void delete_report_format_rows (report_format_t report_format)
 Delete a report format from the db. More...
 
int delete_report_format (const char *report_format_id, int ultimate)
 Delete a report format. More...
 
char * report_format_uuid (report_format_t report_format)
 Return the UUID of a report format. More...
 
char * report_format_owner_uuid (report_format_t report_format)
 Return the UUID of the owner of a report format. More...
 
char * report_format_name (report_format_t report_format)
 Return the name of a report format. More...
 
char * report_format_content_type (report_format_t report_format)
 Return the content type of a report format. More...
 
int report_format_in_use (report_format_t report_format)
 Return whether a report format is referenced by an alert. More...
 
int trash_report_format_in_use (report_format_t report_format)
 Return whether a report format in trash is referenced by an alert. More...
 
int report_format_writable (report_format_t report_format)
 Return whether a report format is writable. More...
 
int trash_report_format_writable (report_format_t report_format)
 Return whether a trashcan report_format is writable. More...
 
char * report_format_extension (report_format_t report_format)
 Return the extension of a report format. More...
 
int report_format_predefined (report_format_t report_format)
 Return whether a report format is predefined. More...
 
int report_format_active (report_format_t report_format)
 Return whether a report format is active. More...
 
static report_format_param_type_t report_format_param_type (report_format_t report_format, const char *name)
 Return the type max of a report format param. More...
 
static long long int report_format_param_type_max (report_format_t report_format, const char *name)
 Return the type max of a report format param. More...
 
static long long int report_format_param_type_min (report_format_t report_format, const char *name)
 Return the type min of a report format param. More...
 

Variables

int authenticate_allow_all
 Flag to force authentication to succeed. More...
 
static manage_connection_forker_t manage_fork_connection
 Function to fork a connection that will accept GMP requests.
 
static int max_hosts = MANAGE_MAX_HOSTS
 Max number of hosts per target.
 
static int slave_commit_size = SLAVE_COMMIT_SIZE_DEFAULT
 Maximum number of SQL queries per transaction in slave updates.
 
static int max_content_length = MAX_CONTENT_LENGTH
 Maximum number of bytes of reports included in email alerts. More...
 
static int max_attach_length = MAX_ATTACH_LENGTH
 Maximum number of bytes of reports attached to email alerts. More...
 
static int max_email_message_length = MAX_EMAIL_MESSAGE_LENGTH
 Maximum number of bytes of user-defined message text in email alerts. More...
 
static nvtis_t * nvti_cache = NULL
 Memory cache of NVT information from the database.
 
gchar * gvmd_db_name = NULL
 Name of the database file.
 
static gboolean in_transaction
 Whether a transaction has been opened and not committed yet.
 
static struct timeval last_msg
 Time of reception of the currently processed message.
 
command_t gmp_commands []
 The GMP command list.
 
static int table_order_if_sort_not_specified = 0
 Flag to control the default sorting produced by split_filter. More...
 
static sql_stmt_tprognosis_stmt = NULL
 Prognosis iterator prepared statement.
 
int ignore_max_rows_per_page = 0
 Whether to ignore the Max Rows Per Page settings.
 

Detailed Description

The Greenbone Vulnerability Manager management library (SQLite implementation).

This file defines the SQLite specific portions of the Greenbone Vulnerability Manager management library.

Macro Definition Documentation

◆ AGENT_ITERATOR_COLUMNS

#define AGENT_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (agents), \
{ "installer", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_64", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_filename", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_signature_64", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_trust" , NULL, KEYWORD_TYPE_STRING }, \
{ "installer_trust_time", NULL, KEYWORD_TYPE_STRING }, \
{ "howto_install", NULL, KEYWORD_TYPE_STRING }, \
{ "howto_use", NULL, KEYWORD_TYPE_STRING }, \
{ \
"(CASE" \
" WHEN installer_trust = 1 THEN 'yes'" \
" WHEN installer_trust = 2 THEN 'no'" \
" WHEN installer_trust = 3 THEN 'unknown'" \
" ELSE ''" \
" END)" \
" || ' (' || iso_time (installer_trust_time) || ')'", \
"trust", \
KEYWORD_TYPE_STRING \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Agent iterator columns.

◆ AGENT_ITERATOR_TRASH_COLUMNS

#define AGENT_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (agents_trash), \
{ "installer", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_64", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_filename", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_signature_64", NULL, KEYWORD_TYPE_STRING }, \
{ "installer_trust" , NULL, KEYWORD_TYPE_STRING }, \
{ "installer_trust_time", NULL, KEYWORD_TYPE_STRING }, \
{ "howto_install", NULL, KEYWORD_TYPE_STRING }, \
{ "howto_use", NULL, KEYWORD_TYPE_STRING }, \
{ \
"(CASE" \
" WHEN installer_trust = 1 THEN 'yes'" \
" WHEN installer_trust = 2 THEN 'no'" \
" WHEN installer_trust = 3 THEN 'unknown'" \
" ELSE ''" \
" END)" \
" || ' (' || iso_time (installer_trust_time) || ')'", \
"trust", \
KEYWORD_TYPE_STRING \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Agent iterator columns for trash case.

◆ ALERT_ITERATOR_COLUMNS

#define ALERT_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (alerts), \
{ "event", NULL, KEYWORD_TYPE_INTEGER }, \
{ "condition", NULL, KEYWORD_TYPE_INTEGER }, \
{ "method", NULL, KEYWORD_TYPE_INTEGER }, \
{ "filter", NULL, KEYWORD_TYPE_INTEGER }, \
{ G_STRINGIFY (LOCATION_TABLE), NULL, KEYWORD_TYPE_INTEGER }, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Alert iterator columns.

◆ ALERT_ITERATOR_FILTER_COLUMNS

#define ALERT_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "event", "condition", "method", \
"filter", NULL }

Filter columns for alert iterator.

◆ ALERT_ITERATOR_TRASH_COLUMNS

#define ALERT_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (alerts_trash), \
{ "event", NULL, KEYWORD_TYPE_INTEGER }, \
{ "condition", NULL, KEYWORD_TYPE_INTEGER }, \
{ "method", NULL, KEYWORD_TYPE_INTEGER }, \
{ "filter", NULL, KEYWORD_TYPE_STRING }, \
{ "filter_location", NULL, KEYWORD_TYPE_INTEGER}, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Alert iterator columns for trash case.

◆ APPEND_VFIRE_PARAM

#define APPEND_VFIRE_PARAM (   param)
Value:
if (param) \
xml_string_append (config_xml, \
"<" G_STRINGIFY(param) ">%s</" G_STRINGIFY(param) ">", \
param); \
else \
{ \
*message = g_strdup ("Mandatory " G_STRINGIFY(param) " missing."); \
g_warning ("%s: Missing " G_STRINGIFY(param) ".", __FUNCTION__); \
g_string_free (config_xml, TRUE); \
return -1; \
}

Checks a mandatory vFire parameter and adds it to the config XML.

Parameters
[in]paramThe parameter to check.

◆ CONFIG_ITERATOR_COLUMNS

#define CONFIG_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (configs), \
{ "nvt_selector", NULL, KEYWORD_TYPE_STRING }, \
{ "family_count", "families_total", KEYWORD_TYPE_INTEGER }, \
{ "nvt_count", "nvts_total", KEYWORD_TYPE_INTEGER}, \
{ "families_growing", "families_trend", KEYWORD_TYPE_INTEGER}, \
{ "nvts_growing", "nvts_trend", KEYWORD_TYPE_INTEGER }, \
{ "type", NULL, KEYWORD_TYPE_INTEGER }, \
{ "scanner", NULL, KEYWORD_TYPE_INTEGER }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Scan config iterator columns.

◆ CONFIG_ITERATOR_FILTER_COLUMNS

#define CONFIG_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "nvt_selector", "families_total", \
"nvts_total", "families_trend", "nvts_trend", "type", NULL }

Filter columns for scan configs iterator.

◆ CONFIG_ITERATOR_TRASH_COLUMNS

#define CONFIG_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (configs_trash), \
{ "nvt_selector", NULL, KEYWORD_TYPE_STRING }, \
{ "family_count", "families_total", KEYWORD_TYPE_INTEGER }, \
{ "nvt_count", "nvts_total", KEYWORD_TYPE_INTEGER}, \
{ "families_growing", "families_trend", KEYWORD_TYPE_INTEGER}, \
{ "nvts_growing", "nvts_trend", KEYWORD_TYPE_INTEGER }, \
{ "type", NULL, KEYWORD_TYPE_INTEGER }, \
{ "scanner", NULL, KEYWORD_TYPE_INTEGER }, \
{ "scanner_location", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Scan config iterator columns for trash case.

◆ FILTER_ITERATOR_COLUMNS

#define FILTER_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (filters), \
{ "type" , NULL, KEYWORD_TYPE_STRING }, \
{ "term", NULL, KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ FILTER_ITERATOR_TRASH_COLUMNS

#define FILTER_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (filters_trash), \
{ "type" , NULL, KEYWORD_TYPE_STRING }, \
{ "term", NULL, KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ GROUP_ITERATOR_COLUMNS

#define GROUP_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (groups), \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ GROUP_ITERATOR_TRASH_COLUMNS

#define GROUP_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (groups_trash), \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ HOST_ITERATOR_FILTER_COLUMNS

#define HOST_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "severity", "os", "oss", "hostname", "ip", \
"severity_level", "updated", NULL }

◆ HOST_ITERATOR_WHERE_COLUMNS

#define HOST_ITERATOR_WHERE_COLUMNS
Value:
{ \
{ \
"(SELECT severity_to_level (CAST (severity AS numeric), 0)" \
" FROM host_max_severities" \
" WHERE host = hosts.id" \
" ORDER by creation_time DESC" \
" LIMIT 1)", \
"severity_level", \
KEYWORD_TYPE_STRING \
}, \
{ \
"modification_time", "updated", KEYWORD_TYPE_INTEGER \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ NEW_CERT_BUNDS_HEADER

#define NEW_CERT_BUNDS_HEADER
Value:
/* CB-K13/0849 Novell SUSE Linux Enterprise Server: Mehrere Schwachstellen... */ \
"Name Title\n" \
"------------------------------------------------------------------------------------------\n"

Header for "New CERT-Bund Advisories" alert message.

◆ NEW_CPES_HEADER

#define NEW_CPES_HEADER
Value:
/* cpe:/a:.joomclan:com_joomclip 1024cms... */ \
"Name Title\n" \
"------------------------------------------------------------------------------------------\n"

Header for "New CPEs" alert message.

◆ NEW_CVES_HEADER

#define NEW_CVES_HEADER
Value:
/* CVE-2014-100001 6.8 Cross-site request forgery (CSRF) vulnerability in... */ \
"Name Severity Description\n" \
"--------------------------------------------------------------------------------\n"

Header for "New CVEs" alert message.

◆ NEW_DFN_CERTS_HEADER

#define NEW_DFN_CERTS_HEADER
Value:
/* DFN-CERT-2008-1100 Denial of Service Schwachstelle in der... */ \
"Name Title\n" \
"------------------------------------------------------------------------------------------\n"

Header for "New DFN-CERT Advisories" alert message.

◆ NEW_NVTS_HEADER

#define NEW_NVTS_HEADER
Value:
/* Open-Xchange (OX) AppSuite XHTML File HTML Injection Vuln... NoneAvailable 0.0 100% */ \
"Name Solution Type Severity QOD\n" \
"------------------------------------------------------------------------------------------\n"

Header for "New NVTs" alert message.

◆ NEW_NVTS_HEADER_OID

#define NEW_NVTS_HEADER_OID
Value:
/* Open-Xchange (OX) AppSuite XHTML File HTML Injection Vuln... NoneAvailable 0.0 100% 1.3... */ \
"Name Solution Type Severity QOD OID\n" \
"------------------------------------------------------------------------------------------------\n"

Header for "New NVTs" alert message, when there's an OID.

◆ NEW_OVAL_DEFS_HEADER

#define NEW_OVAL_DEFS_HEADER
Value:
/* oval:org.mitre.oval:def:100116 libtiff Malloc Error Denial of Service */ \
"OVAL ID Title\n" \
"------------------------------------------------------------------------------------------\n"

Header for "New CERT-Bund Advisories" alert message.

◆ NOTE_ITERATOR_FILTER_COLUMNS

#define NOTE_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "name", "nvt", "text", "nvt_id", \
"task_name", "task_id", "hosts", "port", "active", "result", "severity", \
"end_time", "active_days", NULL }

Filter columns for note iterator.

◆ OS_ITERATOR_FILTER_COLUMNS

#define OS_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "title", "hosts", "latest_severity", \
"highest_severity", "average_severity", "average_severity_score", \
"severity", NULL }

◆ OS_ITERATOR_WHERE_COLUMNS

#define OS_ITERATOR_WHERE_COLUMNS
Value:
{ \
{ \
"(SELECT round (CAST (avg (severity) AS numeric)" \
" * (SELECT count (distinct host)" \
" FROM host_oss WHERE os = oss.id), 2)" \
" FROM (SELECT (SELECT severity FROM host_max_severities" \
" WHERE host = hosts.host" \
" ORDER BY creation_time DESC LIMIT 1)" \
" AS severity" \
" FROM (SELECT distinct host FROM host_oss WHERE os = oss.id)" \
" AS hosts)" \
" AS severities)", \
"average_severity_score", \
KEYWORD_TYPE_DOUBLE \
}, \
{ \
"(SELECT round (CAST (avg (severity) AS numeric), 2)" \
" FROM (SELECT (SELECT severity FROM host_max_severities" \
" WHERE host = hosts.host" \
" ORDER BY creation_time DESC LIMIT 1)" \
" AS severity" \
" FROM (SELECT distinct host FROM host_oss WHERE os = oss.id)" \
" AS hosts)" \
" AS severities)", \
"severity", \
KEYWORD_TYPE_DOUBLE \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ OVERRIDE_ITERATOR_FILTER_COLUMNS

#define OVERRIDE_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "name", "nvt", "text", "nvt_id", \
"task_name", "task_id", "hosts", "port", "threat", "new_threat", "active", \
"result", "severity", "new_severity", "active_days", NULL }

Filter columns for override iterator.

◆ PERMISSION_ITERATOR_FILTER_COLUMNS

#define PERMISSION_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "type", "resource_uuid", "subject_type", \
"_subject", "_resource", "subject_uuid", "orphan", NULL }

◆ PRINT

#define PRINT (   stream,
  format,
  args... 
)
Value:
do \
{ \
gchar *msg; \
msg = g_markup_printf_escaped (format, ## args); \
if (fprintf (stream, "%s", msg) < 0) \
{ \
g_free (msg); \
fclose (stream); \
return -1; \
} \
g_free (msg); \
} \
while (0)

Write to a file or close stream and exit.

Parameters
[in]streamStream to write to.
[in]formatFormat specification.
[in]argsArguments.

◆ PRINT_REPORT_ERROR

#define PRINT_REPORT_ERROR (   stream,
  errors,
  asset_id 
)
Value:
do \
{ \
PRINT (stream, \
"<error>" \
"<host>" \
"%s" \
"<asset asset_id=\"%s\"/>" \
"</host>" \
"<port>%s</port>" \
"<description>%s</description>" \
"<nvt oid=\"%s\">" \
"<type>nvt</type>" \
"<name>%s</name>" \
"<cvss_base>%s</cvss_base>" \
"</nvt>" \
"<scan_nvt_version>%s</scan_nvt_version>" \
"<severity>%s</severity>" \
"</error>", \
report_errors_iterator_host (errors) ?: "", \
asset_id ? asset_id : "", \
report_errors_iterator_port (errors), \
report_errors_iterator_desc (errors), \
report_errors_iterator_nvt_oid (errors), \
report_errors_iterator_nvt_name (errors), \
report_errors_iterator_nvt_cvss (errors), \
report_errors_iterator_scan_nvt_version (errors), \
report_errors_iterator_severity (errors)); \
} \
while (0)

Write report error message to file stream.

Parameters
[in]streamStream to write to.
[in]errorsPointer to report error messages iterator.
[in]asset_idAsset ID.

◆ PRINT_XML

#define PRINT_XML (   stream,
  xml 
)
Value:
do \
{ \
if (fprintf (stream, "%s", xml) < 0) \
{ \
fclose (stream); \
return -1; \
} \
} \
while (0)

Write XML to a file or close stream and return.

Parameters
[in]streamStream to write to.
[in]xmlXML.

◆ RANGE

#define RANGE (   type,
  start,
  end 
)
Value:
sql ("INSERT INTO port_ranges" \
" (uuid, port_list, type, start, \"end\", comment, exclude)" \
" VALUES" \
" (make_uuid (), %llu, %i," \
" '" G_STRINGIFY (start) "'," \
" '" G_STRINGIFY (end) "'," \
" '', 0)", \
list, \
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:202
keyword_type_t type
Type of keyword.
Definition: manage.h:3589

Insert a port range.

◆ REPORT_FORMAT_ITERATOR_COLUMNS

#define REPORT_FORMAT_ITERATOR_COLUMNS
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "''", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "creation_time", "created", KEYWORD_TYPE_INTEGER }, \
{ "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \
{ \
"(SELECT name FROM users WHERE users.id = report_formats.owner)", \
"_owner", \
KEYWORD_TYPE_STRING \
}, \
{ "owner", NULL, KEYWORD_TYPE_INTEGER }, \
{ "extension", NULL, KEYWORD_TYPE_STRING }, \
{ "content_type", NULL, KEYWORD_TYPE_STRING }, \
{ "summary", NULL, KEYWORD_TYPE_STRING }, \
{ "description", NULL, KEYWORD_TYPE_STRING }, \
{ "signature", NULL, KEYWORD_TYPE_STRING }, \
{ "trust", NULL, KEYWORD_TYPE_INTEGER }, \
{ "trust_time", NULL, KEYWORD_TYPE_INTEGER }, \
{ "flags & 1", "active", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ REPORT_FORMAT_ITERATOR_FILTER_COLUMNS

#define REPORT_FORMAT_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "name", "extension", "content_type", \
"summary", "description", "trust", "trust_time", "active", NULL }

◆ REPORT_FORMAT_ITERATOR_TRASH_COLUMNS

#define REPORT_FORMAT_ITERATOR_TRASH_COLUMNS
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "''", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (creation_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (modification_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "creation_time", "created", KEYWORD_TYPE_INTEGER }, \
{ "modification_time", "modified", KEYWORD_TYPE_INTEGER }, \
{ \
"(SELECT name FROM users" \
" WHERE users.id = report_formats_trash.owner)", \
"_owner", \
KEYWORD_TYPE_STRING \
}, \
{ "owner", NULL, KEYWORD_TYPE_INTEGER }, \
{ "extension", NULL, KEYWORD_TYPE_STRING }, \
{ "content_type", NULL, KEYWORD_TYPE_STRING }, \
{ "summary", NULL, KEYWORD_TYPE_STRING }, \
{ "description", NULL, KEYWORD_TYPE_STRING }, \
{ "signature", NULL, KEYWORD_TYPE_STRING }, \
{ "trust", NULL, KEYWORD_TYPE_INTEGER }, \
{ "trust_time", NULL, KEYWORD_TYPE_INTEGER }, \
{ "flags & 1", "active", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ REPORT_ITERATOR_COLUMNS

#define REPORT_ITERATOR_COLUMNS
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (start_time)", "name", KEYWORD_TYPE_STRING }, \
{ "''", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (start_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (end_time)", NULL, KEYWORD_TYPE_STRING }, \
{ "start_time", "created", KEYWORD_TYPE_INTEGER }, \
{ "end_time", "modified", KEYWORD_TYPE_INTEGER }, \
{ "(SELECT name FROM users WHERE users.id = reports.owner)", \
"_owner", \
KEYWORD_TYPE_STRING }, \
{ "owner", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Report iterator columns.

◆ REPORT_ITERATOR_FILTER_COLUMNS

#define REPORT_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "task_id", "name", "date", "status", \
"task", "severity", "false_positive", "log", "low", "medium", "high", \
"hosts", "result_hosts", "fp_per_host", "log_per_host", "low_per_host", \
"medium_per_host", "high_per_host", "duration", "duration_per_host", \
NULL }

Filter columns for report iterator.

◆ RESULT_ITERATOR_COLUMNS

#define RESULT_ITERATOR_COLUMNS
Value:
{ \
BASE_RESULT_ITERATOR_COLUMNS \
{ SECINFO_SQL_RESULT_HAS_CERT_BUNDS, \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ SECINFO_SQL_RESULT_HAS_DFN_CERTS, \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Result iterator columns.

◆ RESULT_ITERATOR_COLUMNS_NO_CERT

#define RESULT_ITERATOR_COLUMNS_NO_CERT
Value:
{ \
BASE_RESULT_ITERATOR_COLUMNS \
{ "0", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "0", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Result iterator columns, when CERT db is not loaded.

◆ RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE

#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE
Value:
{ \
BASE_RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE \
{ SECINFO_SQL_RESULT_HAS_CERT_BUNDS, \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ SECINFO_SQL_RESULT_HAS_DFN_CERTS, \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Result iterator columns.

◆ RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE_NO_CERT

#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE_NO_CERT
Value:
{ \
BASE_RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE \
{ "0", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "0", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Result iterator columns, when CERT db is not loaded.

◆ RESULT_ITERATOR_FILTER_COLUMNS

#define RESULT_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "host", "location", "nvt", \
"type", "original_type", "auto_type", \
"description", "task", "report", "cvss_base", "nvt_version", \
"severity", "original_severity", "vulnerability", "date", "report_id", \
"solution_type", "qod", "qod_type", "task_id", "cve", "hostname", NULL }

Filter columns for result iterator.

◆ ROLE_ITERATOR_COLUMNS

#define ROLE_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (roles), \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ ROLE_ITERATOR_TRASH_COLUMNS

#define ROLE_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (roles_trash), \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ SCANNER_ITERATOR_COLUMNS

#define SCANNER_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (scanners), \
{ "host", NULL, KEYWORD_TYPE_STRING }, \
{ "port", NULL, KEYWORD_TYPE_INTEGER }, \
{ "type", NULL, KEYWORD_TYPE_INTEGER }, \
{ "ca_pub", NULL, KEYWORD_TYPE_STRING }, \
{ \
"(SELECT name FROM credentials WHERE id = credential)", \
"credential", \
KEYWORD_TYPE_STRING \
}, \
{ "credential", NULL, KEYWORD_TYPE_INTEGER }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "credential_value (credential, 0, CAST ('certificate' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ "credential_value (credential, 0, CAST ('private_key' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ "credential_value (credential, 0, CAST ('secret' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ \
"(SELECT type FROM credentials WHERE id = credential)", \
"credential_type", \
KEYWORD_TYPE_STRING \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Scanner iterator columns.

◆ SCANNER_ITERATOR_TRASH_COLUMNS

#define SCANNER_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (scanners_trash), \
{ "host" , NULL, KEYWORD_TYPE_STRING }, \
{ "port" , NULL, KEYWORD_TYPE_INTEGER }, \
{ "type", NULL, KEYWORD_TYPE_INTEGER }, \
{ "ca_pub", NULL, KEYWORD_TYPE_STRING }, \
{ \
"(SELECT CASE" \
" WHEN credential_location = " G_STRINGIFY (LOCATION_TABLE) \
" THEN (SELECT name FROM credentials WHERE id = credential)" \
" ELSE (SELECT name FROM credentials_trash WHERE id = credential)" \
" END)", \
"credential", \
KEYWORD_TYPE_STRING \
}, \
{ "credential", NULL, KEYWORD_TYPE_INTEGER }, \
{ "credential_location", NULL, KEYWORD_TYPE_INTEGER }, \
{ "credential_value (credential, 1, CAST ('certificate' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ "credential_value (credential, 1, CAST ('private_key' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ "credential_value (credential, 1, CAST ('secret' AS TEXT))", \
NULL, \
KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Scanner iterator columns for trash case.

◆ SCHEDULE_ITERATOR_COLUMNS

#define SCHEDULE_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (schedules), \
{ "first_time", NULL, KEYWORD_TYPE_INTEGER }, \
{ "period", NULL, KEYWORD_TYPE_INTEGER }, \
{ "period_months", NULL, KEYWORD_TYPE_INTEGER }, \
{ "byday", NULL, KEYWORD_TYPE_INTEGER }, \
{ "duration", NULL, KEYWORD_TYPE_INTEGER }, \
{ "timezone", NULL, KEYWORD_TYPE_STRING }, \
{ "initial_offset", NULL, KEYWORD_TYPE_INTEGER }, \
{ "icalendar", NULL, KEYWORD_TYPE_STRING }, \
{ "next_time_ical (icalendar, timezone)", \
"next_run", \
KEYWORD_TYPE_INTEGER }, \
{ "first_time", "first_run", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Schedule iterator columns.

◆ SCHEDULE_ITERATOR_FILTER_COLUMNS

#define SCHEDULE_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "first_time", "period", "period_months", \
"duration", "timezone", "initial_offset", "first_run", "next_run", NULL }

Filter columns for schedule iterator.

◆ SCHEDULE_ITERATOR_TRASH_COLUMNS

#define SCHEDULE_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (schedules_trash), \
{ "first_time", NULL, KEYWORD_TYPE_INTEGER }, \
{ "period", NULL, KEYWORD_TYPE_INTEGER }, \
{ "period_months", NULL, KEYWORD_TYPE_INTEGER }, \
{ "byday", NULL, KEYWORD_TYPE_INTEGER }, \
{ "duration", NULL, KEYWORD_TYPE_INTEGER }, \
{ "timezone", NULL, KEYWORD_TYPE_STRING }, \
{ "initial_offset", NULL, KEYWORD_TYPE_INTEGER }, \
{ "icalendar", NULL, KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Schedule iterator columns for trash case.

◆ SECINFO_SIMPLE_NOTICE_FORMAT

#define SECINFO_SIMPLE_NOTICE_FORMAT
Value:
"%s.\n" \
"\n" \
"After the event %s,\n" \
"the following condition was met: %s\n" \
"\n" \
"This email escalation is not configured to provide more details.\n" \
"Full details are stored on the scan engine.\n" \
"\n" \
"\n" \
"Note:\n" \
"This email was sent to you as a configured security scan escalation.\n" \
"Please contact your local system administrator if you think you\n" \
"should not have received it.\n"

Format string for simple notice alert email.

◆ SETTING_ITERATOR_COLUMNS

#define SETTING_ITERATOR_COLUMNS
Value:
{ \
{ "id" , NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "comment", NULL, KEYWORD_TYPE_STRING }, \
{ "value", NULL, KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ SIMPLE_NOTICE_FORMAT

#define SIMPLE_NOTICE_FORMAT
Value:
"%s.\n" \
"\n" \
"After the event %s,\n" \
"the following condition was met: %s\n" \
"\n" \
"This email escalation is not configured to provide more details.\n" \
"Full details are stored on the scan engine.\n" \
"\n" \
"\n" \
"Note:\n" \
"This email was sent to you as a configured security scan escalation.\n" \
"Please contact your local system administrator if you think you\n" \
"should not have received it.\n"

Format string for simple notice alert email.

◆ TAG_ITERATOR_COLUMNS

#define TAG_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (tags), \
{ "resource_type", NULL, KEYWORD_TYPE_STRING }, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ "value", NULL, KEYWORD_TYPE_STRING }, \
{ "(SELECT count(*) FROM tag_resources" \
" WHERE tag = tags.id" \
" AND resource_location = " G_STRINGIFY (LOCATION_TABLE) ")", \
"resources", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ TAG_ITERATOR_FILTER_COLUMNS

#define TAG_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "resource_type", "active", "value", \
"resources", NULL }

◆ TAG_ITERATOR_TRASH_COLUMNS

#define TAG_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (tags_trash), \
{ "resource_type", NULL, KEYWORD_TYPE_STRING }, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ "value", NULL, KEYWORD_TYPE_STRING }, \
{ "(SELECT count(*) FROM tag_resources_trash" \
" WHERE tag = tags_trash.id)", \
"resources", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ TAG_NAME_ITERATOR_COLUMNS

#define TAG_NAME_ITERATOR_COLUMNS
Value:
{ \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "resource_type", NULL, KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ TARGET_ITERATOR_FILTER_COLUMNS

#define TARGET_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "hosts", "exclude_hosts", "ips", "port_list", \
"ssh_credential", "smb_credential", "esxi_credential", "snmp_credential", \
NULL }

Filter columns for target iterator.

◆ TASK_ITERATOR_COLUMNS

#define TASK_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (tasks), \
TASK_ITERATOR_COLUMNS_INNER, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Task iterator columns.

◆ TASK_ITERATOR_COLUMNS_MIN

#define TASK_ITERATOR_COLUMNS_MIN
Value:
{ \
GET_ITERATOR_COLUMNS (tasks), \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Task iterator minimal columns.

◆ TASK_ITERATOR_FILTER_COLUMNS

#define TASK_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "status", "total", "first_report", \
"last_report", "threat", "trend", "severity", "schedule", "next_due", \
"first", "last", "false_positive", "log", "low", "medium", "high", \
"hosts", "result_hosts", "fp_per_host", "log_per_host", "low_per_host", \
"medium_per_host", "high_per_host", "target", NULL }

Filter columns for task iterator.

◆ TASK_ITERATOR_WHERE_COLUMNS

#define TASK_ITERATOR_WHERE_COLUMNS
Value:
{ \
TASK_ITERATOR_WHERE_COLUMNS_INNER, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Task iterator WHERE columns.

◆ TASK_ITERATOR_WHERE_COLUMNS_MIN

#define TASK_ITERATOR_WHERE_COLUMNS_MIN
Value:
{ \
TASK_ITERATOR_COLUMNS_INNER, \
TASK_ITERATOR_WHERE_COLUMNS_INNER, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Task iterator minimal WHERE columns.

◆ USER_ITERATOR_FILTER_COLUMNS

#define USER_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "method", "roles", "groups", "hosts", \
"ifaces", NULL }

◆ USER_ITERATOR_TRASH_COLUMNS

#define USER_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (users_trash), \
{ "method", NULL, KEYWORD_TYPE_STRING }, \
{ "hosts", NULL, KEYWORD_TYPE_STRING }, \
{ "hosts_allow", NULL, KEYWORD_TYPE_INTEGER }, \
{ "ifaces", NULL, KEYWORD_TYPE_STRING }, \
{ "ifaces_allow", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ VULN_ITERATOR_FILTER_COLUMNS

#define VULN_ITERATOR_FILTER_COLUMNS
Value:
{ \
GET_ITERATOR_FILTER_COLUMNS, "results", "hosts", "severity", "qod", \
"oldest", "newest", "type", NULL \
}

◆ VULN_RESULTS_WHERE

#define VULN_RESULTS_WHERE
Value:
" WHERE nvt = vulns.uuid" \
" AND (opts.report IS NULL OR results.report = opts.report)" \
" AND (opts.task IS NULL OR results.task = opts.task)" \
" AND (opts.host IS NULL OR results.host = opts.host)" \
" AND (results.severity != " G_STRINGIFY (SEVERITY_ERROR) ")" \
" AND (SELECT has_permission FROM permissions_get_tasks" \
" WHERE \"user\" = (SELECT id FROM users" \
" WHERE uuid =" \
" (SELECT uuid FROM current_credentials))" \
" AND task = results.task)"

◆ WHERE_OWNER

#define WHERE_OWNER
Value:
" WHERE owner = (SELECT id FROM users WHERE uuid = '%s')", \
current_credentials.uuid

Function Documentation

◆ add_permissions_on_globals()

static void add_permissions_on_globals ( const gchar *  role_uuid)
static

Add permissions for all global resources.

Parameters
[in]role_uuidUUID of role.

◆ add_port()

static void add_port ( GTree *  ports,
iterator_t results 
)
static

Add a port to a port tree.

Parameters
[in]portsThe tree.
[in]resultsResult iterator on result whose port to add.

◆ add_role_permission()

static void add_role_permission ( const gchar *  role,
const gchar *  permission 
)
static

Add command permission to role.

Caller must ensure args are SQL escaped.

Parameters
[in]roleRole.
[in]permissionPermission.

◆ add_role_permission_resource()

static void add_role_permission_resource ( const gchar *  role_id,
const gchar *  permission,
const gchar *  type,
const gchar *  resource_id 
)
static

Add resource permission to role.

Caller must ensure args are SQL escaped.

Parameters
[in]role_idRole ID.
[in]permissionPermission.
[in]typeResource type.
[in]resource_idResource ID.

◆ add_task_alert()

void add_task_alert ( task_t  task,
alert_t  alert 
)

Add an alert to a task.

Parameters
[in]taskTask.
[in]alertAlert.

◆ agent_count()

int agent_count ( const get_data_t get)

Count number of agents.

Parameters
[in]getGET params.
Returns
Total number of agents in filtered set.

◆ agent_in_use()

int agent_in_use ( agent_t  agent)

Check whether an agent is in use.

Parameters
[in]agentAgent.
Returns
1 yes, 0 no.

◆ agent_iterator_installer_size()

static gsize agent_iterator_installer_size ( iterator_t iterator)
static

Get the installer size from an agent iterator.

Parameters
[in]iteratorIterator.
Returns
Installer size, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ agent_iterator_trust()

const char* agent_iterator_trust ( iterator_t iterator)

Get the trust value from an agent iterator.

Parameters
[in]iteratorIterator.
Returns
Trust value.

◆ agent_iterator_trust_time()

time_t agent_iterator_trust_time ( iterator_t iterator)

Get the installer trust time from a agent iterator.

Parameters
[in]iteratorIterator.
Returns
Time agent installer was verified.

◆ agent_uuid()

char* agent_uuid ( agent_t  agent)

Return the UUID of an agent.

Parameters
[in]agentAgent.
Returns
UUID of Agent.

◆ agent_writable()

int agent_writable ( agent_t  agent)

Check whether a agent is writable.

Parameters
[in]agentAgent.
Returns
1 yes, 0 no.

◆ aggregate_iterator_count()

int aggregate_iterator_count ( iterator_t iterator)

Get the count from an aggregate iterator.

Parameters
[in]iteratorIterator.
Returns
The count of resources in the current group.

◆ aggregate_iterator_max()

double aggregate_iterator_max ( iterator_t iterator,
int  data_column_index 
)

Get the maximum from an aggregate iterator.

Parameters
[in]iteratorIterator.
[in]data_column_indexIndex of the data column to get max of.
Returns
The maximum value in the current group.

◆ aggregate_iterator_mean()

double aggregate_iterator_mean ( iterator_t iterator,
int  data_column_index 
)

Get the mean from an aggregate iterator.

Parameters
[in]iteratorIterator.
[in]data_column_indexIndex of the data column to get mean of.
Returns
The mean value in the current group.

◆ aggregate_iterator_min()

double aggregate_iterator_min ( iterator_t iterator,
int  data_column_index 
)

Get the minimum from an aggregate iterator.

Parameters
[in]iteratorIterator.
[in]data_column_indexIndex of the data column to get min of.
Returns
The minimum value in the current group.

◆ aggregate_iterator_subgroup_value()

const char* aggregate_iterator_subgroup_value ( iterator_t iterator)

Get the value of the subgroup column from an aggregate iterator.

Parameters
[in]iteratorIterator.
Returns
The value, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ aggregate_iterator_sum()

double aggregate_iterator_sum ( iterator_t iterator,
int  data_column_index 
)

Get the sum from a statistics iterator.

Parameters
[in]iteratorIterator.
[in]data_column_indexIndex of the data column to get sum of.
Returns
The sum of values in the current group.

◆ aggregate_iterator_text()

const char* aggregate_iterator_text ( iterator_t iterator,
int  text_column_index,
int  data_columns 
)

Get the value of a text column from an aggregate iterator.

Parameters
[in]iteratorIterator.
[in]text_column_indexIndex of the text column to get.
[in]data_columnsNumber of data columns.
Returns
The value, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ aggregate_iterator_value()

const char* aggregate_iterator_value ( iterator_t iterator)

Get the value of the group column from a statistics iterator.

Parameters
[in]iteratorIterator.
Returns
The value, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ alert_applies_to_task()

static int alert_applies_to_task ( alert_t  alert,
task_t  task 
)
static

Check whether an alert applies to a task.

Parameters
[in]alertAlert.
[in]taskTask.
Returns
1 if applies, else 0.

◆ alert_condition()

static alert_condition_t alert_condition ( alert_t  alert)
static

Return the condition associated with an alert.

Parameters
[in]alertAlert.
Returns
Condition.

◆ alert_count()

int alert_count ( const get_data_t get)

Count the number of alerts.

Parameters
[in]getGET params.
Returns
Total number of alerts filtered set.

◆ alert_data()

char* alert_data ( alert_t  alert,
const char *  type,
const char *  name 
)

Return data associated with an alert.

Parameters
[in]alertAlert.
[in]typeType of data: "condition", "event" or "method".
[in]nameName of the data.
Returns
Freshly allocated data if it exists, else NULL.

◆ alert_data_iterator_data()

const char* alert_data_iterator_data ( iterator_t iterator)

Return the data from an alert data iterator.

Parameters
[in]iteratorIterator.
Returns
Data of the alert data or NULL if iteration is complete.

◆ alert_data_iterator_name()

const char* alert_data_iterator_name ( iterator_t iterator)

Return the name from an alert data iterator.

Parameters
[in]iteratorIterator.
Returns
Name of the alert data or NULL if iteration is complete.

◆ alert_event()

static event_t alert_event ( alert_t  alert)
static

Return the event associated with an alert.

Parameters
[in]alertAlert.
Returns
Event.

◆ alert_filter_id()

static char* alert_filter_id ( alert_t  alert)
static

Return the UUID of the filter of an alert.

Parameters
[in]alertAlert.
Returns
UUID if there's a filter, else NULL.

◆ alert_in_use()

int alert_in_use ( alert_t  alert)

Return whether a alert is in use by a task.

Parameters
[in]alertAlert.
Returns
1 if in use, else 0.

◆ alert_iterator_active()

int alert_iterator_active ( iterator_t iterator)

Return the active state from an alert.

Parameters
[in]iteratorIterator.
Returns
Method of the alert or NULL if iteration is complete.

◆ alert_iterator_condition()

int alert_iterator_condition ( iterator_t iterator)

Return the condition from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Condition of the alert or NULL if iteration is complete.

◆ alert_iterator_event()

int alert_iterator_event ( iterator_t iterator)

Return the event from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Event of the alert or NULL if iteration is complete.

◆ alert_iterator_filter()

static filter_t alert_iterator_filter ( iterator_t iterator)
static

Return the filter from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Filter of the alert or NULL if iteration is complete.

◆ alert_iterator_filter_name()

char* alert_iterator_filter_name ( iterator_t iterator)

Return the filter name from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Name of filter of the alert or NULL if iteration is complete.

◆ alert_iterator_filter_readable()

int alert_iterator_filter_readable ( iterator_t iterator)

Return the filter readable state from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Whether filter is readable.

◆ alert_iterator_filter_trash()

int alert_iterator_filter_trash ( iterator_t iterator)

Return the location of an alert iterator filter.

Parameters
[in]iteratorIterator.
Returns
0 in table, 1 in trash.

◆ alert_iterator_filter_uuid()

char* alert_iterator_filter_uuid ( iterator_t iterator)

Return the filter UUID from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
UUID of filter of the alert or NULL if iteration is complete.

◆ alert_iterator_method()

int alert_iterator_method ( iterator_t iterator)

Return the method from an alert iterator.

Parameters
[in]iteratorIterator.
Returns
Method of the alert or NULL if iteration is complete.

◆ alert_message_print()

static gchar* alert_message_print ( const gchar *  message,
event_t  event,
const void *  event_data,
task_t  task,
alert_t  alert,
alert_condition_t  condition,
gchar *  format_name,
filter_t  filter,
const gchar *  term,
const gchar *  zone,
const gchar *  host_summary,
const gchar *  content,
gsize  content_length,
int  truncated,
int  total,
int  max_length 
)
static

Print an alert message.

Parameters
[in]messageFormat string for message.
[in]eventEvent.
[in]event_dataEvent data.
[in]taskTask.
[in]alertAlert.
[in]conditionAlert condition.
[in]format_nameReport format name.
[in]filterFilter.
[in]termFilter term.
[in]zoneTimezone.
[in]host_summaryHost summary.
[in]contentThe report, for inlining.
[in]content_lengthLength of content.
[in]truncatedWhether the report was truncated.
[in]totalTotal number of resources (for SecInfo alerts).
[in]max_lengthMax allowed length of content.
Returns
Freshly allocated message.

◆ alert_method()

static alert_method_t alert_method ( alert_t  alert)
static

Return the method associated with an alert.

Parameters
[in]alertAlert.
Returns
Method.

◆ alert_name()

static char* alert_name ( alert_t  alert)
static

Return the name of an alert.

Parameters
[in]alertAlert.
Returns
Name of alert.

◆ alert_owner()

static user_t alert_owner ( alert_t  alert)
static

Return the owner of an alert.

Parameters
[in]alertAlert.
Returns
Owner.

◆ alert_owner_uuid()

static char* alert_owner_uuid ( alert_t  alert)
static

Return the UUID of the owner of an alert.

Parameters
[in]alertAlert.
Returns
UUID of owner.

◆ alert_script_cleanup()

static int alert_script_cleanup ( const char *  report_dir,
gchar *  report_path,
gchar *  error_path,
gchar *  extra_path 
)
static

Clean up common files and variables for running alert script.

Parameters
[in]report_dirThe temporary directory.
[in]report_pathThe temporary report file path to free.
[in]error_pathThe temporary error file path to free.
[in]extra_pathThe temporary extra data file path to free.
Returns
0 success, -1 error.

◆ alert_script_exec()

static int alert_script_exec ( const char *  alert_id,
const char *  command_args,
const char *  report_path,
const char *  report_dir,
const char *  error_path,
const char *  extra_path,
gchar **  message 
)
static

Execute the alert script.

Parameters
[in]alert_idUUID of the alert.
[in]command_argsArgs for the "alert" script.
[in]report_pathPath to temporary file containing the report
[in]report_dirTemporary directory for the report
[in]error_pathPath to the script error message file
[in]extra_pathPath to the extra data file
[out]messageCustom error message generated by the script
Returns
0 success, -1 error, -5 alert script failed.

◆ alert_script_init()

static int alert_script_init ( const char *  report_filename,
const char *  report,
size_t  report_size,
const char *  extra_content,
size_t  extra_size,
char *  report_dir,
gchar **  report_path,
gchar **  error_path,
gchar **  extra_path 
)
static

Initialize common files and variables for an alert script.

The temporary file / dir parameters will be modified by mkdtemp / mkstemp to contain the actual path. The extra data is meant for data that should not be logged like passwords.

Parameters
[in]report_filenameFilename for the report or NULL for default.
[in]reportReport that should be sent.
[in]report_sizeSize of the report.
[in]extra_contentOptional extra data, e.g. credentials
[in]extra_sizeOptional extra data length
[in,out]report_dirTemplate for temporary report directory
[out]report_pathPointer to store path to report file at
[out]error_pathPointer to temporary file path for error messages
[out]extra_pathPointer to temporary extra data file path
Returns
0 success, -1 error.

◆ alert_subject_print()

static gchar* alert_subject_print ( const gchar *  subject,
event_t  event,
const void *  event_data,
alert_t  alert,
task_t  task,
int  total 
)
static

Print an alert subject.

Parameters
[in]subjectFormat string for subject.
[in]eventEvent.
[in]event_dataEvent data.
[in]alertAlert.
[in]taskTask.
[in]totalTotal number of resources (for SecInfo alerts).
Returns
Freshly allocated subject.

◆ alert_task_iterator_name()

const char* alert_task_iterator_name ( iterator_t iterator)

Return the name from an alert task iterator.

Parameters
[in]iteratorIterator.
Returns
Name of the task or NULL if iteration is complete.

◆ alert_task_iterator_readable()

int alert_task_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ alert_task_iterator_uuid()

const char* alert_task_iterator_uuid ( iterator_t iterator)

Return the uuid from an alert task iterator.

Parameters
[in]iteratorIterator.
Returns
UUID of the task or NULL if iteration is complete.

◆ alert_url_print()

static gchar* alert_url_print ( const gchar *  url,
const gchar *  oid,
const gchar *  type 
)
static

Print an URL for a New NVTs alert.

Parameters
[in]urlFormat string for url.
[in]oidSecInfo ID.
[in]typeSecInfo Type.
Returns
Freshly allocated url.

◆ alert_uuid()

char* alert_uuid ( alert_t  alert)

Return the UUID of an alert.

Parameters
[in]alertAlert.
Returns
UUID of alert.

◆ alert_writable()

int alert_writable ( alert_t  alert)

Return whether a alert is writable.

Parameters
[in]alertAlert.
Returns
1 if writable, else 0.

◆ alive_test_from_string()

static int alive_test_from_string ( const char *  alive_tests)
static

Convert alive test name to alive test bitfield.

Parameters
[in]alive_testsName of alive test.
Returns
Alive test, or -1 on error.

◆ app_location()

gchar* app_location ( report_host_t  report_host,
const gchar *  app 
)

Get the location of an App for a report's host.

Parameters
[in]report_hostReport host.
[in]appCPE.
Returns
Location if there is one, else NULL.

◆ append_column()

static void append_column ( GArray *  columns,
const gchar *  column_name,
column_t select_columns,
column_t where_columns 
)
static

Append expression for a column to an array.

Parameters
[in]columnsArray.
[in]column_nameName of column.
[in]select_columnsDefinition of "SELECT" columns.
[in]where_columnsDefinition of "WHERE" columns.

◆ append_relation()

static void append_relation ( GString *  clean,
keyword_t keyword,
const char  relation 
)
static

Append relation to filter.

Parameters
[in]cleanFilter.
[in]keywordKeyword
[in]relationRelation char.

◆ append_to_task_comment()

void append_to_task_comment ( task_t  task,
const char *  text,
int  length 
)

Append text to the comment associated with a task.

Parameters
[in]taskA pointer to the task.
[in]textThe text to append.
[in]lengthLength of the text.

◆ append_to_task_string()

static void append_to_task_string ( task_t  task,
const char *  field,
const char *  value 
)
static

Append value to field of task.

Parameters
[in]taskTask.
[in]fieldField.
[in]valueValue.

◆ apply_report_format()

static gchar * apply_report_format ( gchar *  report_format_id,
gchar *  xml_start,
gchar *  xml_file,
gchar *  xml_dir,
GList **  used_rfps 
)
static

Applies a report format to an XML report.

Parameters
[in]report_format_idReport format to apply.
[in]xml_startPath to the main part of the report XML.
[in]xml_filePath to the report XML file.
[in]xml_dirPath to the temporary dir.
[in]used_rfpsList of already applied report formats.
Returns
Path to the generated file or NULL.

◆ array_add_new_string()

static void array_add_new_string ( array_t *  array,
const gchar *  string 
)
static

Ensure a string is in an array.

Parameters
[in]arrayArray.
[in]stringString. Copied into array.

◆ array_add_port()

static gboolean array_add_port ( gpointer  key,
gpointer  value,
gpointer  ports 
)
static

Add port to ports array.

Parameters
[in]keyPort.
[in]valueThreat.
[in]portsPorts array.
Returns
Always FALSE.

◆ array_find_string()

static gchar* array_find_string ( array_t *  array,
const gchar *  string 
)
static

Find a string in an array.

Parameters
[in]arrayArray.
[in]stringString.
Returns
The string from the array if found, else NULL.

◆ auth_cache_find()

static int auth_cache_find ( const char *  username,
const char *  password,
int  method 
)
static

Search for LDAP or RADIUS credentials in the recently-used authentication cache.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[in]method0 for LDAP, 1 for RADIUS.
Returns
0 on success, -1 on failure.

◆ auth_cache_insert()

static void auth_cache_insert ( const char *  username,
const char *  password,
int  method 
)
static

Add LDAP or RADIUS credentials to the recently-used authentication cache.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[in]method0 for LDAP, 1 for RADIUS.

◆ authenticate()

int authenticate ( credentials_t *  credentials)

Authenticate credentials.

Parameters
[in]credentialsCredentials.
Returns
0 authentication success, 1 authentication failure, 99 permission denied, -1 error.

◆ authenticate_any_method()

static int authenticate_any_method ( const gchar *  username,
const gchar *  password,
auth_method_t *  auth_method 
)
static

Authenticate, trying any method.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[out]auth_methodAuth method return.
Returns
0 authentication success, 1 authentication failure, 99 permission denied, -1 error.

◆ buffer_results_xml()

void buffer_results_xml ( GString *  buffer,
iterator_t results,
task_t  task,
int  include_notes,
int  include_notes_details,
int  include_overrides,
int  include_overrides_details,
int  include_tags,
int  include_tags_details,
int  include_details,
const char *  delta_state,
iterator_t delta_results,
int  changed,
int  cert_loaded 
)

Buffer XML for some results.

Todo:
Defined in gmp.c!
Todo:
Exported for manage_sql.c.
Todo:
Exported for manage_sql.c.

Includes cert_loaded arg.

Parameters
[in]bufferBuffer into which to buffer results.
[in]resultsResult iterator.
[in]taskTask associated with results. Only needed with include_notes or include_overrides.
[in]include_notesWhether to include notes.
[in]include_notes_detailsWhether to include details of notes.
[in]include_overridesWhether to include overrides.
[in]include_overrides_detailsWhether to include details of overrides.
[in]include_tagsWhether to include user tag count.
[in]include_tags_detailsWhether to include details of tags.
[in]include_detailsWhether to include details of the result.
[in]delta_stateDelta state of result, or NULL.
[in]delta_resultsIterator for delta result to include, or NULL.
[in]changedWhether the result is a "changed" delta.
[in]cert_loadedWhether the CERT db is loaded. 0 not loaded, -1 needs to be checked, else loaded.

◆ buffer_vfire_call_input()

gboolean buffer_vfire_call_input ( gchar *  key,
gchar *  value,
GString *  buffer 
)

Appends an XML fragment for vFire call input to a string buffer.

Parameters
[in]keyThe name of the key.
[in]valueThe value to add.
[in]bufferThe string buffer to append to.
Returns
Always FALSE.

◆ byday_from_string()

static int byday_from_string ( const char *  byday)
static

Get Byday mask from ical style string.

Parameters
[in]bydayByday string.
Returns
Byday mask, or -1 on syntax error.

◆ cache_report_counts()

static int cache_report_counts ( report_t  report,
int  override,
int  min_qod,
severity_data_t data 
)
static

Cache the message counts for a report.

Parameters
[in]reportReport.
[in]overrideWhether overrides were applied to the results.
[in]min_qodThe minimum QoD of the results.
[in]dataSeverity data struct containing the message counts.
Returns
0 if successful, 1 gave up, -1 error (see sql_giveup).

◆ cert_check_time()

static int cert_check_time ( )
static

Get last time CERT SecInfo alerts were checked.

Returns
Last time CERT was checked.

◆ check_alert_params()

static int check_alert_params ( event_t  event,
alert_condition_t  condition,
alert_method_t  method 
)
static

Check alert params.

Parameters
[in]eventType of event.
[in]conditionEvent condition.
[in]methodEscalation method.
Returns
0 success, 20 method does not match event, 21 condition does not match event.

◆ check_alerts()

void check_alerts ( )

Check if any SecInfo alerts are due.

Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ check_config_discovery()

int check_config_discovery ( const char *  uuid)

Ensure the Discovery config is up to date.

Parameters
[in]uuidUUID of config.
Returns
0 success, -1 error.

◆ check_config_families()

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.

Returns
0 success, -1 error.

◆ check_config_host_discovery()

void check_config_host_discovery ( const char *  uuid)

Ensure the Host Discovery config is up to date.

Parameters
[in]uuidUUID of config.
Returns
0 success, -1 error.

◆ check_config_system_discovery()

int check_config_system_discovery ( const char *  uuid)

Ensure the Discovery config is up to date.

Parameters
[in]uuidUUID of config.
Returns
0 success, -1 error.

◆ check_db()

static int check_db ( int  check_encryption_key)
static

Ensure that the database is in order.

Only called by init_manage_internal, and ultimately only by the main process.

Parameters
[in]check_encryption_keyWhether to check encryption key.
Returns
0 success, -1 error.

◆ check_db_encryption_key()

static int check_db_encryption_key ( )
static

Ensure that there is an encryption key.

This prevents contention problems that can happen when the key is created on the fly during a GMP operation.

Up to caller to create transaction.

Returns
0 success, -1 error.

◆ check_db_report_formats()

static int check_db_report_formats ( )
static

Ensure the predefined report formats exist.

Returns
0 success, -1 error.

◆ check_db_report_formats_trash()

static int check_db_report_formats_trash ( )
static

Ensure that the report formats trash directory matches the database.

Returns
-1 if error, 0 if success.

◆ check_db_scanners()

static int check_db_scanners ( )
static

Ensure the predefined scanner exists.

Returns
0 if success, -1 if error.

◆ check_db_sequences()

void check_db_sequences ( )

Ensure sequences for automatic ids are in a consistent state.

Caller must organise a transaction.

◆ check_db_settings()

static void check_db_settings ( )
static

Initialize the default settings.

Ensure all the default manager settings exist.

◆ check_db_trash_report_formats()

static int check_db_trash_report_formats ( )
static

Check that trash report formats are correct.

Returns
0 success, -1 error.

◆ check_db_versions()

static int check_db_versions ( int  nvt_cache_mode)
static

Ensure that the databases are the right versions.

Parameters
[in]nvt_cache_modeTrue when running in NVT caching mode.
Returns
0 success, -1 error, -2 database is wrong version.

◆ check_generate_scripts()

void check_generate_scripts ( )

Ensure the generate scripts are all executable.

Used by a migrator.

◆ clean_hosts()

gchar * clean_hosts ( const char *  given_hosts,
int *  max 
)

Clean a hosts string.

Parameters
[in]given_hostsString describing hosts.
[out]maxMax number of hosts, adjusted for duplicates.
Returns
Freshly allocated new hosts string, or NULL on error.

◆ cleanup_keyword()

static void cleanup_keyword ( keyword_t keyword)
static

Cleans up keywords with special conditions and relations.

Parameters
[in]keywordKeyword to clean up.

◆ cleanup_manage_process()

void cleanup_manage_process ( gboolean  cleanup)

Cleanup the manage library.

Optionally put any running task in the interrupted state and close the database.

Parameters
[in]cleanupIf TRUE perform all cleanup operations, else only those required at the start of a forked process.

◆ cleanup_schedule_times()

static int cleanup_schedule_times ( )
static

Fixes the DST offset in schedule_next_time of tasks.

Returns
changes The number of tasks updated.

◆ cleanup_tables()

static void cleanup_tables ( )
static

Clean up database tables.

Remove superfluous entries from tables.

◆ cleanup_task_schedule_iterator()

void cleanup_task_schedule_iterator ( iterator_t iterator)

Cleanup a task schedule iterator.

Parameters
[in]iteratorIterator.

◆ clear_duration_schedules()

void clear_duration_schedules ( task_t  task)

Clear once-off schedules from tasks where the duration has passed.

Parameters
[in]taskTask. 0 for all.

◆ collate_ip()

static int collate_ip ( void *  data,
int  one_len,
const void *  arg_one,
int  two_len,
const void *  arg_two 
)
static

Collate two IP addresses.

For example, 127.0.0.2 is less than 127.0.0.3 and 127.0.0.10.

Only works correctly for IPv4 addresses.

Parameters
[in]dataDummy for callback.
[in]one_lenLength of first IP (a string).
[in]arg_oneFirst string.
[in]two_lenLength of second IP (a string).
[in]arg_twoSecond string.
Returns
-1, 0 or 1 if first is less than, equal to or greater than second.

◆ collate_ip_compare()

static int collate_ip_compare ( const char *  one_arg,
const char *  two_arg 
)
static

Compare two number strings for collate_ip.

Parameters
[in]one_argFirst string.
[in]two_argSecond string.
Returns
-1, 0 or 1 if first is less than, equal to or greater than second.

◆ column_array_copy()

static column_t* column_array_copy ( column_t columns)
static

Copy an array of columns.

Parameters
[in]columnsColumns.
Returns
Freshly allocated array.

◆ column_array_free()

static void column_array_free ( column_t columns)
static

Free an array of columns.

Parameters
[in]columnsColumns.

◆ column_array_set()

static void column_array_set ( column_t columns,
const gchar *  filter,
gchar *  select 
)
static

Set the select clause of a column in an array of columns.

Frees the existing select clause.

Parameters
[in]columnsColumns.
[in]filterFilter term name.
[in]selectSelect clause.

◆ columns_build_select()

gchar* columns_build_select ( column_t select_columns)

Return column list for SELECT statement.

Parameters
[in]select_columnsSELECT columns.
Returns
Column list for the SELECT statement.

◆ columns_select_column()

static gchar* columns_select_column ( column_t select_columns,
column_t where_columns,
const char *  filter_column 
)
static

Get the selection term for a filter column.

Parameters
[in]select_columnsSELECT columns.
[in]where_columnsWHERE "columns".
[in]filter_columnFilter column.
Returns
Column for the SELECT statement.

◆ columns_select_column_single()

static gchar* columns_select_column_single ( column_t select_columns,
const char *  filter_column,
keyword_type_t *  type 
)
static

Get the column expression for a filter column.

Parameters
[in]select_columnsSELECT columns.
[in]filter_columnFilter column.
[out]typeType of returned column.
Returns
Column for the SELECT statement.

◆ columns_select_column_with_type()

static gchar* columns_select_column_with_type ( column_t select_columns,
column_t where_columns,
const char *  filter_column,
keyword_type_t *  type 
)
static

Get the selection term for a filter column.

Parameters
[in]select_columnsSELECT columns.
[in]where_columnsWHERE "columns".
[in]filter_columnFilter column.
[out]typeType of the returned column.
Returns
Column for the SELECT statement.

◆ compare_and_buffer_results()

static compare_results_t compare_and_buffer_results ( GString *  buffer,
iterator_t results,
iterator_t delta_results,
task_t  task,
int  notes,
int  notes_details,
int  overrides,
int  overrides_details,
int  sort_order,
const char *  sort_field,
int  changed,
int  gone,
int  new,
int  same,
int *  max_results,
int *  first_result,
int *  used,
int *  would_use 
)
static

Compare two results, writing associated XML to a buffer.

Parameters
[in]bufferBuffer.
[in]resultsIterator containing first result.
[in]delta_resultsIterator containing second result.
[in]taskTask associated with report.
[in]notesWhether to include notes.
[in]notes_detailsIf notes, Whether to include details.
[in]overridesWhether to include overrides.
[in]overrides_detailsIf overrides, Whether to include details.
[in]sort_orderWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for "type".
[in]changedWhether to include changed results.
[in]goneWhether to include gone results.
[in]newWhether to include new results.
[in]sameWhether to include same results.
[in]max_resultsValue to decrement if result is buffered.
[in]first_resultSkip result and decrement if positive.
[in]used0 if used, 1 if skipped.
[in]would_use0 if would use (first_result aside), 1 if skipped.
Returns
Result of comparison.

◆ compare_files()

static gint compare_files ( gconstpointer  one,
gconstpointer  two 
)
static

Compare files for create_report_format.

Parameters
[in]oneFirst.
[in]twoSecond.
Returns
Less than, equal to, or greater than zero if one is found to be less than, to match, or be greater than two.

◆ compare_port_severity()

static gint compare_port_severity ( gconstpointer  arg_one,
gconstpointer  arg_two 
)
static

Compares two buffered results, sorting by host, port then severity.

Parameters
[in]arg_oneFirst result.
[in]arg_twoSecond result.
Returns
-1, 0 or 1 if first given result is less than, equal to or greater than second.

◆ compare_ports_severity()

static gint compare_ports_severity ( gconstpointer  one,
gconstpointer  two 
)
static

Compare port severities, ascending.

Parameters
[in]oneFirst.
[in]twoSecond.
Returns
1 one greater, -1 two greater, 0 equal.

◆ compare_ports_severity_desc()

static gint compare_ports_severity_desc ( gconstpointer  one,
gconstpointer  two 
)
static

Compare port severities, descending.

Parameters
[in]oneFirst.
[in]twoSecond.
Returns
1 one less, -1 two less, 0 equal.

◆ compare_results()

static compare_results_t compare_results ( iterator_t results,
iterator_t delta_results,
int  sort_order,
const char *  sort_field 
)
static

Compare two results.

Parameters
[in]resultsIterator containing first result.
[in]delta_resultsIterator containing second result.
[in]sort_orderWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for "type".
Returns
Result of comparison.

◆ compare_severity_asc()

static gint compare_severity_asc ( gconstpointer  arg_one,
gconstpointer  arg_two 
)
static

Compares two textual port representations, sorting descending.

by severity

Parameters
[in]arg_oneFirst port.
[in]arg_twoSecond port.
Returns
-1, 0 or 1 if first given severity is less than, equal to or greater than second.

◆ compare_severity_desc()

static gint compare_severity_desc ( gconstpointer  arg_one,
gconstpointer  arg_two 
)
static

Compares two textual port representations, sorting descending.

by severity

Parameters
[in]arg_oneFirst threat level.
[in]arg_twoSecond threat level.
Returns
1, 0 or -1 if first given severity is less than, equal to or greater than second.

◆ condition_met()

static int condition_met ( task_t  task,
report_t  report,
alert_t  alert,
alert_condition_t  condition 
)
static

Return whether the condition of an alert is met by a task.

Parameters
[in]taskTask.
[in]reportReport.
[in]alertAlert.
[in]conditionCondition.
Returns
1 if met, else 0.

◆ config_count()

int config_count ( const get_data_t get)

Count the number of scan configs.

Parameters
[in]getGET params.
Returns
Total number of scan configs filtered set.

◆ config_families_growing()

int config_families_growing ( config_t  config)

Get the family growth status of a config.

Parameters
[in]configConfig.
Returns
1 growing, 0 static.

◆ config_in_use()

int config_in_use ( config_t  config)

Return whether a config is referenced by a task.

The predefined configs are always in use.

Parameters
[in]configConfig.
Returns
1 if in use, else 0.

◆ config_insert_preferences()

static int config_insert_preferences ( config_t  config,
const array_t *  preferences,
const char *  config_type 
)
static

Insert preferences into a config.

Parameters
[in]configConfig.
[in]preferencesPreferences.
[in]config_typeConfig type.
Returns
0 success, -1 error, -4 input error.

◆ config_iterator_families_growing()

int config_iterator_families_growing ( iterator_t iterator)

Get the families growing state from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Families growing flag.

◆ config_iterator_family_count()

int config_iterator_family_count ( iterator_t iterator)

Get the family count from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Family count if known, -1 else.

◆ config_iterator_nvt_count()

int config_iterator_nvt_count ( iterator_t iterator)

Get the nvt count from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Nvt count if known, -1 else.

◆ config_iterator_nvts_growing()

int config_iterator_nvts_growing ( iterator_t iterator)

Get the NVTs growing state from a config iterator.

Parameters
[in]iteratorIterator.
Returns
NVTs growing flag.

◆ config_iterator_scanner()

scanner_t config_iterator_scanner ( iterator_t iterator)

Get the scanner from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Scanner.

◆ config_iterator_scanner_trash()

int config_iterator_scanner_trash ( iterator_t iterator)

Get whether scanner is in trash from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Whether Scanner is in trash.

◆ config_iterator_type()

int config_iterator_type ( iterator_t iterator)

Get the type from a config iterator.

Parameters
[in]iteratorIterator.
Returns
Config type.

◆ config_nvt_selector()

char* config_nvt_selector ( config_t  config)

Return the NVT selector associated with a config.

Parameters
[in]configConfig.
Returns
Name of NVT selector if config exists and NVT selector is set, else NULL.

◆ config_nvt_timeout()

char* config_nvt_timeout ( config_t  config,
const char *  oid 
)

Get the timeout value for an NVT in a config.

Parameters
[in]configConfig.
[in]oidID of NVT.
Returns
Newly allocated timeout if set for the NVT, else NULL.

◆ config_nvts_growing()

int config_nvts_growing ( config_t  config)

Get the NVT growth status of a config.

Todo:
Move these config functions to the config section.
Parameters
[in]configConfig.
Returns
1 growing, 0 static.

◆ config_scanner()

static scanner_t config_scanner ( config_t  config)
static

Return the scanner associated with a config, if any.

Parameters
[in]configConfig.
Returns
Scanner ID if found, 0 otherwise.

◆ config_task_iterator_readable()

int config_task_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ config_type()

int config_type ( config_t  config)

Return the type of a config.

Parameters
[in]configConfig.
Returns
Config type, -1 if not found.

◆ config_update_nvt_family()

static int config_update_nvt_family ( resource_t  config,
const char *  oid,
const char *  old_family,
const char *  new_family 
)
static

Change the family of an NVT in a config.

Parameters
[in]configConfig.
[in]oidNVT OID.
[in]old_familyName of old family.
[in]new_familyName of new family.
Returns
0 success, -1 error.

◆ config_uuid()

char* config_uuid ( config_t  config)

Return the UUID of a config.

Parameters
[in]configConfig.
Returns
Newly allocated config uuid pointer.

◆ config_writable()

int config_writable ( config_t  config)

Return whether a config can be modified.

Parameters
[in]configConfig.
Returns
0 if predefined config, else 1.

◆ connect_unix()

static int connect_unix ( const gchar *  path)
static

Connect a UNIX socket.

Parameters
[in]pathPath.
Returns
Socket, or -1 on error.

◆ connection_open()

static int connection_open ( gvm_connection_t *  connection,
const gchar *  address,
int  port 
)
static

Connect to an address.

Parameters
[out]connectionConnection.
[out]addressAddress.
[out]portPort.
Returns
0 success, -1 failed to connect.

◆ copy_agent()

int copy_agent ( const char *  name,
const char *  comment,
const char *  agent_id,
agent_t *  new_agent 
)

Create an agent from an existing agent.

Parameters
[in]nameName of new agent. NULL to copy from existing.
[in]commentComment on new agent. NULL to copy from existing.
[in]agent_idUUID of existing schedule.
[out]new_agentNew agent.
Returns
0 success, 1 agent exists already, 2 failed to find existing agent, 99 permission denied, -1 error.

◆ copy_alert()

int copy_alert ( const char *  name,
const char *  comment,
const char *  alert_id,
alert_t *  new_alert 
)

Create an alert from an existing alert.

Parameters
[in]nameName of new alert. NULL to copy from existing.
[in]commentComment on new alert. NULL to copy from existing.
[in]alert_idUUID of existing alert.
[out]new_alertNew alert.
Returns
0 success, 1 alert exists already, 2 failed to find existing alert, 99 permission denied, -1 error.

◆ copy_config()

int copy_config ( const char *  name,
const char *  comment,
const char *  config_id,
config_t *  new_config 
)

Create a config from an existing config.

Parameters
[in]nameName of new config and NVT selector.
[in]commentComment on new config.
[in]config_idUUID of existing config.
[out]new_configNew config.
Returns
0 success, 1 config exists already, 2 failed to find existing config, 99 permission denied, -1 error.

◆ copy_credential()

int copy_credential ( const char *  name,
const char *  comment,
const char *  credential_id,
credential_t *  new_credential 
)

Create an LSC Credential from an existing one.

Parameters
[in]nameName of new Credential. NULL to copy from existing.
[in]commentComment on new Credential. NULL to copy from existing.
[in]credential_idUUID of existing Credential.
[out]new_credentialNew Credential.
Returns
0 success, 1 Credential exists already, 2 failed to find existing Credential, -1 error.

◆ copy_note()

int copy_note ( const char *  note_id,
note_t *  new_note 
)

Create a note from an existing note.

Parameters
[in]note_idUUID of existing note.
[out]new_noteNew note.
Returns
0 success, 1 note exists already, 2 failed to find existing note, -1 error.

◆ copy_override()

int copy_override ( const char *  override_id,
override_t *  new_override 
)

Create a override from an existing override.

Parameters
[in]override_idUUID of existing override.
[out]new_overrideNew override.
Returns
0 success, 1 override exists already, 2 failed to find existing override, -1 error.

◆ copy_report_format()

int copy_report_format ( const char *  name,
const char *  source_uuid,
report_format_t *  new_report_format 
)

Create Report Format from an existing Report Format.

Parameters
[in]nameName of new Report Format. NULL to copy from existing.
[in]source_uuidUUID of existing Report Format.
[out]new_report_formatNew Report Format.
Returns
0 success, 1 Report Format exists already, 2 failed to find existing Report Format, 99 permission denied, -1 error.

◆ copy_resource()

int copy_resource ( const char *  type,
const char *  name,
const char *  comment,
const char *  resource_id,
const char *  columns,
int  make_name_unique,
resource_t new_resource,
resource_t old_resource 
)

Create a resource from an existing resource.

Parameters
[in]typeType of resource.
[in]nameName of new resource. NULL to copy from existing.
[in]commentComment on new resource. NULL to copy from existing.
[in]resource_idUUID of existing resource.
[in]columnsExtra columns in resource.
[in]make_name_uniqueWhen name NULL, whether to make existing name unique.
[out]new_resourceNew resource.
[out]old_resourceAddress for existing resource, or NULL.
Returns
0 success, 1 resource exists already, 2 failed to find existing resource, 99 permission denied, -1 error.

◆ copy_resource_lock()

static int copy_resource_lock ( const char *  type,
const char *  name,
const char *  comment,
const char *  resource_id,
const char *  columns,
int  make_name_unique,
resource_t new_resource,
resource_t old_resource 
)
static

Create a resource from an existing resource.

Parameters
[in]typeType of resource.
[in]nameName of new resource. NULL to copy from existing.
[in]commentComment on new resource. NULL to copy from existing.
[in]resource_idUUID of existing resource.
[in]columnsExtra columns in resource.
[in]make_name_uniqueWhen name NULL, whether to make existing name unique.
[out]new_resourceAddress for new resource, or NULL.
[out]old_resourceAddress for existing resource, or NULL.
Returns
0 success, 1 resource exists already, 2 failed to find existing resource, 99 permission denied, -1 error.

◆ copy_scanner()

int copy_scanner ( const char *  name,
const char *  comment,
const char *  scanner_id,
scanner_t *  new_scanner 
)

Create a scanner from an existing scanner.

Parameters
[in]nameName of new scanner. NULL to copy from existing.
[in]commentComment on new scanner. NULL to copy from existing.
[in]scanner_idUUID of existing scanner.
[out]new_scannerNew scanner.
Returns
0 success, 1 scanner exists already, 2 failed to find existing scanner, -1 error, 98 not allowed to copy cve scanner, 99 permission denied.

◆ copy_schedule()

int copy_schedule ( const char *  name,
const char *  comment,
const char *  schedule_id,
schedule_t *  new_schedule 
)

Create a schedule from an existing schedule.

Parameters
[in]nameName of new schedule. NULL to copy from existing.
[in]commentComment on new schedule. NULL to copy from existing.
[in]schedule_idUUID of existing schedule.
[out]new_scheduleNew schedule.
Returns
0 success, 1 schedule exists already, 2 failed to find existing schedule, -1 error.

◆ copy_target()

int copy_target ( const char *  name,
const char *  comment,
const char *  target_id,
target_t *  new_target 
)

Create a target from an existing target.

Parameters
[in]nameName of new target. NULL to copy from existing.
[in]commentComment on new target. NULL to copy from existing.
[in]target_idUUID of existing target.
[out]new_targetNew target.
Returns
0 success, 1 target exists already, 2 failed to find existing target, 99 permission denied, -1 error.

◆ copy_task()

int copy_task ( const char *  name,
const char *  comment,
const char *  task_id,
int  alterable,
task_t *  new_task 
)

Create a task from an existing task.

Parameters
[in]nameName of new task. NULL to copy from existing.
[in]commentComment on new task. NULL to copy from existing.
[in]task_idUUID of existing task.
[in]alterableWhether the new task will be alterable.
[out]new_taskNew task.
Returns
0 success, 2 failed to find existing task, 99 permission denied, -1 error.

◆ count()

int count ( const char *  type,
const get_data_t get,
column_t select_columns,
column_t trash_select_columns,
const char **  filter_columns,
int  distinct,
const char *  extra_tables,
const char *  extra_where,
int  owned 
)

Count number of a particular resource.

Parameters
[in]typeType of resource.
[in]getGET params.
[in]select_columnsSELECT columns.
[in]trash_select_columnsSELECT columns for trashcan.
[in]filter_columnsExtra columns.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]extra_tablesJoin tables. Skipped for trash and single resource.
[in]extra_whereExtra WHERE clauses. Skipped for trash and single resource.
[in]ownedOnly count items owned by current user.
Returns
Total number of resources in filtered set.

◆ count2()

static int count2 ( const char *  type,
const get_data_t get,
column_t select_columns,
column_t trash_select_columns,
column_t where_columns,
column_t trash_where_columns,
const char **  filter_columns,
int  distinct,
const char *  extra_tables,
const char *  extra_where,
int  owned 
)
static

Count number of a particular resource.

Parameters
[in]typeType of resource.
[in]getGET params.
[in]select_columnsSELECT columns.
[in]trash_select_columnsSELECT columns for trashcan.
[in]where_columnsWHERE columns.
[in]trash_where_columnsWHERE columns for trashcan.
[in]filter_columnsExtra columns.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]extra_tablesJoin tables. Skipped for trash and single resource.
[in]extra_whereExtra WHERE clauses. Skipped for trash and single resource.
[in]ownedOnly count items owned by current user.
Returns
Total number of resources in filtered set.

◆ cpe_highest_cvss()

static double cpe_highest_cvss ( const char *  cpe)
static

Return highest CVSS for an App.

Parameters
[in]cpeCPE.
Returns
Highest CVSS.

◆ create_agent()

int create_agent ( const char *  name,
const char *  comment,
const char *  installer_64,
const char *  installer_filename,
const char *  installer_signature_64,
const char *  howto_install,
const char *  howto_use,
agent_t *  agent 
)

Create an agent entry.

Parameters
[in]nameName of agent. Must be at least one character long.
[in]commentComment on agent.
[in]installer_64Installer, in base64.
[in]installer_filenameInstaller filename.
[in]installer_signature_64Installer signature, in base64.
[in]howto_installInstall HOWTO, in base64.
[in]howto_useUsage HOWTO, in base64.
[out]agentCreated agent.
Returns
0 success, 1 agent exists already, 99 permission denied, -1 error.

◆ create_alert()

int create_alert ( const char *  name,
const char *  comment,
const char *  filter_id,
const char *  active,
event_t  event,
GPtrArray *  event_data,
alert_condition_t  condition,
GPtrArray *  condition_data,
alert_method_t  method,
GPtrArray *  method_data,
alert_t *  alert 
)

Create an alert.

Parameters
[in]nameName of alert.
[in]commentComment on alert.
[in]filter_idFilter.
[in]activeWhether the alert is active.
[in]eventType of event.
[in]event_dataType-specific event data.
[in]conditionEvent condition.
[in]condition_dataCondition-specific data.
[in]methodEscalation method.
[in]method_dataData for escalation method.
[out]alertCreated alert on success.
Returns
0 success, 1 escalation exists already, 2 validation of email failed, 3 failed to find filter, 4 type must be "result" if specified, 5 unexpected condition data name, 6 syntax error in condition data, 7 email subject too long, 8 email message too long, 9 failed to find filter for condition, 12 error in Send host, 13 error in Send port, 14 failed to find report format for Send method, 15 error in SCP host, 17 failed to find report format for SCP method, 18 error in SCP credential, 19 error in SCP path, 20 method does not match event, 21 condition does not match event, 31 unexpected event data name, 32 syntax error in event data, 40 invalid SMB credential , 41 invalid SMB share path, 42 invalid SMB file path, 43 SMB file path contains dot, 50 invalid TippingPoint credential, 51 invalid TippingPoint hostname, 52 invalid TippingPoint certificate, 53 invalid TippingPoint TLS workaround setting, 60 recipient credential not found, 61 invalid recipient credential type, 70 vFire credential not found, 71 invalid vFire credential type, 99 permission denied, -1 error.

◆ create_config()

int create_config ( const char *  proposed_name,
const char *  comment,
const array_t *  selectors,
const array_t *  preferences,
const char *  config_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.

Parameters
[in]proposed_nameProposed name of config.
[in]commentComment on config.
[in]selectorsNVT selectors.
[in]preferencesPreferences.
[in]config_typeConfig type.
[out]configOn success the config.
[out]nameOn success the name of the config.
Returns
0 success, 1 config exists already, 99 permission denied, -1 error, -2 name empty, -3 input error in selectors, -4 input error in preferences.

◆ create_config_from_scanner()

int create_config_from_scanner ( const char *  scanner_id,
const char *  name,
const char *  comment,
char **  uuid 
)

Create a config from an OSP scanner.

Parameters
[in]scanner_idUUID of scanner to create config from.
[in]nameName for config.
[in]commentComment for config.
[out]uuidConfig UUID, on success.
Returns
0 success, 1 couldn't find scanner, 2 scanner not of OSP type, 3 config name exists already, 4 couldn't get params from scanner, 99 permission denied, -1 error.

◆ create_credential()

int create_credential ( const char *  name,
const char *  comment,
const char *  login,
const char *  given_password,
const char *  key_private,
const char *  key_public,
const char *  certificate,
const char *  community,
const char *  auth_algorithm,
const char *  privacy_password,
const char *  privacy_algorithm,
const char *  given_type,
const char *  allow_insecure,
credential_t *  credential 
)

Create a Credential.

Parameters
[in]nameName of LSC credential. Must be at least one character long.
[in]commentComment on LSC credential.
[in]loginName of LSC credential user. Must be at least one character long.
[in]given_passwordPassword for password-only credential, NULL to generate credentials.
[in]key_privatePrivate key, or NULL.
[in]key_publicPublic key, or NULL.
[in]certificateCertificate, or NULL.
[in]communitySNMP community string, or NULL.
[in]auth_algorithmSNMP authentication algorithm, or NULL.
[in]privacy_passwordSNMP privacy password.
[in]privacy_algorithmSNMP privacy algorithm.
[in]given_typeCredential type or NULL.
[in]allow_insecureWhether to allow insecure uses.
[out]credentialCreated Credential.
Returns
0 success, 1 LSC credential exists already, 2 invalid username, 3 Failed to create public key from private key/password, 4 Invalid credential type, 5 login username missing, 6 password missing, 7 private key missing, 8 certificate missing, 9 public key missing, 10 autogenerate not supported, 11 community missing, 12 auth algorithm missing, 14 privacy algorithm missing, 15 invalid auth algorithm, 16 invalid privacy algorithm, 17 invalid certificate, 99 permission denied, -1 error.

◆ create_current_report()

int create_current_report ( task_t  task,
char **  report_id,
task_status_t  status 
)

Create the current report for a task.

Parameters
[in]taskThe task.
[out]report_idReport ID.
[in]statusRun status of scan associated with report.
Returns
0 success, -1 global_current_report is already set, -2 failed to generate ID.

◆ create_note()

int create_note ( const char *  active,
const char *  nvt,
const char *  text,
const char *  hosts,
const char *  port,
const char *  severity,
const char *  threat,
task_t  task,
result_t  result,
note_t *  note 
)

Create a note.

Parameters
[in]activeNULL or -1 on, 0 off, n on for n days.
[in]nvtOID of noted NVT.
[in]textNote text.
[in]hostsHosts to apply note to, NULL for any host.
[in]portPort to apply note to, NULL for any port.
[in]severitySeverity to apply note to, "" or NULL for any.
[in]threatThreat to apply note to, "" or NULL for any threat. Only used if severity is "" or NULL.
[in]taskTask to apply note to, 0 for any task.
[in]resultResult to apply note to, 0 for any result.
[out]noteCreated note.
Returns
0 success, 1 failed to find NVT, 2 invalid port, 99 permission denied, -1 error.

◆ create_override()

int create_override ( const char *  active,
const char *  nvt,
const char *  text,
const char *  hosts,
const char *  port,
const char *  threat,
const char *  new_threat,
const char *  severity,
const char *  new_severity,
task_t  task,
result_t  result,
override_t *  override 
)

Create an override.

Parameters
[in]activeNULL or -1 on, 0 off, n on for n days.
[in]nvtOID of overridden NVT.
[in]textOverride text.
[in]hostsHosts to apply override to, NULL for any host.
[in]portPort to apply override to, NULL for any port.
[in]threatThreat to apply override to, "" or NULL for any threat.
[in]new_threatThreat to override result to.
[in]severitySeverity to apply override to, "" or NULL for any.
[in]new_severitySeverity score to override "Alarm" type results to.
[in]taskTask to apply override to, 0 for any task.
[in]resultResult to apply override to, 0 for any result.
[out]overrideCreated override.
Returns
0 success, 1 failed to find NVT, 2 invalid port, 3 invalid severity, 99 permission denied, -1 error.

◆ create_report()

int create_report ( array_t *  results,
const char *  task_id,
const char *  task_name,
const char *  task_comment,
const char *  in_assets,
const char *  scan_start,
const char *  scan_end,
array_t *  host_starts,
array_t *  host_ends,
array_t *  details,
char **  report_id 
)

Create a report from an array of results.

Parameters
[in]resultsArray of create_report_result_t pointers.
[in]task_idUUID of container task, or NULL to create new one.
[in]task_nameName for container task.
[in]task_commentComment for container task.
[in]in_assetsWhether to create assets from the report.
[in]scan_startScan start time text.
[in]scan_endScan end time text.
[in]host_startsArray of create_report_result_t pointers. Host name in host, time in description.
[in]host_endsArray of create_report_result_t pointers. Host name in host, time in description.
[in]detailsArray of host_detail_t pointers.
[out]report_idReport ID.
Returns
0 success, 99 permission denied, -1 error, -2 failed to generate ID, -3 task_name is NULL, -4 failed to find task, -5 task must be container, -6 permission to create assets denied.

◆ create_report_format()

int create_report_format ( const char *  uuid,
const char *  name,
const char *  content_type,
const char *  extension,
const char *  summary,
const char *  description,
int  global,
array_t *  files,
array_t *  params,
array_t *  params_options,
const char *  signature,
report_format_t *  report_format 
)

Create a report format.

Parameters
[in]uuidUUID of format.
[in]nameName of format.
[in]content_typeContent type of format.
[in]extensionFile extension of format.
[in]summarySummary of format.
[in]descriptionDescription of format.
[in]globalWhether the report is global.
[in]filesArray of memory. Each item is a file name string, a terminating NULL, the file contents in base64 and a terminating NULL.
[in]paramsArray of params.
[in]params_optionsArray. Each item is an array corresponding to params. Each item of an inner array is a string, the text of an option in a selection.
[in]signatureSignature.
[out]report_formatCreated report format.
Returns
0 success, 1 report format exists, 2 empty file name, 3 param value validation failed, 4 param value validation failed, 5 param default missing, 6 param min or max out of range, 7 param type missing, 8 duplicate param name, 9 bogus param type name, 99 permission denied, -1 error.

◆ create_scanner()

int create_scanner ( const char *  name,
const char *  comment,
const char *  host,
const char *  port,
const char *  type,
scanner_t *  new_scanner,
const char *  ca_pub,
const char *  credential_id 
)

Create a scanner.

Parameters
[in]nameName of scanner.
[in]commentComment on scanner.
[in]hostHost of scanner.
[in]portPort of scanner.
[in]typeType of scanner.
[out]new_scannerThe created scanner.
[in]ca_pubCA Certificate for scanner.
[in]credential_idID of credential for scanner.
Returns
0 success, 1 scanner exists already, 2 Invalid value, 3 credential not found, 4 credential should be 'up', 5 credential should be 'cc', 99 permission denied.

◆ create_schedule()

int create_schedule ( const char *  name,
const char *  comment,
const char *  ical_string,
time_t  first_time,
time_t  period,
time_t  period_months,
const char *  byday,
time_t  duration,
const char *  zone,
schedule_t *  schedule,
gchar **  error_out 
)

Create a schedule.

Parameters
[in]nameName of schedule.
[in]commentComment on schedule.
[in]ical_stringiCalendar string. Overrides first_time, period, period_months, byday and duration.
[in]first_timeFirst time action will run.
[in]periodHow often the action will run in seconds. 0 means once.
[in]period_monthsThe months part of the period.
[in]bydayWhich days of week schedule will run.
[in]durationThe length of the time window the action will run in. 0 means entire duration of action.
[in]zoneTimezone.
[out]scheduleCreated schedule.
[out]error_outOutput for iCalendar errors and warnings.
Returns
0 success, 1 schedule exists already, 2 syntax error in byday, 3 error in iCal string, 99 permission denied.

◆ create_target()

int create_target ( const char *  name,
const char *  asset_hosts_filter,
const char *  hosts,
const char *  exclude_hosts,
const char *  comment,
const char *  port_list_id,
const char *  port_range,
credential_t  ssh_credential,
const char *  ssh_port,
credential_t  smb_credential,
credential_t  esxi_credential,
credential_t  snmp_credential,
const char *  reverse_lookup_only,
const char *  reverse_lookup_unify,
const char *  alive_tests,
target_t *  target 
)

Create a target.

Parameters
[in]nameName of target.
[in]asset_hosts_filterAsset host filter to select hosts. Overrides hosts and exclude_hosts.
[in]hostsHost list of target.
[in]exclude_hostsList of hosts to exclude from hosts.
[in]commentComment on target.
[in]port_list_idPort list of target (overrides port_range).
[in]port_rangePort range of target.
[in]ssh_credentialSSH credential.
[in]ssh_portPort for SSH login.
[in]smb_credentialSMB credential.
[in]esxi_credentialESXi credential.
[in]snmp_credentialSNMP credential.
[in]reverse_lookup_onlyScanner preference reverse_lookup_only.
[in]reverse_lookup_unifyScanner preference reverse_lookup_unify.
[in]alive_testsAlive tests.
[out]targetCreated target.
Returns
0 success, 1 target exists already, 2 error in host specification, 3 too many hosts, 4 error in port range, 5 error in SSH port, 6 failed to find port list, 7 error in alive tests, 8 invalid SSH credential type, 9 invalid SMB credential type, 10 invalid ESXi credential type, 11 invalid SNMP credential type, 99 permission denied, -1 error.

◆ create_task_check_config_scanner()

int create_task_check_config_scanner ( config_t  config,
scanner_t  scanner 
)

Check scanner and config values match for a task.

Parameters
[in]configScan Config.
[in]scannerScanner.
Returns
1 if config and scanner types match, 0 otherwise.

◆ credential_count()

int credential_count ( const get_data_t get)

Count number of LSC Credentials.

Parameters
[in]getGET params.
Returns
Total number of LSC Credentials in filtered set.

◆ credential_encrypted_value()

gchar* credential_encrypted_value ( credential_t  credential,
const char *  value_name 
)

Get a possibly encrypted credential value in decrypted form.

Parameters
[in]credentialThe Credential.
[in]value_nameName of the value.
Returns
Value.

◆ credential_in_use()

int credential_in_use ( credential_t  credential)

Check whether a Credential is in use.

Parameters
[in]credentialCredential.
Returns
1 yes, 0 no.

◆ credential_iterator_allow_insecure()

int credential_iterator_allow_insecure ( iterator_t iterator)

Get the login from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Login, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ credential_iterator_community()

const char* credential_iterator_community ( iterator_t iterator)

Get the SNMP community from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
SNMP community, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ credential_iterator_deb()

char* credential_iterator_deb ( iterator_t iterator)

Get the deb from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Deb, or NULL if iteration is complete. Free with g_free().

◆ credential_iterator_encrypted_data()

static const char* credential_iterator_encrypted_data ( iterator_t iterator,
const char *  type 
)
static

Get possibly encrypted data from credentials.

Parameters
[in]iteratorIterator.
[in]typeType of data.
Returns
Data.

◆ credential_iterator_exe()

char* credential_iterator_exe ( iterator_t iterator)

Get the exe from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Exe, or NULL if iteration is complete. Free with g_free().

◆ credential_iterator_format_available()

gboolean credential_iterator_format_available ( iterator_t iterator,
credential_format_t  format 
)

Test if a credential format is available for an iterator.

Parameters
[in]iteratorIterator.
[in]formatThe format to test availability of.
Returns
Whether format is available for the current credential of iterator.

◆ credential_iterator_formats_xml()

gchar* credential_iterator_formats_xml ( iterator_t iterator)

Get XML of available formats for a credential iterator.

Parameters
[in]iteratorIterator.
Returns
Newly allocated XML string.

◆ credential_iterator_password()

const char* credential_iterator_password ( iterator_t iterator)

Get the password from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Password, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ credential_iterator_privacy_password()

const char* credential_iterator_privacy_password ( iterator_t iterator)

Get the privacy password from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
SNMP community, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ credential_iterator_private_key()

const char* credential_iterator_private_key ( iterator_t iterator)

Get the private_key from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Private_key, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ credential_iterator_rpm()

char* credential_iterator_rpm ( iterator_t iterator)

Get the rpm from a Credential iterator.

Parameters
[in]iteratorIterator.
Returns
Rpm, or NULL if iteration is complete. Free with g_free().

◆ credential_name()

char* credential_name ( credential_t  credential)

Get the name of an LSC credential.

Parameters
[in]credentialCredential.
Returns
Name.

◆ credential_scanner_iterator_readable()

int credential_scanner_iterator_readable ( iterator_t iterator)

Get the read permission status from a Credential Scanner iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ credential_target_iterator_readable()

int credential_target_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ credential_type()

char* credential_type ( credential_t  credential)

Get the type of a Credential.

Parameters
[in]credentialCredential.
Returns
Credential type.

◆ credential_uuid()

char* credential_uuid ( credential_t  credential)

Get the UUID of a Credential.

Parameters
[in]credentialCredential.
Returns
UUID.

◆ credential_value()

gchar* credential_value ( credential_t  credential,
const char *  value_name 
)

Get a value from a credential.

Parameters
[in]credentialThe Credential.
[in]value_nameName of the value.
Returns
Value.

◆ credential_writable()

int credential_writable ( credential_t  credential)

Check whether a Credential is writable.

Parameters
[in]credentialCredential.
Returns
1 yes, 0 no.

◆ credentials_setup()

static int credentials_setup ( credentials_t *  credentials)
static

Set credentials for authenticate.

Parameters
[in]credentialsCredentials.
Returns
0 success, 99 permission denied.

◆ delete_agent()

int delete_agent ( const char *  agent_id,
int  ultimate 
)

Delete an agent.

Parameters
[in]agent_idUUID of agent.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 2 failed to find agent, 99 permission denied, -1 error.

◆ delete_alert()

int delete_alert ( const char *  alert_id,
int  ultimate 
)

Delete an alert.

Parameters
[in]alert_idUUID of alert.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a task refers to the alert, 2 failed to find target, 99 permission denied, -1 error.

◆ delete_config()

int delete_config ( const char *  config_id,
int  ultimate 
)

Delete a config.

Parameters
[in]config_idUUID of config.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a task refers to the config, 2 failed to find config, 3 config is predefined, 99 permission denied, -1 error.

◆ delete_credential()

int delete_credential ( const char *  credential_id,
int  ultimate 
)

Delete a Credential.

Parameters
[in]credential_idUUID of Credential.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because the credential is in use, 2 failed to find credential, 99 permission denied, -1 error.

◆ delete_note()

int delete_note ( const char *  note_id,
int  ultimate 
)

Delete a note.

Parameters
[in]note_idUUID of note.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 2 failed to find note, 99 permission denied, -1 error.

◆ delete_override()

int delete_override ( const char *  override_id,
int  ultimate 
)

Delete a override.

Parameters
[in]override_idUUID of override.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 2 failed to find override, 99 permission denied, -1 error.

◆ delete_report()

int delete_report ( const char *  report_id,
int  dummy 
)

Delete a report.

Parameters
[in]report_idUUID of report.
[in]dummyDummy arg to match other delete functions.
Returns
0 success, 2 failed to find report, 99 permission denied, -1 error.

◆ delete_report_format()

int delete_report_format ( const char *  report_format_id,
int  ultimate 
)

Delete a report format.

Parameters
[in]report_format_idUUID of Report format.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 report format in use, 2 failed to find report format, 3 predefined report format, 99 permission denied, -1 error.

◆ delete_report_format_rows()

static void delete_report_format_rows ( report_format_t  report_format)
static

Delete a report format from the db.

Parameters
[in]report_formatReport format.

◆ delete_report_internal()

int delete_report_internal ( report_t  report)

Delete a report.

It's up to the caller to provide the transaction.

Parameters
[in]reportReport.
Returns
0 success, 2 report is in use, -1 error.

◆ delete_reports()

int delete_reports ( task_t  task)

Delete all the reports for a task.

It's up to the caller to ensure that this runs in a contention safe context (for example within an SQL transaction).

Parameters
[in]taskA task descriptor.
Returns
0 on success, -1 on error.

◆ delete_scanner()

int delete_scanner ( const char *  scanner_id,
int  ultimate 
)

Delete a scanner.

Parameters
[in]scanner_idUUID of scanner.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 scanner in use, 2 failed to find scanner, 3 predefined scanner, 99 permission denied, -1 error.

◆ delete_schedule()

int delete_schedule ( const char *  schedule_id,
int  ultimate 
)

Delete a schedule.

Parameters
[in]schedule_idSchedule.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a task refers to the schedule, 2 failed to find schedule, 99 permission denied, -1 error.

◆ delete_slave_task()

int delete_slave_task ( const gchar *  host,
int  port,
const gchar *  username,
const gchar *  password,
const char *  slave_task_uuid 
)

Delete a task on a slave.

Parameters
[in]hostSlave host.
[in]portSlave port.
[in]usernameSlave username.
[in]passwordSlave password.
[in]slave_task_uuidUUID of task on slave.
Returns
0 success, -1 error.

◆ delete_target()

int delete_target ( const char *  target_id,
int  ultimate 
)

Delete a target.

Parameters
[in]target_idUUID of target.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a task refers to the target, 2 failed to find target, 3 predefined target, 99 permission denied, -1 error.

◆ delete_task()

int delete_task ( task_t  task,
int  ultimate 
)

Complete deletion of a task.

The caller must do the locking, and must do the hidden check.

The caller must handle the case where the task is already in the trashcan.

Parameters
[in]taskThe task.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 on success, -1 on error.

◆ delete_task_lock()

int delete_task_lock ( task_t  task,
int  ultimate 
)

Complete deletion of a task.

This sets up a transaction around the delete.

Parameters
[in]taskThe task.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 on success, 1 if task is hidden, -1 on error.

◆ delete_trash_tasks()

static int delete_trash_tasks ( )
static

Delete all trash tasks.

The caller must do the transaction.

Returns
0 on success, -1 on error.

◆ email()

static int email ( const char *  to_address,
const char *  from_address,
const char *  subject,
const char *  body,
const gchar *  attachment,
const char *  attachment_type,
const char *  attachment_name,
const char *  attachment_extension,
credential_t  recipient_credential 
)
static

Send an email.

Parameters
[in]to_addressAddress to send to.
[in]from_addressAddress to send to.
[in]subjectSubject of email.
[in]bodyBody of email.
[in]attachmentAttachment in line broken base64, or NULL.
[in]attachment_typeAttachment MIME type, or NULL.
[in]attachment_nameBase file name of the attachment, or NULL.
[in]attachment_extensionAttachment file extension, or NULL.
[in]recipient_credentialOptional credential to use for encryption.
Returns
0 success, -1 error.

◆ email_encrypt_gpg()

static int email_encrypt_gpg ( FILE *  plain_file,
FILE *  encrypted_file,
const char *  public_key,
const char *  to_address,
const char *  from_address,
const char *  subject 
)
static

Create a PGP encrypted email from a plain text one.

Parameters
[in]plain_fileStream to read the plain text email from.
[in]encrypted_fileStream to write the encrypted email to.
[in]public_keyRecipient public key to use for encryption.
[in]to_addressEmail address to send to.
[in]from_addressEmail address to use as sender.
[in]subjectSubject of email.
Returns
0 success, -1 error.

◆ email_encrypt_smime()

static int email_encrypt_smime ( FILE *  plain_file,
FILE *  encrypted_file,
const char *  certificate,
const char *  to_address,
const char *  from_address,
const char *  subject 
)
static

Create an S/MIME encrypted email from a plain text one.

Parameters
[in]plain_fileStream to read the plain text email from.
[in]encrypted_fileStream to write the encrypted email to.
[in]certificateRecipient certificate chain for encryption.
[in]to_addressEmail address to send to.
[in]from_addressEmail address to use as sender.
[in]subjectSubject of email.
Returns
0 success, -1 error.

◆ email_secinfo()

static int email_secinfo ( alert_t  alert,
task_t  task,
event_t  event,
const void *  event_data,
alert_method_t  method,
alert_condition_t  condition,
const gchar *  to_address,
const gchar *  from_address 
)
static

Build and send email for SecInfo alert.

Parameters
[in]alertAlert.
[in]taskTask.
[in]eventEvent.
[in]event_dataEvent data.
[in]methodMethod from alert.
[in]conditionCondition from alert, which was met by event.
[in]to_addressTo address.
[in]from_addressFrom address.
Returns
0 success, -1 error, -2 failed to find report format, -3 failed to find filter.

◆ email_ticket()

static int email_ticket ( alert_t  alert,
ticket_t  ticket,
event_t  event,
const void *  event_data,
alert_method_t  method,
alert_condition_t  condition,
const gchar *  to_address,
const gchar *  from_address,
const gchar *  subject 
)
static

Build and send email for a ticket alert.

Parameters
[in]alertAlert.
[in]ticketTicket.
[in]eventEvent.
[in]event_dataEvent data.
[in]methodMethod from alert.
[in]conditionCondition from alert, which was met by event.
[in]to_addressTo address.
[in]from_addressFrom address.
[in]subjectSubject.
Returns
0 success, -1 error.

◆ email_write_content()

static int email_write_content ( FILE *  content_file,
const char *  to_address,
const char *  from_address,
const char *  subject,
const char *  body,
const gchar *  attachment,
const char *  attachment_type,
const char *  attachment_name,
const char *  attachment_extension 
)
static

Write the content of a plain text email to a stream.

Parameters
[in]content_fileStream to write the email content to.
[in]to_addressAddress to send to.
[in]from_addressAddress to send to.
[in]subjectSubject of email.
[in]bodyBody of email.
[in]attachmentAttachment in line broken base64, or NULL.
[in]attachment_typeAttachment MIME type, or NULL.
[in]attachment_nameBase file name of the attachment, or NULL.
[in]attachment_extensionAttachment file extension, or NULL.
Returns
0 success, -1 error.

◆ encrypt_all_credentials()

static int encrypt_all_credentials ( gboolean  decrypt_flag)
static

Encrypt, re-encrypt or decrypt all credentials.

All plaintext credentials in the credentials table are encrypted, all already encrypted credentials are encrypted again using the latest key.

Parameters
[in]decrypt_flagIf true decrypt all credentials.
Returns
0 success, -1 error.

◆ escalate_1()

static int escalate_1 ( alert_t  alert,
task_t  task,
report_t  report,
event_t  event,
const void *  event_data,
alert_method_t  method,
alert_condition_t  condition,
gchar **  script_message 
)
static

Escalate an event with preset report filtering.

Parameters
[in]alertAlert.
[in]taskTask.
[in]reportReport.
[in]eventEvent.
[in]event_dataEvent data.
[in]methodMethod from alert.
[in]conditionCondition from alert, which was met by event.
[out]script_messageCustom error message from alert script.
Returns
0 success, -1 error, -2 failed to find report format for alert, -3 failed to find filter for alert, -4 failed to find credential, -5 alert script failed.

◆ escalate_2()

static int escalate_2 ( alert_t  alert,
task_t  task,
report_t  report,
event_t  event,
const void *  event_data,
alert_method_t  method,
alert_condition_t  condition,
const get_data_t get,
int  notes_details,
int  overrides_details,
gchar **  script_message 
)
static

Escalate an event.

Parameters
[in]alertAlert.
[in]taskTask.
[in]reportReport. 0 for most recent report.
[in]eventEvent.
[in]event_dataEvent data.
[in]methodMethod from alert.
[in]conditionCondition from alert, which was met by event.
[in]getGET data for report.
[in]notes_detailsIf notes, Whether to include details.
[in]overrides_detailsIf overrides, Whether to include details.
[out]script_messageCustom error message from the script.
Returns
0 success, -1 error, -2 failed to find report format, -3 failed to find filter, -4 failed to find credential, -5 alert script failed.

◆ escalate_to_vfire()

static int escalate_to_vfire ( alert_t  alert,
task_t  task,
report_t  report,
event_t  event,
const void *  event_data,
alert_method_t  method,
alert_condition_t  condition,
const get_data_t get,
int  notes_details,
int  overrides_details,
gchar **  script_message 
)
static

Escalate an event.

Parameters
[in]alertAlert.
[in]taskTask.
[in]reportReport. 0 for most recent report.
[in]eventEvent.
[in]event_dataEvent data.
[in]methodMethod from alert.
[in]conditionCondition from alert, which was met by event.
[in]getGET data for report.
[in]notes_detailsIf notes, Whether to include details.
[in]overrides_detailsIf overrides, Whether to include details.
[out]script_messageCustom error message from the script.
Returns
0 success, -1 error, -2 failed to find report format, -3 failed to find filter, -4 failed to find credential, -5 alert script failed.

◆ event()

void event ( event_t  event,
void *  event_data,
resource_t  resource_1,
resource_t  resource_2 
)

Produce an event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]resource_1Event type specific resource 1. For example, a task for EVENT_TASK_RUN_STATUS_CHANGED.
[in]resource_2Event type specific resource 2.

◆ event_alert_iterator_active()

static int event_alert_iterator_active ( iterator_t iterator)
static

Get the active state from an event alert iterator.

Parameters
[in]iteratorIterator.
Returns
Active state.

◆ event_alert_iterator_alert()

static alert_t event_alert_iterator_alert ( iterator_t iterator)
static

Get the alert from a event alert iterator.

Parameters
[in]iteratorIterator.
Returns
alert.

◆ event_applies()

static int event_applies ( event_t  event,
const void *  event_data,
resource_t  event_resource,
alert_t  alert 
)
static

Return whether an event applies to a task and an alert.

Parameters
[in]eventEvent.
[in]event_dataEvent data.
[in]event_resourceEvent resource.
[in]alertAlert.
Returns
1 if event applies, else 0.

◆ family_count()

int family_count ( )

Get the number of families.

Returns
Total number of families.

◆ family_is_selected()

static int family_is_selected ( const char *  quoted_selector,
const char *  quoted_family 
)
static

Check whether a family is selected.

Only works for "generating from empty" selection.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]quoted_familySQL-quoted family name (NULL for families).
Returns
1 if selected, else 0.

◆ filter_clause()

gchar* filter_clause ( const char *  type,
const char *  filter,
const char **  filter_columns,
column_t select_columns,
column_t where_columns,
int  trash,
gchar **  order_return,
int *  first_return,
int *  max_return,
array_t **  permissions,
gchar **  owner_filter 
)

Return SQL WHERE clause for restricting a SELECT to a filter term.

Parameters
[in]typeResource type.
[in]filterFilter term.
[in]filter_columnsFilter columns.
[in]select_columnsSELECT columns.
[in]where_columnsColumns in SQL that only appear in WHERE clause.
[out]trashWhether the trash table is being queried.
[out]order_returnIf given then order clause.
[out]first_returnIf given then first row.
[out]max_returnIf given then max rows.
[out]permissionsWhen given then permissions string vector.
[out]owner_filterWhen given then value of owner keyword.
Returns
WHERE clause for filter if one is required, else NULL.

◆ filter_clause_append_tag()

static void filter_clause_append_tag ( GString *  clause,
keyword_t keyword,
const char *  type,
int  first_keyword,
int  last_was_and,
int  last_was_not 
)
static

Append parts for a "tag" keyword to a filter clause.

Parameters
[in,out]clauseBuffer for the filter clause to append to.
[in]keywordThe keyword to create the filter clause part for.
[in]typeThe resource type.
[in]first_keywordWhether keyword is first.
[in]last_was_andWhether last keyword was "and".
[in]last_was_notWhether last keyword was "not".

◆ filter_clause_append_tag_id()

static void filter_clause_append_tag_id ( GString *  clause,
keyword_t keyword,
const char *  type,
int  first_keyword,
int  last_was_and,
int  last_was_not 
)
static

Append parts for a "tag_id" keyword to a filter clause.

Parameters
[in,out]clauseBuffer for the filter clause to append to.
[in]keywordThe keyword to create the filter clause part for.
[in]typeThe resource type.
[in]first_keywordWhether keyword is first.
[in]last_was_andWhether last keyword was "and".
[in]last_was_notWhether last keyword was "not".

◆ filter_control_int()

static int filter_control_int ( keyword_t **  point,
const char *  column,
int *  val 
)
static

Get an int column from a filter split.

Parameters
[in]pointFilter split.
[in]columnName of column.
[out]valValue of column.
Returns
0 success, 1 fail.

◆ filter_control_str()

static int filter_control_str ( keyword_t **  point,
const char *  column,
gchar **  string 
)
static

Get a string column from a filter split.

Parameters
[in]pointFilter split.
[in]columnName of column.
[out]stringValue of column, freshly allocated.
Returns
0 success, 1 fail.

◆ filter_free()

void filter_free ( array_t *  split)

Free a split filter.

Parameters
[in]splitSplit filter.

◆ filtered_host_count()

static int filtered_host_count ( const char *  levels,
const char *  search_phrase,
int  apply_overrides 
)
static

Count hosts with filtering.

Parameters
[in]levelsLevels.
[in]search_phrasePhrase that host IPs must include. All hosts if NULL or "".
[in]apply_overridesWhether to apply overrides.
Returns
Host count.

◆ find_agent_with_permission()

static gboolean find_agent_with_permission ( const char *  uuid,
agent_t *  agent,
const char *  permission 
)
static

Find a agent for a specific permission, given a UUID.

Parameters
[in]uuidUUID of agent.
[out]agentAgent return, 0 if successfully failed to find agent.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find agent), TRUE on error.

◆ find_alert_with_permission()

gboolean find_alert_with_permission ( const char *  uuid,
alert_t *  alert,
const char *  permission 
)

Find a alert for a specific permission, given a UUID.

Parameters
[in]uuidUUID of alert.
[out]alertAlert return, 0 if successfully failed to find alert.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find alert), TRUE on error.

◆ find_config_with_permission()

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.

Parameters
[in]uuidUUID of config.
[out]configConfig return, 0 if successfully failed to find config.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find config), TRUE on error.

◆ find_credential_with_permission()

gboolean find_credential_with_permission ( const char *  uuid,
credential_t *  credential,
const char *  permission 
)

Find a credential for a specific permission, given a UUID.

Parameters
[in]uuidUUID of credential.
[out]credentialCredential return, 0 if successfully failed to find Credential.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find credential), TRUE on error.

◆ find_note_with_permission()

gboolean find_note_with_permission ( const char *  uuid,
note_t *  note,
const char *  permission 
)

Find a note for a specific permission, given a UUID.

Parameters
[in]uuidUUID of note.
[out]noteNote return, 0 if successfully failed to find note.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find note), TRUE on error.

◆ find_override_with_permission()

gboolean find_override_with_permission ( const char *  uuid,
override_t *  override,
const char *  permission 
)

Find a override for a specific permission, given a UUID.

Parameters
[in]uuidUUID of override.
[out]overrideOverride return, 0 if successfully failed to find override.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find override), TRUE on error.

◆ find_report_format_with_permission()

gboolean find_report_format_with_permission ( const char *  uuid,
report_format_t *  report_format,
const char *  permission 
)

Find a reportformat for a specific permission, given a UUID.

Parameters
[in]uuidUUID of report format.
[out]report_formatReport format return, 0 if successfully failed to find report_format.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find report_format), TRUE on error.

◆ find_report_with_permission()

gboolean find_report_with_permission ( const char *  uuid,
report_t *  report,
const char *  permission 
)

Find a report for a specific permission, given a UUID.

Parameters
[in]uuidUUID of report.
[out]reportReport return, 0 if successfully failed to find report.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find report), TRUE on error.

◆ find_resource()

gboolean find_resource ( const char *  type,
const char *  uuid,
resource_t resource 
)

Find a resource given a UUID.

This only looks for resources owned (or effectively owned) by the current user. So no shared resources and no globals.

Parameters
[in]typeType of resource.
[in]uuidUUID of resource.
[out]resourceResource return, 0 if successfully failed to find resource.
Returns
FALSE on success (including if failed to find resource), TRUE on error.

◆ find_resource_by_name()

static gboolean find_resource_by_name ( const char *  type,
const char *  name,
resource_t resource 
)
static

Find a resource given a name.

Parameters
[in]typeType of resource.
[in]nameA resource name.
[out]resourceResource return, 0 if successfully failed to find resource.
Returns
FALSE on success (including if failed to find resource), TRUE on error.

◆ find_resource_by_name_with_permission()

static gboolean find_resource_by_name_with_permission ( const char *  type,
const char *  name,
resource_t resource,
const char *  permission 
)
static

Find a resource given a UUID and a permission.

Parameters
[in]typeType of resource.
[in]nameName of resource.
[out]resourceResource return, 0 if successfully failed to find resource.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find resource), TRUE on error.

◆ find_resource_with_permission()

gboolean find_resource_with_permission ( const char *  type,
const char *  uuid,
resource_t resource,
const char *  permission,
int  trash 
)

Find a resource given a UUID and a permission.

Parameters
[in]typeType of resource.
[in]uuidUUID of resource.
[out]resourceResource return, 0 if successfully failed to find resource.
[in]permissionPermission.
[in]trashWhether resource is in trashcan.
Returns
FALSE on success (including if failed to find resource), TRUE on error.

◆ find_result_with_permission()

gboolean find_result_with_permission ( const char *  uuid,
result_t *  result,
const char *  permission 
)

Find a result for a set of permissions, given a UUID.

Parameters
[in]uuidUUID of result.
[out]resultResult return, 0 if successfully failed to find result.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find result), TRUE on error.

◆ find_scanner_with_permission()

gboolean find_scanner_with_permission ( const char *  uuid,
scanner_t *  scanner,
const char *  permission 
)

Find a scanner for a specific permission, given a UUID.

Parameters
[in]uuidUUID of scanner.
[out]scannerScanner return, 0 if successfully failed to find scanner.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find scanner), TRUE on error.

◆ find_schedule_with_permission()

gboolean find_schedule_with_permission ( const char *  uuid,
schedule_t *  schedule,
const char *  permission 
)

Find a schedule for a specific permission, given a UUID.

Parameters
[in]uuidUUID of schedule.
[out]scheduleSchedule return, 0 if successfully failed to find schedule.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find schedule), TRUE on error.

◆ find_signature()

static int find_signature ( const gchar *  location,
const gchar *  installer_filename,
gchar **  signature,
gsize *  signature_size,
gchar **  uuid 
)
static

Find a signature in a feed.

Parameters
[in]locationFeed directory to search for signature.
[in]installer_filenameInstaller filename.
[out]signatureFreshly allocated installer signature.
[out]signature_sizeSize of installer signature.
[out]uuidAddress for basename of linked signature when the signature was found in the private directory, if desired, else NULL. Private directory is only checked if this is given.
Returns
0 success, -1 error.

◆ find_target_with_permission()

gboolean find_target_with_permission ( const char *  uuid,
target_t *  target,
const char *  permission 
)

Find a target for a specific permission, given a UUID.

Parameters
[in]uuidUUID of target.
[out]targetTarget return, 0 if successfully failed to find target.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find target), TRUE on error.

◆ find_task_with_permission()

gboolean find_task_with_permission ( const char *  uuid,
task_t *  task,
const char *  permission 
)

Find a task for a specific permission, given a UUID.

Parameters
[in]uuidUUID of task.
[out]taskTask return, 0 if successfully failed to find task.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find task), TRUE on error.

◆ find_trash()

gboolean find_trash ( const char *  type,
const char *  uuid,
resource_t resource 
)

Find a resource in the trashcan given a UUID.

Parameters
[in]typeType of resource.
[in]uuidUUID of resource.
[out]resourceResource return, 0 if successfully failed to find resource.
Returns
FALSE on success (including if failed to find resource), TRUE on error.

◆ find_trash_report_with_permission()

static gboolean find_trash_report_with_permission ( const char *  uuid,
report_t *  report,
const char *  permission 
)
static

Find a report in the trashcan for a specific permission, given a UUID.

Parameters
[in]uuidUUID of report.
[out]reportReport return, 0 if successfully failed to find report.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find report), TRUE on error.

◆ find_trash_task()

static gboolean find_trash_task ( const char *  uuid,
task_t *  task 
)
static

Find a task in the trashcan, given an identifier.

Parameters
[in]uuidA task identifier.
[out]taskTask return, 0 if successfully failed to find task.
Returns
FALSE on success (including if failed to find task), TRUE on error.

◆ find_trash_task_with_permission()

gboolean find_trash_task_with_permission ( const char *  uuid,
task_t *  task,
const char *  permission 
)

Find a task in the trashcan for a specific permission, given a UUID.

Parameters
[in]uuidUUID of task.
[out]taskTask return, 0 if successfully failed to find task.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find task), TRUE on error.

◆ free_host_ports()

static gboolean free_host_ports ( GTree *  host_ports,
gpointer  dummy 
)
static

Free delta host ports.

Parameters
[in]host_portsPorts.
[in]dummyDummy.
Returns
Always FALSE.

◆ generate_alert_filter_get()

static int generate_alert_filter_get ( alert_t  alert,
const get_data_t base_get_data,
get_data_t **  alert_filter_get,
filter_t *  filter_return 
)
static

Generates report results get data for an alert.

Parameters
[in]alertThe alert to try to get the filter data from.
[in]base_get_dataThe get data for fallback and other data.
[out]alert_filter_getPointer to the newly allocated get_data.
[out]filter_returnPointer to the filter.
Returns
0 success, -1 error, -3 filter not found.

◆ generate_report_filename()

static gchar* generate_report_filename ( report_t  report,
report_format_t  report_format,
const char *  custom_format,
gboolean  add_extension 
)
static

Generates a filename or path for a report.

If no custom_format is given, the setting "Report Export File Name" is used instead.

Parameters
[in]reportThe report to generate the filename for.
[in]report_formatThe report format to use.
[in]custom_formatA custom format string to use for the filename.
[in]add_extensionWhether to add the filename extension or not.
Returns
Newly allocated filename.

◆ get_delta_report()

static report_t get_delta_report ( alert_t  alert,
task_t  task,
report_t  report 
)
static

Get the delta report to be used for an alert.

Parameters
[in]alertAlert.
[in]taskTask.
[in]reportReport.
Returns
Report to compare with if required, else 0.

◆ get_iterator_comment()

const char* get_iterator_comment ( iterator_t iterator)

Get the comment from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
Comment.

◆ get_iterator_owner()

user_t get_iterator_owner ( iterator_t iterator)

Get the owner from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
Owner.

◆ get_iterator_resource()

resource_t get_iterator_resource ( iterator_t iterator)

Get the resource from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
Resource.

◆ get_join()

static const char* get_join ( int  first,
int  last_was_and,
int  last_was_not 
)
static

Return SQL join words for filter_clause.

Parameters
[in]firstWhether keyword is first.
[in]last_was_andWhether last keyword was "and".
[in]last_was_notWhether last keyword was "not".
Returns
SQL join words.

◆ get_scanner_params()

static GSList* get_scanner_params ( scanner_t  scanner)
static

Get list of OSP Scanner parameters.

Parameters
[in]scannerScanner.
Returns
List of scanner parameters, NULL if error.

◆ get_sysconf_gpghome()

static const char* get_sysconf_gpghome ( )
static

Return the name of the sysconf GnuPG home directory.

Returns the name of the GnuPG home directory to use when checking signatures. It is the directory openvas/gnupg under the sysconfdir that was set by configure (usually $prefix/etc).

Returns
Static name of the Sysconf GnuPG home directory.

◆ get_trustedkeys_name()

static const char* get_trustedkeys_name ( )
static

Return the name of the trusted keys file name.

We currently use the name pubring.gpg to be compatible with previous installations. That file should best be installed read-only so that it is not accidentally accessed while we are running a verification. All files in that keyring are assumed to be fully trustworthy.

Returns
Static file name.

◆ gmp_command_takes_resource()

static int gmp_command_takes_resource ( const char *  name)
static

Check whether a GMP command takes a resource.

MODIFY_TARGET, for example, takes a target.

Parameters
[in]nameCommand name.
Returns
1 if takes resource, else 0.

◆ gmp_command_type()

static gchar* gmp_command_type ( const char *  name)
static

Get the type associated with a GMP command.

Parameters
[in]nameCommand name.
Returns
Freshly allocated type name if any, else NULL.

◆ host_count()

static int host_count ( )
static

Count hosts.

Returns
Host count.

◆ host_detail_free()

void host_detail_free ( host_detail_t detail)

Free a host detail.

Parameters
[in]detailHost detail.

◆ host_identify()

static host_t host_identify ( const char *  host_name,
const char *  identifier_name,
const char *  identifier_value,
const char *  source_type,
const char *  source 
)
static

Identify a host, given an identifier.

Find a host which has an identifier of the same name and value, and which has no identifiers of the same name and a different value.

Parameters
[in]host_nameHost name.
[in]identifier_nameHost identifier name.
[in]identifier_valueValue of host identifier.
[in]source_typeSource of identification: result.
[in]sourceSource identifier.
Returns
Host if exists, else 0.

◆ host_iterator_current_port()

int host_iterator_current_port ( iterator_t iterator)

Get the current port from a host iterator.

Parameters
[in]iteratorIterator.
Returns
Current port.

◆ host_iterator_max_port()

int host_iterator_max_port ( iterator_t iterator)

Get the max port from a host iterator.

Parameters
[in]iteratorIterator.
Returns
Current port.

◆ host_iterator_report()

static report_t host_iterator_report ( iterator_t iterator)
static

Get the report from a host iterator.

Parameters
[in]iteratorIterator.
Returns
The report of the host.

◆ host_iterator_report_host()

static report_host_t host_iterator_report_host ( iterator_t iterator)
static

Get the report host from a host iterator.

Parameters
[in]iteratorIterator.
Returns
Report host.

◆ host_notice()

host_t host_notice ( const char *  host_name,
const char *  identifier_type,
const char *  identifier_value,
const char *  source_type,
const char *  source_id,
int  check_add_to_assets,
int  check_for_existing_identifier 
)

Notice a host.

When a host is detected during a scan, this makes the decision about which asset host is used for the host, as described in asset_rules. This decision is revised at the end of the scan by hosts_set_identifiers if there are any identifiers for the host.

Parameters
[in]host_nameName of host.
[in]identifier_typeType of host identifier.
[in]identifier_valueValue of host identifier.
[in]source_typeType of source identifier
[in]source_idSource identifier.
[in]check_add_to_assetsWhether to check the 'Add to Assets' task preference.
[in]check_for_existing_identifierWhether to check for an existing identifier like this one. Used for slaves, which call this repeatedly.
Returns
Host if existed, else 0.

◆ host_nthlast_report_host()

gboolean host_nthlast_report_host ( const char *  host,
report_host_t *  report_host,
int  position 
)

Get N'th last report_host given a host.

The last report_host is at position 1, the second last at position 2, and so on.

Parameters
[in]hostHost.
[in]report_hostReport host.
[in]positionPosition from end.
Returns
N'th last report_host.

◆ host_report_count()

static int host_report_count ( const char *  host)
static

Count host reports.

Parameters
[in]hostHost.
Returns
Report count.

◆ host_summary_append()

static void host_summary_append ( GString *  host_summary_buffer,
const char *  host,
const char *  start_iso,
const char *  end_iso 
)
static

Print the XML for a report to a file.

Parameters
[in]host_summary_bufferSummary.
[in]hostHost.
[in]start_isoStart time, in ISO format.
[in]end_isoEnd time, in ISO format.

◆ http_get()

static int http_get ( const char *  url)
static

GET an HTTP resource.

Parameters
[in]urlURL.
Returns
0 success, -1 error.

◆ info_name_count()

int info_name_count ( const char *  type,
const char *  name 
)

Count number of info of a given subtype with a given name.

Parameters
[in]typeGET_INFO subtype.
[out]nameName of the info item.
Returns
Total number of get_info items of given type, -1 on error.

◆ init_agent_iterator()

int init_agent_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise an agent iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find agent, 2 failed to find filter, -1 error.

◆ init_aggregate_iterator()

int init_aggregate_iterator ( iterator_t iterator,
const char *  type,
const get_data_t get,
int  distinct,
GArray *  data_columns,
const char *  group_column,
const char *  subgroup_column,
GArray *  text_columns,
GArray *  sort_data,
int  first_group,
int  max_groups,
const char *  extra_tables,
const char *  given_extra_where 
)

Initialise a GET_AGGREGATES iterator, including observed resources.

Parameters
[in]iteratorIterator.
[in]typeType of resource.
[in]getGET data.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]data_columnsColumns to calculate statistics for.
[in]group_columnColumn to group data by.
[in]subgroup_columnColumn to further group data by.
[in]text_columnsColumns to get text from.
[in]sort_dataGArray of sorting data.
[in]first_groupRow number to start iterating from.
[in]max_groupsMaximum number of rows.
[in]extra_tablesJoin tables. Skipped for trash and single resource.
[in]given_extra_whereExtra WHERE clauses. Skipped for single resource.
Returns
0 success, 1 failed to find resource, 2 failed to find filter, 3 invalid stat_column, 4 invalid group_column, 5 invalid type, 6 trashcan not used by type, 7 invalid text column, 8 invalid subgroup_column, -1 error.

◆ init_alert_data_iterator()

void init_alert_data_iterator ( iterator_t iterator,
alert_t  alert,
int  trash,
const char *  table 
)

Initialise an alert data iterator.

Parameters
[in]iteratorIterator.
[in]alertAlert.
[in]trashWhether to iterate over trashcan alert data.
[in]tableType of data: "condition", "event" or "method", corresponds to substring of the table to select from.

◆ init_alert_iterator()

int init_alert_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise an alert iterator, including observed alerts.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find alert, 2 failed to find filter (filt_id), -1 error.

◆ init_alert_task_iterator()

void init_alert_task_iterator ( iterator_t iterator,
alert_t  alert,
int  ascending 
)

Initialise an alert task iterator.

Iterate over all tasks that use the alert.

Parameters
[in]iteratorIterator.
[in]alertAlert.
[in]ascendingWhether to sort ascending or descending.

◆ init_classic_asset_iterator()

static void init_classic_asset_iterator ( iterator_t iterator,
int  first_result,
int  max_results,
const char *  levels,
const char *  search_phrase,
int  apply_overrides 
)
static

Initialise an asset iterator.

Parameters
[in]iteratorIterator.
[in]first_resultThe host to start from. The hosts are 0 indexed.
[in]max_resultsThe maximum number of hosts returned.
[in]levelsString describing threat levels (message types) to include in hosts (for example, "hml" for High, Medium and Low). All levels if NULL.
[in]search_phrasePhrase that host IPs must include. All hosts if NULL or "".
[in]apply_overridesWhether to apply overrides.
Todo:
Include tasks.hidden and task pref in_assets?

◆ init_config_iterator()

int init_config_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a scan config iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find scan config, 2 failed to find filter, -1 error.

◆ init_config_task_iterator()

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.

Parameters
[in]iteratorIterator.
[in]configConfig.
[in]ascendingWhether to sort ascending or descending.

◆ init_config_timeout_iterator()

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.

Parameters
[in]iteratorIterator.
[in]configConfig.

◆ init_credential_iterator()

int init_credential_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a Credential iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find filter, 2 failed to find filter (filt_id), -1 error.

◆ init_credential_iterator_one()

void init_credential_iterator_one ( iterator_t iterator,
credential_t  credential 
)

Initialise a Credential iterator, given a single Credential.

Parameters
[in]iteratorIterator.
[in]credentialSingle Credential to iterate.

◆ init_credential_scanner_iterator()

void init_credential_scanner_iterator ( iterator_t iterator,
credential_t  credential,
int  ascending 
)

Initialise a Credential scanner iterator.

Iterates over all scanners that use the credential.

Parameters
[in]iteratorIterator.
[in]credentialName of credential.
[in]ascendingWhether to sort ascending or descending.

◆ init_credential_target_iterator()

void init_credential_target_iterator ( iterator_t iterator,
credential_t  credential,
int  ascending 
)

Initialise a Credential target iterator.

Iterates over all targets that use the credential.

Parameters
[in]iteratorIterator.
[in]credentialName of credential.
[in]ascendingWhether to sort ascending or descending.

◆ init_delta_iterators()

static int init_delta_iterators ( report_t  report,
iterator_t results,
report_t  delta,
iterator_t delta_results,
const get_data_t get,
const char *  term,
const char *  sort_field 
)
static

Init delta iterators for print_report_xml.

Parameters
[in]reportThe report.
[in]resultsReport result iterator.
[in]deltaDelta report.
[in]delta_resultsDelta report result iterator.
[in]getGET command data.
[in]termFilter term.
[out]sort_fieldSort field.
Returns
0 on success, -1 error.

◆ init_event_alert_iterator()

static void init_event_alert_iterator ( iterator_t iterator,
event_t  event 
)
static

Initialise an event alert iterator.

Parameters
[in]iteratorIterator.
[in]eventEvent.

◆ init_family_iterator()

void init_family_iterator ( iterator_t iterator,
int  all,
const char *  selector,
int  ascending 
)

Initialise an NVT selector family iterator.

Parameters
[in]iteratorIterator.
[in]allTrue if families are growing in the selector, else 0. Only considered with a selector.
[in]selectorName of NVT selector. NULL for all families.
[in]ascendingWhether to sort ascending or descending.

◆ init_get_iterator()

int init_get_iterator ( iterator_t iterator,
const char *  type,
const get_data_t get,
column_t select_columns,
column_t trash_select_columns,
const char **  filter_columns,
int  distinct,
const char *  extra_tables,
const char *  extra_where,
int  owned 
)

Initialise a GET iterator, including observed resources.

Parameters
[in]iteratorIterator.
[in]typeType of resource.
[in]getGET data.
[in]select_columnsColumns for SQL.
[in]trash_select_columnsColumns for SQL trash case.
[in]filter_columnsColumns for filter.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]extra_tablesExtra tables to join in FROM clause.
[in]extra_whereExtra WHERE clauses. Skipped for single resource.
[in]ownedOnly get items owned by the current user.
Returns
0 success, 1 failed to find resource, 2 failed to find filter, -1 error.

◆ init_get_iterator2()

static int init_get_iterator2 ( iterator_t iterator,
const char *  type,
const get_data_t get,
column_t select_columns,
column_t trash_select_columns,
column_t where_columns,
column_t trash_where_columns,
const char **  filter_columns,
int  distinct,
const char *  extra_tables,
const char *  extra_where,
int  owned,
int  ignore_id,
const char *  extra_order 
)
static

Initialise a GET iterator, including observed resources.

Parameters
[in]iteratorIterator.
[in]typeType of resource.
[in]getGET data.
[in]select_columnsColumns for SQL.
[in]trash_select_columnsColumns for SQL trash case.
[in]where_columnsWHERE columns. These are columns that can be used for filtering and searching, but are not accessed (so column has no iterator access function).
[in]trash_where_columnsWHERE columns for trashcan.
[in]filter_columnsColumns for filter.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]extra_tablesExtra tables to join in FROM clause.
[in]extra_whereExtra WHERE clauses. Skipped for single resource.
[in]ownedOnly get items owned by the current user.
[in]ignore_idWhether to ignore id (e.g. for report results).
[in]extra_orderExtra ORDER clauses.
Returns
0 success, 1 failed to find resource, 2 failed to find filter, -1 error.

◆ init_get_iterator2_with()

static int init_get_iterator2_with ( iterator_t iterator,
const char *  type,
const get_data_t get,
column_t select_columns,
column_t trash_select_columns,
column_t where_columns,
column_t trash_where_columns,
const char **  filter_columns,
int  distinct,
const char *  extra_tables,
const char *  extra_where,
int  owned,
int  ignore_id,
const char *  extra_order,
const char *  extra_with,
int  assume_permitted 
)
static

Initialise a GET iterator, including observed resources.

This version includes the extra_with arg.

Parameters
[in]iteratorIterator.
[in]typeType of resource.
[in]getGET data.
[in]select_columnsColumns for SQL.
[in]trash_select_columnsColumns for SQL trash case.
[in]where_columnsWHERE columns. These are columns that can be used for filtering and searching, but are not accessed (so column has no iterator access function).
[in]trash_where_columnsWHERE columns for trashcan.
[in]filter_columnsColumns for filter.
[in]distinctWhether the query should be distinct. Skipped for trash and single resource.
[in]extra_tablesExtra tables to join in FROM clause.
[in]extra_whereExtra WHERE clauses. Skipped for single resource.
[in]ownedOnly get items owned by the current user.
[in]ignore_idWhether to ignore id (e.g. for report results).
[in]extra_orderExtra ORDER clauses.
[in]extra_withExtra WITH clauses.
[in]assume_permittedWhether to skip permission checks.
Returns
0 success, 1 failed to find resource, 2 failed to find filter, -1 error.

◆ init_host_prognosis_iterator()

void init_host_prognosis_iterator ( iterator_t iterator,
report_host_t  report_host,
int  first_result,
int  max_results,
const char *  levels,
const char *  search_phrase,
int  sort_order,
const char *  sort_field 
)

Initialise a report host prognosis iterator.

Parameters
[in]iteratorIterator.
[in]report_hostReport host whose prognosis the iterator loops over. All report_hosts if NULL.
[in]first_resultThe result to start from. The results are 0 indexed.
[in]max_resultsThe maximum number of results returned.
[in]levelsString describing threat levels (message types) to include in count (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[in]search_phrasePhrase that results must include. All results
[in]sort_orderWhether to sort in ascending order.
[in]sort_fieldName of the field to sort by.

◆ init_manage()

int init_manage ( GSList *  log_config,
int  nvt_cache_mode,
const gchar *  database,
int  max_ips_per_target,
int  max_email_attachment_size,
int  max_email_include_size,
int  max_email_message_size,
manage_connection_forker_t  fork_connection,
int  skip_db_check 
)

Initialize the manage library.

Check DB version, do startup database checks, load the NVT cache.

Ensure all tasks are in a clean initial state.

Beware that calling this function while tasks are running may lead to problems.

Parameters
[in]log_configLog configuration.
[in]nvt_cache_modeTrue when running in NVT caching mode.
[in]databaseLocation of database.
[in]max_ips_per_targetMax number of IPs per target.
[in]max_email_attachment_sizeMax size of email attachments.
[in]max_email_include_sizeMax size of email inclusions.
[in]max_email_message_sizeMax size of email user message text.
[in]fork_connectionFunction to fork a connection that will accept GMP requests. Used to start tasks with GMP when an alert occurs.
[in]skip_db_checkSkip DB check.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server, -4 max_ips_per_target out of range.

◆ init_manage_helper()

int init_manage_helper ( GSList *  log_config,
const gchar *  database,
int  max_ips_per_target 
)

Initialize the manage library for a helper program.

This should be called at the beginning of any program that accesses the database. Forked processes should call init_manage_process. The daemon itself calls init_manage, including in NVT cache mode.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of database.
[in]max_ips_per_targetMax number of IPs per target.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server, -4 max_ips_per_target out of range.

◆ init_manage_internal()

static int init_manage_internal ( GSList *  log_config,
int  nvt_cache_mode,
const gchar *  database,
int  max_ips_per_target,
int  max_email_attachment_size,
int  max_email_include_size,
int  max_email_message_size,
int  stop_tasks,
manage_connection_forker_t  fork_connection,
int  skip_db_check,
int  check_encryption_key 
)
static

Initialize the manage library.

Check DB version, do startup database checks, load the NVT cache. Optionally also stop active tasks.

Parameters
[in]log_configLog configuration.
[in]nvt_cache_modeTrue when running in NVT caching mode.
[in]databaseLocation of database.
[in]max_ips_per_targetMax number of IPs per target.
[in]max_email_attachment_sizeMax size of email attachments.
[in]max_email_include_sizeMax size of email inclusions.
[in]max_email_message_sizeMax size of email user message text.
[in]stop_tasksStop any active tasks.
[in]fork_connectionFunction to fork a connection that will accept GMP requests. Used to start tasks with GMP when an alert occurs.
[in]skip_db_checkSkip DB check.
[in]check_encryption_keyCheck encryption key if doing DB check.
Returns
0 success, -1 error, -2 database is wrong version, -4 max_ips_per_target out of range.

◆ init_manage_process()

void init_manage_process ( int  update_nvt_cache,
const gchar *  database 
)

Initialize the manage library for a process.

Open the SQL database, attach secondary databases, and define functions.

Parameters
[in]update_nvt_cache0 operate normally, -1 just update NVT cache.
[in]databaseLocation of manage database.

◆ init_note_iterator()

int init_note_iterator ( iterator_t iterator,
const get_data_t get,
nvt_t  nvt,
result_t  result,
task_t  task 
)

Initialise a note iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
[in]resultResult to limit notes to, 0 for all.
[in]taskIf result is > 0, task whose notes on result to include, otherwise task to limit notes to. 0 for all tasks.
[in]nvtNVT to limit notes to, 0 for all.
Returns
0 success, 1 failed to find target, 2 failed to find filter, -1 error.

◆ init_nvt_preference_iterator()

void init_nvt_preference_iterator ( iterator_t iterator,
const char *  name 
)

Initialise an NVT preference iterator.

Parameters
[in]iteratorIterator.
[in]nameName of NVT, NULL for all preferences.

◆ init_nvt_selector_iterator()

void init_nvt_selector_iterator ( iterator_t iterator,
const char *  selector,
config_t  config,
int  type 
)

Initialise an NVT selector iterator.

Parameters
[in]iteratorIterator.
[in]selectorName of single selector to iterate over, NULL for all.
[in]configConfig to limit iteration to, 0 for all.
[in]typeType of selector. All if config is given.

◆ init_otp_pref_iterator()

void init_otp_pref_iterator ( iterator_t iterator,
config_t  config,
const char *  section 
)

Initialise an "OTP" preference iterator.

Assume the caller has permission to access the config.

This version substitutes the scanner preference when the NVT preference is missing.

Parameters
[in]iteratorIterator.
[in]configConfig containing preferences.
[in]sectionPreference section, NULL for general preferences.

◆ init_override_iterator()

int init_override_iterator ( iterator_t iterator,
const get_data_t get,
nvt_t  nvt,
result_t  result,
task_t  task 
)

Initialise an override iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
[in]resultResult to limit overrides to, 0 for all.
[in]taskIf result is > 0, task whose overrides on result to include, otherwise task to limit overrides to. 0 for all tasks.
[in]nvtNVT to limit overrides to, 0 for all.
Returns
0 success, 1 failed to find target, 2 failed to find filter, -1 error.

◆ init_preference_iterator()

void init_preference_iterator ( iterator_t iterator,
config_t  config 
)

Initialise a preference iterator.

Assume the caller has permission to access the config.

Parameters
[in]iteratorIterator.
[in]configConfig.

◆ init_prognosis_iterator()

static void init_prognosis_iterator ( iterator_t iterator,
const char *  cpe 
)
static

Initialise a prognosis iterator.

Parameters
[in]iteratorIterator.
[in]cpeCPE.

◆ init_report_counts_build_iterator()

void init_report_counts_build_iterator ( iterator_t iterator,
report_t  report,
int  min_qod_limit,
int  add_defaults,
const char *  users_where 
)

Initializes an iterator for updating the report cache.

Parameters
[in]iteratorIterator.
[in]reportReport to select.
[in]min_qod_limitLimit for min_qod.
[in]add_defaultsWhether to add default values.
[in]users_whereOptional SQL clause to limit users.

◆ init_report_errors_iterator()

void init_report_errors_iterator ( iterator_t iterator,
report_t  report 
)

Initialise a report errors iterator.

Parameters
[in]iteratorIterator.
[in]reportThe report.

◆ init_report_host_details_iterator()

static void init_report_host_details_iterator ( iterator_t iterator,
report_host_t  report_host 
)
static

Initialise a report host details iterator.

Parameters
[in]iteratorIterator.
[in]report_hostReport host whose details the iterator loops over. All report_hosts if NULL.

◆ init_report_host_iterator()

void init_report_host_iterator ( iterator_t iterator,
report_t  report,
const char *  host,
report_host_t  report_host 
)

Initialise a host iterator.

Parameters
[in]iteratorIterator.
[in]reportReport whose hosts the iterator loops over.
[in]hostSingle host to iterate over. All hosts if NULL.
[in]report_hostSingle report host to iterate over. All if 0.

◆ init_report_iterator()

int init_report_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a report iterator, including observed reports.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find report, 2 failed to find filter, -1 error.

◆ init_report_iterator_task()

void init_report_iterator_task ( iterator_t iterator,
task_t  task 
)

Initialise a report iterator.

Parameters
[in]iteratorIterator.
[in]taskTask whose reports the iterator loops over.

◆ init_result_get_iterator()

int init_result_get_iterator ( iterator_t iterator,
const get_data_t get,
report_t  report,
const char *  host,
const gchar *  extra_order 
)

Initialise a result iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
[in]reportReport to restrict returned results to.
[in]hostHost to limit results to.
[in]extra_orderExtra text for ORDER term in SQL.
Returns
0 success, 1 failed to find result, 2 failed to find filter (filt_id), -1 error.

◆ init_result_get_iterator_severity()

static int init_result_get_iterator_severity ( iterator_t iterator,
const get_data_t get,
report_t  report,
const char *  host,
const gchar *  extra_order 
)
static

Initialise the severity-only result iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
[in]reportReport to restrict returned results to.
[in]hostHost to limit results to.
[in]extra_orderExtra text for ORDER term in SQL.
Returns
0 success, 1 failed to find result, 2 failed to find filter (filt_id), -1 error.

◆ init_scanner_config_iterator()

void init_scanner_config_iterator ( iterator_t iterator,
scanner_t  scanner 
)

Initialise a scanner config iterator.

Parameters
[in]iteratorIterator.
[in]scannerScanner.

◆ init_scanner_iterator()

int init_scanner_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise an scanner iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find scanner, 2 failed to find filter, -1 error.

◆ init_scanner_task_iterator()

void init_scanner_task_iterator ( iterator_t iterator,
scanner_t  scanner 
)

Initialise a scanner task iterator.

Parameters
[in]iteratorIterator.
[in]scannerScanner.

◆ init_schedule_iterator()

int init_schedule_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a schedule iterator.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find filter, 2 failed to find" filter (filt_id), -1 error.

◆ init_schedule_task_iterator()

void init_schedule_task_iterator ( iterator_t iterator,
schedule_t  schedule 
)

Initialise a schedule task iterator.

Parameters
[in]iteratorIterator.
[in]scheduleSchedule.

◆ init_target_iterator()

int init_target_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a target iterator, including observed targets.

Parameters
[in]iteratorIterator.
[in]getGET data.
Returns
0 success, 1 failed to find target, 2 failed to find filter, -1 error.

◆ init_target_iterator_one()

void init_target_iterator_one ( iterator_t iterator,
target_t  target 
)

Initialise a target iterator, given a single target.

Parameters
[in]iteratorIterator.
[in]targetSingle target to iterate.

◆ init_target_task_iterator()

void init_target_task_iterator ( iterator_t iterator,
target_t  target 
)

Initialise a target task iterator.

Iterates over all tasks that use the target.

Parameters
[in]iteratorIterator.
[in]targetTarget.

◆ init_task_alert_iterator()

void init_task_alert_iterator ( iterator_t iterator,
task_t  task 
)

Initialise a task alert iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.

◆ init_task_file_iterator()

void init_task_file_iterator ( iterator_t iterator,
task_t  task,
const char *  file 
)

Initialise a task file iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.
[in]fileFile name, NULL for all files.

◆ init_task_group_iterator()

void init_task_group_iterator ( iterator_t iterator,
task_t  task 
)

Initialise a task group iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.

◆ init_task_iterator()

int init_task_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a task iterator.

Parameters
[in]iteratorTask iterator.
[in]getGET data.
Returns
0 success, 1 failed to find target, 2 failed to find filter, -1 error.

◆ init_task_role_iterator()

void init_task_role_iterator ( iterator_t iterator,
task_t  task 
)

Initialise a task role iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.

◆ init_task_schedule_iterator()

int init_task_schedule_iterator ( iterator_t iterator)

Initialise a task schedule iterator.

Lock the database before initialising.

Parameters
[in]iteratorIterator.
Returns
0 success, 1 failed to get lock, -1 error.

◆ init_task_user_iterator()

static void init_task_user_iterator ( iterator_t iterator,
task_t  task 
)
static

Initialise a task user iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.

◆ init_user_config_iterator()

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.

Parameters
[in]iteratorIterator.
[in]configConfig. 0 for all.
[in]trashWhether to iterate over trashcan configs.
[in]ascendingWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for "id".

◆ init_user_task_iterator()

static void init_user_task_iterator ( iterator_t iterator,
int  trash,
int  ignore_severity 
)
static

Initialise a task iterator, limited to current user's tasks.

Parameters
[in]iteratorTask iterator.
[in]trashWhether to iterate over trashcan tasks.
[in]ignore_severityWhether to ignore severity data.

◆ insert_nvt_selectors()

static int insert_nvt_selectors ( const char *  quoted_name,
const array_t *  selectors 
)
static

Insert NVT selectors.

Parameters
[in]quoted_nameName of NVT selector.
[in]selectorsNVT selectors.
Returns
0 success, -1 error, -3 input error.
Todo:
Check that selector->type is actually an integer.

◆ insert_osp_parameter()

static int insert_osp_parameter ( osp_param_t *  param,
config_t  config 
)
static

Insert an OSP parameter into a config if not already present.

Parameters
[in]paramOSP parameter to insert.
[in]configConfig to insert parameter into.
Returns
1 if added, 0 otherwise.

◆ insert_report_host_detail()

void insert_report_host_detail ( report_t  report,
const char *  host,
const char *  s_type,
const char *  s_name,
const char *  s_desc,
const char *  name,
const char *  value 
)

Insert a host detail into a report.

Parameters
[in]reportThe detail's report.
[in]hostThe detail's host.
[in]s_typeThe detail's source type.
[in]s_nameThe detail's source name.
[in]s_descThe detail's source description.
[in]nameThe detail's name.
[in]valueThe detail's value.

◆ insert_scanner()

static void insert_scanner ( const char *  name,
const char *  comment,
const char *  host,
const char *  ca_pub,
int  iport,
int  itype,
scanner_t *  new_scanner 
)
static

Insert a scanner for create_scanner.

Parameters
[in]nameName of scanner.
[in]commentComment on scanner.
[in]hostHost of scanner.
[in]ca_pubCA Certificate for scanner.
[in]iportPort of scanner.
[in]itypeType of scanner.
[out]new_scannerThe created scanner.

◆ keyword_applies()

static int keyword_applies ( array_t *  array,
const keyword_t keyword 
)
static

Check whether a keyword has any effect in the filter.

Some keywords are redundant, like a second sort= keyword.

Parameters
[in]arrayArray of existing keywords.
[in]keywordKeyword under consideration.
Returns
0 no, 1 yes.

◆ keyword_applies_to_column()

static int keyword_applies_to_column ( keyword_t keyword,
const char *  column 
)
static

Check whether a keyword applies to a column.

Parameters
[in]keywordKeyword.
[in]columnColumn.
Returns
1 if applies, else 0.

◆ keyword_free()

static void keyword_free ( keyword_t keyword)
static

Free a keyword.

Parameters
[in]keywordFilter keyword.

◆ keyword_relation_symbol()

const char* keyword_relation_symbol ( keyword_relation_t  relation)

Get the symbol of a keyword relation.

Parameters
[in]relationRelation.
Returns
Relation symbol.

◆ keyword_special()

int keyword_special ( keyword_t keyword)

Get whether a keyword is special (like "and").

Parameters
[in]keywordKeyword.
Returns
1 if special, else 0.

◆ ldap_auth_enabled()

static int ldap_auth_enabled ( )
static

Check whether LDAP is enabled.

Returns
0 no, else yes.

◆ lookup_report_format()

static gboolean lookup_report_format ( const char *  name,
report_format_t *  report_format 
)
static

Find a report format given a name.

Parameters
[in]nameName of report_format.
[out]report_formatReport format return, 0 if successfully failed to find report_format.
Returns
FALSE on success (including if failed to find report format), TRUE on error.

◆ make_config_discovery()

void make_config_discovery ( char *const  uuid,
char *const  selector_name 
)

Make Discovery Scan Config.

Caller must lock the db.

Parameters
[in]uuidUUID for new scan config.
[in]selector_nameName of NVT selector to use.

◆ make_config_discovery_service_detection()

void make_config_discovery_service_detection ( char *const  selector_name)

Make Discovery Scan Config.

Caller must lock the db.

Parameters
[in]selector_nameName of NVT selector to use.

◆ make_config_host_discovery()

void make_config_host_discovery ( char *const  uuid,
char *const  selector_name 
)

Make Host Discovery Scan Config.

Caller must lock the db.

Parameters
[in]uuidUUID for new scan config.
[in]selector_nameName of NVT selector to use.

◆ make_config_system_discovery()

void make_config_system_discovery ( char *const  uuid,
char *const  selector_name 
)

Make System Discovery Scan Config.

Caller must lock the db.

Parameters
[in]uuidUUID for new scan config.
[in]selector_nameName of NVT selector to use.

◆ make_cve_result()

result_t make_cve_result ( task_t  task,
const char *  host,
const char *  nvt,
double  cvss,
const char *  description 
)

Make a CVE result.

Parameters
[in]taskThe task associated with the result.
[in]hostHost.
[in]nvtThe OID of the NVT that produced the result.
[in]cvssCVSS base.
[in]descriptionDescription of the result.
Returns
A result descriptor for the new result, 0 if error.

◆ make_osp_result()

result_t make_osp_result ( task_t  task,
const char *  host,
const char *  nvt,
const char *  type,
const char *  description,
const char *  port,
const char *  severity,
int  qod 
)

Make an OSP result.

Parameters
[in]taskThe task associated with the result.
[in]hostTarget host of result.
[in]nvtThe uuid of oval definition that produced the result, a title for the result otherwise.
[in]typeType of result. "Alarm", etc.
[in]descriptionDescription of the result.
[in]portResult port.
[in]severityResult severity.
[in]qodQuality of detection.
Returns
A result descriptor for the new result, 0 if error.

◆ make_port_ranges_all_tcp_nmap_5_51_top_100()

void make_port_ranges_all_tcp_nmap_5_51_top_100 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_port_ranges_all_tcp_nmap_5_51_top_1000()

void make_port_ranges_all_tcp_nmap_5_51_top_1000 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_port_ranges_iana_tcp_2012()

void make_port_ranges_iana_tcp_2012 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_port_ranges_iana_tcp_udp_2012()

void make_port_ranges_iana_tcp_udp_2012 ( port_list_t  list)

Make port ranges for IANA TCP and UDP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_port_ranges_nmap_5_51_top_2000_top_100()

void make_port_ranges_nmap_5_51_top_2000_top_100 ( port_list_t  list)

Make port ranges for Nmap top 2000 top 100.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_port_ranges_openvas_default()

static void make_port_ranges_openvas_default ( port_list_t  list)
static

Make port ranges.

Caller must lock the db.

Parameters
[in]listPort list.

◆ make_report()

report_t make_report ( task_t  task,
const char *  uuid,
task_status_t  status 
)

Make a report.

Parameters
[in]taskThe task associated with the report.
[in]uuidThe UUID of the report.
[in]statusThe run status of the scan associated with the report.
Returns
A report descriptor for the new report.

◆ make_report_format_uuids_unique()

static int make_report_format_uuids_unique ( )
static

Ensure every report format has a unique UUID.

Returns
0 success, -1 error.

◆ make_result()

result_t make_result ( task_t  task,
const char *  host,
const char *  hostname,
const char *  port,
const char *  nvt,
const char *  type,
const char *  description 
)

Make a result.

Parameters
[in]taskThe task associated with the result.
[in]hostHost IP address.
[in]hostnameHostname.
[in]portThe port the result refers to.
[in]nvtThe OID of the NVT that produced the result.
[in]typeType of result. "Security Hole", etc.
[in]descriptionDescription of the result.
Returns
A result descriptor for the new result, 0 if error.

◆ make_task()

task_t make_task ( char *  name,
char *  comment,
int  in_assets,
int  event 
)

Make a task.

The char* parameters name and comment are used directly and freed when the task is freed.

Parameters
[in]nameThe name of the task.
[in]commentA comment associated the task.
[in]in_assetsWhether task must be considered for assets.
[in]eventWhether to be generate event and event log.
Returns
A pointer to the new task.

◆ make_task_complete()

void make_task_complete ( task_t  task)

Complete the creation of a task.

Parameters
[in]taskThe task.

◆ manage_alert()

int manage_alert ( const char *  alert_id,
const char *  task_id,
event_t  event,
const void *  event_data,
gchar **  script_message 
)

Escalate an alert with task and event data.

Parameters
[in]alert_idAlert UUID.
[in]task_idTask UUID.
[in]eventEvent.
[in]event_dataEvent data.
[out]script_messageCustom error message from alert script.
Returns
0 success, 1 failed to find alert, 2 failed to find task, 99 permission denied, -1 error, -2 failed to find report format for alert, -3 failed to find filter for alert, -4 failed to find credential for alert, -5 alert script failed.

◆ manage_cert_db_supported_version()

int manage_cert_db_supported_version ( )

Return the database version supported by this manager.

Returns
Database version supported by this manager.

◆ manage_cert_db_version()

int manage_cert_db_version ( )

Return the database version of the actual database.

Returns
Database version read from database if possible, else -1.

◆ manage_check_alerts()

int manage_check_alerts ( GSList *  log_config,
const gchar *  database 
)

Check if any SecInfo alerts are due.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_clean_filter()

gchar* manage_clean_filter ( const gchar *  filter)

Clean a filter.

Parameters
[in]filterFilter.
Returns
Cleaned filter.

◆ manage_clean_filter_remove()

gchar* manage_clean_filter_remove ( const gchar *  filter,
const gchar *  column 
)

Clean a filter, removing a keyword in the process.

Parameters
[in]filterFilter.
[in]columnKeyword to remove, or NULL.
Returns
Cleaned filter.

◆ manage_cleanup_process_error()

void manage_cleanup_process_error ( int  signal)

Cleanup as immediately as possible.

Put any running task in the error state and close the database.

Intended for handlers for signals like SIGSEGV and SIGABRT.

Parameters
[in]signalDummy argument for use as signal handler.

◆ manage_count_hosts()

int manage_count_hosts ( const char *  given_hosts,
const char *  exclude_hosts 
)

Return number of hosts described by a hosts string.

Parameters
[in]given_hostsString describing hosts.
[in]exclude_hostsString describing hosts excluded from given set.
Returns
Number of hosts, or -1 on error.

◆ manage_create_scanner()

int manage_create_scanner ( GSList *  log_config,
const gchar *  database,
const char *  name,
const char *  host,
const char *  port,
const char *  type,
const char *  ca_pub_path,
const char *  key_pub_path,
const char *  key_priv_path 
)

Create the given scanner.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
[in]nameName of scanner.
[in]hostHost of scanner.
[in]portPort of scanner.
[in]typeType of scanner.
[in]ca_pub_pathCA Certificate path.
[in]key_pub_pathCertificate path.
[in]key_priv_pathPrivate key path.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_create_sql_functions()

int manage_create_sql_functions ( )

Create functions.

Returns
0 success, -1 error.

◆ manage_db_supported_version()

int manage_db_supported_version ( )

Return the database version supported by this manager.

Returns
Database version supported by this manager.

◆ manage_db_version()

int manage_db_version ( )

Return the database version of the actual database.

Returns
Database version read from database, -2 if database is empty, -1 on error.

◆ manage_decrypt_all_credentials()

int manage_decrypt_all_credentials ( GSList *  log_config,
const gchar *  database 
)

Decrypt all credentials.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_delete_scanner()

int manage_delete_scanner ( GSList *  log_config,
const gchar *  database,
const gchar *  uuid 
)

Delete the given scanner.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
[in]uuidUUID of scanner.
Returns
0 success, 2 failed to find scanner, 3 scanner can't be deleted, -1 error. -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_encrypt_all_credentials()

int manage_encrypt_all_credentials ( GSList *  log_config,
const gchar *  database 
)

Encrypt or re-encrypt all credentials.

All plaintext credentials in the credentials table are encrypted, all already encrypted credentials are encrypted again using the latest key.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_filter_controls()

void manage_filter_controls ( const gchar *  filter,
int *  first,
int *  max,
gchar **  sort_field,
int *  sort_order 
)

Get info from a filter.

It's up to the caller to ensure that max is adjusted for Max Rows Per Page (by calling manage_max_rows).

Parameters
[in]filterFilter.
[out]firstNumber of first item.
[out]maxMax number of rows.
[out]sort_fieldSort field.
[out]sort_orderSort order.

◆ manage_get_scanners()

int manage_get_scanners ( GSList *  log_config,
const gchar *  database 
)

List scanners.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
Returns
0 success, -1 error.

◆ manage_max_hosts()

int manage_max_hosts ( )

Get the maximum allowed number of hosts per target.

Returns
Maximum.

◆ manage_modify_scanner()

int manage_modify_scanner ( GSList *  log_config,
const gchar *  database,
const char *  scanner_id,
const char *  name,
const char *  host,
const char *  port,
const char *  type,
const char *  ca_pub_path,
const char *  key_pub_path,
const char *  key_priv_path 
)

Modify the given scanner.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
[in]scanner_idID of scanner.
[in]nameName of scanner.
[in]hostHost of scanner.
[in]portPort of scanner.
[in]typeType of scanner.
[in]ca_pub_pathCA Certificate path. NULL to leave it as is. "" to use the default.
[in]key_pub_pathCertificate path.
[in]key_priv_pathPrivate key path.
Returns
0 success, , 1 failed to find scanner, 2 scanner with new name exists, 3 scanner_id required, 4 invalid value, 99 permission denied, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_nvt_preference_add()

void manage_nvt_preference_add ( const char *  name,
const char *  value 
)

Add an NVT preference.

Parameters
[in]nameThe name of the preference.
[in]valueThe value of the preference.

◆ manage_option_setup()

int manage_option_setup ( GSList *  log_config,
const gchar *  database 
)

Setup for an option process.

Parameters
[in]log_configLog configuration.
[in]databaseDatabase.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

◆ manage_port_name()

char* manage_port_name ( int  number,
const char *  protocol 
)

Returns associated name for a tcp/ip port.

Parameters
numberPort number to get name for.
protocolProtocol type of port.
Returns
associated name for port if found, NULL otherwise.

◆ manage_report()

gchar* manage_report ( report_t  report,
report_t  delta_report,
const get_data_t get,
const report_format_t  report_format,
int  notes_details,
int  overrides_details,
const char *  type,
gsize *  output_length,
gchar **  extension,
gchar **  content_type,
gchar **  filter_term_return,
gchar **  zone_return,
gchar **  host_summary 
)

Generate a report.

Parameters
[in]reportReport.
[in]delta_reportReport to compare with.
[in]getGET data for report.
[in]report_formatReport format.
[in]notes_detailsIf notes, Whether to include details.
[in]overrides_detailsIf overrides, Whether to include details.
[in]typeType of report: NULL or "scan".
[out]output_lengthNULL or location for length of return.
[out]extensionNULL or location for report format extension. Only defined on success.
[out]content_typeNULL or location for report format content type. Only defined on success.
[out]filter_term_returnFilter term used in report.
[out]zone_returnActual timezone used in report.
[out]host_summarySummary of results per host.
Returns
Contents of report on success, NULL on error.

◆ manage_report_filter_controls()

void manage_report_filter_controls ( const gchar *  filter,
int *  first,
int *  max,
gchar **  sort_field,
int *  sort_order,
int *  result_hosts_only,
gchar **  min_qod,
gchar **  levels,
gchar **  delta_states,
gchar **  search_phrase,
int *  search_phrase_exact,
int *  autofp,
int *  notes,
int *  overrides,
int *  apply_overrides,
gchar **  zone 
)

Get info from a filter for report.

It's up to the caller to ensure that max is adjusted for Max Rows Per Page (by calling manage_max_rows).

Parameters
[in]filterFilter.
[out]firstNumber of first item.
[out]maxMax number of rows.
[out]sort_fieldSort field.
[out]sort_orderSort order.
[out]result_hosts_onlyWhether to show only hosts with results.
[out]min_qodMinimum QoD base of included results. All results if NULL.
[out]levelsString describing threat levels (message types) to include in count (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[out]delta_statesString describing delta states to include in count (for example, "sngc" Same, New, Gone and Changed). All levels if NULL.
[out]search_phrasePhrase that results must include. All results if NULL or "".
[out]search_phrase_exactWhether search phrase is exact.
[out]autofpWhether to apply auto FP filter.
[out]notesWhether to include notes.
[out]overridesWhether to include overrides.
[out]apply_overridesWhether to apply overrides.
[out]zoneTimezone.

◆ manage_resource_name()

int manage_resource_name ( const char *  type,
const char *  uuid,
char **  name 
)

Get the name of a resource.

Parameters
[in]typeType.
[in]uuidUUID.
[out]nameReturn for freshly allocated name.
Returns
0 success, 1 error in type.

◆ manage_scanner_set()

static int manage_scanner_set ( const char *  uuid)
static

Set the address of scanner to connect to.

Parameters
[in]uuidScanner UUID.
Returns
0 if success, -1 if error, -2 scanner has no cert.

◆ manage_scanner_set_default()

int manage_scanner_set_default ( )

Set the default scanner as the scanner to connect to.

Returns
0 success, -1 error, -2 scanner has no cert.

◆ manage_scap_db_supported_version()

int manage_scap_db_supported_version ( )

Return the database version supported by this manager.

Returns
Database version supported by this manager.

◆ manage_scap_db_version()

int manage_scap_db_version ( )

Return the database version of the actual database.

Returns
Database version read from database if possible, else -1.

◆ manage_send_report()

int manage_send_report ( report_t  report,
report_t  delta_report,
report_format_t  report_format,
const get_data_t get,
int  notes_details,
int  overrides_details,
int  result_tags,
int  ignore_pagination,
int  base64,
gboolean(*)(const char *, int(*)(const char *, void *), void *)  send,
int(*)(const char *, void *)  send_data_1,
void *  send_data_2,
const char *  alert_id,
const char *  type,
const char *  host,
int  pos,
const char *  host_search_phrase,
const char *  host_levels,
int  host_first_result,
int  host_max_results,
const gchar *  prefix 
)

Generate a report.

Parameters
[in]reportReport.
[in]delta_reportReport to compare with.
[in]report_formatReport format.
[in]getGET command data.
[in]notes_detailsIf notes, Whether to include details.
[in]overrides_detailsIf overrides, Whether to include details.
[in]result_tagsWhether to include tags in results.
[in]ignore_paginationWhether to ignore pagination.
[in]base64Whether to base64 encode the report.
[in]sendFunction to write to client.
[in]send_data_1Second argument to send.
[in]send_data_2Third argument to send.
[in]alert_idID of alert to escalate report with, instead of getting report. NULL to get report.
[in]typeType of report: NULL, "scan" or "assets".
[in]hostHost or NULL, when type "assets".
[in]posPosition of report from end, when host. 1 for last.
[in]host_search_phrasePhrase that results must include. All results if NULL or "". For hosts.
[in]host_levelsString describing threat levels (message types) to include in count (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[in]host_first_resultThe host result to start from. The results are 0 indexed.
[in]host_max_resultsThe host maximum number of results returned.
[in]prefixText to send to client before the report.
Returns
0 success, -1 error, -2 failed to find alert report format, -3 error during alert, -4 failed to find alert filter, 1 failed to find alert, 2 failed to find filter (before anything sent to client).

◆ manage_set_config()

int manage_set_config ( const gchar *  config_id,
const char *  name,
const char *  comment,
const char *  scanner_id 
)

Set the name, comment and scanner of a config.

Parameters
[in]config_idConfig.
[in]nameNew name, not updated if NULL.
[in]commentNew comment, not updated if NULL.
[in]scanner_idUUID of new scanner, not updated if NULL.
Returns
0 success, 1 config with new name exists already, 2 scanner doesn't exist, 3 modification not allowed while config is in use, 4 failed to find config, -1 error.

◆ manage_set_config_families()

int manage_set_config_families ( const gchar *  config_id,
GPtrArray *  growing_all_families,
GPtrArray *  static_all_families,
GPtrArray *  growing_families,
int  grow_families 
)

Refresh NVT selection of a config from given families.

Parameters
[in]config_idConfig.
[in]growing_all_familiesGrowing families with all selection.
[in]static_all_familiesStatic families with all selection.
[in]growing_familiesThe rest of the growing families.
[in]grow_families1 if families should grow, else 0.
Returns
0 success, 1 config in use, 2 failed to find config, -1 error.

◆ manage_set_config_nvts()

int manage_set_config_nvts ( const gchar *  config_id,
const char *  family,
GPtrArray *  selected_nvts 
)

Set the NVT's selected for a single family of a config.

Parameters
[in]config_idConfig.
[in]familyFamily name.
[in]selected_nvtsNVT's.
Returns
0 success, 1 config in use, 2 failed to find config, -1 error.

◆ manage_set_config_preference()

int manage_set_config_preference ( const gchar *  config_id,
const char *  nvt,
const char *  name,
const char *  value_64 
)

Set a preference of a config.

Parameters
[in]config_idConfig.
[in]nvtUUID of NVT. NULL for scanner preference.
[in]namePreference name, including NVT name and preference type.
[in]value_64Preference value in base64. NULL for an NVT preference removes the preference from the config.
Returns
0 success, 1 config in use, 2 empty radio value, 3 failed to find config, -1 error.

◆ manage_set_max_hosts()

static void manage_set_max_hosts ( int  new_max)
static

Set the maximum allowed number of hosts per target.

Parameters
[in]new_maxNew max_hosts value.

◆ manage_task_remove_file()

int manage_task_remove_file ( const gchar *  task_id,
const char *  name 
)

Remove a file on a task.

Parameters
[in]task_idTask.
[in]nameName of file.
Returns
0 success, 1 failed to find task, -1 error.

◆ manage_task_update_file()

int manage_task_update_file ( const gchar *  task_id,
const char *  name,
const void *  content 
)

Add a file to a task, or update the file on the task.

Parameters
[in]task_idTask.
[in]nameName of file.
[in]contentContent for file in base64 encoding.
Returns
0 success, 1 failed to find task, -1 error.
Todo:
Probably better to save ASCII instead of base64.

◆ manage_test_alert()

int manage_test_alert ( const char *  alert_id,
gchar **  script_message 
)

Test an alert.

Parameters
[in]alert_idAlert UUID.
[out]script_messageCustom message from the alert script.
Returns
0 success, 1 failed to find alert, 2 failed to find task, 99 permission denied, -1 error, -2 failed to find report format for alert, -3 failed to find filter for alert, -4 failed to find credential for alert, -5 alert script failed.

◆ manage_transaction_stop()

void manage_transaction_stop ( gboolean  force_commit)

Commit the current transaction, if any.

The algorithm is extremely naive (time elapsed since the last message was received) but delivers good enough performances when facing bursts of messages.

Parameters
[in]force_commitForce committing the pending transaction.

◆ manage_trash_resource_name()

int manage_trash_resource_name ( const char *  type,
const char *  uuid,
char **  name 
)

Get the name of a trashcan resource.

Parameters
[in]typeType.
[in]uuidUUID.
[out]nameReturn for freshly allocated name.
Returns
0 success, 1 error in type.

◆ manage_update_nvti_cache()

int manage_update_nvti_cache ( )

Update the memory cache of NVTs, if this has been requested.

Returns
0 success, 1 failed to get lock, -1 error.

◆ manage_user_hash()

gchar* manage_user_hash ( const gchar *  username)

Get user hash.

This is for "file" users, now entirely stored in db.

Parameters
[in]usernameUser name.
Returns
Hash.

◆ manage_verify_scanner()

int manage_verify_scanner ( GSList *  log_config,
const gchar *  database,
const gchar *  uuid 
)

Verify the given scanner.

Parameters
[in]log_configLog configuration.
[in]databaseLocation of manage database.
[in]uuidUUID of scanner.
Returns
0 success, 1 failed to find scanner, 2 failed to verify scanner, -1 error. -2 database is wrong version, -3 database needs to be initialised from server.

◆ member()

static int member ( GPtrArray *  array,
const char *  string 
)
static

Test whether a string equal to a given string exists in an array.

Parameters
[in]arrayArray of gchar* pointers.
[in]stringString.
Returns
1 if a string equal to
  • string exists in
  • array, else 0.

◆ message_type_threat()

const char* message_type_threat ( const char *  type)

Get the threat of a message type.

Parameters
typeMessage type.
Returns
Static threat name if type names a message type, else NULL.

◆ modify_agent()

int modify_agent ( const char *  agent_id,
const char *  name,
const char *  comment 
)

Modify an agent.

Parameters
[in]agent_idUUID of agent.
[in]nameName of agent.
[in]commentComment on agent.
Returns
0 success, 1 failed to find agent, 2 agent with new name exists, 3 agent_id required, 99 permission denied, -1 internal error.

◆ modify_alert()

int modify_alert ( const char *  alert_id,
const char *  name,
const char *  comment,
const char *  filter_id,
const char *  active,
event_t  event,
GPtrArray *  event_data,
alert_condition_t  condition,
GPtrArray *  condition_data,
alert_method_t  method,
GPtrArray *  method_data 
)

Modify an alert.

Parameters
[in]alert_idUUID of alert.
[in]nameName of alert.
[in]commentComment on alert.
[in]filter_idFilter.
[in]activeWhether the alert is active. NULL to leave it at the current value.
[in]eventType of event.
[in]event_dataType-specific event data.
[in]conditionEvent condition.
[in]condition_dataCondition-specific data.
[in]methodEscalation method.
[in]method_dataData for escalation method.
Returns
0 success, 1 failed to find alert, 2 alert with new name exists, 3 alert_id required, 4 failed to find filter, 5 filter type must be result if specified, 6 Provided email address not valid, 7 unexpected condition data name, 8 syntax error in condition data, 9 email subject too long, 10 email message too long, 11 failed to find filter for condition, 12 error in Send host, 13 error in Send port, 14 failed to find report format for Send method, 15 error in SCP host, 17 failed to find report format for SCP method, 18 error in SCP credential, 19 error in SCP path, 20 method does not match event, 21 condition does not match event, 31 unexpected event data name, 32 syntax error in event data, 40 invalid SMB credential , 41 invalid SMB share path, 42 invalid SMB file path, 43 SMB file path contains dot, 50 invalid TippingPoint credential, 51 invalid TippingPoint hostname, 52 invalid TippingPoint certificate, 53 invalid TippingPoint TLS workaround setting, 60 recipient credential not found, 61 invalid recipient credential type, 70 vFire credential not found, 71 invalid vFire credential type, 99 permission denied, -1 internal error.

◆ modify_credential()

int modify_credential ( const char *  credential_id,
const char *  name,
const char *  comment,
const char *  login,
const char *  password,
const char *  key_private,
const char *  key_public,
const char *  certificate,
const char *  community,
const char *  auth_algorithm,
const char *  privacy_password,
const char *  privacy_algorithm,
const char *  allow_insecure 
)

Modify a Credential.

Parameters
[in]credential_idUUID of Credential.
[in]nameName of Credential.
[in]commentComment on Credential.
[in]loginLogin of Credential.
[in]passwordPassword or passphrase of Credential.
[in]key_privatePrivate key of Credential.
[in]key_publicPublic key of Credential.
[in]certificateCertificate of Credential.
[in]communitySNMP Community of Credential.
[in]auth_algorithmAuthentication algorithm of Credential.
[in]privacy_passwordPrivacy password of Credential.
[in]privacy_algorithmPrivacy algorithm of Credential.
[in]allow_insecureWhether to allow insecure use.
Returns
0 success, 1 failed to find credential, 2 credential with new name exists, 3 credential_id required, 4 invalid login name, 5 invalid certificate, 6 invalid auth_algorithm, 7 invalid privacy_algorithm, 8 invalid private key, 9 invalid public key, 10 privacy password must be empty if algorithm is empty 99 permission denied, -1 internal error.

◆ modify_note()

int modify_note ( const gchar *  note_id,
const char *  active,
const char *  nvt,
const char *  text,
const char *  hosts,
const char *  port,
const char *  severity,
const char *  threat,
const gchar *  task_id,
const gchar *  result_id 
)

Modify a note.

Parameters
[in]note_idNote.
[in]activeNULL or -2 leave as is, -1 on, 0 off, n on for n days.
[in]nvtOID of noted NVT.
[in]textNote text.
[in]hostsHosts to apply note to, NULL for any host.
[in]portPort to apply note to, NULL for any port.
[in]severitySeverity to apply note to, "" or NULL for any.
[in]threatThreat to apply note to, "" or NULL for any threat. Only used if severity is "" or NULL.
[in]task_idTask to apply note to, NULL for any task.
[in]result_idResult to apply note to, 0 for any result.
Returns
0 success, -1 error, 1 syntax error in active, 2 invalid port, 3 invalid severity, 4 failed to find NVT, 5 failed to find note, 6 failed to find task, 7 failed to find result.

◆ modify_override()

int modify_override ( const gchar *  override_id,
const char *  active,
const char *  nvt,
const char *  text,
const char *  hosts,
const char *  port,
const char *  threat,
const char *  new_threat,
const char *  severity,
const char *  new_severity,
const gchar *  task_id,
const gchar *  result_id 
)

Modify an override.

Parameters
[in]override_idOverride.
[in]activeNULL or -2 leave as is, -1 on, 0 off, n on for n days.
[in]nvtOID of noted NVT.
[in]textOverride text.
[in]hostsHosts to apply override to, NULL for any host.
[in]portPort to apply override to, NULL for any port.
[in]threatThreat to apply override to, "" or NULL for any threat.
[in]new_threatThreat to override result to.
[in]severitySeverity to apply override to, "" or NULL for any threat.
[in]new_severitySeverity score to override "Alarm" type results to.
[in]task_idTask to apply override to, 0 for any task.
[in]result_idResult to apply override to, 0 for any result.
Returns
0 success, -1 error, 1 syntax error in active, 2 invalid port, 3 invalid severity score, 4 failed to find NVT, 5 failed to find override, 6 failed to find task, 7 failed to find result.

◆ modify_report()

int modify_report ( const char *  report_id,
const char *  comment 
)

Modify a report.

Parameters
[in]report_idUUID of report.
[in]commentComment on report.
Returns
0 success, 1 failed to find report, 2 report_id required, 3 comment required, 99 permission denied, -1 internal error.

◆ modify_report_format()

int modify_report_format ( const char *  report_format_id,
const char *  name,
const char *  summary,
const char *  active,
const char *  param_name,
const char *  param_value,
const char *  predefined 
)

Modify a report format.

Parameters
[in]report_format_idUUID of report format.
[in]nameName of report format.
[in]summarySummary of report format.
[in]activeActive flag.
[in]param_nameParameter to modify.
[in]param_valueValue of parameter.
[in]predefinedPredefined flag.
Returns
0 success, 1 failed to find report format, 2 report_format_id required, 3 failed to find report format parameter, 4 parameter value validation failed, 5 error in predefined, 99 permission denied, -1 internal error.

◆ modify_scanner()

int modify_scanner ( const char *  scanner_id,
const char *  name,
const char *  comment,
const char *  host,
const char *  port,
const char *  type,
const char *  ca_pub,
const char *  credential_id 
)

Modify an scanner.

Parameters
[in]scanner_idUUID of scanner.
[in]nameName of scanner.
[in]commentComment on scanner.
[in]hostHost of scanner.
[in]portPort of scanner.
[in]typeType of scanner.
[in]ca_pubCA Certificate of scanner, or "" for default, or to keep existing value.
[in]credential_idUUID of credential or NULL.
Returns
0 success, 1 failed to find scanner, 2 scanner with new name exists, 3 scanner_id required, 4 invalid value, 5 credential not found, 6 credential should be 'cc', 7 credential should be 'up', 99 permission denied, -1 internal error.

◆ modify_schedule()

int modify_schedule ( const char *  schedule_id,
const char *  name,
const char *  comment,
const char *  ical_string,
time_t  first_time,
time_t  period,
time_t  period_months,
const char *  byday,
time_t  duration,
const char *  zone,
gchar **  error_out 
)

Modify a schedule.

Parameters
[in]schedule_idUUID of schedule.
[in]nameName of schedule.
[in]commentComment on schedule.
[in]ical_stringiCalendar string. Overrides first_time, period, period_months, byday and duration.
[in]first_timeFirst time action will run.
[in]periodHow often the action will run in seconds. 0 means once.
[in]period_monthsThe months part of the period.
[in]bydayWhich days of week schedule will run.
[in]durationThe length of the time window the action will run in. 0 means entire duration of action.
[in]zoneTimezone.
[out]error_outOutput for iCalendar errors and warnings.
Returns
0 success, 1 failed to find schedule, 2 schedule with new name exists, 3 error in type name, 4 schedule_id required, 5 syntax error in byday, 6 error in iCalendar, 99 permission denied, -1 internal error.

◆ modify_target()

int modify_target ( const char *  target_id,
const char *  name,
const char *  hosts,
const char *  exclude_hosts,
const char *  comment,
const char *  port_list_id,
const char *  ssh_credential_id,
const char *  ssh_port,
const char *  smb_credential_id,
const char *  esxi_credential_id,
const char *  snmp_credential_id,
const char *  reverse_lookup_only,
const char *  reverse_lookup_unify,
const char *  alive_tests 
)

Modify a target.

Parameters
[in]target_idUUID of target.
[in]nameName of target.
[in]hostsHost list of target.
[in]exclude_hostsList of hosts to exclude from hosts.
[in]commentComment on target.
[in]port_list_idPort list of target (overrides port_range).
[in]ssh_credential_idSSH credential.
[in]ssh_portPort for SSH login.
[in]smb_credential_idSMB credential.
[in]esxi_credential_idESXi credential.
[in]snmp_credential_idSNMP credential.
[in]reverse_lookup_onlyScanner preference reverse_lookup_only.
[in]reverse_lookup_unifyScanner preference reverse_lookup_unify.
[in]alive_testsAlive tests.
Returns
0 success, 1 target exists already, 2 error in host specification, 3 too many hosts, 4 error in port range, 5 error in SSH port, 6 failed to find port list, 7 failed to find SSH cred, 8 failed to find SMB cred, 9 failed to find target, 10 error in alive tests, 11 zero length name, 12 exclude hosts requires hosts 13 hosts requires exclude hosts, 14 hosts must be at least one character, 15 target is in use, 16 failed to find ESXi cred, 17 failed to find SNMP cred, 18 invalid SSH credential type, 19 invalid SMB credential type, 20 invalid ESXi credential type, 21 invalid SNMP credential type, 99 permission denied, -1 error.

◆ modify_task()

int modify_task ( const gchar *  task_id,
const gchar *  name,
const gchar *  comment,
const gchar *  scanner_id,
const gchar *  target_id,
const gchar *  config_id,
const gchar *  observers,
array_t *  alerts,
const gchar *  alterable,
array_t *  groups,
const gchar *  schedule_id,
const gchar *  schedule_periods,
array_t *  preferences,
const gchar *  hosts_ordering,
gchar **  fail_alert_id,
gchar **  fail_group_id 
)

Modify a task.

Parameters
[in]task_idTask.
[in]nameName of file.
[in]commentComment.
[in]scanner_idScanner.
[in]target_idTarget.
[in]config_idConfig.
[in]observersObservers.
[in]alertsAlerts.
[in]alterableAlterable.
[in]groupsGroups.
[in]schedule_idSchedule.
[in]schedule_periodsPeriod of schedule.
[in]preferencesPreferences.
[in]hosts_orderingHost scan order.
[out]fail_alert_idAlert when failed to find alert.
[out]fail_group_idGroup when failed to find group.
Returns
0 success, 1 failed to find task, 2 status must be new to edit scanner, 3 failed to find scanner, 4 failed to find config, 5 status must be new to edit config, 6 user name validation failed, 7 failed to find user, 8 failed to find alert, 9 task must be new to modify alterable state, 10 failed to find group, 11 failed to find schedule, 12 failed to find target, 13 invalid auto_delete value, 14 auto delete count out of range, 15 config and scanner types mismatch, 16 status must be new to edit target, 17 for container tasks only certain fields may be edited, -1 error.

◆ modify_task_check_config_scanner()

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.

Parameters
[in]taskTask.
[in]config_idID of config. "0" to use task's config.
[in]scanner_idID of scanner.
Returns
0 if config and scanner types match, 1 do not match, 2 failed to find config, 3 failed to find scanner, -1 error.

◆ move_report_format_dir()

static int move_report_format_dir ( const char *  dir,
const char *  new_dir 
)
static

Move a report format directory.

Parameters
[in]dirOld dir.
[in]new_dirNew dir.
Returns
0 success, -1 error.

◆ new_cert_bunds_list()

static gchar* new_cert_bunds_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for "New CERT-Bund Advisories" event message.

Parameters
[in]eventEvent.
[in]event_dataEvent data.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated string.

◆ new_cpes_list()

static gchar* new_cpes_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for New CPEs event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated list.

◆ new_cves_list()

static gchar* new_cves_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for New CVEs event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated message.

◆ new_dfn_certs_list()

static gchar* new_dfn_certs_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for "New DFN-CERT Advisories" event message.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated string.

◆ new_nvts_list()

static gchar* new_nvts_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for New NVTs event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated list.

◆ new_oval_defs_list()

static gchar* new_oval_defs_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int  example,
int *  count_return 
)
static

Create list for "New OVAL Definitions" event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
[in]exampleWhether the message is an example only.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated list.

◆ new_resources_hashtable()

static GHashTable* new_resources_hashtable ( )
static

Create a new GHashTable for containing resource rowids.

Returns
The newly allocated GHashTable

◆ new_secinfo_list()

static gchar * new_secinfo_list ( event_t  event,
const void *  event_data,
alert_t  alert,
int *  count_return 
)
static

Create message for New NVTs event.

Parameters
[in]eventEvent.
[in]event_dataEvent data.
[in]alertAlert.
[out]count_returnNULL, or address for row count.
Returns
Freshly allocated list.

◆ new_secinfo_message()

static gchar * new_secinfo_message ( event_t  event,
const void *  event_data,
alert_t  alert 
)
static

Create message for New NVTs event.

Parameters
[in]eventEvent.
[in]event_dataEvent type specific details.
[in]alertAlert.
Returns
Freshly allocated message.

◆ next_report()

gboolean next_report ( iterator_t iterator,
report_t *  report 
)

Read the next report from an iterator.

Parameters
[in]iteratorTask iterator.
[out]reportReport.
Returns
TRUE if there was a next task, else FALSE.

◆ note_count()

int note_count ( const get_data_t get,
nvt_t  nvt,
result_t  result,
task_t  task 
)

Count number of notes.

Parameters
[in]getGET params.
[in]resultResult to limit notes to, 0 for all.
[in]taskIf result is > 0, task whose notes on result to include, otherwise task to limit notes to. 0 for all tasks.
[in]nvtNVT to limit notes to, 0 for all.
Returns
Total number of notes in filtered set.

◆ note_iterator_active()

int note_iterator_active ( iterator_t iterator)

Get the active status from an note iterator.

Parameters
[in]iteratorIterator.
Returns
1 if active, else 0.

◆ note_iterator_end_time()

time_t note_iterator_end_time ( iterator_t iterator)

Get the end time from an note iterator.

Parameters
[in]iteratorIterator.
Returns
Time until which note applies. 0 for always. 1 means the note has been explicitly turned off.

◆ note_iterator_nvt_type()

const char* note_iterator_nvt_type ( iterator_t iterator)

Get the NVT type from a note iterator.

Parameters
[in]iteratorIterator.
Returns
NVT type, or NULL. Static string.

◆ note_iterator_result()

result_t note_iterator_result ( iterator_t iterator)

Get the result from a note iterator.

Parameters
[in]iteratorIterator.
Returns
The result associated with the note, or 0 on error.

◆ note_iterator_task()

task_t note_iterator_task ( iterator_t iterator)

Get the task from a note iterator.

Parameters
[in]iteratorIterator.
Returns
The task associated with the note, or 0 on error.

◆ note_iterator_threat()

const char* note_iterator_threat ( iterator_t iterator)

Get the threat from a note iterator.

Parameters
[in]iteratorIterator.
Returns
Threat.

◆ note_uuid()

int note_uuid ( note_t  note,
char **  id 
)

Return the UUID of a note.

Parameters
[in]noteNote.
[out]idPointer to a newly allocated string.
Returns
0.

◆ nvt_exists()

static gboolean nvt_exists ( const char *  nvt)
static

Check if an NVT exists.

Parameters
[in]nvtNVT OID.
Returns
1 if exists, else 0.

◆ nvt_preference_count()

int nvt_preference_count ( const char *  name)

Get the number preferences available for an NVT.

Parameters
[in]nameName of NVT.
Returns
Number of possible preferences on NVT.

◆ nvt_preference_iterator_config_value()

char* nvt_preference_iterator_config_value ( iterator_t iterator,
config_t  config 
)

Get the config value from an NVT preference iterator.

Parameters
[in]iteratorIterator.
[in]configConfig.
Returns
Freshly allocated config value.

◆ nvt_preference_iterator_nvt()

char* nvt_preference_iterator_nvt ( iterator_t iterator)

Get the NVT from an NVT preference iterator.

Parameters
[in]iteratorIterator.
Returns
NVT.

◆ nvt_preference_iterator_real_name()

char* nvt_preference_iterator_real_name ( iterator_t iterator)

Get the real name from an NVT preference iterator.

Parameters
[in]iteratorIterator.
Returns
Real name.

◆ nvt_preference_iterator_type()

char* nvt_preference_iterator_type ( iterator_t iterator)

Get the type from an NVT preference iterator.

Parameters
[in]iteratorIterator.
Returns
Type.

◆ nvt_selector_add()

static void nvt_selector_add ( const char *  quoted_selector,
const char *  quoted_family_or_nvt,
const char *  quoted_family,
int  exclude 
)
static

Add a selector to an NVT selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]quoted_family_or_nvtSQL-quoted family or NVT name.
[in]quoted_familySQL-quoted family name (NULL for families).
[in]exclude1 exclude selector, 0 include selector.
Returns
0 success, -1 error.

◆ nvt_selector_families_growing()

static int nvt_selector_families_growing ( const char *  selector)
static

Get the family growth status of an NVT selector.

Parameters
[in]selectorNVT selector.
Returns
1 growing, 0 static.

◆ nvt_selector_family_count()

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.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]families_growing1 if families are growing, else 0.
Returns
The number of families selected by an NVT selector.

◆ nvt_selector_family_growing()

int nvt_selector_family_growing ( const char *  selector,
const char *  family,
int  all 
)

Get whether an NVT selector family is growing.

Parameters
[in]selectorNVT selector.
[in]familyFamily name.
[in]allTrue if selector is an "all" selector, else 0.
Returns
1 growing, 0 static.

◆ nvt_selector_has()

static int nvt_selector_has ( const char *  quoted_selector,
const char *  family_or_nvt,
int  type,
int  exclude 
)
static

Check whether an NVT selector has a particular selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]family_or_nvtSQL-quoted UUID of NVT, or family name.
[in]typeSelector type.
[in]exclude1 exclude, 0 include.
Returns
1 if contains include/exclude, else 0.

◆ nvt_selector_iterator_include()

int nvt_selector_iterator_include ( iterator_t iterator)

Get whether the selector rule is an include rule.

Parameters
[in]iteratorIterator.
Returns
-1 if iteration is complete, 1 if include, else 0.

◆ nvt_selector_iterator_type()

int nvt_selector_iterator_type ( iterator_t iterator)

Get the type from an NVT selector.

Parameters
[in]iteratorIterator.
Returns
-1 if iteration is complete, 1 if include, else 0.

◆ nvt_selector_nvt_count()

int nvt_selector_nvt_count ( const char *  selector,
const char *  family,
int  growing 
)

Get the number of NVTs selected by an NVT selector.

Parameters
[in]selectorNVT selector.
[in]familyFamily name. NULL for all.
[in]growingTrue if the given family is growing, else 0. If
familyis NULL, true if the the families are growing, else 0.
Returns
Number of NVTs selected in one or all families.

◆ nvt_selector_nvts_growing_2()

static int nvt_selector_nvts_growing_2 ( const char *  quoted_selector,
int  families_growing 
)
static

Get the NVT growth status of an NVT selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]families_growing1 if families are growing, else 0.
Returns
1 growing, 0 static.

◆ nvt_selector_remove()

static void nvt_selector_remove ( const char *  quoted_selector,
const char *  quoted_family,
int  type 
)
static

Remove all selectors of a certain family from an NVT selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]quoted_familySQL-quoted family name.
[in]typeSelector type to remove.
Returns
0 success, -1 error.

◆ nvt_selector_remove_selector()

static void nvt_selector_remove_selector ( const char *  quoted_selector,
const char *  family_or_nvt,
int  type 
)
static

Remove all selectors of a certain type from an NVT selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]family_or_nvtSQL-quoted family name or NVT UUID.
[in]typeSelector type to remove.
Returns
0 success, -1 error.

◆ nvt_selector_set_family()

static void nvt_selector_set_family ( const char *  quoted_selector,
const char *  family_or_nvt,
int  type,
const char *  family 
)
static

Set the family of an NVT selector.

Parameters
[in]quoted_selectorSQL-quoted selector name.
[in]family_or_nvtFamily name or NVT OID of selector.
[in]typeSelector type to remove.
[in]familyNew family.
Returns
0 success, -1 error.

◆ nvt_severity()

static char* nvt_severity ( const char *  nvt_id,
const char *  type 
)
static

Get a severity string from an nvt and result type.

Parameters
[in]nvt_idNVT oid.
[in]typeResult type.
Returns
A severity string, NULL if unknown type or no nvt id for Alarm type.

◆ nvts_check_time()

static int nvts_check_time ( )
static

Get last time NVT alerts were checked.

Returns
Last check time.

◆ osp_get_details_from_iterator()

int osp_get_details_from_iterator ( iterator_t iterator,
char **  desc,
GSList **  params 
)

Get an OSP Scanner's get_scanner_details info.

Parameters
[in]iteratorScanner object iterator.
[out]descScanner description.
[out]paramsScanner parameters.
Returns
0 success, 1 for failure.

◆ osp_get_version_from_iterator()

int osp_get_version_from_iterator ( iterator_t iterator,
char **  s_name,
char **  s_ver,
char **  d_name,
char **  d_ver,
char **  p_name,
char **  p_ver 
)

Get an OSP Scanner's get_version info.

Parameters
[in]iteratorScanner object iterator.
[out]s_nameScanner name.
[out]s_verScanner version.
[out]d_nameDaemon name.
[out]d_verDaemon version.
[out]p_nameProtocol name.
[out]p_verProtocol version.
Returns
0 success, 1 for failure.

◆ osp_scanner_connect()

osp_connection_t* osp_scanner_connect ( scanner_t  scanner)

Create a new connection to an OSP scanner.

Parameters
[in]scannerScanner.
Returns
New connection if success, NULL otherwise.

◆ override_count()

int override_count ( const get_data_t get,
nvt_t  nvt,
result_t  result,
task_t  task 
)

Count number of overrides.

Parameters
[in]getGET params.
[in]resultResult to limit overrides to, 0 for all.
[in]taskIf result is > 0, task whose overrides on result to include, otherwise task to limit overrides to. 0 for all tasks.
[in]nvtNVT to limit overrides to, 0 for all.
Returns
Total number of overrides in filtered set.

◆ override_iterator_active()

int override_iterator_active ( iterator_t iterator)

Get the active status from an override iterator.

Parameters
[in]iteratorIterator.
Returns
1 if active, else 0.

◆ override_iterator_end_time()

time_t override_iterator_end_time ( iterator_t iterator)

Get the end time from an override iterator.

Parameters
[in]iteratorIterator.
Returns
Time until which override applies. 0 for always. 1 means the override has been explicitly turned off.

◆ override_iterator_new_threat()

const char* override_iterator_new_threat ( iterator_t iterator)

Get the threat from an override iterator.

Parameters
[in]iteratorIterator.
Returns
Threat.

◆ override_iterator_nvt_type()

const char* override_iterator_nvt_type ( iterator_t iterator)

Get the NVT type from a override iterator.

Parameters
[in]iteratorIterator.
Returns
NVT type, or NULL. Static string.

◆ override_iterator_result()

result_t override_iterator_result ( iterator_t iterator)

Get the result from a override iterator.

Parameters
[in]iteratorIterator.
Returns
The result associated with the override, or 0 on error.

◆ override_iterator_task()

task_t override_iterator_task ( iterator_t iterator)

Get the task from a override iterator.

Parameters
[in]iteratorIterator.
Returns
The task associated with the override, or 0 on error.

◆ override_iterator_threat()

const char* override_iterator_threat ( iterator_t iterator)

Get the threat from a override iterator.

Parameters
[in]iteratorIterator.
Returns
Threat.

◆ override_uuid()

int override_uuid ( override_t  override,
char **  id 
)

Return the UUID of an override.

Parameters
[in]overrideOverride.
[out]idPointer to a newly allocated string.
Returns
0.

◆ parse_column_relation()

static keyword_relation_t parse_column_relation ( const char  relation)
static

Parse a filter column relation.

Parameters
[in]relationFilter relation.
Returns
keyword relation

◆ parse_iso_time()

int parse_iso_time ( const char *  text_time)

Convert an ISO time into seconds since epoch.

For backward compatibility, if the conversion fails try parse in ctime format.

Parameters
[in]text_timeTime as text in ISO format: 2011-11-03T09:23:28+02:00.
Returns
Time since epoch. 0 on error.

◆ parse_keyword()

static void parse_keyword ( keyword_t keyword)
static

Parse a filter keyword.

Parameters
[in]keywordFilter keyword.

◆ parse_osp_report()

void parse_osp_report ( task_t  task,
report_t  report,
const char *  report_xml 
)

Parse an OSP report.

Parameters
[in]taskTask.
[in]reportReport.
[in]report_xmlReport XML.

◆ port_name_formatted()

gchar* port_name_formatted ( const char *  field)

Returns formatted port number, protocol and iana name from.

field in "number/proto" form.

Parameters
fieldNumber/Protocol string.
Returns
Formatted port name string, NULL if error.

◆ predefined_report_format_dir()

gchar* predefined_report_format_dir ( const gchar *  uuid)

Get the directory of a report format.

Parameters
[in]uuidReport format UUID. NULL to get parent dir.
Returns
Freshly allocated dir name.

◆ print_host_port()

static gboolean print_host_port ( gpointer  key,
gpointer  value,
gpointer  data 
)
static

Print delta host ports.

Parameters
[in]keyPort.
[in]valueThreat.
[in]dataHost and stream.
Returns
Always FALSE.

◆ print_host_ports()

static gboolean print_host_ports ( gpointer  key,
gpointer  value,
gpointer  stream 
)
static

Print delta ports.

Parameters
[in]keyHost.
[in]valuePort tree.
[in]streamStream.
Returns
Always FALSE.

◆ print_host_ports_by_severity()

static gboolean print_host_ports_by_severity ( gpointer  key,
gpointer  value,
gpointer  stream,
int  ascending 
)
static

Print delta ports, ordering by severity.

Parameters
[in]keyHost.
[in]valuePort tree.
[in]streamStream.
[in]ascendingAscending or descending.
Returns
Always FALSE.

◆ print_host_ports_by_severity_asc()

static gboolean print_host_ports_by_severity_asc ( gpointer  key,
gpointer  value,
gpointer  stream 
)
static

Print delta ports, ordering by severity ascending.

Parameters
[in]keyHost.
[in]valuePort tree.
[in]streamStream.
Returns
Always FALSE.

◆ print_host_ports_by_severity_desc()

static gboolean print_host_ports_by_severity_desc ( gpointer  key,
gpointer  value,
gpointer  stream 
)
static

Print delta ports, ordering by severity descending.

Parameters
[in]keyHost.
[in]valuePort tree.
[in]streamStream.
Returns
Always FALSE.

◆ print_host_ports_desc()

static gboolean print_host_ports_desc ( gpointer  key,
gpointer  value,
gpointer  stream 
)
static

Print delta ports, in descending order.

Parameters
[in]keyHost.
[in]valuePort tree.
[in]streamStream.
Returns
Always FALSE.

◆ print_report_assets_xml()

static int print_report_assets_xml ( FILE *  out,
const char *  host,
int  first_result,
int  max_results,
gchar *  levels,
gchar *  search_phrase,
int  pos,
const get_data_t get,
int  apply_overrides,
int  autofp 
)
static

Print the XML for a report of type assets.

Parameters
[in]outFile stream to write to.
[in]hostHost or NULL.
[in]first_resultThe result to start from. The results are 0 indexed.
[in]max_resultsThe maximum number of results returned.
[in]levelsString describing threat levels (message types)
[in]search_phrasePhrase that results must include.
[in]posPosition of report from end.
[in]getGET command data.
[in]apply_overridesWhether to apply overrides.
[in]autofpWhether to apply the auto FP filter.
Returns
0 on success, -1 error.

◆ print_report_delta_xml()

static int print_report_delta_xml ( FILE *  out,
iterator_t results,
iterator_t delta_results,
const char *  delta_states,
int  first_result,
int  max_results,
task_t  task,
int  notes,
int  notes_details,
int  overrides,
int  overrides_details,
int  sort_order,
const char *  sort_field,
int  result_hosts_only,
int *  orig_filtered_result_count,
int *  filtered_result_count,
int *  orig_f_debugs,
int *  f_debugs,
int *  orig_f_holes,
int *  f_holes,
int *  orig_f_infos,
int *  f_infos,
int *  orig_f_logs,
int *  f_logs,
int *  orig_f_warnings,
int *  f_warnings,
int *  orig_f_false_positives,
int *  f_false_positives,
array_t *  result_hosts 
)
static

Print delta results for print_report_xml.

Parameters
[in]outFile stream to write to.
[in]resultsReport result iterator.
[in]delta_resultsDelta report result iterator.
[in]delta_statesString describing delta states to include in count (for example, "sngc" Same, New, Gone and Changed). All levels if NULL.
[in]first_resultFirst result.
[in]max_resultsMax results.
[in]taskThe task.
[in]notesWhether to include notes.
[in]notes_detailsWhether to include note details.
[in]overridesWhether to include overrides.
[in]overrides_detailsWhether to include override details.
[in]sort_orderSort order.
[in]sort_fieldSort field.
[in]result_hosts_onlyWhether to only include hosts with results.
[in]orig_filtered_result_countResult count.
[in]filtered_result_countResult count.
[in]orig_f_debugsResult count.
[in]f_debugsResult count.
[in]orig_f_holesResult count.
[in]f_holesResult count.
[in]orig_f_infosResult count.
[in]f_infosResult count.
[in]orig_f_logsResult count.
[in]f_logsResult count.
[in]orig_f_warningsResult count.
[in]f_warningsResult count.
[in]orig_f_false_positivesResult count.
[in]f_false_positivesResult count.
[in]result_hostsResult hosts.
Returns
0 on success, -1 error.

◆ print_report_errors_xml()

static int print_report_errors_xml ( report_t  report,
FILE *  stream 
)
static

Print the XML for a report's error messages to a file stream.

Parameters
[in]reportThe report.
[in]streamFile stream to write to.
Returns
0 on success, -1 error.

◆ print_report_host_detail()

static int print_report_host_detail ( FILE *  stream,
iterator_t details 
)
static

Write report host detail to file stream.

On error close stream.

Parameters
[in]streamStream to write to.
[in]detailsReport host details iterator.
Returns
0 success, -1 error.

◆ print_report_host_details_xml()

static int print_report_host_details_xml ( report_host_t  report_host,
FILE *  stream 
)
static

Print the XML for a report's host details to a file stream.

Parameters
[in]report_hostThe report host.
[in]streamFile stream to write to.
Returns
0 on success, -1 error.

◆ print_report_port_xml()

static int print_report_port_xml ( report_t  report,
FILE *  out,
const get_data_t get,
int  first_result,
int  max_results,
int  sort_order,
const char *  sort_field,
GHashTable *  host_ports 
)
static

Print the XML for a report port summary to a file.

Parameters
[in]reportThe report.
[in]outFile stream.
[in]getResult get data.
[in]first_resultThe result to start from. The results are 0 indexed.
[in]max_resultsThe maximum number of results returned.
[in]sort_orderWhether to sort ascending or descending.
[in]sort_fieldField to sort on.
[out]host_portsHash table for counting ports per host.
Returns
0 on success, -1 error.
Todo:
Sort by ROWID if was requested.

◆ print_report_xml_end()

static int print_report_xml_end ( gchar *  xml_start,
gchar *  xml_full,
report_format_t  report_format 
)
static

Completes a report by adding report format info.

Parameters
[in]xml_startPath of file containing start of report.
[in]xml_fullPath to file to print full report to.
[in]report_formatFormat of report that will be created from XML.
Returns
0 success, -1 error.

◆ print_report_xml_start()

static int print_report_xml_start ( report_t  report,
report_t  delta,
task_t  task,
gchar *  xml_start,
const get_data_t get,
const char *  type,
int  notes_details,
int  overrides_details,
int  result_tags,
const char *  host,
int  pos,
const char *  host_search_phrase,
const char *  host_levels,
int  host_first_result,
int  host_max_results,
int  ignore_pagination,
gchar **  filter_term_return,
gchar **  zone_return,
gchar **  host_summary 
)
static

Print the main XML content for a report to a file.

Parameters
[in]reportThe report.
[in]deltaReport to compare with the report.
[in]taskTask associated with report.
[in]xml_startFile name.
[in]getGET command data.
[in]typeType of report, NULL, "scan" or "assets".
[in]notes_detailsIf notes, Whether to include details.
[in]overrides_detailsIf overrides, Whether to include details.
[in]result_tagsWhether to include tags in results.
[in]hostHost or NULL, when type "assets".
[in]posPosition of report from end, when type "assets".
[in]host_search_phrasePhrase that results must include. All results if NULL or "". For hosts.
[in]host_levelsString describing threat levels (message types) to include in count (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[in]host_first_resultThe host result to start from. The results are 0 indexed.
[in]host_max_resultsThe host maximum number of results returned.
[in]ignore_paginationWhether to ignore pagination data.
[out]filter_term_returnFilter term used in report.
[out]zone_returnActual timezone used in report.
[out]host_summarySummary of results per host.
Returns
0 on success, -1 error, 2 failed to find filter (before any printing).
Todo:
Leaks on error in PRINT and PRINT_XML. The process normally exits then anyway.
Todo:
The f_debugs, etc. vars are setup to give the page count.

◆ prognosis_iterator_cvss_double()

double prognosis_iterator_cvss_double ( iterator_t iterator)

Get the CVSS from a result iterator as a double.

Parameters
[in]iteratorIterator.
Returns
CVSS.

◆ prognosis_order_by()

static GString* prognosis_order_by ( const char *  sort_field,
int  ascending 
)
static

Return SQL ORDER BY for sorting results in a prognostic report.

Parameters
[in]sort_fieldName of the field to sort by.
[in]ascendingSort in ascending order if true, descending if false.
Returns
ORDER BY clause.

◆ prognosis_where_levels()

static const char* prognosis_where_levels ( const char *  levels)
static

Return SQL WHERE for restricting a SELECT to levels.

Parameters
[in]levelsString describing threat levels (message types) to include in report (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
Returns
WHERE clause for levels if one is required, else NULL.

◆ prognosis_where_search_phrase()

static GString* prognosis_where_search_phrase ( const char *  search_phrase)
static

Return SQL WHERE for restricting a SELECT to a search phrase.

Parameters
[in]search_phrasePhrase that results must include. All results if NULL or "".
Returns
WHERE clause for search phrase if one is required, else NULL.

◆ qod_from_type()

int qod_from_type ( const char *  qod_type)

Get QoD percentage for a qod_type string.

Parameters
[in]qod_typeThe QoD type string.
Returns
A QoD percentage value, QOD_DEFAULT if string is NULL or unknown.

◆ radius_auth_enabled()

static int radius_auth_enabled ( )
static

Check whether RADIUS is enabled.

Returns
0 no, else yes.

◆ reinit_manage_process()

void reinit_manage_process ( )

Reinitialize the manage library for a process.

This is mandatory after a fork, to not carry open databases around (refer to database documentation).

◆ report_active()

static int report_active ( report_t  report)
static

Check whether the scan of a report is active.

Parameters
[in]reportReport.
Returns
1 if active, else 0.

◆ report_add_result()

void report_add_result ( report_t  report,
result_t  result 
)

Add a result to a report.

Parameters
[in]reportThe report.
[in]resultThe result.

◆ report_add_result_for_buffer()

static void report_add_result_for_buffer ( report_t  report,
result_t  result 
)
static

Add a result to a report.

Parameters
[in]reportThe report.
[in]resultThe result.

◆ report_app_count()

static int report_app_count ( report_t  report)
static

Count a report's total number of detected Apps.

Parameters
[in]reportReport.
Returns
App count.

◆ report_cache_counts()

static void report_cache_counts ( report_t  report,
int  clear_original,
int  clear_overridden,
const char *  users_where 
)
static

Cache report counts and clear existing caches if requested.

Parameters
[in]reportReport to cache counts of.
[in]clear_originalWhether to clear existing cache for original severity.
[in]clear_overriddenWhether to clear existing cache for overridden severity.
[in]users_whereOptional SQL clause to limit users.

◆ report_clear_count_cache()

static void report_clear_count_cache ( report_t  report,
int  clear_original,
int  clear_overridden,
const char *  users_where 
)
static

Clear report counts .

Parameters
[in]reportReport.
[in]clear_originalWhether to clear existing cache for original severity.
[in]clear_overriddenWhether to clear existing cache for overridden severity.
[in]users_whereOptional SQL clause to limit users.

◆ report_closed_cve_count()

static int report_closed_cve_count ( report_t  report)
static

Count a report's total number of closed cves.

Parameters
[in]reportReport.
Returns
Closed CVE count.

◆ report_content_for_alert()

static int report_content_for_alert ( alert_t  alert,
report_t  report,
task_t  task,
const get_data_t get,
const char *  report_format_data_name,
const char *  report_format_lookup,
const char *  fallback_format_id,
int  notes_details,
int  overrides_details,
gchar **  content,
gsize *  content_length,
gchar **  extension,
gchar **  content_type,
gchar **  term,
gchar **  report_zone,
gchar **  host_summary,
report_format_t *  used_report_format,
filter_t *  filter_return 
)
static

Generate report content for alert.

Parameters
[in]alertThe alert the report is generated for.
[in]reportReport or NULL to get last report of task.
[in]taskTask the report belongs to.
[in]getGET data for the report.
[in]report_format_data_nameName of alert data with report format, or NULL if not configurable.
[in]report_format_lookupName of report format to lookup if lookup by name, or NULL if not required. Used if report_format_data_name is NULL or fails.
[in]fallback_format_idUUID of fallback report format. Used if both report_format_data_name and report_format_lookup are NULL or fail.
[in]notes_detailsWhether to include details of notes in report.
[in]overrides_detailsWhether to include override details in report.
[out]contentReport content location.
[out]content_lengthLength of report content.
[out]extensionFile extension of report format.
[out]content_typeContent type of report format.
[out]termFilter term.
[out]report_zoneActual timezone used in report.
[out]host_summarySummary of results per host.
[out]used_report_formatReport format used.
[out]filter_returnFilter used.
Returns
0 success, -1 error, -2 failed to find report format, -3 failed to find filter.

◆ report_count()

int report_count ( const get_data_t get)

Count number of reports.

Parameters
[in]getGET params.
Returns
Total number of reports in filtered set.

◆ report_counts()

int report_counts ( const char *  report_id,
int *  debugs,
int *  holes,
int *  infos,
int *  logs,
int *  warnings,
int *  false_positives,
double *  severity,
int  override,
int  autofp,
int  min_qod 
)

Get the message counts for a report given the UUID.

Todo:
Lacks permission check. Caller contexts all have permission checks before calling this so it's safe. Rework callers to use report_counts_id instead.
Parameters
[in]report_idID of report.
[out]debugsNumber of debug messages.
[out]holesNumber of hole messages.
[out]infosNumber of info messages.
[out]logsNumber of log messages.
[out]warningsNumber of warning messages.
[out]false_positivesNumber of false positives.
[out]severityMaximum severity score.
[in]overrideWhether to override the threat.
[in]autofpWhether to apply the auto FP filter.
[in]min_qodMin QOD.
Returns
0 on success, -1 on error.

◆ report_counts_build_iterator_min_qod()

static int report_counts_build_iterator_min_qod ( iterator_t iterator)
static

Get the min_qod from a report_counts build iterator.

Parameters
[in]iteratorIterator.
Returns
The min_qod.

◆ report_counts_build_iterator_override()

static int report_counts_build_iterator_override ( iterator_t iterator)
static

Get the override flag from a report_counts build iterator.

Parameters
[in]iteratorIterator.
Returns
Whether the report counts are using overrides.

◆ report_counts_build_iterator_user()

static user_t report_counts_build_iterator_user ( iterator_t iterator)
static

Get the user from a report_counts build iterator.

Parameters
[in]iteratorIterator.
Returns
The min_qod.

◆ report_counts_cache_exists()

static int report_counts_cache_exists ( report_t  report,
int  override,
int  min_qod 
)
static

Test if a counts cache exists for a report and the current user.

Parameters
[in]reportThe report to check.
[in]overrideWhether to check for overridden results.
[in]min_qodMinimum QoD of results to count.
Returns
1 if cache exists, 0 otherwise.

◆ report_counts_from_cache()

static void report_counts_from_cache ( report_t  report,
int  override,
int  min_qod,
severity_data_t data 
)
static

Get cached result counts for a report and the current user.

Parameters
[in]reportThe report to get counts from.
[in]overrideWhether to get overridden results.
[in]min_qodMinimum QoD of results to count.
[out]dataThe severity_data_t to save counts in.

◆ report_counts_id()

int report_counts_id ( report_t  report,
int *  debugs,
int *  holes,
int *  infos,
int *  logs,
int *  warnings,
int *  false_positives,
double *  severity,
const get_data_t get,
const char *  host 
)

Get only the filtered message counts for a report.

Parameters
[in]reportReport.
[out]debugsNumber of debug messages.
[out]holesNumber of hole messages.
[out]infosNumber of info messages.
[out]logsNumber of log messages.
[out]warningsNumber of warning messages.
[out]false_positivesNumber of false positive messages.
[out]severityMaximum severity score.
[in]getGet data.
[in]hostHost to which to limit the count. NULL to allow all.
Returns
0 on success, -1 on error.

◆ report_counts_id_full()

static int report_counts_id_full ( report_t  report,
int *  debugs,
int *  holes,
int *  infos,
int *  logs,
int *  warnings,
int *  false_positives,
double *  severity,
const get_data_t get,
const char *  host,
int *  filtered_debugs,
int *  filtered_holes,
int *  filtered_infos,
int *  filtered_logs,
int *  filtered_warnings,
int *  filtered_false_positives,
double *  filtered_severity 
)
static

Get the message counts for a report.

Parameters
[in]reportReport.
[out]debugsNumber of debug messages.
[out]holesNumber of hole messages.
[out]infosNumber of info messages.
[out]logsNumber of log messages.
[out]warningsNumber of warning messages.
[out]false_positivesNumber of false positive messages.
[out]severityMaximum severity of the report.
[in]getGet data.
[in]hostHost to which to limit the count.
[out]filtered_debugsNumber of debug messages after filtering.
[out]filtered_holesNumber of hole messages after filtering.
[out]filtered_infosNumber of info messages after filtering.
[out]filtered_logsNumber of log messages after filtering.
[out]filtered_warningsNumber of warning messages after filtering.
[out]filtered_false_positivesNumber of false positive messages after filtering.
[out]filtered_severityMaximum severity after filtering.
Returns
0 on success, -1 on error.

◆ report_error_count()

static int report_error_count ( report_t  report)
static

Count a report's total number of error messages.

Parameters
[in]reportReport.
Returns
Error Messages count.

◆ report_errors_iterator_result()

static result_t report_errors_iterator_result ( iterator_t iterator)
static

Get the result from a report error messages iterator.

Parameters
[in]iteratorIterator.
Returns
Result.

◆ report_format_active()

int report_format_active ( report_format_t  report_format)

Return whether a report format is active.

Parameters
[in]report_formatReport format.
Returns
-1 on error, 1 if active, else 0.

◆ report_format_content_type()

char* report_format_content_type ( report_format_t  report_format)

Return the content type of a report format.

Parameters
[in]report_formatReport format.
Returns
Newly allocated content type.

◆ report_format_extension()

char* report_format_extension ( report_format_t  report_format)

Return the extension of a report format.

Parameters
[in]report_formatReport format.
Returns
Newly allocated extension.

◆ report_format_in_use()

int report_format_in_use ( report_format_t  report_format)

Return whether a report format is referenced by an alert.

Parameters
[in]report_formatReport Format.
Returns
1 if in use, else 0.

◆ report_format_name()

char* report_format_name ( report_format_t  report_format)

Return the name of a report format.

Parameters
[in]report_formatReport format.
Returns
Newly allocated name.

◆ report_format_owner_uuid()

char* report_format_owner_uuid ( report_format_t  report_format)

Return the UUID of the owner of a report format.

Parameters
[in]report_formatReport format.
Returns
Newly allocated owner UUID if there is an owner, else NULL.

◆ report_format_param_type()

static report_format_param_type_t report_format_param_type ( report_format_t  report_format,
const char *  name 
)
static

Return the type max of a report format param.

Parameters
[in]report_formatReport format.
[in]nameName of param.
Returns
Param type.

◆ report_format_param_type_max()

static long long int report_format_param_type_max ( report_format_t  report_format,
const char *  name 
)
static

Return the type max of a report format param.

Parameters
[in]report_formatReport format.
[in]nameName of param.
Returns
Max.

◆ report_format_param_type_min()

static long long int report_format_param_type_min ( report_format_t  report_format,
const char *  name 
)
static

Return the type min of a report format param.

Parameters
[in]report_formatReport format.
[in]nameName of param.
Returns
Min.

◆ report_format_predefined()

int report_format_predefined ( report_format_t  report_format)

Return whether a report format is predefined.

Parameters
[in]report_formatReport format.
Returns
1 if predefined, else 0.

◆ report_format_trash_dir()

static gchar* report_format_trash_dir ( const gchar *  report_format_id)
static

Get trash directory of a report format.

Parameters
[in]report_format_idUUID of report format. NULL for the base dir that holds the report format trash.
Returns
Freshly allocated trash dir.

◆ report_format_uuid()

char* report_format_uuid ( report_format_t  report_format)

Return the UUID of a report format.

Parameters
[in]report_formatReport format.
Returns
Newly allocated UUID.

◆ report_format_writable()

int report_format_writable ( report_format_t  report_format)

Return whether a report format is writable.

Parameters
[in]report_formatReport Format.
Returns
1 if writable, else 0.

◆ report_host_count()

int report_host_count ( report_t  report)

Count a report's total number of hosts.

Parameters
[in]reportReport.
Returns
Host count.

◆ report_host_ip()

gchar* report_host_ip ( const char *  host)

Get the IP of a host, using the 'hostname' report host details.

The most recent host detail takes preference.

Parameters
[in]hostHost name or IP.
Returns
Newly allocated UUID if available, else NULL.

◆ report_host_noticeable()

int report_host_noticeable ( report_t  report,
const gchar *  host 
)

Check if a report host is alive and has at least one result.

Parameters
[in]reportReport.
[in]hostHost name or IP.
Returns
0 if dead, else alive.

◆ report_iterator_opts_table()

static gchar* report_iterator_opts_table ( int  override,
int  min_qod 
)
static

Generate the extra_tables string for a report iterator.

Parameters
[in]overrideWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
Returns
Newly allocated string with the extra_tables clause.

◆ report_os_count()

static int report_os_count ( report_t  report)
static

Count a report's total number of detected Operating Systems.

Parameters
[in]reportReport.
Returns
OS count.

◆ report_port_count()

static int report_port_count ( report_t  report)
static

Count a report's total number of tcp/ip ports.

Ignores port entries in "general/..." form.

Parameters
[in]reportReport.
Returns
Ports count.

◆ report_progress()

int report_progress ( report_t  report,
task_t  task,
gchar **  hosts_xml 
)

Calculate the progress of a report.

Parameters
[in]reportReport.
[in]taskReport's task.
[out]hosts_xmlReturn for hosts XML if required, else NULL.
Returns
Progress.

◆ report_progress_active()

static int report_progress_active ( report_t  report,
long  maximum_hosts,
gchar **  hosts_xml 
)
static

Get progress for active report.

Parameters
[in]reportReport.
[in]maximum_hostsMaximum number of hosts in target.
[out]hosts_xmlReturn for hosts XML if required, else NULL.
Returns
Progress XML.

◆ report_result_host_count()

int report_result_host_count ( report_t  report,
int  min_qod 
)

Count a report's total number of hosts with results.

Parameters
[in]reportReport.
[in]min_qodMinimum QoD of results to count.
Returns
The number of hosts with results

◆ report_scan_run_status()

static int report_scan_run_status ( report_t  report,
task_status_t *  status 
)
static

Return the run status of the scan associated with a report.

Parameters
[in]reportReport.
[out]statusScan run status.
Returns
0 on success, -1 on error.

◆ report_scheduled()

static int report_scheduled ( report_t  report)
static

Get a report's scheduled flag.

Parameters
[in]reportReport.
Returns
Scheduled flag.

◆ report_set_slave_host()

void report_set_slave_host ( report_t  report,
const gchar *  host 
)

Set the host of the slave of a report.

Parameters
[in]reportReport.
[in]hostHost.

◆ report_set_slave_name()

void report_set_slave_name ( report_t  report,
const gchar *  name 
)

Set the name of the slave on a report.

Parameters
[in]reportReport.
[in]nameName.

◆ report_set_slave_port()

void report_set_slave_port ( report_t  report,
int  port 
)

Set the port of the slave of a report.

Parameters
[in]reportReport.
[in]portPort.

◆ report_set_slave_uuid()

void report_set_slave_uuid ( report_t  report,
const gchar *  uuid 
)

Set the UUID of the slave on a report.

Parameters
[in]reportReport.
[in]uuidUUID.

◆ report_set_source_iface()

void report_set_source_iface ( report_t  report,
const gchar *  iface 
)

Set the source interface of a report.

Parameters
[in]reportReport.
[in]ifaceSource interface.

◆ report_severity()

double report_severity ( report_t  report,
int  overrides,
int  min_qod 
)

Get the maximum severity of a report.

Parameters
[in]reportReport.
[in]overridesWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
Returns
Severity score of the report.

◆ report_severity_data()

static void report_severity_data ( report_t  report,
const char *  host,
const get_data_t get,
severity_data_t severity_data,
severity_data_t filtered_severity_data 
)
static

Get the result severity counts for a report.

Parameters
[in]reportReport.
[in]hostHost to which to limit the count. NULL to allow all.
[in]getReport "get" data to retrieve filter info from.
[out]severity_dataThe severity data struct to store counts in.
[out]filtered_severity_dataThe severity data struct to store counts in.

◆ report_slave_host()

static char* report_slave_host ( report_t  report)
static

Return the host of a report's slave.

Parameters
[in]reportReport.
Returns
Slave UUID.

◆ report_slave_name()

static char* report_slave_name ( report_t  report)
static

Return the name of a report's slave.

Parameters
[in]reportReport.
Returns
Slave name.

◆ report_slave_port()

static char* report_slave_port ( report_t  report)
static

Return the port of a report's slave.

Parameters
[in]reportReport.
Returns
Slave port.

◆ report_slave_port_int()

static int report_slave_port_int ( report_t  report)
static

Return the port of a report's slave.

Parameters
[in]reportReport.
Returns
Slave port.

◆ report_slave_progress()

static int report_slave_progress ( report_t  report)
static

Return the slave progress of a report.

Parameters
[in]reportReport.
Returns
Number of reports.

◆ report_slave_task_uuid()

char* report_slave_task_uuid ( report_t  report)

Return the UUID of the task on the slave.

Parameters
[in]reportThe report.
Returns
UUID of the slave task if any, else NULL.

◆ report_slave_uuid()

static char* report_slave_uuid ( report_t  report)
static

Return the UUID of a report's slave.

Parameters
[in]reportReport.
Returns
Slave UUID.

◆ report_source_iface()

static char* report_source_iface ( report_t  report)
static

Return the source interface of a report.

Parameters
[in]reportReport.
Returns
Source interface.

◆ report_ssl_cert_count()

static int report_ssl_cert_count ( report_t  report)
static

Count a report's total number of found SSL Certificates.

Parameters
[in]reportReport.
Returns
SSL Certificates count.

◆ report_task()

gboolean report_task ( report_t  report,
task_t *  task 
)

Return the task of a report.

Parameters
[in]reportA report.
[out]taskTask return, 0 if successfully failed to find task.
Returns
FALSE on success (including if failed to find report), TRUE on error.

◆ report_timestamp()

int report_timestamp ( const char *  report_id,
gchar **  timestamp 
)

Get the timestamp of a report.

Todo:
Lacks permission check. Caller contexts all have permission checks before calling this so it's safe. Rework callers so they pass report_t instead of UUID string.
Parameters
[in]report_idUUID of report.
[out]timestampTimestamp on success. Caller must free.
Returns
0 on success, -1 on error.

◆ report_uuid()

char* report_uuid ( report_t  report)

Return the UUID of a report.

Parameters
[in]reportReport.
Returns
Report UUID.

◆ report_vuln_count()

static int report_vuln_count ( report_t  report)
static

Count a report's total number of vulnerabilities.

Parameters
[in]reportReport.
Returns
Vulnerabilities count.

◆ reports_add_all()

static void reports_add_all ( GHashTable *  reports_table)
static

Add all reports to an existing GHashtable.

Parameters
[in]reports_tableThe GHashtable to contain the report rowids.

◆ reports_add_for_override()

static void reports_add_for_override ( GHashTable *  reports_table,
override_t  override 
)
static

Add reports affected by an override to an existing GHashtable. This is used to add more reports to the hashtable from reports_for_override.

Parameters
[in]reports_tableThe GHashtable to contain the report rowids.
[in]overrideThe override that selected reports must be affected by.

◆ reports_build_count_cache()

static void reports_build_count_cache ( int  clear,
int *  changes_out 
)
static

Rebuild the report count cache for all reports and users.

Parameters
[in]clearWhether to clear the cache before rebuilding.
[out]changes_outThe number of processed user/report combinations.

◆ reports_for_override()

static GHashTable* reports_for_override ( override_t  override)
static

Get reports affected by an override in a GHashTable.

Parameters
[in]overrideThe override that selected reports must be affected by.
Returns
A GHashtable containing the affected report rowids.

◆ reports_hashtable()

static GHashTable* reports_hashtable ( )
static

Get all reports in a GHashTable.

Returns
A GHashtable containing the report rowids.

◆ request_delete_task()

int request_delete_task ( task_t *  task_pointer)

Request deletion of a task.

Stop the task beforehand with stop_task_internal, if it is running.

Used only for CREATE_TASK in gmp.c. Always ultimate.

Parameters
[in]task_pointerA pointer to the task.
Returns
0 if deleted, 1 if delete requested, 2 if task is hidden, -1 if error, -5 if scanner is down.

◆ request_delete_task_uuid()

int request_delete_task_uuid ( const char *  task_id,
int  ultimate 
)

Request deletion of a task.

Stop the task beforehand with stop_task_internal, if it is running.

This is only used for DELETE_TASK in gmp.c.

Parameters
[in]task_idUUID of task.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 deleted, 1 delete requested, 2 task is hidden, 3 failed to find task, 99 permission denied, -1 error, -5 scanner is down, -7 no CA cert.

◆ reschedule_task()

void reschedule_task ( const gchar *  task_id)

Set a task's schedule so that it runs again next scheduling round.

Parameters
task_idUUID of task.

◆ reset_task()

void reset_task ( task_t  task)

Reset all running information for a task.

Parameters
[in]taskTask.

◆ resource_count()

int resource_count ( const char *  type,
const get_data_t get 
)

Return number of resources of a certain type for current user.

Parameters
[in]typeType.
[in]getGET params.
Returns
The number of resources associated with the current user.

◆ resource_exists()

int resource_exists ( const char *  type,
resource_t  resource,
int  location 
)

Get whether a resource exists.

Parameters
[in]typeType.
[in]resourceResource.
[in]locationLocation.
Returns
1 yes, 0 no, -1 error in type.

◆ resource_name()

int resource_name ( const char *  type,
const char *  uuid,
int  location,
char **  name 
)

Get the name of a resource.

Parameters
[in]typeType.
[in]uuidUUID.
[in]locationLocation.
[out]nameReturn for freshly allocated name.
Returns
0 success, 1 error in type.

◆ resource_predefined()

static int resource_predefined ( const gchar *  type,
resource_t  resource 
)
static

Return whether a resource is predefined.

Parameters
[in]typeType of resource.
[in]resourceResource.
Returns
1 if predefined, else 0.

◆ resource_set_predefined()

static void resource_set_predefined ( const gchar *  type,
resource_t  resource,
int  enable 
)
static

Mark a resource as predefined.

Currently only report formats use this.

Parameters
[in]typeResource type.
[in]resourceResource.
[in]enableIf true mark as predefined, else remove mark.

◆ resource_uuid()

gchar* resource_uuid ( const gchar *  type,
resource_t  resource 
)

Get the UUID of a resource.

Parameters
[in]typeType.
[in]resourceResource.
Returns
Freshly allocated UUID on success, else NULL.

◆ resource_with_name_exists()

gboolean resource_with_name_exists ( const char *  name,
const char *  type,
resource_t  resource 
)

Check if a resource with a certain name exists already.

Conflicting resource can be global or owned by the current user.

Parameters
[in]nameName of resource to check for.
[in]typeType of resource.
[in]resourceResource to ignore, 0 otherwise.
Returns
Whether resource with name exists.

◆ resource_with_name_exists_global()

static gboolean resource_with_name_exists_global ( const char *  name,
const char *  type,
resource_t  resource 
)
static

Check if a resource with a certain name exists already.

Conflicting resource can be owned by anybody.

Parameters
[in]nameName of resource to check for.
[in]typeType of resource.
[in]resourceResource to ignore, 0 otherwise.
Returns
Whether resource with name exists.

◆ result_buffer_free()

static void result_buffer_free ( result_buffer_t result_buffer)
static

Free a result buffer.

Parameters
[in]result_bufferResult buffer.

◆ result_buffer_new()

static result_buffer_t* result_buffer_new ( const gchar *  host,
const gchar *  port,
const gchar *  severity,
double  severity_double 
)
static

Create a result buffer.

Parameters
[in]hostHost.
[in]portPort.
[in]severitySeverity.
[in]severity_doubleSeverity.
Returns
Freshly allocated result buffer.

◆ result_cmp()

static compare_results_t result_cmp ( iterator_t results,
iterator_t delta_results,
int  sort_order,
const char *  sort_field 
)
static

Return the sort order of two results.

Parameters
[in]resultsIterator containing first result.
[in]delta_resultsIterator containing second result.
[in]sort_orderWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for "type".
Returns
< 0 if first comes before second, 0 if equal, > 0 if first comes after second.

◆ result_count()

int result_count ( const get_data_t get,
report_t  report,
const char *  host 
)

Count the number of results.

Parameters
[in]getGET params.
[in]reportReport to limit results to.
[in]hostHost to limit results to.
Returns
Total number of results in filtered set.

◆ result_detection_reference()

int result_detection_reference ( result_t  result,
report_t  report,
const gchar *  host,
const char *  oid,
char **  ref,
char **  product,
char **  location,
char **  name 
)

Get product detection results corresponding to a given vulnerability detection result.

Parameters
[in]resultVulnerability detection result.
[in]reportReport of result.
[in]hostHost of result.
[in]oidDetection script OID.
[out]refDetection result UUID.
[out]productProduct name.
[out]locationProduct location.
[out]nameDetection script name.
Returns
-1 on error, 0 on success.

◆ result_iterator_has_cert_bunds()

int result_iterator_has_cert_bunds ( iterator_t iterator)

Get whether CERT-Bunds may exist from a result iterator.

Parameters
[in]iteratorIterator.
Returns
1 if notes may exist, else 0.

◆ result_iterator_has_dfn_certs()

int result_iterator_has_dfn_certs ( iterator_t iterator)

Get whether DFN-CERTs may exist from a result iterator.

Parameters
[in]iteratorIterator.
Returns
1 if notes may exist, else 0.

◆ result_iterator_level()

const char* result_iterator_level ( iterator_t iterator)

Get the severity/threat level from a result iterator.

This is the the autofp adjusted overridden level.

Parameters
[in]iteratorIterator.
Returns
The threat level of the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_may_have_notes()

int result_iterator_may_have_notes ( iterator_t iterator)

Get whether notes may exist from a result iterator.

Parameters
[in]iteratorIterator.
Returns
1 if notes may exist, else 0.

◆ result_iterator_may_have_overrides()

int result_iterator_may_have_overrides ( iterator_t iterator)

Get whether overrides may exist from a result iterator.

Parameters
[in]iteratorIterator.
Returns
1 if overrides may exist, else 0.

◆ result_iterator_may_have_tickets()

int result_iterator_may_have_tickets ( iterator_t iterator)

Get whether tickets may exist from a result iterator.

Parameters
[in]iteratorIterator.
Returns
1 if notes may exist, else 0.

◆ result_iterator_nvt_bid()

const char* result_iterator_nvt_bid ( iterator_t iterator)

Get the NVT BID from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The BID of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_cve()

const char* result_iterator_nvt_cve ( iterator_t iterator)

Get the NVT CVE from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The CVE of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_cvss_base()

const char* result_iterator_nvt_cvss_base ( iterator_t iterator)

Get the NVT CVSS base value from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The CVSS base of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_family()

const char* result_iterator_nvt_family ( iterator_t iterator)

Get the NVT family from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The family of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_name()

const char* result_iterator_nvt_name ( iterator_t iterator)

Get the NVT name from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The name of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_tag()

const char* result_iterator_nvt_tag ( iterator_t iterator)

Get the NVT tags from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The tags of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_xref()

const char* result_iterator_nvt_xref ( iterator_t iterator)

Get the NVT XREF from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The XREF of the NVT that produced the result, or NULL on error.

◆ result_iterator_opts_table()

static gchar* result_iterator_opts_table ( int  autofp,
int  override,
int  dynamic 
)
static

Generate the extra_tables string for a result iterator.

Parameters
[in]autofpWhether to apply auto FP filter.
[in]overrideWhether to apply overrides.
[in]dynamicWhether to use dynamic severity scores.
Returns
Newly allocated string with the extra_tables clause.

◆ result_iterator_original_level()

const char* result_iterator_original_level ( iterator_t iterator)

Get the original severity/threat level from a result iterator.

This is the original level without overrides and autofp.

Parameters
[in]iteratorIterator.
Returns
The original threat level of the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_original_severity()

const char* result_iterator_original_severity ( iterator_t iterator)

Get the original severity from a result iterator.

This is the original severity without overrides and autofp.

Parameters
[in]iteratorIterator.
Returns
The original severity of the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_report()

report_t result_iterator_report ( iterator_t iterator)

Get the report from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The report associated with the result, or 0 on error.

◆ result_iterator_result()

result_t result_iterator_result ( iterator_t iterator)

Get the result from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The result.

◆ result_iterator_scan_nvt_version()

const char* result_iterator_scan_nvt_version ( iterator_t iterator)

Get the NVT version used during the scan from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The version of NVT used by the scan that produced the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_severity()

static const char* result_iterator_severity ( iterator_t iterator)
static

Get the severity from a result iterator.

This is the the autofp adjusted overridden severity.

Parameters
[in]iteratorIterator.
Returns
The severity of the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_severity_double()

double result_iterator_severity_double ( iterator_t iterator)

Get the severity from a result iterator as double.

This is the the autofp adjusted overridden severity.

Parameters
[in]iteratorIterator.
Returns
The severity of the result. Caller must only use before calling cleanup_iterator.

◆ result_iterator_task()

task_t result_iterator_task ( iterator_t iterator)

Get the task from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The task associated with the result, or 0 on error.

◆ result_iterator_type()

static const char* result_iterator_type ( iterator_t iterator)
static

Get the type from a result iterator.

This is the the autofp adjusted overridden type.

Parameters
[in]iteratorIterator.
Returns
The type of the result. Caller must only use before calling cleanup_iterator.

◆ result_nvt_notice()

static void result_nvt_notice ( const gchar *  nvt)
static

Ensure an NVT occurs in the result_nvts table.

Parameters
[in]nvtNVT OID.

◆ result_uuid()

int result_uuid ( result_t  result,
char **  id 
)

Return the UUID of a result.

Parameters
[in]resultResult.
[out]idPointer to a newly allocated string.
Returns
0.

◆ results_extra_where()

static gchar * results_extra_where ( int  trash,
report_t  report,
const gchar *  host,
int  autofp,
int  apply_overrides,
int  dynamic_severity,
const gchar *  filter 
)
static

Get extra_where string for a result iterator or count.

Parameters
[in]trashWhether to get results from trashcan.
[in]reportReport to restrict returned results to.
[in]hostHost to restrict returned results to.
[in]autofpWhether to apply auto FP filter.
[in]apply_overridesWhether to apply overrides.
[in]dynamic_severityWhether to use dynamic severity.
[in]filterFilter string.
Returns
Newly allocated extra_where string.

◆ run_alert_script()

static int run_alert_script ( const char *  alert_id,
const char *  command_args,
const char *  report_filename,
const char *  report,
size_t  report_size,
const char *  extra_content,
size_t  extra_size,
gchar **  message 
)
static

Run an alert's "alert" script with one file of extra data.

Parameters
[in]alert_idID of alert.
[in]command_argsArgs for the "alert" script.
[in]report_filenameOptional report file name, default: "report"
[in]reportReport that should be sent.
[in]report_sizeSize of the report.
[in]extra_contentOptional extra data like passwords
[in]extra_sizeSize of the report.
[out]messageCustom error message of the script.
Returns
0 success, -1 error, -5 alert script failed.

◆ run_report_format_script()

static int run_report_format_script ( gchar *  report_format_id,
gchar *  xml_file,
gchar *  xml_dir,
gchar *  report_format_extra,
gchar *  output_file 
)
static

Runs the script of a report format.

Parameters
[in]report_format_idUUID of the report format.
[in]xml_filePath to main part of the report XML.
[in]xml_dirPath of the dir with XML and subreports.
[in]report_format_extraExtra data for report format.
[in]output_filePath to write report to.
Returns
0 success, -1 error.

◆ scan_end_time()

static char* scan_end_time ( report_t  report)
static

Get the end time of a scan.

Parameters
[in]reportThe report associated with the scan.
Returns
End time of scan, in a newly allocated string.

◆ scan_end_time_uuid()

char* scan_end_time_uuid ( const char *  uuid)

Get the end time of a scan.

Parameters
[in]uuidThe report associated with the scan.
Returns
End time of scan, in a newly allocated string.

◆ scan_host_end_time()

int scan_host_end_time ( report_t  report,
const char *  host 
)

Get the end time of a scanned host.

Parameters
[in]reportReport associated with the scan.
[in]hostHost.
Returns
End time.

◆ scan_start_time()

static char* scan_start_time ( report_t  report)
static

Get the start time of a scan.

Parameters
[in]reportThe report associated with the scan.
Returns
Start time of scan, in a newly allocated string.

◆ scan_start_time_epoch()

int scan_start_time_epoch ( report_t  report)

Get the start time of a scan, in seconds since the epoch.

Parameters
[in]reportThe report associated with the scan.
Returns
Start time of scan, in seconds.

◆ scan_start_time_uuid()

char* scan_start_time_uuid ( const char *  uuid)

Get the start time of a scan.

Parameters
[in]uuidThe report associated with the scan.
Returns
Start time of scan, in a newly allocated string.

◆ scanner_ca_pub()

char* scanner_ca_pub ( scanner_t  scanner)

Return the CA Certificate of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated CA Certificate.

◆ scanner_config_iterator_readable()

int scanner_config_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ scanner_count()

int scanner_count ( const get_data_t get)

Count number of scanners.

Parameters
[in]getGET params.
Returns
Total number of scanners in filtered set.

◆ scanner_host()

char* scanner_host ( scanner_t  scanner)

Return the host of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated host.

◆ scanner_in_use()

int scanner_in_use ( scanner_t  scanner)

Check whether an scanner is in use.

Parameters
[in]scannerScanner.
Returns
1 yes, 0 no.

◆ scanner_iterator_credential()

credential_t scanner_iterator_credential ( iterator_t iterator)

Get the credential of the scanner from a scanner iterator.

Parameters
[in]iteratorIterator.
Returns
Credential of the scanner or 0 if iteration is complete.

◆ scanner_iterator_credential_trash()

int scanner_iterator_credential_trash ( iterator_t iterator)

Get the credential location of the scanner from a scanner iterator.

Parameters
[in]iteratorIterator.
Returns
Location of the credential or NULL if iteration is complete.

◆ scanner_iterator_key_priv()

static const char* scanner_iterator_key_priv ( iterator_t iterator)
static

Get the Scanner private key from a scanner iterator.

Parameters
[in]iteratorIterator.
Returns
Scanner private key, or NULL if iteration is complete. Freed by cleanup_iterator.

◆ scanner_iterator_port()

int scanner_iterator_port ( iterator_t iterator)

Get the port from an scanner iterator.

Parameters
[in]iteratorIterator.
Returns
Port, or -1 if iteration is complete.

◆ scanner_iterator_type()

int scanner_iterator_type ( iterator_t iterator)

Get the type from an scanner iterator.

Parameters
[in]iteratorIterator.
Returns
Type, or SCANNER_TYPE_NONE if iteration is complete.

◆ scanner_key_priv()

char* scanner_key_priv ( scanner_t  scanner)

Return the private key of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated private key.

◆ scanner_key_pub()

char* scanner_key_pub ( scanner_t  scanner)

Return the Certificate of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated Certificate.

◆ scanner_login()

char* scanner_login ( scanner_t  scanner)

Return the login associated with a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated login if available, else NULL.

◆ scanner_name()

char* scanner_name ( scanner_t  scanner)

Return the name of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated name if available, else NULL.

◆ scanner_password()

char* scanner_password ( scanner_t  scanner)

Return the password associated with a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated password if available, else NULL.

◆ scanner_port()

int scanner_port ( scanner_t  scanner)

Return the port of a scanner.

Parameters
[in]scannerScanner.
Returns
Scanner port, -1 if not found;

◆ scanner_task_iterator_readable()

int scanner_task_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ scanner_type()

int scanner_type ( scanner_t  scanner)

Return the type of a scanner.

Parameters
[in]scannerScanner.
Returns
Scanner type, -1 if not found;

◆ scanner_uuid()

char* scanner_uuid ( scanner_t  scanner)

Return the UUID of a scanner.

Parameters
[in]scannerScanner.
Returns
Newly allocated UUID.

◆ scanner_uuid_default()

const char* scanner_uuid_default ( )

Return the UUID of the default scanner.

Returns
UUID.

◆ scanner_writable()

int scanner_writable ( scanner_t  scanner)

Check whether a scanner is writable.

Parameters
[in]scannerScanner.
Returns
1 yes, 0 no.

◆ scap_check_time()

static int scap_check_time ( )
static

Get last time SCAP SecInfo alerts were checked.

Returns
Last time SCAP was checked.

◆ schedule_count()

int schedule_count ( const get_data_t get)

Count the number of schedules.

Parameters
[in]getGET params.
Returns
Total number of schedules filtered set.

◆ schedule_duration()

int schedule_duration ( schedule_t  schedule)

Return the duration of a schedule.

Parameters
[in]scheduleSchedule.
Returns
Duration in seconds.

◆ schedule_in_use()

int schedule_in_use ( schedule_t  schedule)

Return whether a schedule is in use by a task.

Parameters
[in]scheduleSchedule.
Returns
1 if in use, else 0.

◆ schedule_info()

int schedule_info ( schedule_t  schedule,
int  trash,
time_t *  first_time,
time_t *  next_time,
int *  period,
int *  period_months,
int *  duration,
gchar **  icalendar,
gchar **  zone 
)

Return info about a schedule.

Parameters
[in]scheduleSchedule.
[in]trashWhether to get schedule from trash.
[out]first_timeFirst time schedule ran.
[out]next_timeNext time schedule will run.
[out]periodPeriod.
[out]period_monthsPeriod months.
[out]durationDuration.
[out]icalendariCalendar string.
[out]zoneTimezone string.
Returns
0 success, -1 error.

◆ schedule_iterator_byday_string()

gchar* schedule_iterator_byday_string ( iterator_t iterator)

Get the byday string from a schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Byday string.

◆ schedule_iterator_duration()

time_t schedule_iterator_duration ( iterator_t iterator)

Get the duration from a schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Duration of schedule.

◆ schedule_iterator_first_time()

time_t schedule_iterator_first_time ( iterator_t iterator)

Get the first time from a schedule iterator.

Parameters
[in]iteratorIterator.
Returns
First time of schedule.

◆ schedule_iterator_next_time()

time_t schedule_iterator_next_time ( iterator_t iterator)

Get the next time a schedule could be schedulable.

Parameters
[in]iteratorIterator.
Returns
Next time an action associated with schedule could be run.

◆ schedule_iterator_period()

time_t schedule_iterator_period ( iterator_t iterator)

Get the period from a schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Period of schedule.

◆ schedule_iterator_period_months()

time_t schedule_iterator_period_months ( iterator_t iterator)

Get the period months from a schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Period of schedule (months).

◆ schedule_name()

char* schedule_name ( schedule_t  schedule)

Return the name of a schedule.

Parameters
[in]scheduleSchedule.
Returns
Newly allocated name.

◆ schedule_period()

int schedule_period ( schedule_t  schedule)

Return the period of a schedule.

Parameters
[in]scheduleSchedule.
Returns
Period in seconds.

◆ schedule_task_iterator_readable()

int schedule_task_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ schedule_uuid()

char* schedule_uuid ( schedule_t  schedule)

Return the UUID of a schedule.

Parameters
[in]scheduleSchedule.
Returns
Newly allocated UUID.

◆ schedule_writable()

int schedule_writable ( schedule_t  schedule)

Return whether a schedule is writable.

Parameters
[in]scheduleSchedule.
Returns
1 if writable, else 0.

◆ scp_alert_path_print()

static gchar* scp_alert_path_print ( const gchar *  message,
task_t  task 
)
static

Print an SCP alert file path.

Parameters
[in]messageFormat string for message.
[in]taskTask.
Returns
Freshly allocated message.

◆ scp_to_host()

static int scp_to_host ( const char *  password,
const char *  username,
const char *  host,
const char *  path,
const char *  known_hosts,
const char *  report,
int  report_size,
gchar **  script_message 
)
static

Send a report to a host via TCP.

Parameters
[in]passwordPassword.
[in]usernameUsername.
[in]hostAddress of host.
[in]pathDestination filename with path.
[in]known_hostsContent for known_hosts file.
[in]reportReport that should be sent.
[in]report_sizeSize of the report.
[out]script_messageCustom error message of the alert script.
Returns
0 success, -1 error, -5 alert script failed.

◆ send_to_host()

static int send_to_host ( const char *  host,
const char *  port,
const char *  report,
int  report_size,
gchar **  script_message 
)
static

Send a report to a host via TCP.

Parameters
[in]hostAddress of host.
[in]portPort of host.
[in]reportReport that should be sent.
[in]report_sizeSize of the report.
[out]script_messageCustom error message of the script.
Returns
0 success, -1 error, -5 alert script failed.

◆ send_to_sourcefire()

static int send_to_sourcefire ( const char *  ip,
const char *  port,
const char *  pkcs12_64,
const char *  pkcs12_password,
const char *  report 
)
static

Send a report to a Sourcefire Defense Center.

Parameters
[in]ipIP of center.
[in]portPort of center.
[in]pkcs12_64PKCS12 content in base64.
[in]pkcs12_passwordPassword for encrypted PKCS12.
[in]reportReport in "Sourcefire" format.
Returns
0 success, -1 error.

◆ send_to_tippingpoint()

static int send_to_tippingpoint ( const char *  report,
size_t  report_size,
const char *  username,
const char *  password,
const char *  hostname,
const char *  certificate,
int  cert_workaround,
gchar **  message 
)
static

Convert an XML report and send it to a TippingPoint SMS.

Parameters
[in]reportReport to send.
[in]report_sizeSize of report.
[in]usernameUsername.
[in]passwordPassword.
[in]hostnameHostname.
[in]certificateCertificate.
[in]cert_workaroundWhether to use cert workaround.
[out]messageCustom error message of the script.
Returns
0 success, -1 error.

◆ send_to_verinice()

static int send_to_verinice ( const char *  url,
const char *  username,
const char *  password,
const char *  archive,
int  archive_size 
)
static

Send a report to a verinice.PRO server.

Parameters
[in]urlURL of the server.
[in]usernameUsername for server access.
[in]passwordPassword for server access.
[in]archiveVerinice archive that should be sent.
[in]archive_sizeSize of the verinice archive
Returns
0 success, -1 error.

◆ send_to_vfire()

static int send_to_vfire ( const char *  base_url,
const char *  client_id,
const char *  session_type,
const char *  username,
const char *  password,
GPtrArray *  report_data,
GTree *  call_data,
const char *  description_template,
gchar **  message 
)
static

Create a new call on an Alemba vFire server.

Parameters
[in]base_urlBase url of the vFire server.
[in]client_idThe Alemba API Client ID to authenticate with.
[in]session_typeAlemba session type to use, e.g. "Analyst".
[in]usernameUsername.
[in]passwordPassword.
[in]report_dataData for vFire call report attachments.
[in]call_dataData for creating the vFire call.
[in]description_templateTemplate for the description text.
[out]messageError message.
Returns
0 success, -1 error, -5 alert script failed.

◆ set_certs()

int set_certs ( const char *  ca_pub,
const char *  key_pub,
const char *  key_priv 
)

Initialise OpenVAS scanner variables, checking for defaults.

Parameters
[in]ca_pubCA Certificate.
[in]key_pubScanner Certificate.
[in]key_privScanner private key.
Returns
0 success, 1 both default CA cert setting and ca_pub were NULL.

◆ set_credential_auth_algorithm()

static void set_credential_auth_algorithm ( credential_t  credential,
const char *  algorithm 
)
static

Set the auth_algorithm of a Credential.

Parameters
[in]credentialThe Credential.
[in]algorithmAuthentication algorithm.

◆ set_credential_certificate()

static void set_credential_certificate ( credential_t  credential,
const char *  certificate 
)
static

Set the certificate of a Credential.

Parameters
[in]credentialThe Credential.
[in]certificateCertificate.

◆ set_credential_comment()

static void set_credential_comment ( credential_t  credential,
const char *  comment 
)
static

Set the comment of a Credential.

Parameters
[in]credentialThe Credential.
[in]commentComment.

◆ set_credential_data()

static int set_credential_data ( credential_t  credential,
const char *  type,
const char *  value 
)
static

Set data for a credential.

Parameters
[in]credentialThe credential.
[in]typeThe data type (e.g. "username" or "secret").
[in]valueThe value to set or NULL to remove data entry.
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ set_credential_login()

static void set_credential_login ( credential_t  credential,
const char *  login 
)
static

Set the login of a Credential.

Parameters
[in]credentialThe Credential.
[in]loginLogin.

◆ set_credential_name()

static void set_credential_name ( credential_t  credential,
const char *  name 
)
static

Set the name of a Credential.

Parameters
[in]credentialThe Credential.
[in]nameName.

◆ set_credential_password()

static void set_credential_password ( credential_t  credential,
const char *  password 
)
static

Set the password of a Credential.

Parameters
[in]credentialThe Credential.
[in]passwordPassword.

◆ set_credential_privacy_algorithm()

void set_credential_privacy_algorithm ( credential_t  credential,
const char *  algorithm 
)

Set the privacy_algorithm of a Credential.

Parameters
[in]credentialThe Credential.
[in]algorithmPrivacy algorithm.

◆ set_credential_private_key()

static void set_credential_private_key ( credential_t  credential,
const char *  private_key,
const char *  passphrase 
)
static

Set the private key and passphrase of a Credential.

Parameters
[in]credentialThe Credential.
[in]private_keyPrivate key.
[in]passphrasePassphrase.

◆ set_credential_public_key()

void set_credential_public_key ( credential_t  credential,
const char *  public_key 
)

Set the public key of a Credential.

Parameters
[in]credentialThe Credential.
[in]public_keyPublic key.

◆ set_credential_snmp_secret()

static void set_credential_snmp_secret ( credential_t  credential,
const char *  community,
const char *  password,
const char *  privacy_password 
)
static

Set the community, password and privacy password of a Credential.

Parameters
[in]credentialThe Credential.
[in]communitySNMP community.
[in]passwordAuthentication password.
[in]privacy_passwordPrivacy password.

◆ set_db_version()

void set_db_version ( int  version)

Set the database version of the actual database.

Caller must organise transaction.

Parameters
versionNew version number.

◆ set_report_format_active()

static void set_report_format_active ( report_format_t  report_format,
int  active 
)
static

Set the active flag of a report format.

Parameters
[in]report_formatThe report format.
[in]activeActive flag.

◆ set_report_format_name()

static void set_report_format_name ( report_format_t  report_format,
const char *  name 
)
static

Set the name of the report format.

Parameters
[in]report_formatThe report format.
[in]nameName.

◆ set_report_format_summary()

static void set_report_format_summary ( report_format_t  report_format,
const char *  summary 
)
static

Set the summary of the report format.

Parameters
[in]report_formatThe report format.
[in]summarySummary.

◆ set_report_scan_run_status()

int set_report_scan_run_status ( report_t  report,
task_status_t  status 
)

Return the run status of the scan associated with a report.

Parameters
[in]reportReport.
[out]statusScan run status.
Returns
0 on success, -1 on error.

◆ set_report_scheduled()

void set_report_scheduled ( report_t  report)

Set a report's scheduled flag.

Set flag if task was scheduled, else clear flag.

Parameters
[in]reportReport.

◆ set_report_slave_progress()

int set_report_slave_progress ( report_t  report,
int  progress 
)

Set slave progress of a report.

Parameters
[in]reportThe report.
[in]progressThe new progress value.
Returns
0 success.

◆ set_report_slave_task_uuid()

void set_report_slave_task_uuid ( report_t  report,
const char *  uuid 
)

Set the UUID of the slave task, on the local task.

Parameters
[in]reportThe report.
[in]uuidUUID.

◆ set_scan_end_time()

void set_scan_end_time ( report_t  report,
const char *  timestamp 
)

Set the end time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampEnd time. ISO format. If NULL, clear end time.

◆ set_scan_end_time_epoch()

void set_scan_end_time_epoch ( report_t  report,
time_t  timestamp 
)

Set the end time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampEnd time. Epoch format.

◆ set_scan_end_time_otp()

void set_scan_end_time_otp ( report_t  report,
const char *  timestamp 
)

Set the end time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampEnd time. OTP format (ctime). If NULL, clear end time.

◆ set_scan_host_end_time()

void set_scan_host_end_time ( report_t  report,
const char *  host,
const char *  timestamp 
)

Set the end time of a scanned host.

Parameters
[in]reportReport associated with the scan.
[in]hostHost.
[in]timestampEnd time. ISO format.

◆ set_scan_host_end_time_otp()

void set_scan_host_end_time_otp ( report_t  report,
const char *  host,
const char *  timestamp 
)

Set the end time of a scanned host.

Parameters
[in]reportReport associated with the scan.
[in]hostHost.
[in]timestampEnd time. OTP format (ctime).

◆ set_scan_host_start_time()

static void set_scan_host_start_time ( report_t  report,
const char *  host,
const char *  timestamp 
)
static

Set the start time of a scanned host.

Parameters
[in]reportReport associated with the scan.
[in]hostHost.
[in]timestampStart time. ISO format.

◆ set_scan_host_start_time_otp()

void set_scan_host_start_time_otp ( report_t  report,
const char *  host,
const char *  timestamp 
)

Set the start time of a scanned host.

Parameters
[in]reportReport associated with the scan.
[in]hostHost.
[in]timestampStart time. OTP format (ctime).

◆ set_scan_ports()

void set_scan_ports ( report_t  report,
const char *  host,
unsigned int  current,
unsigned int  max 
)

Set the ports for a particular host in a scan.

Parameters
[in]reportReport associated with scan.
[in]hostHost.
[in]currentNew value for port currently being scanned.
[in]maxNew value for last port to be scanned.

◆ set_scan_start_time()

static void set_scan_start_time ( report_t  report,
const char *  timestamp 
)
static

Set the start time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampStart time. In ISO format.

◆ set_scan_start_time_epoch()

void set_scan_start_time_epoch ( report_t  report,
time_t  timestamp 
)

Set the start time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampStart time. Epoch format.

◆ set_scan_start_time_otp()

void set_scan_start_time_otp ( report_t  report,
const char *  timestamp 
)

Set the start time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampStart time. In OTP format (ctime).

◆ set_target_login_data()

static int set_target_login_data ( target_t  target,
const char *  type,
credential_t  credential,
int  port 
)
static

Set login data for a target.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
[in]credentialThe credential or 0 to remove.
[in]portThe port to authenticate at with credential.
Returns
0 on success, -1 on error, 1 target not found, 99 permission denied.

◆ set_task_alerts()

static int set_task_alerts ( task_t  task,
array_t *  alerts,
gchar **  alert_id_return 
)
static

Set the alerts on a task, removing any previous alerts.

Parameters
[in]taskTask.
[in]alertsAlerts.
[out]alert_id_returnID of alert on "failed to find" error.
Returns
0 success, -1 error, 1 failed to find alert.

◆ set_task_alterable()

void set_task_alterable ( task_t  task,
int  alterable 
)

Set the alterable state of a task.

Parameters
[in]taskTask.
[in]alterableWhether task is alterable.

◆ set_task_comment()

static void set_task_comment ( task_t  task,
const char *  comment 
)
static

Set the comment of a task.

Parameters
[in]taskA task.
[in]commentNew comment.

◆ set_task_config()

void set_task_config ( task_t  task,
config_t  config 
)

Set the config of a task.

Parameters
[in]taskTask.
[in]configConfig.

◆ set_task_end_time()

void set_task_end_time ( task_t  task,
char *  time 
)

Set the end time of a task.

Parameters
[in]taskTask.
[in]timeNew time. Freed before return. If NULL, clear end time.

◆ set_task_end_time_epoch()

void set_task_end_time_epoch ( task_t  task,
time_t  time 
)

Set the end time of a task.

Parameters
[in]taskTask.
[in]timeNew time. Freed before return. If NULL, clear end time.

◆ set_task_groups()

int set_task_groups ( task_t  task,
array_t *  groups,
gchar **  group_id_return 
)

Set observer groups on a task, removing any previous groups.

Parameters
[in]taskTask.
[in]groupsGroups.
[out]group_id_returnID of group on "failed to find" error.
Returns
0 success, -1 error, 1 failed to find group.

◆ set_task_hosts_ordering()

void set_task_hosts_ordering ( task_t  task,
const char *  ordering 
)

Set the hosts ordering of a task.

Parameters
[in]taskTask.
[in]orderingHosts ordering.

◆ set_task_interrupted()

void set_task_interrupted ( task_t  task,
const gchar *  message 
)

Set a task to interrupted.

Expects global_current_report to match the task.

Parameters
[in]taskTask
[in]messageMessage for error result.

◆ set_task_name()

void set_task_name ( task_t  task,
const char *  name 
)

Set the name of a task.

Parameters
[in]taskA task.
[in]nameNew name.

◆ set_task_observers()

int set_task_observers ( task_t  task,
const gchar *  observers 
)

Set the observers of a task.

Parameters
[in]taskTask.
[in]observersObservers.
Returns
0 success, -1 error, 1 user name validation failed, 2 failed to find user.

◆ set_task_preferences()

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).

Parameters
[in]taskTask.
[in]preferencesPreferences.
Returns
0 success, 1 invalid auto_delete value, 2 auto_delete_data out of range.

◆ set_task_requested()

int set_task_requested ( task_t  task,
task_status_t *  status 
)

Atomically set the run state of a task to requested.

Only used by run_slave_or_gmp_task and run_otp_task.

Parameters
[in]taskTask.
[out]statusOld run status of task.
Returns
0 success, 1 task is active already.

◆ set_task_run_status()

void set_task_run_status ( task_t  task,
task_status_t  status 
)

Set the run state of a task.

Logs and generates event.

Parameters
[in]taskTask.
[in]statusNew run status.

◆ set_task_run_status_internal()

static void set_task_run_status_internal ( task_t  task,
task_status_t  status 
)
static

Set the run state of a task.

Parameters
[in]taskTask.
[in]statusNew run status.

◆ set_task_scanner()

void set_task_scanner ( task_t  task,
scanner_t  scanner 
)

Set the scanner of a task.

Parameters
[in]taskTask.
[in]scannerScanner.

◆ set_task_schedule()

int set_task_schedule ( task_t  task,
schedule_t  schedule,
int  periods 
)

Set the schedule of a task.

Parameters
[in]taskTask.
[in]scheduleSchedule.
[in]periodsNumber of schedule periods.
Returns
0 success, -1 error.

◆ set_task_schedule_next_time()

void set_task_schedule_next_time ( task_t  task,
time_t  time 
)

Set the next time a scheduled task will be due.

Parameters
[in]taskTask.
[in]timeNew next time.

◆ set_task_schedule_next_time_uuid()

void set_task_schedule_next_time_uuid ( const gchar *  task_id,
time_t  time 
)

Set the next time a scheduled task will be due.

Parameters
[in]task_idTask UUID.
[in]timeNew next time.

◆ set_task_schedule_periods()

int set_task_schedule_periods ( const gchar *  task_id,
int  periods 
)

Set the schedule periods of a task, given a UUID.

The task modification time stays the same.

Parameters
[in]task_idTask UUID.
[in]periodsSchedule periods.
Returns
0 success, -1 error.

◆ set_task_schedule_periods_id()

int set_task_schedule_periods_id ( task_t  task,
int  periods 
)

Set the schedule periods of a task, given an ID.

The task modification time stays the same.

Parameters
[in]taskTask UUID.
[in]periodsSchedule periods.
Returns
0 success, -1 error.

◆ set_task_schedule_uuid()

int set_task_schedule_uuid ( const gchar *  task_id,
schedule_t  schedule,
int  periods 
)

Set the schedule of a task.

Parameters
[in]task_idTask UUID.
[in]scheduleSchedule.
[in]periodsNumber of schedule periods.
Returns
0 success, -1 error.

◆ set_task_start_time()

static void set_task_start_time ( task_t  task,
char *  time 
)
static

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. ISO format. Freed before return.

◆ set_task_start_time_epoch()

void set_task_start_time_epoch ( task_t  task,
int  time 
)

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. Seconds since epoch.

◆ set_task_start_time_otp()

void set_task_start_time_otp ( task_t  task,
char *  time 
)

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. OTP format (ctime). Freed before return.

◆ set_task_target()

void set_task_target ( task_t  task,
target_t  target 
)

Set the target of a task.

Parameters
[in]taskTask.
[in]targetTarget.

◆ setup_full_config_prefs()

static void setup_full_config_prefs ( config_t  config,
int  safe_checks,
int  optimize_test,
int  port_range 
)
static

Setup config preferences for a config.

Parameters
[in]configThe config.
[in]safe_checkssafe_checks option: 1 for "yes", 0 for "no".
[in]optimize_testoptimize_test option: 1 for "yes", 0 for "no".
[in]port_rangeport_range option: 1 for "yes", 0 for "no".

◆ severity_class_xml()

static gchar* severity_class_xml ( const gchar *  severity)
static

Buffer XML for a severity class.

Parameters
[in]severitySeverity name.
Returns
Freshly allocated XML on success, else NULL.

◆ smb_send_to_host()

static int smb_send_to_host ( const char *  password,
const char *  username,
const char *  share_path,
const char *  file_path,
const char *  report,
gsize  report_size,
gchar **  script_message 
)
static

Send a report to a host via SMB.

Parameters
[in]passwordPassword.
[in]usernameUsername.
[in]share_pathName/address of host and name of the share.
[in]file_pathDestination filename with path inside the share.
[in]reportReport that should be sent.
[in]report_sizeSize of the report.
[out]script_messageCustom error message of the alert script.
Returns
0 success, -1 error, -5 alert script failed.

◆ snmp_to_host()

static int snmp_to_host ( const char *  community,
const char *  agent,
const char *  message,
gchar **  script_message 
)
static

Send an SNMP TRAP to a host.

Parameters
[in]communityCommunity.
[in]agentAgent.
[in]messageMessage.
[out]script_messageCustom error message of the script.
Returns
0 success, -1 error, -5 alert script failed.

◆ split_filter()

array_t* split_filter ( const gchar *  given_filter)

Split the filter term into parts.

Parameters
[in]given_filterFilter term.
Returns
Array of strings, the parts.

◆ split_filter_add_specials()

void split_filter_add_specials ( array_t *  parts,
const gchar *  given_filter 
)

Ensure filter parts contains the special keywords.

Parameters
[in]partsArray of keyword strings.
[in]given_filterFilter term.

◆ stop_task_internal()

int stop_task_internal ( task_t  task)

Initiate stopping a task.

Use send_to_server to queue the task stop sequence in the scanner output buffer.

Parameters
[in]taskTask.
Returns
0 on success, 1 if stop requested, -1 if out of space in scanner output buffer, -5 scanner down, -7 no CA cert.

◆ switch_representation()

static int switch_representation ( config_t  config,
int  constraining 
)
static

Switch between constraining and generating representation.

It's up to the caller to start and end a transaction.

Parameters
[in]configConfig name.
[in]constraining1 families currently growing, 0 families currently static.
Returns
0 success, -1 error.

◆ sync_config()

int sync_config ( const char *  config_id)

Synchronize a config.

Parameters
[in]config_idUUID of config.
Returns
0 success, 1 failed to find config, 2 config not of OSP type, 3 config has no scanner, 4 couldn't get params from scanner, 99 permission denied, -1 error.

◆ tag_uuid()

char* tag_uuid ( tag_t  tag)

Return the UUID of a tag.

Parameters
[in]tagTag.
Returns
Newly allocated UUID if available, else NULL.

◆ tag_value()

gchar* tag_value ( const gchar *  tags,
const gchar *  tag 
)

Extract a tag from an OTP tag list.

Parameters
[in]tagsTag list.
[out]tagTag name.
Returns
Newly allocated tag value.

◆ target_alive_tests()

alive_test_t target_alive_tests ( target_t  target)

Return a target's alive tests.

Parameters
[in]targetTarget.
Returns
Alive test bitfield.

◆ target_comment()

static char * target_comment ( target_t  target)
static

Return the comment of a target.

Parameters
[in]targetTarget.
Returns
Newly allocated name if available, else NULL.

◆ target_count()

int target_count ( const get_data_t get)

Count number of targets.

Parameters
[in]getGET params.
Returns
Total number of targets in filtered set.

◆ target_credential()

credential_t target_credential ( target_t  target,
const char *  type 
)

Get a credential from a target.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ target_esxi_credential()

credential_t target_esxi_credential ( target_t  target)

Return the ESXi credential associated with a target, if any.

Parameters
[in]targetTarget.
Returns
ESXi credential if any, else 0.

◆ target_exclude_hosts()

char* target_exclude_hosts ( target_t  target)

Return the excluded hosts associated with a target.

Parameters
[in]targetTarget.
Returns
Newly allocated comma separated list of excluded hosts if available, else NULL.

◆ target_hosts()

char* target_hosts ( target_t  target)

Return the hosts associated with a target.

Parameters
[in]targetTarget.
Returns
Newly allocated comma separated list of hosts if available, else NULL.

◆ target_in_use()

int target_in_use ( target_t  target)

Return whether a target is in use by a task.

Parameters
[in]targetTarget.
Returns
1 if in use, else 0.

◆ target_iterator_alive_tests()

const char* target_iterator_alive_tests ( iterator_t iterator)

Get the alive test description from a target iterator.

Parameters
[in]iteratorIterator.
Returns
Reverse lookup unify of the target or NULL if iteration is complete.

◆ target_iterator_esxi_credential()

int target_iterator_esxi_credential ( iterator_t iterator)

Get the ESXi LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ESXi LSC credential.

◆ target_iterator_esxi_trash()

int target_iterator_esxi_trash ( iterator_t iterator)

Get the ESXi LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ESXi LSC credential.

◆ target_iterator_port_list_trash()

int target_iterator_port_list_trash ( iterator_t iterator)

Get the location of the port list from a target iterator.

Parameters
[in]iteratorIterator.
Returns
0 in table, 1 in trash.

◆ target_iterator_smb_credential()

int target_iterator_smb_credential ( iterator_t iterator)

Get the SMB LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
SMB LSC credential.

◆ target_iterator_smb_trash()

int target_iterator_smb_trash ( iterator_t iterator)

Get the location of the SMB LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
0 in table, 1 in trash

◆ target_iterator_snmp_credential()

int target_iterator_snmp_credential ( iterator_t iterator)

Get the SNMP LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ESXi LSC credential.

◆ target_iterator_snmp_trash()

int target_iterator_snmp_trash ( iterator_t iterator)

Get the SNMP LSC credential location from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ESXi LSC credential.

◆ target_iterator_ssh_credential()

int target_iterator_ssh_credential ( iterator_t iterator)

Get the SSH LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
SSH LSC credential.

◆ target_iterator_ssh_trash()

int target_iterator_ssh_trash ( iterator_t iterator)

Get the location of the SSH LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
0 in table, 1 in trash

◆ target_login_port()

int target_login_port ( target_t  target,
const char *  type 
)

Get a login port from a target.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ target_name()

char* target_name ( target_t  target)

Return the name of a target.

Parameters
[in]targetTarget.
Returns
Newly allocated name if available, else NULL.

◆ target_port_list()

port_list_t target_port_list ( target_t  target)

Return the port list associated with a target, if any.

Parameters
[in]targetTarget.
Returns
Port list
Todo:
Move return to arg; return -1.

◆ target_port_range()

char* target_port_range ( target_t  target)

Return the port range of a target, in OTP format.

For "OpenVAS Default", return the explicit port ranges instead of "default".

Parameters
[in]targetTarget.
Returns
Newly allocated port range if available, else NULL.

◆ target_reverse_lookup_only()

char* target_reverse_lookup_only ( target_t  target)

Return the reverse_lookup_only value of a target.

Parameters
[in]targetTarget.
Returns
Reverse lookup only value if available, else NULL.

◆ target_reverse_lookup_unify()

char* target_reverse_lookup_unify ( target_t  target)

Return the reverse_lookup_unify value of a target.

Parameters
[in]targetTarget.
Returns
Reverse lookup unify value if available, else NULL.

◆ target_smb_credential()

credential_t target_smb_credential ( target_t  target)

Return the SMB credential associated with a target, if any.

Parameters
[in]targetTarget.
Returns
SMB credential if any, else 0.

◆ target_ssh_credential()

credential_t target_ssh_credential ( target_t  target)

Return the SSH credential associated with a target, if any.

Parameters
[in]targetTarget.
Returns
SSH credential if any, else 0.

◆ target_ssh_port()

char* target_ssh_port ( target_t  target)

Return the SSH LSC port of a target.

Parameters
[in]targetTarget.
Returns
Newly allocated port if available, else NULL.

◆ target_task_iterator_readable()

int target_task_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, else 0.

◆ target_uuid()

char* target_uuid ( target_t  target)

Return the UUID of a target.

Parameters
[in]targetTarget.
Returns
Newly allocated UUID if available, else NULL.

◆ target_writable()

int target_writable ( target_t  target)

Return whether a target is writable.

Parameters
[in]targetTarget.
Returns
1 if writable, else 0.

◆ task_alterable()

int task_alterable ( task_t  task)

Return whether a task is an Alterable Task.

Parameters
[in]taskTask.
Returns
1 if Alterable, else 0.

◆ task_average_scan_duration()

int task_average_scan_duration ( task_t  task)

Get the average duration of all finished reports of a task.

Parameters
[in]taskTask.
Returns
Average scan duration in seconds.

◆ task_comment()

char* task_comment ( task_t  task)

Return the comment of a task.

Parameters
[in]taskTask.
Returns
Comment of task.

◆ task_config()

config_t task_config ( task_t  task)

Return the config of a task.

Parameters
[in]taskTask.
Returns
Config of task.

◆ task_config_in_trash()

int task_config_in_trash ( task_t  task)

Return whether the config of a task is in the trashcan.

Parameters
[in]taskTask.
Returns
1 if in trashcan, else 0.

◆ task_config_name()

char* task_config_name ( task_t  task)

Return the name of the config of a task.

Parameters
[in]taskTask.
Returns
Name of config of task.

◆ task_config_uuid()

char* task_config_uuid ( task_t  task)

Return the UUID of the config of a task.

Parameters
[in]taskTask.
Returns
UUID of config of task.

◆ task_count()

unsigned int task_count ( const get_data_t get)

Return the number of tasks associated with the current user.

Parameters
[in]getGET params.
Returns
The number of tasks associated with the current user.

◆ task_definitions_file()

static char* task_definitions_file ( task_t  task)
static

Get definitions file from a task's config.

Parameters
[in]taskTask.
Returns
Definitions file.

◆ task_finished_report_count()

static unsigned int task_finished_report_count ( task_t  task)
static

Return the number of finished reports associated with a task.

Parameters
[in]taskTask.
Returns
Number of reports.

◆ task_hosts_ordering()

char* task_hosts_ordering ( task_t  task)

Return the hosts ordering of a task.

Parameters
[in]taskTask.
Returns
Hosts ordering of task.

◆ task_in_trash()

int task_in_trash ( task_t  task)

Return whether a task is in the trashcan.

Parameters
[in]taskTask.
Returns
1 if in trashcan, else 0.

◆ task_in_trash_id()

int task_in_trash_id ( const gchar *  task_id)

Return whether a task is in the trashcan.

Assume the UUID is properly formatted.

Parameters
[in]task_idTask UUID.
Returns
1 if in trashcan, else 0.

◆ task_in_use()

int task_in_use ( task_t  task)

Return whether a task is in use by a task.

Parameters
[in]taskTask.
Returns
0.

◆ task_iterator_current_report()

report_t task_iterator_current_report ( iterator_t iterator)

Return the current report of a task.

Parameters
[in]iteratorIterator.
Returns
Current report of task if task is active, else (report_t) 0.

◆ task_iterator_finished_reports()

int task_iterator_finished_reports ( iterator_t iterator)

Get the number of reports of a task iterator.

Parameters
[in]iteratorIterator.
Returns
Count of all task reports.

◆ task_iterator_first_report()

const char* task_iterator_first_report ( iterator_t iterator)

Get the first report UUID from a task iterator.

Parameters
[in]iteratorIterator.
Returns
First report UUID.

◆ task_iterator_hosts_ordering()

const char* task_iterator_hosts_ordering ( iterator_t iterator)

Get the hosts ordering value from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Task hosts ordering.

◆ task_iterator_last_report()

const char* task_iterator_last_report ( iterator_t iterator)

Get the last report UUID from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Last report UUID.

◆ task_iterator_opts_table()

static gchar* task_iterator_opts_table ( int  override,
int  min_qod,
int  ignore_severity 
)
static

Generate the extra_tables string for a task iterator.

Parameters
[in]overrideWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
[in]ignore_severityWhether to ignore severity data.
Returns
Newly allocated string with the extra_tables clause.

◆ task_iterator_run_status()

task_status_t task_iterator_run_status ( iterator_t iterator)

Get the run status from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Task run status.

◆ task_iterator_run_status_name()

const char* task_iterator_run_status_name ( iterator_t iterator)

Get the run status name from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Task run status name.

◆ task_iterator_scanner()

scanner_t task_iterator_scanner ( iterator_t iterator)

Get the UUID of task scanner from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Task scanner if found, NULL otherwise.

◆ task_iterator_total_reports()

int task_iterator_total_reports ( iterator_t iterator)

Get the number of reports of a task iterator.

Parameters
[in]iteratorIterator.
Returns
Count of all task reports.

◆ task_iterator_trend_counts()

const char* task_iterator_trend_counts ( iterator_t iterator,
int  holes_a,
int  warns_a,
int  infos_a,
double  severity_a,
int  holes_b,
int  warns_b,
int  infos_b,
double  severity_b 
)

Return the trend of a task, given counts.

Parameters
[in]iteratorTask iterator.
[in]holes_aNumber of holes on earlier report.
[in]warns_aNumber of warnings on earlier report.
[in]infos_aNumber of infos on earlier report.
[in]severity_aSeverity score of earlier report.
[in]holes_bNumber of holes on later report.
[in]warns_bNumber of warnings on later report.
[in]infos_bNumber of infos on later report.
[in]severity_bSeverity score of later report.
Returns
"up", "down", "more", "less", "same" or if too few reports "".

◆ task_last_report()

int task_last_report ( task_t  task,
report_t *  report 
)

Get the report from the most recently completed invocation of task.

Parameters
[in]taskThe task.
[out]reportReport return, 0 if successfully failed to select report.
Returns
0 success, -1 error.

◆ task_last_report_any_status()

static int task_last_report_any_status ( task_t  task,
report_t *  report 
)
static

Get the report from the most recently invocation of task.

Parameters
[in]taskThe task.
[out]reportReport return, 0 if successfully failed to select report.
Returns
0 success, -1 error.

◆ task_last_resumable_report()

int task_last_resumable_report ( task_t  task,
report_t *  report 
)

Get the report from the most recently stopped invocation of task.

Parameters
[in]taskThe task.
[out]reportReport return, 0 if successfully failed to select report.
Returns
0 success, -1 error.

◆ task_name()

char* task_name ( task_t  task)

Return the name of a task.

Parameters
[in]taskTask.
Returns
Task name.

◆ task_observers()

char* task_observers ( task_t  task)

Return the observers of a task.

Parameters
[in]taskTask.
Returns
Observers of task.

◆ task_owner_name()

char* task_owner_name ( task_t  task)

Return the name of the owner of a task.

Parameters
[in]taskTask.
Returns
Newly allocated user name.

◆ task_owner_uuid()

static char * task_owner_uuid ( task_t  task)
static

Return the name of the owner of a task.

Parameters
[in]taskTask.
Returns
Newly allocated user name.

◆ task_preference_value()

char* task_preference_value ( task_t  task,
const char *  name 
)

Get the value of a task preference.

Parameters
[in]taskTask.
[in]namePreference name.
Returns
Freshly allocated task preference value or NULL if pref missing.

◆ task_report_previous()

static int task_report_previous ( task_t  task,
report_t  report,
report_t *  previous 
)
static

Get most recently completed report that precedes a report.

Parameters
[in]taskThe task.
[out]reportReport.
[out]previousReport return, 0 if successfully failed to select report.
Returns
0 success, -1 error.

◆ task_result_count()

int task_result_count ( task_t  task,
int  min_qod 
)

Return number of results in a task.

Parameters
[in]taskTask.
[in]min_qodMinimum QOD.
Returns
Result count.

◆ task_run_status()

task_status_t task_run_status ( task_t  task)

Return the run state of a task.

Parameters
[in]taskTask.
Returns
Task run status.

◆ task_running_report()

report_t task_running_report ( task_t  task)

Return the running report of a task.

Parameters
[in]taskTask.
Returns
Current report of task if task is active, else (report_t) 0.

◆ task_scanner()

scanner_t task_scanner ( task_t  task)

Return the scanner of a task.

Parameters
[in]taskTask.
Returns
scanner of task.

◆ task_scanner_in_trash()

int task_scanner_in_trash ( task_t  task)

Return whether the scanner of a task is in the trashcan.

Parameters
[in]taskTask.
Returns
1 if in trash, else 0.

◆ task_schedule()

schedule_t task_schedule ( task_t  task)

Return the schedule of a task.

Parameters
[in]taskTask.
Returns
Schedule.

◆ task_schedule_in_trash()

int task_schedule_in_trash ( task_t  task)

Get whether the task schedule is in the trash.

Parameters
[in]taskTask.
Returns
1 if in trash, else 0.

◆ task_schedule_iterator_duration()

static time_t task_schedule_iterator_duration ( iterator_t iterator)
static

Get the next time from a task schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Next time.

◆ task_schedule_iterator_next_time()

static time_t task_schedule_iterator_next_time ( iterator_t iterator)
static

Get the next time from a task schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Next time.

◆ task_schedule_iterator_start_due()

gboolean task_schedule_iterator_start_due ( iterator_t iterator)

Get the start due state from a task schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Start due flag.

◆ task_schedule_iterator_stop_due()

gboolean task_schedule_iterator_stop_due ( iterator_t iterator)

Get the stop due state from a task schedule iterator.

Parameters
[in]iteratorIterator.
Returns
Stop due flag.

◆ task_schedule_iterator_task()

task_t task_schedule_iterator_task ( iterator_t iterator)

Get the task from a task schedule iterator.

Parameters
[in]iteratorIterator.
Returns
task.

◆ task_schedule_iterator_timed_out()

gboolean task_schedule_iterator_timed_out ( iterator_t iterator)

Get if schedule of task in iterator is timed out.

Parameters
[in]iteratorIterator.
Returns
Whether task schedule is timed out.

◆ task_schedule_next_time()

int task_schedule_next_time ( task_t  task)

Get next time a scheduled task will run, following schedule timezone.

Parameters
[in]taskTask.
Returns
If the task has a schedule, the next time the task will run (0 if it has already run), otherwise 0.

◆ task_schedule_next_time_uuid()

time_t task_schedule_next_time_uuid ( const gchar *  task_id)

Get the next time a scheduled task will be due.

Parameters
[in]task_idTask UUID.
Returns
Next scheduled time.

◆ task_schedule_periods()

int task_schedule_periods ( task_t  task)

Get the number of times the period schedule should run on the task.

Parameters
[in]taskTask.
Returns
Number of times.

◆ task_schedule_periods_uuid()

int task_schedule_periods_uuid ( const gchar *  task_id)

Set the next time a scheduled task will be due.

Parameters
[in]task_idTask UUID.
Returns
Task schedule periods.

◆ task_schedule_uuid()

schedule_t task_schedule_uuid ( const gchar *  task_id)

Return the schedule of a task.

Parameters
[in]task_idID of task.
Returns
Schedule.

◆ task_second_last_report()

static int task_second_last_report ( task_t  task,
report_t *  report 
)
static

Get the report from second most recently completed invocation of task.

Parameters
[in]taskThe task.
[out]reportReport return, 0 if successfully failed to select report.
Returns
0 success, -1 error.

◆ task_second_last_report_id()

gchar* task_second_last_report_id ( task_t  task)

Get report ID from second most recently completed invocation of task.

Parameters
[in]taskThe task.
Returns
The UUID of the report as a newly allocated string.

◆ task_severity()

char* task_severity ( task_t  task,
int  overrides,
int  min_qod,
int  offset 
)

Return the severity score of a task, taking overrides into account.

Only used by SQLite backend.

Parameters
[in]taskTask.
[in]overridesWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
[in]offsetOffset of report to get severity from: 0 = use last report, 1 = use next to last report
Returns
Severity score of last report on task if there is one, as a freshly allocated string, else NULL.

◆ task_severity_double()

static double task_severity_double ( task_t  task,
int  overrides,
int  min_qod,
int  offset 
)
static

Return the severity score of a task, taking overrides into account.

Parameters
[in]taskTask.
[in]overridesWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
[in]offsetOffset of report to get severity from: 0 = use last report, 1 = use next to last report
Returns
Severity score of last report on task as a double if there is one, else SEVERITY_MISSING.

◆ task_target()

target_t task_target ( task_t  task)

Return the target of a task.

Parameters
[in]taskTask.
Returns
Target of task.

◆ task_target_in_trash()

int task_target_in_trash ( task_t  task)

Return whether the target of a task is in the trashcan.

Parameters
[in]taskTask.
Returns
1 if in trash, else 0.

◆ task_trend()

const char* task_trend ( task_t  task,
int  override,
int  min_qod 
)

Return the trend of a task.

Only used by SQLite backend.

Parameters
[in]taskTask.
[in]overrideWhether to override the threat.
[in]min_qodThe minimum QoD of results to count.
Returns
"up", "down", "more", "less", "same" or if too few reports "".
Todo:
Either fail better or abort at SQL level.
Todo:
Either fail better or abort at SQL level.

◆ task_trend_calc()

static const char* task_trend_calc ( int  holes_a,
int  warns_a,
int  infos_a,
double  severity_a,
int  holes_b,
int  warns_b,
int  infos_b,
double  severity_b 
)
static

Return the trend of a task, given counts.

Parameters
[in]holes_aNumber of holes on earlier report.
[in]warns_aNumber of warnings on earlier report.
[in]infos_aNumber of infos on earlier report.
[in]severity_aSeverity of earlier report.
[in]holes_bNumber of holes on later report.
[in]warns_bNumber of warnings on later report.
[in]infos_bNumber of infos on later report.
[in]severity_bSeverity of later report.
Returns
"up", "down", "more", "less", "same" or if too few reports "".

◆ task_upload_progress()

int task_upload_progress ( task_t  task)

Return the upload progress of a task.

Parameters
[in]taskTask.
Returns
Task upload progress, as a percentage, or -1 on error.

◆ task_uuid()

int task_uuid ( task_t  task,
char **  id 
)

Return the UUID of a task.

Parameters
[in]taskTask.
[out]idPointer to a newly allocated string.
Returns
0.

◆ task_writable()

int task_writable ( task_t  task)

Return whether a task is writable.

Parameters
[in]taskTask.
Returns
1 if writable, else 0.

◆ threat_message_type()

const char* threat_message_type ( const char *  threat)

Get the message type of a threat.

Parameters
threatThreat.
Returns
Static message type name if threat names a threat, else NULL.

◆ trash_agent_in_use()

int trash_agent_in_use ( agent_t  agent)

Check whether a trashcan agent is writable.

Parameters
[in]agentAgent.
Returns
1 yes, 0 no.

◆ trash_agent_writable()

int trash_agent_writable ( agent_t  agent)

Check whether a trashcan agent is writable.

Parameters
[in]agentAgent.
Returns
1 yes, 0 no.

◆ trash_alert_in_use()

int trash_alert_in_use ( alert_t  alert)

Return whether a trashcan alert is in use by a task.

Parameters
[in]alertAlert.
Returns
1 if in use, else 0.

◆ trash_alert_writable()

int trash_alert_writable ( alert_t  alert)

Return whether a trashcan alert is writable.

Parameters
[in]alertAlert.
Returns
1 if writable, else 0.

◆ trash_config_in_use()

int trash_config_in_use ( config_t  config)

Return whether a trashcan config is referenced by a task.

Parameters
[in]configConfig.
Returns
1 if in use, else 0.

◆ trash_config_readable_uuid()

int trash_config_readable_uuid ( const gchar *  config_id)

Return whether a trashcan config is readable.

Parameters
[in]config_idConfig UUID.
Returns
1 if readable, else 0.

◆ trash_config_writable()

int trash_config_writable ( config_t  config)

Return whether a trashcan config is writable.

Parameters
[in]configConfig.
Returns
1 if in use, else 0.

◆ trash_credential_in_use()

int trash_credential_in_use ( credential_t  credential)

Check whether a trashcan Credential is in use.

Parameters
[in]credentialCredential.
Returns
1 yes, 0 no.

◆ trash_credential_name()

char* trash_credential_name ( credential_t  credential)

Get the name of an LSC credential in the trashcan.

Parameters
[in]credentialCredential.
Returns
Name.

◆ trash_credential_readable()

int trash_credential_readable ( credential_t  credential)

Return whether a trashcan credential is readable.

Parameters
[in]credentialCredential.
Returns
1 if readable, else 0.

◆ trash_credential_uuid()

char* trash_credential_uuid ( credential_t  credential)

Get the UUID of a Credential in the trashcan.

Parameters
[in]credentialCredential.
Returns
UUID.

◆ trash_credential_writable()

int trash_credential_writable ( credential_t  credential)

Check whether a trashcan Credential is writable.

Parameters
[in]credentialCredential.
Returns
1 yes, 0 no.

◆ trash_report_format_in_use()

int trash_report_format_in_use ( report_format_t  report_format)

Return whether a report format in trash is referenced by an alert.

Parameters
[in]report_formatReport Format.
Returns
1 if in use, else 0.

◆ trash_report_format_writable()

int trash_report_format_writable ( report_format_t  report_format)

Return whether a trashcan report_format is writable.

Parameters
[in]report_formatReport Format.
Returns
1 if writable, else 0.

◆ trash_scanner_in_use()

int trash_scanner_in_use ( scanner_t  scanner)

Check whether a trashcan scanner is writable.

Parameters
[in]scannerScanner.
Returns
1 yes, 0 no.

◆ trash_scanner_name()

char* trash_scanner_name ( scanner_t  scanner)

Return the name of a scanner in the trashcan.

Parameters
[in]scannerScanner.
Returns
Newly allocated name if available, else NULL.

◆ trash_scanner_readable()

int trash_scanner_readable ( scanner_t  scanner)

Return whether a trashcan scanner is readable.

Parameters
[in]scannerScanner.
Returns
1 if readable, else 0.

◆ trash_scanner_uuid()

char* trash_scanner_uuid ( scanner_t  scanner)

Return the UUID of a scanner in the trashcan.

Parameters
[in]scannerScanner.
Returns
Newly allocated UUID.

◆ trash_scanner_writable()

int trash_scanner_writable ( scanner_t  scanner)

Check whether a trashcan scanner is writable.

Parameters
[in]scannerScanner.
Returns
1 yes, 0 no.

◆ trash_schedule_in_use()

int trash_schedule_in_use ( schedule_t  schedule)

Return whether a trashcan schedule is in use by a task.

Parameters
[in]scheduleschedule.
Returns
1 if in use, else 0.

◆ trash_schedule_name()

char* trash_schedule_name ( schedule_t  schedule)

Return the name of a trash schedule.

Parameters
[in]scheduleSchedule.
Returns
Newly allocated name.

◆ trash_schedule_readable()

int trash_schedule_readable ( schedule_t  schedule)

Return whether a trashcan schedule is readable.

Parameters
[in]scheduleSchedule.
Returns
1 if readable, else 0.

◆ trash_schedule_uuid()

char* trash_schedule_uuid ( schedule_t  schedule)

Return the UUID of a trash schedule.

Parameters
[in]scheduleSchedule.
Returns
Newly allocated UUID.

◆ trash_schedule_writable()

int trash_schedule_writable ( schedule_t  schedule)

Return whether a trashcan schedule is writable.

Parameters
[in]scheduleSchedule.
Returns
1 if writable, else 0.

◆ trash_target_comment()

static char * trash_target_comment ( target_t  target)
static

Return the comment of a trashcan target.

Parameters
[in]targetTarget.
Returns
Newly allocated name if available, else NULL.

◆ trash_target_credential()

credential_t trash_target_credential ( target_t  target,
const char *  type 
)

Get a credential from a target in the trashcan.

Only used by SQLite backend.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ trash_target_credential_location()

int trash_target_credential_location ( target_t  target,
const char *  type 
)

Get whether a credential of a trash target is in trashcan.

Only used by SQLite backend.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ trash_target_exclude_hosts()

static char * trash_target_exclude_hosts ( target_t  target)
static

Return the excluded hosts associated with a trashcan target.

Parameters
[in]targetTarget.
Returns
Newly allocated comma separated list of excluded hosts if available, else NULL.

◆ trash_target_hosts()

static char * trash_target_hosts ( target_t  target)
static

Return the hosts associated with a trashcan target.

Parameters
[in]targetTarget.
Returns
Newly allocated comma separated list of hosts if available, else NULL.

◆ trash_target_in_use()

int trash_target_in_use ( target_t  target)

Return whether a trashcan target is referenced by a task.

Parameters
[in]targetTarget.
Returns
1 if in use, else 0.

◆ trash_target_login_port()

int trash_target_login_port ( target_t  target,
const char *  type 
)

Get a port from a target in the trashcan.

Only used by SQLite backend.

Parameters
[in]targetThe target.
[in]typeThe credential type (e.g. "ssh" or "smb").
Returns
0 on success, -1 on error, 1 credential not found, 99 permission denied.

◆ trash_target_name()

char* trash_target_name ( target_t  target)

Return the name of a trashcan target.

Parameters
[in]targetTarget.
Returns
Newly allocated name if available, else NULL.

◆ trash_target_readable()

int trash_target_readable ( target_t  target)

Return whether a trashcan target is readable.

Parameters
[in]targetTarget.
Returns
1 if readable, else 0.

◆ trash_target_uuid()

char* trash_target_uuid ( target_t  target)

Return the UUID of a trashcan target.

Parameters
[in]targetTarget.
Returns
Newly allocated UUID if available, else NULL.

◆ trash_target_writable()

int trash_target_writable ( target_t  target)

Return whether a trashcan target is writable.

Parameters
[in]targetTarget.
Returns
1 if writable, else 0.

◆ trash_task_in_use()

int trash_task_in_use ( task_t  task)

Return whether a trashcan task is referenced by a task.

Parameters
[in]taskTask.
Returns
0.

◆ trash_task_writable()

int trash_task_writable ( task_t  task)

Return whether a trashcan task is writable.

Parameters
[in]taskTask.
Returns
1 if writable, else 0.

◆ trim_hosts()

static gchar* trim_hosts ( gchar *  string)
static

Trim leading and trailing space from a hosts string.

Parameters
[in]stringString. May be modified.
Returns
Either string or some address within string.

◆ trim_partial_report()

void trim_partial_report ( report_t  report)

Prepare a partial report for resumption of the scan.

Parameters
[in]reportThe report.

◆ trim_report()

void trim_report ( report_t  report)

Prepare a partial report for restarting the scan from the beginning.

Parameters
[in]reportThe report.

◆ type_db_name()

static const char* type_db_name ( const char *  type)
static

Return DB name of type.

Parameters
[in]typeDatabase or pretty name.
Returns
Database name of type if possible, else NULL.

◆ type_has_comment()

static int type_has_comment ( const char *  type)
static

Check whether a type has a comment.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_has_trash()

static int type_has_trash ( const char *  type)
static

Check whether a resource type uses the trashcan.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_is_asset_subtype()

static int type_is_asset_subtype ( const char *  type)
static

Check whether a resource type is an asset subtype.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_is_info_subtype()

static int type_is_info_subtype ( const char *  type)
static

Check whether a resource type is an info subtype, excluding allinfo.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_named()

static int type_named ( const char *  type)
static

Check whether a type has a name and comment.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_owned()

static int type_owned ( const char *  type)
static

Check whether a resource type has an owner.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ type_trash_in_table()

static int type_trash_in_table ( const char *  type)
static

Check whether the trash is in the real table.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ tz_revert()

static int tz_revert ( gchar *  zone,
char *  tz,
char *  old_tz_override 
)
static

Restore original TZ.

Parameters
[in]zoneOnly revert if this is at least one character. Freed here always.
[in]tzOriginal TZ. Freed here if revert occurs.
[in]old_tz_overrideOriginal tz_override. Freed here on revert.
Returns
0 success, -1 error.

◆ update_all_config_caches()

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.

◆ update_config_cache()

static void update_config_cache ( iterator_t configs)
static

Update the cached count and growing information in a config.

It's up to the caller to organise a transaction.

Parameters
[in]configsConfig to update.

◆ update_config_cache_init()

void update_config_cache_init ( const char *  uuid)

Update count and growing info in config, without checking user.

For use during initialisation.

Parameters
[in]uuidConfig UUID.

It's up to the caller to organise a transaction.

◆ update_config_caches()

static void update_config_caches ( config_t  config)
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.

Parameters
[in]configConfig to update. 0 for all.

◆ update_config_params()

static void update_config_params ( config_t  config,
const char *  config_id,
GSList *  params 
)
static

Update a config with a list of parameters.

Parameters
[in]configConfig ID.
[in]config_idConfig UUID.
[in]paramsList of new config parameters.

◆ update_config_preference()

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.

Parameters
[in]config_idUUID of the config to set the preference in
[in]typeType of the preference, e.g. "PLUGINS_PREFS"
[in]preference_nameFull name of the preference
[in]new_valueThe new value to set
[in]insertWhether to insert the preference if missing

◆ update_duration_schedule_periods()

void update_duration_schedule_periods ( task_t  task)

Update tasks with limited run schedules which have durations.

If a task is given, assume that the task has finished. Otherwise only update the task if more time than the duration has passed the start time.

Parameters
[in]taskTask. 0 for all.

◆ update_nvt_family()

static int update_nvt_family ( const char *  oid,
const char *  old_family,
const char *  new_family 
)
static

Change the family of an NVT in all configs.

Parameters
[in]oidNVT OID.
[in]old_familyName of old family.
[in]new_familyName of new family.
Returns
0 success, -1 error.

◆ update_report_format_uuid()

static void update_report_format_uuid ( const char *  old,
const char *  new 
)
static

Bring UUIDs for single predefined report format up to date.

Parameters
[in]oldOld UUID.
[in]newNew UUID.

◆ user_ensure_in_db()

static int user_ensure_in_db ( const gchar *  name,
const gchar *  method 
)
static

Ensure the user exists in the database.

Parameters
[in]nameUser name.
[in]methodAuth method.
Returns
0 success.

◆ user_exists()

static int user_exists ( const gchar *  name)
static

Check if user exists.

Parameters
[in]nameUser name.
Returns
1 yes, 0 no.

◆ user_exists_method()

static int user_exists_method ( const gchar *  name,
auth_method_t  method 
)
static

Check if user exists.

Parameters
[in]nameUser name.
[in]methodAuth method.
Returns
1 yes, 0 no.

◆ user_uuid_any_method()

static gchar* user_uuid_any_method ( const gchar *  name)
static

Get user uuid, trying all authentication methods.

Parameters
[in]nameUser name.
Returns
UUID.

◆ user_uuid_method()

static gchar* user_uuid_method ( const gchar *  username,
auth_method_t  method 
)
static

Get user uuid.

Parameters
[in]usernameUser name.
[in]methodAuthentication method.
Returns
UUID.

◆ valid_gmp_command()

int valid_gmp_command ( const char *  name)

Check whether a command name is valid.

Parameters
[in]nameCommand name.
Returns
1 yes, 0 no.

◆ valid_type()

static int valid_type ( const char *  type)
static

Check whether a resource type name is valid.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ validate_alert_condition_data()

static int validate_alert_condition_data ( gchar *  name,
gchar *  data,
alert_condition_t  condition 
)
static

Validate condition data for an alert.

Parameters
[in]nameName.
[in]dataData to validate.
[in]conditionThe condition.
Returns
0 on success, 1 unexpected data name, 2 syntax error in data, 3 failed to find filter for condition, -1 internal error.

◆ validate_alert_event_data()

static int validate_alert_event_data ( gchar *  name,
gchar *  data,
event_t  event 
)
static

Validate event data for an alert.

Parameters
[in]nameName.
[in]dataData to validate.
[in]eventThe event.
Returns
0 on success, 1 unexpected data name, 2 syntax error in data.

◆ validate_credential_username()

static int validate_credential_username ( const gchar *  username)
static

Test if a username is valid to use in a credential.

Valid usernames may only contain alphanumeric characters and a few special ones to avoid problems with installer package generation.

Parameters
[in]usernameThe username string to test.
Returns
Whether the username is valid.

◆ validate_credential_username_for_format()

static gboolean validate_credential_username_for_format ( const gchar *  username,
credential_format_t  format 
)
static

Test if a username is valid for a credential export format.

Parameters
[in]usernameThe username string to test.
[in]formatThe credential format to validate for.
Returns
Whether the username is valid.

◆ validate_email()

static int validate_email ( const char *  address)
static

Validate an email address.

Parameters
[in]addressEmail address.
Returns
0 success, 1 failure.

◆ validate_email_data()

int validate_email_data ( alert_method_t  method,
const gchar *  name,
gchar **  data,
int  for_modify 
)

Validate method data for the email method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
[in]for_modifyWhether to return error codes for modify_alert.
Returns
0 valid, 2 or 6: validation of email address failed, 7 or 9 subject too long, 8 or 10 message too long, 60 recipient credential not found, 61 invalid recipient credential type, -1 error. When for_modify is 0, the first code is returned, otherwise the second one.

◆ validate_email_list()

static int validate_email_list ( const char *  list)
static

Validate an email address list.

Parameters
[in]listComma separated list of email addresses.
Returns
0 success, 1 failure.

◆ validate_param_value()

static int validate_param_value ( report_format_t  report_format,
report_format_param_t  param,
const char *  name,
const char *  value 
)
static

Validate a value for a report format param.

Parameters
[in]report_formatReport format.
[in]paramParam.
[in]nameName of param.
[in]valuePotential value of param.
Returns
0 success, 1 fail.

◆ validate_port()

static int validate_port ( const char *  port)
static

Validate a single port.

Parameters
[in]portA port.
Returns
0 success, 1 failed.

◆ validate_results_port()

static int validate_results_port ( const char *  port)
static

Validate a single port.

May come in values such as 100/foo and 100/foo (IANA: bar). Will also validate values such as: general/tcp.

Parameters
[in]portA port.
Returns
0 success, 1 failed.

◆ validate_scp_data()

static int validate_scp_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the SCP method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 15 error in SCP host, 17 failed to find report format for SCP method, 18 error in SCP credential, 19 error in SCP path, -1 error.

◆ validate_send_data()

static int validate_send_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the Send method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 12 error in Send host, 13 error in Send port, 14 failed to find report format for Send method, -1 error.

◆ validate_smb_data()

static int validate_smb_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the Send method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 40 invalid credential, 41 invalid SMB share path, 42 invalid SMB file path, 43 SMB file path contains dot, -1 error.

◆ validate_sourcefire_data()

static int validate_sourcefire_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the Sourcefire method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 80 credential not found, 81 invalid credential type

◆ validate_tippingpoint_data()

static int validate_tippingpoint_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the TippingPoint method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 50 invalid credential, 51 invalid hostname, 52 invalid certificate, 53 invalid TLS workaround setting.

◆ validate_username()

int validate_username ( const gchar *  name)

Validates a username.

Parameters
[in]nameThe name.
Returns
0 if the username is valid, 1 if not.

◆ validate_vfire_data()

static int validate_vfire_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)
static

Validate method data for the vFire alert method.

Parameters
[in]methodMethod that data corresponds to.
[in]nameName of data.
[in]dataThe data.
Returns
0 valid, 70 credential not found, 71 invalid credential type

◆ vector_find_filter()

static int vector_find_filter ( const gchar **  vector,
const gchar *  string 
)
static

Find a filter string in a glib style string vector.

Parameters
[in]vectorVector.
[in]stringString.
Returns
1 if found, 2 if found with underscore prefix, else NULL.

◆ vector_find_string()

static const gchar* vector_find_string ( const gchar **  vector,
const gchar *  string 
)
static

Find a string in a glib style string vector.

Parameters
[in]vectorVector.
[in]stringString.
Returns
The string from the vector if found, else NULL.

◆ verify_agent()

int verify_agent ( const char *  agent_id)

Verify an agent.

Parameters
[in]agent_idAgent UUID.
Returns
0 success, 1 failed to find agent, 99 permission denied, -1 error.

◆ verify_scanner()

int verify_scanner ( const char *  scanner_id,
char **  version 
)

Verify a scanner.

Parameters
[in]scanner_idScanner UUID.
[out]versionVersion returned by the scanner.
Returns
0 success, 1 failed to find scanner, 2 failed to get version, 3 no cert, 99 if permission denied, -1 error.

◆ verify_signature()

static int verify_signature ( const gchar *  installer,
gsize  installer_size,
const gchar *  signature,
gsize  signature_size,
int *  trust 
)
static

Execute gpg to verify an installer signature.

Parameters
[in]installerInstaller.
[in]installer_sizeSize of installer.
[in]signatureInstaller signature.
[in]signature_sizeSize of installer signature.
[out]trustTrust value.
Returns
0 success, -1 error.

◆ where_levels()

static GString* where_levels ( const char *  levels,
const char *  new_severity_sql 
)
static

Return SQL WHERE for restricting a SELECT to levels.

Parameters
[in]levelsString describing threat levels (message types) to include in report (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[in]new_severity_sqlSQL for new severity.
Returns
WHERE clause for levels if one is required, else NULL.

◆ where_levels_auto()

static GString* where_levels_auto ( const char *  levels,
const char *  new_severity_sql,
const char *  auto_type_sql 
)
static

Return SQL WHERE for restricting a SELECT to levels.

Parameters
[in]levelsString describing threat levels (message types) to include in report (for example, "hmlgd" for High, Medium, Low, loG and Debug). All levels if NULL.
[in]new_severity_sqlSQL for new severity.
[in]auto_type_sqlSQL for auto type.
Returns
WHERE clause for levels if one is required, else NULL.

◆ where_qod()

static gchar* where_qod ( int  min_qod)
static

Return SQL WHERE for restricting a SELECT to a minimum QoD.

Parameters
[in]min_qodMinimum value for QoD.
Returns
WHERE clause if one is required, else an empty string.

Variable Documentation

◆ authenticate_allow_all

int authenticate_allow_all

Flag to force authentication to succeed.

1 if set via scheduler, 2 if set via event, else 0.

Flag to force authentication to succeed.

1 if set via scheduler, 2 if set via event, else 0.

◆ max_attach_length

int max_attach_length = MAX_ATTACH_LENGTH
static

Maximum number of bytes of reports attached to email alerts.

A value less or equal to 0 allows any size.

◆ max_content_length

int max_content_length = MAX_CONTENT_LENGTH
static

Maximum number of bytes of reports included in email alerts.

A value less or equal to 0 allows any size.

◆ max_email_message_length

int max_email_message_length = MAX_EMAIL_MESSAGE_LENGTH
static

Maximum number of bytes of user-defined message text in email alerts.

A value less or equal to 0 allows any size.

◆ table_order_if_sort_not_specified

int table_order_if_sort_not_specified = 0
static

Flag to control the default sorting produced by split_filter.

If this is true, and the filter does not specify a sort field, then split_filter will not insert a default sort term, so that the random (and fast) table order in the database will be used.