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

The Greenbone Vulnerability Manager management library. More...

#include "debug_utils.h"
#include "manage_sql.h"
#include "manage_port_lists.h"
#include "manage_report_formats.h"
#include "manage_sql_secinfo.h"
#include "manage_sql_nvts.h"
#include "manage_tickets.h"
#include "manage_sql_configs.h"
#include "manage_sql_port_lists.h"
#include "manage_sql_report_formats.h"
#include "manage_sql_tickets.h"
#include "manage_sql_tls_certificates.h"
#include "manage_acl.h"
#include "manage_authentication.h"
#include "lsc_user.h"
#include "sql.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 <gnutls/x509.h>
#include <malloc.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/gvm_sentry.h>
#include <gvm/base/hosts.h>
#include <gvm/base/pwpolicy.h>
#include <gvm/base/logging.h>
#include <bsd/unistd.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...
 
struct  identifier_t
 Host identifier type. More...
 

Macros

#define _GNU_SOURCE
 Enable extra GNU functions.
 
#define G_LOG_DOMAIN   "md manage"
 GLib log domain.
 
#define LOCK_RETRIES   16
 Number of retries for LOCK TABLE .. IN ACCESS EXLUSIVE MODE NOWAIT statements.
 
#define LOCK_RETRY_DELAY   2
 Time of delay between two lock retries.
 
#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 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 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 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 PRE_BASE_RESULT_ITERATOR_COLUMNS(new_severity_sql)
 Result iterator columns.
 
#define BASE_RESULT_ITERATOR_COLUMNS    PRE_BASE_RESULT_ITERATOR_COLUMNS("lateral_new_severity.new_severity")
 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 CURRENT_SEVERITY_SQL
 SQL for getting current severity. 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 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 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 GROUP_ITERATOR_FILTER_COLUMNS    { GET_ITERATOR_FILTER_COLUMNS, NULL }
 Filter columns for group iterator.
 
#define GROUP_ITERATOR_COLUMNS
 Group iterator columns. More...
 
#define GROUP_ITERATOR_TRASH_COLUMNS
 Group iterator columns for trash case. More...
 
#define PERMISSION_ITERATOR_FILTER_COLUMNS
 Filter columns for permission iterator. More...
 
#define PERMISSION_ITERATOR_COLUMNS
 Permission iterator columns.
 
#define PERMISSION_ITERATOR_TRASH_COLUMNS
 Permission iterator columns for trash case.
 
#define ROLE_ITERATOR_FILTER_COLUMNS    { GET_ITERATOR_FILTER_COLUMNS, NULL }
 Filter columns for role iterator.
 
#define ROLE_ITERATOR_COLUMNS
 Role iterator columns. More...
 
#define ROLE_ITERATOR_TRASH_COLUMNS
 Role iterator columns for trash case. More...
 
#define FILTER_ITERATOR_FILTER_COLUMNS    { GET_ITERATOR_FILTER_COLUMNS, "type", "term", NULL }
 Filter columns for filter iterator.
 
#define FILTER_ITERATOR_COLUMNS
 Filter iterator columns. More...
 
#define FILTER_ITERATOR_TRASH_COLUMNS
 Filter iterator columns for trash case. More...
 
#define WHERE_OWNER
 Owner SQL for manage_empty_trash. More...
 
#define HOST_ITERATOR_FILTER_COLUMNS
 Filter columns for host iterator. More...
 
#define HOST_ITERATOR_COLUMNS
 Host iterator columns.
 
#define HOST_ITERATOR_WHERE_COLUMNS
 Host iterator WHERE columns. More...
 
#define OS_ITERATOR_FILTER_COLUMNS
 Filter columns for os iterator. More...
 
#define OS_ITERATOR_COLUMNS
 OS iterator columns.
 
#define OS_ITERATOR_WHERE_COLUMNS
 OS iterator optional filtering columns. More...
 
#define SETTING_ITERATOR_FILTER_COLUMNS    { "name", "comment", "value", NULL }
 Filter columns for setting iterator.
 
#define SETTING_ITERATOR_COLUMNS
 Setting iterator columns. More...
 
#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.
 

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...
 
int check_db_extensions ()
 Ensure all extensions are installed. 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...
 
int delete_reports (task_t)
 Delete all the reports for a task. 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...
 
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 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...
 
gchar * clean_hosts (const char *given_hosts, int *max)
 Clean a hosts string. More...
 
static gboolean find_user_by_name (const char *, user_t *user)
 
static gboolean find_role_with_permission (const char *uuid, role_t *role, const char *permission)
 Find a role for a specific permission, given a UUID. More...
 
static int user_ensure_in_db (const gchar *name, const gchar *method)
 Ensure the user exists in the database. More...
 
static int set_password (const gchar *, const gchar *, const gchar *, gchar **)
 
static void permissions_set_subjects (const char *type, resource_t old, resource_t new, int to)
 Adjust subject in permissions. More...
 
static resource_t permission_resource (permission_t permission)
 Return the resource of a permission. More...
 
static resource_t permission_subject (permission_t permission)
 Return the subject of a permission. More...
 
static char * permission_subject_type (permission_t permission)
 Return the subject type of a permission. More...
 
static int role_is_predefined (role_t role)
 Return whether a role is predefined. More...
 
static int role_is_predefined_id (const char *uuid)
 Return whether a role is predefined. More...
 
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 int report_counts_id_full (report_t report, int *holes, int *infos, int *logs, int *warnings, int *false_positives, double *severity, const get_data_t *get, const char *host, 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 gboolean find_group_with_permission (const char *uuid, group_t *group, const char *permission)
 Find a group for a specific permission, given a UUID. More...
 
static gchar * vulns_extra_where ()
 
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 char * permission_name (permission_t permission)
 Return the name of a permission. More...
 
static void cache_permissions_for_resource (const char *, resource_t, GArray *)
 
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 report_host)
 Tests if a report host is marked as dead. More...
 
static int report_host_result_count (report_host_t report_host)
 Counts. More...
 
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 *uuid, int *value)
 Get the value of a setting. More...
 
static int setting_auto_cache_rebuild_int ()
 Return the Auto Cache Rebuild user setting as an int. More...
 
static int setting_dynamic_severity_int ()
 Return the Dynamic Severity user setting as an int. More...
 
static char * setting_timezone ()
 Return the user's timezone. More...
 
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 filter)
 Return the UUID of a trashcan filter. More...
 
static char * trash_filter_name (filter_t filter)
 Return the name of a trashcan filter. 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 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...
 
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 db_conn_info_t *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 *notes, int *overrides, int *apply_overrides, gchar **zone)
 Get info from a result filter for a 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...
 
int valid_type (const char *type)
 Check whether a resource type name is valid. 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. More...
 
static int type_named (const char *type)
 Check whether a type has a name and comment. More...
 
static int type_globally_unique (const char *type)
 Check whether a type must have globally unique names. 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...
 
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, const char *extra_where_single, int owned, int ignore_id, const char *extra_order, const char *extra_with, int acl_with_optional, 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, const char *extra_where_single, 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, const char *extra_with, 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...
 
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...
 
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 db_conn_info_t *database)
 Encrypt or re-encrypt all credentials. More...
 
int manage_decrypt_all_credentials (GSList *log_config, const db_conn_info_t *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.
 
int manage_check_alerts (GSList *log_config, const db_conn_info_t *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_write_data_file (const char *directory, const char *filename, const char *content, gsize content_size, const char *description, gchar **file_path)
 Write data to a file for use by an 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 *username, const char *password, const char *private_key, 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 time_t alert_secinfo_count (alert_t alert, char *filter_id)
 Return the SecInfo count. 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 gchar * tasks_extra_where (int trash, const char *usage_type)
 Generate an extra WHERE clause for selecting tasks. 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...
 
const char * task_iterator_usage_type (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...
 
static int init_manage_open_db (const db_conn_info_t *database)
 Initialize the manage library: open db. More...
 
static void init_manage_create_functions ()
 Initialize the manage library: define SQL functions.
 
void init_manage_process (const db_conn_info_t *database)
 Initialize the manage library for a process. More...
 
void reinit_manage_process ()
 Reinitialize the manage library for a process. More...
 
nvti_t * lookup_nvti (const gchar *nvt)
 Update the memory cache of NVTs. 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 int check_db_scanners ()
 Ensure the predefined scanner exists. More...
 
static void check_db_settings ()
 Initialize the default settings. More...
 
static void add_role_permission (const gchar *role_id, const gchar *permission)
 Add command permission to role. More...
 
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 ()
 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 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 gchar * manage_migrate_relay_sensors ()
 Tries to migrate sensor type scanners to match the relays. More...
 
static int check_db (int check_encryption_key)
 Ensure that the database is in order. 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, const db_conn_info_t *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, const db_conn_info_t *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 db_conn_info_t *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 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...
 
void set_task_usage_type (task_t task, const char *usage_type)
 Set the usage_type of a task. 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 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...
 
void set_task_start_time_epoch (task_t task, int time)
 Set the start time of a task. More...
 
void set_task_start_time_ctime (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...
 
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 *hostname, const char *nvt, const char *type, const char *description, const char *port, const char *severity, int qod, const char *path)
 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, const char *path)
 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 char *host, const char *port, const char *path, char **oid, char **ref, char **product, char **location, char **name)
 Get product detection results corresponding to a given vulnerability detection result. More...
 
void init_app_locations_iterator (iterator_t *iterator, report_host_t report_host, const gchar *app)
 Initialize an iterator of locations of an App for a report's host. More...
 
const char * app_locations_iterator_location (iterator_t *iterator)
 Get a location from an app locations iterator. More...
 
void init_host_prognosis_iterator (iterator_t *iterator, report_host_t report_host)
 Initialise a report host prognosis iterator. More...
 
double prognosis_iterator_cvss_double (iterator_t *iterator)
 Get the CVSS from a result iterator as a double. 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_clear_count_cache (const gchar *uuid)
 Clear the report count cache for all reports of a user. More...
 
void reports_clear_count_cache_dynamic ()
 Clear all report counts for all dynamic severity users.
 
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 *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...
 
void report_compliance_by_uuid (const char *report_id, int *compliance_yes, int *compliance_no, int *compliance_incomplete)
 Get compliance counts for 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...
 
void report_add_results_array (report_t report, GArray *results)
 Add results from an array 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_auto (const char *levels, const char *new_severity_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 override, int dynamic)
 Generate the extra_tables string for a result iterator. More...
 
static gchar * new_severity_clause (int apply_overrides, int dynamic_severity)
 Get new severity clause. More...
 
static gchar * results_extra_where (int trash, report_t report, const gchar *host, int apply_overrides, int dynamic_severity, const gchar *filter, const gchar *given_new_severity_sql)
 Get extra_where string for a result iterator or count. 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...
 
static const gchar * result_iterator_lateral (int apply_overrides, int dynamic_severity)
 Get LATERAL clause for 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...
 
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...
 
const char * result_iterator_original_level (iterator_t *iterator)
 Get the original severity/threat level from a result iterator. More...
 
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_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...
 
gchar ** result_iterator_cert_bunds (iterator_t *iterator)
 Get CERT-BUNDs from a result iterator. More...
 
gchar ** result_iterator_dfn_certs (iterator_t *iterator)
 Get DFN-CERTs 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_solution_type (iterator_t *iterator)
 Get the NVT solution_type from a result iterator. More...
 
const char * result_iterator_nvt_solution_method (iterator_t *iterator)
 Get the NVT solution_method from a result iterator. More...
 
void xml_append_nvt_refs (GString *xml, const char *oid, int *first)
 Append an NVT's references to an XML string buffer. More...
 
int cleanup_result_nvts ()
 Check if the result_nvts are assigned to result. 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...
 
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...
 
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...
 
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_ctime (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_ctime (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_ctime (report_t report, const char *host, const char *timestamp)
 Set the end time of a scanned host. More...
 
void set_scan_host_start_time_ctime (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 update_report_modification_time (report_t report)
 Update modification_time of a report to current time. More...
 
int report_counts (const char *report_id, int *holes, int *infos, int *logs, int *warnings, int *false_positives, double *severity, int override, 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 *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 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...
 
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, 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 int streq_ignore_ws (const gchar *one, const gchar *two)
 Test if two strings are equal, ignoring whitespace. 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, optionally 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...
 
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...
 
char * report_finished_hosts_str (report_t report)
 Get a list string of finished hosts in a report. More...
 
static int print_report_host_detail (FILE *stream, iterator_t *details, int lean)
 Write report host detail to file stream. More...
 
static int print_report_host_details_xml (report_host_t report_host, FILE *stream, int lean)
 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_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, iterator_t *results)
 Print the XML for a report port summary to a file. More...
 
int report_progress (report_t report)
 Calculate the progress of a report. 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_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, int notes_details, int overrides_details, int result_tags, int ignore_pagination, int lean, gchar **filter_term_return, gchar **zone_return, gchar **host_summary)
 Print the main XML content for a report to a file. 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, gsize *output_length, gchar **extension, gchar **content_type, gchar **filter_term_return, gchar **zone_return, gchar **host_summary)
 Generate a report. 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 lean, 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 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 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...
 
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...
 
static int delete_task_lock (task_t task, int ultimate)
 Complete deletion of a 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...
 
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, for use in override or note. 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...
 
int target_login_port (target_t target, const char *type)
 Get a login port from a target. 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, credential_t ssh_elevate_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, const char *allow_simultaneous_ips, 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_elevate_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, const char *allow_simultaneous_ips)
 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...
 
int target_iterator_ssh_elevate_credential (iterator_t *iterator)
 Get the ELEVATE LSC credential from a target iterator. More...
 
int target_iterator_ssh_elevate_trash (iterator_t *iterator)
 Get the ELEVATE 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_allow_simultaneous_ips (target_t target)
 Return the allow_simultaneous_ips 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...
 
credential_t target_ssh_elevate_credential (target_t target)
 Return the ELEVATE 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 GMP port range list 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...
 
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...
 
int check_private_key (const char *key_str, const char *key_phrase)
 Check that a string represents a valid Private Key. 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...
 
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...
 
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 db_conn_info_t *database, const char *name, const char *host, const char *port, const char *type, const char *ca_pub_path, const char *credential_id, const char *key_pub_path, const char *key_priv_path)
 Create the given scanner. More...
 
int manage_delete_scanner (GSList *log_config, const db_conn_info_t *database, const gchar *uuid)
 Delete the given scanner. More...
 
int manage_modify_scanner (GSList *log_config, const db_conn_info_t *database, const char *scanner_id, const char *name, const char *host, const char *port, const char *type, const char *ca_pub_path, const char *credential_id, const char *key_pub_path, const char *key_priv_path)
 Modify the given scanner. More...
 
int manage_verify_scanner (GSList *log_config, const db_conn_info_t *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...
 
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...
 
char * openvas_default_scanner_host ()
 Get the default scanner path or host. More...
 
static osp_connection_t * osp_scanner_relay_connect (const char *host, int port, const char *ca_pub, const char *key_pub, const char *key_priv)
 Create a new connection to an OSP scanner relay. More...
 
osp_connection_t * osp_connect_with_data (const char *host, int port, const char *ca_pub, const char *key_pub, const char *key_priv)
 Create a new connection to an OSP scanner using the scanner data. 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...
 
int verify_scanner (const char *scanner_id, char **version)
 Verify a scanner. More...
 
int manage_get_scanners (GSList *log_config, const db_conn_info_t *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...
 
int create_schedule (const char *name, const char *comment, const char *ical_string, 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, 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...
 
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, const char *zone, gchar **error_out)
 Modify a schedule. More...
 
int copy_group (const char *name, const char *comment, const char *group_id, group_t *new_group_return)
 Create a group from an existing group. More...
 
static int add_users (const gchar *type, resource_t resource, const char *users)
 Add users to a group. More...
 
int create_group (const char *group_name, const char *comment, const char *users, int special_full, group_t *group)
 Create a group. More...
 
int delete_group (const char *group_id, int ultimate)
 Delete a group. More...
 
char * group_uuid (group_t group)
 Return the UUID of a group. More...
 
gchar * group_users (group_t group)
 Gets users of group as a string. More...
 
int group_writable (group_t group)
 Check whether a group is writable. More...
 
int trash_group_writable (group_t group)
 Check whether a trashcan group is writable. More...
 
int group_in_use (group_t group)
 Check whether a group is in use. More...
 
int trash_group_in_use (group_t group)
 Check whether a trashcan group is in use. More...
 
int group_count (const get_data_t *get)
 Count number of groups. More...
 
int init_group_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a group iterator, including observed groups. More...
 
int modify_group (const char *group_id, const char *name, const char *comment, const char *users)
 Modify a group. More...
 
void permissions_set_locations (const char *type, resource_t old, resource_t new, int to)
 Adjust location of resource in permissions. More...
 
void permissions_set_orphans (const char *type, resource_t resource, int location)
 Set permissions to orphan. More...
 
static gboolean find_permission (const char *uuid, permission_t *permission)
 Find a permission given a UUID. More...
 
static int check_permission_args (const char *name_arg, const char *resource_type_arg, const char *resource_id_arg, const char *subject_type, const char *subject_id, gchar **name, resource_t *resource, char **resource_type, const char **resource_id, resource_t *subject)
 Check args for create_permission or modify_permission. More...
 
static gchar * subject_where_clause (const char *subject_type, resource_t subject)
 Create a SQL clause to select the subject users. More...
 
int create_permission_internal (int check_access, const char *name_arg, const char *comment, const char *resource_type_arg, const char *resource_id_arg, const char *subject_type, const char *subject_id, permission_t *permission)
 Create a permission. More...
 
int create_permission (const char *name_arg, const char *comment, const char *resource_type_arg, const char *resource_id_arg, const char *subject_type, const char *subject_id, permission_t *permission)
 Create a permission. More...
 
int create_permission_no_acl (const char *name_arg, const char *comment, const char *resource_type_arg, const char *resource_id_arg, const char *subject_type, const char *subject_id, permission_t *permission)
 Create a permission. More...
 
int copy_permission (const char *comment, const char *permission_id, permission_t *new_permission)
 Create a permission from an existing permission. More...
 
char * permission_uuid (permission_t permission)
 Return the UUID of a permission. More...
 
static char * permission_subject_id (permission_t permission)
 Return the UUID of the subject of a permission. More...
 
static char * permission_resource_type (permission_t permission)
 Return the resource type of a permission. More...
 
static char * permission_resource_id (permission_t permission)
 Return the UUID of the resource of a permission. More...
 
static int permission_is_predefined (permission_t permission)
 Return whether a permission is predefined. More...
 
int permission_is_admin (const char *permission_id)
 Test whether a permission is the special Admin permission. More...
 
int permission_in_use (permission_t permission)
 Return whether a permission is in use. More...
 
int trash_permission_in_use (permission_t permission)
 Return whether a trashcan permission is referenced by a task. More...
 
int permission_writable (permission_t permission)
 Return whether a permission is writable. More...
 
int trash_permission_writable (permission_t permission)
 Return whether a trashcan permission is writable. More...
 
int permission_count (const get_data_t *get)
 Count number of permissions. More...
 
int init_permission_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a permission iterator. More...
 
int permission_iterator_resource_in_trash (iterator_t *iterator)
 Return the permission resource location. More...
 
int permission_iterator_resource_orphan (iterator_t *iterator)
 Check if the permission resource has been deleted. More...
 
int permission_iterator_resource_readable (iterator_t *iterator)
 Get the readable status of a resource from a permission iterator. More...
 
int permission_iterator_subject_in_trash (iterator_t *iterator)
 Return the permission subject location. More...
 
int permission_iterator_subject_readable (iterator_t *iterator)
 Get the readable status of a subject from a permission iterator. More...
 
static gboolean find_permission_with_permission (const char *uuid, permission_t *resource, const char *permission)
 Find a permission with a given permission, given a UUID. More...
 
int delete_permission (const char *permission_id, int ultimate)
 Delete a permission. More...
 
int modify_permission (const char *permission_id, const char *name_arg, const char *comment, const char *resource_id_arg, const char *resource_type_arg, const char *subject_type, const char *subject_id)
 Modify a permission. More...
 
static void add_feed_role_permissions (const char *type, const char *type_cap, int *permission_count, int *object_count)
 Add role permissions to feed objects according to the 'Feed Import Roles' setting. More...
 
static void clean_feed_role_permissions (const char *type, const char *type_cap, int *permission_count, int *object_count)
 Delete permissions to feed objects for roles that are not set in the 'Feed Import Roles' setting. More...
 
int manage_get_roles (GSList *log_config, const db_conn_info_t *database, int verbose)
 List roles. More...
 
int copy_role (const char *name, const char *comment, const char *role_id, role_t *new_role_return)
 Create a role from an existing role. More...
 
int create_role (const char *role_name, const char *comment, const char *users, role_t *role)
 Create a role. More...
 
int delete_role (const char *role_id, int ultimate)
 Delete a role. More...
 
static gboolean find_role_by_name (const char *name, role_t *role)
 Find a role given a name. More...
 
gchar * role_uuid (role_t role)
 Gets UUID of role. More...
 
gchar * role_users (role_t role)
 Gets users of role as a string. More...
 
int role_writable (role_t role)
 Check whether a role is writable. More...
 
int trash_role_writable (role_t role)
 Check whether a trashcan role is writable. More...
 
int role_in_use (role_t role)
 Check whether a role is in use. More...
 
int trash_role_in_use (role_t role)
 Check whether a trashcan role is in use. More...
 
int modify_role (const char *role_id, const char *name, const char *comment, const char *users)
 Modify a role. More...
 
int role_count (const get_data_t *get)
 Count number of roles. More...
 
int init_role_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a role iterator, including observed roles. More...
 
gboolean find_filter_with_permission (const char *uuid, filter_t *filter, const char *permission)
 Find a filter for a specific permission, given a UUID. More...
 
char * filter_uuid (filter_t filter)
 Return the UUID of a filter. More...
 
char * filter_name (filter_t filter)
 Return the name of a filter. More...
 
gchar * filter_term (const char *uuid)
 Return the term of a filter. More...
 
gchar * filter_term_value (const char *term, const char *column)
 Return the value of a column keyword of a filter term. More...
 
int filter_term_apply_overrides (const char *term)
 Return the value of the apply_overrides keyword of a filter term. More...
 
int filter_term_min_qod (const char *term)
 Return the value of the min_qod keyword of a filter term. More...
 
int create_filter (const char *name, const char *comment, const char *type, const char *term, filter_t *filter)
 Create a filter. More...
 
int copy_filter (const char *name, const char *comment, const char *filter_id, filter_t *new_filter)
 Create a filter from an existing filter. More...
 
int delete_filter (const char *filter_id, int ultimate)
 Delete a filter. More...
 
int filter_in_use (filter_t filter)
 Check whether a filter is in use. More...
 
static int filter_in_use_for_output (filter_t filter)
 Check whether a filter is in use for the output of any alert. More...
 
static int filter_in_use_for_result_event (filter_t filter)
 Check whether a filter is in use by any result alert conditions. More...
 
static int filter_in_use_for_secinfo_event (filter_t filter)
 Check whether a filter is in use by any secinfo alert conditions. More...
 
int trash_filter_in_use (filter_t filter)
 Check whether a trashcan filter is in use. More...
 
int filter_writable (filter_t filter)
 Check whether a filter is writable. More...
 
int trash_filter_writable (filter_t filter)
 Check whether a trashcan filter is writable. More...
 
int filter_count (const get_data_t *get)
 Count number of filters. More...
 
int init_filter_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a filter iterator, including observed filters. More...
 
const char * filter_iterator_type (iterator_t *iterator)
 Get the type from a filter iterator. More...
 
void init_filter_alert_iterator (iterator_t *iterator, filter_t filter)
 Initialise a filter alert iterator. More...
 
int filter_alert_iterator_readable (iterator_t *iterator)
 Get the read permission status from a GET iterator. More...
 
int modify_filter (const char *filter_id, const char *name, const char *comment, const char *term, const char *type)
 Modify a filter. More...
 
int manage_schema (gchar *format, gchar **output_return, gsize *output_length, gchar **extension, gchar **content_type)
 Generate the GMP schema. More...
 
int manage_restore (const char *id)
 Restore a resource from the trashcan. More...
 
int manage_empty_trashcan ()
 Empty the trashcan. More...
 
char * result_host_asset_id (const char *host, result_t result)
 Return the UUID of the asset associated with a result host. More...
 
char * host_uuid (resource_t host)
 Return the UUID of a host. More...
 
report_host_t manage_report_host_add (report_t report, const char *host, time_t start, time_t end)
 Add a report host. More...
 
void report_host_set_end_time (report_host_t report_host, time_t end_time)
 Set end time of a report host. More...
 
static void identifier_free (identifier_t *identifier)
 Free an identifier. More...
 
void hosts_set_identifiers (report_t report)
 Setup hosts and their identifiers after a scan, from host details. More...
 
void hosts_set_max_severity (report_t report, int *overrides_arg, int *min_qod_arg)
 Set the maximum severity of each host in a scan. More...
 
void hosts_set_details (report_t report)
 Store certain host details in the assets after a scan. More...
 
gchar * host_routes_xml (host_t host)
 Get XML of a detailed host route. More...
 
int manage_report_host_details (report_t report, const char *ip, entity_t entity)
 Add host details to a report host. More...
 
int manage_report_host_detail (report_t report, const char *host, const char *xml)
 Add a host detail to a report host. More...
 
void init_host_identifier_iterator (iterator_t *iterator, host_t host, int ascending, const char *sort_field)
 Initialise a host identifier iterator. More...
 
int host_identifier_iterator_source_orphan (iterator_t *iterator)
 Get the source orphan state from a host identifier iterator. More...
 
int init_asset_host_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a host iterator. More...
 
int asset_iterator_writable (iterator_t *iterator)
 Get the writable status from an asset iterator. More...
 
int asset_iterator_in_use (iterator_t *iterator)
 Get the "in use" status from an asset iterator. More...
 
int asset_host_count (const get_data_t *get)
 Count number of hosts. More...
 
static gchar * asset_os_iterator_opts_table ()
 Generate the extra_tables string for an OS iterator. More...
 
int init_asset_os_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise an OS iterator. More...
 
int asset_os_iterator_installs (iterator_t *iterator)
 Get the number of installs from an asset OS iterator. More...
 
int asset_os_count (const get_data_t *get)
 Count number of oss. More...
 
void init_os_host_iterator (iterator_t *iterator, resource_t os)
 Initialise an OS host iterator. More...
 
void init_host_detail_iterator (iterator_t *iterator, resource_t host)
 Initialise an asset host detail iterator. More...
 
static gboolean find_host_with_permission (const char *uuid, host_t *host, const char *permission)
 Find a host for a specific permission, given a UUID. More...
 
static int identifier_name (const char *name)
 Check whether a string is an identifier name. More...
 
int create_asset_host (const char *host_name, const char *comment, resource_t *host_return)
 Create a host asset. More...
 
int create_asset_report (const char *report_id, const char *term)
 Create all available assets from a report. More...
 
int modify_asset (const char *asset_id, const char *comment)
 Modify an asset. More...
 
static int delete_report_assets (const char *report_id)
 Delete all asset that came from a report. More...
 
int delete_asset (const char *asset_id, const char *report_id, int dummy)
 Delete an asset. More...
 
int add_assets_from_host_in_report (report_t report, const char *host_ip)
 Generates and adds assets from report host details. More...
 
int setting_count (const char *filter)
 Count number of settings. More...
 
char * setting_filter (const char *resource)
 Return the uuid of a resource filter from settings. More...
 
void init_setting_iterator (iterator_t *iterator, const char *uuid, const char *filter, int first, int max, int ascending, const char *sort_field)
 Initialise a setting iterator, including observed settings. More...
 
int setting_value (const char *uuid, char **value)
 Get the value of a setting as a string. More...
 
int modify_setting (const gchar *uuid, const gchar *name, const gchar *value_64, gchar **r_errdesc)
 Set the value of a setting. 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 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.
 
db_conn_info_t gvmd_db_conn_info = { NULL, NULL, 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.
 
static gchar * vt_verification_collation = NULL
 The VT verification collation override.
 
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...
 
int ignore_max_rows_per_page = 0
 Whether to ignore the Max Rows Per Page settings.
 
array_t * identifiers = NULL
 Host identifiers for the current scan.
 
static array_t * identifier_hosts = NULL
 Unique hosts listed in host_identifiers.
 

Detailed Description

The Greenbone Vulnerability Manager management library.

Macro Definition Documentation

◆ 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 \
{ \
if (message) \
*message = g_strdup ("Mandatory " G_STRINGIFY(param) " missing."); \
g_warning ("%s: Missing " G_STRINGIFY(param) ".", __func__); \
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.

◆ CURRENT_SEVERITY_SQL

#define CURRENT_SEVERITY_SQL
Value:
"coalesce ((CASE WHEN results.severity > " G_STRINGIFY (SEVERITY_LOG) \
" THEN CAST (nvts.cvss_base AS double precision)" \
" ELSE results.severity" \
" END)," \
" results.severity)"

SQL for getting current severity.

◆ 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 columns.

◆ 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 } \
}

Filter iterator columns for trash case.

◆ GROUP_ITERATOR_COLUMNS

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

Group iterator columns.

◆ GROUP_ITERATOR_TRASH_COLUMNS

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

Group iterator columns for trash case.

◆ HOST_ITERATOR_FILTER_COLUMNS

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

Filter columns for host iterator.

◆ 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 } \
}

Host iterator WHERE columns.

◆ 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.

◆ 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 }

Filter columns for os iterator.

◆ 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 } \
}

OS iterator optional filtering columns.

◆ 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 }

Filter columns for permission iterator.

◆ 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.

◆ REPORT_ITERATOR_COLUMNS

#define REPORT_ITERATOR_COLUMNS
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (creation_time)", "name", 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 = reports.owner)", \
"_owner", \
KEYWORD_TYPE_STRING }, \
{ "owner", NULL, KEYWORD_TYPE_INTEGER }, \
{ "start_time", "scan_start", KEYWORD_TYPE_INTEGER }, \
{ "end_time", "scan_end", 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", "creation_time", \
"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", "start_time", "end_time", "scan_start", "scan_end", \
NULL }

Filter columns for report iterator.

◆ RESULT_ITERATOR_COLUMNS

#define RESULT_ITERATOR_COLUMNS
Value:
{ \
BASE_RESULT_ITERATOR_COLUMNS \
{ SECINFO_SQL_RESULT_CERT_BUNDS, \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ SECINFO_SQL_RESULT_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 \
{ 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", \
"description", "task", "report", "cvss_base", "nvt_version", \
"severity", "original_severity", "vulnerability", "date", "report_id", \
"solution_type", "qod", "qod_type", "task_id", "cve", "hostname", \
"path", 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 columns.

◆ ROLE_ITERATOR_TRASH_COLUMNS

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

Role iterator columns for trash case.

◆ 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 }, \
{ "duration", NULL, KEYWORD_TYPE_INTEGER }, \
{ "timezone", NULL, KEYWORD_TYPE_STRING }, \
{ "icalendar", NULL, KEYWORD_TYPE_STRING }, \
{ "next_time_ical (icalendar, m_now()::bigint, 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", "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 }, \
{ "duration", NULL, KEYWORD_TYPE_INTEGER }, \
{ "timezone", NULL, KEYWORD_TYPE_STRING }, \
{ "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 } \
}

Setting iterator columns.

◆ 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", \
"ssh_elevate_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", "usage_type", 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_COLUMNS

#define USER_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (users), \
{ "method", NULL, KEYWORD_TYPE_STRING }, \
{ "hosts", NULL, KEYWORD_TYPE_STRING }, \
{ "hosts_allow", NULL, KEYWORD_TYPE_INTEGER }, \
{ \
"coalesce ((SELECT group_concat (name, ', ')" \
" FROM (SELECT DISTINCT name, order_role (name)" \
" FROM roles, role_users" \
" WHERE role_users.role = roles.id" \
" AND \"user\" = users.id" \
" ORDER BY order_role (roles.name) ASC)" \
" AS user_iterator_sub)," \
" '')", \
"roles", \
KEYWORD_TYPE_STRING \
}, \
{ \
"coalesce ((SELECT group_concat (name, ', ')" \
" FROM (SELECT DISTINCT name FROM groups, group_users" \
" WHERE group_users.\"group\" = groups.id" \
" AND \"user\" = users.id" \
" ORDER BY groups.name ASC)" \
" AS user_iterator_sub)," \
" '')", \
"groups", \
KEYWORD_TYPE_STRING \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ USER_ITERATOR_FILTER_COLUMNS

#define USER_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "method", "roles", "groups", "hosts", \
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 }, \
{ 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\" = gvmd_user ()" \
" AND task = results.task)"

◆ WHERE_OWNER

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

Owner SQL for manage_empty_trash.

Function Documentation

◆ add_assets_from_host_in_report()

int add_assets_from_host_in_report ( report_t  report,
const char *  host_ip 
)

Generates and adds assets from report host details.

Parameters
[in]reportThe report to get host details from.
[in]host_ipIP address of the host to get details from.
Returns
0 success, -1 error.

◆ add_feed_role_permissions()

static void add_feed_role_permissions ( const char *  type,
const char *  type_cap,
int *  permission_count,
int *  object_count 
)
static

Add role permissions to feed objects according to the 'Feed Import Roles' setting.

Parameters
[in]typeThe object type, e.g. report_format.
[in]type_capCapitalized type, e.g. "Report Format"
[out]permission_countNumber of permissions added.
[out]object_countNumber of data objects affected.

◆ 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_id,
const gchar *  permission 
)
static

Add command permission to role.

Caller must ensure args are SQL escaped.

Parameters
[in]role_idRole.
[in]permissionPermission.

◆ add_role_permission_resource()

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

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.

◆ add_users()

static int add_users ( const gchar *  type,
resource_t  resource,
const char *  users 
)
static

Add users to a group.

Caller must take care of transaction.

Parameters
[in]typeType.
[in]resourceGroup or role.
[in]usersList of users.
Returns
0 success, 2 failed to find user, 4 user name validation failed, 99 permission denied, -1 error.

◆ 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_secinfo_count()

static time_t alert_secinfo_count ( alert_t  alert,
char *  filter_id 
)
static

Return the SecInfo count.

Parameters
[in]alertAlert.
[in]filter_idCondition filter id.
Returns
1 if met, else 0.

◆ 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.

◆ alert_write_data_file()

static int alert_write_data_file ( const char *  directory,
const char *  filename,
const char *  content,
gsize  content_size,
const char *  description,
gchar **  file_path 
)
static

Write data to a file for use by an alert script.

Parameters
[in]directoryBase directory to create the file in
[in]filenameFilename without directory
[in]contentThe file content
[in]content_sizeSize of the file content
[in]descriptionShort file description for error messages
[out]file_pathReturn location of combined file path
Returns
0 success, -1 error

◆ 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_locations_iterator_location()

const char* app_locations_iterator_location ( iterator_t iterator)

Get a location from an app locations iterator.

Parameters
[in]iteratorIterator.
Returns
The location.

◆ 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.

◆ 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.

◆ asset_host_count()

int asset_host_count ( const get_data_t get)

Count number of hosts.

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

◆ asset_iterator_in_use()

int asset_iterator_in_use ( iterator_t iterator)

Get the "in use" status from an asset iterator.

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

◆ asset_iterator_writable()

int asset_iterator_writable ( iterator_t iterator)

Get the writable status from an asset iterator.

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

◆ asset_os_count()

int asset_os_count ( const get_data_t get)

Count number of oss.

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

◆ asset_os_iterator_installs()

int asset_os_iterator_installs ( iterator_t iterator)

Get the number of installs from an asset OS iterator.

Parameters
[in]iteratorIterator.
Returns
Number of hosts that have the OS.

◆ asset_os_iterator_opts_table()

static gchar* asset_os_iterator_opts_table ( )
static

Generate the extra_tables string for an OS iterator.

Returns
Newly allocated string.

◆ 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,
int  lean 
)

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.
[in]leanWhether to include less info.

◆ 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.

◆ 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_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_extensions()

int check_db_extensions ( )

Ensure all extensions are installed.

Returns
0 success, 1 extension missing.

◆ 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_versions()

static int check_db_versions ( )
static

Ensure that the databases are the right versions.

Returns
0 success, -1 error, -2 database is wrong version.

◆ check_permission_args()

static int check_permission_args ( const char *  name_arg,
const char *  resource_type_arg,
const char *  resource_id_arg,
const char *  subject_type,
const char *  subject_id,
gchar **  name,
resource_t resource,
char **  resource_type,
const char **  resource_id,
resource_t subject 
)
static

Check args for create_permission or modify_permission.

Parameters
[in]name_argName of permission.
[in]resource_type_argType of resource, for special permissions.
[in]resource_id_argUUID of resource.
[in]subject_typeType of subject.
[in]subject_idUUID of subject.
[out]nameName return.
[out]resourceResource return.
[out]resource_typeResource type return.
[out]resource_idResource ID return.
[out]subjectSubject return.
Returns
0 success, 2 failed to find subject, 3 failed to find resource, 5 error in resource, 6 error in subject, 7 error in name, 8 permission on permission, 9 permission does not accept resource, 99 permission denied, -1 error.

◆ check_private_key()

int check_private_key ( const char *  key_str,
const char *  key_phrase 
)

Check that a string represents a valid Private Key.

Parameters
[in]key_strPrivate Key string.
[in]key_phrasePrivate Key passphrase.
Returns
0 if valid, 1 otherwise.

◆ clean_feed_role_permissions()

static void clean_feed_role_permissions ( const char *  type,
const char *  type_cap,
int *  permission_count,
int *  object_count 
)
static

Delete permissions to feed objects for roles that are not set in the 'Feed Import Roles' setting.

Parameters
[in]typeThe object type, e.g. report_format.
[in]type_capCapitalized type, e.g. "Report Format"
[out]permission_countNumber of permissions added.
[out]object_countNumber of data objects affected.

◆ 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_result_nvts()

int cleanup_result_nvts ( )

Check if the result_nvts are assigned to result.

Returns
0 success, -1 error

◆ 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, optionally writing associated XML to a buffer.

This is called with buffer NULL to compare results after the page limit (filter keyword "max") is reached. These results need to be compared to be included in the counts.

Parameters
[in]bufferBuffer. NULL to skip writing to buffer.
[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_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.

◆ 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_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_filter()

int copy_filter ( const char *  name,
const char *  comment,
const char *  filter_id,
filter_t *  new_filter 
)

Create a filter from an existing filter.

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

◆ copy_group()

int copy_group ( const char *  name,
const char *  comment,
const char *  group_id,
group_t *  new_group_return 
)

Create a group from an existing group.

Parameters
[in]nameName of new group. NULL to copy from existing.
[in]commentComment on new group. NULL to copy from existing.
[in]group_idUUID of existing group.
[out]new_group_returnNew group.
Returns
0 success, 1 group exists already, 2 failed to find existing group, 99 permission denied, -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_permission()

int copy_permission ( const char *  comment,
const char *  permission_id,
permission_t *  new_permission 
)

Create a permission from an existing permission.

Parameters
[in]commentComment on new permission. NULL to copy from existing.
[in]permission_idUUID of existing permission.
[out]new_permissionNew permission.
Returns
0 success, 1 permission exists already, 2 failed to find existing permission, 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()

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.

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_role()

int copy_role ( const char *  name,
const char *  comment,
const char *  role_id,
role_t *  new_role_return 
)

Create a role from an existing role.

Parameters
[in]nameName of new role. NULL to copy from existing.
[in]commentComment on new role. NULL to copy from existing.
[in]role_idUUID of existing role.
[out]new_role_returnNew role.
Returns
0 success, 1 role exists already, 2 failed to find existing role, 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. < 0 to to copy from existing.
[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,
const char *  extra_with,
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]extra_withExtra WITH clauses.
[in]ownedOnly count items owned by current user.
Returns
Total number of resources in filtered set.

◆ 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_asset_host()

int create_asset_host ( const char *  host_name,
const char *  comment,
resource_t host_return 
)

Create a host asset.

Parameters
[in]host_nameHost Name.
[in]commentComment.
[out]host_returnCreated asset.
Returns
0 success, 1 failed to find report, 2 host not an IP address, 99 permission denied, -1 error.

◆ create_asset_report()

int create_asset_report ( const char *  report_id,
const char *  term 
)

Create all available assets from a report.

Parameters
[in]report_idUUID of report.
[in]termFilter term, for min_qod and apply_overrides.
Returns
0 success, 1 failed to find report, 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_filter()

int create_filter ( const char *  name,
const char *  comment,
const char *  type,
const char *  term,
filter_t *  filter 
)

Create a filter.

Parameters
[in]nameName of filter.
[in]commentComment on filter.
[in]typeType of resource.
[in]termFilter term.
[out]filterCreated filter.
Returns
0 success, 1 filter exists already, 2 error in type, 99 permission denied.

◆ create_group()

int create_group ( const char *  group_name,
const char *  comment,
const char *  users,
int  special_full,
group_t *  group 
)

Create a group.

Parameters
[in]group_nameGroup name.
[in]commentComment on group.
[in]usersUsers group applies to.
[in]special_fullWhether to give group super on itself (full sharing between members).
[out]groupGroup return.
Returns
0 success, 1 group exists already, 2 failed to find user, 4 user name validation failed, 99 permission denied, -1 error.

◆ 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_permission()

int create_permission ( const char *  name_arg,
const char *  comment,
const char *  resource_type_arg,
const char *  resource_id_arg,
const char *  subject_type,
const char *  subject_id,
permission_t *  permission 
)

Create a permission.

Parameters
[in]name_argName of permission.
[in]commentComment on permission.
[in]resource_type_argType of resource, for special permissions.
[in]resource_id_argUUID of resource.
[in]subject_typeType of subject.
[in]subject_idUUID of subject.
[out]permissionPermission.
Returns
0 success, 2 failed to find subject, 3 failed to find resource, 5 error in resource, 6 error in subject, 7 error in name, 8 permission on permission, 9 permission does not accept resource, 99 permission denied, -1 internal error.

◆ create_permission_internal()

int create_permission_internal ( int  check_access,
const char *  name_arg,
const char *  comment,
const char *  resource_type_arg,
const char *  resource_id_arg,
const char *  subject_type,
const char *  subject_id,
permission_t *  permission 
)

Create a permission.

Caller must organise the transaction.

Parameters
[in]check_accessWhether to check if user may CREATE_PERMISSION.
[in]name_argName of permission.
[in]commentComment on permission.
[in]resource_type_argType of resource, for special permissions.
[in]resource_id_argUUID of resource.
[in]subject_typeType of subject.
[in]subject_idUUID of subject.
[out]permissionPermission.
Returns
0 success, 2 failed to find subject, 3 failed to find resource, 5 error in resource, 6 error in subject, 7 error in name, 8 permission on permission, 9 permission does not accept resource, 99 permission denied, -1 internal error.

◆ create_permission_no_acl()

int create_permission_no_acl ( const char *  name_arg,
const char *  comment,
const char *  resource_type_arg,
const char *  resource_id_arg,
const char *  subject_type,
const char *  subject_id,
permission_t *  permission 
)

Create a permission.

Does not require current user to have CREATE_PERMISSION access.

Parameters
[in]name_argName of permission.
[in]commentComment on permission.
[in]resource_type_argType of resource, for special permissions.
[in]resource_id_argUUID of resource.
[in]subject_typeType of subject.
[in]subject_idUUID of subject.
[out]permissionPermission.
Returns
0 success, 2 failed to find subject, 3 failed to find resource, 5 error in resource, 6 error in subject, 7 error in name, 8 permission on permission, 9 permission does not accept resource, 99 permission denied, -1 internal error.

◆ create_report()

int create_report ( array_t *  results,
const char *  task_id,
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]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_id is NULL, -4 failed to find task, -5 task must be container, -6 permission to create assets denied.

◆ create_role()

int create_role ( const char *  role_name,
const char *  comment,
const char *  users,
role_t *  role 
)

Create a role.

Parameters
[in]role_nameRole name.
[in]commentComment on role.
[in]usersUsers role applies to.
[in]roleRole return.
Returns
0 success, 1 role exists already, 2 failed to find user, 4 user name validation failed, 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', 6 credential required, 99 permission denied.

◆ create_schedule()

int create_schedule ( const char *  name,
const char *  comment,
const char *  ical_string,
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]zoneTimezone.
[out]scheduleCreated schedule.
[out]error_outOutput for iCalendar errors and warnings.
Returns
0 success, 1 schedule exists already, 3 error in iCal string, 4 error in timezone, 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,
credential_t  ssh_elevate_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,
const char *  allow_simultaneous_ips,
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_elevate_credentialSSH previlige escalation 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.
[in]allow_simultaneous_ipsScanner preference allow_simultaneous_ips.
[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 SSH elevate credential type, 10 invalid SMB credential type, 11 invalid ESXi credential type, 12 invalid SNMP credential type, 13 port range or port list required, 14 SSH elevate credential without an SSH credential, 99 permission denied, -1 error.

◆ 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_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_asset()

int delete_asset ( const char *  asset_id,
const char *  report_id,
int  dummy 
)

Delete an asset.

Parameters
[in]asset_idUUID of asset.
[in]report_idUUID of report from which to delete assets. Overridden by asset_id.
[in]dummyDummy arg to match other delete functions.
Returns
0 success, 1 asset is in use, 2 failed to find asset, 4 UUID required, 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_filter()

int delete_filter ( const char *  filter_id,
int  ultimate 
)

Delete a filter.

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

◆ delete_group()

int delete_group ( const char *  group_id,
int  ultimate 
)

Delete a group.

Parameters
[in]group_idUUID of group.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a permission refers to the group, 2 failed to find group, 3 predefined group, 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_permission()

int delete_permission ( const char *  permission_id,
int  ultimate 
)

Delete a permission.

Parameters
[in]permission_idUUID of permission.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 2 failed to find permission, 3 predefined permission, 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_assets()

static int delete_report_assets ( const char *  report_id)
static

Delete all asset that came from a report.

Assume caller started a transaction.

Parameters
[in]report_idUUID of report.
Returns
0 success, 2 failed to find report, 4 UUID required, 99 permission denied, -1 error.

◆ 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_role()

int delete_role ( const char *  role_id,
int  ultimate 
)

Delete a role.

Parameters
[in]role_idUUID of role.
[in]ultimateWhether to remove entirely, or to trashcan.
Returns
0 success, 1 fail because a task refers to the role, 2 failed to find role, 3 predefined role, -1 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_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, 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()

static int delete_task_lock ( task_t  task,
int  ultimate 
)
static

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.

◆ filter_alert_iterator_readable()

int filter_alert_iterator_readable ( iterator_t iterator)

Get the read permission status from a GET iterator.

Parameters
[in]iteratorIterator.
Returns
1 if may read, 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_count()

int filter_count ( const get_data_t get)

Count number of filters.

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

◆ filter_free()

void filter_free ( array_t *  split)

Free a split filter.

Parameters
[in]splitSplit filter.

◆ filter_in_use()

int filter_in_use ( filter_t  filter)

Check whether a filter is in use.

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

◆ filter_in_use_for_output()

static int filter_in_use_for_output ( filter_t  filter)
static

Check whether a filter is in use for the output of any alert.

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

◆ filter_in_use_for_result_event()

static int filter_in_use_for_result_event ( filter_t  filter)
static

Check whether a filter is in use by any result alert conditions.

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

◆ filter_in_use_for_secinfo_event()

static int filter_in_use_for_secinfo_event ( filter_t  filter)
static

Check whether a filter is in use by any secinfo alert conditions.

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

◆ filter_iterator_type()

const char* filter_iterator_type ( iterator_t iterator)

Get the type from a filter iterator.

Parameters
[in]iteratorIterator.
Returns
The type of the filter, or NULL if iteration is complete. Freed by cleanup_iterator. "" for any type.

◆ filter_name()

char* filter_name ( filter_t  filter)

Return the name of a filter.

Parameters
[in]filterFilter.
Returns
name of filter.

◆ filter_term()

gchar* filter_term ( const char *  uuid)

Return the term of a filter.

Parameters
[in]uuidFilter UUID.
Returns
Newly allocated term if available, else NULL.

◆ filter_term_apply_overrides()

int filter_term_apply_overrides ( const char *  term)

Return the value of the apply_overrides keyword of a filter term.

Parameters
[in]termFilter term.
Returns
Value of apply_overrides if it exists, else APPLY_OVERRIDES_DEFAULT.

◆ filter_term_min_qod()

int filter_term_min_qod ( const char *  term)

Return the value of the min_qod keyword of a filter term.

Parameters
[in]termFilter term.
Returns
Value of min_qod if it exists, else MIN_QOD_DEFAULT.

◆ filter_term_value()

gchar* filter_term_value ( const char *  term,
const char *  column 
)

Return the value of a column keyword of a filter term.

Parameters
[in]termFilter term.
[in]columnColumn name.
Returns
Value of column keyword if one exists, else NULL.

◆ filter_uuid()

char* filter_uuid ( filter_t  filter)

Return the UUID of a filter.

Parameters
[in]filterFilter.
Returns
Newly allocated UUID if available, else NULL.

◆ filter_writable()

int filter_writable ( filter_t  filter)

Check whether a filter is writable.

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

◆ 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_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_filter_with_permission()

gboolean find_filter_with_permission ( const char *  uuid,
filter_t *  filter,
const char *  permission 
)

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

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

◆ find_group_with_permission()

static gboolean find_group_with_permission ( const char *  uuid,
group_t *  group,
const char *  permission 
)
static

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

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

◆ find_host_with_permission()

static gboolean find_host_with_permission ( const char *  uuid,
host_t *  host,
const char *  permission 
)
static

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

Parameters
[in]uuidUUID of host.
[out]hostHost return, 0 if successfully failed to find host.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find host), 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_permission()

static gboolean find_permission ( const char *  uuid,
permission_t *  permission 
)
static

Find a permission given a UUID.

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

◆ find_permission_with_permission()

static gboolean find_permission_with_permission ( const char *  uuid,
permission_t *  resource,
const char *  permission 
)
static

Find a permission with a given permission, given a UUID.

Parameters
[in]uuidUUID of permission.
[out]resourcePermission return, 0 if successfully failed to find permission.
[in]permissionRequired permission, for example "delete".
Returns
FALSE on success (including if failed to find permission), 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_role_by_name()

static gboolean find_role_by_name ( const char *  name,
role_t *  role 
)
static

Find a role given a name.

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

◆ find_role_with_permission()

static gboolean find_role_with_permission ( const char *  uuid,
role_t *  role,
const char *  permission 
)
static

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

Parameters
[in]uuidUUID of role.
[out]roleRole return, 0 if successfully failed to find role.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find role), 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_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_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.

◆ 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.

◆ group_count()

int group_count ( const get_data_t get)

Count number of groups.

Parameters
[in]getGET params.
Returns
Total number of groups in grouped set.

◆ group_in_use()

int group_in_use ( group_t  group)

Check whether a group is in use.

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

◆ group_users()

gchar* group_users ( group_t  group)

Gets users of group as a string.

Parameters
[in]groupGroup.
Returns
Users.

◆ group_uuid()

char* group_uuid ( group_t  group)

Return the UUID of a group.

Parameters
[in]groupGroup.
Returns
Newly allocated UUID if available, else NULL.

◆ group_writable()

int group_writable ( group_t  group)

Check whether a group is writable.

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

◆ host_detail_free()

void host_detail_free ( host_detail_t detail)

Free a host detail.

Parameters
[in]detailHost detail.

◆ host_identifier_iterator_source_orphan()

int host_identifier_iterator_source_orphan ( iterator_t iterator)

Get the source orphan state from a host identifier iterator.

Parameters
[in]iteratorIterator.
Returns
The source orphan state of the host identifier, or 0 if iteration is complete. Freed by cleanup_iterator.

◆ 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_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 Ruleset for updating assets from scan detections. 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_routes_xml()

gchar* host_routes_xml ( host_t  host)

Get XML of a detailed host route.

Parameters
[in]hostThe host.
Returns
XML.

◆ 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.

◆ host_uuid()

char* host_uuid ( resource_t  host)

Return the UUID of a host.

Parameters
[in]hostHost.
Returns
Host UUID.

◆ hosts_set_details()

void hosts_set_details ( report_t  report)

Store certain host details in the assets after a scan.

Parameters
[in]reportThe report associated with the scan.

◆ hosts_set_identifiers()

void hosts_set_identifiers ( report_t  report)

Setup hosts and their identifiers after a scan, from host details.

At the end of a scan this revises the decision about which asset host to use for each host that has identifiers. The rules for this decision are described in Ruleset for updating assets from scan detections. (The initial decision is made by host_notice.)

Parameters
[in]reportReport that the identifiers come from.

◆ hosts_set_max_severity()

void hosts_set_max_severity ( report_t  report,
int *  overrides_arg,
int *  min_qod_arg 
)

Set the maximum severity of each host in a scan.

Parameters
[in]reportThe report associated with the scan.
[in]overrides_argWhether override should be applied.
[in]min_qod_argMin QOD to use.

◆ http_get()

static int http_get ( const char *  url)
static

GET an HTTP resource.

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

◆ identifier_free()

static void identifier_free ( identifier_t identifier)
static

Free an identifier.

Parameters
[in]identifierIdentifier.

◆ identifier_name()

static int identifier_name ( const char *  name)
static

Check whether a string is an identifier name.

Parameters
[in]namePossible identifier name.
Returns
1 if an identifier name, else 0.

◆ 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_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_app_locations_iterator()

void init_app_locations_iterator ( iterator_t iterator,
report_host_t  report_host,
const gchar *  app 
)

Initialize an iterator of locations of an App for a report's host.

Parameters
[in]iteratorIterator.
[in]report_hostReport host.
[in]appCPE.

◆ init_asset_host_iterator()

int init_asset_host_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a host iterator.

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

◆ init_asset_os_iterator()

int init_asset_os_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise an OS iterator.

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

◆ 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_filter_alert_iterator()

void init_filter_alert_iterator ( iterator_t iterator,
filter_t  filter 
)

Initialise a filter alert iterator.

Iterates over all alerts that use the filter.

Parameters
[in]iteratorIterator.
[in]filterFilter.

◆ init_filter_iterator()

int init_filter_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a filter iterator, including observed filters.

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

◆ 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,
const char *  extra_where_single,
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]extra_where_singleExtra WHERE clauses. Used 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,
const char *  extra_where_single,
int  owned,
int  ignore_id,
const char *  extra_order,
const char *  extra_with,
int  acl_with_optional,
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]extra_where_singleExtra WHERE clauses. Used 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]acl_with_optionalWhether default permission WITH clauses are optional.
[in]assume_permittedWhether to skip permission checks.
Returns
0 success, 1 failed to find resource, 2 failed to find filter, -1 error.

◆ init_group_iterator()

int init_group_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a group iterator, including observed groups.

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

◆ init_host_detail_iterator()

void init_host_detail_iterator ( iterator_t iterator,
resource_t  host 
)

Initialise an asset host detail iterator.

Parameters
[in]iteratorIterator.
[in]hostHost.

◆ init_host_identifier_iterator()

void init_host_identifier_iterator ( iterator_t iterator,
host_t  host,
int  ascending,
const char *  sort_field 
)

Initialise a host identifier iterator.

Parameters
[in]iteratorIterator.
[in]hostHost.
[in]ascendingWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for type then start.

◆ init_host_prognosis_iterator()

void init_host_prognosis_iterator ( iterator_t iterator,
report_host_t  report_host 
)

Initialise a report host prognosis iterator.

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

◆ init_manage()

int init_manage ( GSList *  log_config,
const db_conn_info_t 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]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 db_conn_info_t 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,
const db_conn_info_t 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]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_open_db()

static int init_manage_open_db ( const db_conn_info_t database)
static

Initialize the manage library: open db.

Parameters
[in]databaseLocation of manage database.
Returns
1 if open already, else 0.

◆ init_manage_process()

void init_manage_process ( const db_conn_info_t database)

Initialize the manage library for a process.

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

Parameters
[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_os_host_iterator()

void init_os_host_iterator ( iterator_t iterator,
resource_t  os 
)

Initialise an OS host iterator.

Parameters
[in]iteratorIterator.
[in]osOS.

◆ 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_permission_iterator()

int init_permission_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a permission iterator.

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

◆ 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_role_iterator()

int init_role_iterator ( iterator_t iterator,
const get_data_t get 
)

Initialise a role iterator, including observed roles.

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

◆ 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_setting_iterator()

void init_setting_iterator ( iterator_t iterator,
const char *  uuid,
const char *  filter,
int  first,
int  max,
int  ascending,
const char *  sort_field 
)

Initialise a setting iterator, including observed settings.

Parameters
[in]iteratorIterator.
[in]uuidUUID of setting to limit iteration to. 0 for all.
[in]filterFilter term.
[in]firstFirst setting.
[in]maxMaximum number of settings returned.
[in]ascendingWhether to sort ascending or descending.
[in]sort_fieldField to sort on, or NULL for "id".

◆ 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_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_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_nvti()

nvti_t* lookup_nvti ( const gchar *  nvt)

Update the memory cache of NVTs.

Parameters
[in]nvtNVT.
Returns
NVTi if found, else NULL.

◆ 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 *  hostname,
const char *  nvt,
const char *  type,
const char *  description,
const char *  port,
const char *  severity,
int  qod,
const char *  path 
)

Make an OSP result.

Parameters
[in]taskThe task associated with the result.
[in]hostTarget host of result.
[in]hostnameHostname of the result.
[in]nvtA title for the result.
[in]typeType of result. "Alarm", etc.
[in]descriptionDescription of the result.
[in]portResult port.
[in]severityResult severity.
[in]qodQuality of detection.
[in]pathResult path, e.g. file location of a product.
Returns
A result descriptor for the new result, 0 if error.

◆ 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_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,
const char *  path 
)

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: "Alarm", "Error Message" or "Log Message".
[in]descriptionDescription of the result.
[in]pathResult path, e.g. file location of a product.
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 db_conn_info_t 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 db_conn_info_t database,
const char *  name,
const char *  host,
const char *  port,
const char *  type,
const char *  ca_pub_path,
const char *  credential_id,
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]credential_idUUID of credential to use or NULL to create.
[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 db_conn_info_t 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 db_conn_info_t 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_empty_trashcan()

int manage_empty_trashcan ( )

Empty the trashcan.

Returns
0 success, 99 permission denied, -1 error.

◆ manage_encrypt_all_credentials()

int manage_encrypt_all_credentials ( GSList *  log_config,
const db_conn_info_t 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_roles()

int manage_get_roles ( GSList *  log_config,
const db_conn_info_t database,
int  verbose 
)

List roles.

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

◆ manage_get_scanners()

int manage_get_scanners ( GSList *  log_config,
const db_conn_info_t 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_migrate_relay_sensors()

static gchar* manage_migrate_relay_sensors ( )
static

Tries to migrate sensor type scanners to match the relays.

Returns
A string describing the results or NULL on error.

◆ manage_modify_scanner()

int manage_modify_scanner ( GSList *  log_config,
const db_conn_info_t database,
const char *  scanner_id,
const char *  name,
const char *  host,
const char *  port,
const char *  type,
const char *  ca_pub_path,
const char *  credential_id,
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]credential_idUUID of credential to use or NULL to create.
[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_option_setup()

int manage_option_setup ( GSList *  log_config,
const db_conn_info_t 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_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,
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.
[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 *  notes,
int *  overrides,
int *  apply_overrides,
gchar **  zone 
)

Get info from a result filter for a 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, "hmlg" for High, Medium, Low and loG). 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]notesWhether to include notes.
[out]overridesWhether to include overrides.
[out]apply_overridesWhether to apply overrides.
[out]zoneTimezone.

◆ manage_report_host_add()

report_host_t manage_report_host_add ( report_t  report,
const char *  host,
time_t  start,
time_t  end 
)

Add a report host.

Parameters
[in]reportUUID of resource.
[in]hostHost.
[in]startStart time.
[in]endEnd time.
Returns
Report host.

◆ manage_report_host_detail()

int manage_report_host_detail ( report_t  report,
const char *  host,
const char *  xml 
)

Add a host detail to a report host.

Parameters
[in]reportUUID of resource.
[in]hostHost.
[in]xmlReport host detail XML.
Returns
0 success, -1 failed to parse XML, -2 host was NULL.

◆ manage_report_host_details()

int manage_report_host_details ( report_t  report,
const char *  ip,
entity_t  entity 
)

Add host details to a report host.

Parameters
[in]reportUUID of resource.
[in]ipHost.
[in]entityXML entity containing details.
Returns
0 success, -1 failed to parse XML.

◆ 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_restore()

int manage_restore ( const char *  id)

Restore a resource from the trashcan.

Parameters
[in]idUUID of resource.
Returns
0 success, 1 fail because the resource refers to another resource in the trashcan, 2 failed to find resource in trashcan, 3 fail because resource with such name exists already, 4 fail because resource with UUID exists already, 99 permission denied, -1 error.

◆ 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_schema()

int manage_schema ( gchar *  format,
gchar **  output_return,
gsize *  output_length,
gchar **  extension,
gchar **  content_type 
)

Generate the GMP schema.

Parameters
[in]formatName of schema format, "XML" or NULL for XML.
[out]output_returnNULL or location for output.
[out]output_lengthNULL or location for length of output.
[out]extensionNULL or location for schema extension.
[out]content_typeNULL or location for schema content type.
Returns
0 success, 1 failed to find schema format, -1 error.

◆ 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  lean,
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 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]leanWhether to send lean report.
[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]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_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 db_conn_info_t 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.

◆ 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_asset()

int modify_asset ( const char *  asset_id,
const char *  comment 
)

Modify an asset.

Parameters
[in]asset_idUUID of asset.
[in]commentComment on asset.
Returns
0 success, 1 failed to find asset, 3 asset_id required, 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_filter()

int modify_filter ( const char *  filter_id,
const char *  name,
const char *  comment,
const char *  term,
const char *  type 
)

Modify a filter.

Parameters
[in]filter_idUUID of filter.
[in]nameName of filter.
[in]commentComment on filter.
[in]termFilter term.
[in]typeType of filter.
Returns
0 success, 1 failed to find filter, 2 filter with new name exists, 3 error in type name, 4 filter_id required, 5 filter is in use so type must be "result", 6 filter is in use so type must be "info", 99 permission denied, -1 internal error.

◆ modify_group()

int modify_group ( const char *  group_id,
const char *  name,
const char *  comment,
const char *  users 
)

Modify a group.

Parameters
[in]group_idUUID of group.
[in]nameName of group.
[in]commentComment on group.
[in]usersGroup users.
Returns
0 success, 1 failed to find group, 2 failed to find user, 3 group_id required, 4 user name validation failed, 5 group with new name exists, 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, 8 invalid threat, 9 invalid new_threat, 10 invalid new_severity, 11 missing new_severity.

◆ modify_permission()

int modify_permission ( const char *  permission_id,
const char *  name_arg,
const char *  comment,
const char *  resource_id_arg,
const char *  resource_type_arg,
const char *  subject_type,
const char *  subject_id 
)

Modify a permission.

Parameters
[in]permission_idUUID of permission.
[in]name_argName of permission.
[in]commentComment on permission.
[in]resource_id_argUUID of resource.
[in]resource_type_argType of resource, for Super permissions.
[in]subject_typeType of subject.
[in]subject_idUUID of subject.
Returns
0 success, 1 failed to find permission, 2 failed to find subject, 3 failed to find resource, 4 permission_id required, 5 error in resource, 6 error in subject, 7 error in name, 8 name required to find resource, 9 permission does not accept resource, 99 permission denied, -1 internal error.

◆ modify_role()

int modify_role ( const char *  role_id,
const char *  name,
const char *  comment,
const char *  users 
)

Modify a role.

Parameters
[in]role_idUUID of role.
[in]nameName of role.
[in]commentComment on role.
[in]usersRole users.
Returns
0 success, 1 failed to find role, 2 failed to find user, 3 role_id required, 4 user name validation failed, 5 role with new name exists, 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', 8 credential missing, 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,
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]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, 6 error in iCalendar, 7 error in zone, 99 permission denied, -1 internal error.

◆ modify_setting()

int modify_setting ( const gchar *  uuid,
const gchar *  name,
const gchar *  value_64,
gchar **  r_errdesc 
)

Set the value of a setting.

Parameters
[in]uuidUUID of setting.
[in]nameSetting name. For Timezone and Password.
[in]value_64New setting value, base64 encoded.
[out]r_errdescIf not NULL the address of a variable to receive a malloced string with the error description. Will always be set to NULL on success.
Returns
0 success, 1 failed to find setting, 2 syntax error in value, 99 permission denied, -1 on 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_elevate_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,
const char *  allow_simultaneous_ips 
)

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_elevate_credential_idSSH previlige escalation 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.
[in]allow_simultaneous_ipsScanner preference allow_simultaneous_ips.
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, 22 failed to find SSH elevate cred, 23 invalid SSH elevate credential type, 24 SSH elevate credential without SSH credential, 25 SSH elevate credential equals SSH credential, 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.

◆ 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_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.

◆ new_severity_clause()

static gchar* new_severity_clause ( int  apply_overrides,
int  dynamic_severity 
)
static

Get new severity clause.

Parameters
[in]apply_overridesWhether to apply overrides.
[in]dynamic_severityWhether to use dynamic severity.
Returns
Newly allocated clause.

◆ 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_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_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.

◆ openvas_default_scanner_host()

char* openvas_default_scanner_host ( )

Get the default scanner path or host.

Returns
Newly allocated scanner path or host.

◆ osp_connect_with_data()

osp_connection_t* osp_connect_with_data ( const char *  host,
int  port,
const char *  ca_pub,
const char *  key_pub,
const char *  key_priv 
)

Create a new connection to an OSP scanner using the scanner data.

Parameters
[in]hostHost name or IP address.
[in]portPort.
[in]ca_pubCA certificate.
[in]key_pubPublic key.
[in]key_privPrivate key.
Returns
New connection if success, NULL otherwise.

◆ 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.

◆ osp_scanner_relay_connect()

static osp_connection_t* osp_scanner_relay_connect ( const char *  host,
int  port,
const char *  ca_pub,
const char *  key_pub,
const char *  key_priv 
)
static

Create a new connection to an OSP scanner relay.

Parameters
[in]hostOriginal host name or IP address.
[in]portOriginal port.
[in]ca_pubOriginal CA certificate.
[in]key_pubPublic key for authentication.
[in]key_privPrivate key for authentication.
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.

If no offset is specified, the timezone of the current user is used. If there is no current user timezone, UTC is used.

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.

◆ permission_count()

int permission_count ( const get_data_t get)

Count number of permissions.

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

◆ permission_in_use()

int permission_in_use ( permission_t  permission)

Return whether a permission is in use.

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

◆ permission_is_admin()

int permission_is_admin ( const char *  permission_id)

Test whether a permission is the special Admin permission.

Parameters
[in]permission_idUUID of permission.
Returns
1 permission is Admin, else 0.

◆ permission_is_predefined()

static int permission_is_predefined ( permission_t  permission)
static

Return whether a permission is predefined.

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

◆ permission_iterator_resource_in_trash()

int permission_iterator_resource_in_trash ( iterator_t iterator)

Return the permission resource location.

Parameters
[in]iteratorIterator.
Returns
Whether the resource is in the trashcan

◆ permission_iterator_resource_orphan()

int permission_iterator_resource_orphan ( iterator_t iterator)

Check if the permission resource has been deleted.

Parameters
[in]iteratorIterator.
Returns
Whether the resource has been deleted.

◆ permission_iterator_resource_readable()

int permission_iterator_resource_readable ( iterator_t iterator)

Get the readable status of a resource from a permission iterator.

Parameters
[in]iteratorIterator.
Returns
1 if readable, otherwise 0.

◆ permission_iterator_subject_in_trash()

int permission_iterator_subject_in_trash ( iterator_t iterator)

Return the permission subject location.

Parameters
[in]iteratorIterator.
Returns
Whether the subject is in the trashcan

◆ permission_iterator_subject_readable()

int permission_iterator_subject_readable ( iterator_t iterator)

Get the readable status of a subject from a permission iterator.

Parameters
[in]iteratorIterator.
Returns
1 if readable, otherwise 0.

◆ permission_name()

static char * permission_name ( permission_t  permission)
static

Return the name of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated name if available, else NULL.

◆ permission_resource()

static resource_t permission_resource ( permission_t  permission)
static

Return the resource of a permission.

Parameters
[in]permissionPermission.
Returns
Resource if there is one, else 0.

◆ permission_resource_id()

static char* permission_resource_id ( permission_t  permission)
static

Return the UUID of the resource of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated resource ID if available, else NULL.

◆ permission_resource_type()

static char* permission_resource_type ( permission_t  permission)
static

Return the resource type of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated resource type if available, else NULL.

◆ permission_subject()

static resource_t permission_subject ( permission_t  permission)
static

Return the subject of a permission.

Parameters
[in]permissionPermission.
Returns
Subject if there is one, else 0.

◆ permission_subject_id()

static char* permission_subject_id ( permission_t  permission)
static

Return the UUID of the subject of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated subject ID if available, else NULL.

◆ permission_subject_type()

static char * permission_subject_type ( permission_t  permission)
static

Return the subject type of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated subject type if available, else NULL.

◆ permission_uuid()

char* permission_uuid ( permission_t  permission)

Return the UUID of a permission.

Parameters
[in]permissionPermission.
Returns
Newly allocated UUID if available, else NULL.

◆ permission_writable()

int permission_writable ( permission_t  permission)

Return whether a permission is writable.

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

◆ permissions_set_locations()

void permissions_set_locations ( const char *  type,
resource_t  old,
resource_t  new,
int  to 
)

Adjust location of resource in permissions.

Parameters
[in]typeType.
[in]oldResource ID in old table.
[in]newResource ID in new table.
[in]toDestination, trash or table.

◆ permissions_set_orphans()

void permissions_set_orphans ( const char *  type,
resource_t  resource,
int  location 
)

Set permissions to orphan.

Parameters
[in]typeType.
[in]resourceResource ID.
[in]locationLocation: table or trash.

◆ permissions_set_subjects()

static void permissions_set_subjects ( const char *  type,
resource_t  old,
resource_t  new,
int  to 
)
static

Adjust subject in permissions.

Parameters
[in]typeSubject type.
[in]oldResource ID in old table.
[in]newResource ID in new table.
[in]toDestination, trash or table.

◆ 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_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_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_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,
int  lean 
)
static

Write report host detail to file stream.

On error close stream.

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

◆ print_report_host_details_xml()

static int print_report_host_details_xml ( report_host_t  report_host,
FILE *  stream,
int  lean 
)
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.
[in]leanReport host details iterator.
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,
iterator_t results 
)
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.
[in,out]resultsResult iterator. For caller to reuse.
Returns
0 on success, -1 error.
Todo:
Sort by ROWID if was requested.

◆ 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,
int  notes_details,
int  overrides_details,
int  result_tags,
int  ignore_pagination,
int  lean,
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]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 data.
[in]leanWhether to return lean report.
[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_holes, 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.

◆ 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_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_add_results_array()

void report_add_results_array ( report_t  report,
GArray *  results 
)

Add results from an array to a report.

Parameters
[in]reportThe report to add the results to.
[in]resultsGArray containing the row ids of the results to add.

◆ 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_compliance_by_uuid()

void report_compliance_by_uuid ( const char *  report_id,
int *  compliance_yes,
int *  compliance_no,
int *  compliance_incomplete 
)

Get compliance counts for a report.

Parameters
[in]report_idUUID of the report.
[out]compliance_yesNumber of "YES" results.
[out]compliance_noNumber of "NO" results.
[out]compliance_incompleteNumber of "INCOMPLETE" results.

◆ 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 *  holes,
int *  infos,
int *  logs,
int *  warnings,
int *  false_positives,
double *  severity,
int  override,
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]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]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 *  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]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 *  holes,
int *  infos,
int *  logs,
int *  warnings,
int *  false_positives,
double *  severity,
const get_data_t get,
const char *  host,
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]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_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_finished_hosts_str()

char* report_finished_hosts_str ( report_t  report)

Get a list string of finished hosts in a report.

Parameters
[in]reportThe report to get the finished hosts from.
Returns
String containing finished hosts as comma separated list.

◆ 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_dead()

static int report_host_dead ( report_host_t  report_host)
static

Tests if a report host is marked as dead.

Parameters
[in]report_hostReport host.
Returns
1 if the host is marked as dead, 0 otherwise.

◆ 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_host_result_count()

static int report_host_result_count ( report_host_t  report_host)
static

Counts.

Parameters
[in]report_hostReport host.
Returns
1 if the host is marked as dead, 0 otherwise.

◆ report_host_set_end_time()

void report_host_set_end_time ( report_host_t  report_host,
time_t  end_time 
)

Set end time of a report host.

Parameters
[in]report_hostReport host.
[in]end_timeEnd time.

◆ 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)

Calculate the progress of a report.

Parameters
[in]reportReport.
Returns
Progress.

◆ 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_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_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_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_clear_count_cache()

static void reports_clear_count_cache ( const gchar *  uuid)
static

Clear the report count cache for all reports of a user.

Parameters
[in]uuidUUID of user.

◆ 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_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 char *  host,
const char *  port,
const char *  path,
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]portPort of result.
[in]pathPath of result.
[out]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_host_asset_id()

char* result_host_asset_id ( const char *  host,
result_t  result 
)

Return the UUID of the asset associated with a result host.

Parameters
[in]hostHost value from result.
[in]resultResult.
Returns
Asset UUID.

◆ result_iterator_cert_bunds()

gchar** result_iterator_cert_bunds ( iterator_t iterator)

Get CERT-BUNDs from a result iterator.

Parameters
[in]iteratorIterator.
Returns
CERT-BUND names if any, else NULL.

◆ result_iterator_dfn_certs()

gchar** result_iterator_dfn_certs ( iterator_t iterator)

Get DFN-CERTs from a result iterator.

Parameters
[in]iteratorIterator.
Returns
DFN-CERT names if any, else NULL.

◆ result_iterator_lateral()

static const gchar* result_iterator_lateral ( int  apply_overrides,
int  dynamic_severity 
)
static

Get LATERAL clause for result iterator.

Parameters
[in]apply_overridesWhether to apply overrides.
[in]dynamic_severityWhether to use dynamic severity.
Returns
SQL clause for FROM.

◆ result_iterator_level()

const char* result_iterator_level ( iterator_t iterator)

Get the severity/threat level from a result iterator.

This is the the 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_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_solution_method()

const char* result_iterator_nvt_solution_method ( iterator_t iterator)

Get the NVT solution_method from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The solution_method of the NVT that produced the result, or NULL on error.

◆ result_iterator_nvt_solution_type()

const char* result_iterator_nvt_solution_type ( iterator_t iterator)

Get the NVT solution_type from a result iterator.

Parameters
[in]iteratorIterator.
Returns
The solution_type of the NVT that produced the result, or NULL on error.

◆ result_iterator_opts_table()

static gchar* result_iterator_opts_table ( int  override,
int  dynamic 
)
static

Generate the extra_tables string for a result iterator.

Parameters
[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.

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.

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()

const char* result_iterator_severity ( iterator_t iterator)

Get the severity from a result iterator.

This is the the 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 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 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  apply_overrides,
int  dynamic_severity,
const gchar *  filter,
const gchar *  given_new_severity_sql 
)
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]apply_overridesWhether to apply overrides.
[in]dynamic_severityWhether to use dynamic severity.
[in]filterFilter string.
[in]given_new_severity_sqlSQL for new severity, or NULL.
Returns
Newly allocated extra_where string.

◆ role_count()

int role_count ( const get_data_t get)

Count number of roles.

Parameters
[in]getGET params.
Returns
Total number of roles in roleed set.

◆ role_in_use()

int role_in_use ( role_t  role)

Check whether a role is in use.

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

◆ role_is_predefined()

static int role_is_predefined ( role_t  role)
static

Return whether a role is predefined.

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

◆ role_is_predefined_id()

static int role_is_predefined_id ( const char *  uuid)
static

Return whether a role is predefined.

Parameters
[in]uuidUUID of role.
Returns
1 if predefined, else 0.

◆ role_users()

gchar* role_users ( role_t  role)

Gets users of role as a string.

Parameters
[in]roleRole.
Returns
Users.

◆ role_uuid()

gchar* role_uuid ( role_t  role)

Gets UUID of role.

Parameters
[in]roleRole.
Returns
Users.

◆ role_writable()

int role_writable ( role_t  role)

Check whether a role is writable.

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

◆ 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.

◆ 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,
gchar **  icalendar,
gchar **  zone 
)

Return info about a schedule.

Parameters
[in]scheduleSchedule.
[in]trashWhether to get schedule from trash.
[out]icalendariCalendar string.
[out]zoneTimezone string.
Returns
0 success, -1 error.

◆ 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 *  username,
const char *  password,
const char *  private_key,
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]usernameUsername.
[in]passwordPassword or passphrase of private key.
[in]private_keyPrivate key or NULL for password-only auth.
[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_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_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_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_ctime()

void set_scan_end_time_ctime ( report_t  report,
const char *  timestamp 
)

Set the end time of a scan.

Parameters
[in]reportThe report associated with the scan.
[in]timestampEnd time. In UTC ctime 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_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_ctime()

void set_scan_host_end_time_ctime ( 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. In UTC ctime format.

◆ set_scan_host_start_time_ctime()

void set_scan_host_start_time_ctime ( 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. In UTC ctime format.

◆ 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_ctime()

void set_scan_start_time_ctime ( 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 UTC ctime 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_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_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. -1 to use existing value.
Returns
0 success, -1 error.

◆ set_task_start_time_ctime()

void set_task_start_time_ctime ( task_t  task,
char *  time 
)

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. UTC ctime 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_target()

void set_task_target ( task_t  task,
target_t  target 
)

Set the target of a task.

Parameters
[in]taskTask.
[in]targetTarget.

◆ set_task_usage_type()

void set_task_usage_type ( task_t  task,
const char *  usage_type 
)

Set the usage_type of a task.

Parameters
[in]taskTask.
[in]usage_typeNew usage type ("scan" or "audit").

◆ setting_auto_cache_rebuild_int()

static int setting_auto_cache_rebuild_int ( )
static

Return the Auto Cache Rebuild user setting as an int.

Returns
1 if cache is rebuilt automatically, 0 if not.

◆ setting_count()

int setting_count ( const char *  filter)

Count number of settings.

Parameters
[in]filterFilter term.
Returns
Total number of settings in filtered set.

◆ setting_dynamic_severity_int()

static int setting_dynamic_severity_int ( )
static

Return the Dynamic Severity user setting as an int.

Returns
1 if user's Dynamic Severity is "Yes", 0 if it is "No", or does not exist.

◆ setting_filter()

char* setting_filter ( const char *  resource)

Return the uuid of a resource filter from settings.

Parameters
[in]resourceResource (eg. Filters, Targets, CPE).
Returns
resource filter uuid in settings if it exists, "" otherwise.

◆ setting_timezone()

static char * setting_timezone ( )
static

Return the user's timezone.

Returns
User Severity Class in settings if it exists, else NULL.

◆ setting_value()

int setting_value ( const char *  uuid,
char **  value 
)

Get the value of a setting as a string.

Parameters
[in]uuidUUID of setting.
[out]valueFreshly allocated value.
Returns
0 success, -1 error.

◆ setting_value_int()

static int setting_value_int ( const char *  uuid,
int *  value 
)
static

Get the value of a setting.

Parameters
[in]uuidUUID of setting.
[out]valueValue.
Returns
0 success, -1 error.

◆ 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.

Parameters
[in]taskTask.
Returns
0 on success, 1 if stop requested.

◆ streq_ignore_ws()

static int streq_ignore_ws ( const gchar *  one,
const gchar *  two 
)
static

Test if two strings are equal, ignoring whitespace.

Parameters
[in]oneFirst string.
[in]twoSecond string.
Returns
1 if equal, else 0.

◆ subject_where_clause()

static gchar* subject_where_clause ( const char *  subject_type,
resource_t  subject 
)
static

Create a SQL clause to select the subject users.

Parameters
[in]subject_typeSubject type.
[in]subjectThe subject.
Returns
Newly allocated string containing the SQL clause.

◆ 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.

◆ 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_allow_simultaneous_ips()

char* target_allow_simultaneous_ips ( target_t  target)

Return the allow_simultaneous_ips value of a target.

Parameters
[in]targetTarget.
Returns
The allow_simultaneous_ips value if available, else NULL.

◆ 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_elevate_credential()

int target_iterator_ssh_elevate_credential ( iterator_t iterator)

Get the ELEVATE LSC credential from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ELEVATE LSC credential.

◆ target_iterator_ssh_elevate_trash()

int target_iterator_ssh_elevate_trash ( iterator_t iterator)

Get the ELEVATE LSC credential location from a target iterator.

Parameters
[in]iteratorIterator.
Returns
ELEVATE 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 GMP port range list 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_elevate_credential()

credential_t target_ssh_elevate_credential ( target_t  target)

Return the ELEVATE credential associated with a target, if any.

Parameters
[in]targetTarget.
Returns
ELEVATE 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_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_iterator_usage_type()

const char* task_iterator_usage_type ( iterator_t iterator)

Get the UUID of task scanner from a task iterator.

Parameters
[in]iteratorIterator.
Returns
Task scanner if found, NULL otherwise.

◆ 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_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_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_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.

◆ tasks_extra_where()

static gchar* tasks_extra_where ( int  trash,
const char *  usage_type 
)
static

Generate an extra WHERE clause for selecting tasks.

Parameters
[in]trashWhether to get tasks from the trashcan.
[in]usage_typeThe usage type to limit the selection to.
Returns
Newly allocated where clause string.

◆ 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_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_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_filter_in_use()

int trash_filter_in_use ( filter_t  filter)

Check whether a trashcan filter is in use.

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

◆ trash_filter_name()

static char * trash_filter_name ( filter_t  filter)
static

Return the name of a trashcan filter.

Parameters
[in]filterFilter.
Returns
name of filter.

◆ trash_filter_uuid()

static char * trash_filter_uuid ( filter_t  filter)
static

Return the UUID of a trashcan filter.

Parameters
[in]filterFilter.
Returns
Newly allocated UUID if available, else NULL.

◆ trash_filter_writable()

int trash_filter_writable ( filter_t  filter)

Check whether a trashcan filter is writable.

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

◆ trash_group_in_use()

int trash_group_in_use ( group_t  group)

Check whether a trashcan group is in use.

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

◆ trash_group_writable()

int trash_group_writable ( group_t  group)

Check whether a trashcan group is writable.

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

◆ trash_permission_in_use()

int trash_permission_in_use ( permission_t  permission)

Return whether a trashcan permission is referenced by a task.

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

◆ trash_permission_writable()

int trash_permission_writable ( permission_t  permission)

Return whether a trashcan permission is writable.

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

◆ trash_role_in_use()

int trash_role_in_use ( role_t  role)

Check whether a trashcan role is in use.

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

◆ trash_role_writable()

int trash_role_writable ( role_t  role)

Check whether a trashcan role is writable.

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

◆ 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_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_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_globally_unique()

static int type_globally_unique ( const char *  type)
static

Check whether a type must have globally unique names.

Parameters
[in]typeType of resource.
Returns
1 yes, 0 no.

◆ 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.

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_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_report_modification_time()

int update_report_modification_time ( report_t  report)

Update modification_time of a report to current time.

Parameters
[in]reportReport.
Returns
0.

◆ 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()

int valid_type ( const char *  type)

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_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, for use in override or note.

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_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 authentication failed, 99 if permission denied, -1 error.

◆ where_levels_auto()

static GString* where_levels_auto ( 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, "hmlg" for High, Medium, Low and loG). All levels if NULL.
[in]new_severity_sqlSQL for new severity.
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.

◆ xml_append_nvt_refs()

void xml_append_nvt_refs ( GString *  xml,
const char *  oid,
int *  first 
)

Append an NVT's references to an XML string buffer.

Parameters
[in]xmlThe buffer where to append to.
[in]oidThe oid of the nvti object from where to collect the refs.
[in]firstMarker for first element.

Variable Documentation

◆ authenticate_allow_all

int authenticate_allow_all
extern

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.