OpenVAS Manager  7.0.3~git
manage_sql.c File Reference

The OpenVAS Manager management library (SQLite implementation). More...

#include "manage_sql.h"
#include "manage_acl.h"
#include "lsc_user.h"
#include "sql.h"
#include "scanner.h"
#include "utils.h"
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <gcrypt.h>
#include <glib/gstdio.h>
#include <locale.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.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 <openvas/base/openvas_string.h>
#include <openvas/base/openvas_file.h>
#include <openvas/base/openvas_hosts.h>
#include <openvas/misc/openvas_auth.h>
#include <openvas/misc/ldap_connect_auth.h>
#include <openvas/misc/radius.h>
#include <openvas/misc/openvas_logging.h>
#include <openvas/misc/openvas_uuid.h>
#include <openvas/misc/openvas_server.h>
#include <openvas/misc/openvas_ssh.h>
#include <openvas/base/pwpolicy.h>
#include <openvas/omp/omp.h>
Include dependency graph for manage_sql.c:

Go to the source code of this file.

Data Structures

struct  column_t
 Iterator column. More...
 

Macros

#define _GNU_SOURCE
 
#define G_LOG_DOMAIN   "md manage"
 GLib log domain. More...
 
#define OPENVASSD_ADDRESS   OPENVAS_RUN_DIR "/openvassd.sock"
 Scanner (openvassd) address. More...
 
#define MAX_CONTENT_LENGTH   20000
 Default max number of bytes of reports included in email alerts. More...
 
#define MAX_ATTACH_LENGTH   1048576
 Default max number of bytes of reports attached to email alerts. More...
 
#define MAX_EMAIL_MESSAGE_LENGTH   2000
 Default max number of bytes of user-defined message in email alerts. More...
 
#define ANON_GET_ITERATOR_FILTER_COLUMNS
 Filter columns for GET iterator. More...
 
#define GET_ITERATOR_FILTER_COLUMNS
 Filter columns for GET iterator. More...
 
#define GET_ITERATOR_COLUMNS_STRING
 Columns for GET iterator, as a single string. More...
 
#define GET_ITERATOR_COLUMNS_PREFIX(prefix)
 Columns for GET iterator. More...
 
#define GET_ITERATOR_COLUMNS(table)
 Columns for GET iterator. More...
 
#define GET_ITERATOR_COLUMN_COUNT   10
 Number of columns for GET iterator. More...
 
#define AGGREGATE_ITERATOR_OFFSET   3
 
#define AGGREGATE_ITERATOR_N_STATS   4
 
#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 SIMPLE_NOTICE_FORMAT
 Format string for simple notice alert email. More...
 
#define SECINFO_SIMPLE_NOTICE_FORMAT
 Format string for simple notice alert email. More...
 
#define NEW_NVTS_HEADER
 Header for "New NVTs" alert message. More...
 
#define NEW_NVTS_HEADER_OID
 Header for "New NVTs" alert message, when there's an OID. More...
 
#define NEW_CVES_HEADER
 Header for "New CVEs" alert message. More...
 
#define NEW_CPES_HEADER
 Header for "New CPEs" alert message. More...
 
#define NEW_CERT_BUNDS_HEADER
 Header for "New CERT-Bund Advisories" alert message. More...
 
#define NEW_DFN_CERTS_HEADER
 Header for "New DFN-CERT Advisories" alert message. More...
 
#define NEW_OVAL_DEFS_HEADER
 Header for "New CERT-Bund Advisories" alert message. More...
 
#define TASK_ITERATOR_FILTER_COLUMNS
 Filter columns for task iterator. More...
 
#define TASK_ITERATOR_COLUMNS_INNER
 Task iterator columns. More...
 
#define TASK_ITERATOR_WHERE_COLUMNS_INNER
 Task iterator WHERE columns. More...
 
#define TASK_ITERATOR_WHERE_COLUMNS
 Task iterator WHERE columns. More...
 
#define TASK_ITERATOR_COLUMNS
 Task iterator columns. More...
 
#define TASK_ITERATOR_COLUMNS_MIN
 Task iterator minimal columns. More...
 
#define TASK_ITERATOR_WHERE_COLUMNS_MIN
 Task iterator minimal WHERE columns. More...
 
#define RANGE(type, start, end)
 Insert a port range. More...
 
#define CREATE_REPORT_CHUNK_SIZE   10
 
#define CREATE_REPORT_CHUNK_SLEEP   1000
 
#define REPORT_ITERATOR_FILTER_COLUMNS
 
#define REPORT_ITERATOR_COLUMNS
 
#define REPORT_ITERATOR_WHERE_COLUMNS
 
#define CVSS_BASE_SQL   "(SELECT cvss_base FROM nvts WHERE nvts.oid = results.nvt)"
 
#define RESULT_ITERATOR_FILTER_COLUMNS
 
#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE
 
#define RESULT_ITERATOR_COLUMNS
 
#define PRINT(stream, format, args...)
 
#define PRINT_XML(stream, xml)
 
#define PRINT_REPORT_ERROR(stream, errors, asset_id)
 
#define MANAGE_SEND_REPORT_CHUNK64_SIZE   262144
 
#define MANAGE_SEND_REPORT_CHUNK_SIZE   (MANAGE_SEND_REPORT_CHUNK64_SIZE * 3 / 4)
 
#define TARGET_ITERATOR_FILTER_COLUMNS
 
#define TARGET_ITERATOR_COLUMNS
 
#define TARGET_ITERATOR_TRASH_COLUMNS
 
#define CONFIG_ITERATOR_FILTER_COLUMNS
 
#define CONFIG_ITERATOR_COLUMNS
 
#define CONFIG_ITERATOR_TRASH_COLUMNS
 
#define CHUNK_SIZE   100
 
#define NVT_INFO_ITERATOR_FILTER_COLUMNS
 
#define NVT_ITERATOR_COLUMNS
 
#define NVT_ITERATOR_COLUMNS_NVTS
 
#define PASSWORD_LENGTH   10
 
#define CREDENTIAL_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "login", "type", "allow_insecure", NULL }
 
#define CREDENTIAL_ITERATOR_COLUMNS
 
#define CREDENTIAL_ITERATOR_TRASH_COLUMNS
 
#define AGENT_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "trust", NULL }
 
#define AGENT_ITERATOR_COLUMNS
 
#define AGENT_ITERATOR_TRASH_COLUMNS
 
#define NOTE_ITERATOR_FILTER_COLUMNS
 
#define NOTE_ITERATOR_COLUMNS
 
#define NOTE_ITERATOR_TRASH_COLUMNS
 
#define OVERRIDE_ITERATOR_FILTER_COLUMNS
 
#define OVERRIDE_ITERATOR_COLUMNS
 
#define OVERRIDE_ITERATOR_TRASH_COLUMNS
 
#define SCANNER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "host", "port", "type", NULL }
 
#define SCANNER_ITERATOR_COLUMNS
 
#define SCANNER_ITERATOR_TRASH_COLUMNS
 
#define SCHEDULE_ITERATOR_FILTER_COLUMNS
 
#define SCHEDULE_ITERATOR_COLUMNS
 
#define SCHEDULE_ITERATOR_TRASH_COLUMNS
 
#define REPORT_FORMAT_ITERATOR_FILTER_COLUMNS
 
#define REPORT_FORMAT_ITERATOR_COLUMNS
 
#define REPORT_FORMAT_ITERATOR_TRASH_COLUMNS
 
#define GROUP_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }
 
#define GROUP_ITERATOR_COLUMNS
 
#define GROUP_ITERATOR_TRASH_COLUMNS
 
#define PERMISSION_ITERATOR_FILTER_COLUMNS
 
#define PERMISSION_ITERATOR_COLUMNS
 
#define PERMISSION_ITERATOR_TRASH_COLUMNS
 
#define PORT_LIST_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "total", "tcp", "udp", NULL }
 
#define PORT_LIST_ITERATOR_COLUMNS
 
#define PORT_LIST_ITERATOR_TRASH_COLUMNS
 
#define ROLE_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }
 
#define ROLE_ITERATOR_COLUMNS
 
#define ROLE_ITERATOR_TRASH_COLUMNS
 
#define FILTER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "type", "term", NULL }
 
#define FILTER_ITERATOR_COLUMNS
 
#define FILTER_ITERATOR_TRASH_COLUMNS
 
#define WHERE_OWNER
 
#define HOST_ITERATOR_FILTER_COLUMNS
 
#define HOST_ITERATOR_COLUMNS
 
#define HOST_ITERATOR_WHERE_COLUMNS
 
#define OS_ITERATOR_FILTER_COLUMNS
 
#define OS_ITERATOR_COLUMNS
 
#define OS_ITERATOR_WHERE_COLUMNS
 
#define SETTING_ITERATOR_FILTER_COLUMNS   { "name", "comment", "value", NULL }
 
#define SETTING_ITERATOR_COLUMNS
 
#define CVE_INFO_ITERATOR_FILTER_COLUMNS
 
#define CVE_INFO_ITERATOR_COLUMNS
 
#define CPE_INFO_ITERATOR_FILTER_COLUMNS
 
#define CPE_INFO_ITERATOR_COLUMNS
 
#define OVALDEF_INFO_ITERATOR_FILTER_COLUMNS
 
#define OVALDEF_INFO_ITERATOR_COLUMNS
 
#define CERT_BUND_ADV_INFO_ITERATOR_FILTER_COLUMNS
 
#define CERT_BUND_ADV_INFO_ITERATOR_COLUMNS
 
#define DFN_CERT_ADV_INFO_ITERATOR_FILTER_COLUMNS
 
#define DFN_CERT_ADV_INFO_ITERATOR_COLUMNS
 
#define ALL_INFO_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "type", "extra", "severity", NULL }
 
#define ALL_INFO_ITERATOR_COLUMNS
 
#define ALL_INFO_ITERATOR_COLUMNS_ARGS(type, extra, severity)
 
#define ALL_INFO_UNION_COLUMNS
 
#define ALL_INFO_UNION_COLUMNS_LIMIT
 
#define USER_ITERATOR_FILTER_COLUMNS
 
#define USER_ITERATOR_COLUMNS
 
#define USER_ITERATOR_TRASH_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
 

Functions

int manage_create_sql_functions ()
 Create functions. More...
 
void create_tables ()
 Create all tables. More...
 
void check_db_sequences ()
 Ensure sequences for automatic ids are in a consistent state. More...
 
void manage_attach_databases ()
 Attach external databases. More...
 
int manage_cert_loaded ()
 Check whether CERT is available. More...
 
int manage_scap_loaded ()
 Check whether SCAP is available. More...
 
const char * threat_message_type (const char *)
 Get the message type of a threat. More...
 
const char * message_type_threat (const char *)
 Get the threat of a message type. More...
 
int delete_reports (task_t)
 Delete all the reports for a task. More...
 
int delete_slave_task (const char *, int, const char *, const char *, const char *)
 
int set_certs (const char *, const char *, const char *)
 Initialise OpenVAS scanner variables, checking for defaults. More...
 
gchar * predefined_report_format_dir (const gchar *)
 Get the directory of a report format. More...
 
int stop_task_internal (task_t)
 Initiate stopping a task. More...
 
int validate_username (const gchar *)
 Validates a username. More...
 
void make_port_ranges_iana_tcp_2012 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_iana_tcp_udp_2012 (port_list_t)
 Make port ranges for IANA TCP and UDP 2012. More...
 
void make_port_ranges_all_tcp_nmap_5_51_top_100 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_all_tcp_nmap_5_51_top_1000 (port_list_t)
 Make port ranges for IANA TCP 2012. More...
 
void make_port_ranges_nmap_5_51_top_2000_top_100 (port_list_t)
 Make port ranges for Nmap top 2000 top 100. More...
 
void make_config_discovery (char *const, const char *const)
 
void make_config_discovery_service_detection (char *const)
 Make Discovery Scan Config. More...
 
void make_config_host_discovery (char *const, const char *const)
 
void make_config_system_discovery (char *const, const char *const)
 
int check_config_discovery (const char *)
 Ensure the Discovery config is up to date. More...
 
void check_config_host_discovery (const char *)
 Ensure the Host Discovery config is up to date. More...
 
int check_config_system_discovery (const char *)
 Ensure the Discovery config is up to date. More...
 
int family_count ()
 
int delete_task_lock (task_t, int)
 
gchar * clean_hosts (const char *, int *)
 
int create_port_list_unique (const char *, const char *, const char *, port_list_t *)
 
int valid_type (const char *type)
 Check whether a resource type name is valid. More...
 
gboolean find_group (const char *, group_t *)
 
gboolean find_role (const char *, group_t *)
 
gboolean find_role_with_permission (const char *, role_t *, const char *)
 
int user_ensure_in_db (const gchar *name, const gchar *method)
 Ensure the user exists in the database. More...
 
void cleanup_prognosis_iterator ()
 
int set_password (const gchar *, const gchar *, const gchar *, gchar **)
 
void permissions_set_locations (const char *, resource_t, resource_t, int)
 
void permissions_set_orphans (const char *, resource_t, int)
 
void permissions_set_subjects (const char *, resource_t, resource_t, int)
 
resource_t permission_subject (permission_t)
 
char * permission_subject_type (permission_t)
 
void tags_set_locations (const char *, resource_t, resource_t, int)
 
void tags_set_orphans (const char *, resource_t, int)
 
int role_is_predefined (role_t)
 
int role_is_predefined_id (const char *)
 
int valid_omp_command (const char *name)
 Check whether a command name is valid. More...
 
gchar * omp_command_type (const char *name)
 Get the type associated with an OMP command. More...
 
void array_add_new_string (array_t *array, const gchar *string)
 Ensure a string is in an array. More...
 
int parse_iso_time (const char *text_time)
 Convert an ISO time into seconds since epoch. More...
 
int days_from_now (time_t *epoch_time)
 Calculate difference between now and epoch_time in days. More...
 
char * iso_time (time_t *epoch_time)
 Create an ISO time from seconds since epoch. More...
 
char * iso_time_tz (time_t *epoch_time, const char *timezone, const char **abbrev)
 Create an ISO time from seconds since epoch, given a timezone. More...
 
gchar * tag_value (const gchar *tags, const gchar *tag)
 Extract a tag from an OTP tag list. More...
 
int parse_time (const gchar *string, int *seconds)
 Try convert an OTP NVT tag time string into epoch time. More...
 
int manage_option_setup (GSList *log_config, const gchar *database)
 Setup for an option process. More...
 
void manage_option_cleanup ()
 Cleanup for an option process. More...
 
void column_array_print (column_t *columns)
 Print an array of columns. More...
 
column_tcolumn_array_copy (column_t *columns)
 Copy an array of columns. More...
 
void column_array_free (column_t *columns)
 Free an array of columns. More...
 
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...
 
void filter_free (array_t *split)
 Free a split filter. 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...
 
int filter_control_int (keyword_t **point, const char *column, int *val)
 Get an int column from a filter split. More...
 
int filter_control_str (keyword_t **point, const char *column, gchar **string)
 Get a string column from a filter split. More...
 
void manage_report_filter_controls (const gchar *filter, int *first, int *max, gchar **sort_field, int *sort_order, int *result_hosts_only, gchar **min_qod, gchar **levels, gchar **delta_states, gchar **search_phrase, int *search_phrase_exact, int *autofp, int *notes, int *overrides, int *apply_overrides, gchar **zone)
 Get info from a filter for report. More...
 
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...
 
const char * type_pretty_name (const char *type)
 Return pretty name of type. More...
 
const char * type_db_name (const char *type)
 Return DB name of type. More...
 
int type_named (const char *type)
 Check whether a type has a name and comment. More...
 
int type_has_comment (const char *type)
 Check whether a type has a comment. More...
 
int type_owned (const char *type)
 Check whether a resource type has an owner. 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...
 
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 (const char *type, const char *name, const char *comment, const char *resource_id, const char *columns, int make_name_unique, resource_t *new_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...
 
column_ttype_select_columns (const char *type, int)
 
column_ttype_where_columns (const char *type, int)
 
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 *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...
 
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...
 
char * manage_port_name (int number, const char *protocol)
 Returns associated name for a tcp/ip port. More...
 
gchar * port_name_formatted (const char *field)
 Returns formatted port number, protocol and iana name from. More...
 
void set_db_version (int version)
 Set the database version of the actual database. More...
 
int manage_encrypt_all_credentials (GSList *log_config, const gchar *database)
 Encrypt or re-encrypt all credentials. More...
 
int manage_decrypt_all_credentials (GSList *log_config, const gchar *database)
 Decrypt all credentials. More...
 
int collate_message_type (void *data, int one_len, const void *arg_one, int two_len, const void *arg_two)
 Collate two message type strings. More...
 
int collate_ip (void *data, int one_len, const void *arg_one, int two_len, const void *arg_two)
 Collate two IP addresses. More...
 
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...
 
int manage_check_alerts (GSList *log_config, const gchar *database)
 Check if any SecInfo alerts are due. More...
 
gboolean find_alert_with_permission (const char *uuid, alert_t *alert, const char *permission)
 Find a alert for a specific permission, given a UUID. More...
 
int validate_scp_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the SCP method. More...
 
int validate_send_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the Send method. More...
 
int validate_smb_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the Send method. More...
 
int validate_tippingpoint_data (alert_method_t method, const gchar *name, gchar **data)
 Validate method data for the TippingPoint method. More...
 
int create_alert (const char *name, const char *comment, const char *filter_id, 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, 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...
 
char * alert_name (alert_t alert)
 Return the name of an alert. More...
 
char * alert_owner_uuid (alert_t alert)
 Return the UUID of the owner of an alert. More...
 
char * alert_filter_id (alert_t alert)
 Return the UUID of the filter of 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...
 
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...
 
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...
 
void init_task_alert_iterator (iterator_t *iterator, task_t task, event_t event)
 Initialise a task alert iterator. More...
 
alert_t task_alert_iterator_alert (iterator_t *iterator)
 Get the alert from a task alert iterator. More...
 
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...
 
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...
 
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...
 
int init_task_iterator (iterator_t *iterator, const get_data_t *get)
 Initialise a task iterator. More...
 
task_status_t task_iterator_run_status (iterator_t *iterator)
 Get the run status from a task iterator. More...
 
int task_iterator_total_reports (iterator_t *iterator)
 Get the number of reports of a task iterator. More...
 
const char * task_iterator_first_report (iterator_t *iterator)
 Get the first report UUID from a task iterator. More...
 
const char * task_iterator_run_status_name (iterator_t *iterator)
 Get the run status name from a task iterator. More...
 
const char * task_iterator_last_report (iterator_t *iterator)
 Get the last report UUID from a task iterator. More...
 
int task_iterator_finished_reports (iterator_t *iterator)
 Get the number of reports of a task iterator. More...
 
const char * task_iterator_hosts_ordering (iterator_t *iterator)
 Get the hosts ordering value from a task iterator. More...
 
scanner_t task_iterator_scanner (iterator_t *iterator)
 Get the UUID of task scanner from a task iterator. More...
 
int task_in_use (task_t task)
 Return whether a task is in use by a task. More...
 
int trash_task_in_use (task_t task)
 Return whether a trashcan task is referenced by a task. More...
 
int task_alterable (task_t task)
 Return whether a task is an Alterable Task. More...
 
int task_writable (task_t task)
 Return whether a task is writable. More...
 
int trash_task_writable (task_t task)
 Return whether a trashcan task is writable. More...
 
int task_average_scan_duration (task_t task)
 Get the average duration of all finished reports of a task. More...
 
void init_manage_process (int update_nvt_cache, const gchar *database)
 Initialize the manage library for a process. More...
 
void reinit_manage_process ()
 Reinitialize the manage library for a process. More...
 
int manage_update_nvti_cache ()
 Update the memory cache of NVTs, if this has been requested. More...
 
void add_role_permission (const gchar *role, const gchar *permission)
 Add permission to role. More...
 
void refresh_nvt_cves ()
 Refresh nvt_cves table. More...
 
int check_db_versions (int nvt_cache_mode)
 Ensure that the databases are the right versions. More...
 
void check_generate_scripts ()
 Ensure the generate scripts are all executable. More...
 
void stop_active_tasks ()
 Stop any active tasks. More...
 
void cleanup_tables ()
 Clean up database tables. More...
 
int init_manage (GSList *log_config, int nvt_cache_mode, const gchar *database, int max_ips_per_target, int max_email_attachment_size, int max_email_include_size, int max_email_message_size, void(*update_progress)(), int(*fork_connection)(openvas_connection_t *, gchar *), int skip_db_check)
 Initialize the manage library. More...
 
int init_manage_helper (GSList *log_config, const gchar *database, int max_ips_per_target, void(*update_progress)())
 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. More...
 
gchar * manage_user_hash (const gchar *username)
 Get user hash. More...
 
gchar * user_uuid_method (const gchar *username, auth_method_t method)
 Get user uuid. More...
 
gchar * user_uuid_any_method (const gchar *name)
 Get user uuid, trying all authentication methods. More...
 
int user_exists (const gchar *name)
 Check if user exists. More...
 
int manage_scanner_set (const char *uuid)
 Set the address of scanner to connect to. More...
 
int manage_scanner_set_default ()
 Set the default scanner as the scanner to connect to. More...
 
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...
 
int resource_id_exists (const char *type, const char *id)
 Test whether a resource of the given type and unique ID exists. More...
 
int trash_id_exists (const char *type, const char *id)
 Test Whether a resource of the given type and ID exists in the trash. More...
 
unsigned int task_count (const get_data_t *get)
 Return the number of tasks associated with the current user. More...
 
unsigned int task_id (task_t task)
 Return the identifier of a task. 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...
 
char * task_owner_name (task_t task)
 Return the name of the owner of a task. More...
 
char * task_name (task_t task)
 Return the name of a task. More...
 
char * task_comment (task_t task)
 Return the comment of a task. More...
 
char * task_hosts_ordering (task_t task)
 Return the hosts ordering of a task. More...
 
char * task_observers (task_t task)
 Return the observers of a task. More...
 
config_t task_config (task_t task)
 Return the config of a task. More...
 
char * task_config_uuid (task_t task)
 Return the UUID of the config of a task. More...
 
char * task_config_name (task_t task)
 Return the name of the config of a task. More...
 
int task_config_in_trash (task_t task)
 Return whether the config of a task is in the trashcan. More...
 
void set_task_config (task_t task, config_t config)
 Set the config of a task. More...
 
target_t task_target (task_t task)
 Return the target of a task. More...
 
void set_task_target (task_t task, target_t target)
 Set the target of a task. More...
 
void set_task_hosts_ordering (task_t task, const char *ordering)
 Set the hosts ordering of a task. More...
 
int task_target_in_trash (task_t task)
 Return whether the target of a task is in the trashcan. More...
 
scanner_t task_scanner (task_t task)
 Return the scanner of a task. More...
 
void set_task_scanner (task_t task, scanner_t scanner)
 Set the scanner of a task. More...
 
int task_scanner_in_trash (task_t task)
 Return whether the scanner of a task is in the trashcan. More...
 
task_status_t task_run_status (task_t task)
 Return the run state of a task. More...
 
void set_report_scheduled (report_t report)
 Set a report's scheduled flag. More...
 
void set_task_run_status (task_t task, task_status_t status)
 Set the run state of a task. More...
 
int set_task_requested (task_t task, task_status_t *status)
 Atomically set the run state of a task to requested. More...
 
int task_result_count (task_t task, int min_qod)
 Return number of results in a task. More...
 
report_t task_running_report (task_t task)
 Return the running report of a task. More...
 
report_t task_iterator_current_report (iterator_t *iterator)
 Return the current report of a task. More...
 
int task_upload_progress (task_t task)
 Return the upload progress of a task. More...
 
void set_task_start_time (task_t task, char *time)
 Set the start time of a task. More...
 
void set_task_start_time_epoch (task_t task, int time)
 Set the start time of a task. More...
 
void set_task_start_time_otp (task_t task, char *time)
 Set the start time of a task. More...
 
int task_last_report (task_t task, report_t *report)
 Get the report from the most recently completed invocation of task. More...
 
int task_last_stopped_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...
 
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)
 Set the next time a scheduled task will be due. More...
 
void set_task_schedule_next_time (task_t task, time_t time)
 Set the next time a scheduled task will be due. More...
 
void set_task_schedule_next_time_uuid (const gchar *task_id, time_t time)
 Set the next time a scheduled task will be due. More...
 
char * task_severity (task_t task, int overrides, int min_qod, int offset)
 Return the severity score of a task, taking overrides into account. More...
 
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...
 
int set_task_observers (task_t task, const gchar *observers)
 Set the observers of a task. More...
 

Variables

int authenticate_allow_all
 Flag to force authentication to succeed. More...
 
int(* manage_fork_connection )(openvas_connection_t *, gchar *) = NULL
 Function to fork a connection that will accept OMP requests. More...
 
void(* progress )() = NULL
 Function to mark progress. More...
 
nvtis_t * nvti_cache = NULL
 Memory cache of NVT information from the database. More...
 
gchar * task_db_name = NULL
 Name of the database file. More...
 
command_t omp_commands []
 The OMP command list. More...
 
int table_order_if_sort_not_specified = 0
 Flag to control the default sorting produced by split filter. More...
 

Detailed Description

The OpenVAS Manager management library (SQLite implementation).

This file defines the SQLite specific portions of the OpenVAS manager management library.

Definition in file manage_sql.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 35 of file manage_sql.c.

◆ AGENT_ITERATOR_COLUMNS

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

◆ AGENT_ITERATOR_FILTER_COLUMNS

#define AGENT_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "trust", NULL }

◆ AGENT_ITERATOR_TRASH_COLUMNS

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

◆ AGGREGATE_ITERATOR_N_STATS

#define AGGREGATE_ITERATOR_N_STATS   4

◆ AGGREGATE_ITERATOR_OFFSET

#define AGGREGATE_ITERATOR_OFFSET   3

◆ 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 }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81

Alert iterator columns.

Definition at line 8456 of file manage_sql.c.

Referenced by alert_count(), and init_alert_iterator().

◆ ALERT_ITERATOR_FILTER_COLUMNS

#define ALERT_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "event", "condition", "method", \
"filter", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

Filter columns for alert iterator.

Definition at line 8449 of file manage_sql.c.

Referenced by alert_count(), and init_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}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

Alert iterator columns for trash case.

Definition at line 8470 of file manage_sql.c.

Referenced by alert_count(), and init_alert_iterator().

◆ ALL_INFO_ITERATOR_COLUMNS

#define ALL_INFO_ITERATOR_COLUMNS
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "comment", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (created)", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (modified)", NULL, KEYWORD_TYPE_STRING }, \
{ "created", NULL, KEYWORD_TYPE_INTEGER }, \
{ "modified", NULL, KEYWORD_TYPE_INTEGER }, \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "type", NULL, KEYWORD_TYPE_STRING }, \
{ "extra", NULL, KEYWORD_TYPE_STRING }, \
{ "severity", NULL, KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ ALL_INFO_ITERATOR_COLUMNS_ARGS

#define ALL_INFO_ITERATOR_COLUMNS_ARGS (   type,
  extra,
  severity 
)
Value:
{ \
{ "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "comment", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (created)", NULL, KEYWORD_TYPE_STRING }, \
{ "iso_time (modified)", NULL, KEYWORD_TYPE_STRING }, \
{ "created", NULL, KEYWORD_TYPE_INTEGER }, \
{ "modified", NULL, KEYWORD_TYPE_INTEGER }, \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ type, "type", KEYWORD_TYPE_STRING }, \
{ extra, "extra", KEYWORD_TYPE_STRING }, \
{ severity, "severity", KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ ALL_INFO_ITERATOR_FILTER_COLUMNS

#define ALL_INFO_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "type", "extra", "severity", NULL }

◆ ALL_INFO_UNION_COLUMNS

#define ALL_INFO_UNION_COLUMNS
Value:
"(SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner, 'cve' AS type," \
" description AS extra, cvss AS severity" \
" FROM cves" \
" UNION ALL SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner," \
" 'cpe' AS type, title AS extra, max_cvss AS severity" \
" FROM cpes" \
" UNION ALL SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner," \
" 'nvt' AS type, tag AS extra," \
" CAST (cvss_base AS float) AS severity" \
" FROM nvts" \
" UNION ALL SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner," \
" 'cert_bund_adv' AS type, title AS extra," \
" max_cvss AS severity" \
" FROM cert_bund_advs" \
" UNION ALL SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner," \
" 'dfn_cert_adv' AS type, title AS extra," \
" max_cvss AS severity" \
" FROM dfn_cert_advs" \
" UNION ALL SELECT " GET_ITERATOR_COLUMNS_STRING ", '' AS _owner," \
" 'ovaldef' AS type, title AS extra, max_cvss AS severity" \
" FROM ovaldefs)" \
" AS allinfo"
#define GET_ITERATOR_COLUMNS_STRING
Columns for GET iterator, as a single string.
Definition: manage_sql.c:4153

◆ ALL_INFO_UNION_COLUMNS_LIMIT

#define ALL_INFO_UNION_COLUMNS_LIMIT

◆ ANON_GET_ITERATOR_FILTER_COLUMNS

#define ANON_GET_ITERATOR_FILTER_COLUMNS
Value:
"uuid", \
"created", "modified", "_owner"

Filter columns for GET iterator.

Definition at line 4139 of file manage_sql.c.

◆ CERT_BUND_ADV_INFO_ITERATOR_COLUMNS

#define CERT_BUND_ADV_INFO_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "title", NULL, KEYWORD_TYPE_STRING }, \
{ "summary", NULL, KEYWORD_TYPE_STRING }, \
{ "cve_refs", "cves", KEYWORD_TYPE_INTEGER }, \
{ "max_cvss", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "max_cvss", "severity", KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ CERT_BUND_ADV_INFO_ITERATOR_FILTER_COLUMNS

#define CERT_BUND_ADV_INFO_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "title", "summary", \
"cves", "max_cvss", "severity", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ CHUNK_SIZE

#define CHUNK_SIZE   100

◆ CONFIG_ITERATOR_COLUMNS

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

◆ CONFIG_ITERATOR_FILTER_COLUMNS

#define CONFIG_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "nvt_selector", "families_total", \
"nvts_total", "families_trend", "nvts_trend", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ CONFIG_ITERATOR_TRASH_COLUMNS

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

◆ CPE_INFO_ITERATOR_COLUMNS

#define CPE_INFO_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "title", NULL, KEYWORD_TYPE_STRING }, \
{ "status", NULL, KEYWORD_TYPE_STRING }, \
{ "deprecated_by_id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "max_cvss", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "cve_refs", "cves", KEYWORD_TYPE_INTEGER }, \
{ "nvd_id", NULL, KEYWORD_TYPE_INTEGER }, \
{ "max_cvss", "severity", KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ CPE_INFO_ITERATOR_FILTER_COLUMNS

#define CPE_INFO_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "title", "status", \
"deprecated_by_id", "max_cvss", "cves", "nvd_id", \
"severity", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ CREATE_REPORT_CHUNK_SIZE

#define CREATE_REPORT_CHUNK_SIZE   10

◆ CREATE_REPORT_CHUNK_SLEEP

#define CREATE_REPORT_CHUNK_SLEEP   1000

◆ CREDENTIAL_ITERATOR_COLUMNS

#define CREDENTIAL_ITERATOR_COLUMNS

◆ CREDENTIAL_ITERATOR_FILTER_COLUMNS

#define CREDENTIAL_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "login", "type", "allow_insecure", NULL }

◆ CREDENTIAL_ITERATOR_TRASH_COLUMNS

#define CREDENTIAL_ITERATOR_TRASH_COLUMNS

◆ CVE_INFO_ITERATOR_COLUMNS

#define CVE_INFO_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "vector", NULL, KEYWORD_TYPE_STRING }, \
{ "complexity", NULL, KEYWORD_TYPE_STRING }, \
{ "authentication", NULL, KEYWORD_TYPE_STRING }, \
{ "confidentiality_impact", NULL, KEYWORD_TYPE_STRING }, \
{ "integrity_impact", NULL, KEYWORD_TYPE_STRING }, \
{ "availability_impact", NULL, KEYWORD_TYPE_STRING }, \
{ "products", NULL, KEYWORD_TYPE_STRING }, \
{ "cvss", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "description", NULL, KEYWORD_TYPE_STRING }, \
{ "cvss", "severity", KEYWORD_TYPE_DOUBLE }, \
{ "creation_time", "published", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ CVE_INFO_ITERATOR_FILTER_COLUMNS

#define CVE_INFO_ITERATOR_FILTER_COLUMNS
Value:
"complexity", "authentication", "confidentiality_impact", \
"integrity_impact", "availability_impact", "products", \
"cvss", "description", "severity", "published", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ CVSS_BASE_SQL

#define CVSS_BASE_SQL   "(SELECT cvss_base FROM nvts WHERE nvts.oid = results.nvt)"

◆ DFN_CERT_ADV_INFO_ITERATOR_COLUMNS

#define DFN_CERT_ADV_INFO_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "title", NULL, KEYWORD_TYPE_STRING }, \
{ "summary", NULL, KEYWORD_TYPE_STRING }, \
{ "cve_refs", "cves", KEYWORD_TYPE_INTEGER }, \
{ "max_cvss", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "max_cvss", "severity", KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ DFN_CERT_ADV_INFO_ITERATOR_FILTER_COLUMNS

#define DFN_CERT_ADV_INFO_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "title", "summary", \
"cves", "max_cvss", "severity", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

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

#define FILTER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "type", "term", NULL }

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

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "md manage"

GLib log domain.

Definition at line 81 of file manage_sql.c.

◆ GET_ITERATOR_COLUMN_COUNT

◆ GET_ITERATOR_COLUMNS

#define GET_ITERATOR_COLUMNS (   table)
Value:
{ \
"(SELECT name FROM users AS inner_users" \
" WHERE inner_users.id = " G_STRINGIFY (table) ".owner)", \
"_owner", \
KEYWORD_TYPE_STRING \
}, \
{ "owner", NULL, KEYWORD_TYPE_INTEGER }
#define GET_ITERATOR_COLUMNS_PREFIX(prefix)
Columns for GET iterator.
Definition: manage_sql.c:4163

Columns for GET iterator.

Parameters
[in]tableTable.

Definition at line 4178 of file manage_sql.c.

◆ GET_ITERATOR_COLUMNS_PREFIX

#define GET_ITERATOR_COLUMNS_PREFIX (   prefix)
Value:
{ prefix "id", NULL, KEYWORD_TYPE_INTEGER }, \
{ prefix "uuid", NULL, KEYWORD_TYPE_STRING }, \
{ prefix "name", NULL, KEYWORD_TYPE_STRING }, \
{ prefix "comment", NULL, KEYWORD_TYPE_STRING }, \
{ " iso_time (" prefix "creation_time)", NULL, KEYWORD_TYPE_STRING }, \
{ " iso_time (" prefix "modification_time)", NULL, KEYWORD_TYPE_STRING }, \
{ prefix "creation_time", "created", KEYWORD_TYPE_INTEGER }, \
{ prefix "modification_time", "modified", KEYWORD_TYPE_INTEGER }

Columns for GET iterator.

Parameters
[in]prefixColumn prefix.

Definition at line 4163 of file manage_sql.c.

◆ GET_ITERATOR_COLUMNS_STRING

#define GET_ITERATOR_COLUMNS_STRING
Value:
"id, uuid, name, comment, iso_time (creation_time)," \
" iso_time (modification_time), creation_time AS created," \
" modification_time AS modified"

Columns for GET iterator, as a single string.

Parameters
[in]prefixColumn prefix.

Definition at line 4153 of file manage_sql.c.

◆ GET_ITERATOR_FILTER_COLUMNS

#define GET_ITERATOR_FILTER_COLUMNS
Value:
"uuid", "name", "comment", \
"created", "modified", "_owner"

Filter columns for GET iterator.

Definition at line 4145 of file manage_sql.c.

◆ GROUP_ITERATOR_COLUMNS

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

◆ GROUP_ITERATOR_FILTER_COLUMNS

#define GROUP_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }

◆ GROUP_ITERATOR_TRASH_COLUMNS

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

◆ HOST_ITERATOR_COLUMNS

#define HOST_ITERATOR_COLUMNS

◆ HOST_ITERATOR_FILTER_COLUMNS

#define HOST_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "severity", "os", "oss", "hostname", "ip", \
"severity_level", "updated", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

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

◆ MANAGE_SEND_REPORT_CHUNK64_SIZE

#define MANAGE_SEND_REPORT_CHUNK64_SIZE   262144

◆ MANAGE_SEND_REPORT_CHUNK_SIZE

#define MANAGE_SEND_REPORT_CHUNK_SIZE   (MANAGE_SEND_REPORT_CHUNK64_SIZE * 3 / 4)

◆ MAX_ATTACH_LENGTH

#define MAX_ATTACH_LENGTH   1048576

Default max number of bytes of reports attached to email alerts.

Definition at line 374 of file manage_sql.c.

◆ MAX_CONTENT_LENGTH

#define MAX_CONTENT_LENGTH   20000

Default max number of bytes of reports included in email alerts.

Definition at line 362 of file manage_sql.c.

◆ MAX_EMAIL_MESSAGE_LENGTH

#define MAX_EMAIL_MESSAGE_LENGTH   2000

Default max number of bytes of user-defined message in email alerts.

Definition at line 386 of file manage_sql.c.

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

Definition at line 13051 of file manage_sql.c.

◆ NEW_CPES_HEADER

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

Header for "New CPEs" alert message.

Definition at line 13043 of file manage_sql.c.

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

Definition at line 13035 of file manage_sql.c.

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

Definition at line 13059 of file manage_sql.c.

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

Definition at line 13019 of file manage_sql.c.

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

Definition at line 13027 of file manage_sql.c.

◆ NEW_OVAL_DEFS_HEADER

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

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

Definition at line 13067 of file manage_sql.c.

◆ NOTE_ITERATOR_COLUMNS

#define NOTE_ITERATOR_COLUMNS

◆ 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 }
#define ANON_GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4139

◆ NOTE_ITERATOR_TRASH_COLUMNS

#define NOTE_ITERATOR_TRASH_COLUMNS

◆ NVT_INFO_ITERATOR_FILTER_COLUMNS

#define NVT_INFO_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "version", "cve", "bid", "xref", \
"family", "cvss_base", "severity", "cvss", "script_tags", "qod", \
"qod_type", "solution_type", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ NVT_ITERATOR_COLUMNS

#define NVT_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "oid", NULL, KEYWORD_TYPE_STRING }, \
{ "version", NULL, KEYWORD_TYPE_STRING }, \
{ "name", NULL, KEYWORD_TYPE_STRING }, \
{ "copyright", NULL, KEYWORD_TYPE_STRING }, \
{ "cve", NULL, KEYWORD_TYPE_STRING }, \
{ "bid", NULL, KEYWORD_TYPE_STRING }, \
{ "xref", NULL, KEYWORD_TYPE_STRING }, \
{ "tag", NULL, KEYWORD_TYPE_STRING }, \
{ "category", NULL, KEYWORD_TYPE_STRING }, \
{ "family", NULL, KEYWORD_TYPE_STRING }, \
{ "cvss_base", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "cvss_base", "severity", KEYWORD_TYPE_DOUBLE }, \
{ "cvss_base", "cvss", KEYWORD_TYPE_DOUBLE }, \
{ "qod", NULL, KEYWORD_TYPE_INTEGER }, \
{ "qod_type", NULL, KEYWORD_TYPE_STRING }, \
{ "solution_type", NULL, KEYWORD_TYPE_STRING }, \
{ "tag", "script_tags", KEYWORD_TYPE_STRING}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ NVT_ITERATOR_COLUMNS_NVTS

#define NVT_ITERATOR_COLUMNS_NVTS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX ("nvts."), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_STRING }, \
{ "oid", NULL, KEYWORD_TYPE_STRING }, \
{ "version", NULL, KEYWORD_TYPE_STRING }, \
{ "nvts.name", NULL, KEYWORD_TYPE_STRING }, \
{ "copyright", NULL, KEYWORD_TYPE_STRING }, \
{ "cve", NULL, KEYWORD_TYPE_STRING }, \
{ "bid", NULL, KEYWORD_TYPE_STRING }, \
{ "xref", NULL, KEYWORD_TYPE_STRING }, \
{ "tag", NULL, KEYWORD_TYPE_STRING }, \
{ "category", NULL, KEYWORD_TYPE_STRING }, \
{ "nvts.family", NULL, KEYWORD_TYPE_STRING }, \
{ "cvss_base", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "cvss_base", "severity", KEYWORD_TYPE_DOUBLE }, \
{ "cvss_base", "cvss", KEYWORD_TYPE_DOUBLE }, \
{ "qod", NULL, KEYWORD_TYPE_INTEGER }, \
{ "qod_type", NULL, KEYWORD_TYPE_STRING }, \
{ "solution_type", NULL, KEYWORD_TYPE_STRING }, \
{ "tag", "script_tags", KEYWORD_TYPE_STRING }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ OPENVASSD_ADDRESS

#define OPENVASSD_ADDRESS   OPENVAS_RUN_DIR "/openvassd.sock"

Scanner (openvassd) address.

Definition at line 86 of file manage_sql.c.

◆ OS_ITERATOR_COLUMNS

#define OS_ITERATOR_COLUMNS

◆ 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", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ 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 \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ OVALDEF_INFO_ITERATOR_COLUMNS

#define OVALDEF_INFO_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS_PREFIX (""), \
{ "''", "_owner", KEYWORD_TYPE_STRING }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "version", NULL, KEYWORD_TYPE_INTEGER }, \
{ "deprecated", NULL, KEYWORD_TYPE_INTEGER }, \
{ "def_class", "class", KEYWORD_TYPE_STRING }, \
{ "title", NULL, KEYWORD_TYPE_STRING }, \
{ "description", NULL, KEYWORD_TYPE_STRING }, \
{ "xml_file", "file", KEYWORD_TYPE_STRING }, \
{ "status", NULL, KEYWORD_TYPE_STRING }, \
{ "max_cvss", NULL, KEYWORD_TYPE_DOUBLE }, \
{ "cve_refs", "cves", KEYWORD_TYPE_INTEGER }, \
{ "max_cvss", "severity", KEYWORD_TYPE_DOUBLE }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ OVALDEF_INFO_ITERATOR_FILTER_COLUMNS

#define OVALDEF_INFO_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "version", "deprecated", \
"class", "title", "description", "file", \
"status", "max_cvss", "cves", "severity", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ OVERRIDE_ITERATOR_COLUMNS

#define OVERRIDE_ITERATOR_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 }
#define ANON_GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4139

◆ OVERRIDE_ITERATOR_TRASH_COLUMNS

#define OVERRIDE_ITERATOR_TRASH_COLUMNS

◆ PASSWORD_LENGTH

#define PASSWORD_LENGTH   10

◆ PERMISSION_ITERATOR_COLUMNS

#define PERMISSION_ITERATOR_COLUMNS

◆ 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 }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ PERMISSION_ITERATOR_TRASH_COLUMNS

#define PERMISSION_ITERATOR_TRASH_COLUMNS

◆ PORT_LIST_ITERATOR_COLUMNS

#define PORT_LIST_ITERATOR_COLUMNS

◆ PORT_LIST_ITERATOR_FILTER_COLUMNS

#define PORT_LIST_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "total", "tcp", "udp", NULL }

◆ PORT_LIST_ITERATOR_TRASH_COLUMNS

#define PORT_LIST_ITERATOR_TRASH_COLUMNS

◆ PRINT

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

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

◆ PRINT_XML

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

◆ RANGE

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

Insert a port range.

Definition at line 14497 of file manage_sql.c.

◆ REPORT_FORMAT_ITERATOR_COLUMNS

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

◆ REPORT_FORMAT_ITERATOR_FILTER_COLUMNS

#define REPORT_FORMAT_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "name", "extension", "content_type", \
"summary", "description", "trust", "trust_time", "active", NULL }
#define ANON_GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4139

◆ REPORT_FORMAT_ITERATOR_TRASH_COLUMNS

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

◆ REPORT_ITERATOR_COLUMNS

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

◆ REPORT_ITERATOR_FILTER_COLUMNS

#define REPORT_ITERATOR_FILTER_COLUMNS
Value:
{ ANON_GET_ITERATOR_FILTER_COLUMNS, "task_id", "name", "date", "status", \
"task", "severity", "false_positive", "log", "low", "medium", "high", \
"hosts", "result_hosts", "fp_per_host", "log_per_host", "low_per_host", \
"medium_per_host", "high_per_host", "duration", "duration_per_host", \
NULL }
#define ANON_GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4139

◆ REPORT_ITERATOR_WHERE_COLUMNS

#define REPORT_ITERATOR_WHERE_COLUMNS

◆ RESULT_ITERATOR_COLUMNS

#define RESULT_ITERATOR_COLUMNS

◆ RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE

#define RESULT_ITERATOR_COLUMNS_SEVERITY_FILTERABLE

◆ RESULT_ITERATOR_FILTER_COLUMNS

#define RESULT_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "host", "location", "nvt", \
"type", "original_type", "auto_type", \
"description", "task", "report", "cvss_base", "nvt_version", \
"severity", "original_severity", "vulnerability", "date", "report_id", \
"solution_type", "qod", "qod_type", "task_id", "cve", "hostname", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ ROLE_ITERATOR_COLUMNS

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

◆ ROLE_ITERATOR_FILTER_COLUMNS

#define ROLE_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, NULL }

◆ ROLE_ITERATOR_TRASH_COLUMNS

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

◆ SCANNER_ITERATOR_COLUMNS

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

◆ SCANNER_ITERATOR_FILTER_COLUMNS

#define SCANNER_ITERATOR_FILTER_COLUMNS   { GET_ITERATOR_FILTER_COLUMNS, "host", "port", "type", NULL }

◆ 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 } \
}
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81

◆ 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 }, \
{ "initial_offset", NULL, KEYWORD_TYPE_INTEGER }, \
{ "next_time (first_time, period, period_months, timezone)", \
"next_run", \
KEYWORD_TYPE_INTEGER }, \
{ "first_time", "first_run", KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ SCHEDULE_ITERATOR_FILTER_COLUMNS

#define SCHEDULE_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "first_time", "period", "period_months", \
"duration", "timezone", "initial_offset", "first_run", "next_run", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ 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 }, \
{ "initial_offset", NULL, KEYWORD_TYPE_INTEGER }, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

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

Definition at line 10702 of file manage_sql.c.

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

#define SETTING_ITERATOR_FILTER_COLUMNS   { "name", "comment", "value", NULL }

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

Definition at line 10684 of file manage_sql.c.

◆ TAG_ITERATOR_COLUMNS

#define TAG_ITERATOR_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (tags), \
{ "resource_type", NULL, KEYWORD_TYPE_STRING }, \
{ "resource", NULL, KEYWORD_TYPE_INTEGER }, \
{ "resource_uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "resource_location", NULL, KEYWORD_TYPE_INTEGER }, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ "value", NULL, KEYWORD_TYPE_STRING }, \
{ "(resource = 0)", "orphan", KEYWORD_TYPE_INTEGER }, \
{ \
"resource_name (resource_type, resource_uuid, resource_location)", \
"resource_name", \
KEYWORD_TYPE_STRING \
}, \
{ NULL, NULL, KEYWORD_TYPE_UNKNOWN } \
}

◆ TAG_ITERATOR_FILTER_COLUMNS

#define TAG_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "resource_type", "resource", "resource_uuid", \
"resource_location", "active", "value", "orphan", "resource_name", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ TAG_ITERATOR_TRASH_COLUMNS

#define TAG_ITERATOR_TRASH_COLUMNS
Value:
{ \
GET_ITERATOR_COLUMNS (tags_trash), \
{ "resource_type", NULL, KEYWORD_TYPE_STRING }, \
{ "resource", NULL, KEYWORD_TYPE_INTEGER }, \
{ "resource_uuid", NULL, KEYWORD_TYPE_STRING }, \
{ "resource_location", NULL, KEYWORD_TYPE_INTEGER }, \
{ "active", NULL, KEYWORD_TYPE_INTEGER }, \
{ "value", NULL, KEYWORD_TYPE_STRING }, \
{ "(resource = 0)", "orphan", KEYWORD_TYPE_INTEGER }, \
{ \
"resource_name (resource_type, resource_uuid, resource_location)", \
"resource_name", \
KEYWORD_TYPE_STRING \
}, \
{ 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 } \
}

◆ TAG_NAME_ITERATOR_FILTER_COLUMNS

#define TAG_NAME_ITERATOR_FILTER_COLUMNS   { "name", "resource_type", NULL }

◆ TARGET_ITERATOR_COLUMNS

#define TARGET_ITERATOR_COLUMNS

◆ TARGET_ITERATOR_FILTER_COLUMNS

#define TARGET_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "hosts", "exclude_hosts", "ips", "port_list", \
"ssh_credential", "smb_credential", "esxi_credential", "snmp_credential", \
NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ TARGET_ITERATOR_TRASH_COLUMNS

#define TARGET_ITERATOR_TRASH_COLUMNS

◆ TASK_ITERATOR_COLUMNS

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

Task iterator columns.

Definition at line 13934 of file manage_sql.c.

Referenced by init_task_iterator(), and task_count().

◆ TASK_ITERATOR_COLUMNS_INNER

#define TASK_ITERATOR_COLUMNS_INNER

Task iterator columns.

Definition at line 13713 of file manage_sql.c.

◆ TASK_ITERATOR_COLUMNS_MIN

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

Task iterator minimal columns.

Definition at line 13944 of file manage_sql.c.

Referenced by init_task_iterator().

◆ TASK_ITERATOR_FILTER_COLUMNS

#define TASK_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "status", "total", "first_report", \
"last_report", "threat", "trend", "severity", "schedule", "next_due", \
"first", "last", "false_positive", "log", "low", "medium", "high", \
"hosts", "result_hosts", "fp_per_host", "log_per_host", "low_per_host", \
"medium_per_host", "high_per_host", "target", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

Filter columns for task iterator.

Definition at line 13703 of file manage_sql.c.

Referenced by init_task_iterator(), and task_count().

◆ TASK_ITERATOR_WHERE_COLUMNS

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

Task iterator WHERE columns.

Definition at line 13925 of file manage_sql.c.

Referenced by init_task_iterator(), and task_count().

◆ TASK_ITERATOR_WHERE_COLUMNS_INNER

#define TASK_ITERATOR_WHERE_COLUMNS_INNER

Task iterator WHERE columns.

Definition at line 13751 of file manage_sql.c.

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

Definition at line 13953 of file manage_sql.c.

Referenced by init_task_iterator().

◆ USER_ITERATOR_COLUMNS

#define USER_ITERATOR_COLUMNS

◆ USER_ITERATOR_FILTER_COLUMNS

#define USER_ITERATOR_FILTER_COLUMNS
Value:
{ GET_ITERATOR_FILTER_COLUMNS, "method", "roles", "groups", "hosts", \
"ifaces", NULL }
#define GET_ITERATOR_FILTER_COLUMNS
Filter columns for GET iterator.
Definition: manage_sql.c:4145

◆ USER_ITERATOR_TRASH_COLUMNS

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

◆ WHERE_OWNER

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

Function Documentation

◆ add_role_permission()

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

Add permission to role.

Caller must ensure args are SQL escaped.

Parameters
[in]roleRole.
[in]permissionPermission.

Definition at line 15524 of file manage_sql.c.

References LOCATION_TABLE, and sql().

15525 {
15526  sql ("INSERT INTO permissions"
15527  " (uuid, owner, name, comment, resource_type, resource, resource_uuid,"
15528  " resource_location, subject_type, subject, subject_location,"
15529  " creation_time, modification_time)"
15530  " VALUES"
15531  " (make_uuid (), NULL, lower ('%s'), '', '',"
15532  " 0, '', " G_STRINGIFY (LOCATION_TABLE) ", 'role',"
15533  " (SELECT id FROM roles WHERE uuid = '%s'),"
15534  " " G_STRINGIFY (LOCATION_TABLE) ", m_now (), m_now ());",
15535  permission,
15536  role);
15537 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

◆ add_task_alert()

void add_task_alert ( task_t  task,
alert_t  alert 
)

Add an alert to a task.

Parameters
[in]taskTask.
[in]alertAlert.

Definition at line 18656 of file manage_sql.c.

References LOCATION_TABLE, and sql().

18657 {
18658  sql ("INSERT INTO task_alerts (task, alert, alert_location)"
18659  " VALUES (%llu, %llu, " G_STRINGIFY (LOCATION_TABLE) ");",
18660  task,
18661  alert);
18662 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

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

Definition at line 5923 of file manage_sql.c.

References sql_column_int(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

5924 {
5925  return sql_column_int (iterator->stmt, 0);
5926 }
A generic SQL iterator.
Definition: iterator.h:52
int sql_column_int(sql_stmt_t *, int)
Return a column as an integer from a prepared statement.
Definition: sql_pg.c:906
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 5953 of file manage_sql.c.

References AGGREGATE_ITERATOR_N_STATS, AGGREGATE_ITERATOR_OFFSET, sql_column_double(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

5954 {
5955  return sql_column_double (iterator->stmt,
5957  + data_column_index * AGGREGATE_ITERATOR_N_STATS);
5958 }
double sql_column_double(sql_stmt_t *, int)
Return a column as a double from a prepared statement.
Definition: sql_pg.c:868
A generic SQL iterator.
Definition: iterator.h:52
#define AGGREGATE_ITERATOR_OFFSET
Definition: manage_sql.c:5912
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
#define AGGREGATE_ITERATOR_N_STATS
Definition: manage_sql.c:5913
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 5969 of file manage_sql.c.

References AGGREGATE_ITERATOR_N_STATS, AGGREGATE_ITERATOR_OFFSET, sql_column_double(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

5970 {
5971  return sql_column_double (iterator->stmt,
5973  + data_column_index * AGGREGATE_ITERATOR_N_STATS);
5974 }
double sql_column_double(sql_stmt_t *, int)
Return a column as a double from a prepared statement.
Definition: sql_pg.c:868
A generic SQL iterator.
Definition: iterator.h:52
#define AGGREGATE_ITERATOR_OFFSET
Definition: manage_sql.c:5912
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
#define AGGREGATE_ITERATOR_N_STATS
Definition: manage_sql.c:5913
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 5937 of file manage_sql.c.

References AGGREGATE_ITERATOR_N_STATS, AGGREGATE_ITERATOR_OFFSET, sql_column_double(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

5938 {
5939  return sql_column_double (iterator->stmt,
5941  + data_column_index * AGGREGATE_ITERATOR_N_STATS);
5942 }
double sql_column_double(sql_stmt_t *, int)
Return a column as a double from a prepared statement.
Definition: sql_pg.c:868
A generic SQL iterator.
Definition: iterator.h:52
#define AGGREGATE_ITERATOR_OFFSET
Definition: manage_sql.c:5912
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
#define AGGREGATE_ITERATOR_N_STATS
Definition: manage_sql.c:5913
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 6042 of file manage_sql.c.

References iterator::done, sql_column_text(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

6043 {
6044  const char *ret;
6045  if (iterator->done) return NULL;
6046  ret = (const char*) sql_column_text (iterator->stmt, 2);
6047  return ret;
6048 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * sql_column_text(sql_stmt_t *, int)
Return a column as text from a prepared statement.
Definition: sql_pg.c:887
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 5985 of file manage_sql.c.

References AGGREGATE_ITERATOR_N_STATS, AGGREGATE_ITERATOR_OFFSET, sql_column_double(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

5986 {
5987  return sql_column_double (iterator->stmt,
5989  + data_column_index * AGGREGATE_ITERATOR_N_STATS);
5990 }
double sql_column_double(sql_stmt_t *, int)
Return a column as a double from a prepared statement.
Definition: sql_pg.c:868
A generic SQL iterator.
Definition: iterator.h:52
#define AGGREGATE_ITERATOR_OFFSET
Definition: manage_sql.c:5912
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
#define AGGREGATE_ITERATOR_N_STATS
Definition: manage_sql.c:5913
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 6003 of file manage_sql.c.

References AGGREGATE_ITERATOR_N_STATS, AGGREGATE_ITERATOR_OFFSET, iterator::done, sql_column_text(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

6005 {
6006  const char *ret;
6007  if (iterator->done) return NULL;
6008  ret = (const char*) sql_column_text (iterator->stmt,
6010  + (data_columns
6012  + text_column_index);
6013  return ret;
6014 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define AGGREGATE_ITERATOR_OFFSET
Definition: manage_sql.c:5912
const char * sql_column_text(sql_stmt_t *, int)
Return a column as text from a prepared statement.
Definition: sql_pg.c:887
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
#define AGGREGATE_ITERATOR_N_STATS
Definition: manage_sql.c:5913
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 6025 of file manage_sql.c.

References iterator::done, sql_column_text(), and iterator::stmt.

Referenced by buffer_aggregate_xml().

6026 {
6027  const char *ret;
6028  if (iterator->done) return NULL;
6029  ret = (const char*) sql_column_text (iterator->stmt, 1);
6030  return ret;
6031 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * sql_column_text(sql_stmt_t *, int)
Return a column as text from a prepared statement.
Definition: sql_pg.c:887
sql_stmt_t * stmt
SQL statement.
Definition: iterator.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 8489 of file manage_sql.c.

References ALERT_ITERATOR_COLUMNS, ALERT_ITERATOR_FILTER_COLUMNS, and ALERT_ITERATOR_TRASH_COLUMNS.

8490 {
8491  static const char *filter_columns[] = ALERT_ITERATOR_FILTER_COLUMNS;
8492  static column_t columns[] = ALERT_ITERATOR_COLUMNS;
8493  static column_t trash_columns[] = ALERT_ITERATOR_TRASH_COLUMNS;
8494  return count ("alert", get, columns, trash_columns, filter_columns, 0, 0, 0,
8495  TRUE);
8496 }
Iterator column.
Definition: manage_sql.c:1512
#define ALERT_ITERATOR_FILTER_COLUMNS
Filter columns for alert iterator.
Definition: manage_sql.c:8449
#define ALERT_ITERATOR_TRASH_COLUMNS
Alert iterator columns for trash case.
Definition: manage_sql.c:8470
#define ALERT_ITERATOR_COLUMNS
Alert iterator columns.
Definition: manage_sql.c:8456

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

Definition at line 8810 of file manage_sql.c.

References sql_quote(), and sql_string().

Referenced by alert_condition_description(), and migrate_165_to_166().

8811 {
8812  gchar *quoted_name;
8813  char *data;
8814 
8815  assert (strcmp (type, "condition") == 0
8816  || strcmp (type, "event") == 0
8817  || strcmp (type, "method") == 0);
8818 
8819  quoted_name = sql_quote (name);
8820  data = sql_string ("SELECT data FROM alert_%s_data"
8821  " WHERE alert = %llu AND name = '%s';",
8822  type,
8823  alert,
8824  quoted_name);
8825  g_free (quoted_name);
8826  return data;
8827 }
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 8792 of file manage_sql.c.

References iterator::done, and iterator_string().

8793 {
8794  const char *ret;
8795  if (iterator->done) return NULL;
8796  ret = iterator_string (iterator, 1);
8797  return ret;
8798 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
Here is the call graph for this function:

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

Definition at line 8775 of file manage_sql.c.

References iterator::done, and iterator_string().

8776 {
8777  const char *ret;
8778  if (iterator->done) return NULL;
8779  ret = iterator_string (iterator, 0);
8780  return ret;
8781 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
Here is the call graph for this function:

◆ alert_filter_id()

char* alert_filter_id ( alert_t  alert)

Return the UUID of the filter of an alert.

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

Definition at line 8390 of file manage_sql.c.

References sql_string().

8391 {
8392  return sql_string ("SELECT"
8393  " (CASE WHEN (SELECT filter IS NULL OR filter = 0"
8394  " FROM alerts WHERE id = %llu)"
8395  " THEN NULL"
8396  " ELSE (SELECT uuid FROM filters"
8397  " WHERE id = (SELECT filter FROM alerts"
8398  " WHERE id = %llu))"
8399  " END);",
8400  alert,
8401  alert);
8402 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 8506 of file manage_sql.c.

References sql_int().

8507 {
8508  return !!sql_int ("SELECT count (*) FROM task_alerts WHERE alert = %llu;",
8509  alert);
8510 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 8606 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int().

8607 {
8608  int ret;
8609  if (iterator->done) return -1;
8611  return ret;
8612 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 8590 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int().

8591 {
8592  int ret;
8593  if (iterator->done) return -1;
8595  return ret;
8596 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

◆ alert_iterator_filter()

filter_t alert_iterator_filter ( iterator_t iterator)

Return the filter from an alert iterator.

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

Definition at line 8638 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int64().

Referenced by alert_iterator_filter_name(), alert_iterator_filter_readable(), alert_iterator_filter_trash(), and alert_iterator_filter_uuid().

8639 {
8640  if (iterator->done) return -1;
8642 }
long long int filter_t
Definition: manage.h:281
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
Definition: sql.c:637
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 8677 of file manage_sql.c.

References alert_iterator_filter(), iterator::done, filter_name(), GET_ITERATOR_COLUMN_COUNT, iterator_int(), LOCATION_TABLE, and trash_filter_name().

8678 {
8679  filter_t filter;
8680 
8681  if (iterator->done) return NULL;
8682 
8683  filter = alert_iterator_filter (iterator);
8684  if (filter)
8685  {
8687  == LOCATION_TABLE)
8688  return filter_name (filter);
8689  return trash_filter_name (filter);
8690  }
8691  return NULL;
8692 }
long long int filter_t
Definition: manage.h:281
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
char * trash_filter_name(filter_t)
filter_t alert_iterator_filter(iterator_t *iterator)
Return the filter from an alert iterator.
Definition: manage_sql.c:8638
char * filter_name(filter_t)
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 8720 of file manage_sql.c.

References acl_user_has_access_uuid(), alert_iterator_filter(), alert_iterator_filter_uuid(), iterator::done, GET_ITERATOR_COLUMN_COUNT, iterator_int(), and LOCATION_TRASH.

8721 {
8722  filter_t filter;
8723 
8724  if (iterator->done) return 0;
8725 
8726  filter = alert_iterator_filter (iterator);
8727  if (filter)
8728  {
8729  char *uuid;
8731  if (uuid)
8732  {
8733  int readable;
8734  readable = acl_user_has_access_uuid
8735  ("filter", uuid, "get_filters",
8737  == LOCATION_TRASH);
8738  free (uuid);
8739  return readable;
8740  }
8741  }
8742  return 0;
8743 }
long long int filter_t
Definition: manage.h:281
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
int acl_user_has_access_uuid(const char *type, const char *uuid, const char *permission, int trash)
Test whether the user may access a resource.
Definition: manage_acl.c:758
gboolean done
End flag.
Definition: iterator.h:55
char * alert_iterator_filter_uuid(iterator_t *iterator)
Return the filter UUID from an alert iterator.
Definition: manage_sql.c:8652
filter_t alert_iterator_filter(iterator_t *iterator)
Return the filter from an alert iterator.
Definition: manage_sql.c:8638
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 8702 of file manage_sql.c.

References alert_iterator_filter(), iterator::done, GET_ITERATOR_COLUMN_COUNT, iterator_int(), and LOCATION_TRASH.

8703 {
8704  if (iterator->done) return 0;
8707  == LOCATION_TRASH))
8708  return 1;
8709  return 0;
8710 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
filter_t alert_iterator_filter(iterator_t *iterator)
Return the filter from an alert iterator.
Definition: manage_sql.c:8638
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 8652 of file manage_sql.c.

References alert_iterator_filter(), iterator::done, filter_uuid(), GET_ITERATOR_COLUMN_COUNT, iterator_int(), LOCATION_TABLE, and trash_filter_uuid().

Referenced by alert_iterator_filter_readable().

8653 {
8654  filter_t filter;
8655 
8656  if (iterator->done) return NULL;
8657 
8658  filter = alert_iterator_filter (iterator);
8659  if (filter)
8660  {
8662  == LOCATION_TABLE)
8663  return filter_uuid (filter);
8664  return trash_filter_uuid (filter);
8665  }
8666  return NULL;
8667 }
long long int filter_t
Definition: manage.h:281
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
char * filter_uuid(filter_t)
filter_t alert_iterator_filter(iterator_t *iterator)
Return the filter from an alert iterator.
Definition: manage_sql.c:8638
char * trash_filter_uuid(filter_t)
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 8622 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int().

8623 {
8624  int ret;
8625  if (iterator->done) return -1;
8627  return ret;
8628 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

◆ alert_name()

char* alert_name ( alert_t  alert)

Return the name of an alert.

Parameters
[in]alertAlert.
Returns
Name of alert.

Definition at line 8362 of file manage_sql.c.

References sql_string().

8363 {
8364  return sql_string ("SELECT name FROM alerts WHERE id = %llu;", alert);
8365 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ alert_owner_uuid()

char* alert_owner_uuid ( alert_t  alert)

Return the UUID of the owner of an alert.

Parameters
[in]alertAlert.
Returns
UUID of owner.

Definition at line 8375 of file manage_sql.c.

References sql_string().

8376 {
8377  return sql_string ("SELECT uuid FROM users"
8378  " WHERE id = (SELECT owner FROM alerts WHERE id = %llu);",
8379  alert);
8380 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 13627 of file manage_sql.c.

References iterator::done, and iterator_string().

13628 {
13629  const char *ret;
13630  if (iterator->done) return NULL;
13631  ret = iterator_string (iterator, 0);
13632  return ret;
13633 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
Here is the call graph for this function:

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

Definition at line 13659 of file manage_sql.c.

References iterator::done, and iterator_int().

13660 {
13661  if (iterator->done) return 0;
13662  return iterator_int (iterator, 2);
13663 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
Here is the call graph for this function:

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

Definition at line 13643 of file manage_sql.c.

References iterator::done, and iterator_string().

13644 {
13645  const char *ret;
13646  if (iterator->done) return NULL;
13647  ret = iterator_string (iterator, 1);
13648  return ret;
13649 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
Here is the call graph for this function:

◆ alert_uuid()

char* alert_uuid ( alert_t  alert)

Return the UUID of an alert.

Parameters
[in]alertAlert.
Returns
UUID of alert.

Definition at line 8348 of file manage_sql.c.

References sql_string().

8349 {
8350  return sql_string ("SELECT uuid FROM alerts WHERE id = %llu;",
8351  alert);
8352 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ alert_writable()

int alert_writable ( alert_t  alert)

Return whether a alert is writable.

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

Definition at line 8536 of file manage_sql.c.

8537 {
8538  return 1;
8539 }

◆ array_add_new_string()

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

Ensure a string is in an array.

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

Definition at line 710 of file manage_sql.c.

711 {
712  guint index;
713  for (index = 0; index < array->len; index++)
714  if (strcmp (g_ptr_array_index (array, index), string) == 0)
715  return;
716  array_add (array, g_strdup (string));
717 }

◆ authenticate()

int authenticate ( credentials_t *  credentials)

Authenticate credentials.

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

Definition at line 17631 of file manage_sql.c.

References authenticate_allow_all, and get_scheduled_user_uuid().

17632 {
17633  if (credentials->username && credentials->password)
17634  {
17635  int fail;
17636  auth_method_t auth_method;
17637 
17639  {
17640  /* This flag is set when Manager makes a connection to itself, for
17641  * scheduled tasks and alerts. Take the stored uuid
17642  * to be able to tell apart locally authenticated vs remotely
17643  * authenticated users (in order to fetch the correct rules). */
17644  credentials->uuid = get_scheduled_user_uuid ();
17645  if (*credentials->uuid)
17646  {
17647  if (credentials_setup (credentials))
17648  return 99;
17649 
17650  manage_session_init (credentials->uuid);
17651  return 0;
17652  }
17653  return -1;
17654  }
17655 
17656  fail = authenticate_any_method (credentials->username,
17657  credentials->password,
17658  &auth_method);
17659  if (fail == 0)
17660  {
17661  gchar *quoted_name, *quoted_method;
17662 
17663  /* Authentication succeeded. */
17664 
17665  user_ensure_in_db (credentials->username,
17666  auth_method_name (auth_method));
17667 
17668  quoted_name = sql_quote (credentials->username);
17669  quoted_method = sql_quote (auth_method_name (auth_method));
17670  credentials->uuid = sql_string ("SELECT uuid FROM users"
17671  " WHERE name = '%s'"
17672  " AND method = '%s';",
17673  quoted_name,
17674  quoted_method);
17675  g_free (quoted_name);
17676  g_free (quoted_method);
17677 
17678  if (credentials_setup (credentials))
17679  {
17680  free (credentials->uuid);
17681  credentials->uuid = NULL;
17682  credentials->role = NULL;
17683  return 99;
17684  }
17685 
17686  manage_session_init (credentials->uuid);
17687 
17688  return 0;
17689  }
17690  return fail;
17691  }
17692  return 1;
17693 }
int authenticate_allow_all
Flag to force authentication to succeed.
Definition: manage_sql.c:120
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
void manage_session_init(const char *uuid)
Setup session.
Definition: manage_pg.c:46
int authenticate_any_method(const gchar *username, const gchar *password, auth_method_t *auth_method)
Authenticate, trying any method.
Definition: manage_sql.c:17566
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
int user_ensure_in_db(const gchar *, const gchar *)
Ensure the user exists in the database.
Definition: manage_sql.c:17309
gchar * get_scheduled_user_uuid()
Access UUID of user that scheduled the current task.
Definition: manage.c:6451
Here is the call graph for this function:

◆ authenticate_any_method()

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

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.

Definition at line 17566 of file manage_sql.c.

17568 {
17569  int ret;
17570  gchar *hash;
17571 
17572  if (openvas_auth_ldap_enabled ()
17573  && ldap_auth_enabled ()
17574  && user_exists_method (username, AUTHENTICATION_METHOD_LDAP_CONNECT))
17575  {
17576  ldap_auth_info_t info;
17577  int allow_plaintext;
17578  gchar *authdn, *host, *cacert;
17579 
17580  *auth_method = AUTHENTICATION_METHOD_LDAP_CONNECT;
17581  /* Search the LDAP authentication cache first. */
17582  if (auth_cache_find (username, password, 0) == 0)
17583  return 0;
17584 
17585  manage_get_ldap_info (NULL, &host, &authdn, &allow_plaintext, &cacert);
17586  info = ldap_auth_info_new (host, authdn, allow_plaintext);
17587  g_free (host);
17588  g_free (authdn);
17589  ret = ldap_connect_authenticate (username, password, info, cacert);
17590  ldap_auth_info_free (info);
17591  free (cacert);
17592 
17593  if (ret == 0)
17594  auth_cache_insert (username, password, 0);
17595  return ret;
17596  }
17597  if (openvas_auth_radius_enabled ()
17598  && radius_auth_enabled ()
17599  && user_exists_method (username, AUTHENTICATION_METHOD_RADIUS_CONNECT))
17600  {
17601  char *key = NULL, *host = NULL;
17602 
17603  *auth_method = AUTHENTICATION_METHOD_RADIUS_CONNECT;
17604  if (auth_cache_find (username, password, 1) == 0)
17605  return 0;
17606 
17607  manage_get_radius_info (NULL, &host, &key);
17608  ret = radius_authenticate (host, key, username, password);
17609  g_free (host);
17610  g_free (key);
17611  if (ret == 0)
17612  auth_cache_insert (username, password, 1);
17613  return ret;
17614  }
17615  *auth_method = AUTHENTICATION_METHOD_FILE;
17616  hash = manage_user_hash (username);
17617  ret = openvas_authenticate_classic (username, password, hash);
17618  g_free (hash);
17619  return ret;
17620 }
void manage_get_ldap_info(int *, gchar **, gchar **, int *, gchar **)
gchar * manage_user_hash(const gchar *username)
Get user hash.
Definition: manage_sql.c:17189
void manage_get_radius_info(int *, char **, char **)

◆ check_config_discovery()

int check_config_discovery ( const char *  uuid)

Ensure the Discovery config is up to date.

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

Definition at line 971 of file manage_config_discovery.c.

References sql().

972 {
973  /* Check new preference. */
974 
975  sql ("UPDATE config_preferences SET value = 'no'"
976  " WHERE config = (SELECT id FROM configs WHERE uuid = '%s')"
977  " AND type = 'PLUGINS_PREFS'"
978  " AND name = 'Ping Host[checkbox]:Report about unrechable Hosts'"
979  " AND value = 'yes';",
980  uuid);
981 
982  return 0;
983 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ check_config_host_discovery()

void check_config_host_discovery ( const char *  uuid)

Ensure the Host Discovery config is up to date.

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

Definition at line 118 of file manage_config_host_discovery.c.

References NAME, NVT_SELECTOR_TYPE_NVT, sql(), sql_int(), and update_config_cache_init().

119 {
120  int update;
121 
122  update = 0;
123 
124  /* Check new preference. */
125 
126  if (sql_int ("SELECT count (*) FROM config_preferences"
127  " WHERE config = (SELECT id FROM configs WHERE uuid = '%s')"
128  " AND type = 'PLUGINS_PREFS'"
129  " AND name = '" NAME "';",
130  uuid)
131  == 0)
132  {
133  sql ("INSERT INTO config_preferences (config, type, name, value)"
134  " VALUES ((SELECT id FROM configs WHERE uuid = '%s'),"
135  " 'PLUGINS_PREFS',"
136  " '" NAME "',"
137  " 'yes');",
138  uuid);
139  update = 1;
140  }
141 
142  /* Check new NVT. */
143 
144  if (sql_int ("SELECT count (*) FROM nvt_selectors"
145  " WHERE name = (SELECT nvt_selector FROM configs"
146  " WHERE uuid = '%s')"
147  " AND family_or_nvt = '1.3.6.1.4.1.25623.1.0.12288';",
148  uuid)
149  == 0)
150  {
151  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
152  " VALUES ((SELECT nvt_selector FROM configs WHERE uuid = '%s'), 0,"
153  " " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
154  " '1.3.6.1.4.1.25623.1.0.12288', 'Settings');",
155  uuid);
156  update = 1;
157  }
158 
159  if (update)
161 
162  return 0;
163 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
Definition: manage.h:2001
#define NAME
Preference name.
void update_config_cache_init(const char *)
Here is the call graph for this function:

◆ check_config_system_discovery()

int check_config_system_discovery ( const char *  uuid)

Ensure the Discovery config is up to date.

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

Definition at line 202 of file manage_config_system_discovery.c.

References NVT_SELECTOR_TYPE_NVT, sql(), sql_int(), and update_config_cache_init().

203 {
204  int update;
205 
206  update = 0;
207 
208  /* Check new NVT. */
209 
210  if (sql_int ("SELECT count (*) FROM nvt_selectors"
211  " WHERE name = (SELECT nvt_selector FROM configs"
212  " WHERE uuid = '%s')"
213  " AND family_or_nvt = '1.3.6.1.4.1.25623.1.0.51662';",
214  uuid)
215  == 0)
216  {
217  sql ("INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)"
218  " VALUES ((SELECT nvt_selector FROM configs WHERE uuid = '%s'), 0,"
219  " " G_STRINGIFY (NVT_SELECTOR_TYPE_NVT) ","
220  " '1.3.6.1.4.1.25623.1.0.51662', 'General');",
221  uuid);
222  update = 1;
223  }
224 
225  if (update)
227 
228  return 0;
229 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
Definition: manage.h:2001
void update_config_cache_init(const char *)
Here is the call graph for this function:

◆ check_db_sequences()

void check_db_sequences ( )

Ensure sequences for automatic ids are in a consistent state.

Caller must organise a transaction.

Definition at line 2584 of file manage_pg.c.

References cleanup_iterator(), init_iterator(), iterator_string(), next(), sql(), and sql_int64().

2585 {
2586  iterator_t sequence_tables;
2587  init_iterator(&sequence_tables,
2588  "SELECT table_name, column_name,"
2589  " pg_get_serial_sequence (table_name, column_name)"
2590  " FROM information_schema.columns"
2591  " WHERE table_schema = 'public'"
2592  " AND pg_get_serial_sequence (table_name, column_name)"
2593  " IS NOT NULL;");
2594 
2595  while (next (&sequence_tables))
2596  {
2597  const char* table = iterator_string (&sequence_tables, 0);
2598  const char* column = iterator_string (&sequence_tables, 1);
2599  const char* sequence = iterator_string (&sequence_tables, 2);
2600  resource_t old_start, new_start;
2601 
2602  sql_int64 (&old_start,
2603  "SELECT last_value + 1 FROM %s;",
2604  sequence);
2605 
2606  sql_int64 (&new_start,
2607  "SELECT coalesce (max (%s), 0) + 1 FROM %s;",
2608  column, table);
2609 
2610  if (old_start < new_start)
2611  sql ("ALTER SEQUENCE %s RESTART WITH %llu;", sequence, new_start);
2612  }
2613 
2614  cleanup_iterator (&sequence_tables);
2615 }
A generic SQL iterator.
Definition: iterator.h:52
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
gboolean next(iterator_t *)
Increment an iterator.
Definition: sql.c:689
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
long long int resource_t
A resource, like a task or target.
Definition: iterator.h:42
Here is the call graph for this function:

◆ check_db_versions()

int check_db_versions ( int  nvt_cache_mode)

Ensure that the databases are the right versions.

Parameters
[in]nvt_cache_modeTrue when running in NVT caching mode.
Returns
0 success, -1 error, -2 database is wrong version, -3 database needs to be initialised from server.

Definition at line 15595 of file manage_sql.c.

References sql_schema(), and sql_string().

15596 {
15597  char *database_version;
15598  int scap_db_version, cert_db_version;
15599 
15600  database_version = sql_string ("SELECT value FROM %s.meta"
15601  " WHERE name = 'database_version';",
15602  sql_schema ());
15603  if (nvt_cache_mode)
15604  {
15605  if (database_version
15606  && strcmp (database_version,
15607  G_STRINGIFY (OPENVASMD_DATABASE_VERSION)))
15608  {
15609  g_message ("%s: database version of database: %s\n",
15610  __FUNCTION__,
15611  database_version);
15612  g_message ("%s: database version supported by manager: %s\n",
15613  __FUNCTION__,
15614  G_STRINGIFY (OPENVASMD_DATABASE_VERSION));
15615  g_free (database_version);
15616  return -2;
15617  }
15618  g_free (database_version);
15619 
15620  /* If database_version was NULL then meta was missing, so assume
15621  * that the database is missing, which is OK. */
15622  }
15623  else
15624  {
15625  long long int count;
15626 
15627  if (database_version)
15628  {
15629  if (strcmp (database_version,
15630  G_STRINGIFY (OPENVASMD_DATABASE_VERSION)))
15631  {
15632  g_message ("%s: database version of database: %s\n",
15633  __FUNCTION__,
15634  database_version);
15635  g_message ("%s: database version supported by manager: %s\n",
15636  __FUNCTION__,
15637  G_STRINGIFY (OPENVASMD_DATABASE_VERSION));
15638  g_free (database_version);
15639  return -2;
15640  }
15641  g_free (database_version);
15642 
15643  /* Check that the database was initialised from the scanner.
15644  *
15645  * This can also fail after a migration, for example if the database
15646  * was created before NVT preferences were cached in the database.
15647  */
15648 
15649  if (sql_int64 (&count,
15650  "SELECT count(*) FROM %s.meta"
15651  " WHERE name = 'nvts_feed_version'"
15652  " OR name = 'nvt_preferences_enabled';",
15653  sql_schema ())
15654  || count < 2)
15655  g_warning ("database must be initialised from scanner"
15656  " (with --update or --rebuild)");
15657  }
15658  else
15659  /* Assume database is missing. */
15660  g_warning ("database must be initialised from scanner"
15661  " (with --update or --rebuild)");
15662  }
15663 
15664  /* Check SCAP database version. */
15665 
15666  scap_db_version = manage_scap_db_version ();
15667  if (scap_db_version == -1)
15668  g_message ("No SCAP database found");
15669  else if (scap_db_version != manage_scap_db_supported_version ())
15670  {
15671  g_message ("%s: database version of SCAP database: %i\n",
15672  __FUNCTION__,
15673  scap_db_version);
15674  g_message ("%s: SCAP database version supported by manager: %s\n",
15675  __FUNCTION__,
15676  G_STRINGIFY (OPENVASMD_SCAP_DATABASE_VERSION));
15677  return -2;
15678  }
15679 
15680  /* Check CERT database version. */
15681 
15682  cert_db_version = manage_cert_db_version ();
15683  if (cert_db_version == -1)
15684  g_message ("No CERT database found");
15685  else if (cert_db_version != manage_cert_db_supported_version ())
15686  {
15687  g_message ("%s: database version of CERT database: %i\n",
15688  __FUNCTION__,
15689  cert_db_version);
15690  g_message ("%s: CERT database version supported by manager: %s\n",
15691  __FUNCTION__,
15692  G_STRINGIFY (OPENVASMD_CERT_DATABASE_VERSION));
15693  return -2;
15694  }
15695  return 0;
15696 }
const char * sql_schema()
Get main schema name.
Definition: sql_pg.c:103
int manage_scap_db_version()
Return the database version of the actual database.
Definition: manage_sql.c:6299
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
int manage_scap_db_supported_version()
Return the database version supported by this manager.
Definition: manage_sql.c:6288
int manage_cert_db_version()
Return the database version of the actual database.
Definition: manage_sql.c:6333
int manage_cert_db_supported_version()
Return the database version supported by this manager.
Definition: manage_sql.c:6322
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ check_generate_scripts()

void check_generate_scripts ( )

Ensure the generate scripts are all executable.

Used by a migrator.

Definition at line 16716 of file manage_sql.c.

References cleanup_iterator(), init_iterator(), iterator_int64(), iterator_string(), next(), report_format_uuid(), and user_uuid().

Referenced by migrate_147_to_148().

16717 {
16718  iterator_t rows;
16719 
16720  init_iterator (&rows, "SELECT owner,"
16721  " uuid,"
16722  " (SELECT uuid FROM users"
16723  " WHERE users.id = report_formats.owner)"
16724  " FROM report_formats;");
16725  while (next (&rows))
16726  {
16727  resource_t owner;
16728 
16729  owner = iterator_int64 (&rows, 0);
16730  if (owner)
16731  {
16732  const gchar *report_format_uuid, *user_uuid;
16733  gchar *path;
16734 
16735  report_format_uuid = iterator_string (&rows, 1);
16736  if (report_format_uuid == NULL)
16737  continue;
16738 
16739  user_uuid = iterator_string (&rows, 2);
16740  if (user_uuid == NULL)
16741  continue;
16742 
16743  path = g_build_filename (OPENVAS_STATE_DIR,
16744  "openvasmd",
16745  "report_formats",
16746  user_uuid,
16748  "generate",
16749  NULL);
16750 
16751  if (chmod (path, 0755 /* rwxr-xr-x */))
16752  g_warning ("%s: chmod %s failed: %s\n",
16753  __FUNCTION__,
16754  path,
16755  strerror (errno));
16756 
16757  g_free (path);
16758  }
16759  }
16760  cleanup_iterator (&rows);
16761 }
char * user_uuid(user_t)
A generic SQL iterator.
Definition: iterator.h:52
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
char * report_format_uuid(report_format_t)
gboolean next(iterator_t *)
Increment an iterator.
Definition: sql.c:689
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
Definition: sql.c:637
long long int resource_t
A resource, like a task or target.
Definition: iterator.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean_hosts()

gchar* clean_hosts ( const char *  ,
int *   
)

◆ cleanup_manage_process()

void cleanup_manage_process ( gboolean  cleanup)

Cleanup the manage library.

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

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

Definition at line 17128 of file manage_sql.c.

Referenced by manage_option_cleanup(), and reinit_manage_process().

17129 {
17130  if (sql_is_open ())
17131  {
17132  if (cleanup)
17133  {
17137  sql_close ();
17138  }
17139  else
17140  sql_close_fork ();
17141  }
17142 }
void sql_close_fork()
Close the database in a forked process.
Definition: sql_pg.c:373
int sql_is_open()
Check whether the database is open.
Definition: sql_pg.c:201
task_t current_scanner_task
The task currently running on the scanner.
Definition: manage.c:998
void cleanup_prognosis_iterator()
void sql_close()
Close the database.
Definition: sql_pg.c:363
void set_task_run_status(task_t task, task_status_t status)
Set the run state of a task.
Definition: manage_sql.c:18307
Here is the caller graph for this function:

◆ cleanup_prognosis_iterator()

void cleanup_prognosis_iterator ( )

◆ cleanup_tables()

void cleanup_tables ( )

Clean up database tables.

Remove superfluous entries from tables.

Definition at line 16835 of file manage_sql.c.

References LOCATION_TABLE, LOCATION_TRASH, and sql().

16836 {
16837  /* Remove group and role assignments of deleted users.
16838  *
16839  * This should be a migrator, but this way is easier to backport. */
16840 
16841  sql ("DELETE FROM group_users"
16842  " WHERE \"user\" NOT IN (SELECT id FROM users);");
16843  sql ("DELETE FROM group_users_trash"
16844  " WHERE \"user\" NOT IN (SELECT id FROM users);");
16845  sql ("DELETE FROM role_users"
16846  " WHERE \"user\" NOT IN (SELECT id FROM users);");
16847  sql ("DELETE FROM role_users_trash"
16848  " WHERE \"user\" NOT IN (SELECT id FROM users);");
16849 
16850  /*
16851  * Remove permissions of deleted users, groups and roles.
16852  */
16853  sql ("DELETE FROM permissions"
16854  " WHERE (subject_type = 'user'"
16855  " AND subject NOT IN (SELECT id FROM users))"
16856  " OR (subject_type = 'group'"
16857  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE)
16858  " AND subject NOT IN (SELECT id FROM groups))"
16859  " OR (subject_type = 'group'"
16860  " AND subject_location = " G_STRINGIFY (LOCATION_TRASH)
16861  " AND subject NOT IN (SELECT id FROM groups_trash))"
16862  " OR (subject_type = 'role'"
16863  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE)
16864  " AND subject NOT IN (SELECT id FROM roles))"
16865  " OR (subject_type = 'role'"
16866  " AND subject_location = " G_STRINGIFY (LOCATION_TRASH)
16867  " AND subject NOT IN (SELECT id FROM roles_trash));");
16868 
16869  sql ("DELETE FROM permissions_trash"
16870  " WHERE (subject_type = 'user'"
16871  " AND subject NOT IN (SELECT id FROM users))"
16872  " OR (subject_type = 'group'"
16873  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE)
16874  " AND subject NOT IN (SELECT id FROM groups))"
16875  " OR (subject_type = 'group'"
16876  " AND subject_location = " G_STRINGIFY (LOCATION_TRASH)
16877  " AND subject NOT IN (SELECT id FROM groups_trash))"
16878  " OR (subject_type = 'role'"
16879  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE)
16880  " AND subject NOT IN (SELECT id FROM roles))"
16881  " OR (subject_type = 'role'"
16882  " AND subject_location = " G_STRINGIFY (LOCATION_TRASH)
16883  " AND subject NOT IN (SELECT id FROM roles_trash));");
16884 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

◆ collate_ip()

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

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.

Definition at line 6728 of file manage_sql.c.

6731 {
6732  int ret, one_dot, two_dot;
6733  char one_a[4], one_b[4], one_c[4], one_d[4];
6734  char two_a[4], two_b[4], two_c[4], two_d[4];
6735  const char* one = (const char*) arg_one;
6736  const char* two = (const char*) arg_two;
6737 
6738  if ((sscanf (one, "%3[0-9].%3[0-9].%3[0-9].%n%3[0-9]",
6739  one_a, one_b, one_c, &one_dot, one_d)
6740  == 4)
6741  && (sscanf (two, "%3[0-9].%3[0-9].%3[0-9].%n%3[0-9]",
6742  two_a, two_b, two_c, &two_dot, two_d)
6743  == 4))
6744  {
6745  int ret = collate_ip_compare (one_a, two_a);
6746  if (ret) return ret < 0 ? -1 : 1;
6747 
6748  ret = collate_ip_compare (one_b, two_b);
6749  if (ret) return ret < 0 ? -1 : 1;
6750 
6751  ret = collate_ip_compare (one_c, two_c);
6752  if (ret) return ret < 0 ? -1 : 1;
6753 
6754  /* Ensure that the last number is limited to digits in the arg. */
6755  one_d[one_len - one_dot] = '\0';
6756  two_d[two_len - two_dot] = '\0';
6757 
6758  ret = collate_ip_compare (one_d, two_d);
6759  if (ret) return ret < 0 ? -1 : 1;
6760 
6761  return 0;
6762  }
6763 
6764  ret = strncmp (one, two, MIN (one_len, two_len));
6765  return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
6766 }

◆ collate_message_type()

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

Collate two message type strings.

A lower threat is considered less than a higher threat, so Medium is less than High.

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

Definition at line 6638 of file manage_sql.c.

6641 {
6642  const char* one = (const char*) arg_one;
6643  const char* two = (const char*) arg_two;
6644 
6645  if (strncmp (one, "Security Hole", one_len) == 0)
6646  {
6647  if (strncmp (two, "Security Hole", two_len) == 0)
6648  return 0;
6649  return 1;
6650  }
6651  if (strncmp (two, "Security Hole", two_len) == 0) return -1;
6652 
6653  if (strncmp (one, "Security Warning", one_len) == 0)
6654  {
6655  if (strncmp (two, "Security Warning", two_len) == 0)
6656  return 0;
6657  return 1;
6658  }
6659  if (strncmp (two, "Security Warning", two_len) == 0) return -1;
6660 
6661  if (strncmp (one, "Security Note", one_len) == 0)
6662  {
6663  if (strncmp (two, "Security Note", two_len) == 0)
6664  return 0;
6665  return 1;
6666  }
6667  if (strncmp (two, "Security Note", two_len) == 0) return -1;
6668 
6669  if (strncmp (one, "Log Message", one_len) == 0)
6670  {
6671  if (strncmp (two, "Log Message", two_len) == 0)
6672  return 0;
6673  return 1;
6674  }
6675  if (strncmp (two, "Log Message", two_len) == 0) return -1;
6676 
6677  if (strncmp (one, "Debug Message", one_len) == 0)
6678  {
6679  if (strncmp (two, "Debug Message", two_len) == 0)
6680  return 0;
6681  return 1;
6682  }
6683  if (strncmp (two, "Debug Message", two_len) == 0) return -1;
6684 
6685  if (strncmp (one, "Error Message", one_len) == 0)
6686  {
6687  if (strncmp (two, "Error Message", two_len) == 0)
6688  return 0;
6689  return 1;
6690  }
6691  if (strncmp (two, "Error Message", two_len) == 0) return -1;
6692 
6693  return strncmp (one, two, MIN (one_len, two_len));
6694 }

◆ column_array_copy()

column_t* column_array_copy ( column_t columns)

Copy an array of columns.

Parameters
[in]columnsColumns.

Definition at line 1547 of file manage_sql.c.

1548 {
1549  column_t *point, *start;
1550  int count;
1551 
1552  count = 1;
1553  point = columns;
1554  while (point->select)
1555  {
1556  point++;
1557  count++;
1558  }
1559 
1560  g_debug ("%s: %i", __FUNCTION__, count);
1561  start = g_malloc0 (sizeof (column_t) * count);
1562  point = start;
1563 
1564  while (columns->select)
1565  {
1566  point->select = g_strdup (columns->select);
1567  point->filter = columns->filter ? g_strdup (columns->filter) : NULL;
1568  point->type = columns->type;
1569  point++;
1570  columns++;
1571  }
1572  return start;
1573 }
gchar * select
Column for SELECT.
Definition: manage_sql.c:1514
keyword_type_t type
Type of column.
Definition: manage_sql.c:1516
Iterator column.
Definition: manage_sql.c:1512
gchar * filter
Filter column name. NULL to use select_column.
Definition: manage_sql.c:1515

◆ column_array_free()

void column_array_free ( column_t columns)

Free an array of columns.

Parameters
[in]columnsColumns.

Definition at line 1581 of file manage_sql.c.

References column_t::filter, and column_t::select.

1582 {
1583  while (columns->filter)
1584  {
1585  g_free (columns->select);
1586  g_free (columns->filter);
1587  columns++;
1588  }
1589  g_free (columns);
1590 }
gchar * select
Column for SELECT.
Definition: manage_sql.c:1514
gchar * filter
Filter column name. NULL to use select_column.
Definition: manage_sql.c:1515

◆ column_array_print()

void column_array_print ( column_t columns)

Print an array of columns.

Parameters
[in]columnsColumns.

Definition at line 1525 of file manage_sql.c.

References column_t::filter, column_t::select, and column_t::type.

1526 {
1527  g_debug ("%s: %p", __FUNCTION__, columns);
1528  g_debug ("%s: {", __FUNCTION__);
1529  while (columns->select)
1530  {
1531  g_debug ("%s: { \"%s\", \"%s\", %i }",
1532  __FUNCTION__,
1533  columns->select,
1534  columns->filter ? columns->filter : "NULL",
1535  columns->type);
1536  columns++;
1537  }
1538  g_debug ("%s: }", __FUNCTION__);
1539 }
gchar * select
Column for SELECT.
Definition: manage_sql.c:1514
keyword_type_t type
Type of column.
Definition: manage_sql.c:1516
gchar * filter
Filter column name. NULL to use select_column.
Definition: manage_sql.c:1515

◆ column_array_set()

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

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.

Definition at line 1602 of file manage_sql.c.

References column_t::filter, and column_t::select.

1603 {
1604  while (columns->select)
1605  {
1606  if (columns->filter && (strcmp (columns->filter, filter) == 0))
1607  {
1608  g_free (columns->select);
1609  columns->select = select;
1610  break;
1611  }
1612  columns++;
1613  }
1614 }
gchar * select
Column for SELECT.
Definition: manage_sql.c:1514
gchar * filter
Filter column name. NULL to use select_column.
Definition: manage_sql.c:1515

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

Definition at line 7814 of file manage_sql.c.

References current_credentials, and sql_begin_immediate().

7816 {
7817  int ret;
7818  alert_t new, old;
7819 
7820  assert (current_credentials.uuid);
7821 
7822  if (alert_id == NULL)
7823  return -1;
7824 
7826 
7827  ret = copy_resource_lock ("alert", name, comment, alert_id,
7828  "event, condition, method, filter",
7829  1, &new, &old);
7830  if (ret)
7831  {
7832  sql_rollback ();
7833  return ret;
7834  }
7835 
7836  /* Copy the alert condition data */
7837  sql ("INSERT INTO alert_condition_data (alert, name, data)"
7838  " SELECT %llu, name, data FROM alert_condition_data"
7839  " WHERE alert = %llu;",
7840  new,
7841  old);
7842 
7843  /* Copy the alert event data */
7844  sql ("INSERT INTO alert_event_data (alert, name, data)"
7845  " SELECT %llu, name, data FROM alert_event_data"
7846  " WHERE alert = %llu;",
7847  new,
7848  old);
7849 
7850  /* Copy the alert method data */
7851  sql ("INSERT INTO alert_method_data (alert, name, data)"
7852  " SELECT %llu, name, data FROM alert_method_data"
7853  " WHERE alert = %llu;",
7854  new,
7855  old);
7856 
7857  sql_commit ();
7858  if (new_alert) *new_alert = new;
7859  return 0;
7860 }
long long int alert_t
Definition: manage.h:280
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
Here is the call graph for this function:

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

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.
Returns
0 success, 1 resource exists already, 2 failed to find existing resource, 99 permission denied, -1 error.

Definition at line 4795 of file manage_sql.c.

References current_credentials, and sql_begin_immediate().

4798 {
4799  int ret;
4800 
4801  assert (current_credentials.uuid);
4802 
4804 
4805  ret = copy_resource_lock (type, name, comment, resource_id, columns,
4806  make_name_unique, new_resource, NULL);
4807 
4808  if (ret)
4809  sql_rollback ();
4810  else
4811  sql_commit ();
4812 
4813  return ret;
4814 }
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
Here is the call graph for this function:

◆ create_alert()

int create_alert ( const char *  name,
const char *  comment,
const char *  filter_id,
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]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, 50 invalid TippingPoint credential, 51 invalid TippingPoint hostname, 52 invalid TippingPoint certificate, 53 invalid TippingPoint TLS workaround setting. 99 permission denied, -1 error.

Definition at line 7545 of file manage_sql.c.

7550 {
7551  int index, ret;
7552  gchar *item, *quoted_comment;
7553  gchar *quoted_name;
7554  filter_t filter;
7555 
7556  assert (current_credentials.uuid);
7557 
7559 
7560  if (acl_user_may ("create_alert") == 0)
7561  {
7562  sql_rollback ();
7563  return 99;
7564  }
7565 
7566  ret = check_alert_params (event, condition, method);
7567  if (ret)
7568  {
7569  sql_rollback ();
7570  return ret;
7571  }
7572 
7573  filter = 0;
7574  if (event != EVENT_NEW_SECINFO && event != EVENT_UPDATED_SECINFO && filter_id
7575  && strcmp (filter_id, "0"))
7576  {
7577  char *type;
7578 
7579  if (find_filter_with_permission (filter_id, &filter, "get_filters"))
7580  {
7581  sql_rollback ();
7582  return -1;
7583  }
7584 
7585  if (filter == 0)
7586  {
7587  sql_rollback ();
7588  return 3;
7589  }
7590 
7591  /* Filter type must be result if specified. */
7592 
7593  type = sql_string ("SELECT type FROM filters WHERE id = %llu;",
7594  filter);
7595  if (type && strcasecmp (type, "result"))
7596  {
7597  free (type);
7598  sql_rollback ();
7599  return 4;
7600  }
7601  free (type);
7602  }
7603 
7604  if (resource_with_name_exists (name, "alert", 0))
7605  {
7606  sql_rollback ();
7607  return 1;
7608  }
7609  quoted_name = sql_quote (name);
7610  quoted_comment = sql_quote (comment ?: "");
7611 
7612  sql ("INSERT INTO alerts (uuid, owner, name, comment, event, condition,"
7613  " method, filter, creation_time, modification_time)"
7614  " VALUES (make_uuid (),"
7615  " (SELECT id FROM users WHERE users.uuid = '%s'),"
7616  " '%s', '%s', %i, %i, %i, %llu, m_now (), m_now ());",
7617  current_credentials.uuid,
7618  quoted_name,
7619  quoted_comment,
7620  event,
7621  condition,
7622  method,
7623  filter);
7624 
7625  g_free (quoted_comment);
7626  g_free (quoted_name);
7627 
7628  *alert = sql_last_insert_id ();
7629 
7630  index = 0;
7631  while ((item = (gchar*) g_ptr_array_index (condition_data, index++)))
7632  {
7633  int validation_result;
7634  gchar *name = sql_quote (item);
7635  gchar *data = sql_quote (item + strlen (item) + 1);
7636 
7637  validation_result = validate_alert_condition_data (name, data, condition);
7638 
7639  if (validation_result)
7640  {
7641  g_free (name);
7642  g_free (data);
7643  sql_rollback ();
7644 
7645  switch (validation_result)
7646  {
7647  case 1:
7648  return 5;
7649  case 2:
7650  return 6;
7651  case 3:
7652  return 9;
7653  default:
7654  return -1;
7655  }
7656  }
7657 
7658  sql ("INSERT INTO alert_condition_data (alert, name, data)"
7659  " VALUES (%llu, '%s', '%s');",
7660  *alert,
7661  name,
7662  data);
7663  g_free (name);
7664  g_free (data);
7665  }
7666 
7667  index = 0;
7668  while ((item = (gchar*) g_ptr_array_index (event_data, index++)))
7669  {
7670  int validation_result;
7671  gchar *name = sql_quote (item);
7672  gchar *data = sql_quote (item + strlen (item) + 1);
7673 
7674  validation_result = validate_alert_event_data (name, data, event);
7675 
7676  if (validation_result)
7677  {
7678  g_free (name);
7679  g_free (data);
7680  sql_rollback ();
7681 
7682  switch (validation_result)
7683  {
7684  case 1:
7685  return 31;
7686  case 2:
7687  return 32;
7688  default:
7689  return -1;
7690  }
7691  }
7692 
7693  sql ("INSERT INTO alert_event_data (alert, name, data)"
7694  " VALUES (%llu, '%s', '%s');",
7695  *alert,
7696  name,
7697  data);
7698  g_free (name);
7699  g_free (data);
7700  }
7701 
7702  index = 0;
7703  while ((item = (gchar*) g_ptr_array_index (method_data, index++)))
7704  {
7705  int ret;
7706  gchar *name, *data;
7707 
7708  name = sql_quote (item);
7709  data = sql_quote (item + strlen (item) + 1);
7710 
7711  if (method == ALERT_METHOD_EMAIL
7712  && strcmp (name, "to_address") == 0
7713  && validate_email_list (data))
7714  {
7715  g_free (name);
7716  g_free (data);
7717  sql_rollback ();
7718  return 2;
7719  }
7720 
7721  if (method == ALERT_METHOD_EMAIL
7722  && strcmp (name, "from_address") == 0
7723  && validate_email (data))
7724  {
7725  g_free (name);
7726  g_free (data);
7727  sql_rollback ();
7728  return 2;
7729  }
7730 
7731  if (method == ALERT_METHOD_EMAIL
7732  && strcmp (name, "subject") == 0
7733  && strlen (data) > 80)
7734  {
7735  g_free (name);
7736  g_free (data);
7737  sql_rollback ();
7738  return 7;
7739  }
7740 
7741  if (method == ALERT_METHOD_EMAIL
7742  && strcmp (name, "message") == 0
7743  && strlen (data) > max_email_message_length)
7744  {
7745  g_free (name);
7746  g_free (data);
7747  sql_rollback ();
7748  return 8;
7749  }
7750 
7751  ret = validate_scp_data (method, name, &data);
7752  if (ret)
7753  {
7754  g_free (name);
7755  g_free (data);
7756  sql_rollback ();
7757  return ret;
7758  }
7759 
7760  ret = validate_send_data (method, name, &data);
7761  if (ret)
7762  {
7763  g_free (name);
7764  g_free (data);
7765  sql_rollback ();
7766  return ret;
7767  }
7768 
7769  ret = validate_smb_data (method, name, &data);
7770  if (ret)
7771  {
7772  g_free (name);
7773  g_free (data);
7774  sql_rollback ();
7775  return ret;
7776  }
7777 
7778  ret = validate_tippingpoint_data (method, name, &data);
7779  if (ret)
7780  {
7781  g_free (name);
7782  g_free (data);
7783  sql_rollback ();
7784  return ret;
7785  }
7786 
7787  sql ("INSERT INTO alert_method_data (alert, name, data)"
7788  " VALUES (%llu, '%s', '%s');",
7789  *alert,
7790  name,
7791  data);
7792  g_free (name);
7793  g_free (data);
7794  }
7795 
7796  sql_commit ();
7797 
7798  return 0;
7799 }
long long int filter_t
Definition: manage.h:281
int validate_send_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the Send method.
Definition: manage_sql.c:7304
int validate_scp_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the SCP method.
Definition: manage_sql.c:7222
resource_t sql_last_insert_id()
Get the ID of the last inserted row.
Definition: sql_pg.c:395
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
int validate_smb_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the Send method.
Definition: manage_sql.c:7368
gboolean find_filter_with_permission(const char *, filter_t *, const char *)
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
Definition: manage_acl.c:56
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
int validate_tippingpoint_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the TippingPoint method.
Definition: manage_sql.c:7435
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649

◆ create_port_list_unique()

int create_port_list_unique ( const char *  ,
const char *  ,
const char *  ,
port_list_t  
)

◆ create_tables()

void create_tables ( )

Create all tables.

Definition at line 1506 of file manage_pg.c.

References acl_where_owned_for_get(), LSC_FAMILY_LIST, manage_create_sql_functions(), SEVERITY_ERROR, SEVERITY_LOG, and sql().

1507 {
1508  gchar *owned_clause;
1509 
1510  sql ("DROP TABLE IF EXISTS current_credentials");
1511  sql ("CREATE TABLE IF NOT EXISTS current_credentials"
1512  " (id SERIAL PRIMARY KEY,"
1513  " uuid text UNIQUE NOT NULL,"
1514  " tz_override text);");
1515 
1516  sql ("CREATE TABLE IF NOT EXISTS meta"
1517  " (id SERIAL PRIMARY KEY,"
1518  " name text UNIQUE NOT NULL,"
1519  " value text);");
1520 
1521  sql ("CREATE TABLE IF NOT EXISTS users"
1522  " (id SERIAL PRIMARY KEY,"
1523  " uuid text UNIQUE NOT NULL,"
1524  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1525  " name text NOT NULL,"
1526  " comment text,"
1527  " password text,"
1528  " timezone text,"
1529  " hosts text,"
1530  " hosts_allow integer,"
1531  " ifaces text,"
1532  " ifaces_allow integer,"
1533  " method text,"
1534  " creation_time integer,"
1535  " modification_time integer);");
1536 
1537  sql ("CREATE TABLE IF NOT EXISTS auth_cache"
1538  " (id SERIAL PRIMARY KEY,"
1539  " username text NOT NULL,"
1540  " hash text,"
1541  " method integer,"
1542  " creation_time integer);");
1543 
1544  sql ("CREATE TABLE IF NOT EXISTS agents"
1545  " (id SERIAL PRIMARY KEY,"
1546  " uuid text UNIQUE NOT NULL,"
1547  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1548  " name text NOT NULL,"
1549  " comment text,"
1550  " installer bytea,"
1551  " installer_64 text,"
1552  " installer_filename text,"
1553  " installer_signature_64 text,"
1554  " installer_trust integer,"
1555  " installer_trust_time integer,"
1556  " howto_install text,"
1557  " howto_use text,"
1558  " creation_time integer,"
1559  " modification_time integer);");
1560 
1561  sql ("CREATE TABLE IF NOT EXISTS agents_trash"
1562  " (id SERIAL PRIMARY KEY,"
1563  " uuid text UNIQUE NOT NULL,"
1564  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1565  " name text NOT NULL,"
1566  " comment text,"
1567  " installer bytea,"
1568  " installer_64 text,"
1569  " installer_filename text,"
1570  " installer_signature_64 text,"
1571  " installer_trust integer,"
1572  " installer_trust_time integer,"
1573  " howto_install text,"
1574  " howto_use text,"
1575  " creation_time integer,"
1576  " modification_time integer);");
1577 
1578  sql ("CREATE TABLE IF NOT EXISTS alerts"
1579  " (id SERIAL PRIMARY KEY,"
1580  " uuid text UNIQUE NOT NULL,"
1581  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1582  " name text NOT NULL,"
1583  " comment text,"
1584  " event integer,"
1585  " condition integer,"
1586  " method integer,"
1587  " filter integer,"
1588  " creation_time integer,"
1589  " modification_time integer);");
1590 
1591  sql ("CREATE TABLE IF NOT EXISTS alerts_trash"
1592  " (id SERIAL PRIMARY KEY,"
1593  " uuid text UNIQUE NOT NULL,"
1594  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1595  " name text NOT NULL,"
1596  " comment text,"
1597  " event integer,"
1598  " condition integer,"
1599  " method integer,"
1600  " filter integer,"
1601  " filter_location integer,"
1602  " creation_time integer,"
1603  " modification_time integer);");
1604 
1605  sql ("CREATE TABLE IF NOT EXISTS alert_condition_data"
1606  " (id SERIAL PRIMARY KEY,"
1607  " alert integer REFERENCES alerts (id) ON DELETE RESTRICT,"
1608  " name text,"
1609  " data text);");
1610 
1611  sql ("CREATE TABLE IF NOT EXISTS alert_condition_data_trash"
1612  " (id SERIAL PRIMARY KEY,"
1613  " alert integer REFERENCES alerts_trash (id) ON DELETE RESTRICT,"
1614  " name text,"
1615  " data text);");
1616 
1617  sql ("CREATE TABLE IF NOT EXISTS alert_event_data"
1618  " (id SERIAL PRIMARY KEY,"
1619  " alert integer REFERENCES alerts (id) ON DELETE RESTRICT,"
1620  " name text,"
1621  " data text);");
1622 
1623  sql ("CREATE TABLE IF NOT EXISTS alert_event_data_trash"
1624  " (id SERIAL PRIMARY KEY,"
1625  " alert integer REFERENCES alerts_trash (id) ON DELETE RESTRICT,"
1626  " name text,"
1627  " data text);");
1628 
1629  sql ("CREATE TABLE IF NOT EXISTS alert_method_data"
1630  " (id SERIAL PRIMARY KEY,"
1631  " alert integer REFERENCES alerts (id) ON DELETE RESTRICT,"
1632  " name text,"
1633  " data text);");
1634 
1635  sql ("CREATE TABLE IF NOT EXISTS alert_method_data_trash"
1636  " (id SERIAL PRIMARY KEY,"
1637  " alert integer REFERENCES alerts_trash (id) ON DELETE RESTRICT,"
1638  " name text,"
1639  " data text);");
1640 
1641  sql ("CREATE TABLE IF NOT EXISTS credentials"
1642  " (id SERIAL PRIMARY KEY,"
1643  " uuid text UNIQUE NOT NULL,"
1644  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1645  " name text NOT NULL,"
1646  " comment text,"
1647  " creation_time integer,"
1648  " modification_time integer,"
1649  " type text,"
1650  " allow_insecure integer);");
1651 
1652  sql ("CREATE TABLE IF NOT EXISTS credentials_trash"
1653  " (id SERIAL PRIMARY KEY,"
1654  " uuid text UNIQUE NOT NULL,"
1655  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1656  " name text NOT NULL,"
1657  " comment text,"
1658  " creation_time integer,"
1659  " modification_time integer,"
1660  " type text,"
1661  " allow_insecure integer);");
1662 
1663  sql ("CREATE TABLE IF NOT EXISTS credentials_data"
1664  " (id SERIAL PRIMARY KEY,"
1665  " credential INTEGER REFERENCES credentials (id) ON DELETE RESTRICT,"
1666  " type TEXT,"
1667  " value TEXT);");
1668 
1669  sql ("CREATE TABLE IF NOT EXISTS credentials_trash_data"
1670  " (id SERIAL PRIMARY KEY,"
1671  " credential INTEGER REFERENCES credentials_trash (id) ON DELETE RESTRICT,"
1672  " type TEXT,"
1673  " value TEXT);");
1674 
1675  sql ("CREATE TABLE IF NOT EXISTS filters"
1676  " (id SERIAL PRIMARY KEY,"
1677  " uuid text UNIQUE NOT NULL,"
1678  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1679  " name text NOT NULL,"
1680  " comment text,"
1681  " type text,"
1682  " term text,"
1683  " creation_time integer,"
1684  " modification_time integer);");
1685 
1686  sql ("CREATE TABLE IF NOT EXISTS filters_trash"
1687  " (id SERIAL PRIMARY KEY,"
1688  " uuid text UNIQUE NOT NULL,"
1689  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1690  " name text NOT NULL,"
1691  " comment text,"
1692  " type text,"
1693  " term text,"
1694  " creation_time integer,"
1695  " modification_time integer);");
1696 
1697  sql ("CREATE TABLE IF NOT EXISTS groups"
1698  " (id SERIAL PRIMARY KEY,"
1699  " uuid text UNIQUE NOT NULL,"
1700  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1701  " name text NOT NULL,"
1702  " comment text,"
1703  " creation_time integer,"
1704  " modification_time integer);");
1705 
1706  sql ("CREATE TABLE IF NOT EXISTS groups_trash"
1707  " (id SERIAL PRIMARY KEY,"
1708  " uuid text UNIQUE NOT NULL,"
1709  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1710  " name text NOT NULL,"
1711  " comment text,"
1712  " creation_time integer,"
1713  " modification_time integer);");
1714 
1715  sql ("CREATE TABLE IF NOT EXISTS group_users"
1716  " (id SERIAL PRIMARY KEY,"
1717  " \"group\" integer REFERENCES groups (id) ON DELETE RESTRICT,"
1718  " \"user\" integer REFERENCES users (id) ON DELETE RESTRICT);");
1719 
1720  sql ("CREATE TABLE IF NOT EXISTS group_users_trash"
1721  " (id SERIAL PRIMARY KEY,"
1722  " \"group\" integer REFERENCES groups_trash (id) ON DELETE RESTRICT,"
1723  " \"user\" integer REFERENCES users (id) ON DELETE RESTRICT);");
1724 
1725  sql ("CREATE TABLE IF NOT EXISTS hosts"
1726  " (id SERIAL PRIMARY KEY,"
1727  " uuid text UNIQUE NOT NULL,"
1728  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1729  " name text NOT NULL,"
1730  " comment text,"
1731  " creation_time integer,"
1732  " modification_time integer);");
1733 
1734  sql ("CREATE TABLE IF NOT EXISTS host_identifiers"
1735  " (id SERIAL PRIMARY KEY,"
1736  " uuid text UNIQUE NOT NULL,"
1737  " host integer REFERENCES hosts (id) ON DELETE RESTRICT,"
1738  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1739  " name text NOT NULL,"
1740  " comment text,"
1741  " value text NOT NULL,"
1742  " source_type text NOT NULL,"
1743  " source_id text NOT NULL,"
1744  " source_data text NOT NULL,"
1745  " creation_time integer,"
1746  " modification_time integer);");
1747 
1748  sql ("CREATE TABLE IF NOT EXISTS oss"
1749  " (id SERIAL PRIMARY KEY,"
1750  " uuid text UNIQUE NOT NULL,"
1751  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1752  " name text NOT NULL,"
1753  " comment text,"
1754  " creation_time integer,"
1755  " modification_time integer);");
1756 
1757  sql ("CREATE TABLE IF NOT EXISTS host_oss"
1758  " (id SERIAL PRIMARY KEY,"
1759  " uuid text UNIQUE NOT NULL,"
1760  " host integer REFERENCES hosts (id) ON DELETE RESTRICT,"
1761  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1762  " name text NOT NULL,"
1763  " comment text,"
1764  " os integer REFERENCES oss (id) ON DELETE RESTRICT,"
1765  " source_type text NOT NULL,"
1766  " source_id text NOT NULL,"
1767  " source_data text NOT NULL,"
1768  " creation_time integer,"
1769  " modification_time integer);");
1770 
1771  sql ("CREATE TABLE IF NOT EXISTS host_max_severities"
1772  " (id SERIAL PRIMARY KEY,"
1773  " host integer REFERENCES hosts (id) ON DELETE RESTRICT,"
1774  " severity real,"
1775  " source_type text NOT NULL,"
1776  " source_id text NOT NULL,"
1777  " creation_time integer);");
1778 
1779  sql ("CREATE TABLE IF NOT EXISTS host_details"
1780  " (id SERIAL PRIMARY KEY,"
1781  " host integer REFERENCES hosts (id) ON DELETE RESTRICT,"
1782  /* The report that the host detail came from. */
1783  " source_type text NOT NULL,"
1784  " source_id text NOT NULL,"
1785  /* The original source of the host detail, from the scanner. */
1786  " detail_source_type text,"
1787  " detail_source_name text,"
1788  " detail_source_description text,"
1789  " name text,"
1790  " value text);");
1791 
1792  sql ("CREATE TABLE IF NOT EXISTS roles"
1793  " (id SERIAL PRIMARY KEY,"
1794  " uuid text UNIQUE NOT NULL,"
1795  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1796  " name text NOT NULL,"
1797  " comment text,"
1798  " creation_time integer,"
1799  " modification_time integer);");
1800 
1801  sql ("CREATE TABLE IF NOT EXISTS roles_trash"
1802  " (id SERIAL PRIMARY KEY,"
1803  " uuid text UNIQUE NOT NULL,"
1804  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1805  " name text NOT NULL,"
1806  " comment text,"
1807  " creation_time integer,"
1808  " modification_time integer);");
1809 
1810  sql ("CREATE TABLE IF NOT EXISTS role_users"
1811  " (id SERIAL PRIMARY KEY,"
1812  " role integer REFERENCES roles (id) ON DELETE RESTRICT,"
1813  " \"user\" integer REFERENCES users (id) ON DELETE RESTRICT);");
1814 
1815  sql ("CREATE TABLE IF NOT EXISTS role_users_trash"
1816  " (id SERIAL PRIMARY KEY,"
1817  " role integer REFERENCES roles_trash (id) ON DELETE RESTRICT,"
1818  " \"user\" integer REFERENCES users (id) ON DELETE RESTRICT);");
1819 
1820  sql ("CREATE TABLE IF NOT EXISTS nvt_selectors"
1821  " (id SERIAL PRIMARY KEY,"
1822  " name text,"
1823  " exclude integer,"
1824  " type integer,"
1825  " family_or_nvt text,"
1826  " family text);");
1827 
1828  sql ("CREATE TABLE IF NOT EXISTS port_lists"
1829  " (id SERIAL PRIMARY KEY,"
1830  " uuid text UNIQUE NOT NULL,"
1831  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1832  " name text NOT NULL,"
1833  " comment text,"
1834  " creation_time integer,"
1835  " modification_time integer);");
1836 
1837  sql ("CREATE TABLE IF NOT EXISTS port_lists_trash"
1838  " (id SERIAL PRIMARY KEY,"
1839  " uuid text UNIQUE NOT NULL,"
1840  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1841  " name text NOT NULL,"
1842  " comment text,"
1843  " creation_time integer,"
1844  " modification_time integer);");
1845 
1846  sql ("CREATE TABLE IF NOT EXISTS port_ranges"
1847  " (id SERIAL PRIMARY KEY,"
1848  " uuid text UNIQUE NOT NULL,"
1849  " port_list integer REFERENCES port_lists (id) ON DELETE RESTRICT,"
1850  " type integer,"
1851  " start integer,"
1852  " \"end\" integer,"
1853  " comment text,"
1854  " exclude integer);");
1855 
1856  sql ("CREATE TABLE IF NOT EXISTS port_ranges_trash"
1857  " (id SERIAL PRIMARY KEY,"
1858  " uuid text UNIQUE NOT NULL,"
1859  " port_list integer REFERENCES port_lists_trash (id) ON DELETE RESTRICT,"
1860  " type integer,"
1861  " start integer,"
1862  " \"end\" integer,"
1863  " comment text,"
1864  " exclude integer);");
1865 
1866  sql ("CREATE TABLE IF NOT EXISTS port_names"
1867  " (id SERIAL PRIMARY KEY,"
1868  " number integer,"
1869  " protocol text,"
1870  " name text,"
1871  " UNIQUE (number, protocol));");
1872 
1873  sql ("CREATE TABLE IF NOT EXISTS targets"
1874  " (id SERIAL PRIMARY KEY,"
1875  " uuid text UNIQUE NOT NULL,"
1876  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1877  " name text NOT NULL,"
1878  " hosts text,"
1879  " exclude_hosts text,"
1880  " reverse_lookup_only integer,"
1881  " reverse_lookup_unify integer,"
1882  " comment text,"
1883  " port_list integer REFERENCES port_lists (id) ON DELETE RESTRICT,"
1884  " alive_test integer,"
1885  " creation_time integer,"
1886  " modification_time integer);");
1887 
1888  sql ("CREATE TABLE IF NOT EXISTS targets_trash"
1889  " (id SERIAL PRIMARY KEY,"
1890  " uuid text UNIQUE NOT NULL,"
1891  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1892  " name text NOT NULL,"
1893  " hosts text,"
1894  " exclude_hosts text,"
1895  " reverse_lookup_only integer,"
1896  " reverse_lookup_unify integer,"
1897  " comment text,"
1898  " port_list integer," // REFERENCES port_lists (id) ON DELETE RESTRICT,"
1899  " port_list_location integer,"
1900  " alive_test integer,"
1901  " creation_time integer,"
1902  " modification_time integer);");
1903 
1904  sql ("CREATE TABLE IF NOT EXISTS targets_login_data"
1905  " (id SERIAL PRIMARY KEY,"
1906  " target INTEGER REFERENCES targets (id) ON DELETE RESTRICT,"
1907  " type TEXT,"
1908  " credential INTEGER REFERENCES credentials (id) ON DELETE RESTRICT,"
1909  " port INTEGER);");
1910 
1911  sql ("CREATE TABLE IF NOT EXISTS targets_trash_login_data"
1912  " (id SERIAL PRIMARY KEY,"
1913  " target INTEGER REFERENCES targets_trash (id) ON DELETE RESTRICT,"
1914  " type TEXT,"
1915  " credential INTEGER,"//REFERENCES credentials (id) ON DELETE RESTRICT,"
1916  " port INTEGER,"
1917  " credential_location INTEGER);");
1918 
1919  sql ("CREATE TABLE IF NOT EXISTS scanners"
1920  " (id SERIAL PRIMARY KEY,"
1921  " uuid text UNIQUE NOT NULL,"
1922  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1923  " name text,"
1924  " comment text,"
1925  " host text,"
1926  " port integer,"
1927  " type integer,"
1928  " ca_pub text,"
1929  " credential integer REFERENCES credentials (id) ON DELETE RESTRICT,"
1930  " creation_time integer,"
1931  " modification_time integer);");
1932 
1933  sql ("CREATE TABLE IF NOT EXISTS configs"
1934  " (id SERIAL PRIMARY KEY,"
1935  " uuid text UNIQUE NOT NULL,"
1936  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1937  " name text NOT NULL,"
1938  " nvt_selector text," /* REFERENCES nvt_selectors (name) */
1939  " comment text,"
1940  " family_count integer,"
1941  " nvt_count integer,"
1942  " families_growing integer,"
1943  " nvts_growing integer,"
1944  " type integer,"
1945  " scanner integer REFERENCES scanners (id) ON DELETE RESTRICT,"
1946  " creation_time integer,"
1947  " modification_time integer);");
1948 
1949  sql ("CREATE TABLE IF NOT EXISTS configs_trash"
1950  " (id SERIAL PRIMARY KEY,"
1951  " uuid text UNIQUE NOT NULL,"
1952  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1953  " name text NOT NULL,"
1954  " nvt_selector text," /* REFERENCES nvt_selectors (name) */
1955  " comment text,"
1956  " family_count integer,"
1957  " nvt_count integer,"
1958  " families_growing integer,"
1959  " nvts_growing integer,"
1960  " type integer,"
1961  " scanner integer REFERENCES scanners (id) ON DELETE RESTRICT,"
1962  " creation_time integer,"
1963  " modification_time integer);");
1964 
1965  sql ("CREATE TABLE IF NOT EXISTS config_preferences"
1966  " (id SERIAL PRIMARY KEY,"
1967  " config integer REFERENCES configs (id) ON DELETE RESTRICT,"
1968  " type text,"
1969  " name text,"
1970  " value text,"
1971  " default_value text,"
1972  " hr_name text);");
1973 
1974  sql ("CREATE TABLE IF NOT EXISTS config_preferences_trash"
1975  " (id SERIAL PRIMARY KEY,"
1976  " config integer REFERENCES configs_trash (id) ON DELETE RESTRICT,"
1977  " type text,"
1978  " name text,"
1979  " value text,"
1980  " default_value text,"
1981  " hr_name text);");
1982 
1983  sql ("CREATE TABLE IF NOT EXISTS schedules"
1984  " (id SERIAL PRIMARY KEY,"
1985  " uuid text UNIQUE NOT NULL,"
1986  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
1987  " name text NOT NULL,"
1988  " comment text,"
1989  " first_time integer,"
1990  " period integer,"
1991  " period_months integer,"
1992  " duration integer,"
1993  " timezone text,"
1994  " initial_offset integer,"
1995  " creation_time integer,"
1996  " modification_time integer);");
1997 
1998  sql ("CREATE TABLE IF NOT EXISTS schedules_trash"
1999  " (id SERIAL PRIMARY KEY,"
2000  " uuid text UNIQUE NOT NULL,"
2001  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2002  " name text NOT NULL,"
2003  " comment text,"
2004  " first_time integer,"
2005  " period integer,"
2006  " period_months integer,"
2007  " duration integer,"
2008  " timezone text,"
2009  " initial_offset integer,"
2010  " creation_time integer,"
2011  " modification_time integer);");
2012 
2013  sql ("CREATE TABLE IF NOT EXISTS scanners_trash"
2014  " (id SERIAL PRIMARY KEY,"
2015  " uuid text UNIQUE NOT NULL,"
2016  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2017  " name text,"
2018  " comment text,"
2019  " host text,"
2020  " port integer,"
2021  " type integer,"
2022  " ca_pub text,"
2023  " credential integer,"
2024  " credential_location integer,"
2025  " creation_time integer,"
2026  " modification_time integer);");
2027 
2028  sql ("CREATE TABLE IF NOT EXISTS tasks"
2029  " (id SERIAL PRIMARY KEY,"
2030  " uuid text UNIQUE NOT NULL,"
2031  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2032  " name text,"
2033  " hidden integer,"
2034  " comment text,"
2035  " run_status integer,"
2036  " start_time integer,"
2037  " end_time integer,"
2038  " config integer," // REFERENCES configs (id) ON DELETE RESTRICT,"
2039  " target integer," // REFERENCES targets (id) ON DELETE RESTRICT,"
2040  " schedule integer," // REFERENCES schedules (id) ON DELETE RESTRICT,"
2041  " schedule_next_time integer,"
2042  " schedule_periods integer,"
2043  " scanner integer," // REFERENCES scanner (id) ON DELETE RESTRICT,"
2044  " config_location integer,"
2045  " target_location integer,"
2046  " schedule_location integer,"
2047  " scanner_location integer,"
2048  " upload_result_count integer,"
2049  " hosts_ordering text,"
2050  " alterable integer,"
2051  " creation_time integer,"
2052  " modification_time integer);");
2053 
2054  sql ("CREATE TABLE IF NOT EXISTS task_files"
2055  " (id SERIAL PRIMARY KEY,"
2056  " task integer REFERENCES tasks (id) ON DELETE RESTRICT,"
2057  " name text,"
2058  " content text);");
2059 
2060  sql ("CREATE TABLE IF NOT EXISTS task_alerts"
2061  " (id SERIAL PRIMARY KEY,"
2062  " task integer REFERENCES tasks (id) ON DELETE RESTRICT,"
2063  " alert integer," // REFERENCES alerts (id) ON DELETE RESTRICT,"
2064  " alert_location integer);");
2065 
2066  sql ("CREATE TABLE IF NOT EXISTS task_preferences"
2067  " (id SERIAL PRIMARY KEY,"
2068  " task integer REFERENCES tasks (id) ON DELETE RESTRICT,"
2069  " name text,"
2070  " value text);");
2071 
2072  sql ("CREATE TABLE IF NOT EXISTS reports"
2073  " (id SERIAL PRIMARY KEY,"
2074  " uuid text UNIQUE NOT NULL,"
2075  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2076  " hidden integer,"
2077  " task integer REFERENCES tasks (id) ON DELETE RESTRICT,"
2078  " date integer,"
2079  " start_time integer,"
2080  " end_time integer,"
2081  " nbefile text,"
2082  " comment text,"
2083  " scan_run_status integer,"
2084  " slave_progress integer,"
2085  " slave_task_uuid text,"
2086  " slave_uuid text,"
2087  " slave_name text,"
2088  " slave_host text,"
2089  " slave_port integer,"
2090  " source_iface text,"
2091  " flags integer);");
2092 
2093  sql ("CREATE TABLE IF NOT EXISTS report_counts"
2094  " (id SERIAL PRIMARY KEY,"
2095  " report integer REFERENCES reports (id) ON DELETE RESTRICT,"
2096  " \"user\" integer REFERENCES users (id) ON DELETE RESTRICT,"
2097  " severity decimal,"
2098  " count integer,"
2099  " override integer,"
2100  " end_time integer,"
2101  " min_qod integer);");
2102 
2103  sql ("CREATE TABLE IF NOT EXISTS resources_predefined"
2104  " (id SERIAL PRIMARY KEY,"
2105  " resource_type text,"
2106  " resource integer);");
2107 
2108  sql ("CREATE TABLE IF NOT EXISTS results"
2109  " (id SERIAL PRIMARY KEY,"
2110  " uuid text UNIQUE NOT NULL,"
2111  " task integer REFERENCES tasks (id) ON DELETE RESTRICT,"
2112  " host text,"
2113  " port text,"
2114  " nvt text,"
2115  " type text,"
2116  " description text,"
2117  " report integer REFERENCES reports (id) ON DELETE RESTRICT,"
2118  " nvt_version text,"
2119  " severity real,"
2120  " qod integer,"
2121  " qod_type text,"
2122  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2123  " date integer);");
2124 
2125  sql ("CREATE TABLE IF NOT EXISTS report_formats"
2126  " (id SERIAL PRIMARY KEY,"
2127  " uuid text UNIQUE NOT NULL,"
2128  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2129  " name text NOT NULL,"
2130  " extension text,"
2131  " content_type text,"
2132  " summary text,"
2133  " description text,"
2134  " signature text,"
2135  " trust integer,"
2136  " trust_time integer,"
2137  " flags integer,"
2138  " creation_time integer,"
2139  " modification_time integer);");
2140 
2141  sql ("CREATE TABLE IF NOT EXISTS report_formats_trash"
2142  " (id SERIAL PRIMARY KEY,"
2143  " uuid text UNIQUE NOT NULL,"
2144  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2145  " name text NOT NULL,"
2146  " extension text,"
2147  " content_type text,"
2148  " summary text,"
2149  " description text,"
2150  " signature text,"
2151  " trust integer,"
2152  " trust_time integer,"
2153  " flags integer,"
2154  " original_uuid text,"
2155  " creation_time integer,"
2156  " modification_time integer);");
2157 
2158  sql ("CREATE TABLE IF NOT EXISTS report_format_params"
2159  " (id SERIAL PRIMARY KEY,"
2160  " report_format integer REFERENCES report_formats (id) ON DELETE RESTRICT,"
2161  " name text,"
2162  " type integer,"
2163  " value text,"
2164  " type_min bigint,"
2165  " type_max bigint,"
2166  " type_regex text,"
2167  " fallback text);");
2168 
2169  sql ("CREATE TABLE IF NOT EXISTS report_format_params_trash"
2170  " (id SERIAL PRIMARY KEY,"
2171  " report_format integer REFERENCES report_formats_trash (id) ON DELETE RESTRICT,"
2172  " name text,"
2173  " type integer,"
2174  " value text,"
2175  " type_min bigint,"
2176  " type_max bigint,"
2177  " type_regex text,"
2178  " fallback text);");
2179 
2180  sql ("CREATE TABLE IF NOT EXISTS report_format_param_options"
2181  " (id SERIAL PRIMARY KEY,"
2182  " report_format_param integer REFERENCES report_format_params (id) ON DELETE RESTRICT,"
2183  " value text);");
2184 
2185  sql ("CREATE TABLE IF NOT EXISTS report_format_param_options_trash"
2186  " (id SERIAL PRIMARY KEY,"
2187  " report_format_param integer REFERENCES report_format_params_trash (id) ON DELETE RESTRICT,"
2188  " value text);");
2189 
2190  sql ("CREATE TABLE IF NOT EXISTS report_hosts"
2191  " (id SERIAL PRIMARY KEY,"
2192  " report integer REFERENCES reports (id) ON DELETE RESTRICT,"
2193  " host text,"
2194  " start_time integer,"
2195  " end_time integer,"
2196  " current_port integer,"
2197  " max_port integer);");
2198 
2199  sql ("CREATE TABLE IF NOT EXISTS report_host_details"
2200  " (id SERIAL PRIMARY KEY,"
2201  " report_host integer REFERENCES report_hosts (id) ON DELETE RESTRICT,"
2202  " source_type text,"
2203  " source_name text,"
2204  " source_description text,"
2205  " name text,"
2206  " value text);");
2207 
2208  sql ("CREATE TABLE IF NOT EXISTS nvt_preferences"
2209  " (id SERIAL PRIMARY KEY,"
2210  " name text UNIQUE NOT NULL,"
2211  " value text);");
2212 
2213  sql ("CREATE TABLE IF NOT EXISTS nvts"
2214  " (id SERIAL PRIMARY KEY,"
2215  " uuid text UNIQUE NOT NULL,"
2216  " oid text UNIQUE NOT NULL,"
2217  " version text,"
2218  " name text,"
2219  " comment text,"
2220  " copyright text,"
2221  " cve text,"
2222  " bid text,"
2223  " xref text,"
2224  " tag text,"
2225  " category text,"
2226  " family text,"
2227  " cvss_base text,"
2228  " creation_time integer,"
2229  " modification_time integer,"
2230  " solution_type text,"
2231  " qod integer,"
2232  " qod_type text);");
2233 
2234  sql ("CREATE TABLE IF NOT EXISTS nvt_cves"
2235  " (id SERIAL PRIMARY KEY,"
2236  " nvt integer REFERENCES nvts (id) ON DELETE RESTRICT,"
2237  " oid text,"
2238  " cve_name text);");
2239 
2240  sql ("CREATE TABLE IF NOT EXISTS notes"
2241  " (id SERIAL PRIMARY KEY,"
2242  " uuid text UNIQUE NOT NULL,"
2243  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2244  " nvt text NOT NULL,"
2245  " creation_time integer,"
2246  " modification_time integer,"
2247  " text text,"
2248  " hosts text,"
2249  " port text,"
2250  " severity double precision,"
2251  " task integer," // REFERENCES tasks (id) ON DELETE RESTRICT,"
2252  " result integer," // REFERENCES results (id) ON DELETE RESTRICT,"
2253  " end_time integer);");
2254 
2255  sql ("CREATE TABLE IF NOT EXISTS notes_trash"
2256  " (id SERIAL PRIMARY KEY,"
2257  " uuid text UNIQUE NOT NULL,"
2258  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2259  " nvt text NOT NULL,"
2260  " creation_time integer,"
2261  " modification_time integer,"
2262  " text text,"
2263  " hosts text,"
2264  " port text,"
2265  " severity double precision,"
2266  " task integer," // REFERENCES tasks (id) ON DELETE RESTRICT,"
2267  " result integer," // REFERENCES results (id) ON DELETE RESTRICT,"
2268  " end_time integer);");
2269 
2270  sql ("CREATE TABLE IF NOT EXISTS overrides"
2271  " (id SERIAL PRIMARY KEY,"
2272  " uuid text UNIQUE NOT NULL,"
2273  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2274  " nvt text NOT NULL,"
2275  " creation_time integer,"
2276  " modification_time integer,"
2277  " text text,"
2278  " hosts text,"
2279  " new_severity double precision,"
2280  " port text,"
2281  " severity double precision,"
2282  " task integer," // REFERENCES tasks (id) ON DELETE RESTRICT,"
2283  " result integer," // REFERENCES results (id) ON DELETE RESTRICT,"
2284  " end_time integer);");
2285 
2286  sql ("CREATE TABLE IF NOT EXISTS overrides_trash"
2287  " (id SERIAL PRIMARY KEY,"
2288  " uuid text UNIQUE NOT NULL,"
2289  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2290  " nvt text NOT NULL,"
2291  " creation_time integer,"
2292  " modification_time integer,"
2293  " text text,"
2294  " hosts text,"
2295  " new_severity double precision,"
2296  " port text,"
2297  " severity double precision,"
2298  " task integer," // REFERENCES tasks (id) ON DELETE RESTRICT,"
2299  " result integer," // REFERENCES results (id) ON DELETE RESTRICT,"
2300  " end_time integer);");
2301 
2302  sql ("CREATE TABLE IF NOT EXISTS permissions"
2303  " (id SERIAL PRIMARY KEY,"
2304  " uuid text UNIQUE NOT NULL,"
2305  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2306  " name text NOT NULL,"
2307  " comment text,"
2308  " resource_type text,"
2309  " resource integer,"
2310  " resource_uuid text,"
2311  " resource_location integer,"
2312  " subject_type text,"
2313  " subject integer,"
2314  " subject_location integer,"
2315  " creation_time integer,"
2316  " modification_time integer);");
2317 
2318  sql ("CREATE TABLE IF NOT EXISTS permissions_trash"
2319  " (id SERIAL PRIMARY KEY,"
2320  " uuid text UNIQUE NOT NULL,"
2321  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2322  " name text NOT NULL,"
2323  " comment text,"
2324  " resource_type text,"
2325  " resource integer,"
2326  " resource_uuid text,"
2327  " resource_location integer,"
2328  " subject_type text,"
2329  " subject integer,"
2330  " subject_location integer,"
2331  " creation_time integer,"
2332  " modification_time integer);");
2333 
2334  sql ("CREATE TABLE IF NOT EXISTS settings"
2335  " (id SERIAL PRIMARY KEY,"
2336  " uuid text NOT NULL," /* Note: not UNIQUE. */
2337  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2338  " name text NOT NULL,"
2339  " comment text,"
2340  " value text);");
2341 
2342  sql ("CREATE TABLE IF NOT EXISTS tags"
2343  " (id SERIAL PRIMARY KEY,"
2344  " uuid text UNIQUE NOT NULL,"
2345  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2346  " name text NOT NULL,"
2347  " comment text,"
2348  " resource_type text,"
2349  " resource integer,"
2350  " resource_uuid text,"
2351  " resource_location integer,"
2352  " active integer,"
2353  " value text,"
2354  " creation_time integer,"
2355  " modification_time integer);");
2356 
2357  sql ("CREATE TABLE IF NOT EXISTS tags_trash"
2358  " (id SERIAL PRIMARY KEY,"
2359  " uuid text UNIQUE NOT NULL,"
2360  " owner integer REFERENCES users (id) ON DELETE RESTRICT,"
2361  " name text NOT NULL,"
2362  " comment text,"
2363  " resource_type text,"
2364  " resource integer,"
2365  " resource_uuid text,"
2366  " resource_location integer,"
2367  " active integer,"
2368  " value text,"
2369  " creation_time integer,"
2370  " modification_time integer);");
2371 
2372  /* Create result views. */
2373 
2374  /* Create functions, so that current_severity is created for
2375  * result_new_severities. */
2377 
2378  owned_clause = acl_where_owned_for_get ("override", "users.id");
2379 
2380  sql ("CREATE OR REPLACE VIEW result_overrides AS"
2381  " SELECT users.id AS user,"
2382  " results.id as result,"
2383  " overrides.id AS override,"
2384  " overrides.severity AS ov_old_severity,"
2385  " overrides.new_severity AS ov_new_severity"
2386  " FROM users, results, overrides"
2387  " WHERE overrides.nvt = results.nvt"
2388  " AND (overrides.result = 0 OR overrides.result = results.id)"
2389  " AND %s"
2390  " AND ((overrides.end_time = 0)"
2391  " OR (overrides.end_time >= m_now ()))"
2392  " AND (overrides.task ="
2393  " (SELECT reports.task FROM reports"
2394  " WHERE results.report = reports.id)"
2395  " OR overrides.task = 0)"
2396  " AND (overrides.result = results.id"
2397  " OR overrides.result = 0)"
2398  " AND (overrides.hosts is NULL"
2399  " OR overrides.hosts = ''"
2400  " OR hosts_contains (overrides.hosts, results.host))"
2401  " AND (overrides.port is NULL"
2402  " OR overrides.port = ''"
2403  " OR overrides.port = results.port)"
2404  " ORDER BY overrides.result DESC, overrides.task DESC,"
2405  " overrides.port DESC, overrides.severity ASC,"
2406  " overrides.creation_time DESC",
2407  owned_clause);
2408 
2409  g_free (owned_clause);
2410 
2411  sql ("CREATE OR REPLACE VIEW result_new_severities AS"
2412  " SELECT results.id as result, users.id as user, dynamic, override,"
2413  " CASE WHEN dynamic != 0 THEN"
2414  " CASE WHEN override != 0 THEN"
2415  " coalesce ((SELECT ov_new_severity FROM result_overrides"
2416  " WHERE result = results.id"
2417  " AND result_overrides.user = users.id"
2418  " AND severity_matches_ov"
2419  " (current_severity (results.severity,"
2420  " results.nvt),"
2421  " ov_old_severity)"
2422  " LIMIT 1),"
2423  " current_severity (results.severity, results.nvt))"
2424  " ELSE"
2425  " current_severity (results.severity, results.nvt)"
2426  " END"
2427  " ELSE"
2428  " CASE WHEN override != 0 THEN"
2429  " coalesce ((SELECT ov_new_severity FROM result_overrides"
2430  " WHERE result = results.id"
2431  " AND result_overrides.user = users.id"
2432  " AND severity_matches_ov"
2433  " (results.severity,"
2434  " ov_old_severity)"
2435  " LIMIT 1),"
2436  " results.severity)"
2437  " ELSE"
2438  " results.severity"
2439  " END"
2440  " END AS new_severity"
2441  " FROM results, users,"
2442  " (SELECT 0 AS override UNION SELECT 1 AS override) AS override_opts,"
2443  " (SELECT 0 AS dynamic UNION SELECT 1 AS dynamic) AS dynamic_opts;");
2444 
2445  sql ("CREATE OR REPLACE VIEW results_autofp AS"
2446  " SELECT results.id as result, autofp_selection,"
2447  " (CASE autofp_selection"
2448  " WHEN 1 THEN"
2449  " (CASE WHEN"
2450  " (((SELECT family FROM nvts WHERE oid = results.nvt)"
2451  " IN (" LSC_FAMILY_LIST "))"
2452  " OR results.nvt = '0'" /* Open ports previously had 0 NVT. */
2453  " OR EXISTS"
2454  " (SELECT id FROM nvts"
2455  " WHERE oid = results.nvt"
2456  " AND"
2457  " (cve = 'NOCVE'"
2458  " OR cve NOT IN (SELECT cve FROM nvts"
2459  " WHERE oid"
2460  " IN (SELECT source_name"
2461  " FROM report_host_details"
2462  " WHERE report_host"
2463  " = (SELECT id"
2464  " FROM report_hosts"
2465  " WHERE report = %llu"
2466  " AND host"
2467  " = results.host)"
2468  " AND name = 'EXIT_CODE'"
2469  " AND value = 'EXIT_NOTVULN')"
2470  " AND family IN (" LSC_FAMILY_LIST ")))))"
2471  " THEN NULL"
2472  " WHEN severity = " G_STRINGIFY (SEVERITY_ERROR) " THEN NULL"
2473  " ELSE 1 END)"
2474  " WHEN 2 THEN"
2475  " (CASE WHEN"
2476  " (((SELECT family FROM nvts WHERE oid = results.nvt)"
2477  " IN (" LSC_FAMILY_LIST "))"
2478  " OR results.nvt = '0'" /* Open ports previously had 0 NVT.*/
2479  " OR EXISTS"
2480  " (SELECT id FROM nvts AS outer_nvts"
2481  " WHERE oid = results.nvt"
2482  " AND"
2483  " (cve = 'NOCVE'"
2484  " OR NOT EXISTS"
2485  " (SELECT cve FROM nvts"
2486  " WHERE oid IN (SELECT source_name"
2487  " FROM report_host_details"
2488  " WHERE report_host"
2489  " = (SELECT id"
2490  " FROM report_hosts"
2491  " WHERE report = results.report"
2492  " AND host = results.host)"
2493  " AND name = 'EXIT_CODE'"
2494  " AND value = 'EXIT_NOTVULN')"
2495  " AND family IN (" LSC_FAMILY_LIST ")"
2496  /* The CVE of the result NVT is outer_nvts.cve. The CVE of the
2497  * NVT that has registered the "closed" host detail is nvts.cve.
2498  * Either can be a list of CVEs. */
2499  " AND common_cve (nvts.cve, outer_nvts.cve)))))"
2500  " THEN NULL"
2501  " WHEN severity = " G_STRINGIFY (SEVERITY_ERROR) " THEN NULL"
2502  " ELSE 1 END)"
2503  " ELSE 0 END) AS autofp"
2504  " FROM results,"
2505  " (SELECT 0 AS autofp_selection"
2506  " UNION SELECT 1 AS autofp_selection"
2507  " UNION SELECT 2 AS autofp_selection) AS autofp_opts;");
2508 
2509  /* Create indexes. */
2510 
2511  sql ("SELECT create_index ('host_details_by_host',"
2512  " 'host_details', 'host');");
2513 
2514  sql ("SELECT create_index ('host_identifiers_by_host',"
2515  " 'host_identifiers', 'host');");
2516  sql ("SELECT create_index ('host_identifiers_by_value',"
2517  " 'host_identifiers', 'value');");
2518 
2519  sql ("SELECT create_index ('host_max_severities_by_host',"
2520  " 'host_max_severities', 'host');");
2521  sql ("SELECT create_index ('host_oss_by_host',"
2522  " 'host_oss', 'host');");
2523 
2524  sql ("SELECT create_index ('nvt_cves_by_oid', 'nvt_cves', 'oid');");
2525  sql ("SELECT create_index ('nvt_selectors_by_family_or_nvt',"
2526  " 'nvt_selectors',"
2527  " 'type, family_or_nvt');");
2528  sql ("SELECT create_index ('nvt_selectors_by_name',"
2529  " 'nvt_selectors',"
2530  " 'name');");
2531  sql ("SELECT create_index ('nvts_by_creation_time',"
2532  " 'nvts',"
2533  " 'creation_time');");
2534  sql ("SELECT create_index ('nvts_by_family', 'nvts', 'family');");
2535  sql ("SELECT create_index ('nvts_by_name', 'nvts', 'name');");
2536  sql ("SELECT create_index ('nvts_by_modification_time',"
2537  " 'nvts', 'modification_time');");
2538  sql ("SELECT create_index ('nvts_by_cvss_base',"
2539  " 'nvts', 'cvss_base');");
2540  sql ("SELECT create_index ('nvts_by_solution_type',"
2541  " 'nvts', 'solution_type');");
2542 
2543  sql ("SELECT create_index ('permissions_by_name',"
2544  " 'permissions', 'name');");
2545  sql ("SELECT create_index ('permissions_by_resource',"
2546  " 'permissions', 'resource');");
2547 
2548  sql ("SELECT create_index ('report_counts_by_report_and_override',"
2549  " 'report_counts', 'report, override');");
2550 
2551 
2552 #if 0
2553  /* TODO The value column can be bigger than 8191, the maximum size that
2554  * Postgres can handle. For example, this can happen for "ports".
2555  * Mostly value is short, like a CPE for the "App" detail, which is
2556  * what the index is for. */
2557  sql ("SELECT create_index"
2558  " ('report_host_details_by_report_host_and_name_and_value',"
2559  " 'report_host_details',"
2560  " 'report_host, name, value');");
2561 #else
2562  sql ("SELECT create_index"
2563  " ('report_host_details_by_report_host_and_name',"
2564  " 'report_host_details',"
2565  " 'report_host, name');");
2566 #endif
2567  sql ("SELECT create_index"
2568  " ('report_hosts_by_report_and_host',"
2569  " 'report_hosts',"
2570  " 'report, host');");
2571  sql ("SELECT create_index ('results_by_host_and_qod', 'results',"
2572  " 'host, qod');");
2573  sql ("SELECT create_index ('results_by_report', 'results', 'report');");
2574  sql ("SELECT create_index ('results_by_task', 'results', 'task');");
2575  sql ("SELECT create_index ('results_by_date', 'results', 'date');");
2576 }
#define LSC_FAMILY_LIST
SQL list of LSC families.
Definition: manage.h:1065
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * acl_where_owned_for_get(const char *type, const char *user_sql)
Generate ownership part of WHERE, for getting a type of resource.
Definition: manage_acl.c:1378
int manage_create_sql_functions()
Create functions.
Definition: manage_pg.c:113
#define SEVERITY_ERROR
Definition: manage_utils.h:38
Here is the call graph for this function:

◆ days_from_now()

int days_from_now ( time_t *  epoch_time)

Calculate difference between now and epoch_time in days.

Parameters
[in]epoch_timeTime in seconds from epoch.
Returns
Int days bettween now and epoch_time or -1 if epoch_time is in the past

Definition at line 1072 of file manage_sql.c.

Referenced by sql_days_from_now().

1073 {
1074  time_t now = time (NULL);
1075  int diff = *epoch_time - now;
1076 
1077  if (diff < 0) return -1;
1078  return diff / 86400; /* 60 sec * 60 min * 24 h */
1079 }
Here is the caller graph for this function:

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

Definition at line 8195 of file manage_sql.c.

References acl_user_may(), find_alert_with_permission(), sql_begin_immediate(), and sql_rollback().

8196 {
8197  alert_t alert = 0;
8198 
8200 
8201  if (acl_user_may ("delete_alert") == 0)
8202  {
8203  sql_rollback ();
8204  return 99;
8205  }
8206 
8207  if (find_alert_with_permission (alert_id, &alert, "delete_alert"))
8208  {
8209  sql_rollback ();
8210  return -1;
8211  }
8212 
8213  if (alert == 0)
8214  {
8215  if (find_trash ("alert", alert_id, &alert))
8216  {
8217  sql_rollback ();
8218  return -1;
8219  }
8220  if (alert == 0)
8221  {
8222  sql_rollback ();
8223  return 2;
8224  }
8225  if (ultimate == 0)
8226  {
8227  /* It's already in the trashcan. */
8228  sql_commit ();
8229  return 0;
8230  }
8231 
8232  /* Check if it's in use by a task in the trashcan. */
8233  if (sql_int ("SELECT count(*) FROM task_alerts"
8234  " WHERE alert = %llu"
8235  " AND alert_location = " G_STRINGIFY (LOCATION_TRASH) ";",
8236  alert))
8237  {
8238  sql_rollback ();
8239  return 1;
8240  }
8241 
8242  permissions_set_orphans ("alert", alert, LOCATION_TRASH);
8243  tags_set_orphans ("alert", alert, LOCATION_TRASH);
8244 
8245  sql ("DELETE FROM alert_condition_data_trash WHERE alert = %llu;",
8246  alert);
8247  sql ("DELETE FROM alert_event_data_trash WHERE alert = %llu;",
8248  alert);
8249  sql ("DELETE FROM alert_method_data_trash WHERE alert = %llu;",
8250  alert);
8251  sql ("DELETE FROM alerts_trash WHERE id = %llu;", alert);
8252  sql_commit ();
8253  return 0;
8254  }
8255 
8256  if (ultimate == 0)
8257  {
8258  alert_t trash_alert;
8259 
8260  if (sql_int ("SELECT count(*) FROM task_alerts"
8261  " WHERE alert = %llu"
8262  " AND alert_location = " G_STRINGIFY (LOCATION_TABLE)
8263  " AND (SELECT hidden < 2 FROM tasks"
8264  " WHERE id = task_alerts.task);",
8265  alert))
8266  {
8267  sql_rollback ();
8268  return 1;
8269  }
8270 
8271  sql ("INSERT INTO alerts_trash"
8272  " (uuid, owner, name, comment, event, condition, method, filter,"
8273  " filter_location, creation_time, modification_time)"
8274  " SELECT uuid, owner, name, comment, event, condition, method,"
8275  " filter, " G_STRINGIFY (LOCATION_TABLE) ", creation_time,"
8276  " m_now ()"
8277  " FROM alerts WHERE id = %llu;",
8278  alert);
8279 
8280  trash_alert = sql_last_insert_id ();
8281 
8282  sql ("INSERT INTO alert_condition_data_trash"
8283  " (alert, name, data)"
8284  " SELECT %llu, name, data"
8285  " FROM alert_condition_data WHERE alert = %llu;",
8286  trash_alert,
8287  alert);
8288 
8289  sql ("INSERT INTO alert_event_data_trash"
8290  " (alert, name, data)"
8291  " SELECT %llu, name, data"
8292  " FROM alert_event_data WHERE alert = %llu;",
8293  trash_alert,
8294  alert);
8295 
8296  sql ("INSERT INTO alert_method_data_trash"
8297  " (alert, name, data)"
8298  " SELECT %llu, name, data"
8299  " FROM alert_method_data WHERE alert = %llu;",
8300  trash_alert,
8301  alert);
8302 
8303  /* Update the location of the alert in any trashcan tasks. */
8304  sql ("UPDATE task_alerts"
8305  " SET alert = %llu,"
8306  " alert_location = " G_STRINGIFY (LOCATION_TRASH)
8307  " WHERE alert = %llu"
8308  " AND alert_location = " G_STRINGIFY (LOCATION_TABLE) ";",
8309  trash_alert,
8310  alert);
8311 
8312  permissions_set_locations ("alert", alert, trash_alert,
8313  LOCATION_TRASH);
8314  tags_set_locations ("alert", alert, trash_alert,
8315  LOCATION_TRASH);
8316  }
8317  else if (sql_int ("SELECT count(*) FROM task_alerts"
8318  " WHERE alert = %llu"
8319  " AND alert_location = " G_STRINGIFY (LOCATION_TABLE) ";",
8320  alert))
8321  {
8322  sql_rollback ();
8323  return 1;
8324  }
8325  else
8326  {
8327  permissions_set_orphans ("alert", alert, LOCATION_TABLE);
8328  tags_set_orphans ("alert", alert, LOCATION_TABLE);
8329  }
8330 
8331  sql ("DELETE FROM alert_condition_data WHERE alert = %llu;",
8332  alert);
8333  sql ("DELETE FROM alert_event_data WHERE alert = %llu;", alert);
8334  sql ("DELETE FROM alert_method_data WHERE alert = %llu;", alert);
8335  sql ("DELETE FROM alerts WHERE id = %llu;", alert);
8336  sql_commit ();
8337  return 0;
8338 }
long long int alert_t
Definition: manage.h:280
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
void permissions_set_locations(const char *, resource_t, resource_t, int)
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
resource_t sql_last_insert_id()
Get the ID of the last inserted row.
Definition: sql_pg.c:395
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
void tags_set_locations(const char *, resource_t, resource_t, int)
gboolean find_alert_with_permission(const char *uuid, alert_t *alert, const char *permission)
Find a alert for a specific permission, given a UUID.
Definition: manage_sql.c:6983
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
Definition: manage_acl.c:56
void permissions_set_orphans(const char *, resource_t, int)
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
void tags_set_orphans(const char *, resource_t, int)
Here is the call graph for this function:

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

Definition at line 733 of file manage.c.

References cleanup_iterator(), delete_report_internal(), init_report_iterator_task(), and next_report().

734 {
735  report_t report;
738  while (next_report (&iterator, &report))
739  if (delete_report_internal (report))
740  {
742  return -1;
743  }
745  return 0;
746 }
A generic SQL iterator.
Definition: iterator.h:52
void init_report_iterator_task(iterator_t *, task_t)
long long int report_t
Definition: manage.h:288
gboolean next_report(iterator_t *, report_t *)
int delete_report_internal(report_t)
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
Here is the call graph for this function:

◆ delete_slave_task()

int delete_slave_task ( const char *  ,
int  ,
const char *  ,
const char *  ,
const char *   
)

◆ delete_task_lock()

int delete_task_lock ( task_t  ,
int   
)

◆ email_secinfo()

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.

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.

Definition at line 11164 of file manage_sql.c.

11168 {
11169  gchar *alert_subject, *message, *subject, *example, *list, *type, *base64;
11170  gchar *body;
11171  char *notice;
11172  int ret, count;
11173 
11174  list = new_secinfo_list (event, event_data, alert, &count);
11175 
11176  type = g_strdup (event_data);
11177  if (type && (example = strstr (type, "_example")))
11178  example[0] = '\0';
11179 
11180  /* Setup subject. */
11181 
11182  subject = g_strdup_printf
11183  ("[OpenVAS-Manager] %s %s arrived",
11184  event == EVENT_NEW_SECINFO ? "New" : "Updated",
11185  type_name_plural (type ? type : "nvt"));
11186  alert_subject = alert_data (alert, "method", "subject");
11187  if (alert_subject && strlen (alert_subject))
11188  {
11189  g_free (subject);
11190  subject = alert_subject_print (alert_subject, event,
11191  type, alert, task, count);
11192  }
11193  g_free (alert_subject);
11194 
11195  /* Setup body. */
11196 
11197  notice = alert_data (alert, "method", "notice");
11198 
11199  message = alert_data (alert, "method", "message");
11200  if (message == NULL || strlen (message) == 0)
11201  {
11202  g_free (message);
11203  if (notice && strcmp (notice, "0") == 0)
11204  /* Message with inlined report. */
11205  message = g_strdup (SECINFO_ALERT_MESSAGE_INCLUDE);
11206  else if (notice && strcmp (notice, "2") == 0)
11207  /* Message with attached report. */
11208  message = g_strdup (SECINFO_ALERT_MESSAGE_ATTACH);
11209  else
11210  /* Simple notice message. */
11211  message = NULL;
11212  }
11213 
11214  base64 = NULL;
11215  if (list && notice && strcmp (notice, "2") == 0)
11216  {
11217  /* Add list as text attachment. */
11218  if (max_attach_length <= 0
11219  || strlen (list) <= max_attach_length)
11220  base64 = g_base64_encode ((guchar*) list,
11221  strlen (list));
11222  }
11223 
11224  if (message && strlen (message))
11225  body = alert_message_print (message, event, type,
11226  task, alert, condition,
11227  NULL, 0, NULL, NULL, NULL,
11228  list,
11229  list ? strlen (list) : 0,
11230  0, count, 0);
11231  else
11232  {
11233  gchar *event_desc, *condition_desc;
11234  event_desc = event_description (event, event_data, NULL);
11235  condition_desc = alert_condition_description
11236  (condition, alert);
11237  body = g_strdup_printf (SECINFO_SIMPLE_NOTICE_FORMAT,
11238  event_desc,
11239  event_desc,
11240  condition_desc);
11241  free (event_desc);
11242  free (condition_desc);
11243  }
11244 
11245  g_free (message);
11246  g_free (list);
11247 
11248  /* Send email. */
11249 
11250  ret = email (to_address, from_address, subject,
11251  body, base64,
11252  base64 ? "text/plain" : NULL,
11253  base64 ? "secinfo-alert" : NULL,
11254  base64 ? "txt" : NULL);
11255  g_free (body);
11256  g_free (type);
11257  g_free (subject);
11258  return ret;
11259 }
char * alert_data(alert_t alert, const char *type, const char *name)
Return data associated with an alert.
Definition: manage_sql.c:8810
const char * type_name_plural(const char *type)
Return the plural name of a resource type.
Definition: manage.c:416
gchar * alert_condition_description(alert_condition_t condition, alert_t alert)
Get a description of an alert condition.
Definition: manage.c:1063
#define SECINFO_ALERT_MESSAGE_ATTACH
Default format string for SecInfo alert email, when attaching report.
Definition: manage.h:452
gchar * event_description(event_t event, const void *event_data, const char *task_name)
Get a description of an alert event.
Definition: manage.c:1114
#define SECINFO_ALERT_MESSAGE_INCLUDE
Default format string for SecInfo alert email, when including report.
Definition: manage.h:411
#define SECINFO_SIMPLE_NOTICE_FORMAT
Format string for simple notice alert email.
Definition: manage_sql.c:10702

◆ family_count()

int family_count ( )

◆ filter_control_int()

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

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.

Definition at line 2395 of file manage_sql.c.

References keyword::column, and keyword::string.

Referenced by manage_report_filter_controls().

2396 {
2397  if (val)
2398  while (*point)
2399  {
2400  keyword_t *keyword;
2401 
2402  keyword = *point;
2403  if (keyword->column
2404  && (strcmp (keyword->column, column) == 0))
2405  {
2406  *val = atoi (keyword->string);
2407  return 0;
2408  }
2409  point++;
2410  }
2411  return 1;
2412 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
Here is the caller graph for this function:

◆ filter_control_str()

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

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.

Definition at line 2424 of file manage_sql.c.

References keyword::column, and keyword::string.

Referenced by manage_report_filter_controls().

2425 {
2426  if (string)
2427  while (*point)
2428  {
2429  keyword_t *keyword;
2430 
2431  keyword = *point;
2432  if (keyword->column
2433  && (strcmp (keyword->column, column) == 0))
2434  {
2435  *string = g_strdup (keyword->string);
2436  return 0;
2437  }
2438  point++;
2439  }
2440  return 1;
2441 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
Here is the caller graph for this function:

◆ filter_free()

void filter_free ( array_t *  split)

Free a split filter.

Parameters
[in]splitSplit filter.

Definition at line 2018 of file manage_sql.c.

Referenced by manage_filter_controls(), and manage_report_filter_controls().

2019 {
2020  keyword_t **point;
2021  for (point = (keyword_t**) split->pdata; *point; point++)
2022  keyword_free (*point);
2023  array_free (split);
2024 }
Keyword.
Definition: manage.h:3428
Here is the caller graph for this function:

◆ 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 succesfully failed to find alert.
[in]permissionPermission.
Returns
FALSE on success (including if failed to find alert), TRUE on error.

Definition at line 6983 of file manage_sql.c.

References find_resource_with_permission().

Referenced by delete_alert(), manage_test_alert(), and set_task_alerts().

6985 {
6986  return find_resource_with_permission ("alert", uuid, alert, permission, 0);
6987 }
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.
Definition: manage_sql.c:4459
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_group()

gboolean find_group ( const char *  ,
group_t  
)

Referenced by set_task_groups().

Here is the caller graph for this function:

◆ find_resource()

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

Find a resource given a UUID.

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

Definition at line 4411 of file manage_sql.c.

References acl_user_owns_uuid(), sql_int64(), and sql_quote().

4412 {
4413  gchar *quoted_uuid;
4414  quoted_uuid = sql_quote (uuid);
4415  if (acl_user_owns_uuid (type, quoted_uuid, 0) == 0)
4416  {
4417  g_free (quoted_uuid);
4418  *resource = 0;
4419  return FALSE;
4420  }
4421  // TODO should really check type
4422  switch (sql_int64 (resource,
4423  "SELECT id FROM %ss WHERE uuid = '%s'%s;",
4424  type,
4425  quoted_uuid,
4426  strcmp (type, "task") ? "" : " AND hidden < 2"))
4427  {
4428  case 0:
4429  break;
4430  case 1: /* Too few rows in result of query. */
4431  *resource = 0;
4432  break;
4433  default: /* Programming error. */
4434  assert (0);
4435  case -1:
4436  g_free (quoted_uuid);
4437  return TRUE;
4438  break;
4439  }
4440 
4441  g_free (quoted_uuid);
4442  return FALSE;
4443 }
int acl_user_owns_uuid(const char *type, const char *uuid, int trash)
Test whether a user effectively owns a resource.
Definition: manage_acl.c:606
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
Here is the call graph for this function:

◆ find_resource_by_name_with_permission()

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.

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

Definition at line 4554 of file manage_sql.c.

References acl_user_has_access_uuid(), sql_int64(), sql_quote(), and sql_string().

4557 {
4558  gchar *quoted_name;
4559  assert (strcmp (type, "task"));
4560  if (name == NULL)
4561  return TRUE;
4562  quoted_name = sql_quote (name);
4563  // TODO should really check type
4564  switch (sql_int64 (resource,
4565  "SELECT id FROM %ss WHERE name = '%s'"
4566  " ORDER BY id DESC;",
4567  type,
4568  quoted_name))
4569  {
4570  case 0:
4571  {
4572  gchar *uuid;
4573 
4574  uuid = sql_string ("SELECT uuid FROM %ss WHERE id = %llu;",
4575  type, *resource);
4576  if (acl_user_has_access_uuid (type, uuid, permission, 0) == 0)
4577  {
4578  g_free (uuid);
4579  g_free (quoted_name);
4580  *resource = 0;
4581  return FALSE;
4582  }
4583  g_free (uuid);
4584  }
4585  break;
4586  case 1: /* Too few rows in result of query. */
4587  *resource = 0;
4588  break;
4589  default: /* Programming error. */
4590  assert (0);
4591  case -1:
4592  g_free (quoted_name);
4593  return TRUE;
4594  break;
4595  }
4596 
4597  g_free (quoted_name);
4598  return FALSE;
4599 }
int acl_user_has_access_uuid(const char *type, const char *uuid, const char *permission, int trash)
Test whether the user may access a resource.
Definition: manage_acl.c:758
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 4459 of file manage_sql.c.

References acl_user_has_access_uuid(), sql_int64(), sql_quote(), and valid_type().

Referenced by find_alert_with_permission().

4462 {
4463  gchar *quoted_uuid;
4464  if (uuid == NULL)
4465  return TRUE;
4466  if ((type == NULL) || (valid_type (type) == 0))
4467  return TRUE;
4468  quoted_uuid = sql_quote (uuid);
4469  if (acl_user_has_access_uuid (type, quoted_uuid, permission, trash) == 0)
4470  {
4471  g_free (quoted_uuid);
4472  *resource = 0;
4473  return FALSE;
4474  }
4475  switch (sql_int64 (resource,
4476  "SELECT id FROM %ss%s WHERE uuid = '%s'%s;",
4477  type,
4478  (strcmp (type, "task") && trash) ? "_trash" : "",
4479  quoted_uuid,
4480  strcmp (type, "task")
4481  ? ""
4482  : (trash ? " AND hidden = 2" : " AND hidden < 2")))
4483  {
4484  case 0:
4485  break;
4486  case 1: /* Too few rows in result of query. */
4487  *resource = 0;
4488  break;
4489  default: /* Programming error. */
4490  assert (0);
4491  case -1:
4492  g_free (quoted_uuid);
4493  return TRUE;
4494  break;
4495  }
4496 
4497  g_free (quoted_uuid);
4498  return FALSE;
4499 }
int acl_user_has_access_uuid(const char *type, const char *uuid, const char *permission, int trash)
Test whether the user may access a resource.
Definition: manage_acl.c:758
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
int valid_type(const char *)
Check whether a resource type name is valid.
Definition: manage_sql.c:4201
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_role()

gboolean find_role ( const char *  ,
group_t  
)

◆ find_role_with_permission()

gboolean find_role_with_permission ( const char *  ,
role_t ,
const char *   
)

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

Definition at line 6182 of file manage_sql.c.

6183 {
6184  gchar *quoted_name;
6185  int count;
6186  assert(type);
6187  assert(name);
6188 
6189  quoted_name = sql_quote (name);
6190  count = sql_int ("SELECT COUNT(id)"
6191  " FROM %ss"
6192  " WHERE name = '%s';",
6193  type,
6194  quoted_name);
6195  g_free (quoted_name);
6196 
6197  return count;
6198 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121

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

Definition at line 5402 of file manage_sql.c.

References filter_term(), filter_term_value(), init_iterator(), manage_cert_loaded(), manage_scap_loaded(), MIN_QOD_DEFAULT, sql_select_limit(), type_columns(), type_filter_columns(), type_opts_table(), type_owned(), type_select_columns(), type_trash_columns(), and type_where_columns().

5409 {
5410  int owned;
5411  gchar *autofp_str, *apply_overrides_str, *min_qod_str;
5412  int autofp, apply_overrides, min_qod;
5413  column_t *select_columns, *where_columns;
5414  gchar *columns;
5415  gchar *trash_columns;
5416  gchar *opts_table;
5417  const char **filter_columns;
5418  int first, max;
5419  gchar *from_table, *trash_extra, *clause, *filter_order, *filter;
5420  gchar *owned_clause;
5421  array_t *permissions;
5422  resource_t resource = 0;
5423  gchar *owner_filter;
5424  GString *aggregate_select, *outer_col_select;
5425  gchar *aggregate_group_by;
5426  gchar *outer_group_by_column, *outer_subgroup_column;
5427  gchar *select_group_column, *select_subgroup_column;
5428  GArray *select_data_columns, *select_text_columns;
5429  GString *order_clause;
5430 
5431  assert (get);
5432 
5433  if (get->id)
5434  g_warning ("%s: Called with an id parameter", __FUNCTION__);
5435 
5436  if ((manage_scap_loaded () == FALSE
5437  && (strcmp (type, "cve") == 0
5438  || strcmp (type, "cpe") == 0
5439  || strcmp (type, "ovaldef") == 0
5440  || strcmp (type, "allinfo") == 0))
5441  || (manage_cert_loaded () == FALSE
5442  && (strcmp (type, "cert_bund_adv") == 0
5443  || strcmp (type, "dfn_cert_adv") == 0
5444  || strcmp (type, "allinfo") == 0)))
5445  {
5446  // Init a dummy iterator if SCAP or CERT DB is required but unavailable.
5448  "SELECT NULL LIMIT %s",
5449  sql_select_limit (0));
5450  return 0;
5451  }
5452 
5453  if (get->filt_id && strcmp (get->filt_id, "0"))
5454  {
5455  if (get->filter_replacement)
5456  /* Replace the filter term with one given by the caller. This is
5457  * used by GET_REPORTS to use the default filter with any task (when
5458  * given the special value of -3 in filt_id). */
5459  filter = g_strdup (get->filter_replacement);
5460  else
5461  filter = filter_term (get->filt_id);
5462  if (filter == NULL)
5463  return 2;
5464  }
5465  else
5466  filter = NULL;
5467 
5468  autofp_str = filter_term_value (filter ? filter : get->filter,
5469  "autofp");
5470  autofp = autofp_str ? atoi (autofp_str) : 0;
5471  apply_overrides_str = filter_term_value (filter ? filter : get->filter,
5472  "apply_overrides");
5473  apply_overrides = apply_overrides_str ? atoi (apply_overrides_str) : 1;
5474  min_qod_str = filter_term_value (filter ? filter : get->filter, "min_qod");
5475  min_qod = (min_qod_str && strcmp (min_qod_str, ""))
5476  ? atoi (min_qod_str) : MIN_QOD_DEFAULT;
5477  g_free (apply_overrides_str);
5478  g_free (min_qod_str);
5479 
5480  select_columns = type_select_columns (type, apply_overrides);
5481  columns = type_columns (type, apply_overrides);
5482  trash_columns = type_trash_columns (type, apply_overrides);
5483  where_columns = type_where_columns (type, apply_overrides);
5484  filter_columns = type_filter_columns (type, apply_overrides);
5485  opts_table = type_opts_table (type, autofp, apply_overrides, min_qod);
5486 
5487  if (columns == NULL || filter_columns == NULL)
5488  {
5489  g_free (columns);
5490  g_free (trash_columns);
5491  g_free (opts_table);
5492  return 5;
5493  }
5494  if (get->trash && trash_columns == NULL)
5495  {
5496  g_free (columns);
5497  g_free (trash_columns);
5498  g_free (opts_table);
5499  return 6;
5500  }
5501 
5502  owned = type_owned (type);
5503 
5504  if (data_columns && data_columns->len > 0)
5505  {
5506  int i;
5507  for (i = 0; i < data_columns->len; i++)
5508  {
5509  if (vector_find_filter (filter_columns,
5510  g_array_index (data_columns, gchar*, i))
5511  == 0)
5512  {
5513  g_free (columns);
5514  g_free (trash_columns);
5515  g_free (opts_table);
5516  return 3;
5517  }
5518  }
5519  }
5520  if (text_columns && text_columns->len > 0)
5521  {
5522  int i;
5523  for (i = 0; i < text_columns->len; i++)
5524  {
5525  if (vector_find_filter (filter_columns,
5526  g_array_index (text_columns, gchar*, i))
5527  == 0)
5528  {
5529  g_free (columns);
5530  g_free (trash_columns);
5531  g_free (opts_table);
5532  return 7;
5533  }
5534  }
5535  }
5536  if (group_column && vector_find_filter (filter_columns, group_column) == 0)
5537  {
5538  g_free (columns);
5539  g_free (trash_columns);
5540  g_free (opts_table);
5541  return 4;
5542  }
5543  if (subgroup_column
5544  && vector_find_filter (filter_columns, subgroup_column) == 0)
5545  {
5546  g_free (columns);
5547  g_free (trash_columns);
5548  g_free (opts_table);
5549  return 8;
5550  }
5551  select_data_columns = g_array_new (TRUE, TRUE, sizeof (gchar*));
5552  select_text_columns = g_array_new (TRUE, TRUE, sizeof (gchar*));
5553 
5554  clause = filter_clause (type, filter ? filter : get->filter, filter_columns,
5555  select_columns, where_columns, get->trash,
5556  &filter_order, &first, &max, &permissions,
5557  &owner_filter);
5558 
5559  g_free (filter);
5560 
5561  if (resource)
5562  /* Ownership test is done above by find function. */
5563  owned_clause = g_strdup (" 1");
5564  else
5565  owned_clause = acl_where_owned (type, get, owned, owner_filter, resource,
5566  permissions);
5567 
5568  if (strcasecmp (type, "TASK") == 0)
5569  {
5570  if (get->trash)
5571  trash_extra = g_strdup (" AND hidden = 2");
5572  else
5573  trash_extra = g_strdup (" AND hidden = 0");
5574  }
5575  else if (strcasecmp (type, "REPORT") == 0)
5576  {
5577  if (get->trash)
5578  trash_extra = g_strdup (" AND (SELECT hidden FROM tasks"
5579  " WHERE tasks.id = task)"
5580  " = 2");
5581  else
5582  trash_extra = g_strdup (" AND (SELECT hidden FROM tasks"
5583  " WHERE tasks.id = task)"
5584  " = 0");
5585  }
5586  else if (strcasecmp (type, "RESULT") == 0)
5587  {
5588  trash_extra = results_extra_where (get, 0, NULL, autofp, apply_overrides,
5590  filter ? filter : get->filter);
5591  }
5592  else
5593  trash_extra = g_strdup ("");
5594 
5595  g_free (owner_filter);
5596  array_free (permissions);
5597 
5598  select_group_column = NULL;
5599  select_subgroup_column = NULL;
5600 
5601  if (group_column)
5602  {
5603  select_group_column
5604  = g_strdup (columns_select_column (select_columns,
5605  where_columns,
5606  group_column));
5607  if (subgroup_column)
5608  {
5609  select_subgroup_column
5610  = g_strdup (columns_select_column (select_columns,
5611  where_columns,
5612  subgroup_column));
5613  }
5614  }
5615 
5616  if (data_columns && data_columns->len > 0)
5617  {
5618  int column_index;
5619  for (column_index = 0; column_index < data_columns->len; column_index++)
5620  append_column (select_data_columns,
5621  g_array_index (data_columns, gchar*, column_index),
5622  select_columns,
5623  where_columns);
5624  }
5625 
5626  if (text_columns && text_columns->len > 0)
5627  {
5628  int column_index;
5629  for (column_index = 0; column_index < text_columns->len; column_index++)
5630  append_column (select_text_columns,
5631  g_array_index (text_columns, gchar*, column_index),
5632  select_columns,
5633  where_columns);
5634  }
5635 
5636  /* Round time fields to the next day to reduce amount of rows returned
5637  * This returns "pseudo-UTC" dates which are used by the GSA charts because
5638  * the JavaScript Date objects do not support setting the timezone.
5639  */
5640  if (column_is_timestamp (group_column))
5641  if (sql_is_sqlite3 ())
5642  outer_group_by_column
5643  = g_strdup_printf ("CAST (strftime ('%%s',"
5644  " date(%s, 'unixepoch',"
5645  " 'localtime'),"
5646  " 'utc')"
5647  " AS INTEGER)",
5648  "aggregate_group_value");
5649  else
5650  outer_group_by_column
5651  = g_strdup_printf ("EXTRACT (EPOCH FROM"
5652  " date_trunc ('day',"
5653  " TIMESTAMP WITH TIME ZONE 'epoch'"
5654  " + (%s) * INTERVAL '1 second'))"
5655  " :: integer",
5656  "aggregate_group_value");
5657  else
5658  outer_group_by_column = g_strdup ("aggregate_group_value");
5659 
5660  if (column_is_timestamp (subgroup_column))
5661  if (sql_is_sqlite3 ())
5662  outer_subgroup_column
5663  = g_strdup_printf ("CAST (strftime ('%%s',"
5664  " date(%s, 'unixepoch',"
5665  " 'localtime'),"
5666  " 'utc')"
5667  " AS INTEGER)",
5668  "aggregate_subgroup_value");
5669  else
5670  outer_subgroup_column
5671  = g_strdup_printf ("EXTRACT (EPOCH FROM"
5672  " date_trunc ('day',"
5673  " TIMESTAMP WITH TIME ZONE 'epoch'"
5674  " + (%s) * INTERVAL '1 second'))"
5675  " :: integer",
5676  "aggregate_subgroup_value");
5677  else
5678  outer_subgroup_column = g_strdup ("aggregate_subgroup_value");
5679 
5680  if (sort_data)
5681  {
5682  order_clause = g_string_new ("ORDER BY");
5683 
5684  int sort_index;
5685  for (sort_index = 0; sort_index < sort_data->len; sort_index++) {
5686  sort_data_t *sort_data_item;
5687  const gchar *sort_field, *sort_stat;
5688  int sort_order;
5689  gchar *order_column;
5690 
5691  sort_data_item = g_array_index (sort_data, sort_data_t*, sort_index);
5692  sort_field = sort_data_item->field;
5693  sort_stat = sort_data_item->stat;
5694  sort_order = sort_data_item->order;
5695 
5696  if (sort_stat && strcmp (sort_stat, "count") == 0)
5697  order_column = g_strdup ("outer_count");
5698  else if (sort_stat && strcmp (sort_stat, "value") == 0)
5699  order_column = g_strdup ("outer_group_column");
5700  else if (sort_field
5701  && group_column
5702  && strcmp (sort_field, "")
5703  && strcmp (sort_field, group_column)
5704  && (subgroup_column == NULL
5705  || strcmp (sort_field, subgroup_column)))
5706  {
5707  int index;
5708  order_column = NULL;
5709  for (index = 0;
5710  index < data_columns->len && order_column == NULL;
5711  index++)
5712  {
5713  gchar *column = g_array_index (data_columns, gchar*, index);
5714  if (strcmp (column, sort_field) == 0)
5715  {
5716  if (sort_stat == NULL || strcmp (sort_stat, "") == 0
5717  || ( strcmp (sort_stat, "min")
5718  && strcmp (sort_stat, "max")
5719  && strcmp (sort_stat, "mean")
5720  && strcmp (sort_stat, "sum")))
5721  order_column = g_strdup_printf ("max (aggregate_max_%d)",
5722  index);
5723  else if (strcmp (sort_stat, "mean") == 0)
5724  order_column = g_strdup_printf ("sum (aggregate_avg_%d)",
5725  index);
5726  else
5727  order_column = g_strdup_printf ("%s (aggregate_%s_%d)",
5728  sort_stat, sort_stat,
5729  index);
5730  }
5731  }
5732 
5733  for (index = 0;
5734  index < text_columns->len && order_column == NULL;
5735  index++)
5736  {
5737  gchar *column = g_array_index (text_columns, gchar*, index);
5738  if (strcmp (column, sort_field) == 0)
5739  {
5740  order_column = g_strdup_printf ("max (text_column_%d)",
5741  index);
5742  }
5743  }
5744  }
5745  else if (sort_field && subgroup_column
5746  && strcmp (sort_field, subgroup_column) == 0)
5747  order_column = g_strdup ("outer_subgroup_column");
5748  else
5749  order_column = g_strdup ("outer_group_column");
5750 
5751  if (subgroup_column && sort_index == 0)
5752  {
5753  xml_string_append (order_clause,
5754  " outer_group_column %s, %s %s",
5755  sort_order ? "ASC" : "DESC",
5756  order_column,
5757  sort_order ? "ASC" : "DESC");
5758  }
5759  else
5760  {
5761  xml_string_append (order_clause,
5762  "%s %s %s",
5763  sort_index > 0 ? "," : "",
5764  order_column,
5765  sort_order ? "ASC" : "DESC");
5766  }
5767  g_free (order_column);
5768  }
5769 
5770  if (sort_data->len == 0)
5771  g_string_append (order_clause, " outer_group_column ASC");
5772  }
5773  else
5774  order_clause = g_string_new ("");
5775 
5776  aggregate_select = g_string_new ("");
5777  outer_col_select = g_string_new ("");
5778  if (group_column && strcmp (group_column, ""))
5779  {
5780  if (subgroup_column && strcmp (subgroup_column, ""))
5781  {
5782  g_string_append_printf (aggregate_select,
5783  " count(*) AS aggregate_count,"
5784  " %s AS aggregate_group_value,"
5785  " %s AS aggregate_subgroup_value",
5786  select_group_column,
5787  select_subgroup_column);
5788 
5789  aggregate_group_by = g_strdup_printf (" GROUP BY %s, %s",
5790  select_group_column,
5791  select_subgroup_column);
5792  }
5793  else
5794  {
5795  g_string_append_printf (aggregate_select,
5796  " count(*) AS aggregate_count,"
5797  " %s AS aggregate_group_value,"
5798  " CAST (NULL AS TEXT) AS aggregate_subgroup_value",
5799  select_group_column);
5800 
5801  aggregate_group_by = g_strdup_printf (" GROUP BY %s",
5802  select_group_column);
5803  }
5804 
5805 
5806  }
5807  else
5808  {
5809  g_string_append_printf (aggregate_select,
5810  " count(*) AS aggregate_count,"
5811  " CAST (NULL AS TEXT) AS aggregate_group_value,"
5812  " CAST (NULL AS TEXT) AS aggregate_subgroup_value");
5813 
5814  aggregate_group_by = g_strdup ("");
5815  }
5816 
5817  int col_index;
5818  for (col_index = 0; col_index < select_data_columns->len; col_index ++)
5819  {
5820  gchar *select_data_column = g_array_index (select_data_columns, gchar*,
5821  col_index);
5822  // TODO: Test type of column (string, number, timestamp)
5823  g_string_append_printf (aggregate_select,
5824  ","
5825  " min(CAST (%s AS real)) AS aggregate_min_%d,"
5826  " max(CAST (%s AS real)) AS aggregate_max_%d,"
5827  " avg(CAST (%s AS real)) * count(*)"
5828  " AS aggregate_avg_%d,"
5829  " sum(CAST (%s AS real))"
5830  " AS aggregate_sum_%d",
5831  select_data_column,
5832  col_index,
5833  select_data_column,
5834  col_index,
5835  select_data_column,
5836  col_index,
5837  select_data_column,
5838  col_index);
5839  g_string_append_printf (outer_col_select,
5840  ", min(aggregate_min_%d),"
5841  " max (aggregate_max_%d),"
5842  " sum (aggregate_avg_%d) / sum(aggregate_count),"
5843  " sum (aggregate_sum_%d)",
5844  col_index, col_index, col_index, col_index);
5845  }
5846  for (col_index = 0; col_index < select_text_columns->len; col_index ++)
5847  {
5848  gchar *select_text_column = g_array_index (select_text_columns, gchar*,
5849  col_index);
5850  g_string_append_printf (aggregate_select,
5851  ", max (%s) as text_column_%d",
5852  select_text_column,
5853  col_index);
5854  g_string_append_printf (outer_col_select,
5855  ", max (text_column_%d)",
5856  col_index);
5857  }
5858 
5859  from_table = type_table (type, get->trash);
5860 
5862  "SELECT sum(aggregate_count) AS outer_count,"
5863  " %s AS outer_group_column,"
5864  " %s AS outer_subgroup_column"
5865  " %s"
5866  " FROM (SELECT%s %s"
5867  " FROM %s%s%s"
5868  " WHERE"
5869  " %s%s"
5870  " %s%s%s%s"
5871  " %s)"
5872  " AS agg_sub"
5873  " GROUP BY outer_group_column, outer_subgroup_column %s"
5874  " LIMIT %s OFFSET %d;",
5875  outer_group_by_column,
5876  outer_subgroup_column,
5877  outer_col_select->str,
5878  distinct ? " DISTINCT" : "",
5879  aggregate_select->str,
5880  from_table,
5881  opts_table ? opts_table : "",
5882  extra_tables ? extra_tables : "",
5883  owned_clause,
5884  trash_extra,
5885  clause ? " AND (" : "",
5886  clause ? clause : "",
5887  clause ? ")" : "",
5888  extra_where ? extra_where : "",
5889  aggregate_group_by,
5890  order_clause->str,
5891  sql_select_limit (max_groups),
5892  first_group);
5893 
5894  g_free (columns);
5895  g_free (trash_columns);
5896  g_free (opts_table);
5897  g_free (owned_clause);
5898  g_free (trash_extra);
5899  g_free (filter_order);
5900  g_string_free (order_clause, TRUE);
5901  g_free (clause);
5902  g_free (aggregate_group_by);
5903  g_string_free (aggregate_select, TRUE);
5904  g_string_free (outer_col_select, TRUE);
5905  g_free (outer_group_by_column);
5906  g_free (outer_subgroup_column);
5907  g_free (select_group_column);
5908  g_free (select_subgroup_column);
5909  return 0;
5910 }
int sql_is_sqlite3()
Get whether backend is SQLite3.
Definition: sql_pg.c:92
int trash
Boolean. Whether to return from trashcan.
Definition: manage.h:318
int order
The sort order.
Definition: manage.h:4102
#define MIN_QOD_DEFAULT
Default min quality of detection percentage for filters.
Definition: manage.h:1110
gchar * stat
The statistic to sort by.
Definition: manage.h:4101
int column_is_timestamp(const char *)
char * type_columns(const char *, int)
A generic SQL iterator.
Definition: iterator.h:52
char * filt_id
Filter ID. Overrides "filter".
Definition: manage.h:313
gchar * type_table(const char *, int)
gchar * filter_term_value(const char *, const char *)
gchar * field
The field to sort by.
Definition: manage.h:4100
char * type_trash_columns(const char *, int)
Iterator column.
Definition: manage_sql.c:1512
int setting_dynamic_severity_int()
gchar * filter_term(const char *)
column_t * type_select_columns(const char *type, int)
char * id
ID of single item to get.
Definition: manage.h:317
char * filter_replacement
Filter term to replace the one in filt_id.
Definition: manage.h:316
const char ** type_filter_columns(const char *, int)
int type_owned(const char *type)
Check whether a resource type has an owner.
Definition: manage_sql.c:4376
gchar * acl_where_owned(const char *type, const get_data_t *get, int owned, const gchar *owner_filter, resource_t resource, array_t *permissions)
Generate the ownership part of an SQL WHERE clause.
Definition: manage_acl.c:1352
gchar * type_opts_table(const char *, int, int, int)
int manage_cert_loaded()
Check whether CERT is available.
Definition: manage_pg.c:2643
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
const char * sql_select_limit(int)
Setup a LIMIT argument.
Definition: sql_pg.c:127
int manage_scap_loaded()
Check whether SCAP is available.
Definition: manage_pg.c:2659
column_t * type_where_columns(const char *type, int)
char * filter
Filter term.
Definition: manage.h:314
long long int resource_t
A resource, like a task or target.
Definition: iterator.h:42
Here is the call graph for this function:

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

Definition at line 8756 of file manage_sql.c.

References init_iterator().

8758 {
8760  "SELECT name, data FROM alert_%s_data%s"
8761  " WHERE alert = %llu;",
8762  table,
8763  trash ? "_trash" : "",
8764  alert);
8765 }
A generic SQL iterator.
Definition: iterator.h:52
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
Here is the call graph for this function:

◆ 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, failed to find filter (filt_id), -1 error.

Definition at line 8564 of file manage_sql.c.

References ALERT_ITERATOR_COLUMNS, ALERT_ITERATOR_FILTER_COLUMNS, and ALERT_ITERATOR_TRASH_COLUMNS.

8565 {
8566  static const char *filter_columns[] = ALERT_ITERATOR_FILTER_COLUMNS;
8567  static column_t columns[] = ALERT_ITERATOR_COLUMNS;
8568  static column_t trash_columns[] = ALERT_ITERATOR_TRASH_COLUMNS;
8569 
8570  return init_get_iterator (iterator,
8571  "alert",
8572  get,
8573  columns,
8574  trash_columns,
8575  filter_columns,
8576  0,
8577  NULL,
8578  NULL,
8579  TRUE);
8580 }
A generic SQL iterator.
Definition: iterator.h:52
Iterator column.
Definition: manage_sql.c:1512
#define ALERT_ITERATOR_FILTER_COLUMNS
Filter columns for alert iterator.
Definition: manage_sql.c:8449
#define ALERT_ITERATOR_TRASH_COLUMNS
Alert iterator columns for trash case.
Definition: manage_sql.c:8470
#define ALERT_ITERATOR_COLUMNS
Alert iterator columns.
Definition: manage_sql.c:8456

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

Definition at line 13591 of file manage_sql.c.

References acl_where_owned(), and init_iterator().

13593 {
13594  gchar *available;
13595  get_data_t get;
13596  array_t *permissions;
13597 
13598  assert (alert);
13599 
13600  get.trash = 0;
13601  permissions = make_array ();
13602  array_add (permissions, g_strdup ("get_tasks"));
13603  available = acl_where_owned ("task", &get, 1, "any", 0, permissions);
13604  array_free (permissions);
13605 
13607  "SELECT tasks.name, tasks.uuid, %s FROM tasks, task_alerts"
13608  " WHERE tasks.id = task_alerts.task"
13609  " AND task_alerts.alert = %llu"
13610  " AND hidden = 0"
13611  " ORDER BY tasks.name %s;",
13612  available,
13613  alert,
13614  ascending ? "ASC" : "DESC");
13615 
13616  g_free (available);
13617 }
A generic SQL iterator.
Definition: iterator.h:52
Command data for a get command.
Definition: manage.h:310
gchar * acl_where_owned(const char *type, const get_data_t *get, int owned, const gchar *owner_filter, resource_t resource, array_t *permissions)
Generate the ownership part of an SQL WHERE clause.
Definition: manage_acl.c:1352
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
Here is the call graph for this function:

◆ init_manage()

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

Initialize the manage library.

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

Ensure all tasks are in a clean initial state.

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

Parameters
[in]log_configLog configuration.
[in]nvt_cache_modeTrue when running in NVT caching mode.
[in]databaseLocation of database.
[in]max_ips_per_targetMax number of IPs per target.
[in]max_email_attachment_sizeMax size of email attachments.
[in]max_email_include_sizeMax size of email inclusions.
[in]max_email_message_sizeMax size of email user message text.
[in]update_progressFunction to update progress, or NULL. *
[in]fork_connectionFunction to fork a connection that will accept OMP requests. Used to start tasks with OMP 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.

Definition at line 17065 of file manage_sql.c.

17071 {
17072  return init_manage_internal (log_config,
17073  nvt_cache_mode,
17074  database,
17075  max_ips_per_target,
17076  max_email_attachment_size,
17077  max_email_include_size,
17078  max_email_message_size,
17079  update_progress,
17080  1, /* Stop active tasks. */
17081  fork_connection,
17082  skip_db_check,
17083  1); /* Check encryption key if checking db. */
17084 }
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310

◆ init_manage_helper()

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

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 (–rebuild/update).

Parameters
[in]log_configLog configuration.
[in]databaseLocation of database.
[in]max_ips_per_targetMax number of IPs per target.
[in]update_progressFunction to update progress, or NULL. *
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.

Definition at line 17102 of file manage_sql.c.

17104 {
17105  return init_manage_internal (log_config,
17106  0, /* Run daemon in NVT cache mode. */
17107  database,
17108  max_ips_per_target,
17109  0, /* Default max_email_attachment_size. */
17110  0, /* Default max_email_include_size. */
17111  0, /* Default max_email_message_size */
17112  update_progress,
17113  0, /* Stop active tasks. */
17114  NULL,
17115  0, /* Skip DB check. */
17116  0); /* Dummy. */
17117 }
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310

◆ init_manage_process()

void init_manage_process ( int  update_nvt_cache,
const gchar *  database 
)

Initialize the manage library for a process.

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

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

Definition at line 14303 of file manage_sql.c.

Referenced by reinit_manage_process().

14304 {
14305  if (sql_is_open ())
14306  return;
14307 
14308  /* Open the database. */
14309  if (sql_open (database))
14310  {
14311  g_warning ("%s: sql_open failed\n", __FUNCTION__);
14312  abort ();
14313  }
14314 
14315  /* Attach the SCAP and CERT databases. */
14317 
14318  if (update_nvt_cache)
14319  {
14320  sql ("CREATE TEMPORARY TABLE old_nvts"
14321  " (oid TEXT, modification_time INTEGER);");
14322  sql ("INSERT INTO old_nvts (oid, modification_time)"
14323  " SELECT oid, modification_time FROM nvts;");
14324  }
14325 
14326  /* Define functions for SQL. */
14327 
14328  /* Lock to avoid an error return from Postgres when multiple processes
14329  * create a function at the same time. */
14332  {
14333  sql_rollback ();
14334  g_warning ("%s: failed to create functions", __FUNCTION__);
14335  abort ();
14336  }
14337  sql_commit ();
14338 }
int manage_create_sql_functions()
Create functions.
Definition: manage_pg.c:113
int sql_is_open()
Check whether the database is open.
Definition: sql_pg.c:201
void sql_begin_exclusive()
Begin an exclusive transaction.
Definition: sql_pg.c:598
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
void manage_attach_databases()
Attach external databases.
Definition: manage_pg.c:2624
int sql_open(const char *)
Open the database.
Definition: sql_pg.c:250
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
Here is the caller graph for this function:

◆ init_task_alert_iterator()

void init_task_alert_iterator ( iterator_t iterator,
task_t  task,
event_t  event 
)

Initialise a task alert iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.
[in]eventEvent.

Definition at line 8837 of file manage_sql.c.

8838 {
8839  gchar *owned_clause;
8840  get_data_t get;
8841  array_t *permissions;
8842 
8843  get.trash = 0;
8844  permissions = make_array ();
8845  array_add (permissions, g_strdup ("get_alerts"));
8846  owned_clause = acl_where_owned ("alert", &get, 0, "any", 0, permissions);
8847  array_free (permissions);
8848 
8849  if (task && event)
8851  "SELECT alerts.id, alerts.uuid, alerts.name"
8852  " FROM alerts, task_alerts"
8853  " WHERE task_alerts.task = %llu AND event = %i"
8854  " AND task_alerts.alert = alerts.id"
8855  " AND %s;",
8856  task,
8857  event,
8858  owned_clause);
8859  else if (task)
8861  "SELECT alerts.id, alerts.uuid, alerts.name"
8862  " FROM alerts, task_alerts"
8863  " WHERE task_alerts.task = %llu"
8864  " AND task_alerts.alert = alerts.id"
8865  " AND %s;",
8866  task,
8867  owned_clause);
8868  else if (event)
8870  "SELECT alerts.id, alerts.uuid, alerts.name"
8871  " FROM alerts"
8872  " WHERE event = %i"
8873  " AND %s;",
8874  event,
8875  owned_clause);
8876  else
8878  "SELECT alerts.id, alerts.uuid, alerts.name"
8879  " FROM alerts"
8880  " WHERE %s;",
8881  owned_clause);
8882 
8883  g_free (owned_clause);
8884 }
int trash
Boolean. Whether to return from trashcan.
Definition: manage.h:318
A generic SQL iterator.
Definition: iterator.h:52
Command data for a get command.
Definition: manage.h:310
gchar * acl_where_owned(const char *type, const get_data_t *get, int owned, const gchar *owner_filter, resource_t resource, array_t *permissions)
Generate the ownership part of an SQL WHERE clause.
Definition: manage_acl.c:1352
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577

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

Definition at line 6822 of file manage_sql.c.

References init_iterator(), and LOCATION_TABLE.

6823 {
6825  "SELECT DISTINCT 1, resource, subject,"
6826  " (SELECT name FROM groups"
6827  " WHERE groups.id = permissions.subject),"
6828  " (SELECT uuid FROM groups"
6829  " WHERE groups.id = permissions.subject)"
6830  " FROM permissions"
6831  /* Any permission implies 'get_tasks'. */
6832  " WHERE resource_type = 'task'"
6833  " AND resource = %llu"
6834  " AND resource_location = " G_STRINGIFY (LOCATION_TABLE)
6835  " AND subject_type = 'group'"
6836  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE) ";",
6837  task);
6838 }
A generic SQL iterator.
Definition: iterator.h:52
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
Here is the call graph for this function:

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

Definition at line 14024 of file manage_sql.c.

References filter_term(), filter_term_value(), MIN_QOD_DEFAULT, TASK_ITERATOR_COLUMNS, TASK_ITERATOR_COLUMNS_MIN, TASK_ITERATOR_FILTER_COLUMNS, TASK_ITERATOR_WHERE_COLUMNS, and TASK_ITERATOR_WHERE_COLUMNS_MIN.

Referenced by stop_active_tasks().

14025 {
14026  static const char *filter_columns[] = TASK_ITERATOR_FILTER_COLUMNS;
14027  static column_t columns[] = TASK_ITERATOR_COLUMNS;
14028  static column_t where_columns[] = TASK_ITERATOR_WHERE_COLUMNS;
14029  static column_t columns_min[] = TASK_ITERATOR_COLUMNS_MIN;
14030  static column_t where_columns_min[] = TASK_ITERATOR_WHERE_COLUMNS_MIN;
14031  char *filter;
14032  gchar *value;
14033  int overrides, min_qod;
14034  gchar *extra_tables;
14035  int ret;
14036 
14037  if (get->filt_id && strcmp (get->filt_id, "0"))
14038  {
14039  filter = filter_term (get->filt_id);
14040  if (filter == NULL)
14041  return 2;
14042  }
14043  else
14044  filter = NULL;
14045  value = filter_term_value (filter ? filter : get->filter, "apply_overrides");
14046  overrides = value && strcmp (value, "0");
14047  g_free (value);
14048 
14049  value = filter_term_value (filter ? filter : get->filter, "min_qod");
14050  if (value == NULL || sscanf (value, "%d", &min_qod) != 1)
14051  min_qod = MIN_QOD_DEFAULT;
14052  g_free (value);
14053  free (filter);
14054 
14055  extra_tables = task_iterator_opts_table (overrides, min_qod, 0);
14056 
14057  ret = init_get_iterator2 (iterator,
14058  "task",
14059  get,
14060  /* SELECT columns. */
14061  get->minimal ? columns_min : columns,
14062  get->minimal ? columns_min : columns,
14063  /* Filterable columns not in SELECT columns. */
14064  get->minimal ? where_columns_min : where_columns,
14065  get->minimal ? where_columns_min : where_columns,
14066  filter_columns,
14067  0,
14068  extra_tables,
14069  get->trash
14070  ? " AND hidden = 2"
14071  : " AND hidden = 0",
14072  current_credentials.uuid ? TRUE : FALSE,
14073  FALSE,
14074  NULL);
14075 
14076  g_free (extra_tables);
14077  return ret;
14078 }
int trash
Boolean. Whether to return from trashcan.
Definition: manage.h:318
#define MIN_QOD_DEFAULT
Default min quality of detection percentage for filters.
Definition: manage.h:1110
#define TASK_ITERATOR_COLUMNS
Task iterator columns.
Definition: manage_sql.c:13934
A generic SQL iterator.
Definition: iterator.h:52
char * filt_id
Filter ID. Overrides "filter".
Definition: manage.h:313
gchar * filter_term_value(const char *, const char *)
#define TASK_ITERATOR_FILTER_COLUMNS
Filter columns for task iterator.
Definition: manage_sql.c:13703
#define TASK_ITERATOR_COLUMNS_MIN
Task iterator minimal columns.
Definition: manage_sql.c:13944
Iterator column.
Definition: manage_sql.c:1512
gchar * filter_term(const char *)
#define TASK_ITERATOR_WHERE_COLUMNS
Task iterator WHERE columns.
Definition: manage_sql.c:13925
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
#define TASK_ITERATOR_WHERE_COLUMNS_MIN
Task iterator minimal WHERE columns.
Definition: manage_sql.c:13953
int minimal
Whether to respond with minimal information.
Definition: manage.h:323
char * filter
Filter term.
Definition: manage.h:314
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 6851 of file manage_sql.c.

References init_iterator(), and LOCATION_TABLE.

6852 {
6854  "SELECT DISTINCT 1, resource, subject,"
6855  " (SELECT name FROM roles"
6856  " WHERE roles.id = permissions.subject),"
6857  " (SELECT uuid FROM roles"
6858  " WHERE roles.id = permissions.subject)"
6859  " FROM permissions"
6860  /* Any permission implies 'get'. */
6861  " WHERE resource_type = 'task'"
6862  " AND resource = %llu"
6863  " AND resource_location = " G_STRINGIFY (LOCATION_TABLE)
6864  " AND subject_type = 'role'",
6865  task);
6866 }
A generic SQL iterator.
Definition: iterator.h:52
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
Here is the call graph for this function:

◆ init_task_user_iterator()

void init_task_user_iterator ( iterator_t iterator,
task_t  task 
)

Initialise a task user iterator.

Parameters
[in]iteratorIterator.
[in]taskTask.

Definition at line 6797 of file manage_sql.c.

References init_iterator(), and LOCATION_TABLE.

Referenced by task_observers().

6798 {
6800  "SELECT DISTINCT 1, resource, subject,"
6801  " (SELECT name FROM users"
6802  " WHERE users.id = permissions.subject)"
6803  " FROM permissions"
6804  /* Any permission implies 'get_tasks'. */
6805  " WHERE resource_type = 'task'"
6806  " AND resource = %llu"
6807  " AND resource_location = " G_STRINGIFY (LOCATION_TABLE)
6808  " AND subject_type = 'user'"
6809  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE) ";",
6810  task);
6811 }
A generic SQL iterator.
Definition: iterator.h:52
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iso_time()

char* iso_time ( time_t *  epoch_time)

Create an ISO time from seconds since epoch.

Parameters
[in]epoch_timeTime in seconds from epoch.
Returns
Pointer to ISO time in static memory, or NULL on error.

Definition at line 1138 of file manage_sql.c.

Referenced by buffer_aggregate_xml(), certificate_iso_time(), iso_time_tz(), and sql_iso_time().

1139 {
1140  return iso_time_internal (epoch_time, NULL);
1141 }
Here is the caller graph for this function:

◆ iso_time_tz()

char* iso_time_tz ( time_t *  epoch_time,
const char *  timezone,
const char **  abbrev 
)

Create an ISO time from seconds since epoch, given a timezone.

Parameters
[in]epoch_timeTime in seconds from epoch.
[in]timezoneTimezone.
[out]abbrevTimezone abbreviation.
Returns
Pointer to ISO time in static memory, or NULL on error.

Definition at line 1153 of file manage_sql.c.

References iso_time().

1154 {
1155  gchar *tz;
1156  char *ret;
1157 
1158  if (timezone == NULL)
1159  return iso_time (epoch_time);
1160 
1161  /* Store current TZ. */
1162  tz = getenv ("TZ") ? g_strdup (getenv ("TZ")) : NULL;
1163 
1164  if (setenv ("TZ", timezone, 1) == -1)
1165  {
1166  g_warning ("%s: Failed to switch to timezone", __FUNCTION__);
1167  if (tz != NULL)
1168  setenv ("TZ", tz, 1);
1169  g_free (tz);
1170  return iso_time (epoch_time);
1171  }
1172 
1173  tzset ();
1174  ret = iso_time_internal (epoch_time, abbrev);
1175 
1176  /* Revert to stored TZ. */
1177  if (tz)
1178  {
1179  if (setenv ("TZ", tz, 1) == -1)
1180  {
1181  g_warning ("%s: Failed to switch to original TZ", __FUNCTION__);
1182  g_free (tz);
1183  return ret;
1184  }
1185  }
1186  else
1187  unsetenv ("TZ");
1188 
1189  g_free (tz);
1190  return ret;
1191 }
char * iso_time(time_t *epoch_time)
Create an ISO time from seconds since epoch.
Definition: manage_sql.c:1138
Here is the call graph for this function:

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

Definition at line 1627 of file manage_sql.c.

References KEYWORD_RELATION_APPROX, KEYWORD_RELATION_COLUMN_ABOVE, KEYWORD_RELATION_COLUMN_APPROX, KEYWORD_RELATION_COLUMN_BELOW, KEYWORD_RELATION_COLUMN_EQUAL, and KEYWORD_RELATION_COLUMN_REGEXP.

1628 {
1629  switch (relation)
1630  {
1631  case KEYWORD_RELATION_APPROX: return "~";
1632  case KEYWORD_RELATION_COLUMN_ABOVE: return ">";
1633  case KEYWORD_RELATION_COLUMN_APPROX: return "~";
1634  case KEYWORD_RELATION_COLUMN_EQUAL: return "=";
1635  case KEYWORD_RELATION_COLUMN_BELOW: return "<";
1636  case KEYWORD_RELATION_COLUMN_REGEXP: return ":";
1637  default: return "";
1638  }
1639 }

◆ make_config_discovery()

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

◆ make_config_discovery_service_detection()

void make_config_discovery_service_detection ( char *const  selector_name)

Make Discovery Scan Config.

Caller must lock the db.

Parameters
[in]selector_nameName of NVT selector to use.

Definition at line 53 of file manage_config_discovery.c.

References NVT_SELECTOR.

Referenced by make_config_discovery().

54 {
55  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11929", "Service detection");
56  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900534", "Service detection");
57  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902019", "Service detection");
58  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800991", "Service detection");
59  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900539", "Service detection");
60  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800995", "Service detection");
61  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800997", "Service detection");
62  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800999", "Service detection");
63  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100106", "Service detection");
64  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900381", "Service detection");
65  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901084", "Service detection");
66  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900384", "Service detection");
67  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902023", "Service detection");
68  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900620", "Service detection");
69  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901089", "Service detection");
70  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900387", "Service detection");
71  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902028", "Service detection");
72  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902106", "Service detection");
73  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900547", "Service detection");
74  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900705", "Service detection");
75  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900628", "Service detection");
76  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901087", "Service detection");
77  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900624", "Service detection");
78  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900543", "Service detection");
79  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900629", "Service detection");
80  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801869", "Service detection");
81  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11865", "Service detection");
82  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901174", "Service detection");
83  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.12647", "Service detection");
84  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900550", "Service detection");
85  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901178", "Service detection");
86  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900632", "Service detection");
87  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80079", "Service detection");
88  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900556", "Service detection");
89  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900714", "Service detection");
90  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801874", "Service detection");
91  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900710", "Service detection");
92  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100201", "Service detection");
93  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100206", "Service detection");
94  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100208", "Service detection");
95  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900394", "Service detection");
96  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900712", "Service detection");
97  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11945", "Service detection");
98  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.20377", "Service detection");
99  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900562", "Service detection");
100  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103652", "Service detection");
101  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901188", "Service detection");
102  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902046", "Service detection");
103  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900641", "Service detection");
104  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103579", "Service detection");
105  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902044", "Service detection");
106  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900647", "Service detection");
107  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17583", "Service detection");
108  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100215", "Service detection");
109  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100217", "Service detection");
110  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100219", "Service detection");
111  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11963", "Service detection");
112  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80092", "Service detection");
113  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900493", "Service detection");
114  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900571", "Service detection");
115  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80095", "Service detection");
116  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902134", "Service detection");
117  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902058", "Service detection");
118  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902137", "Service detection");
119  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900578", "Service detection");
120  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900576", "Service detection");
121  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900659", "Service detection");
122  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100221", "Service detection");
123  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100301", "Service detection");
124  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100302", "Service detection");
125  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902053", "Service detection");
126  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100226", "Service detection");
127  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100224", "Service detection");
128  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.18532", "Service detection");
129  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.18533", "Service detection");
130  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.18534", "Service detection");
131  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801972", "Service detection");
132  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100300", "Service detection");
133  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902061", "Service detection");
134  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902220", "Service detection");
135  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900583", "Service detection");
136  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900744", "Service detection");
137  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900822", "Service detection");
138  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900746", "Service detection");
139  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900748", "Service detection");
140  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900904", "Service detection");
141  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902309", "Service detection");
142  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.101013", "Service detection");
143  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100154", "Service detection");
144  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100313", "Service detection");
145  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801988", "Service detection");
146  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.101019", "Service detection");
147  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.101018", "Service detection");
148  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900827", "Service detection");
149  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100311", "Service detection");
150  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100233", "Service detection");
151  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11986", "Service detection");
152  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11987", "Service detection");
153  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902311", "Service detection");
154  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900596", "Service detection");
155  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902078", "Service detection");
156  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900598", "Service detection");
157  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100082", "Service detection");
158  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100160", "Service detection");
159  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100240", "Service detection");
160  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.101021", "Service detection");
161  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900753", "Service detection");
162  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100243", "Service detection");
163  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900917", "Service detection");
164  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.101025", "Service detection");
165  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.18393", "Service detection");
166  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900839", "Service detection");
167  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100324", "Service detection");
168  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100322", "Service detection");
169  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100407", "Service detection");
170  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100328", "Service detection");
171  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100329", "Service detection");
172  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902081", "Service detection");
173  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902083", "Service detection");
174  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902084", "Service detection");
175  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900681", "Service detection");
176  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902089", "Service detection");
177  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900686", "Service detection");
178  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900923", "Service detection");
179  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100174", "Service detection");
180  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900926", "Service detection");
181  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100254", "Service detection");
182  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100331", "Service detection");
183  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100335", "Service detection");
184  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100259", "Service detection");
185  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100417", "Service detection");
186  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100419", "Service detection");
187  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900930", "Service detection");
188  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900853", "Service detection");
189  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900932", "Service detection");
190  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900855", "Service detection");
191  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100180", "Service detection");
192  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100184", "Service detection");
193  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100261", "Service detection");
194  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100187", "Service detection");
195  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100266", "Service detection");
196  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100423", "Service detection");
197  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100268", "Service detection");
198  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100425", "Service detection");
199  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100503", "Service detection");
200  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.20834", "Service detection");
201  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902187", "Service detection");
202  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100192", "Service detection");
203  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902503", "Service detection");
204  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100194", "Service detection");
205  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900867", "Service detection");
206  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100196", "Service detection");
207  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900945", "Service detection");
208  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100432", "Service detection");
209  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100437", "Service detection");
210  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100517", "Service detection");
211  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.19289", "Service detection");
212  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800300", "Service detection");
213  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100518", "Service detection");
214  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801005", "Service detection");
215  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801007", "Service detection");
216  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.19608", "Service detection");
217  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900950", "Service detection");
218  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100280", "Service detection");
219  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902513", "Service detection");
220  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900956", "Service detection");
221  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100285", "Service detection");
222  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100288", "Service detection");
223  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100367", "Service detection");
224  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102005", "Service detection");
225  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102006", "Service detection");
226  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102009", "Service detection");
227  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17975", "Service detection");
228  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102003", "Service detection");
229  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800158", "Service detection");
230  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801017", "Service detection");
231  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800317", "Service detection");
232  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102001", "Service detection");
233  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.66286", "Service detection");
234  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902520", "Service detection");
235  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900961", "Service detection");
236  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902447", "Service detection");
237  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900966", "Service detection");
238  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100294", "Service detection");
239  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10159", "Service detection");
240  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100374", "Service detection");
241  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102013", "Service detection");
242  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100376", "Service detection");
243  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100456", "Service detection");
244  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102011", "Service detection");
245  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102017", "Service detection");
246  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801100", "Service detection");
247  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800165", "Service detection");
248  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801102", "Service detection");
249  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103979", "Service detection");
250  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801106", "Service detection");
251  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100292", "Service detection");
252  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800407", "Service detection");
253  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900971", "Service detection");
254  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902533", "Service detection");
255  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900976", "Service detection");
256  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100382", "Service detection");
257  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100540", "Service detection");
258  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100466", "Service detection");
259  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100464", "Service detection");
260  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100468", "Service detection");
261  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800170", "Service detection");
262  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800098", "Service detection");
263  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801112", "Service detection");
264  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.19559", "Service detection");
265  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800413", "Service detection");
266  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801038", "Service detection");
267  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801115", "Service detection");
268  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801117", "Service detection");
269  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801119", "Service detection");
270  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10330", "Service detection");
271  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10175", "Service detection");
272  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902545", "Service detection");
273  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902701", "Service detection");
274  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902547", "Service detection");
275  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100392", "Service detection");
276  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900983", "Service detection");
277  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100460", "Service detection");
278  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100552", "Service detection");
279  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11032", "Service detection");
280  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100395", "Service detection");
281  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100477", "Service detection");
282  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800180", "Service detection");
283  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100479", "Service detection");
284  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801040", "Service detection");
285  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100558", "Service detection");
286  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801121", "Service detection");
287  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103997", "Service detection");
288  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801124", "Service detection");
289  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800268", "Service detection");
290  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801126", "Service detection");
291  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801209", "Service detection");
292  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11120", "Service detection");
293  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11121", "Service detection");
294  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10342", "Service detection");
295  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11128", "Service detection");
296  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902717", "Service detection");
297  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.102048", "Service detection");
298  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100801", "Service detection");
299  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100489", "Service detection");
300  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800272", "Service detection");
301  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801053", "Service detection");
302  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800274", "Service detection");
303  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800276", "Service detection");
304  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801213", "Service detection");
305  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800355", "Service detection");
306  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800279", "Service detection");
307  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801138", "Service detection");
308  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801217", "Service detection");
309  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800432", "Service detection");
310  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902480", "Service detection");
311  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902561", "Service detection");
312  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11134", "Service detection");
313  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100486", "Service detection");
314  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100571", "Service detection");
315  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100573", "Service detection");
316  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100651", "Service detection");
317  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800280", "Service detection");
318  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100819", "Service detection");
319  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801069", "Service detection");
320  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800523", "Service detection");
321  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800603", "Service detection");
322  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800525", "Service detection");
323  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801067", "Service detection");
324  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.14664", "Service detection");
325  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800608", "Service detection");
326  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801223", "Service detection");
327  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800446", "Service detection");
328  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100742", "Service detection");
329  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800291", "Service detection");
330  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801072", "Service detection");
331  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801074", "Service detection");
332  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100669", "Service detection");
333  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100748", "Service detection");
334  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801234", "Service detection");
335  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800297", "Service detection");
336  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100827", "Service detection");
337  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.14674", "Service detection");
338  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800617", "Service detection");
339  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800610", "Service detection");
340  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801152", "Service detection");
341  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801232", "Service detection");
342  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11153", "Service detection");
343  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11154", "Service detection");
344  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10379", "Service detection");
345  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801081", "Service detection");
346  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100755", "Service detection");
347  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100911", "Service detection");
348  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100675", "Service detection");
349  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801087", "Service detection");
350  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100838", "Service detection");
351  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801244", "Service detection");
352  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800467", "Service detection");
353  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801403", "Service detection");
354  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800547", "Service detection");
355  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800627", "Service detection");
356  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802109", "Service detection");
357  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800707", "Service detection");
358  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800464", "Service detection");
359  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800709", "Service detection");
360  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100836", "Service detection");
361  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801247", "Service detection");
362  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10462", "Service detection");
363  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800622", "Service detection");
364  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10622", "Service detection");
365  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100681", "Service detection");
366  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103021", "Service detection");
367  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801091", "Service detection");
368  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800391", "Service detection");
369  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800470", "Service detection");
370  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801251", "Service detection");
371  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800394", "Service detection");
372  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800630", "Service detection");
373  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800553", "Service detection");
374  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800631", "Service detection");
375  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800477", "Service detection");
376  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800712", "Service detection");
377  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.14772", "Service detection");
378  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800559", "Service detection");
379  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800716", "Service detection");
380  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800633", "Service detection");
381  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.14773", "Service detection");
382  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103106", "Service detection");
383  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100846", "Service detection");
384  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801415", "Service detection");
385  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100770", "Service detection");
386  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103111", "Service detection");
387  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100850", "Service detection");
388  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100854", "Service detection");
389  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103118", "Service detection");
390  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801340", "Service detection");
391  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100937", "Service detection");
392  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100859", "Service detection");
393  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800643", "Service detection");
394  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801421", "Service detection");
395  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800568", "Service detection");
396  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800802", "Service detection");
397  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800564", "Service detection");
398  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17200", "Service detection");
399  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800728", "Service detection");
400  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800807", "Service detection");
401  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.14788", "Service detection");
402  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100845", "Service detection");
403  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.9000001", "Service detection");
404  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100780", "Service detection");
405  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801242", "Service detection");
406  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103123", "Service detection");
407  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103124", "Service detection");
408  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103048", "Service detection");
409  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103125", "Service detection");
410  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100867", "Service detection");
411  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800571", "Service detection");
412  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103206", "Service detection");
413  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800573", "Service detection");
414  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100783", "Service detection");
415  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800575", "Service detection");
416  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103204", "Service detection");
417  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801278", "Service detection");
418  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801350", "Service detection");
419  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801438", "Service detection");
420  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800816", "Service detection");
421  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800818", "Service detection");
422  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800579", "Service detection");
423  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800496", "Service detection");
424  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103207", "Service detection");
425  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800735", "Service detection");
426  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100870", "Service detection");
427  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900200", "Service detection");
428  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100795", "Service detection");
429  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103059", "Service detection");
430  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.100950", "Service detection");
431  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801363", "Service detection");
432  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801443", "Service detection");
433  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802145", "Service detection");
434  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800900", "Service detection");
435  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800901", "Service detection");
436  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800821", "Service detection");
437  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800825", "Service detection");
438  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800905", "Service detection");
439  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.15588", "Service detection");
440  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103140", "Service detection");
441  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10666", "Service detection");
442  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103141", "Service detection");
443  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103143", "Service detection");
444  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103223", "Service detection");
445  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103147", "Service detection");
446  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800590", "Service detection");
447  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800592", "Service detection");
448  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900218", "Service detection");
449  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800594", "Service detection");
450  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802230", "Service detection");
451  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800832", "Service detection");
452  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800677", "Service detection");
453  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800911", "Service detection");
454  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800913", "Service detection");
455  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800918", "Service detection");
456  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802158", "Service detection");
457  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103070", "Service detection");
458  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800598", "Service detection");
459  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103073", "Service detection");
460  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103230", "Service detection");
461  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801612", "Service detection");
462  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103156", "Service detection");
463  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901003", "Service detection");
464  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103158", "Service detection");
465  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801381", "Service detection");
466  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800680", "Service detection");
467  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800681", "Service detection");
468  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901008", "Service detection");
469  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800683", "Service detection");
470  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802244", "Service detection");
471  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103317", "Service detection");
472  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800765", "Service detection");
473  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800688", "Service detection");
474  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800923", "Service detection");
475  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800768", "Service detection");
476  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.17244", "Service detection");
477  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800925", "Service detection");
478  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.15765", "Service detection");
479  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.15766", "Service detection");
480  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800928", "Service detection");
481  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10761", "Service detection");
482  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103081", "Service detection");
483  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103086", "Service detection");
484  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901013", "Service detection");
485  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103245", "Service detection");
486  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801390", "Service detection");
487  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901016", "Service detection");
488  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800690", "Service detection");
489  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801392", "Service detection");
490  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800692", "Service detection");
491  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800693", "Service detection");
492  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.802178", "Service detection");
493  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801394", "Service detection");
494  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800933", "Service detection");
495  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800779", "Service detection");
496  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800936", "Service detection");
497  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103326", "Service detection");
498  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800939", "Service detection");
499  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900242", "Service detection");
500  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103098", "Service detection");
501  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103255", "Service detection");
502  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901025", "Service detection");
503  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80003", "Service detection");
504  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80004", "Service detection");
505  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80005", "Service detection");
506  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80006", "Service detection");
507  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901107", "Service detection");
508  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901023", "Service detection");
509  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800941", "Service detection");
510  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800864", "Service detection");
511  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800786", "Service detection");
512  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800949", "Service detection");
513  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103181", "Service detection");
514  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.20301", "Service detection");
515  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900251", "Service detection");
516  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900253", "Service detection");
517  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900256", "Service detection");
518  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900334", "Service detection");
519  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900259", "Service detection");
520  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900338", "Service detection");
521  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800792", "Service detection");
522  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800790", "Service detection");
523  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901118", "Service detection");
524  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800870", "Service detection");
525  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800951", "Service detection");
526  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901036", "Service detection");
527  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801575", "Service detection");
528  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800877", "Service detection");
529  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800878", "Service detection");
530  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800955", "Service detection");
531  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801812", "Service detection");
532  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.18219", "Service detection");
533  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103190", "Service detection");
534  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801737", "Service detection");
535  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901121", "Service detection");
536  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901044", "Service detection");
537  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80100", "Service detection");
538  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103514", "Service detection");
539  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800884", "Service detection");
540  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800964", "Service detection");
541  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800969", "Service detection");
542  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.20160", "Service detection");
543  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.10884", "Service detection");
544  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11822", "Service detection");
545  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900194", "Service detection");
546  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900352", "Service detection");
547  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901056", "Service detection");
548  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11906", "Service detection");
549  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11907", "Service detection");
550  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900357", "Service detection");
551  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800891", "Service detection");
552  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.901135", "Service detection");
553  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800893", "Service detection");
554  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11908", "Service detection");
555  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800895", "Service detection");
556  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800898", "Service detection");
557  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801916", "Service detection");
558  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900360", "Service detection");
559  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.103294", "Service detection");
560  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.11913", "Service detection");
561  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80044", "Service detection");
562  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.80045", "Service detection");
563  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.801681", "Service detection");
564  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.902009", "Service detection");
565  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800980", "Service detection");
566  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800984", "Service detection");
567  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.800988", "Service detection");
568  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900371", "Service detection");
569  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900374", "Service detection");
570  NVT_SELECTOR (selector_name, "1.3.6.1.4.1.25623.1.0.900376", "Service detection");
571 }
#define NVT_SELECTOR(selector, oid, family)
Insert a nvt selector.
Here is the caller graph for this function:

◆ make_config_host_discovery()

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

◆ make_config_system_discovery()

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

◆ make_port_ranges_all_tcp_nmap_5_51_top_100()

void make_port_ranges_all_tcp_nmap_5_51_top_100 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

Definition at line 48 of file manage_ranges_all_tcp_nmap_5_51_top_100.c.

References RANGE.

49 {
50  RANGE (PORT_PROTOCOL_TCP, 1, 65535);
51 
52  RANGE (PORT_PROTOCOL_UDP, 7, 7);
53  RANGE (PORT_PROTOCOL_UDP, 9, 9);
54  RANGE (PORT_PROTOCOL_UDP, 17, 17);
55  RANGE (PORT_PROTOCOL_UDP, 19, 19);
56  RANGE (PORT_PROTOCOL_UDP, 49, 49);
57  RANGE (PORT_PROTOCOL_UDP, 53, 53);
58  RANGE (PORT_PROTOCOL_UDP, 67, 69);
59  RANGE (PORT_PROTOCOL_UDP, 80, 80);
60  RANGE (PORT_PROTOCOL_UDP, 88, 88);
61  RANGE (PORT_PROTOCOL_UDP, 111, 111);
62  RANGE (PORT_PROTOCOL_UDP, 120, 120);
63  RANGE (PORT_PROTOCOL_UDP, 123, 123);
64  RANGE (PORT_PROTOCOL_UDP, 135, 139);
65  RANGE (PORT_PROTOCOL_UDP, 158, 158);
66  RANGE (PORT_PROTOCOL_UDP, 161, 162);
67  RANGE (PORT_PROTOCOL_UDP, 177, 177);
68  RANGE (PORT_PROTOCOL_UDP, 427, 427);
69  RANGE (PORT_PROTOCOL_UDP, 443, 443);
70  RANGE (PORT_PROTOCOL_UDP, 445, 445);
71  RANGE (PORT_PROTOCOL_UDP, 497, 497);
72  RANGE (PORT_PROTOCOL_UDP, 500, 500);
73  RANGE (PORT_PROTOCOL_UDP, 514, 515);
74  RANGE (PORT_PROTOCOL_UDP, 518, 518);
75  RANGE (PORT_PROTOCOL_UDP, 520, 520);
76  RANGE (PORT_PROTOCOL_UDP, 593, 593);
77  RANGE (PORT_PROTOCOL_UDP, 623, 623);
78  RANGE (PORT_PROTOCOL_UDP, 626, 626);
79  RANGE (PORT_PROTOCOL_UDP, 631, 631);
80  RANGE (PORT_PROTOCOL_UDP, 996, 999);
81  RANGE (PORT_PROTOCOL_UDP, 1022, 1023);
82  RANGE (PORT_PROTOCOL_UDP, 1025, 1030);
83  RANGE (PORT_PROTOCOL_UDP, 1433, 1434);
84  RANGE (PORT_PROTOCOL_UDP, 1645, 1646);
85  RANGE (PORT_PROTOCOL_UDP, 1701, 1701);
86  RANGE (PORT_PROTOCOL_UDP, 1718, 1719);
87  RANGE (PORT_PROTOCOL_UDP, 1812, 1813);
88  RANGE (PORT_PROTOCOL_UDP, 1900, 1900);
89  RANGE (PORT_PROTOCOL_UDP, 2000, 2000);
90  RANGE (PORT_PROTOCOL_UDP, 2048, 2049);
91  RANGE (PORT_PROTOCOL_UDP, 2222, 2223);
92  RANGE (PORT_PROTOCOL_UDP, 3283, 3283);
93  RANGE (PORT_PROTOCOL_UDP, 3456, 3456);
94  RANGE (PORT_PROTOCOL_UDP, 3703, 3703);
95  RANGE (PORT_PROTOCOL_UDP, 4444, 4444);
96  RANGE (PORT_PROTOCOL_UDP, 4500, 4500);
97  RANGE (PORT_PROTOCOL_UDP, 5000, 5000);
98  RANGE (PORT_PROTOCOL_UDP, 5060, 5060);
99  RANGE (PORT_PROTOCOL_UDP, 5353, 5353);
100  RANGE (PORT_PROTOCOL_UDP, 5632, 5632);
101  RANGE (PORT_PROTOCOL_UDP, 9200, 9200);
102  RANGE (PORT_PROTOCOL_UDP, 10000, 10000);
103  RANGE (PORT_PROTOCOL_UDP, 17185, 17185);
104  RANGE (PORT_PROTOCOL_UDP, 20031, 20031);
105  RANGE (PORT_PROTOCOL_UDP, 30718, 30718);
106  RANGE (PORT_PROTOCOL_UDP, 31337, 31337);
107  RANGE (PORT_PROTOCOL_UDP, 32768, 32769);
108  RANGE (PORT_PROTOCOL_UDP, 32771, 32771);
109  RANGE (PORT_PROTOCOL_UDP, 32815, 32815);
110  RANGE (PORT_PROTOCOL_UDP, 33281, 33281);
111  RANGE (PORT_PROTOCOL_UDP, 49152, 49154);
112  RANGE (PORT_PROTOCOL_UDP, 49156, 49156);
113  RANGE (PORT_PROTOCOL_UDP, 49181, 49182);
114  RANGE (PORT_PROTOCOL_UDP, 49185, 49186);
115  RANGE (PORT_PROTOCOL_UDP, 49188, 49188);
116  RANGE (PORT_PROTOCOL_UDP, 49190, 49194);
117  RANGE (PORT_PROTOCOL_UDP, 49200, 49201);
118 }
#define RANGE(type, start, end)
Insert a port range.

◆ make_port_ranges_all_tcp_nmap_5_51_top_1000()

void make_port_ranges_all_tcp_nmap_5_51_top_1000 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

Definition at line 48 of file manage_ranges_all_tcp_nmap_5_51_top_1000.c.

References RANGE.

49 {
50  RANGE (PORT_PROTOCOL_TCP, 1, 65535);
51 
52  RANGE (PORT_PROTOCOL_UDP, 2, 3);
53  RANGE (PORT_PROTOCOL_UDP, 7, 7);
54  RANGE (PORT_PROTOCOL_UDP, 9, 9);
55  RANGE (PORT_PROTOCOL_UDP, 13, 13);
56  RANGE (PORT_PROTOCOL_UDP, 17, 17);
57  RANGE (PORT_PROTOCOL_UDP, 19, 23);
58  RANGE (PORT_PROTOCOL_UDP, 37, 38);
59  RANGE (PORT_PROTOCOL_UDP, 42, 42);
60  RANGE (PORT_PROTOCOL_UDP, 49, 49);
61  RANGE (PORT_PROTOCOL_UDP, 53, 53);
62  RANGE (PORT_PROTOCOL_UDP, 67, 69);
63  RANGE (PORT_PROTOCOL_UDP, 80, 80);
64  RANGE (PORT_PROTOCOL_UDP, 88, 88);
65  RANGE (PORT_PROTOCOL_UDP, 111, 113);
66  RANGE (PORT_PROTOCOL_UDP, 120, 120);
67  RANGE (PORT_PROTOCOL_UDP, 123, 123);
68  RANGE (PORT_PROTOCOL_UDP, 135, 139);
69  RANGE (PORT_PROTOCOL_UDP, 158, 158);
70  RANGE (PORT_PROTOCOL_UDP, 161, 162);
71  RANGE (PORT_PROTOCOL_UDP, 177, 177);
72  RANGE (PORT_PROTOCOL_UDP, 192, 192);
73  RANGE (PORT_PROTOCOL_UDP, 199, 199);
74  RANGE (PORT_PROTOCOL_UDP, 207, 207);
75  RANGE (PORT_PROTOCOL_UDP, 217, 217);
76  RANGE (PORT_PROTOCOL_UDP, 363, 363);
77  RANGE (PORT_PROTOCOL_UDP, 389, 389);
78  RANGE (PORT_PROTOCOL_UDP, 402, 402);
79  RANGE (PORT_PROTOCOL_UDP, 407, 407);
80  RANGE (PORT_PROTOCOL_UDP, 427, 427);
81  RANGE (PORT_PROTOCOL_UDP, 434, 434);
82  RANGE (PORT_PROTOCOL_UDP, 443, 443);
83  RANGE (PORT_PROTOCOL_UDP, 445, 445);
84  RANGE (PORT_PROTOCOL_UDP, 464, 464);
85  RANGE (PORT_PROTOCOL_UDP, 497, 497);
86  RANGE (PORT_PROTOCOL_UDP, 500, 500);
87  RANGE (PORT_PROTOCOL_UDP, 502, 502);
88  RANGE (PORT_PROTOCOL_UDP, 512, 515);
89  RANGE (PORT_PROTOCOL_UDP, 517, 518);
90  RANGE (PORT_PROTOCOL_UDP, 520, 520);
91  RANGE (PORT_PROTOCOL_UDP, 539, 539);
92  RANGE (PORT_PROTOCOL_UDP, 559, 559);
93  RANGE (PORT_PROTOCOL_UDP, 593, 593);
94  RANGE (PORT_PROTOCOL_UDP, 623, 623);
95  RANGE (PORT_PROTOCOL_UDP, 626, 626);
96  RANGE (PORT_PROTOCOL_UDP, 631, 631);
97  RANGE (PORT_PROTOCOL_UDP, 639, 639);
98  RANGE (PORT_PROTOCOL_UDP, 643, 643);
99  RANGE (PORT_PROTOCOL_UDP, 657, 657);
100  RANGE (PORT_PROTOCOL_UDP, 664, 664);
101  RANGE (PORT_PROTOCOL_UDP, 682, 689);
102  RANGE (PORT_PROTOCOL_UDP, 764, 764);
103  RANGE (PORT_PROTOCOL_UDP, 767, 767);
104  RANGE (PORT_PROTOCOL_UDP, 772, 776);
105  RANGE (PORT_PROTOCOL_UDP, 780, 782);
106  RANGE (PORT_PROTOCOL_UDP, 786, 786);
107  RANGE (PORT_PROTOCOL_UDP, 789, 789);
108  RANGE (PORT_PROTOCOL_UDP, 800, 800);
109  RANGE (PORT_PROTOCOL_UDP, 814, 814);
110  RANGE (PORT_PROTOCOL_UDP, 826, 826);
111  RANGE (PORT_PROTOCOL_UDP, 829, 829);
112  RANGE (PORT_PROTOCOL_UDP, 838, 838);
113  RANGE (PORT_PROTOCOL_UDP, 902, 903);
114  RANGE (PORT_PROTOCOL_UDP, 944, 944);
115  RANGE (PORT_PROTOCOL_UDP, 959, 959);
116  RANGE (PORT_PROTOCOL_UDP, 965, 965);
117  RANGE (PORT_PROTOCOL_UDP, 983, 983);
118  RANGE (PORT_PROTOCOL_UDP, 989, 990);
119  RANGE (PORT_PROTOCOL_UDP, 996, 1001);
120  RANGE (PORT_PROTOCOL_UDP, 1007, 1008);
121  RANGE (PORT_PROTOCOL_UDP, 1012, 1014);
122  RANGE (PORT_PROTOCOL_UDP, 1019, 1051);
123  RANGE (PORT_PROTOCOL_UDP, 1053, 1060);
124  RANGE (PORT_PROTOCOL_UDP, 1064, 1070);
125  RANGE (PORT_PROTOCOL_UDP, 1072, 1072);
126  RANGE (PORT_PROTOCOL_UDP, 1080, 1081);
127  RANGE (PORT_PROTOCOL_UDP, 1087, 1088);
128  RANGE (PORT_PROTOCOL_UDP, 1090, 1090);
129  RANGE (PORT_PROTOCOL_UDP, 1100, 1101);
130  RANGE (PORT_PROTOCOL_UDP, 1105, 1105);
131  RANGE (PORT_PROTOCOL_UDP, 1124, 1124);
132  RANGE (PORT_PROTOCOL_UDP, 1200, 1200);
133  RANGE (PORT_PROTOCOL_UDP, 1214, 1214);
134  RANGE (PORT_PROTOCOL_UDP, 1234, 1234);
135  RANGE (PORT_PROTOCOL_UDP, 1346, 1346);
136  RANGE (PORT_PROTOCOL_UDP, 1419, 1419);
137  RANGE (PORT_PROTOCOL_UDP, 1433, 1434);
138  RANGE (PORT_PROTOCOL_UDP, 1455, 1455);
139  RANGE (PORT_PROTOCOL_UDP, 1457, 1457);
140  RANGE (PORT_PROTOCOL_UDP, 1484, 1485);
141  RANGE (PORT_PROTOCOL_UDP, 1524, 1524);
142  RANGE (PORT_PROTOCOL_UDP, 1645, 1646);
143  RANGE (PORT_PROTOCOL_UDP, 1701, 1701);
144  RANGE (PORT_PROTOCOL_UDP, 1718, 1719);
145  RANGE (PORT_PROTOCOL_UDP, 1761, 1761);
146  RANGE (PORT_PROTOCOL_UDP, 1782, 1782);
147  RANGE (PORT_PROTOCOL_UDP, 1804, 1804);
148  RANGE (PORT_PROTOCOL_UDP, 1812, 1813);
149  RANGE (PORT_PROTOCOL_UDP, 1885, 1886);
150  RANGE (PORT_PROTOCOL_UDP, 1900, 1901);
151  RANGE (PORT_PROTOCOL_UDP, 1993, 1993);
152  RANGE (PORT_PROTOCOL_UDP, 2000, 2000);
153  RANGE (PORT_PROTOCOL_UDP, 2002, 2002);
154  RANGE (PORT_PROTOCOL_UDP, 2048, 2049);
155  RANGE (PORT_PROTOCOL_UDP, 2051, 2051);
156  RANGE (PORT_PROTOCOL_UDP, 2148, 2148);
157  RANGE (PORT_PROTOCOL_UDP, 2160, 2161);
158  RANGE (PORT_PROTOCOL_UDP, 2222, 2223);
159  RANGE (PORT_PROTOCOL_UDP, 2343, 2343);
160  RANGE (PORT_PROTOCOL_UDP, 2345, 2345);
161  RANGE (PORT_PROTOCOL_UDP, 2362, 2362);
162  RANGE (PORT_PROTOCOL_UDP, 2967, 2967);
163  RANGE (PORT_PROTOCOL_UDP, 3052, 3052);
164  RANGE (PORT_PROTOCOL_UDP, 3130, 3130);
165  RANGE (PORT_PROTOCOL_UDP, 3283, 3283);
166  RANGE (PORT_PROTOCOL_UDP, 3296, 3296);
167  RANGE (PORT_PROTOCOL_UDP, 3343, 3343);
168  RANGE (PORT_PROTOCOL_UDP, 3389, 3389);
169  RANGE (PORT_PROTOCOL_UDP, 3401, 3401);
170  RANGE (PORT_PROTOCOL_UDP, 3456, 3457);
171  RANGE (PORT_PROTOCOL_UDP, 3659, 3659);
172  RANGE (PORT_PROTOCOL_UDP, 3664, 3664);
173  RANGE (PORT_PROTOCOL_UDP, 3702, 3703);
174  RANGE (PORT_PROTOCOL_UDP, 4000, 4000);
175  RANGE (PORT_PROTOCOL_UDP, 4008, 4008);
176  RANGE (PORT_PROTOCOL_UDP, 4045, 4045);
177  RANGE (PORT_PROTOCOL_UDP, 4444, 4444);
178  RANGE (PORT_PROTOCOL_UDP, 4500, 4500);
179  RANGE (PORT_PROTOCOL_UDP, 4666, 4666);
180  RANGE (PORT_PROTOCOL_UDP, 4672, 4672);
181  RANGE (PORT_PROTOCOL_UDP, 5000, 5003);
182  RANGE (PORT_PROTOCOL_UDP, 5010, 5010);
183  RANGE (PORT_PROTOCOL_UDP, 5050, 5050);
184  RANGE (PORT_PROTOCOL_UDP, 5060, 5060);
185  RANGE (PORT_PROTOCOL_UDP, 5093, 5093);
186  RANGE (PORT_PROTOCOL_UDP, 5351, 5351);
187  RANGE (PORT_PROTOCOL_UDP, 5353, 5353);
188  RANGE (PORT_PROTOCOL_UDP, 5355, 5355);
189  RANGE (PORT_PROTOCOL_UDP, 5500, 5500);
190  RANGE (PORT_PROTOCOL_UDP, 5555, 5555);
191  RANGE (PORT_PROTOCOL_UDP, 5632, 5632);
192  RANGE (PORT_PROTOCOL_UDP, 6000, 6002);
193  RANGE (PORT_PROTOCOL_UDP, 6004, 6004);
194  RANGE (PORT_PROTOCOL_UDP, 6050, 6050);
195  RANGE (PORT_PROTOCOL_UDP, 6346, 6347);
196  RANGE (PORT_PROTOCOL_UDP, 6970, 6971);
197  RANGE (PORT_PROTOCOL_UDP, 7000, 7000);
198  RANGE (PORT_PROTOCOL_UDP, 7938, 7938);
199  RANGE (PORT_PROTOCOL_UDP, 8000, 8001);
200  RANGE (PORT_PROTOCOL_UDP, 8010, 8010);
201  RANGE (PORT_PROTOCOL_UDP, 8181, 8181);
202  RANGE (PORT_PROTOCOL_UDP, 8193, 8193);
203  RANGE (PORT_PROTOCOL_UDP, 8900, 8900);
204  RANGE (PORT_PROTOCOL_UDP, 9000, 9001);
205  RANGE (PORT_PROTOCOL_UDP, 9020, 9020);
206  RANGE (PORT_PROTOCOL_UDP, 9103, 9103);
207  RANGE (PORT_PROTOCOL_UDP, 9199, 9200);
208  RANGE (PORT_PROTOCOL_UDP, 9370, 9370);
209  RANGE (PORT_PROTOCOL_UDP, 9876, 9877);
210  RANGE (PORT_PROTOCOL_UDP, 9950, 9950);
211  RANGE (PORT_PROTOCOL_UDP, 10000, 10000);
212  RANGE (PORT_PROTOCOL_UDP, 10080, 10080);
213  RANGE (PORT_PROTOCOL_UDP, 11487, 11487);
214  RANGE (PORT_PROTOCOL_UDP, 16086, 16086);
215  RANGE (PORT_PROTOCOL_UDP, 16402, 16402);
216  RANGE (PORT_PROTOCOL_UDP, 16420, 16420);
217  RANGE (PORT_PROTOCOL_UDP, 16430, 16430);
218  RANGE (PORT_PROTOCOL_UDP, 16433, 16433);
219  RANGE (PORT_PROTOCOL_UDP, 16449, 16449);
220  RANGE (PORT_PROTOCOL_UDP, 16498, 16498);
221  RANGE (PORT_PROTOCOL_UDP, 16503, 16503);
222  RANGE (PORT_PROTOCOL_UDP, 16545, 16545);
223  RANGE (PORT_PROTOCOL_UDP, 16548, 16548);
224  RANGE (PORT_PROTOCOL_UDP, 16573, 16573);
225  RANGE (PORT_PROTOCOL_UDP, 16674, 16674);
226  RANGE (PORT_PROTOCOL_UDP, 16680, 16680);
227  RANGE (PORT_PROTOCOL_UDP, 16697, 16697);
228  RANGE (PORT_PROTOCOL_UDP, 16700, 16700);
229  RANGE (PORT_PROTOCOL_UDP, 16708, 16708);
230  RANGE (PORT_PROTOCOL_UDP, 16711, 16711);
231  RANGE (PORT_PROTOCOL_UDP, 16739, 16739);
232  RANGE (PORT_PROTOCOL_UDP, 16766, 16766);
233  RANGE (PORT_PROTOCOL_UDP, 16779, 16779);
234  RANGE (PORT_PROTOCOL_UDP, 16786, 16786);
235  RANGE (PORT_PROTOCOL_UDP, 16816, 16816);
236  RANGE (PORT_PROTOCOL_UDP, 16829, 16829);
237  RANGE (PORT_PROTOCOL_UDP, 16832, 16832);
238  RANGE (PORT_PROTOCOL_UDP, 16838, 16839);
239  RANGE (PORT_PROTOCOL_UDP, 16862, 16862);
240  RANGE (PORT_PROTOCOL_UDP, 16896, 16896);
241  RANGE (PORT_PROTOCOL_UDP, 16912, 16912);
242  RANGE (PORT_PROTOCOL_UDP, 16918, 16919);
243  RANGE (PORT_PROTOCOL_UDP, 16938, 16939);
244  RANGE (PORT_PROTOCOL_UDP, 16947, 16948);
245  RANGE (PORT_PROTOCOL_UDP, 16970, 16970);
246  RANGE (PORT_PROTOCOL_UDP, 16972, 16972);
247  RANGE (PORT_PROTOCOL_UDP, 16974, 16974);
248  RANGE (PORT_PROTOCOL_UDP, 17006, 17006);
249  RANGE (PORT_PROTOCOL_UDP, 17018, 17018);
250  RANGE (PORT_PROTOCOL_UDP, 17077, 17077);
251  RANGE (PORT_PROTOCOL_UDP, 17091, 17091);
252  RANGE (PORT_PROTOCOL_UDP, 17101, 17101);
253  RANGE (PORT_PROTOCOL_UDP, 17146, 17146);
254  RANGE (PORT_PROTOCOL_UDP, 17184, 17185);
255  RANGE (PORT_PROTOCOL_UDP, 17205, 17205);
256  RANGE (PORT_PROTOCOL_UDP, 17207, 17207);
257  RANGE (PORT_PROTOCOL_UDP, 17219, 17219);
258  RANGE (PORT_PROTOCOL_UDP, 17236, 17237);
259  RANGE (PORT_PROTOCOL_UDP, 17282, 17282);
260  RANGE (PORT_PROTOCOL_UDP, 17302, 17302);
261  RANGE (PORT_PROTOCOL_UDP, 17321, 17321);
262  RANGE (PORT_PROTOCOL_UDP, 17331, 17332);
263  RANGE (PORT_PROTOCOL_UDP, 17338, 17338);
264  RANGE (PORT_PROTOCOL_UDP, 17359, 17359);
265  RANGE (PORT_PROTOCOL_UDP, 17417, 17417);
266  RANGE (PORT_PROTOCOL_UDP, 17423, 17424);
267  RANGE (PORT_PROTOCOL_UDP, 17455, 17455);
268  RANGE (PORT_PROTOCOL_UDP, 17459, 17459);
269  RANGE (PORT_PROTOCOL_UDP, 17468, 17468);
270  RANGE (PORT_PROTOCOL_UDP, 17487, 17487);
271  RANGE (PORT_PROTOCOL_UDP, 17490, 17490);
272  RANGE (PORT_PROTOCOL_UDP, 17494, 17494);
273  RANGE (PORT_PROTOCOL_UDP, 17505, 17505);
274  RANGE (PORT_PROTOCOL_UDP, 17533, 17533);
275  RANGE (PORT_PROTOCOL_UDP, 17549, 17549);
276  RANGE (PORT_PROTOCOL_UDP, 17573, 17573);
277  RANGE (PORT_PROTOCOL_UDP, 17580, 17580);
278  RANGE (PORT_PROTOCOL_UDP, 17585, 17585);
279  RANGE (PORT_PROTOCOL_UDP, 17592, 17592);
280  RANGE (PORT_PROTOCOL_UDP, 17605, 17605);
281  RANGE (PORT_PROTOCOL_UDP, 17615, 17616);
282  RANGE (PORT_PROTOCOL_UDP, 17629, 17629);
283  RANGE (PORT_PROTOCOL_UDP, 17638, 17638);
284  RANGE (PORT_PROTOCOL_UDP, 17663, 17663);
285  RANGE (PORT_PROTOCOL_UDP, 17673, 17674);
286  RANGE (PORT_PROTOCOL_UDP, 17683, 17683);
287  RANGE (PORT_PROTOCOL_UDP, 17726, 17726);
288  RANGE (PORT_PROTOCOL_UDP, 17754, 17754);
289  RANGE (PORT_PROTOCOL_UDP, 17762, 17762);
290  RANGE (PORT_PROTOCOL_UDP, 17787, 17787);
291  RANGE (PORT_PROTOCOL_UDP, 17814, 17814);
292  RANGE (PORT_PROTOCOL_UDP, 17823, 17824);
293  RANGE (PORT_PROTOCOL_UDP, 17836, 17836);
294  RANGE (PORT_PROTOCOL_UDP, 17845, 17845);
295  RANGE (PORT_PROTOCOL_UDP, 17888, 17888);
296  RANGE (PORT_PROTOCOL_UDP, 17939, 17939);
297  RANGE (PORT_PROTOCOL_UDP, 17946, 17946);
298  RANGE (PORT_PROTOCOL_UDP, 17989, 17989);
299  RANGE (PORT_PROTOCOL_UDP, 18004, 18004);
300  RANGE (PORT_PROTOCOL_UDP, 18081, 18081);
301  RANGE (PORT_PROTOCOL_UDP, 18113, 18113);
302  RANGE (PORT_PROTOCOL_UDP, 18134, 18134);
303  RANGE (PORT_PROTOCOL_UDP, 18156, 18156);
304  RANGE (PORT_PROTOCOL_UDP, 18228, 18228);
305  RANGE (PORT_PROTOCOL_UDP, 18234, 18234);
306  RANGE (PORT_PROTOCOL_UDP, 18250, 18250);
307  RANGE (PORT_PROTOCOL_UDP, 18255, 18255);
308  RANGE (PORT_PROTOCOL_UDP, 18258, 18258);
309  RANGE (PORT_PROTOCOL_UDP, 18319, 18319);
310  RANGE (PORT_PROTOCOL_UDP, 18331, 18331);
311  RANGE (PORT_PROTOCOL_UDP, 18360, 18360);
312  RANGE (PORT_PROTOCOL_UDP, 18373, 18373);
313  RANGE (PORT_PROTOCOL_UDP, 18449, 18449);
314  RANGE (PORT_PROTOCOL_UDP, 18485, 18485);
315  RANGE (PORT_PROTOCOL_UDP, 18543, 18543);
316  RANGE (PORT_PROTOCOL_UDP, 18582, 18582);
317  RANGE (PORT_PROTOCOL_UDP, 18605, 18605);
318  RANGE (PORT_PROTOCOL_UDP, 18617, 18617);
319  RANGE (PORT_PROTOCOL_UDP, 18666, 18666);
320  RANGE (PORT_PROTOCOL_UDP, 18669, 18669);
321  RANGE (PORT_PROTOCOL_UDP, 18676, 18676);
322  RANGE (PORT_PROTOCOL_UDP, 18683, 18683);
323  RANGE (PORT_PROTOCOL_UDP, 18807, 18807);
324  RANGE (PORT_PROTOCOL_UDP, 18818, 18818);
325  RANGE (PORT_PROTOCOL_UDP, 18821, 18821);
326  RANGE (PORT_PROTOCOL_UDP, 18830, 18830);
327  RANGE (PORT_PROTOCOL_UDP, 18832, 18832);
328  RANGE (PORT_PROTOCOL_UDP, 18835, 18835);
329  RANGE (PORT_PROTOCOL_UDP, 18869, 18869);
330  RANGE (PORT_PROTOCOL_UDP, 18883, 18883);
331  RANGE (PORT_PROTOCOL_UDP, 18888, 18888);
332  RANGE (PORT_PROTOCOL_UDP, 18958, 18958);
333  RANGE (PORT_PROTOCOL_UDP, 18980, 18980);
334  RANGE (PORT_PROTOCOL_UDP, 18985, 18985);
335  RANGE (PORT_PROTOCOL_UDP, 18987, 18987);
336  RANGE (PORT_PROTOCOL_UDP, 18991, 18991);
337  RANGE (PORT_PROTOCOL_UDP, 18994, 18994);
338  RANGE (PORT_PROTOCOL_UDP, 18996, 18996);
339  RANGE (PORT_PROTOCOL_UDP, 19017, 19017);
340  RANGE (PORT_PROTOCOL_UDP, 19022, 19022);
341  RANGE (PORT_PROTOCOL_UDP, 19039, 19039);
342  RANGE (PORT_PROTOCOL_UDP, 19047, 19047);
343  RANGE (PORT_PROTOCOL_UDP, 19075, 19075);
344  RANGE (PORT_PROTOCOL_UDP, 19096, 19096);
345  RANGE (PORT_PROTOCOL_UDP, 19120, 19120);
346  RANGE (PORT_PROTOCOL_UDP, 19130, 19130);
347  RANGE (PORT_PROTOCOL_UDP, 19140, 19141);
348  RANGE (PORT_PROTOCOL_UDP, 19154, 19154);
349  RANGE (PORT_PROTOCOL_UDP, 19161, 19161);
350  RANGE (PORT_PROTOCOL_UDP, 19165, 19165);
351  RANGE (PORT_PROTOCOL_UDP, 19181, 19181);
352  RANGE (PORT_PROTOCOL_UDP, 19193, 19193);
353  RANGE (PORT_PROTOCOL_UDP, 19197, 19197);
354  RANGE (PORT_PROTOCOL_UDP, 19222, 19222);
355  RANGE (PORT_PROTOCOL_UDP, 19227, 19227);
356  RANGE (PORT_PROTOCOL_UDP, 19273, 19273);
357  RANGE (PORT_PROTOCOL_UDP, 19283, 19283);
358  RANGE (PORT_PROTOCOL_UDP, 19294, 19294);
359  RANGE (PORT_PROTOCOL_UDP, 19315, 19315);
360  RANGE (PORT_PROTOCOL_UDP, 19322, 19322);
361  RANGE (PORT_PROTOCOL_UDP, 19332, 19332);
362  RANGE (PORT_PROTOCOL_UDP, 19374, 19374);
363  RANGE (PORT_PROTOCOL_UDP, 19415, 19415);
364  RANGE (PORT_PROTOCOL_UDP, 19482, 19482);
365  RANGE (PORT_PROTOCOL_UDP, 19489, 19489);
366  RANGE (PORT_PROTOCOL_UDP, 19500, 19500);
367  RANGE (PORT_PROTOCOL_UDP, 19503, 19504);
368  RANGE (PORT_PROTOCOL_UDP, 19541, 19541);
369  RANGE (PORT_PROTOCOL_UDP, 19600, 19600);
370  RANGE (PORT_PROTOCOL_UDP, 19605, 19605);
371  RANGE (PORT_PROTOCOL_UDP, 19616, 19616);
372  RANGE (PORT_PROTOCOL_UDP, 19624, 19625);
373  RANGE (PORT_PROTOCOL_UDP, 19632, 19632);
374  RANGE (PORT_PROTOCOL_UDP, 19639, 19639);
375  RANGE (PORT_PROTOCOL_UDP, 19647, 19647);
376  RANGE (PORT_PROTOCOL_UDP, 19650, 19650);
377  RANGE (PORT_PROTOCOL_UDP, 19660, 19660);
378  RANGE (PORT_PROTOCOL_UDP, 19662, 19663);
379  RANGE (PORT_PROTOCOL_UDP, 19682, 19683);
380  RANGE (PORT_PROTOCOL_UDP, 19687, 19687);
381  RANGE (PORT_PROTOCOL_UDP, 19695, 19695);
382  RANGE (PORT_PROTOCOL_UDP, 19707, 19707);
383  RANGE (PORT_PROTOCOL_UDP, 19717, 19719);
384  RANGE (PORT_PROTOCOL_UDP, 19722, 19722);
385  RANGE (PORT_PROTOCOL_UDP, 19728, 19728);
386  RANGE (PORT_PROTOCOL_UDP, 19789, 19789);
387  RANGE (PORT_PROTOCOL_UDP, 19792, 19792);
388  RANGE (PORT_PROTOCOL_UDP, 19933, 19933);
389  RANGE (PORT_PROTOCOL_UDP, 19935, 19936);
390  RANGE (PORT_PROTOCOL_UDP, 19956, 19956);
391  RANGE (PORT_PROTOCOL_UDP, 19995, 19995);
392  RANGE (PORT_PROTOCOL_UDP, 19998, 19998);
393  RANGE (PORT_PROTOCOL_UDP, 20003, 20004);
394  RANGE (PORT_PROTOCOL_UDP, 20019, 20019);
395  RANGE (PORT_PROTOCOL_UDP, 20031, 20031);
396  RANGE (PORT_PROTOCOL_UDP, 20082, 20082);
397  RANGE (PORT_PROTOCOL_UDP, 20117, 20117);
398  RANGE (PORT_PROTOCOL_UDP, 20120, 20120);
399  RANGE (PORT_PROTOCOL_UDP, 20126, 20126);
400  RANGE (PORT_PROTOCOL_UDP, 20129, 20129);
401  RANGE (PORT_PROTOCOL_UDP, 20146, 20146);
402  RANGE (PORT_PROTOCOL_UDP, 20154, 20154);
403  RANGE (PORT_PROTOCOL_UDP, 20164, 20164);
404  RANGE (PORT_PROTOCOL_UDP, 20206, 20206);
405  RANGE (PORT_PROTOCOL_UDP, 20217, 20217);
406  RANGE (PORT_PROTOCOL_UDP, 20249, 20249);
407  RANGE (PORT_PROTOCOL_UDP, 20262, 20262);
408  RANGE (PORT_PROTOCOL_UDP, 20279, 20279);
409  RANGE (PORT_PROTOCOL_UDP, 20288, 20288);
410  RANGE (PORT_PROTOCOL_UDP, 20309, 20309);
411  RANGE (PORT_PROTOCOL_UDP, 20313, 20313);
412  RANGE (PORT_PROTOCOL_UDP, 20326, 20326);
413  RANGE (PORT_PROTOCOL_UDP, 20359, 20360);
414  RANGE (PORT_PROTOCOL_UDP, 20366, 20366);
415  RANGE (PORT_PROTOCOL_UDP, 20380, 20380);
416  RANGE (PORT_PROTOCOL_UDP, 20389, 20389);
417  RANGE (PORT_PROTOCOL_UDP, 20409, 20409);
418  RANGE (PORT_PROTOCOL_UDP, 20411, 20411);
419  RANGE (PORT_PROTOCOL_UDP, 20423, 20425);
420  RANGE (PORT_PROTOCOL_UDP, 20445, 20445);
421  RANGE (PORT_PROTOCOL_UDP, 20449, 20449);
422  RANGE (PORT_PROTOCOL_UDP, 20464, 20465);
423  RANGE (PORT_PROTOCOL_UDP, 20518, 20518);
424  RANGE (PORT_PROTOCOL_UDP, 20522, 20522);
425  RANGE (PORT_PROTOCOL_UDP, 20525, 20525);
426  RANGE (PORT_PROTOCOL_UDP, 20540, 20540);
427  RANGE (PORT_PROTOCOL_UDP, 20560, 20560);
428  RANGE (PORT_PROTOCOL_UDP, 20665, 20665);
429  RANGE (PORT_PROTOCOL_UDP, 20678, 20679);
430  RANGE (PORT_PROTOCOL_UDP, 20710, 20710);
431  RANGE (PORT_PROTOCOL_UDP, 20717, 20717);
432  RANGE (PORT_PROTOCOL_UDP, 20742, 20742);
433  RANGE (PORT_PROTOCOL_UDP, 20752, 20752);
434  RANGE (PORT_PROTOCOL_UDP, 20762, 20762);
435  RANGE (PORT_PROTOCOL_UDP, 20791, 20791);
436  RANGE (PORT_PROTOCOL_UDP, 20817, 20817);
437  RANGE (PORT_PROTOCOL_UDP, 20842, 20842);
438  RANGE (PORT_PROTOCOL_UDP, 20848, 20848);
439  RANGE (PORT_PROTOCOL_UDP, 20851, 20851);
440  RANGE (PORT_PROTOCOL_UDP, 20865, 20865);
441  RANGE (PORT_PROTOCOL_UDP, 20872, 20872);
442  RANGE (PORT_PROTOCOL_UDP, 20876, 20876);
443  RANGE (PORT_PROTOCOL_UDP, 20884, 20884);
444  RANGE (PORT_PROTOCOL_UDP, 20919, 20919);
445  RANGE (PORT_PROTOCOL_UDP, 21000, 21000);
446  RANGE (PORT_PROTOCOL_UDP, 21016, 21016);
447  RANGE (PORT_PROTOCOL_UDP, 21060, 21060);
448  RANGE (PORT_PROTOCOL_UDP, 21083, 21083);
449  RANGE (PORT_PROTOCOL_UDP, 21104, 21104);
450  RANGE (PORT_PROTOCOL_UDP, 21111, 21111);
451  RANGE (PORT_PROTOCOL_UDP, 21131, 21131);
452  RANGE (PORT_PROTOCOL_UDP, 21167, 21167);
453  RANGE (PORT_PROTOCOL_UDP, 21186, 21186);
454  RANGE (PORT_PROTOCOL_UDP, 21206, 21207);
455  RANGE (PORT_PROTOCOL_UDP, 21212, 21212);
456  RANGE (PORT_PROTOCOL_UDP, 21247, 21247);
457  RANGE (PORT_PROTOCOL_UDP, 21261, 21261);
458  RANGE (PORT_PROTOCOL_UDP, 21282, 21282);
459  RANGE (PORT_PROTOCOL_UDP, 21298, 21298);
460  RANGE (PORT_PROTOCOL_UDP, 21303, 21303);
461  RANGE (PORT_PROTOCOL_UDP, 21318, 21318);
462  RANGE (PORT_PROTOCOL_UDP, 21320, 21320);
463  RANGE (PORT_PROTOCOL_UDP, 21333, 21333);
464  RANGE (PORT_PROTOCOL_UDP, 21344, 21344);
465  RANGE (PORT_PROTOCOL_UDP, 21354, 21354);
466  RANGE (PORT_PROTOCOL_UDP, 21358, 21358);
467  RANGE (PORT_PROTOCOL_UDP, 21360, 21360);
468  RANGE (PORT_PROTOCOL_UDP, 21364, 21364);
469  RANGE (PORT_PROTOCOL_UDP, 21366, 21366);
470  RANGE (PORT_PROTOCOL_UDP, 21383, 21383);
471  RANGE (PORT_PROTOCOL_UDP, 21405, 21405);
472  RANGE (PORT_PROTOCOL_UDP, 21454, 21454);
473  RANGE (PORT_PROTOCOL_UDP, 21468, 21468);
474  RANGE (PORT_PROTOCOL_UDP, 21476, 21476);
475  RANGE (PORT_PROTOCOL_UDP, 21514, 21514);
476  RANGE (PORT_PROTOCOL_UDP, 21524, 21525);
477  RANGE (PORT_PROTOCOL_UDP, 21556, 21556);
478  RANGE (PORT_PROTOCOL_UDP, 21566, 21566);
479  RANGE (PORT_PROTOCOL_UDP, 21568, 21568);
480  RANGE (PORT_PROTOCOL_UDP, 21576, 21576);
481  RANGE (PORT_PROTOCOL_UDP, 21609, 21609);
482  RANGE (PORT_PROTOCOL_UDP, 21621, 21621);
483  RANGE (PORT_PROTOCOL_UDP, 21625, 21625);
484  RANGE (PORT_PROTOCOL_UDP, 21644, 21644);
485  RANGE (PORT_PROTOCOL_UDP, 21649, 21649);
486  RANGE (PORT_PROTOCOL_UDP, 21655, 21655);
487  RANGE (PORT_PROTOCOL_UDP, 21663, 21663);
488  RANGE (PORT_PROTOCOL_UDP, 21674, 21674);
489  RANGE (PORT_PROTOCOL_UDP, 21698, 21698);
490  RANGE (PORT_PROTOCOL_UDP, 21702, 21702);
491  RANGE (PORT_PROTOCOL_UDP, 21710, 21710);
492  RANGE (PORT_PROTOCOL_UDP, 21742, 21742);
493  RANGE (PORT_PROTOCOL_UDP, 21780, 21780);
494  RANGE (PORT_PROTOCOL_UDP, 21784, 21784);
495  RANGE (PORT_PROTOCOL_UDP, 21800, 21800);
496  RANGE (PORT_PROTOCOL_UDP, 21803, 21803);
497  RANGE (PORT_PROTOCOL_UDP, 21834, 21834);
498  RANGE (PORT_PROTOCOL_UDP, 21842, 21842);
499  RANGE (PORT_PROTOCOL_UDP, 21847, 21847);
500  RANGE (PORT_PROTOCOL_UDP, 21868, 21868);
501  RANGE (PORT_PROTOCOL_UDP, 21898, 21898);
502  RANGE (PORT_PROTOCOL_UDP, 21902, 21902);
503  RANGE (PORT_PROTOCOL_UDP, 21923, 21923);
504  RANGE (PORT_PROTOCOL_UDP, 21948, 21948);
505  RANGE (PORT_PROTOCOL_UDP, 21967, 21967);
506  RANGE (PORT_PROTOCOL_UDP, 22029, 22029);
507  RANGE (PORT_PROTOCOL_UDP, 22043, 22043);
508  RANGE (PORT_PROTOCOL_UDP, 22045, 22045);
509  RANGE (PORT_PROTOCOL_UDP, 22053, 22053);
510  RANGE (PORT_PROTOCOL_UDP, 22055, 22055);
511  RANGE (PORT_PROTOCOL_UDP, 22105, 22105);
512  RANGE (PORT_PROTOCOL_UDP, 22109, 22109);
513  RANGE (PORT_PROTOCOL_UDP, 22123, 22124);
514  RANGE (PORT_PROTOCOL_UDP, 22341, 22341);
515  RANGE (PORT_PROTOCOL_UDP, 22692, 22692);
516  RANGE (PORT_PROTOCOL_UDP, 22695, 22695);
517  RANGE (PORT_PROTOCOL_UDP, 22739, 22739);
518  RANGE (PORT_PROTOCOL_UDP, 22799, 22799);
519  RANGE (PORT_PROTOCOL_UDP, 22846, 22846);
520  RANGE (PORT_PROTOCOL_UDP, 22914, 22914);
521  RANGE (PORT_PROTOCOL_UDP, 22986, 22986);
522  RANGE (PORT_PROTOCOL_UDP, 22996, 22996);
523  RANGE (PORT_PROTOCOL_UDP, 23040, 23040);
524  RANGE (PORT_PROTOCOL_UDP, 23176, 23176);
525  RANGE (PORT_PROTOCOL_UDP, 23354, 23354);
526  RANGE (PORT_PROTOCOL_UDP, 23531, 23531);
527  RANGE (PORT_PROTOCOL_UDP, 23557, 23557);
528  RANGE (PORT_PROTOCOL_UDP, 23608, 23608);
529  RANGE (PORT_PROTOCOL_UDP, 23679, 23679);
530  RANGE (PORT_PROTOCOL_UDP, 23781, 23781);
531  RANGE (PORT_PROTOCOL_UDP, 23965, 23965);
532  RANGE (PORT_PROTOCOL_UDP, 23980, 23980);
533  RANGE (PORT_PROTOCOL_UDP, 24007, 24007);
534  RANGE (PORT_PROTOCOL_UDP, 24279, 24279);
535  RANGE (PORT_PROTOCOL_UDP, 24511, 24511);
536  RANGE (PORT_PROTOCOL_UDP, 24594, 24594);
537  RANGE (PORT_PROTOCOL_UDP, 24606, 24606);
538  RANGE (PORT_PROTOCOL_UDP, 24644, 24644);
539  RANGE (PORT_PROTOCOL_UDP, 24854, 24854);
540  RANGE (PORT_PROTOCOL_UDP, 24910, 24910);
541  RANGE (PORT_PROTOCOL_UDP, 25003, 25003);
542  RANGE (PORT_PROTOCOL_UDP, 25157, 25157);
543  RANGE (PORT_PROTOCOL_UDP, 25240, 25240);
544  RANGE (PORT_PROTOCOL_UDP, 25280, 25280);
545  RANGE (PORT_PROTOCOL_UDP, 25337, 25337);
546  RANGE (PORT_PROTOCOL_UDP, 25375, 25375);
547  RANGE (PORT_PROTOCOL_UDP, 25462, 25462);
548  RANGE (PORT_PROTOCOL_UDP, 25541, 25541);
549  RANGE (PORT_PROTOCOL_UDP, 25546, 25546);
550  RANGE (PORT_PROTOCOL_UDP, 25709, 25709);
551  RANGE (PORT_PROTOCOL_UDP, 25931, 25931);
552  RANGE (PORT_PROTOCOL_UDP, 26407, 26407);
553  RANGE (PORT_PROTOCOL_UDP, 26415, 26415);
554  RANGE (PORT_PROTOCOL_UDP, 26720, 26720);
555  RANGE (PORT_PROTOCOL_UDP, 26872, 26872);
556  RANGE (PORT_PROTOCOL_UDP, 26966, 26966);
557  RANGE (PORT_PROTOCOL_UDP, 27015, 27015);
558  RANGE (PORT_PROTOCOL_UDP, 27195, 27195);
559  RANGE (PORT_PROTOCOL_UDP, 27444, 27444);
560  RANGE (PORT_PROTOCOL_UDP, 27473, 27473);
561  RANGE (PORT_PROTOCOL_UDP, 27482, 27482);
562  RANGE (PORT_PROTOCOL_UDP, 27707, 27707);
563  RANGE (PORT_PROTOCOL_UDP, 27892, 27892);
564  RANGE (PORT_PROTOCOL_UDP, 27899, 27899);
565  RANGE (PORT_PROTOCOL_UDP, 28122, 28122);
566  RANGE (PORT_PROTOCOL_UDP, 28369, 28369);
567  RANGE (PORT_PROTOCOL_UDP, 28465, 28465);
568  RANGE (PORT_PROTOCOL_UDP, 28493, 28493);
569  RANGE (PORT_PROTOCOL_UDP, 28543, 28543);
570  RANGE (PORT_PROTOCOL_UDP, 28547, 28547);
571  RANGE (PORT_PROTOCOL_UDP, 28641, 28641);
572  RANGE (PORT_PROTOCOL_UDP, 28840, 28840);
573  RANGE (PORT_PROTOCOL_UDP, 28973, 28973);
574  RANGE (PORT_PROTOCOL_UDP, 29078, 29078);
575  RANGE (PORT_PROTOCOL_UDP, 29243, 29243);
576  RANGE (PORT_PROTOCOL_UDP, 29256, 29256);
577  RANGE (PORT_PROTOCOL_UDP, 29810, 29810);
578  RANGE (PORT_PROTOCOL_UDP, 29823, 29823);
579  RANGE (PORT_PROTOCOL_UDP, 29977, 29977);
580  RANGE (PORT_PROTOCOL_UDP, 30263, 30263);
581  RANGE (PORT_PROTOCOL_UDP, 30303, 30303);
582  RANGE (PORT_PROTOCOL_UDP, 30365, 30365);
583  RANGE (PORT_PROTOCOL_UDP, 30544, 30544);
584  RANGE (PORT_PROTOCOL_UDP, 30656, 30656);
585  RANGE (PORT_PROTOCOL_UDP, 30697, 30697);
586  RANGE (PORT_PROTOCOL_UDP, 30704, 30704);
587  RANGE (PORT_PROTOCOL_UDP, 30718, 30718);
588  RANGE (PORT_PROTOCOL_UDP, 30975, 30975);
589  RANGE (PORT_PROTOCOL_UDP, 31059, 31059);
590  RANGE (PORT_PROTOCOL_UDP, 31073, 31073);
591  RANGE (PORT_PROTOCOL_UDP, 31109, 31109);
592  RANGE (PORT_PROTOCOL_UDP, 31189, 31189);
593  RANGE (PORT_PROTOCOL_UDP, 31195, 31195);
594  RANGE (PORT_PROTOCOL_UDP, 31335, 31335);
595  RANGE (PORT_PROTOCOL_UDP, 31337, 31337);
596  RANGE (PORT_PROTOCOL_UDP, 31365, 31365);
597  RANGE (PORT_PROTOCOL_UDP, 31625, 31625);
598  RANGE (PORT_PROTOCOL_UDP, 31681, 31681);
599  RANGE (PORT_PROTOCOL_UDP, 31731, 31731);
600  RANGE (PORT_PROTOCOL_UDP, 31891, 31891);
601  RANGE (PORT_PROTOCOL_UDP, 32345, 32345);
602  RANGE (PORT_PROTOCOL_UDP, 32385, 32385);
603  RANGE (PORT_PROTOCOL_UDP, 32528, 32528);
604  RANGE (PORT_PROTOCOL_UDP, 32768, 32780);
605  RANGE (PORT_PROTOCOL_UDP, 32798, 32798);
606  RANGE (PORT_PROTOCOL_UDP, 32815, 32815);
607  RANGE (PORT_PROTOCOL_UDP, 32818, 32818);
608  RANGE (PORT_PROTOCOL_UDP, 32931, 32931);
609  RANGE (PORT_PROTOCOL_UDP, 33030, 33030);
610  RANGE (PORT_PROTOCOL_UDP, 33249, 33249);
611  RANGE (PORT_PROTOCOL_UDP, 33281, 33281);
612  RANGE (PORT_PROTOCOL_UDP, 33354, 33355);
613  RANGE (PORT_PROTOCOL_UDP, 33459, 33459);
614  RANGE (PORT_PROTOCOL_UDP, 33717, 33717);
615  RANGE (PORT_PROTOCOL_UDP, 33744, 33744);
616  RANGE (PORT_PROTOCOL_UDP, 33866, 33866);
617  RANGE (PORT_PROTOCOL_UDP, 33872, 33872);
618  RANGE (PORT_PROTOCOL_UDP, 34038, 34038);
619  RANGE (PORT_PROTOCOL_UDP, 34079, 34079);
620  RANGE (PORT_PROTOCOL_UDP, 34125, 34125);
621  RANGE (PORT_PROTOCOL_UDP, 34358, 34358);
622  RANGE (PORT_PROTOCOL_UDP, 34422, 34422);
623  RANGE (PORT_PROTOCOL_UDP, 34433, 34433);
624  RANGE (PORT_PROTOCOL_UDP, 34555, 34555);
625  RANGE (PORT_PROTOCOL_UDP, 34570, 34570);
626  RANGE (PORT_PROTOCOL_UDP, 34577, 34580);
627  RANGE (PORT_PROTOCOL_UDP, 34758, 34758);
628  RANGE (PORT_PROTOCOL_UDP, 34796, 34796);
629  RANGE (PORT_PROTOCOL_UDP, 34855, 34855);
630  RANGE (PORT_PROTOCOL_UDP, 34861, 34862);
631  RANGE (PORT_PROTOCOL_UDP, 34892, 34892);
632  RANGE (PORT_PROTOCOL_UDP, 35438, 35438);
633  RANGE (PORT_PROTOCOL_UDP, 35702, 35702);
634  RANGE (PORT_PROTOCOL_UDP, 35777, 35777);
635  RANGE (PORT_PROTOCOL_UDP, 35794, 35794);
636  RANGE (PORT_PROTOCOL_UDP, 36108, 36108);
637  RANGE (PORT_PROTOCOL_UDP, 36206, 36206);
638  RANGE (PORT_PROTOCOL_UDP, 36384, 36384);
639  RANGE (PORT_PROTOCOL_UDP, 36458, 36458);
640  RANGE (PORT_PROTOCOL_UDP, 36489, 36489);
641  RANGE (PORT_PROTOCOL_UDP, 36669, 36669);
642  RANGE (PORT_PROTOCOL_UDP, 36778, 36778);
643  RANGE (PORT_PROTOCOL_UDP, 36893, 36893);
644  RANGE (PORT_PROTOCOL_UDP, 36945, 36945);
645  RANGE (PORT_PROTOCOL_UDP, 37144, 37144);
646  RANGE (PORT_PROTOCOL_UDP, 37212, 37212);
647  RANGE (PORT_PROTOCOL_UDP, 37393, 37393);
648  RANGE (PORT_PROTOCOL_UDP, 37444, 37444);
649  RANGE (PORT_PROTOCOL_UDP, 37602, 37602);
650  RANGE (PORT_PROTOCOL_UDP, 37761, 37761);
651  RANGE (PORT_PROTOCOL_UDP, 37783, 37783);
652  RANGE (PORT_PROTOCOL_UDP, 37813, 37813);
653  RANGE (PORT_PROTOCOL_UDP, 37843, 37843);
654  RANGE (PORT_PROTOCOL_UDP, 38037, 38037);
655  RANGE (PORT_PROTOCOL_UDP, 38063, 38063);
656  RANGE (PORT_PROTOCOL_UDP, 38293, 38293);
657  RANGE (PORT_PROTOCOL_UDP, 38412, 38412);
658  RANGE (PORT_PROTOCOL_UDP, 38498, 38498);
659  RANGE (PORT_PROTOCOL_UDP, 38615, 38615);
660  RANGE (PORT_PROTOCOL_UDP, 39213, 39213);
661  RANGE (PORT_PROTOCOL_UDP, 39217, 39217);
662  RANGE (PORT_PROTOCOL_UDP, 39632, 39632);
663  RANGE (PORT_PROTOCOL_UDP, 39683, 39683);
664  RANGE (PORT_PROTOCOL_UDP, 39714, 39714);
665  RANGE (PORT_PROTOCOL_UDP, 39723, 39723);
666  RANGE (PORT_PROTOCOL_UDP, 39888, 39888);
667  RANGE (PORT_PROTOCOL_UDP, 40019, 40019);
668  RANGE (PORT_PROTOCOL_UDP, 40116, 40116);
669  RANGE (PORT_PROTOCOL_UDP, 40441, 40441);
670  RANGE (PORT_PROTOCOL_UDP, 40539, 40539);
671  RANGE (PORT_PROTOCOL_UDP, 40622, 40622);
672  RANGE (PORT_PROTOCOL_UDP, 40708, 40708);
673  RANGE (PORT_PROTOCOL_UDP, 40711, 40711);
674  RANGE (PORT_PROTOCOL_UDP, 40724, 40724);
675  RANGE (PORT_PROTOCOL_UDP, 40732, 40732);
676  RANGE (PORT_PROTOCOL_UDP, 40805, 40805);
677  RANGE (PORT_PROTOCOL_UDP, 40847, 40847);
678  RANGE (PORT_PROTOCOL_UDP, 40866, 40866);
679  RANGE (PORT_PROTOCOL_UDP, 40915, 40915);
680  RANGE (PORT_PROTOCOL_UDP, 41058, 41058);
681  RANGE (PORT_PROTOCOL_UDP, 41081, 41081);
682  RANGE (PORT_PROTOCOL_UDP, 41308, 41308);
683  RANGE (PORT_PROTOCOL_UDP, 41370, 41370);
684  RANGE (PORT_PROTOCOL_UDP, 41446, 41446);
685  RANGE (PORT_PROTOCOL_UDP, 41524, 41524);
686  RANGE (PORT_PROTOCOL_UDP, 41638, 41638);
687  RANGE (PORT_PROTOCOL_UDP, 41702, 41702);
688  RANGE (PORT_PROTOCOL_UDP, 41774, 41774);
689  RANGE (PORT_PROTOCOL_UDP, 41896, 41896);
690  RANGE (PORT_PROTOCOL_UDP, 41967, 41967);
691  RANGE (PORT_PROTOCOL_UDP, 41971, 41971);
692  RANGE (PORT_PROTOCOL_UDP, 42056, 42056);
693  RANGE (PORT_PROTOCOL_UDP, 42172, 42172);
694  RANGE (PORT_PROTOCOL_UDP, 42313, 42313);
695  RANGE (PORT_PROTOCOL_UDP, 42431, 42431);
696  RANGE (PORT_PROTOCOL_UDP, 42434, 42434);
697  RANGE (PORT_PROTOCOL_UDP, 42508, 42508);
698  RANGE (PORT_PROTOCOL_UDP, 42557, 42557);
699  RANGE (PORT_PROTOCOL_UDP, 42577, 42577);
700  RANGE (PORT_PROTOCOL_UDP, 42627, 42627);
701  RANGE (PORT_PROTOCOL_UDP, 42639, 42639);
702  RANGE (PORT_PROTOCOL_UDP, 43094, 43094);
703  RANGE (PORT_PROTOCOL_UDP, 43195, 43195);
704  RANGE (PORT_PROTOCOL_UDP, 43370, 43370);
705  RANGE (PORT_PROTOCOL_UDP, 43514, 43514);
706  RANGE (PORT_PROTOCOL_UDP, 43686, 43686);
707  RANGE (PORT_PROTOCOL_UDP, 43824, 43824);
708  RANGE (PORT_PROTOCOL_UDP, 43967, 43967);
709  RANGE (PORT_PROTOCOL_UDP, 44101, 44101);
710  RANGE (PORT_PROTOCOL_UDP, 44160, 44160);
711  RANGE (PORT_PROTOCOL_UDP, 44179, 44179);
712  RANGE (PORT_PROTOCOL_UDP, 44185, 44185);
713  RANGE (PORT_PROTOCOL_UDP, 44190, 44190);
714  RANGE (PORT_PROTOCOL_UDP, 44253, 44253);
715  RANGE (PORT_PROTOCOL_UDP, 44334, 44334);
716  RANGE (PORT_PROTOCOL_UDP, 44508, 44508);
717  RANGE (PORT_PROTOCOL_UDP, 44923, 44923);
718  RANGE (PORT_PROTOCOL_UDP, 44946, 44946);
719  RANGE (PORT_PROTOCOL_UDP, 44968, 44968);
720  RANGE (PORT_PROTOCOL_UDP, 45247, 45247);
721  RANGE (PORT_PROTOCOL_UDP, 45380, 45380);
722  RANGE (PORT_PROTOCOL_UDP, 45441, 45441);
723  RANGE (PORT_PROTOCOL_UDP, 45685, 45685);
724  RANGE (PORT_PROTOCOL_UDP, 45722, 45722);
725  RANGE (PORT_PROTOCOL_UDP, 45818, 45818);
726  RANGE (PORT_PROTOCOL_UDP, 45928, 45928);
727  RANGE (PORT_PROTOCOL_UDP, 46093, 46093);
728  RANGE (PORT_PROTOCOL_UDP, 46532, 46532);
729  RANGE (PORT_PROTOCOL_UDP, 46836, 46836);
730  RANGE (PORT_PROTOCOL_UDP, 47624, 47624);
731  RANGE (PORT_PROTOCOL_UDP, 47765, 47765);
732  RANGE (PORT_PROTOCOL_UDP, 47772, 47772);
733  RANGE (PORT_PROTOCOL_UDP, 47808, 47808);
734  RANGE (PORT_PROTOCOL_UDP, 47915, 47915);
735  RANGE (PORT_PROTOCOL_UDP, 47981, 47981);
736  RANGE (PORT_PROTOCOL_UDP, 48078, 48078);
737  RANGE (PORT_PROTOCOL_UDP, 48189, 48189);
738  RANGE (PORT_PROTOCOL_UDP, 48255, 48255);
739  RANGE (PORT_PROTOCOL_UDP, 48455, 48455);
740  RANGE (PORT_PROTOCOL_UDP, 48489, 48489);
741  RANGE (PORT_PROTOCOL_UDP, 48761, 48761);
742  RANGE (PORT_PROTOCOL_UDP, 49152, 49163);
743  RANGE (PORT_PROTOCOL_UDP, 49165, 49182);
744  RANGE (PORT_PROTOCOL_UDP, 49184, 49202);
745  RANGE (PORT_PROTOCOL_UDP, 49204, 49205);
746  RANGE (PORT_PROTOCOL_UDP, 49207, 49216);
747  RANGE (PORT_PROTOCOL_UDP, 49220, 49220);
748  RANGE (PORT_PROTOCOL_UDP, 49222, 49222);
749  RANGE (PORT_PROTOCOL_UDP, 49226, 49226);
750  RANGE (PORT_PROTOCOL_UDP, 49259, 49259);
751  RANGE (PORT_PROTOCOL_UDP, 49262, 49262);
752  RANGE (PORT_PROTOCOL_UDP, 49306, 49306);
753  RANGE (PORT_PROTOCOL_UDP, 49350, 49350);
754  RANGE (PORT_PROTOCOL_UDP, 49360, 49360);
755  RANGE (PORT_PROTOCOL_UDP, 49393, 49393);
756  RANGE (PORT_PROTOCOL_UDP, 49396, 49396);
757  RANGE (PORT_PROTOCOL_UDP, 49503, 49503);
758  RANGE (PORT_PROTOCOL_UDP, 49640, 49640);
759  RANGE (PORT_PROTOCOL_UDP, 49968, 49968);
760  RANGE (PORT_PROTOCOL_UDP, 50099, 50099);
761  RANGE (PORT_PROTOCOL_UDP, 50164, 50164);
762  RANGE (PORT_PROTOCOL_UDP, 50497, 50497);
763  RANGE (PORT_PROTOCOL_UDP, 50612, 50612);
764  RANGE (PORT_PROTOCOL_UDP, 50708, 50708);
765  RANGE (PORT_PROTOCOL_UDP, 50919, 50919);
766  RANGE (PORT_PROTOCOL_UDP, 51255, 51255);
767  RANGE (PORT_PROTOCOL_UDP, 51456, 51456);
768  RANGE (PORT_PROTOCOL_UDP, 51554, 51554);
769  RANGE (PORT_PROTOCOL_UDP, 51586, 51586);
770  RANGE (PORT_PROTOCOL_UDP, 51690, 51690);
771  RANGE (PORT_PROTOCOL_UDP, 51717, 51717);
772  RANGE (PORT_PROTOCOL_UDP, 51905, 51905);
773  RANGE (PORT_PROTOCOL_UDP, 51972, 51972);
774  RANGE (PORT_PROTOCOL_UDP, 52144, 52144);
775  RANGE (PORT_PROTOCOL_UDP, 52225, 52225);
776  RANGE (PORT_PROTOCOL_UDP, 52503, 52503);
777  RANGE (PORT_PROTOCOL_UDP, 53006, 53006);
778  RANGE (PORT_PROTOCOL_UDP, 53037, 53037);
779  RANGE (PORT_PROTOCOL_UDP, 53571, 53571);
780  RANGE (PORT_PROTOCOL_UDP, 53589, 53589);
781  RANGE (PORT_PROTOCOL_UDP, 53838, 53838);
782  RANGE (PORT_PROTOCOL_UDP, 54094, 54094);
783  RANGE (PORT_PROTOCOL_UDP, 54114, 54114);
784  RANGE (PORT_PROTOCOL_UDP, 54281, 54281);
785  RANGE (PORT_PROTOCOL_UDP, 54321, 54321);
786  RANGE (PORT_PROTOCOL_UDP, 54711, 54711);
787  RANGE (PORT_PROTOCOL_UDP, 54807, 54807);
788  RANGE (PORT_PROTOCOL_UDP, 54925, 54925);
789  RANGE (PORT_PROTOCOL_UDP, 55043, 55043);
790  RANGE (PORT_PROTOCOL_UDP, 55544, 55544);
791  RANGE (PORT_PROTOCOL_UDP, 55587, 55587);
792  RANGE (PORT_PROTOCOL_UDP, 56141, 56141);
793  RANGE (PORT_PROTOCOL_UDP, 57172, 57172);
794  RANGE (PORT_PROTOCOL_UDP, 57409, 57410);
795  RANGE (PORT_PROTOCOL_UDP, 57813, 57813);
796  RANGE (PORT_PROTOCOL_UDP, 57843, 57843);
797  RANGE (PORT_PROTOCOL_UDP, 57958, 57958);
798  RANGE (PORT_PROTOCOL_UDP, 57977, 57977);
799  RANGE (PORT_PROTOCOL_UDP, 58002, 58002);
800  RANGE (PORT_PROTOCOL_UDP, 58075, 58075);
801  RANGE (PORT_PROTOCOL_UDP, 58178, 58178);
802  RANGE (PORT_PROTOCOL_UDP, 58419, 58419);
803  RANGE (PORT_PROTOCOL_UDP, 58631, 58631);
804  RANGE (PORT_PROTOCOL_UDP, 58640, 58640);
805  RANGE (PORT_PROTOCOL_UDP, 58797, 58797);
806  RANGE (PORT_PROTOCOL_UDP, 59193, 59193);
807  RANGE (PORT_PROTOCOL_UDP, 59207, 59207);
808  RANGE (PORT_PROTOCOL_UDP, 59765, 59765);
809  RANGE (PORT_PROTOCOL_UDP, 59846, 59846);
810  RANGE (PORT_PROTOCOL_UDP, 60172, 60172);
811  RANGE (PORT_PROTOCOL_UDP, 60381, 60381);
812  RANGE (PORT_PROTOCOL_UDP, 60423, 60423);
813  RANGE (PORT_PROTOCOL_UDP, 61024, 61024);
814  RANGE (PORT_PROTOCOL_UDP, 61142, 61142);
815  RANGE (PORT_PROTOCOL_UDP, 61319, 61319);
816  RANGE (PORT_PROTOCOL_UDP, 61322, 61322);
817  RANGE (PORT_PROTOCOL_UDP, 61370, 61370);
818  RANGE (PORT_PROTOCOL_UDP, 61412, 61412);
819  RANGE (PORT_PROTOCOL_UDP, 61481, 61481);
820  RANGE (PORT_PROTOCOL_UDP, 61550, 61550);
821  RANGE (PORT_PROTOCOL_UDP, 61685, 61685);
822  RANGE (PORT_PROTOCOL_UDP, 61961, 61961);
823  RANGE (PORT_PROTOCOL_UDP, 62154, 62154);
824  RANGE (PORT_PROTOCOL_UDP, 62287, 62287);
825  RANGE (PORT_PROTOCOL_UDP, 62575, 62575);
826  RANGE (PORT_PROTOCOL_UDP, 62677, 62677);
827  RANGE (PORT_PROTOCOL_UDP, 62699, 62699);
828  RANGE (PORT_PROTOCOL_UDP, 62958, 62958);
829  RANGE (PORT_PROTOCOL_UDP, 63420, 63420);
830  RANGE (PORT_PROTOCOL_UDP, 63555, 63555);
831  RANGE (PORT_PROTOCOL_UDP, 64080, 64080);
832  RANGE (PORT_PROTOCOL_UDP, 64481, 64481);
833  RANGE (PORT_PROTOCOL_UDP, 64513, 64513);
834  RANGE (PORT_PROTOCOL_UDP, 64590, 64590);
835  RANGE (PORT_PROTOCOL_UDP, 64727, 64727);
836 }
#define RANGE(type, start, end)
Insert a port range.

◆ make_port_ranges_iana_tcp_2012()

void make_port_ranges_iana_tcp_2012 ( port_list_t  list)

Make port ranges for IANA TCP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

Definition at line 48 of file manage_ranges_iana_tcp_2012.c.

References RANGE.

49 {
50  RANGE (PORT_PROTOCOL_TCP, 1, 80);
51  RANGE (PORT_PROTOCOL_TCP, 82, 113);
52  RANGE (PORT_PROTOCOL_TCP, 115, 224);
53  RANGE (PORT_PROTOCOL_TCP, 242, 248);
54  RANGE (PORT_PROTOCOL_TCP, 256, 257);
55  RANGE (PORT_PROTOCOL_TCP, 259, 269);
56  RANGE (PORT_PROTOCOL_TCP, 280, 284);
57  RANGE (PORT_PROTOCOL_TCP, 286, 287);
58  RANGE (PORT_PROTOCOL_TCP, 308, 322);
59  RANGE (PORT_PROTOCOL_TCP, 333, 333);
60  RANGE (PORT_PROTOCOL_TCP, 344, 584);
61  RANGE (PORT_PROTOCOL_TCP, 586, 658);
62  RANGE (PORT_PROTOCOL_TCP, 660, 702);
63  RANGE (PORT_PROTOCOL_TCP, 704, 707);
64  RANGE (PORT_PROTOCOL_TCP, 709, 715);
65  RANGE (PORT_PROTOCOL_TCP, 729, 731);
66  RANGE (PORT_PROTOCOL_TCP, 741, 742);
67  RANGE (PORT_PROTOCOL_TCP, 744, 744);
68  RANGE (PORT_PROTOCOL_TCP, 747, 754);
69  RANGE (PORT_PROTOCOL_TCP, 758, 765);
70  RANGE (PORT_PROTOCOL_TCP, 767, 767);
71  RANGE (PORT_PROTOCOL_TCP, 769, 777);
72  RANGE (PORT_PROTOCOL_TCP, 780, 780);
73  RANGE (PORT_PROTOCOL_TCP, 800, 801);
74  RANGE (PORT_PROTOCOL_TCP, 810, 810);
75  RANGE (PORT_PROTOCOL_TCP, 828, 833);
76  RANGE (PORT_PROTOCOL_TCP, 847, 848);
77  RANGE (PORT_PROTOCOL_TCP, 860, 862);
78  RANGE (PORT_PROTOCOL_TCP, 873, 873);
79  RANGE (PORT_PROTOCOL_TCP, 886, 888);
80  RANGE (PORT_PROTOCOL_TCP, 900, 903);
81  RANGE (PORT_PROTOCOL_TCP, 910, 913);
82  RANGE (PORT_PROTOCOL_TCP, 989, 993);
83  RANGE (PORT_PROTOCOL_TCP, 995, 1000);
84  RANGE (PORT_PROTOCOL_TCP, 1010, 1010);
85  RANGE (PORT_PROTOCOL_TCP, 1021, 1022);
86  RANGE (PORT_PROTOCOL_TCP, 1025, 1027);
87  RANGE (PORT_PROTOCOL_TCP, 1029, 1108);
88  RANGE (PORT_PROTOCOL_TCP, 1110, 1490);
89  RANGE (PORT_PROTOCOL_TCP, 1492, 1527);
90  RANGE (PORT_PROTOCOL_TCP, 1529, 1782);
91  RANGE (PORT_PROTOCOL_TCP, 1784, 2193);
92  RANGE (PORT_PROTOCOL_TCP, 2197, 2258);
93  RANGE (PORT_PROTOCOL_TCP, 2260, 2368);
94  RANGE (PORT_PROTOCOL_TCP, 2370, 2374);
95  RANGE (PORT_PROTOCOL_TCP, 2381, 2425);
96  RANGE (PORT_PROTOCOL_TCP, 2427, 2681);
97  RANGE (PORT_PROTOCOL_TCP, 2683, 2793);
98  RANGE (PORT_PROTOCOL_TCP, 2795, 2824);
99  RANGE (PORT_PROTOCOL_TCP, 2826, 2872);
100  RANGE (PORT_PROTOCOL_TCP, 2874, 2924);
101  RANGE (PORT_PROTOCOL_TCP, 2926, 3000);
102  RANGE (PORT_PROTOCOL_TCP, 3002, 3091);
103  RANGE (PORT_PROTOCOL_TCP, 3093, 3096);
104  RANGE (PORT_PROTOCOL_TCP, 3098, 3120);
105  RANGE (PORT_PROTOCOL_TCP, 3122, 3125);
106  RANGE (PORT_PROTOCOL_TCP, 3127, 3299);
107  RANGE (PORT_PROTOCOL_TCP, 3302, 3321);
108  RANGE (PORT_PROTOCOL_TCP, 3326, 3366);
109  RANGE (PORT_PROTOCOL_TCP, 3372, 3402);
110  RANGE (PORT_PROTOCOL_TCP, 3405, 3545);
111  RANGE (PORT_PROTOCOL_TCP, 3547, 3692);
112  RANGE (PORT_PROTOCOL_TCP, 3695, 3765);
113  RANGE (PORT_PROTOCOL_TCP, 3767, 3993);
114  RANGE (PORT_PROTOCOL_TCP, 3995, 4047);
115  RANGE (PORT_PROTOCOL_TCP, 4049, 4076);
116  RANGE (PORT_PROTOCOL_TCP, 4078, 4083);
117  RANGE (PORT_PROTOCOL_TCP, 4085, 4085);
118  RANGE (PORT_PROTOCOL_TCP, 4087, 4119);
119  RANGE (PORT_PROTOCOL_TCP, 4121, 4143);
120  RANGE (PORT_PROTOCOL_TCP, 4145, 4172);
121  RANGE (PORT_PROTOCOL_TCP, 4174, 4190);
122  RANGE (PORT_PROTOCOL_TCP, 4192, 4193);
123  RANGE (PORT_PROTOCOL_TCP, 4199, 4199);
124  RANGE (PORT_PROTOCOL_TCP, 4300, 4313);
125  RANGE (PORT_PROTOCOL_TCP, 4320, 4329);
126  RANGE (PORT_PROTOCOL_TCP, 4340, 4360);
127  RANGE (PORT_PROTOCOL_TCP, 4368, 4379);
128  RANGE (PORT_PROTOCOL_TCP, 4389, 4393);
129  RANGE (PORT_PROTOCOL_TCP, 4395, 4396);
130  RANGE (PORT_PROTOCOL_TCP, 4400, 4410);
131  RANGE (PORT_PROTOCOL_TCP, 4425, 4431);
132  RANGE (PORT_PROTOCOL_TCP, 4433, 4433);
133  RANGE (PORT_PROTOCOL_TCP, 4442, 4458);
134  RANGE (PORT_PROTOCOL_TCP, 4484, 4488);
135  RANGE (PORT_PROTOCOL_TCP, 4500, 4500);
136  RANGE (PORT_PROTOCOL_TCP, 4535, 4538);
137  RANGE (PORT_PROTOCOL_TCP, 4545, 4556);
138  RANGE (PORT_PROTOCOL_TCP, 4559, 4559);
139  RANGE (PORT_PROTOCOL_TCP, 4566, 4569);
140  RANGE (PORT_PROTOCOL_TCP, 4590, 4591);
141  RANGE (PORT_PROTOCOL_TCP, 4593, 4603);
142  RANGE (PORT_PROTOCOL_TCP, 4658, 4692);
143  RANGE (PORT_PROTOCOL_TCP, 4700, 4704);
144  RANGE (PORT_PROTOCOL_TCP, 4725, 4725);
145  RANGE (PORT_PROTOCOL_TCP, 4727, 4728);
146  RANGE (PORT_PROTOCOL_TCP, 4730, 4731);
147  RANGE (PORT_PROTOCOL_TCP, 4733, 4733);
148  RANGE (PORT_PROTOCOL_TCP, 4737, 4745);
149  RANGE (PORT_PROTOCOL_TCP, 4749, 4752);
150  RANGE (PORT_PROTOCOL_TCP, 4784, 4784);
151  RANGE (PORT_PROTOCOL_TCP, 4786, 4788);
152  RANGE (PORT_PROTOCOL_TCP, 4800, 4803);
153  RANGE (PORT_PROTOCOL_TCP, 4827, 4827);
154  RANGE (PORT_PROTOCOL_TCP, 4837, 4851);
155  RANGE (PORT_PROTOCOL_TCP, 4867, 4871);
156  RANGE (PORT_PROTOCOL_TCP, 4876, 4877);
157  RANGE (PORT_PROTOCOL_TCP, 4879, 4880);
158  RANGE (PORT_PROTOCOL_TCP, 4883, 4885);
159  RANGE (PORT_PROTOCOL_TCP, 4894, 4894);
160  RANGE (PORT_PROTOCOL_TCP, 4899, 4902);
161  RANGE (PORT_PROTOCOL_TCP, 4912, 4915);
162  RANGE (PORT_PROTOCOL_TCP, 4940, 4942);
163  RANGE (PORT_PROTOCOL_TCP, 4949, 4953);
164  RANGE (PORT_PROTOCOL_TCP, 4969, 4970);
165  RANGE (PORT_PROTOCOL_TCP, 4984, 4991);
166  RANGE (PORT_PROTOCOL_TCP, 4999, 5013);
167  RANGE (PORT_PROTOCOL_TCP, 5015, 5015);
168  RANGE (PORT_PROTOCOL_TCP, 5020, 5030);
169  RANGE (PORT_PROTOCOL_TCP, 5032, 5032);
170  RANGE (PORT_PROTOCOL_TCP, 5042, 5045);
171  RANGE (PORT_PROTOCOL_TCP, 5048, 5057);
172  RANGE (PORT_PROTOCOL_TCP, 5059, 5074);
173  RANGE (PORT_PROTOCOL_TCP, 5080, 5086);
174  RANGE (PORT_PROTOCOL_TCP, 5093, 5094);
175  RANGE (PORT_PROTOCOL_TCP, 5099, 5103);
176  RANGE (PORT_PROTOCOL_TCP, 5111, 5112);
177  RANGE (PORT_PROTOCOL_TCP, 5114, 5115);
178  RANGE (PORT_PROTOCOL_TCP, 5117, 5117);
179  RANGE (PORT_PROTOCOL_TCP, 5133, 5135);
180  RANGE (PORT_PROTOCOL_TCP, 5137, 5137);
181  RANGE (PORT_PROTOCOL_TCP, 5145, 5146);
182  RANGE (PORT_PROTOCOL_TCP, 5150, 5157);
183  RANGE (PORT_PROTOCOL_TCP, 5161, 5168);
184  RANGE (PORT_PROTOCOL_TCP, 5190, 5194);
185  RANGE (PORT_PROTOCOL_TCP, 5200, 5203);
186  RANGE (PORT_PROTOCOL_TCP, 5221, 5228);
187  RANGE (PORT_PROTOCOL_TCP, 5232, 5237);
188  RANGE (PORT_PROTOCOL_TCP, 5245, 5245);
189  RANGE (PORT_PROTOCOL_TCP, 5248, 5253);
190  RANGE (PORT_PROTOCOL_TCP, 5264, 5265);
191  RANGE (PORT_PROTOCOL_TCP, 5269, 5272);
192  RANGE (PORT_PROTOCOL_TCP, 5280, 5282);
193  RANGE (PORT_PROTOCOL_TCP, 5298, 5310);
194  RANGE (PORT_PROTOCOL_TCP, 5312, 5318);
195  RANGE (PORT_PROTOCOL_TCP, 5320, 5321);
196  RANGE (PORT_PROTOCOL_TCP, 5343, 5344);
197  RANGE (PORT_PROTOCOL_TCP, 5349, 5363);
198  RANGE (PORT_PROTOCOL_TCP, 5397, 5435);
199  RANGE (PORT_PROTOCOL_TCP, 5443, 5443);
200  RANGE (PORT_PROTOCOL_TCP, 5453, 5456);
201  RANGE (PORT_PROTOCOL_TCP, 5461, 5465);
202  RANGE (PORT_PROTOCOL_TCP, 5500, 5506);
203  RANGE (PORT_PROTOCOL_TCP, 5553, 5557);
204  RANGE (PORT_PROTOCOL_TCP, 5566, 5568);
205  RANGE (PORT_PROTOCOL_TCP, 5573, 5575);
206  RANGE (PORT_PROTOCOL_TCP, 5579, 5585);
207  RANGE (PORT_PROTOCOL_TCP, 5597, 5605);
208  RANGE (PORT_PROTOCOL_TCP, 5627, 5638);
209  RANGE (PORT_PROTOCOL_TCP, 5646, 5646);
210  RANGE (PORT_PROTOCOL_TCP, 5671, 5681);
211  RANGE (PORT_PROTOCOL_TCP, 5688, 5689);
212  RANGE (PORT_PROTOCOL_TCP, 5693, 5693);
213  RANGE (PORT_PROTOCOL_TCP, 5696, 5696);
214  RANGE (PORT_PROTOCOL_TCP, 5713, 5730);
215  RANGE (PORT_PROTOCOL_TCP, 5741, 5748);
216  RANGE (PORT_PROTOCOL_TCP, 5750, 5750);
217  RANGE (PORT_PROTOCOL_TCP, 5755, 5755);
218  RANGE (PORT_PROTOCOL_TCP, 5757, 5757);
219  RANGE (PORT_PROTOCOL_TCP, 5766, 5771);
220  RANGE (PORT_PROTOCOL_TCP, 5777, 5777);
221  RANGE (PORT_PROTOCOL_TCP, 5780, 5783);
222  RANGE (PORT_PROTOCOL_TCP, 5785, 5785);
223  RANGE (PORT_PROTOCOL_TCP, 5793, 5793);
224  RANGE (PORT_PROTOCOL_TCP, 5813, 5814);
225  RANGE (PORT_PROTOCOL_TCP, 5842, 5842);
226  RANGE (PORT_PROTOCOL_TCP, 5859, 5859);
227  RANGE (PORT_PROTOCOL_TCP, 5863, 5863);
228  RANGE (PORT_PROTOCOL_TCP, 5883, 5883);
229  RANGE (PORT_PROTOCOL_TCP, 5900, 5900);
230  RANGE (PORT_PROTOCOL_TCP, 5910, 5913);
231  RANGE (PORT_PROTOCOL_TCP, 5963, 5963);
232  RANGE (PORT_PROTOCOL_TCP, 5968, 5969);
233  RANGE (PORT_PROTOCOL_TCP, 5984, 5992);
234  RANGE (PORT_PROTOCOL_TCP, 5999, 6066);
235  RANGE (PORT_PROTOCOL_TCP, 6068, 6076);
236  RANGE (PORT_PROTOCOL_TCP, 6084, 6087);
237  RANGE (PORT_PROTOCOL_TCP, 6099, 6117);
238  RANGE (PORT_PROTOCOL_TCP, 6121, 6124);
239  RANGE (PORT_PROTOCOL_TCP, 6133, 6133);
240  RANGE (PORT_PROTOCOL_TCP, 6140, 6149);
241  RANGE (PORT_PROTOCOL_TCP, 6159, 6163);
242  RANGE (PORT_PROTOCOL_TCP, 6200, 6200);
243  RANGE (PORT_PROTOCOL_TCP, 6222, 6222);
244  RANGE (PORT_PROTOCOL_TCP, 6241, 6244);
245  RANGE (PORT_PROTOCOL_TCP, 6251, 6253);
246  RANGE (PORT_PROTOCOL_TCP, 6267, 6269);
247  RANGE (PORT_PROTOCOL_TCP, 6300, 6301);
248  RANGE (PORT_PROTOCOL_TCP, 6306, 6306);
249  RANGE (PORT_PROTOCOL_TCP, 6315, 6316);
250  RANGE (PORT_PROTOCOL_TCP, 6320, 6322);
251  RANGE (PORT_PROTOCOL_TCP, 6324, 6324);
252  RANGE (PORT_PROTOCOL_TCP, 6343, 6343);
253  RANGE (PORT_PROTOCOL_TCP, 6346, 6347);
254  RANGE (PORT_PROTOCOL_TCP, 6350, 6350);
255  RANGE (PORT_PROTOCOL_TCP, 6355, 6355);
256  RANGE (PORT_PROTOCOL_TCP, 6360, 6360);
257  RANGE (PORT_PROTOCOL_TCP, 6370, 6370);
258  RANGE (PORT_PROTOCOL_TCP, 6382, 6382);
259  RANGE (PORT_PROTOCOL_TCP, 6389, 6390);
260  RANGE (PORT_PROTOCOL_TCP, 6417, 6421);
261  RANGE (PORT_PROTOCOL_TCP, 6432, 6432);
262  RANGE (PORT_PROTOCOL_TCP, 6443, 6446);
263  RANGE (PORT_PROTOCOL_TCP, 6455, 6455);
264  RANGE (PORT_PROTOCOL_TCP, 6471, 6471);
265  RANGE (PORT_PROTOCOL_TCP, 6480, 6489);
266  RANGE (PORT_PROTOCOL_TCP, 6500, 6503);
267  RANGE (PORT_PROTOCOL_TCP, 6505, 6510);
268  RANGE (PORT_PROTOCOL_TCP, 6513, 6515);
269  RANGE (PORT_PROTOCOL_TCP, 6543, 6544);
270  RANGE (PORT_PROTOCOL_TCP, 6547, 6551);
271  RANGE (PORT_PROTOCOL_TCP, 6558, 6558);
272  RANGE (PORT_PROTOCOL_TCP, 6566, 6566);
273  RANGE (PORT_PROTOCOL_TCP, 6568, 6568);
274  RANGE (PORT_PROTOCOL_TCP, 6579, 6583);
275  RANGE (PORT_PROTOCOL_TCP, 6600, 6602);
276  RANGE (PORT_PROTOCOL_TCP, 6619, 6628);
277  RANGE (PORT_PROTOCOL_TCP, 6632, 6632);
278  RANGE (PORT_PROTOCOL_TCP, 6655, 6656);
279  RANGE (PORT_PROTOCOL_TCP, 6665, 6673);
280  RANGE (PORT_PROTOCOL_TCP, 6678, 6679);
281  RANGE (PORT_PROTOCOL_TCP, 6687, 6689);
282  RANGE (PORT_PROTOCOL_TCP, 6701, 6703);
283  RANGE (PORT_PROTOCOL_TCP, 6714, 6715);
284  RANGE (PORT_PROTOCOL_TCP, 6767, 6771);
285  RANGE (PORT_PROTOCOL_TCP, 6785, 6791);
286  RANGE (PORT_PROTOCOL_TCP, 6801, 6801);
287  RANGE (PORT_PROTOCOL_TCP, 6817, 6817);
288  RANGE (PORT_PROTOCOL_TCP, 6831, 6831);
289  RANGE (PORT_PROTOCOL_TCP, 6841, 6842);
290  RANGE (PORT_PROTOCOL_TCP, 6850, 6850);
291  RANGE (PORT_PROTOCOL_TCP, 6868, 6868);
292  RANGE (PORT_PROTOCOL_TCP, 6888, 6888);
293  RANGE (PORT_PROTOCOL_TCP, 6901, 6901);
294  RANGE (PORT_PROTOCOL_TCP, 6935, 6936);
295  RANGE (PORT_PROTOCOL_TCP, 6946, 6946);
296  RANGE (PORT_PROTOCOL_TCP, 6951, 6951);
297  RANGE (PORT_PROTOCOL_TCP, 6961, 6966);
298  RANGE (PORT_PROTOCOL_TCP, 6969, 6969);
299  RANGE (PORT_PROTOCOL_TCP, 6997, 7015);
300  RANGE (PORT_PROTOCOL_TCP, 7018, 7025);
301  RANGE (PORT_PROTOCOL_TCP, 7030, 7030);
302  RANGE (PORT_PROTOCOL_TCP, 7070, 7071);
303  RANGE (PORT_PROTOCOL_TCP, 7080, 7080);
304  RANGE (PORT_PROTOCOL_TCP, 7099, 7101);
305  RANGE (PORT_PROTOCOL_TCP, 7121, 7121);
306  RANGE (PORT_PROTOCOL_TCP, 7128, 7129);
307  RANGE (PORT_PROTOCOL_TCP, 7161, 7171);
308  RANGE (PORT_PROTOCOL_TCP, 7173, 7174);
309  RANGE (PORT_PROTOCOL_TCP, 7200, 7201);
310  RANGE (PORT_PROTOCOL_TCP, 7227, 7229);
311  RANGE (PORT_PROTOCOL_TCP, 7237, 7237);
312  RANGE (PORT_PROTOCOL_TCP, 7262, 7262);
313  RANGE (PORT_PROTOCOL_TCP, 7272, 7283);
314  RANGE (PORT_PROTOCOL_TCP, 7365, 7365);
315  RANGE (PORT_PROTOCOL_TCP, 7391, 7395);
316  RANGE (PORT_PROTOCOL_TCP, 7397, 7397);
317  RANGE (PORT_PROTOCOL_TCP, 7400, 7402);
318  RANGE (PORT_PROTOCOL_TCP, 7410, 7410);
319  RANGE (PORT_PROTOCOL_TCP, 7421, 7421);
320  RANGE (PORT_PROTOCOL_TCP, 7426, 7431);
321  RANGE (PORT_PROTOCOL_TCP, 7437, 7437);
322  RANGE (PORT_PROTOCOL_TCP, 7443, 7443);
323  RANGE (PORT_PROTOCOL_TCP, 7473, 7473);
324  RANGE (PORT_PROTOCOL_TCP, 7491, 7491);
325  RANGE (PORT_PROTOCOL_TCP, 7500, 7501);
326  RANGE (PORT_PROTOCOL_TCP, 7508, 7511);
327  RANGE (PORT_PROTOCOL_TCP, 7542, 7549);
328  RANGE (PORT_PROTOCOL_TCP, 7560, 7560);
329  RANGE (PORT_PROTOCOL_TCP, 7563, 7563);
330  RANGE (PORT_PROTOCOL_TCP, 7566, 7566);
331  RANGE (PORT_PROTOCOL_TCP, 7569, 7570);
332  RANGE (PORT_PROTOCOL_TCP, 7588, 7588);
333  RANGE (PORT_PROTOCOL_TCP, 7624, 7624);
334  RANGE (PORT_PROTOCOL_TCP, 7626, 7631);
335  RANGE (PORT_PROTOCOL_TCP, 7633, 7633);
336  RANGE (PORT_PROTOCOL_TCP, 7648, 7648);
337  RANGE (PORT_PROTOCOL_TCP, 7672, 7677);
338  RANGE (PORT_PROTOCOL_TCP, 7680, 7680);
339  RANGE (PORT_PROTOCOL_TCP, 7689, 7689);
340  RANGE (PORT_PROTOCOL_TCP, 7697, 7697);
341  RANGE (PORT_PROTOCOL_TCP, 7700, 7700);
342  RANGE (PORT_PROTOCOL_TCP, 7707, 7708);
343  RANGE (PORT_PROTOCOL_TCP, 7720, 7720);
344  RANGE (PORT_PROTOCOL_TCP, 7724, 7727);
345  RANGE (PORT_PROTOCOL_TCP, 7734, 7734);
346  RANGE (PORT_PROTOCOL_TCP, 7738, 7738);
347  RANGE (PORT_PROTOCOL_TCP, 7741, 7744);
348  RANGE (PORT_PROTOCOL_TCP, 7747, 7747);
349  RANGE (PORT_PROTOCOL_TCP, 7777, 7779);
350  RANGE (PORT_PROTOCOL_TCP, 7781, 7781);
351  RANGE (PORT_PROTOCOL_TCP, 7786, 7787);
352  RANGE (PORT_PROTOCOL_TCP, 7789, 7789);
353  RANGE (PORT_PROTOCOL_TCP, 7794, 7794);
354  RANGE (PORT_PROTOCOL_TCP, 7797, 7801);
355  RANGE (PORT_PROTOCOL_TCP, 7810, 7810);
356  RANGE (PORT_PROTOCOL_TCP, 7845, 7846);
357  RANGE (PORT_PROTOCOL_TCP, 7869, 7871);
358  RANGE (PORT_PROTOCOL_TCP, 7880, 7880);
359  RANGE (PORT_PROTOCOL_TCP, 7887, 7887);
360  RANGE (PORT_PROTOCOL_TCP, 7900, 7903);
361  RANGE (PORT_PROTOCOL_TCP, 7913, 7913);
362  RANGE (PORT_PROTOCOL_TCP, 7932, 7933);
363  RANGE (PORT_PROTOCOL_TCP, 7967, 7967);
364  RANGE (PORT_PROTOCOL_TCP, 7979, 7982);
365  RANGE (PORT_PROTOCOL_TCP, 7997, 7997);
366  RANGE (PORT_PROTOCOL_TCP, 7999, 8003);
367  RANGE (PORT_PROTOCOL_TCP, 8005, 8005);
368  RANGE (PORT_PROTOCOL_TCP, 8008, 8008);
369  RANGE (PORT_PROTOCOL_TCP, 8019, 8022);
370  RANGE (PORT_PROTOCOL_TCP, 8025, 8026);
371  RANGE (PORT_PROTOCOL_TCP, 8032, 8034);
372  RANGE (PORT_PROTOCOL_TCP, 8040, 8040);
373  RANGE (PORT_PROTOCOL_TCP, 8042, 8044);
374  RANGE (PORT_PROTOCOL_TCP, 8051, 8059);
375  RANGE (PORT_PROTOCOL_TCP, 8074, 8074);
376  RANGE (PORT_PROTOCOL_TCP, 8080, 8083);
377  RANGE (PORT_PROTOCOL_TCP, 8086, 8088);
378  RANGE (PORT_PROTOCOL_TCP, 8091, 8091);
379  RANGE (PORT_PROTOCOL_TCP, 8097, 8097);
380  RANGE (PORT_PROTOCOL_TCP, 8100, 8101);
381  RANGE (PORT_PROTOCOL_TCP, 8115, 8116);
382  RANGE (PORT_PROTOCOL_TCP, 8118, 8118);
383  RANGE (PORT_PROTOCOL_TCP, 8121, 8122);
384  RANGE (PORT_PROTOCOL_TCP, 8128, 8132);
385  RANGE (PORT_PROTOCOL_TCP, 8148, 8148);
386  RANGE (PORT_PROTOCOL_TCP, 8160, 8161);
387  RANGE (PORT_PROTOCOL_TCP, 8181, 8184);
388  RANGE (PORT_PROTOCOL_TCP, 8192, 8192);
389  RANGE (PORT_PROTOCOL_TCP, 8194, 8195);
390  RANGE (PORT_PROTOCOL_TCP, 8199, 8201);
391  RANGE (PORT_PROTOCOL_TCP, 8204, 8208);
392  RANGE (PORT_PROTOCOL_TCP, 8230, 8230);
393  RANGE (PORT_PROTOCOL_TCP, 8243, 8243);
394  RANGE (PORT_PROTOCOL_TCP, 8276, 8276);
395  RANGE (PORT_PROTOCOL_TCP, 8280, 8280);
396  RANGE (PORT_PROTOCOL_TCP, 8292, 8294);
397  RANGE (PORT_PROTOCOL_TCP, 8300, 8301);
398  RANGE (PORT_PROTOCOL_TCP, 8320, 8321);
399  RANGE (PORT_PROTOCOL_TCP, 8351, 8351);
400  RANGE (PORT_PROTOCOL_TCP, 8376, 8380);
401  RANGE (PORT_PROTOCOL_TCP, 8383, 8383);
402  RANGE (PORT_PROTOCOL_TCP, 8400, 8405);
403  RANGE (PORT_PROTOCOL_TCP, 8416, 8417);
404  RANGE (PORT_PROTOCOL_TCP, 8442, 8444);
405  RANGE (PORT_PROTOCOL_TCP, 8450, 8450);
406  RANGE (PORT_PROTOCOL_TCP, 8470, 8474);
407  RANGE (PORT_PROTOCOL_TCP, 8500, 8501);
408  RANGE (PORT_PROTOCOL_TCP, 8554, 8555);
409  RANGE (PORT_PROTOCOL_TCP, 8567, 8567);
410  RANGE (PORT_PROTOCOL_TCP, 8600, 8600);
411  RANGE (PORT_PROTOCOL_TCP, 8610, 8615);
412  RANGE (PORT_PROTOCOL_TCP, 8686, 8686);
413  RANGE (PORT_PROTOCOL_TCP, 8699, 8699);
414  RANGE (PORT_PROTOCOL_TCP, 8733, 8733);
415  RANGE (PORT_PROTOCOL_TCP, 8763, 8765);
416  RANGE (PORT_PROTOCOL_TCP, 8770, 8770);
417  RANGE (PORT_PROTOCOL_TCP, 8786, 8787);
418  RANGE (PORT_PROTOCOL_TCP, 8793, 8793);
419  RANGE (PORT_PROTOCOL_TCP, 8800, 8800);
420  RANGE (PORT_PROTOCOL_TCP, 8804, 8804);
421  RANGE (PORT_PROTOCOL_TCP, 8873, 8873);
422  RANGE (PORT_PROTOCOL_TCP, 8880, 8880);
423  RANGE (PORT_PROTOCOL_TCP, 8883, 8883);
424  RANGE (PORT_PROTOCOL_TCP, 8888, 8894);
425  RANGE (PORT_PROTOCOL_TCP, 8899, 8901);
426  RANGE (PORT_PROTOCOL_TCP, 8910, 8913);
427  RANGE (PORT_PROTOCOL_TCP, 8937, 8937);
428  RANGE (PORT_PROTOCOL_TCP, 8953, 8954);
429  RANGE (PORT_PROTOCOL_TCP, 8989, 8991);
430  RANGE (PORT_PROTOCOL_TCP, 8999, 9002);
431  RANGE (PORT_PROTOCOL_TCP, 9008, 9010);
432  RANGE (PORT_PROTOCOL_TCP, 9020, 9026);
433  RANGE (PORT_PROTOCOL_TCP, 9050, 9051);
434  RANGE (PORT_PROTOCOL_TCP, 9080, 9080);
435  RANGE (PORT_PROTOCOL_TCP, 9083, 9092);
436  RANGE (PORT_PROTOCOL_TCP, 9100, 9107);
437  RANGE (PORT_PROTOCOL_TCP, 9119, 9119);
438  RANGE (PORT_PROTOCOL_TCP, 9131, 9131);
439  RANGE (PORT_PROTOCOL_TCP, 9160, 9164);
440  RANGE (PORT_PROTOCOL_TCP, 9191, 9191);
441  RANGE (PORT_PROTOCOL_TCP, 9200, 9217);
442  RANGE (PORT_PROTOCOL_TCP, 9222, 9222);
443  RANGE (PORT_PROTOCOL_TCP, 9255, 9255);
444  RANGE (PORT_PROTOCOL_TCP, 9278, 9285);
445  RANGE (PORT_PROTOCOL_TCP, 9287, 9287);
446  RANGE (PORT_PROTOCOL_TCP, 9292, 9295);
447  RANGE (PORT_PROTOCOL_TCP, 9300, 9300);
448  RANGE (PORT_PROTOCOL_TCP, 9306, 9306);
449  RANGE (PORT_PROTOCOL_TCP, 9312, 9312);
450  RANGE (PORT_PROTOCOL_TCP, 9318, 9318);
451  RANGE (PORT_PROTOCOL_TCP, 9321, 9321);
452  RANGE (PORT_PROTOCOL_TCP, 9343, 9344);
453  RANGE (PORT_PROTOCOL_TCP, 9346, 9346);
454  RANGE (PORT_PROTOCOL_TCP, 9374, 9374);
455  RANGE (PORT_PROTOCOL_TCP, 9380, 9380);
456  RANGE (PORT_PROTOCOL_TCP, 9387, 9390);
457  RANGE (PORT_PROTOCOL_TCP, 9396, 9397);
458  RANGE (PORT_PROTOCOL_TCP, 9400, 9402);
459  RANGE (PORT_PROTOCOL_TCP, 9418, 9418);
460  RANGE (PORT_PROTOCOL_TCP, 9443, 9445);
461  RANGE (PORT_PROTOCOL_TCP, 9450, 9450);
462  RANGE (PORT_PROTOCOL_TCP, 9500, 9500);
463  RANGE (PORT_PROTOCOL_TCP, 9535, 9536);
464  RANGE (PORT_PROTOCOL_TCP, 9555, 9555);
465  RANGE (PORT_PROTOCOL_TCP, 9592, 9600);
466  RANGE (PORT_PROTOCOL_TCP, 9612, 9612);
467  RANGE (PORT_PROTOCOL_TCP, 9614, 9614);
468  RANGE (PORT_PROTOCOL_TCP, 9616, 9618);
469  RANGE (PORT_PROTOCOL_TCP, 9628, 9631);
470  RANGE (PORT_PROTOCOL_TCP, 9640, 9640);
471  RANGE (PORT_PROTOCOL_TCP, 9667, 9668);
472  RANGE (PORT_PROTOCOL_TCP, 9694, 9695);
473  RANGE (PORT_PROTOCOL_TCP, 9700, 9700);
474  RANGE (PORT_PROTOCOL_TCP, 9747, 9747);
475  RANGE (PORT_PROTOCOL_TCP, 9750, 9750);
476  RANGE (PORT_PROTOCOL_TCP, 9753, 9753);
477  RANGE (PORT_PROTOCOL_TCP, 9762, 9762);
478  RANGE (PORT_PROTOCOL_TCP, 9800, 9802);
479  RANGE (PORT_PROTOCOL_TCP, 9875, 9876);
480  RANGE (PORT_PROTOCOL_TCP, 9888, 9889);
481  RANGE (PORT_PROTOCOL_TCP, 9898, 9900);
482  RANGE (PORT_PROTOCOL_TCP, 9909, 9909);
483  RANGE (PORT_PROTOCOL_TCP, 9911, 9911);
484  RANGE (PORT_PROTOCOL_TCP, 9950, 9954);
485  RANGE (PORT_PROTOCOL_TCP, 9966, 9966);
486  RANGE (PORT_PROTOCOL_TCP, 9987, 9988);
487  RANGE (PORT_PROTOCOL_TCP, 9990, 10005);
488  RANGE (PORT_PROTOCOL_TCP, 10007, 10010);
489  RANGE (PORT_PROTOCOL_TCP, 10050, 10051);
490  RANGE (PORT_PROTOCOL_TCP, 10055, 10055);
491  RANGE (PORT_PROTOCOL_TCP, 10080, 10081);
492  RANGE (PORT_PROTOCOL_TCP, 10100, 10104);
493  RANGE (PORT_PROTOCOL_TCP, 10107, 10107);
494  RANGE (PORT_PROTOCOL_TCP, 10110, 10110);
495  RANGE (PORT_PROTOCOL_TCP, 10113, 10117);
496  RANGE (PORT_PROTOCOL_TCP, 10128, 10129);
497  RANGE (PORT_PROTOCOL_TCP, 10160, 10162);
498  RANGE (PORT_PROTOCOL_TCP, 10200, 10201);
499  RANGE (PORT_PROTOCOL_TCP, 10252, 10252);
500  RANGE (PORT_PROTOCOL_TCP, 10260, 10260);
501  RANGE (PORT_PROTOCOL_TCP, 10288, 10288);
502  RANGE (PORT_PROTOCOL_TCP, 10321, 10321);
503  RANGE (PORT_PROTOCOL_TCP, 10540, 10544);
504  RANGE (PORT_PROTOCOL_TCP, 10631, 10631);
505  RANGE (PORT_PROTOCOL_TCP, 10800, 10800);
506  RANGE (PORT_PROTOCOL_TCP, 10805, 10805);
507  RANGE (PORT_PROTOCOL_TCP, 10809, 10809);
508  RANGE (PORT_PROTOCOL_TCP, 10860, 10860);
509  RANGE (PORT_PROTOCOL_TCP, 10990, 10990);
510  RANGE (PORT_PROTOCOL_TCP, 11000, 11001);
511  RANGE (PORT_PROTOCOL_TCP, 11104, 11106);
512  RANGE (PORT_PROTOCOL_TCP, 11111, 11112);
513  RANGE (PORT_PROTOCOL_TCP, 11161, 11165);
514  RANGE (PORT_PROTOCOL_TCP, 11172, 11172);
515  RANGE (PORT_PROTOCOL_TCP, 11174, 11175);
516  RANGE (PORT_PROTOCOL_TCP, 11201, 11201);
517  RANGE (PORT_PROTOCOL_TCP, 11208, 11208);
518  RANGE (PORT_PROTOCOL_TCP, 11211, 11211);
519  RANGE (PORT_PROTOCOL_TCP, 11319, 11321);
520  RANGE (PORT_PROTOCOL_TCP, 11367, 11367);
521  RANGE (PORT_PROTOCOL_TCP, 11371, 11371);
522  RANGE (PORT_PROTOCOL_TCP, 11489, 11489);
523  RANGE (PORT_PROTOCOL_TCP, 11600, 11600);
524  RANGE (PORT_PROTOCOL_TCP, 11720, 11720);
525  RANGE (PORT_PROTOCOL_TCP, 11751, 11751);
526  RANGE (PORT_PROTOCOL_TCP, 11876, 11876);
527  RANGE (PORT_PROTOCOL_TCP, 11967, 11967);
528  RANGE (PORT_PROTOCOL_TCP, 12000, 12008);
529  RANGE (PORT_PROTOCOL_TCP, 12010, 12010);
530  RANGE (PORT_PROTOCOL_TCP, 12012, 12013);
531  RANGE (PORT_PROTOCOL_TCP, 12109, 12109);
532  RANGE (PORT_PROTOCOL_TCP, 12121, 12121);
533  RANGE (PORT_PROTOCOL_TCP, 12168, 12168);
534  RANGE (PORT_PROTOCOL_TCP, 12172, 12172);
535  RANGE (PORT_PROTOCOL_TCP, 12300, 12300);
536  RANGE (PORT_PROTOCOL_TCP, 12321, 12322);
537  RANGE (PORT_PROTOCOL_TCP, 12345, 12345);
538  RANGE (PORT_PROTOCOL_TCP, 12753, 12753);
539  RANGE (PORT_PROTOCOL_TCP, 13160, 13160);
540  RANGE (PORT_PROTOCOL_TCP, 13216, 13218);
541  RANGE (PORT_PROTOCOL_TCP, 13223, 13224);
542  RANGE (PORT_PROTOCOL_TCP, 13400, 13400);
543  RANGE (PORT_PROTOCOL_TCP, 13720, 13722);
544  RANGE (PORT_PROTOCOL_TCP, 13724, 13724);
545  RANGE (PORT_PROTOCOL_TCP, 13782, 13783);
546  RANGE (PORT_PROTOCOL_TCP, 13785, 13786);
547  RANGE (PORT_PROTOCOL_TCP, 13818, 13823);
548  RANGE (PORT_PROTOCOL_TCP, 13929, 13930);
549  RANGE (PORT_PROTOCOL_TCP, 14000, 14001);
550  RANGE (PORT_PROTOCOL_TCP, 14033, 14034);
551  RANGE (PORT_PROTOCOL_TCP, 14141, 14142);
552  RANGE (PORT_PROTOCOL_TCP, 14145, 14145);
553  RANGE (PORT_PROTOCOL_TCP, 14149, 14150);
554  RANGE (PORT_PROTOCOL_TCP, 14154, 14154);
555  RANGE (PORT_PROTOCOL_TCP, 14250, 14250);
556  RANGE (PORT_PROTOCOL_TCP, 14414, 14414);
557  RANGE (PORT_PROTOCOL_TCP, 14936, 14937);
558  RANGE (PORT_PROTOCOL_TCP, 15000, 15000);
559  RANGE (PORT_PROTOCOL_TCP, 15345, 15345);
560  RANGE (PORT_PROTOCOL_TCP, 15363, 15363);
561  RANGE (PORT_PROTOCOL_TCP, 15555, 15555);
562  RANGE (PORT_PROTOCOL_TCP, 15660, 15660);
563  RANGE (PORT_PROTOCOL_TCP, 15740, 15740);
564  RANGE (PORT_PROTOCOL_TCP, 15999, 16002);
565  RANGE (PORT_PROTOCOL_TCP, 16020, 16021);
566  RANGE (PORT_PROTOCOL_TCP, 16161, 16162);
567  RANGE (PORT_PROTOCOL_TCP, 16309, 16311);
568  RANGE (PORT_PROTOCOL_TCP, 16360, 16361);
569  RANGE (PORT_PROTOCOL_TCP, 16367, 16368);
570  RANGE (PORT_PROTOCOL_TCP, 16384, 16384);
571  RANGE (PORT_PROTOCOL_TCP, 16619, 16619);
572  RANGE (PORT_PROTOCOL_TCP, 16900, 16900);
573  RANGE (PORT_PROTOCOL_TCP, 16950, 16950);
574  RANGE (PORT_PROTOCOL_TCP, 16991, 16995);
575  RANGE (PORT_PROTOCOL_TCP, 17007, 17007);
576  RANGE (PORT_PROTOCOL_TCP, 17185, 17185);
577  RANGE (PORT_PROTOCOL_TCP, 17219, 17219);
578  RANGE (PORT_PROTOCOL_TCP, 17221, 17221);
579  RANGE (PORT_PROTOCOL_TCP, 17234, 17235);
580  RANGE (PORT_PROTOCOL_TCP, 17500, 17500);
581  RANGE (PORT_PROTOCOL_TCP, 17729, 17729);
582  RANGE (PORT_PROTOCOL_TCP, 17754, 17756);
583  RANGE (PORT_PROTOCOL_TCP, 17777, 17777);
584  RANGE (PORT_PROTOCOL_TCP, 18000, 18000);
585  RANGE (PORT_PROTOCOL_TCP, 18104, 18104);
586  RANGE (PORT_PROTOCOL_TCP, 18136, 18136);
587  RANGE (PORT_PROTOCOL_TCP, 18181, 18187);
588  RANGE (PORT_PROTOCOL_TCP, 18241, 18241);
589  RANGE (PORT_PROTOCOL_TCP, 18262, 18262);
590  RANGE (PORT_PROTOCOL_TCP, 18463, 18463);
591  RANGE (PORT_PROTOCOL_TCP, 18634, 18635);
592  RANGE (PORT_PROTOCOL_TCP, 18769, 18769);
593  RANGE (PORT_PROTOCOL_TCP, 18881, 18881);
594  RANGE (PORT_PROTOCOL_TCP, 18888, 18888);
595  RANGE (PORT_PROTOCOL_TCP, 19000, 19000);
596  RANGE (PORT_PROTOCOL_TCP, 19020, 19020);
597  RANGE (PORT_PROTOCOL_TCP, 19191, 19191);
598  RANGE (PORT_PROTOCOL_TCP, 19194, 19194);
599  RANGE (PORT_PROTOCOL_TCP, 19283, 19283);
600  RANGE (PORT_PROTOCOL_TCP, 19315, 19315);
601  RANGE (PORT_PROTOCOL_TCP, 19398, 19398);
602  RANGE (PORT_PROTOCOL_TCP, 19410, 19412);
603  RANGE (PORT_PROTOCOL_TCP, 19539, 19541);
604  RANGE (PORT_PROTOCOL_TCP, 19998, 20003);
605  RANGE (PORT_PROTOCOL_TCP, 20005, 20005);
606  RANGE (PORT_PROTOCOL_TCP, 20013, 20014);
607  RANGE (PORT_PROTOCOL_TCP, 20034, 20034);
608  RANGE (PORT_PROTOCOL_TCP, 20046, 20046);
609  RANGE (PORT_PROTOCOL_TCP, 20048, 20049);
610  RANGE (PORT_PROTOCOL_TCP, 20167, 20167);
611  RANGE (PORT_PROTOCOL_TCP, 20202, 20202);
612  RANGE (PORT_PROTOCOL_TCP, 20222, 20222);
613  RANGE (PORT_PROTOCOL_TCP, 20480, 20480);
614  RANGE (PORT_PROTOCOL_TCP, 20670, 20670);
615  RANGE (PORT_PROTOCOL_TCP, 20999, 21000);
616  RANGE (PORT_PROTOCOL_TCP, 21553, 21554);
617  RANGE (PORT_PROTOCOL_TCP, 21590, 21590);
618  RANGE (PORT_PROTOCOL_TCP, 21800, 21800);
619  RANGE (PORT_PROTOCOL_TCP, 21845, 21849);
620  RANGE (PORT_PROTOCOL_TCP, 22000, 22005);
621  RANGE (PORT_PROTOCOL_TCP, 22125, 22125);
622  RANGE (PORT_PROTOCOL_TCP, 22128, 22128);
623  RANGE (PORT_PROTOCOL_TCP, 22273, 22273);
624  RANGE (PORT_PROTOCOL_TCP, 22305, 22305);
625  RANGE (PORT_PROTOCOL_TCP, 22343, 22343);
626  RANGE (PORT_PROTOCOL_TCP, 22347, 22347);
627  RANGE (PORT_PROTOCOL_TCP, 22350, 22350);
628  RANGE (PORT_PROTOCOL_TCP, 22537, 22537);
629  RANGE (PORT_PROTOCOL_TCP, 22555, 22555);
630  RANGE (PORT_PROTOCOL_TCP, 22763, 22763);
631  RANGE (PORT_PROTOCOL_TCP, 22800, 22800);
632  RANGE (PORT_PROTOCOL_TCP, 22951, 22951);
633  RANGE (PORT_PROTOCOL_TCP, 23000, 23005);
634  RANGE (PORT_PROTOCOL_TCP, 23053, 23053);
635  RANGE (PORT_PROTOCOL_TCP, 23333, 23333);
636  RANGE (PORT_PROTOCOL_TCP, 23400, 23402);
637  RANGE (PORT_PROTOCOL_TCP, 23456, 23457);
638  RANGE (PORT_PROTOCOL_TCP, 24000, 24006);
639  RANGE (PORT_PROTOCOL_TCP, 24242, 24242);
640  RANGE (PORT_PROTOCOL_TCP, 24249, 24249);
641  RANGE (PORT_PROTOCOL_TCP, 24321, 24321);
642  RANGE (PORT_PROTOCOL_TCP, 24386, 24386);
643  RANGE (PORT_PROTOCOL_TCP, 24465, 24465);
644  RANGE (PORT_PROTOCOL_TCP, 24554, 24554);
645  RANGE (PORT_PROTOCOL_TCP, 24676, 24678);
646  RANGE (PORT_PROTOCOL_TCP, 24680, 24680);
647  RANGE (PORT_PROTOCOL_TCP, 24754, 24754);
648  RANGE (PORT_PROTOCOL_TCP, 24922, 24922);
649  RANGE (PORT_PROTOCOL_TCP, 25000, 25009);
650  RANGE (PORT_PROTOCOL_TCP, 25576, 25576);
651  RANGE (PORT_PROTOCOL_TCP, 25604, 25604);
652  RANGE (PORT_PROTOCOL_TCP, 25793, 25793);
653  RANGE (PORT_PROTOCOL_TCP, 25900, 25903);
654  RANGE (PORT_PROTOCOL_TCP, 26000, 26000);
655  RANGE (PORT_PROTOCOL_TCP, 26133, 26133);
656  RANGE (PORT_PROTOCOL_TCP, 26208, 26208);
657  RANGE (PORT_PROTOCOL_TCP, 26260, 26263);
658  RANGE (PORT_PROTOCOL_TCP, 26486, 26487);
659  RANGE (PORT_PROTOCOL_TCP, 26489, 26489);
660  RANGE (PORT_PROTOCOL_TCP, 27345, 27345);
661  RANGE (PORT_PROTOCOL_TCP, 27442, 27442);
662  RANGE (PORT_PROTOCOL_TCP, 27504, 27504);
663  RANGE (PORT_PROTOCOL_TCP, 27782, 27782);
664  RANGE (PORT_PROTOCOL_TCP, 27999, 28001);
665  RANGE (PORT_PROTOCOL_TCP, 28240, 28240);
666  RANGE (PORT_PROTOCOL_TCP, 29167, 29167);
667  RANGE (PORT_PROTOCOL_TCP, 30001, 30002);
668  RANGE (PORT_PROTOCOL_TCP, 30260, 30260);
669  RANGE (PORT_PROTOCOL_TCP, 30999, 30999);
670  RANGE (PORT_PROTOCOL_TCP, 31020, 31020);
671  RANGE (PORT_PROTOCOL_TCP, 31416, 31416);
672  RANGE (PORT_PROTOCOL_TCP, 31457, 31457);
673  RANGE (PORT_PROTOCOL_TCP, 31620, 31620);
674  RANGE (PORT_PROTOCOL_TCP, 31685, 31685);
675  RANGE (PORT_PROTOCOL_TCP, 31765, 31765);
676  RANGE (PORT_PROTOCOL_TCP, 31948, 31949);
677  RANGE (PORT_PROTOCOL_TCP, 32034, 32034);
678  RANGE (PORT_PROTOCOL_TCP, 32249, 32249);
679  RANGE (PORT_PROTOCOL_TCP, 32483, 32483);
680  RANGE (PORT_PROTOCOL_TCP, 32635, 32636);
681  RANGE (PORT_PROTOCOL_TCP, 32767, 32777);
682  RANGE (PORT_PROTOCOL_TCP, 32801, 32801);
683  RANGE (PORT_PROTOCOL_TCP, 32811, 32811);
684  RANGE (PORT_PROTOCOL_TCP, 32896, 32896);
685  RANGE (PORT_PROTOCOL_TCP, 33123, 33123);
686  RANGE (PORT_PROTOCOL_TCP, 33331, 33331);
687  RANGE (PORT_PROTOCOL_TCP, 33333, 33334);
688  RANGE (PORT_PROTOCOL_TCP, 33434, 33434);
689  RANGE (PORT_PROTOCOL_TCP, 33656, 33656);
690  RANGE (PORT_PROTOCOL_TCP, 34249, 34249);
691  RANGE (PORT_PROTOCOL_TCP, 34378, 34379);
692  RANGE (PORT_PROTOCOL_TCP, 34567, 34567);
693  RANGE (PORT_PROTOCOL_TCP, 34962, 34964);
694  RANGE (PORT_PROTOCOL_TCP, 34980, 34980);
695  RANGE (PORT_PROTOCOL_TCP, 35354, 35357);
696  RANGE (PORT_PROTOCOL_TCP, 36001, 36001);
697  RANGE (PORT_PROTOCOL_TCP, 36524, 36524);
698  RANGE (PORT_PROTOCOL_TCP, 36865, 36865);
699  RANGE (PORT_PROTOCOL_TCP, 37475, 37475);
700  RANGE (PORT_PROTOCOL_TCP, 37654, 37654);
701  RANGE (PORT_PROTOCOL_TCP, 38201, 38203);
702  RANGE (PORT_PROTOCOL_TCP, 39681, 39681);
703  RANGE (PORT_PROTOCOL_TCP, 40000, 40000);
704  RANGE (PORT_PROTOCOL_TCP, 40841, 40843);
705  RANGE (PORT_PROTOCOL_TCP, 41111, 41111);
706  RANGE (PORT_PROTOCOL_TCP, 41121, 41121);
707  RANGE (PORT_PROTOCOL_TCP, 41794, 41795);
708  RANGE (PORT_PROTOCOL_TCP, 42508, 42510);
709  RANGE (PORT_PROTOCOL_TCP, 43188, 43191);
710  RANGE (PORT_PROTOCOL_TCP, 43439, 43441);
711  RANGE (PORT_PROTOCOL_TCP, 44321, 44322);
712  RANGE (PORT_PROTOCOL_TCP, 44553, 44553);
713  RANGE (PORT_PROTOCOL_TCP, 44818, 44818);
714  RANGE (PORT_PROTOCOL_TCP, 45000, 45001);
715  RANGE (PORT_PROTOCOL_TCP, 45054, 45054);
716  RANGE (PORT_PROTOCOL_TCP, 45678, 45678);
717  RANGE (PORT_PROTOCOL_TCP, 45825, 45825);
718  RANGE (PORT_PROTOCOL_TCP, 45966, 45966);
719  RANGE (PORT_PROTOCOL_TCP, 46999, 47001);
720  RANGE (PORT_PROTOCOL_TCP, 47557, 47557);
721  RANGE (PORT_PROTOCOL_TCP, 47624, 47624);
722  RANGE (PORT_PROTOCOL_TCP, 47806, 47806);
723  RANGE (PORT_PROTOCOL_TCP, 47808, 47808);
724  RANGE (PORT_PROTOCOL_TCP, 48000, 48005);
725  RANGE (PORT_PROTOCOL_TCP, 48049, 48049);
726  RANGE (PORT_PROTOCOL_TCP, 48128, 48129);
727  RANGE (PORT_PROTOCOL_TCP, 48556, 48556);
728  RANGE (PORT_PROTOCOL_TCP, 48619, 48619);
729 }
#define RANGE(type, start, end)
Insert a port range.

◆ make_port_ranges_iana_tcp_udp_2012()

void make_port_ranges_iana_tcp_udp_2012 ( port_list_t  list)

Make port ranges for IANA TCP and UDP 2012.

Caller must lock the db.

Parameters
[in]listPort list.

Definition at line 48 of file manage_ranges_iana_tcp_udp_2012.c.

References RANGE.

49 {
50  RANGE (PORT_PROTOCOL_TCP, 1, 80);
51  RANGE (PORT_PROTOCOL_TCP, 82, 113);
52  RANGE (PORT_PROTOCOL_TCP, 115, 224);
53  RANGE (PORT_PROTOCOL_TCP, 242, 248);
54  RANGE (PORT_PROTOCOL_TCP, 256, 257);
55  RANGE (PORT_PROTOCOL_TCP, 259, 269);
56  RANGE (PORT_PROTOCOL_TCP, 280, 284);
57  RANGE (PORT_PROTOCOL_TCP, 286, 287);
58  RANGE (PORT_PROTOCOL_TCP, 308, 322);
59  RANGE (PORT_PROTOCOL_TCP, 333, 333);
60  RANGE (PORT_PROTOCOL_TCP, 344, 584);
61  RANGE (PORT_PROTOCOL_TCP, 586, 658);
62  RANGE (PORT_PROTOCOL_TCP, 660, 702);
63  RANGE (PORT_PROTOCOL_TCP, 704, 707);
64  RANGE (PORT_PROTOCOL_TCP, 709, 715);
65  RANGE (PORT_PROTOCOL_TCP, 729, 731);
66  RANGE (PORT_PROTOCOL_TCP, 741, 742);
67  RANGE (PORT_PROTOCOL_TCP, 744, 744);
68  RANGE (PORT_PROTOCOL_TCP, 747, 754);
69  RANGE (PORT_PROTOCOL_TCP, 758, 765);
70  RANGE (PORT_PROTOCOL_TCP, 767, 767);
71  RANGE (PORT_PROTOCOL_TCP, 769, 777);
72  RANGE (PORT_PROTOCOL_TCP, 780, 780);
73  RANGE (PORT_PROTOCOL_TCP, 800, 801);
74  RANGE (PORT_PROTOCOL_TCP, 810, 810);
75  RANGE (PORT_PROTOCOL_TCP, 828, 833);
76  RANGE (PORT_PROTOCOL_TCP, 847, 848);
77  RANGE (PORT_PROTOCOL_TCP, 860, 862);
78  RANGE (PORT_PROTOCOL_TCP, 873, 873);
79  RANGE (PORT_PROTOCOL_TCP, 886, 888);
80  RANGE (PORT_PROTOCOL_TCP, 900, 903);
81  RANGE (PORT_PROTOCOL_TCP, 910, 913);
82  RANGE (PORT_PROTOCOL_TCP, 989, 993);
83  RANGE (PORT_PROTOCOL_TCP, 995, 1000);
84  RANGE (PORT_PROTOCOL_TCP, 1010, 1010);
85  RANGE (PORT_PROTOCOL_TCP, 1021, 1022);
86  RANGE (PORT_PROTOCOL_TCP, 1025, 1027);
87  RANGE (PORT_PROTOCOL_TCP, 1029, 1108);
88  RANGE (PORT_PROTOCOL_TCP, 1110, 1490);
89  RANGE (PORT_PROTOCOL_TCP, 1492, 1527);
90  RANGE (PORT_PROTOCOL_TCP, 1529, 1782);
91  RANGE (PORT_PROTOCOL_TCP, 1784, 2193);
92  RANGE (PORT_PROTOCOL_TCP, 2197, 2258);
93  RANGE (PORT_PROTOCOL_TCP, 2260, 2368);
94  RANGE (PORT_PROTOCOL_TCP, 2370, 2374);
95  RANGE (PORT_PROTOCOL_TCP, 2381, 2425);
96  RANGE (PORT_PROTOCOL_TCP, 2427, 2681);
97  RANGE (PORT_PROTOCOL_TCP, 2683, 2793);
98  RANGE (PORT_PROTOCOL_TCP, 2795, 2824);
99  RANGE (PORT_PROTOCOL_TCP, 2826, 2872);
100  RANGE (PORT_PROTOCOL_TCP, 2874, 2924);
101  RANGE (PORT_PROTOCOL_TCP, 2926, 3000);
102  RANGE (PORT_PROTOCOL_TCP, 3002, 3091);
103  RANGE (PORT_PROTOCOL_TCP, 3093, 3096);
104  RANGE (PORT_PROTOCOL_TCP, 3098, 3120);
105  RANGE (PORT_PROTOCOL_TCP, 3122, 3125);
106  RANGE (PORT_PROTOCOL_TCP, 3127, 3299);
107  RANGE (PORT_PROTOCOL_TCP, 3302, 3321);
108  RANGE (PORT_PROTOCOL_TCP, 3326, 3366);
109  RANGE (PORT_PROTOCOL_TCP, 3372, 3402);
110  RANGE (PORT_PROTOCOL_TCP, 3405, 3545);
111  RANGE (PORT_PROTOCOL_TCP, 3547, 3692);
112  RANGE (PORT_PROTOCOL_TCP, 3695, 3765);
113  RANGE (PORT_PROTOCOL_TCP, 3767, 3993);
114  RANGE (PORT_PROTOCOL_TCP, 3995, 4047);
115  RANGE (PORT_PROTOCOL_TCP, 4049, 4076);
116  RANGE (PORT_PROTOCOL_TCP, 4078, 4083);
117  RANGE (PORT_PROTOCOL_TCP, 4085, 4085);
118  RANGE (PORT_PROTOCOL_TCP, 4087, 4119);
119  RANGE (PORT_PROTOCOL_TCP, 4121, 4143);
120  RANGE (PORT_PROTOCOL_TCP, 4145, 4172);
121  RANGE (PORT_PROTOCOL_TCP, 4174, 4190);
122  RANGE (PORT_PROTOCOL_TCP, 4192, 4193);
123  RANGE (PORT_PROTOCOL_TCP, 4199, 4199);
124  RANGE (PORT_PROTOCOL_TCP, 4300, 4313);
125  RANGE (PORT_PROTOCOL_TCP, 4320, 4329);
126  RANGE (PORT_PROTOCOL_TCP, 4340, 4360);
127  RANGE (PORT_PROTOCOL_TCP, 4368, 4379);
128  RANGE (PORT_PROTOCOL_TCP, 4389, 4393);
129  RANGE (PORT_PROTOCOL_TCP, 4395, 4396);
130  RANGE (PORT_PROTOCOL_TCP, 4400, 4410);
131  RANGE (PORT_PROTOCOL_TCP, 4425, 4431);
132  RANGE (PORT_PROTOCOL_TCP, 4433, 4433);
133  RANGE (PORT_PROTOCOL_TCP, 4442, 4458);
134  RANGE (PORT_PROTOCOL_TCP, 4484, 4488);
135  RANGE (PORT_PROTOCOL_TCP, 4500, 4500);
136  RANGE (PORT_PROTOCOL_TCP, 4535, 4538);
137  RANGE (PORT_PROTOCOL_TCP, 4545, 4556);
138  RANGE (PORT_PROTOCOL_TCP, 4559, 4559);
139  RANGE (PORT_PROTOCOL_TCP, 4566, 4569);
140  RANGE (PORT_PROTOCOL_TCP, 4590, 4591);
141  RANGE (PORT_PROTOCOL_TCP, 4593, 4603);
142  RANGE (PORT_PROTOCOL_TCP, 4658, 4692);
143  RANGE (PORT_PROTOCOL_TCP, 4700, 4704);
144  RANGE (PORT_PROTOCOL_TCP, 4725, 4725);
145  RANGE (PORT_PROTOCOL_TCP, 4727, 4728);
146  RANGE (PORT_PROTOCOL_TCP, 4730, 4731);
147  RANGE (PORT_PROTOCOL_TCP, 4733, 4733);
148  RANGE (PORT_PROTOCOL_TCP, 4737, 4745);
149  RANGE (PORT_PROTOCOL_TCP, 4749, 4752);
150  RANGE (PORT_PROTOCOL_TCP, 4784, 4784);
151  RANGE (PORT_PROTOCOL_TCP, 4786, 4788);
152  RANGE (PORT_PROTOCOL_TCP, 4800, 4803);
153  RANGE (PORT_PROTOCOL_TCP, 4827, 4827);
154  RANGE (PORT_PROTOCOL_TCP, 4837, 4851);
155  RANGE (PORT_PROTOCOL_TCP, 4867, 4871);
156  RANGE (PORT_PROTOCOL_TCP, 4876, 4877);
157  RANGE (PORT_PROTOCOL_TCP, 4879, 4880);
158  RANGE (PORT_PROTOCOL_TCP, 4883, 4885);
159  RANGE (PORT_PROTOCOL_TCP, 4894, 4894);
160  RANGE (PORT_PROTOCOL_TCP, 4899, 4902);
161  RANGE (PORT_PROTOCOL_TCP, 4912, 4915);
162  RANGE (PORT_PROTOCOL_TCP, 4940, 4942);
163  RANGE (PORT_PROTOCOL_TCP, 4949, 4953);
164  RANGE (PORT_PROTOCOL_TCP, 4969, 4970);
165  RANGE (PORT_PROTOCOL_TCP, 4984, 4991);
166  RANGE (PORT_PROTOCOL_TCP, 4999, 5013);
167  RANGE (PORT_PROTOCOL_TCP, 5015, 5015);
168  RANGE (PORT_PROTOCOL_TCP, 5020, 5030);
169  RANGE (PORT_PROTOCOL_TCP, 5032, 5032);
170  RANGE (PORT_PROTOCOL_TCP, 5042, 5045);
171  RANGE (PORT_PROTOCOL_TCP, 5048, 5057);
172  RANGE (PORT_PROTOCOL_TCP, 5059, 5074);
173  RANGE (PORT_PROTOCOL_TCP, 5080, 5086);
174  RANGE (PORT_PROTOCOL_TCP, 5093, 5094);
175  RANGE (PORT_PROTOCOL_TCP, 5099, 5103);
176  RANGE (PORT_PROTOCOL_TCP, 5111, 5112);
177  RANGE (PORT_PROTOCOL_TCP, 5114, 5115);
178  RANGE (PORT_PROTOCOL_TCP, 5117, 5117);
179  RANGE (PORT_PROTOCOL_TCP, 5133, 5135);
180  RANGE (PORT_PROTOCOL_TCP, 5137, 5137);
181  RANGE (PORT_PROTOCOL_TCP, 5145, 5146);
182  RANGE (PORT_PROTOCOL_TCP, 5150, 5157);
183  RANGE (PORT_PROTOCOL_TCP, 5161, 5168);
184  RANGE (PORT_PROTOCOL_TCP, 5190, 5194);
185  RANGE (PORT_PROTOCOL_TCP, 5200, 5203);
186  RANGE (PORT_PROTOCOL_TCP, 5221, 5228);
187  RANGE (PORT_PROTOCOL_TCP, 5232, 5237);
188  RANGE (PORT_PROTOCOL_TCP, 5245, 5245);
189  RANGE (PORT_PROTOCOL_TCP, 5248, 5253);
190  RANGE (PORT_PROTOCOL_TCP, 5264, 5265);
191  RANGE (PORT_PROTOCOL_TCP, 5269, 5272);
192  RANGE (PORT_PROTOCOL_TCP, 5280, 5282);
193  RANGE (PORT_PROTOCOL_TCP, 5298, 5310);
194  RANGE (PORT_PROTOCOL_TCP, 5312, 5318);
195  RANGE (PORT_PROTOCOL_TCP, 5320, 5321);
196  RANGE (PORT_PROTOCOL_TCP, 5343, 5344);
197  RANGE (PORT_PROTOCOL_TCP, 5349, 5363);
198  RANGE (PORT_PROTOCOL_TCP, 5397, 5435);
199  RANGE (PORT_PROTOCOL_TCP, 5443, 5443);
200  RANGE (PORT_PROTOCOL_TCP, 5453, 5456);
201  RANGE (PORT_PROTOCOL_TCP, 5461, 5465);
202  RANGE (PORT_PROTOCOL_TCP, 5500, 5506);
203  RANGE (PORT_PROTOCOL_TCP, 5553, 5557);
204  RANGE (PORT_PROTOCOL_TCP, 5566, 5568);
205  RANGE (PORT_PROTOCOL_TCP, 5573, 5575);
206  RANGE (PORT_PROTOCOL_TCP, 5579, 5585);
207  RANGE (PORT_PROTOCOL_TCP, 5597, 5605);
208  RANGE (PORT_PROTOCOL_TCP, 5627, 5638);
209  RANGE (PORT_PROTOCOL_TCP, 5646, 5646);
210  RANGE (PORT_PROTOCOL_TCP, 5671, 5681);
211  RANGE (PORT_PROTOCOL_TCP, 5688, 5689);
212  RANGE (PORT_PROTOCOL_TCP, 5693, 5693);
213  RANGE (PORT_PROTOCOL_TCP, 5696, 5696);
214  RANGE (PORT_PROTOCOL_TCP, 5713, 5730);
215  RANGE (PORT_PROTOCOL_TCP, 5741, 5748);
216  RANGE (PORT_PROTOCOL_TCP, 5750, 5750);
217  RANGE (PORT_PROTOCOL_TCP, 5755, 5755);
218  RANGE (PORT_PROTOCOL_TCP, 5757, 5757);
219  RANGE (PORT_PROTOCOL_TCP, 5766, 5771);
220  RANGE (PORT_PROTOCOL_TCP, 5777, 5777);
221  RANGE (PORT_PROTOCOL_TCP, 5780, 5783);
222  RANGE (PORT_PROTOCOL_TCP, 5785, 5785);
223  RANGE (PORT_PROTOCOL_TCP, 5793, 5793);
224  RANGE (PORT_PROTOCOL_TCP, 5813, 5814);
225  RANGE (PORT_PROTOCOL_TCP, 5842, 5842);
226  RANGE (PORT_PROTOCOL_TCP, 5859, 5859);
227  RANGE (PORT_PROTOCOL_TCP, 5863, 5863);
228  RANGE (PORT_PROTOCOL_TCP, 5883, 5883);
229  RANGE (PORT_PROTOCOL_TCP, 5900, 5900);
230  RANGE (PORT_PROTOCOL_TCP, 5910, 5913);
231  RANGE (PORT_PROTOCOL_TCP, 5963, 5963);
232  RANGE (PORT_PROTOCOL_TCP, 5968, 5969);
233  RANGE (PORT_PROTOCOL_TCP, 5984, 5992);
234  RANGE (PORT_PROTOCOL_TCP, 5999, 6066);
235  RANGE (PORT_PROTOCOL_TCP, 6068, 6076);
236  RANGE (PORT_PROTOCOL_TCP, 6084, 6087);
237  RANGE (PORT_PROTOCOL_TCP, 6099, 6117);
238  RANGE (PORT_PROTOCOL_TCP, 6121, 6124);
239  RANGE (PORT_PROTOCOL_TCP, 6133, 6133);
240  RANGE (PORT_PROTOCOL_TCP, 6140, 6149);
241  RANGE (PORT_PROTOCOL_TCP, 6159, 6163);
242  RANGE (PORT_PROTOCOL_TCP, 6200, 6200);
243  RANGE (PORT_PROTOCOL_TCP, 6222, 6222);
244  RANGE (PORT_PROTOCOL_TCP, 6241, 6244);
245  RANGE (PORT_PROTOCOL_TCP, 6251, 6253);
246  RANGE (PORT_PROTOCOL_TCP, 6267, 6269);
247  RANGE (PORT_PROTOCOL_TCP, 6300, 6301);
248  RANGE (PORT_PROTOCOL_TCP, 6306, 6306);
249  RANGE (PORT_PROTOCOL_TCP, 6315, 6316);
250  RANGE (PORT_PROTOCOL_TCP, 6320, 6322);
251  RANGE (PORT_PROTOCOL_TCP, 6324, 6324);
252  RANGE (PORT_PROTOCOL_TCP, 6343, 6343);
253  RANGE (PORT_PROTOCOL_TCP, 6346, 6347);
254  RANGE (PORT_PROTOCOL_TCP, 6350, 6350);
255  RANGE (PORT_PROTOCOL_TCP, 6355, 6355);
256  RANGE (PORT_PROTOCOL_TCP, 6360, 6360);
257  RANGE (PORT_PROTOCOL_TCP, 6370, 6370);
258  RANGE (PORT_PROTOCOL_TCP, 6382, 6382);
259  RANGE (PORT_PROTOCOL_TCP, 6389, 6390);
260  RANGE (PORT_PROTOCOL_TCP, 6417, 6421);
261  RANGE (PORT_PROTOCOL_TCP, 6432, 6432);
262  RANGE (PORT_PROTOCOL_TCP, 6443, 6446);
263  RANGE (PORT_PROTOCOL_TCP, 6455, 6455);
264  RANGE (PORT_PROTOCOL_TCP, 6471, 6471);
265  RANGE (PORT_PROTOCOL_TCP, 6480, 6489);
266  RANGE (PORT_PROTOCOL_TCP, 6500, 6503);
267  RANGE (PORT_PROTOCOL_TCP, 6505, 6510);
268  RANGE (PORT_PROTOCOL_TCP, 6513, 6515);
269  RANGE (PORT_PROTOCOL_TCP, 6543, 6544);
270  RANGE (PORT_PROTOCOL_TCP, 6547, 6551);
271  RANGE (PORT_PROTOCOL_TCP, 6558, 6558);
272  RANGE (PORT_PROTOCOL_TCP, 6566, 6566);
273  RANGE (PORT_PROTOCOL_TCP, 6568, 6568);
274  RANGE (PORT_PROTOCOL_TCP, 6579, 6583);
275  RANGE (PORT_PROTOCOL_TCP, 6600, 6602);
276  RANGE (PORT_PROTOCOL_TCP, 6619, 6628);
277  RANGE (PORT_PROTOCOL_TCP, 6632, 6632);
278  RANGE (PORT_PROTOCOL_TCP, 6655, 6656);
279  RANGE (PORT_PROTOCOL_TCP, 6665, 6673);
280  RANGE (PORT_PROTOCOL_TCP, 6678, 6679);
281  RANGE (PORT_PROTOCOL_TCP, 6687, 6689);
282  RANGE (PORT_PROTOCOL_TCP, 6701, 6703);
283  RANGE (PORT_PROTOCOL_TCP, 6714, 6715);
284  RANGE (PORT_PROTOCOL_TCP, 6767, 6771);
285  RANGE (PORT_PROTOCOL_TCP, 6785, 6791);
286  RANGE (PORT_PROTOCOL_TCP, 6801, 6801);
287  RANGE (PORT_PROTOCOL_TCP, 6817, 6817);
288  RANGE (PORT_PROTOCOL_TCP, 6831, 6831);
289  RANGE (PORT_PROTOCOL_TCP, 6841, 6842);
290  RANGE (PORT_PROTOCOL_TCP, 6850, 6850);
291  RANGE (PORT_PROTOCOL_TCP, 6868, 6868);
292  RANGE (PORT_PROTOCOL_TCP, 6888, 6888);
293  RANGE (PORT_PROTOCOL_TCP, 6901, 6901);
294  RANGE (PORT_PROTOCOL_TCP, 6935, 6936);
295  RANGE (PORT_PROTOCOL_TCP, 6946, 6946);
296  RANGE (PORT_PROTOCOL_TCP, 6951, 6951);
297  RANGE (PORT_PROTOCOL_TCP, 6961, 6966);
298  RANGE (PORT_PROTOCOL_TCP, 6969, 6969);
299  RANGE (PORT_PROTOCOL_TCP, 6997, 7015);
300  RANGE (PORT_PROTOCOL_TCP, 7018, 7025);
301  RANGE (PORT_PROTOCOL_TCP, 7030, 7030);
302  RANGE (PORT_PROTOCOL_TCP, 7070, 7071);
303  RANGE (PORT_PROTOCOL_TCP, 7080, 7080);
304  RANGE (PORT_PROTOCOL_TCP, 7099, 7101);
305  RANGE (PORT_PROTOCOL_TCP, 7121, 7121);
306  RANGE (PORT_PROTOCOL_TCP, 7128, 7129);
307  RANGE (PORT_PROTOCOL_TCP, 7161, 7171);
308  RANGE (PORT_PROTOCOL_TCP, 7173, 7174);
309  RANGE (PORT_PROTOCOL_TCP, 7200, 7201);
310  RANGE (PORT_PROTOCOL_TCP, 7227, 7229);
311  RANGE (PORT_PROTOCOL_TCP, 7237, 7237);
312  RANGE (PORT_PROTOCOL_TCP, 7262, 7262);
313  RANGE (PORT_PROTOCOL_TCP, 7272, 7283);
314  RANGE (PORT_PROTOCOL_TCP, 7365, 7365);
315  RANGE (PORT_PROTOCOL_TCP, 7391, 7395);
316  RANGE (PORT_PROTOCOL_TCP, 7397, 7397);
317  RANGE (PORT_PROTOCOL_TCP, 7400, 7402);
318  RANGE (PORT_PROTOCOL_TCP, 7410, 7410);
319  RANGE (PORT_PROTOCOL_TCP, 7421, 7421);
320  RANGE (PORT_PROTOCOL_TCP, 7426, 7431);
321  RANGE (PORT_PROTOCOL_TCP, 7437, 7437);
322  RANGE (PORT_PROTOCOL_TCP, 7443, 7443);
323  RANGE (PORT_PROTOCOL_TCP, 7473, 7473);
324  RANGE (PORT_PROTOCOL_TCP, 7491, 7491);
325  RANGE (PORT_PROTOCOL_TCP, 7500, 7501);
326  RANGE (PORT_PROTOCOL_TCP, 7508, 7511);
327  RANGE (PORT_PROTOCOL_TCP, 7542, 7549);
328  RANGE (PORT_PROTOCOL_TCP, 7560, 7560);
329  RANGE (PORT_PROTOCOL_TCP, 7563, 7563);
330  RANGE (PORT_PROTOCOL_TCP, 7566, 7566);
331  RANGE (PORT_PROTOCOL_TCP, 7569, 7570);
332  RANGE (PORT_PROTOCOL_TCP, 7588, 7588);
333  RANGE (PORT_PROTOCOL_TCP, 7624, 7624);
334  RANGE (PORT_PROTOCOL_TCP, 7626, 7631);
335  RANGE (PORT_PROTOCOL_TCP, 7633, 7633);
336  RANGE (PORT_PROTOCOL_TCP, 7648, 7648);
337  RANGE (PORT_PROTOCOL_TCP, 7672, 7677);
338  RANGE (PORT_PROTOCOL_TCP, 7680, 7680);
339  RANGE (PORT_PROTOCOL_TCP, 7689, 7689);
340  RANGE (PORT_PROTOCOL_TCP, 7697, 7697);
341  RANGE (PORT_PROTOCOL_TCP, 7700, 7700);
342  RANGE (PORT_PROTOCOL_TCP, 7707, 7708);
343  RANGE (PORT_PROTOCOL_TCP, 7720, 7720);
344  RANGE (PORT_PROTOCOL_TCP, 7724, 7727);
345  RANGE (PORT_PROTOCOL_TCP, 7734, 7734);
346  RANGE (PORT_PROTOCOL_TCP, 7738, 7738);
347  RANGE (PORT_PROTOCOL_TCP, 7741, 7744);
348  RANGE (PORT_PROTOCOL_TCP, 7747, 7747);
349  RANGE (PORT_PROTOCOL_TCP, 7777, 7779);
350  RANGE (PORT_PROTOCOL_TCP, 7781, 7781);
351  RANGE (PORT_PROTOCOL_TCP, 7786, 7787);
352  RANGE (PORT_PROTOCOL_TCP, 7789, 7789);
353  RANGE (PORT_PROTOCOL_TCP, 7794, 7794);
354  RANGE (PORT_PROTOCOL_TCP, 7797, 7801);
355  RANGE (PORT_PROTOCOL_TCP, 7810, 7810);
356  RANGE (PORT_PROTOCOL_TCP, 7845, 7846);
357  RANGE (PORT_PROTOCOL_TCP, 7869, 7871);
358  RANGE (PORT_PROTOCOL_TCP, 7880, 7880);
359  RANGE (PORT_PROTOCOL_TCP, 7887, 7887);
360  RANGE (PORT_PROTOCOL_TCP, 7900, 7903);
361  RANGE (PORT_PROTOCOL_TCP, 7913, 7913);
362  RANGE (PORT_PROTOCOL_TCP, 7932, 7933);
363  RANGE (PORT_PROTOCOL_TCP, 7967, 7967);
364  RANGE (PORT_PROTOCOL_TCP, 7979, 7982);
365  RANGE (PORT_PROTOCOL_TCP, 7997, 7997);
366  RANGE (PORT_PROTOCOL_TCP, 7999, 8003);
367  RANGE (PORT_PROTOCOL_TCP, 8005, 8005);
368  RANGE (PORT_PROTOCOL_TCP, 8008, 8008);
369  RANGE (PORT_PROTOCOL_TCP, 8019, 8022);
370  RANGE (PORT_PROTOCOL_TCP, 8025, 8026);
371  RANGE (PORT_PROTOCOL_TCP, 8032, 8034);
372  RANGE (PORT_PROTOCOL_TCP, 8040, 8040);
373  RANGE (PORT_PROTOCOL_TCP, 8042, 8044);
374  RANGE (PORT_PROTOCOL_TCP, 8051, 8059);
375  RANGE (PORT_PROTOCOL_TCP, 8074, 8074);
376  RANGE (PORT_PROTOCOL_TCP, 8080, 8083);
377  RANGE (PORT_PROTOCOL_TCP, 8086, 8088);
378  RANGE (PORT_PROTOCOL_TCP, 8091, 8091);
379  RANGE (PORT_PROTOCOL_TCP, 8097, 8097);
380  RANGE (PORT_PROTOCOL_TCP, 8100, 8101);
381  RANGE (PORT_PROTOCOL_TCP, 8115, 8116);
382  RANGE (PORT_PROTOCOL_TCP, 8118, 8118);
383  RANGE (PORT_PROTOCOL_TCP, 8121, 8122);
384  RANGE (PORT_PROTOCOL_TCP, 8128, 8132);
385  RANGE (PORT_PROTOCOL_TCP, 8148, 8148);
386  RANGE (PORT_PROTOCOL_TCP, 8160, 8161);
387  RANGE (PORT_PROTOCOL_TCP, 8181, 8184);
388  RANGE (PORT_PROTOCOL_TCP, 8192, 8192);
389  RANGE (PORT_PROTOCOL_TCP, 8194, 8195);
390  RANGE (PORT_PROTOCOL_TCP, 8199, 8201);
391  RANGE (PORT_PROTOCOL_TCP, 8204, 8208);
392  RANGE (PORT_PROTOCOL_TCP, 8230, 8230);
393  RANGE (PORT_PROTOCOL_TCP, 8243, 8243);
394  RANGE (PORT_PROTOCOL_TCP, 8276, 8276);
395  RANGE (PORT_PROTOCOL_TCP, 8280, 8280);
396  RANGE (PORT_PROTOCOL_TCP, 8292, 8294);
397  RANGE (PORT_PROTOCOL_TCP, 8300, 8301);
398  RANGE (PORT_PROTOCOL_TCP, 8320, 8321);
399  RANGE (PORT_PROTOCOL_TCP, 8351, 8351);
400  RANGE (PORT_PROTOCOL_TCP, 8376, 8380);
401  RANGE (PORT_PROTOCOL_TCP, 8383, 8383);
402  RANGE (PORT_PROTOCOL_TCP, 8400, 8405);
403  RANGE (PORT_PROTOCOL_TCP, 8416, 8417);
404  RANGE (PORT_PROTOCOL_TCP, 8442, 8444);
405  RANGE (PORT_PROTOCOL_TCP, 8450, 8450);
406  RANGE (PORT_PROTOCOL_TCP, 8470, 8474);
407  RANGE (PORT_PROTOCOL_TCP, 8500, 8501);
408  RANGE (PORT_PROTOCOL_TCP, 8554, 8555);
409  RANGE (PORT_PROTOCOL_TCP, 8567, 8567);
410  RANGE (PORT_PROTOCOL_TCP, 8600, 8600);
411  RANGE (PORT_PROTOCOL_TCP, 8610, 8615);
412  RANGE (PORT_PROTOCOL_TCP, 8686, 8686);
413  RANGE (PORT_PROTOCOL_TCP, 8699, 8699);
414  RANGE (PORT_PROTOCOL_TCP, 8733, 8733);
415  RANGE (PORT_PROTOCOL_TCP, 8763, 8765);
416  RANGE (PORT_PROTOCOL_TCP, 8770, 8770);
417  RANGE (PORT_PROTOCOL_TCP, 8786, 8787);
418  RANGE (PORT_PROTOCOL_TCP, 8793, 8793);
419  RANGE (PORT_PROTOCOL_TCP, 8800, 8800);
420  RANGE (PORT_PROTOCOL_TCP, 8804, 8804);
421  RANGE (PORT_PROTOCOL_TCP, 8873, 8873);
422  RANGE (PORT_PROTOCOL_TCP, 8880, 8880);
423  RANGE (PORT_PROTOCOL_TCP, 8883, 8883);
424  RANGE (PORT_PROTOCOL_TCP, 8888, 8894);
425  RANGE (PORT_PROTOCOL_TCP, 8899, 8901);
426  RANGE (PORT_PROTOCOL_TCP, 8910, 8913);
427  RANGE (PORT_PROTOCOL_TCP, 8937, 8937);
428  RANGE (PORT_PROTOCOL_TCP, 8953, 8954);
429  RANGE (PORT_PROTOCOL_TCP, 8989, 8991);
430  RANGE (PORT_PROTOCOL_TCP, 8999, 9002);
431  RANGE (PORT_PROTOCOL_TCP, 9008, 9010);
432  RANGE (PORT_PROTOCOL_TCP, 9020, 9026);
433  RANGE (PORT_PROTOCOL_TCP, 9050, 9051);
434  RANGE (PORT_PROTOCOL_TCP, 9080, 9080);
435  RANGE (PORT_PROTOCOL_TCP, 9083, 9092);
436  RANGE (PORT_PROTOCOL_TCP, 9100, 9107);
437  RANGE (PORT_PROTOCOL_TCP, 9119, 9119);
438  RANGE (PORT_PROTOCOL_TCP, 9131, 9131);
439  RANGE (PORT_PROTOCOL_TCP, 9160, 9164);
440  RANGE (PORT_PROTOCOL_TCP, 9191, 9191);
441  RANGE (PORT_PROTOCOL_TCP, 9200, 9217);
442  RANGE (PORT_PROTOCOL_TCP, 9222, 9222);
443  RANGE (PORT_PROTOCOL_TCP, 9255, 9255);
444  RANGE (PORT_PROTOCOL_TCP, 9278, 9285);
445  RANGE (PORT_PROTOCOL_TCP, 9287, 9287);
446  RANGE (PORT_PROTOCOL_TCP, 9292, 9295);
447  RANGE (PORT_PROTOCOL_TCP, 9300, 9300);
448  RANGE (PORT_PROTOCOL_TCP, 9306, 9306);
449  RANGE (PORT_PROTOCOL_TCP, 9312, 9312);
450  RANGE (PORT_PROTOCOL_TCP, 9318, 9318);
451  RANGE (PORT_PROTOCOL_TCP, 9321, 9321);
452  RANGE (PORT_PROTOCOL_TCP, 9343, 9344);
453  RANGE (PORT_PROTOCOL_TCP, 9346, 9346);
454  RANGE (PORT_PROTOCOL_TCP, 9374, 9374);
455  RANGE (PORT_PROTOCOL_TCP, 9380, 9380);
456  RANGE (PORT_PROTOCOL_TCP, 9387, 9390);
457  RANGE (PORT_PROTOCOL_TCP, 9396, 9397);
458  RANGE (PORT_PROTOCOL_TCP, 9400, 9402);
459  RANGE (PORT_PROTOCOL_TCP, 9418, 9418);
460  RANGE (PORT_PROTOCOL_TCP, 9443, 9445);
461  RANGE (PORT_PROTOCOL_TCP, 9450, 9450);
462  RANGE (PORT_PROTOCOL_TCP, 9500, 9500);
463  RANGE (PORT_PROTOCOL_TCP, 9535, 9536);
464  RANGE (PORT_PROTOCOL_TCP, 9555, 9555);
465  RANGE (PORT_PROTOCOL_TCP, 9592, 9600);
466  RANGE (PORT_PROTOCOL_TCP, 9612, 9612);
467  RANGE (PORT_PROTOCOL_TCP, 9614, 9614);
468  RANGE (PORT_PROTOCOL_TCP, 9616, 9618);
469  RANGE (PORT_PROTOCOL_TCP, 9628, 9631);
470  RANGE (PORT_PROTOCOL_TCP, 9640, 9640);
471  RANGE (PORT_PROTOCOL_TCP, 9667, 9668);
472  RANGE (PORT_PROTOCOL_TCP, 9694, 9695);
473  RANGE (PORT_PROTOCOL_TCP, 9700, 9700);
474  RANGE (PORT_PROTOCOL_TCP, 9747, 9747);
475  RANGE (PORT_PROTOCOL_TCP, 9750, 9750);
476  RANGE (PORT_PROTOCOL_TCP, 9753, 9753);
477  RANGE (PORT_PROTOCOL_TCP, 9762, 9762);
478  RANGE (PORT_PROTOCOL_TCP, 9800, 9802);
479  RANGE (PORT_PROTOCOL_TCP, 9875, 9876);
480  RANGE (PORT_PROTOCOL_TCP, 9888, 9889);
481  RANGE (PORT_PROTOCOL_TCP, 9898, 9900);
482  RANGE (PORT_PROTOCOL_TCP, 9909, 9909);
483  RANGE (PORT_PROTOCOL_TCP, 9911, 9911);
484  RANGE (PORT_PROTOCOL_TCP, 9950, 9954);
485  RANGE (PORT_PROTOCOL_TCP, 9966, 9966);
486  RANGE (PORT_PROTOCOL_TCP, 9987, 9988);
487  RANGE (PORT_PROTOCOL_TCP, 9990, 10005);
488  RANGE (PORT_PROTOCOL_TCP, 10007, 10010);
489  RANGE (PORT_PROTOCOL_TCP, 10050, 10051);
490  RANGE (PORT_PROTOCOL_TCP, 10055, 10055);
491  RANGE (PORT_PROTOCOL_TCP, 10080, 10081);
492  RANGE (PORT_PROTOCOL_TCP, 10100, 10104);
493  RANGE (PORT_PROTOCOL_TCP, 10107, 10107);
494  RANGE (PORT_PROTOCOL_TCP, 10110, 10110);
495  RANGE (PORT_PROTOCOL_TCP, 10113, 10117);
496  RANGE (PORT_PROTOCOL_TCP, 10128, 10129);
497  RANGE (PORT_PROTOCOL_TCP, 10160, 10162);
498  RANGE (PORT_PROTOCOL_TCP, 10200, 10201);
499  RANGE (PORT_PROTOCOL_TCP, 10252, 10252);
500  RANGE (PORT_PROTOCOL_TCP, 10260, 10260);
501  RANGE (PORT_PROTOCOL_TCP, 10288, 10288);
502  RANGE (PORT_PROTOCOL_TCP, 10321, 10321);
503  RANGE (PORT_PROTOCOL_TCP, 10540, 10544);
504  RANGE (PORT_PROTOCOL_TCP, 10631, 10631);
505  RANGE (PORT_PROTOCOL_TCP, 10800, 10800);
506  RANGE (PORT_PROTOCOL_TCP, 10805, 10805);
507  RANGE (PORT_PROTOCOL_TCP, 10809, 10809);
508  RANGE (PORT_PROTOCOL_TCP, 10860, 10860);
509  RANGE (PORT_PROTOCOL_TCP, 10990, 10990);
510  RANGE (PORT_PROTOCOL_TCP, 11000, 11001);
511  RANGE (PORT_PROTOCOL_TCP, 11104, 11106);
512  RANGE (PORT_PROTOCOL_TCP, 11111, 11112);
513  RANGE (PORT_PROTOCOL_TCP, 11161, 11165);
514  RANGE (PORT_PROTOCOL_TCP, 11172, 11172);
515  RANGE (PORT_PROTOCOL_TCP, 11174, 11175);
516  RANGE (PORT_PROTOCOL_TCP, 11201, 11201);
517  RANGE (PORT_PROTOCOL_TCP, 11208, 11208);
518  RANGE (PORT_PROTOCOL_TCP, 11211, 11211);
519  RANGE (PORT_PROTOCOL_TCP, 11319, 11321);
520  RANGE (PORT_PROTOCOL_TCP, 11367, 11367);
521  RANGE (PORT_PROTOCOL_TCP, 11371, 11371);
522  RANGE (PORT_PROTOCOL_TCP, 11489, 11489);
523  RANGE (PORT_PROTOCOL_TCP, 11600, 11600);
524  RANGE (PORT_PROTOCOL_TCP, 11720, 11720);
525  RANGE (PORT_PROTOCOL_TCP, 11751, 11751);
526  RANGE (PORT_PROTOCOL_TCP, 11876, 11876);
527  RANGE (PORT_PROTOCOL_TCP, 11967, 11967);
528  RANGE (PORT_PROTOCOL_TCP, 12000, 12008);
529  RANGE (PORT_PROTOCOL_TCP, 12010, 12010);
530  RANGE (PORT_PROTOCOL_TCP, 12012, 12013);
531  RANGE (PORT_PROTOCOL_TCP, 12109, 12109);
532  RANGE (PORT_PROTOCOL_TCP, 12121, 12121);
533  RANGE (PORT_PROTOCOL_TCP, 12168, 12168);
534  RANGE (PORT_PROTOCOL_TCP, 12172, 12172);
535  RANGE (PORT_PROTOCOL_TCP, 12300, 12300);
536  RANGE (PORT_PROTOCOL_TCP, 12321, 12322);
537  RANGE (PORT_PROTOCOL_TCP, 12345, 12345);
538  RANGE (PORT_PROTOCOL_TCP, 12753, 12753);
539  RANGE (PORT_PROTOCOL_TCP, 13160, 13160);
540  RANGE (PORT_PROTOCOL_TCP, 13216, 13218);
541  RANGE (PORT_PROTOCOL_TCP, 13223, 13224);
542  RANGE (PORT_PROTOCOL_TCP, 13400, 13400);
543  RANGE (PORT_PROTOCOL_TCP, 13720, 13722);
544  RANGE (PORT_PROTOCOL_TCP, 13724, 13724);
545  RANGE (PORT_PROTOCOL_TCP, 13782, 13783);
546  RANGE (PORT_PROTOCOL_TCP, 13785, 13786);
547  RANGE (PORT_PROTOCOL_TCP, 13818, 13823);
548  RANGE (PORT_PROTOCOL_TCP, 13929, 13930);
549  RANGE (PORT_PROTOCOL_TCP, 14000, 14001);
550  RANGE (PORT_PROTOCOL_TCP, 14033, 14034);
551  RANGE (PORT_PROTOCOL_TCP, 14141, 14142);
552  RANGE (PORT_PROTOCOL_TCP, 14145, 14145);
553  RANGE (PORT_PROTOCOL_TCP, 14149, 14150);
554  RANGE (PORT_PROTOCOL_TCP, 14154, 14154);
555  RANGE (PORT_PROTOCOL_TCP, 14250, 14250);
556  RANGE (PORT_PROTOCOL_TCP, 14414, 14414);
557  RANGE (PORT_PROTOCOL_TCP, 14936, 14937);
558  RANGE (PORT_PROTOCOL_TCP, 15000, 15000);
559  RANGE (PORT_PROTOCOL_TCP, 15345, 15345);
560  RANGE (PORT_PROTOCOL_TCP, 15363, 15363);
561  RANGE (PORT_PROTOCOL_TCP, 15555, 15555);
562  RANGE (PORT_PROTOCOL_TCP, 15660, 15660);
563  RANGE (PORT_PROTOCOL_TCP, 15740, 15740);
564  RANGE (PORT_PROTOCOL_TCP, 15999, 16002);
565  RANGE (PORT_PROTOCOL_TCP, 16020, 16021);
566  RANGE (PORT_PROTOCOL_TCP, 16161, 16162);
567  RANGE (PORT_PROTOCOL_TCP, 16309, 16311);
568  RANGE (PORT_PROTOCOL_TCP, 16360, 16361);
569  RANGE (PORT_PROTOCOL_TCP, 16367, 16368);
570  RANGE (PORT_PROTOCOL_TCP, 16384, 16384);
571  RANGE (PORT_PROTOCOL_TCP, 16619, 16619);
572  RANGE (PORT_PROTOCOL_TCP, 16900, 16900);
573  RANGE (PORT_PROTOCOL_TCP, 16950, 16950);
574  RANGE (PORT_PROTOCOL_TCP, 16991, 16995);
575  RANGE (PORT_PROTOCOL_TCP, 17007, 17007);
576  RANGE (PORT_PROTOCOL_TCP, 17185, 17185);
577  RANGE (PORT_PROTOCOL_TCP, 17219, 17219);
578  RANGE (PORT_PROTOCOL_TCP, 17221, 17221);
579  RANGE (PORT_PROTOCOL_TCP, 17234, 17235);
580  RANGE (PORT_PROTOCOL_TCP, 17500, 17500);
581  RANGE (PORT_PROTOCOL_TCP, 17729, 17729);
582  RANGE (PORT_PROTOCOL_TCP, 17754, 17756);
583  RANGE (PORT_PROTOCOL_TCP, 17777, 17777);
584  RANGE (PORT_PROTOCOL_TCP, 18000, 18000);
585  RANGE (PORT_PROTOCOL_TCP, 18104, 18104);
586  RANGE (PORT_PROTOCOL_TCP, 18136, 18136);
587  RANGE (PORT_PROTOCOL_TCP, 18181, 18187);
588  RANGE (PORT_PROTOCOL_TCP, 18241, 18241);
589  RANGE (PORT_PROTOCOL_TCP, 18262, 18262);
590  RANGE (PORT_PROTOCOL_TCP, 18463, 18463);
591  RANGE (PORT_PROTOCOL_TCP, 18634, 18635);
592  RANGE (PORT_PROTOCOL_TCP, 18769, 18769);
593  RANGE (PORT_PROTOCOL_TCP, 18881, 18881);
594  RANGE (PORT_PROTOCOL_TCP, 18888, 18888);
595  RANGE (PORT_PROTOCOL_TCP, 19000, 19000);
596  RANGE (PORT_PROTOCOL_TCP, 19020, 19020);
597  RANGE (PORT_PROTOCOL_TCP, 19191, 19191);
598  RANGE (PORT_PROTOCOL_TCP, 19194, 19194);
599  RANGE (PORT_PROTOCOL_TCP, 19283, 19283);
600  RANGE (PORT_PROTOCOL_TCP, 19315, 19315);
601  RANGE (PORT_PROTOCOL_TCP, 19398, 19398);
602  RANGE (PORT_PROTOCOL_TCP, 19410, 19412);
603  RANGE (PORT_PROTOCOL_TCP, 19539, 19541);
604  RANGE (PORT_PROTOCOL_TCP, 19998, 20003);
605  RANGE (PORT_PROTOCOL_TCP, 20005, 20005);
606  RANGE (PORT_PROTOCOL_TCP, 20013, 20014);
607  RANGE (PORT_PROTOCOL_TCP, 20034, 20034);
608  RANGE (PORT_PROTOCOL_TCP, 20046, 20046);
609  RANGE (PORT_PROTOCOL_TCP, 20048, 20049);
610  RANGE (PORT_PROTOCOL_TCP, 20167, 20167);
611  RANGE (PORT_PROTOCOL_TCP, 20202, 20202);
612  RANGE (PORT_PROTOCOL_TCP, 20222, 20222);
613  RANGE (PORT_PROTOCOL_TCP, 20480, 20480);
614  RANGE (PORT_PROTOCOL_TCP, 20670, 20670);
615  RANGE (PORT_PROTOCOL_TCP, 20999, 21000);
616  RANGE (PORT_PROTOCOL_TCP, 21553, 21554);
617  RANGE (PORT_PROTOCOL_TCP, 21590, 21590);
618  RANGE (PORT_PROTOCOL_TCP, 21800, 21800);
619  RANGE (PORT_PROTOCOL_TCP, 21845, 21849);
620  RANGE (PORT_PROTOCOL_TCP, 22000, 22005);
621  RANGE (PORT_PROTOCOL_TCP, 22125, 22125);
622  RANGE (PORT_PROTOCOL_TCP, 22128, 22128);
623  RANGE (PORT_PROTOCOL_TCP, 22273, 22273);
624  RANGE (PORT_PROTOCOL_TCP, 22305, 22305);
625  RANGE (PORT_PROTOCOL_TCP, 22343, 22343);
626  RANGE (PORT_PROTOCOL_TCP, 22347, 22347);
627  RANGE (PORT_PROTOCOL_TCP, 22350, 22350);
628  RANGE (PORT_PROTOCOL_TCP, 22537, 22537);
629  RANGE (PORT_PROTOCOL_TCP, 22555, 22555);
630  RANGE (PORT_PROTOCOL_TCP, 22763, 22763);
631  RANGE (PORT_PROTOCOL_TCP, 22800, 22800);
632  RANGE (PORT_PROTOCOL_TCP, 22951, 22951);
633  RANGE (PORT_PROTOCOL_TCP, 23000, 23005);
634  RANGE (PORT_PROTOCOL_TCP, 23053, 23053);
635  RANGE (PORT_PROTOCOL_TCP, 23333, 23333);
636  RANGE (PORT_PROTOCOL_TCP, 23400, 23402);
637  RANGE (PORT_PROTOCOL_TCP, 23456, 23457);
638  RANGE (PORT_PROTOCOL_TCP, 24000, 24006);
639  RANGE (PORT_PROTOCOL_TCP, 24242, 24242);
640  RANGE (PORT_PROTOCOL_TCP, 24249, 24249);
641  RANGE (PORT_PROTOCOL_TCP, 24321, 24321);
642  RANGE (PORT_PROTOCOL_TCP, 24386, 24386);
643  RANGE (PORT_PROTOCOL_TCP, 24465, 24465);
644  RANGE (PORT_PROTOCOL_TCP, 24554, 24554);
645  RANGE (PORT_PROTOCOL_TCP, 24676, 24678);
646  RANGE (PORT_PROTOCOL_TCP, 24680, 24680);
647  RANGE (PORT_PROTOCOL_TCP, 24754, 24754);
648  RANGE (PORT_PROTOCOL_TCP, 24922, 24922);
649  RANGE (PORT_PROTOCOL_TCP, 25000, 25009);
650  RANGE (PORT_PROTOCOL_TCP, 25576, 25576);
651  RANGE (PORT_PROTOCOL_TCP, 25604, 25604);
652  RANGE (PORT_PROTOCOL_TCP, 25793, 25793);
653  RANGE (PORT_PROTOCOL_TCP, 25900, 25903);
654  RANGE (PORT_PROTOCOL_TCP, 26000, 26000);
655  RANGE (PORT_PROTOCOL_TCP, 26133, 26133);
656  RANGE (PORT_PROTOCOL_TCP, 26208, 26208);
657  RANGE (PORT_PROTOCOL_TCP, 26260, 26263);
658  RANGE (PORT_PROTOCOL_TCP, 26486, 26487);
659  RANGE (PORT_PROTOCOL_TCP, 26489, 26489);
660  RANGE (PORT_PROTOCOL_TCP, 27345, 27345);
661  RANGE (PORT_PROTOCOL_TCP, 27442, 27442);
662  RANGE (PORT_PROTOCOL_TCP, 27504, 27504);
663  RANGE (PORT_PROTOCOL_TCP, 27782, 27782);
664  RANGE (PORT_PROTOCOL_TCP, 27999, 28001);
665  RANGE (PORT_PROTOCOL_TCP, 28240, 28240);
666  RANGE (PORT_PROTOCOL_TCP, 29167, 29167);
667  RANGE (PORT_PROTOCOL_TCP, 30001, 30002);
668  RANGE (PORT_PROTOCOL_TCP, 30260, 30260);
669  RANGE (PORT_PROTOCOL_TCP, 30999, 30999);
670  RANGE (PORT_PROTOCOL_TCP, 31020, 31020);
671  RANGE (PORT_PROTOCOL_TCP, 31416, 31416);
672  RANGE (PORT_PROTOCOL_TCP, 31457, 31457);
673  RANGE (PORT_PROTOCOL_TCP, 31620, 31620);
674  RANGE (PORT_PROTOCOL_TCP, 31685, 31685);
675  RANGE (PORT_PROTOCOL_TCP, 31765, 31765);
676  RANGE (PORT_PROTOCOL_TCP, 31948, 31949);
677  RANGE (PORT_PROTOCOL_TCP, 32034, 32034);
678  RANGE (PORT_PROTOCOL_TCP, 32249, 32249);
679  RANGE (PORT_PROTOCOL_TCP, 32483, 32483);
680  RANGE (PORT_PROTOCOL_TCP, 32635, 32636);
681  RANGE (PORT_PROTOCOL_TCP, 32767, 32777);
682  RANGE (PORT_PROTOCOL_TCP, 32801, 32801);
683  RANGE (PORT_PROTOCOL_TCP, 32811, 32811);
684  RANGE (PORT_PROTOCOL_TCP, 32896, 32896);
685  RANGE (PORT_PROTOCOL_TCP, 33123, 33123);
686  RANGE (PORT_PROTOCOL_TCP, 33331, 33331);
687  RANGE (PORT_PROTOCOL_TCP, 33333, 33334);
688  RANGE (PORT_PROTOCOL_TCP, 33434, 33434);
689  RANGE (PORT_PROTOCOL_TCP, 33656, 33656);
690  RANGE (PORT_PROTOCOL_TCP, 34249, 34249);
691  RANGE (PORT_PROTOCOL_TCP, 34378, 34379);
692  RANGE (PORT_PROTOCOL_TCP, 34567, 34567);
693  RANGE (PORT_PROTOCOL_TCP, 34962, 34964);
694  RANGE (PORT_PROTOCOL_TCP, 34980, 34980);
695  RANGE (PORT_PROTOCOL_TCP, 35354, 35357);
696  RANGE (PORT_PROTOCOL_TCP, 36001, 36001);
697  RANGE (PORT_PROTOCOL_TCP, 36524, 36524);
698  RANGE (PORT_PROTOCOL_TCP, 36865, 36865);
699  RANGE (PORT_PROTOCOL_TCP, 37475, 37475);
700  RANGE (PORT_PROTOCOL_TCP, 37654, 37654);
701  RANGE (PORT_PROTOCOL_TCP, 38201, 38203);
702  RANGE (PORT_PROTOCOL_TCP, 39681, 39681);
703  RANGE (PORT_PROTOCOL_TCP, 40000, 40000);
704  RANGE (PORT_PROTOCOL_TCP, 40841, 40843);
705  RANGE (PORT_PROTOCOL_TCP, 41111, 41111);
706  RANGE (PORT_PROTOCOL_TCP, 41121, 41121);
707  RANGE (PORT_PROTOCOL_TCP, 41794, 41795);
708  RANGE (PORT_PROTOCOL_TCP, 42508, 42510);
709  RANGE (PORT_PROTOCOL_TCP, 43188, 43191);
710  RANGE (PORT_PROTOCOL_TCP, 43439, 43441);
711  RANGE (PORT_PROTOCOL_TCP, 44321, 44322);
712  RANGE (PORT_PROTOCOL_TCP, 44553, 44553);
713  RANGE (PORT_PROTOCOL_TCP, 44818, 44818);
714  RANGE (PORT_PROTOCOL_TCP, 45000, 45001);
715  RANGE (PORT_PROTOCOL_TCP, 45054, 45054);
716  RANGE (PORT_PROTOCOL_TCP, 45678, 45678);
717  RANGE (PORT_PROTOCOL_TCP, 45825, 45825);
718  RANGE (PORT_PROTOCOL_TCP, 45966, 45966);
719  RANGE (PORT_PROTOCOL_TCP, 46999, 47001);
720  RANGE (PORT_PROTOCOL_TCP, 47557, 47557);
721  RANGE (PORT_PROTOCOL_TCP, 47624, 47624);
722  RANGE (PORT_PROTOCOL_TCP, 47806, 47806);
723  RANGE (PORT_PROTOCOL_TCP, 47808, 47808);
724  RANGE (PORT_PROTOCOL_TCP, 48000, 48005);
725  RANGE (PORT_PROTOCOL_TCP, 48049, 48049);
726  RANGE (PORT_PROTOCOL_TCP, 48128, 48129);
727  RANGE (PORT_PROTOCOL_TCP, 48556, 48556);
728  RANGE (PORT_PROTOCOL_TCP, 48619, 48619);
729 
730  RANGE (PORT_PROTOCOL_UDP, 1, 80);
731  RANGE (PORT_PROTOCOL_UDP, 82, 99);
732  RANGE (PORT_PROTOCOL_UDP, 101, 113);
733  RANGE (PORT_PROTOCOL_UDP, 115, 224);
734  RANGE (PORT_PROTOCOL_UDP, 242, 248);
735  RANGE (PORT_PROTOCOL_UDP, 256, 257);
736  RANGE (PORT_PROTOCOL_UDP, 259, 270);
737  RANGE (PORT_PROTOCOL_UDP, 280, 284);
738  RANGE (PORT_PROTOCOL_UDP, 286, 287);
739  RANGE (PORT_PROTOCOL_UDP, 308, 322);
740  RANGE (PORT_PROTOCOL_UDP, 333, 333);
741  RANGE (PORT_PROTOCOL_UDP, 344, 584);
742  RANGE (PORT_PROTOCOL_UDP, 586, 658);
743  RANGE (PORT_PROTOCOL_UDP, 660, 702);
744  RANGE (PORT_PROTOCOL_UDP, 704, 707);
745  RANGE (PORT_PROTOCOL_UDP, 709, 716);
746  RANGE (PORT_PROTOCOL_UDP, 729, 731);
747  RANGE (PORT_PROTOCOL_UDP, 741, 742);
748  RANGE (PORT_PROTOCOL_UDP, 744, 744);
749  RANGE (PORT_PROTOCOL_UDP, 747, 754);
750  RANGE (PORT_PROTOCOL_UDP, 758, 765);
751  RANGE (PORT_PROTOCOL_UDP, 767, 767);
752  RANGE (PORT_PROTOCOL_UDP, 769, 777);
753  RANGE (PORT_PROTOCOL_UDP, 780, 780);
754  RANGE (PORT_PROTOCOL_UDP, 800, 801);
755  RANGE (PORT_PROTOCOL_UDP, 810, 810);
756  RANGE (PORT_PROTOCOL_UDP, 828, 833);
757  RANGE (PORT_PROTOCOL_UDP, 847, 848);
758  RANGE (PORT_PROTOCOL_UDP, 860, 862);
759  RANGE (PORT_PROTOCOL_UDP, 873, 873);
760  RANGE (PORT_PROTOCOL_UDP, 886, 888);
761  RANGE (PORT_PROTOCOL_UDP, 900, 903);
762  RANGE (PORT_PROTOCOL_UDP, 910, 913);
763  RANGE (PORT_PROTOCOL_UDP, 989, 993);
764  RANGE (PORT_PROTOCOL_UDP, 995, 1000);
765  RANGE (PORT_PROTOCOL_UDP, 1008, 1008);
766  RANGE (PORT_PROTOCOL_UDP, 1010, 1010);
767  RANGE (PORT_PROTOCOL_UDP, 1021, 1022);
768  RANGE (PORT_PROTOCOL_UDP, 1025, 1026);
769  RANGE (PORT_PROTOCOL_UDP, 1029, 1108);
770  RANGE (PORT_PROTOCOL_UDP, 1110, 1490);
771  RANGE (PORT_PROTOCOL_UDP, 1492, 1527);
772  RANGE (PORT_PROTOCOL_UDP, 1529, 1643);
773  RANGE (PORT_PROTOCOL_UDP, 1645, 1752);
774  RANGE (PORT_PROTOCOL_UDP, 1754, 1774);
775  RANGE (PORT_PROTOCOL_UDP, 1776, 1782);
776  RANGE (PORT_PROTOCOL_UDP, 1784, 2187);
777  RANGE (PORT_PROTOCOL_UDP, 2190, 2193);
778  RANGE (PORT_PROTOCOL_UDP, 2197, 2224);
779  RANGE (PORT_PROTOCOL_UDP, 2226, 2258);
780  RANGE (PORT_PROTOCOL_UDP, 2260, 2368);
781  RANGE (PORT_PROTOCOL_UDP, 2370, 2372);
782  RANGE (PORT_PROTOCOL_UDP, 2381, 2425);
783  RANGE (PORT_PROTOCOL_UDP, 2427, 2563);
784  RANGE (PORT_PROTOCOL_UDP, 2565, 2681);
785  RANGE (PORT_PROTOCOL_UDP, 2683, 2793);
786  RANGE (PORT_PROTOCOL_UDP, 2795, 2824);
787  RANGE (PORT_PROTOCOL_UDP, 2826, 2872);
788  RANGE (PORT_PROTOCOL_UDP, 2874, 2924);
789  RANGE (PORT_PROTOCOL_UDP, 2926, 3000);
790  RANGE (PORT_PROTOCOL_UDP, 3002, 3091);
791  RANGE (PORT_PROTOCOL_UDP, 3093, 3096);
792  RANGE (PORT_PROTOCOL_UDP, 3098, 3120);
793  RANGE (PORT_PROTOCOL_UDP, 3122, 3125);
794  RANGE (PORT_PROTOCOL_UDP, 3127, 3299);
795  RANGE (PORT_PROTOCOL_UDP, 3302, 3321);
796  RANGE (PORT_PROTOCOL_UDP, 3326, 3366);
797  RANGE (PORT_PROTOCOL_UDP, 3372, 3402);
798  RANGE (PORT_PROTOCOL_UDP, 3405, 3453);
799  RANGE (PORT_PROTOCOL_UDP, 3455, 3545);
800  RANGE (PORT_PROTOCOL_UDP, 3547, 3564);
801  RANGE (PORT_PROTOCOL_UDP, 3567, 3692);
802  RANGE (PORT_PROTOCOL_UDP, 3695, 3736);
803  RANGE (PORT_PROTOCOL_UDP, 3738, 3765);
804  RANGE (PORT_PROTOCOL_UDP, 3767, 3863);
805  RANGE (PORT_PROTOCOL_UDP, 3865, 3867);
806  RANGE (PORT_PROTOCOL_UDP, 3869, 3993);
807  RANGE (PORT_PROTOCOL_UDP, 3995, 4047);
808  RANGE (PORT_PROTOCOL_UDP, 4049, 4077);
809  RANGE (PORT_PROTOCOL_UDP, 4079, 4084);
810  RANGE (PORT_PROTOCOL_UDP, 4086, 4086);
811  RANGE (PORT_PROTOCOL_UDP, 4089, 4119);
812  RANGE (PORT_PROTOCOL_UDP, 4121, 4143);
813  RANGE (PORT_PROTOCOL_UDP, 4145, 4169);
814  RANGE (PORT_PROTOCOL_UDP, 4172, 4174);
815  RANGE (PORT_PROTOCOL_UDP, 4177, 4185);
816  RANGE (PORT_PROTOCOL_UDP, 4188, 4188);
817  RANGE (PORT_PROTOCOL_UDP, 4191, 4192);
818  RANGE (PORT_PROTOCOL_UDP, 4199, 4199);
819  RANGE (PORT_PROTOCOL_UDP, 4300, 4310);
820  RANGE (PORT_PROTOCOL_UDP, 4320, 4328);
821  RANGE (PORT_PROTOCOL_UDP, 4340, 4359);
822  RANGE (PORT_PROTOCOL_UDP, 4361, 4362);
823  RANGE (PORT_PROTOCOL_UDP, 4368, 4373);
824  RANGE (PORT_PROTOCOL_UDP, 4375, 4379);
825  RANGE (PORT_PROTOCOL_UDP, 4389, 4390);
826  RANGE (PORT_PROTOCOL_UDP, 4394, 4395);
827  RANGE (PORT_PROTOCOL_UDP, 4400, 4406);
828  RANGE (PORT_PROTOCOL_UDP, 4425, 4426);
829  RANGE (PORT_PROTOCOL_UDP, 4430, 4430);
830  RANGE (PORT_PROTOCOL_UDP, 4441, 4458);
831  RANGE (PORT_PROTOCOL_UDP, 4484, 4484);
832  RANGE (PORT_PROTOCOL_UDP, 4486, 4486);
833  RANGE (PORT_PROTOCOL_UDP, 4488, 4488);
834  RANGE (PORT_PROTOCOL_UDP, 4500, 4500);
835  RANGE (PORT_PROTOCOL_UDP, 4535, 4538);
836  RANGE (PORT_PROTOCOL_UDP, 4545, 4552);
837  RANGE (PORT_PROTOCOL_UDP, 4554, 4559);
838  RANGE (PORT_PROTOCOL_UDP, 4566, 4569);
839  RANGE (PORT_PROTOCOL_UDP, 4591, 4601);
840  RANGE (PORT_PROTOCOL_UDP, 4658, 4692);
841  RANGE (PORT_PROTOCOL_UDP, 4700, 4702);
842  RANGE (PORT_PROTOCOL_UDP, 4725, 4730);
843  RANGE (PORT_PROTOCOL_UDP, 4732, 4732);
844  RANGE (PORT_PROTOCOL_UDP, 4737, 4745);
845  RANGE (PORT_PROTOCOL_UDP, 4749, 4752);
846  RANGE (PORT_PROTOCOL_UDP, 4784, 4785);
847  RANGE (PORT_PROTOCOL_UDP, 4800, 4804);
848  RANGE (PORT_PROTOCOL_UDP, 4827, 4827);
849  RANGE (PORT_PROTOCOL_UDP, 4837, 4851);
850  RANGE (PORT_PROTOCOL_UDP, 4867, 4871);
851  RANGE (PORT_PROTOCOL_UDP, 4876, 4878);
852  RANGE (PORT_PROTOCOL_UDP, 4881, 4882);
853  RANGE (PORT_PROTOCOL_UDP, 4884, 4885);
854  RANGE (PORT_PROTOCOL_UDP, 4894, 4894);
855  RANGE (PORT_PROTOCOL_UDP, 4899, 4900);
856  RANGE (PORT_PROTOCOL_UDP, 4914, 4914);
857  RANGE (PORT_PROTOCOL_UDP, 4937, 4937);
858  RANGE (PORT_PROTOCOL_UDP, 4940, 4942);
859  RANGE (PORT_PROTOCOL_UDP, 4949, 4952);
860  RANGE (PORT_PROTOCOL_UDP, 4969, 4970);
861  RANGE (PORT_PROTOCOL_UDP, 4986, 4991);
862  RANGE (PORT_PROTOCOL_UDP, 4999, 5014);
863  RANGE (PORT_PROTOCOL_UDP, 5020, 5027);
864  RANGE (PORT_PROTOCOL_UDP, 5029, 5031);
865  RANGE (PORT_PROTOCOL_UDP, 5042, 5044);
866  RANGE (PORT_PROTOCOL_UDP, 5046, 5047);
867  RANGE (PORT_PROTOCOL_UDP, 5049, 5052);
868  RANGE (PORT_PROTOCOL_UDP, 5055, 5062);
869  RANGE (PORT_PROTOCOL_UDP, 5064, 5067);
870  RANGE (PORT_PROTOCOL_UDP, 5069, 5074);
871  RANGE (PORT_PROTOCOL_UDP, 5079, 5085);
872  RANGE (PORT_PROTOCOL_UDP, 5092, 5094);
873  RANGE (PORT_PROTOCOL_UDP, 5099, 5102);
874  RANGE (PORT_PROTOCOL_UDP, 5104, 5105);
875  RANGE (PORT_PROTOCOL_UDP, 5111, 5112);
876  RANGE (PORT_PROTOCOL_UDP, 5116, 5116);
877  RANGE (PORT_PROTOCOL_UDP, 5133, 5133);
878  RANGE (PORT_PROTOCOL_UDP, 5136, 5137);
879  RANGE (PORT_PROTOCOL_UDP, 5145, 5145);
880  RANGE (PORT_PROTOCOL_UDP, 5150, 5152);
881  RANGE (PORT_PROTOCOL_UDP, 5154, 5155);
882  RANGE (PORT_PROTOCOL_UDP, 5164, 5168);
883  RANGE (PORT_PROTOCOL_UDP, 5190, 5193);
884  RANGE (PORT_PROTOCOL_UDP, 5200, 5203);
885  RANGE (PORT_PROTOCOL_UDP, 5223, 5227);
886  RANGE (PORT_PROTOCOL_UDP, 5234, 5237);
887  RANGE (PORT_PROTOCOL_UDP, 5245, 5252);
888  RANGE (PORT_PROTOCOL_UDP, 5264, 5265);
889  RANGE (PORT_PROTOCOL_UDP, 5270, 5272);
890  RANGE (PORT_PROTOCOL_UDP, 5282, 5282);
891  RANGE (PORT_PROTOCOL_UDP, 5298, 5310);
892  RANGE (PORT_PROTOCOL_UDP, 5312, 5316);
893  RANGE (PORT_PROTOCOL_UDP, 5343, 5344);
894  RANGE (PORT_PROTOCOL_UDP, 5349, 5363);
895  RANGE (PORT_PROTOCOL_UDP, 5397, 5437);
896  RANGE (PORT_PROTOCOL_UDP, 5443, 5443);
897  RANGE (PORT_PROTOCOL_UDP, 5453, 5456);
898  RANGE (PORT_PROTOCOL_UDP, 5461, 5465);
899  RANGE (PORT_PROTOCOL_UDP, 5500, 5506);
900  RANGE (PORT_PROTOCOL_UDP, 5553, 5556);
901  RANGE (PORT_PROTOCOL_UDP, 5567, 5568);
902  RANGE (PORT_PROTOCOL_UDP, 5573, 5573);
903  RANGE (PORT_PROTOCOL_UDP, 5580, 5585);
904  RANGE (PORT_PROTOCOL_UDP, 5597, 5605);
905  RANGE (PORT_PROTOCOL_UDP, 5627, 5634);
906  RANGE (PORT_PROTOCOL_UDP, 5671, 5683);
907  RANGE (PORT_PROTOCOL_UDP, 5688, 5689);
908  RANGE (PORT_PROTOCOL_UDP, 5713, 5724);
909  RANGE (PORT_PROTOCOL_UDP, 5728, 5730);
910  RANGE (PORT_PROTOCOL_UDP, 5741, 5748);
911  RANGE (PORT_PROTOCOL_UDP, 5750, 5750);
912  RANGE (PORT_PROTOCOL_UDP, 5755, 5755);
913  RANGE (PORT_PROTOCOL_UDP, 5757, 5757);
914  RANGE (PORT_PROTOCOL_UDP, 5766, 5771);
915  RANGE (PORT_PROTOCOL_UDP, 5777, 5777);
916  RANGE (PORT_PROTOCOL_UDP, 5781, 5787);
917  RANGE (PORT_PROTOCOL_UDP, 5793, 5794);
918  RANGE (PORT_PROTOCOL_UDP, 5813, 5814);
919  RANGE (PORT_PROTOCOL_UDP, 5859, 5859);
920  RANGE (PORT_PROTOCOL_UDP, 5863, 5863);
921  RANGE (PORT_PROTOCOL_UDP, 5900, 5900);
922  RANGE (PORT_PROTOCOL_UDP, 5910, 5913);
923  RANGE (PORT_PROTOCOL_UDP, 5963, 5963);
924  RANGE (PORT_PROTOCOL_UDP, 5968, 5969);
925  RANGE (PORT_PROTOCOL_UDP, 5984, 5992);
926  RANGE (PORT_PROTOCOL_UDP, 5999, 6000);
927  RANGE (PORT_PROTOCOL_UDP, 6061, 6066);
928  RANGE (PORT_PROTOCOL_UDP, 6069, 6074);
929  RANGE (PORT_PROTOCOL_UDP, 6082, 6083);
930  RANGE (PORT_PROTOCOL_UDP, 6085, 6087);
931  RANGE (PORT_PROTOCOL_UDP, 6100, 6112);
932  RANGE (PORT_PROTOCOL_UDP, 6122, 6124);
933  RANGE (PORT_PROTOCOL_UDP, 6133, 6133);
934  RANGE (PORT_PROTOCOL_UDP, 6140, 6149);
935  RANGE (PORT_PROTOCOL_UDP, 6160, 6163);
936  RANGE (PORT_PROTOCOL_UDP, 6200, 6200);
937  RANGE (PORT_PROTOCOL_UDP, 6222, 6222);
938  RANGE (PORT_PROTOCOL_UDP, 6241, 6244);
939  RANGE (PORT_PROTOCOL_UDP, 6251, 6253);
940  RANGE (PORT_PROTOCOL_UDP, 6268, 6269);
941  RANGE (PORT_PROTOCOL_UDP, 6300, 6301);
942  RANGE (PORT_PROTOCOL_UDP, 6306, 6306);
943  RANGE (PORT_PROTOCOL_UDP, 6315, 6316);
944  RANGE (PORT_PROTOCOL_UDP, 6320, 6322);
945  RANGE (PORT_PROTOCOL_UDP, 6324, 6324);
946  RANGE (PORT_PROTOCOL_UDP, 6343, 6343);
947  RANGE (PORT_PROTOCOL_UDP, 6346, 6347);
948  RANGE (PORT_PROTOCOL_UDP, 6350, 6350);
949  RANGE (PORT_PROTOCOL_UDP, 6355, 6355);
950  RANGE (PORT_PROTOCOL_UDP, 6360, 6360);
951  RANGE (PORT_PROTOCOL_UDP, 6370, 6370);
952  RANGE (PORT_PROTOCOL_UDP, 6382, 6382);
953  RANGE (PORT_PROTOCOL_UDP, 6389, 6390);
954  RANGE (PORT_PROTOCOL_UDP, 6417, 6417);
955  RANGE (PORT_PROTOCOL_UDP, 6420, 6421);
956  RANGE (PORT_PROTOCOL_UDP, 6443, 6446);
957  RANGE (PORT_PROTOCOL_UDP, 6456, 6456);
958  RANGE (PORT_PROTOCOL_UDP, 6471, 6471);
959  RANGE (PORT_PROTOCOL_UDP, 6480, 6489);
960  RANGE (PORT_PROTOCOL_UDP, 6500, 6503);
961  RANGE (PORT_PROTOCOL_UDP, 6505, 6510);
962  RANGE (PORT_PROTOCOL_UDP, 6514, 6515);
963  RANGE (PORT_PROTOCOL_UDP, 6543, 6544);
964  RANGE (PORT_PROTOCOL_UDP, 6547, 6551);
965  RANGE (PORT_PROTOCOL_UDP, 6558, 6558);
966  RANGE (PORT_PROTOCOL_UDP, 6566, 6566);
967  RANGE (PORT_PROTOCOL_UDP, 6568, 6568);
968  RANGE (PORT_PROTOCOL_UDP, 6579, 6583);
969  RANGE (PORT_PROTOCOL_UDP, 6619, 6623);
970  RANGE (PORT_PROTOCOL_UDP, 6626, 6628);
971  RANGE (PORT_PROTOCOL_UDP, 6657, 6657);
972  RANGE (PORT_PROTOCOL_UDP, 6670, 6673);
973  RANGE (PORT_PROTOCOL_UDP, 6678, 6679);
974  RANGE (PORT_PROTOCOL_UDP, 6689, 6689);
975  RANGE (PORT_PROTOCOL_UDP, 6696, 6696);
976  RANGE (PORT_PROTOCOL_UDP, 6701, 6703);
977  RANGE (PORT_PROTOCOL_UDP, 6714, 6715);
978  RANGE (PORT_PROTOCOL_UDP, 6767, 6771);
979  RANGE (PORT_PROTOCOL_UDP, 6785, 6791);
980  RANGE (PORT_PROTOCOL_UDP, 6801, 6801);
981  RANGE (PORT_PROTOCOL_UDP, 6831, 6831);
982  RANGE (PORT_PROTOCOL_UDP, 6841, 6842);
983  RANGE (PORT_PROTOCOL_UDP, 6850, 6850);
984  RANGE (PORT_PROTOCOL_UDP, 6868, 6868);
985  RANGE (PORT_PROTOCOL_UDP, 6888, 6888);
986  RANGE (PORT_PROTOCOL_UDP, 6935, 6936);
987  RANGE (PORT_PROTOCOL_UDP, 6946, 6946);
988  RANGE (PORT_PROTOCOL_UDP, 6951, 6951);
989  RANGE (PORT_PROTOCOL_UDP, 6961, 6966);
990  RANGE (PORT_PROTOCOL_UDP, 6969, 6969);
991  RANGE (PORT_PROTOCOL_UDP, 6997, 7015);
992  RANGE (PORT_PROTOCOL_UDP, 7019, 7025);
993  RANGE (PORT_PROTOCOL_UDP, 7030, 7030);
994  RANGE (PORT_PROTOCOL_UDP, 7070, 7071);
995  RANGE (PORT_PROTOCOL_UDP, 7080, 7080);
996  RANGE (PORT_PROTOCOL_UDP, 7099, 7101);
997  RANGE (PORT_PROTOCOL_UDP, 7107, 7107);
998  RANGE (PORT_PROTOCOL_UDP, 7121, 7121);
999  RANGE (PORT_PROTOCOL_UDP, 7128, 7129);
1000  RANGE (PORT_PROTOCOL_UDP, 7161, 7166);
1001  RANGE (PORT_PROTOCOL_UDP, 7169, 7171);
1002  RANGE (PORT_PROTOCOL_UDP, 7174, 7174);
1003  RANGE (PORT_PROTOCOL_UDP, 7200, 7201);
1004  RANGE (PORT_PROTOCOL_UDP, 7227, 7227);
1005  RANGE (PORT_PROTOCOL_UDP, 7262, 7262);
1006  RANGE (PORT_PROTOCOL_UDP, 7272, 7282);
1007  RANGE (PORT_PROTOCOL_UDP, 7365, 7365);
1008  RANGE (PORT_PROTOCOL_UDP, 7391, 7395);
1009  RANGE (PORT_PROTOCOL_UDP, 7397, 7397);
1010  RANGE (PORT_PROTOCOL_UDP, 7400, 7402);
1011  RANGE (PORT_PROTOCOL_UDP, 7410, 7410);
1012  RANGE (PORT_PROTOCOL_UDP, 7421, 7421);
1013  RANGE (PORT_PROTOCOL_UDP, 7426, 7431);
1014  RANGE (PORT_PROTOCOL_UDP, 7437, 7437);
1015  RANGE (PORT_PROTOCOL_UDP, 7443, 7443);
1016  RANGE (PORT_PROTOCOL_UDP, 7473, 7473);
1017  RANGE (PORT_PROTOCOL_UDP, 7491, 7491);
1018  RANGE (PORT_PROTOCOL_UDP, 7500, 7501);
1019  RANGE (PORT_PROTOCOL_UDP, 7510, 7511);
1020  RANGE (PORT_PROTOCOL_UDP, 7542, 7550);
1021  RANGE (PORT_PROTOCOL_UDP, 7560, 7560);
1022  RANGE (PORT_PROTOCOL_UDP, 7566, 7566);
1023  RANGE (PORT_PROTOCOL_UDP, 7570, 7570);
1024  RANGE (PORT_PROTOCOL_UDP, 7588, 7588);
1025  RANGE (PORT_PROTOCOL_UDP, 7624, 7624);
1026  RANGE (PORT_PROTOCOL_UDP, 7626, 7629);
1027  RANGE (PORT_PROTOCOL_UDP, 7633, 7633);
1028  RANGE (PORT_PROTOCOL_UDP, 7648, 7648);
1029  RANGE (PORT_PROTOCOL_UDP, 7674, 7677);
1030  RANGE (PORT_PROTOCOL_UDP, 7680, 7680);
1031  RANGE (PORT_PROTOCOL_UDP, 7689, 7689);
1032  RANGE (PORT_PROTOCOL_UDP, 7697, 7697);
1033  RANGE (PORT_PROTOCOL_UDP, 7707, 7708);
1034  RANGE (PORT_PROTOCOL_UDP, 7720, 7720);
1035  RANGE (PORT_PROTOCOL_UDP, 7724, 7727);
1036  RANGE (PORT_PROTOCOL_UDP, 7734, 7734);
1037  RANGE (PORT_PROTOCOL_UDP, 7738, 7738);
1038  RANGE (PORT_PROTOCOL_UDP, 7741, 7741);
1039  RANGE (PORT_PROTOCOL_UDP, 7743, 7744);
1040  RANGE (PORT_PROTOCOL_UDP, 7747, 7747);
1041  RANGE (PORT_PROTOCOL_UDP, 7777, 7779);
1042  RANGE (PORT_PROTOCOL_UDP, 7781, 7781);
1043  RANGE (PORT_PROTOCOL_UDP, 7786, 7787);
1044  RANGE (PORT_PROTOCOL_UDP, 7789, 7789);
1045  RANGE (PORT_PROTOCOL_UDP, 7794, 7794);
1046  RANGE (PORT_PROTOCOL_UDP, 7797, 7801);
1047  RANGE (PORT_PROTOCOL_UDP, 7810, 7810);
1048  RANGE (PORT_PROTOCOL_UDP, 7845, 7846);
1049  RANGE (PORT_PROTOCOL_UDP, 7880, 7880);
1050  RANGE (PORT_PROTOCOL_UDP, 7887, 7887);
1051  RANGE (PORT_PROTOCOL_UDP, 7900, 7903);
1052  RANGE (PORT_PROTOCOL_UDP, 7913, 7913);
1053  RANGE (PORT_PROTOCOL_UDP, 7932, 7933);
1054  RANGE (PORT_PROTOCOL_UDP, 7967, 7967);
1055  RANGE (PORT_PROTOCOL_UDP, 7979, 7980);
1056  RANGE (PORT_PROTOCOL_UDP, 7982, 7982);
1057  RANGE (PORT_PROTOCOL_UDP, 7998, 8003);
1058  RANGE (PORT_PROTOCOL_UDP, 8005, 8005);
1059  RANGE (PORT_PROTOCOL_UDP, 8008, 8008);
1060  RANGE (PORT_PROTOCOL_UDP, 8019, 8022);
1061  RANGE (PORT_PROTOCOL_UDP, 8025, 8026);
1062  RANGE (PORT_PROTOCOL_UDP, 8032, 8034);
1063  RANGE (PORT_PROTOCOL_UDP, 8040, 8040);
1064  RANGE (PORT_PROTOCOL_UDP, 8052, 8059);
1065  RANGE (PORT_PROTOCOL_UDP, 8074, 8074);
1066  RANGE (PORT_PROTOCOL_UDP, 8080, 8083);
1067  RANGE (PORT_PROTOCOL_UDP, 8086, 8088);
1068  RANGE (PORT_PROTOCOL_UDP, 8097, 8097);
1069  RANGE (PORT_PROTOCOL_UDP, 8100, 8100);
1070  RANGE (PORT_PROTOCOL_UDP, 8115, 8116);
1071  RANGE (PORT_PROTOCOL_UDP, 8118, 8118);
1072  RANGE (PORT_PROTOCOL_UDP, 8121, 8122);
1073  RANGE (PORT_PROTOCOL_UDP, 8128, 8132);
1074  RANGE (PORT_PROTOCOL_UDP, 8148, 8149);
1075  RANGE (PORT_PROTOCOL_UDP, 8160, 8161);
1076  RANGE (PORT_PROTOCOL_UDP, 8182, 8182);
1077  RANGE (PORT_PROTOCOL_UDP, 8184, 8184);
1078  RANGE (PORT_PROTOCOL_UDP, 8192, 8192);
1079  RANGE (PORT_PROTOCOL_UDP, 8194, 8195);
1080  RANGE (PORT_PROTOCOL_UDP, 8199, 8202);
1081  RANGE (PORT_PROTOCOL_UDP, 8204, 8208);
1082  RANGE (PORT_PROTOCOL_UDP, 8230, 8230);
1083  RANGE (PORT_PROTOCOL_UDP, 8243, 8243);
1084  RANGE (PORT_PROTOCOL_UDP, 8276, 8276);
1085  RANGE (PORT_PROTOCOL_UDP, 8280, 8280);
1086  RANGE (PORT_PROTOCOL_UDP, 8292, 8292);
1087  RANGE (PORT_PROTOCOL_UDP, 8294, 8294);
1088  RANGE (PORT_PROTOCOL_UDP, 8300, 8301);
1089  RANGE (PORT_PROTOCOL_UDP, 8320, 8321);
1090  RANGE (PORT_PROTOCOL_UDP, 8351, 8351);
1091  RANGE (PORT_PROTOCOL_UDP, 8376, 8380);
1092  RANGE (PORT_PROTOCOL_UDP, 8383, 8383);
1093  RANGE (PORT_PROTOCOL_UDP, 8400, 8403);
1094  RANGE (PORT_PROTOCOL_UDP, 8416, 8417);
1095  RANGE (PORT_PROTOCOL_UDP, 8442, 8444);
1096  RANGE (PORT_PROTOCOL_UDP, 8450, 8450);
1097  RANGE (PORT_PROTOCOL_UDP, 8472, 8474);
1098  RANGE (PORT_PROTOCOL_UDP, 8500, 8501);
1099  RANGE (PORT_PROTOCOL_UDP, 8554, 8555);
1100  RANGE (PORT_PROTOCOL_UDP, 8567, 8567);
1101  RANGE (PORT_PROTOCOL_UDP, 8600, 8600);
1102  RANGE (PORT_PROTOCOL_UDP, 8610, 8614);
1103  RANGE (PORT_PROTOCOL_UDP, 8686, 8686);
1104  RANGE (PORT_PROTOCOL_UDP, 8699, 8699);
1105  RANGE (PORT_PROTOCOL_UDP, 8732, 8733);
1106  RANGE (PORT_PROTOCOL_UDP, 8763, 8765);
1107  RANGE (PORT_PROTOCOL_UDP, 8770, 8770);
1108  RANGE (PORT_PROTOCOL_UDP, 8786, 8787);
1109  RANGE (PORT_PROTOCOL_UDP, 8793, 8793);
1110  RANGE (PORT_PROTOCOL_UDP, 8800, 8800);
1111  RANGE (PORT_PROTOCOL_UDP, 8804, 8804);
1112  RANGE (PORT_PROTOCOL_UDP, 8873, 8873);
1113  RANGE (PORT_PROTOCOL_UDP, 8880, 8880);
1114  RANGE (PORT_PROTOCOL_UDP, 8883, 8883);
1115  RANGE (PORT_PROTOCOL_UDP, 8888, 8894);
1116  RANGE (PORT_PROTOCOL_UDP, 8899, 8901);
1117  RANGE (PORT_PROTOCOL_UDP, 8910, 8913);
1118  RANGE (PORT_PROTOCOL_UDP, 8954, 8954);
1119  RANGE (PORT_PROTOCOL_UDP, 8989, 8991);
1120  RANGE (PORT_PROTOCOL_UDP, 8999, 9002);
1121  RANGE (PORT_PROTOCOL_UDP, 9007, 9007);
1122  RANGE (PORT_PROTOCOL_UDP, 9009, 9009);
1123  RANGE (PORT_PROTOCOL_UDP, 9020, 9026);
1124  RANGE (PORT_PROTOCOL_UDP, 9080, 9080);
1125  RANGE (PORT_PROTOCOL_UDP, 9084, 9092);
1126  RANGE (PORT_PROTOCOL_UDP, 9100, 9106);
1127  RANGE (PORT_PROTOCOL_UDP, 9119, 9119);
1128  RANGE (PORT_PROTOCOL_UDP, 9131, 9131);
1129  RANGE (PORT_PROTOCOL_UDP, 9160, 9164);
1130  RANGE (PORT_PROTOCOL_UDP, 9191, 9191);
1131  RANGE (PORT_PROTOCOL_UDP, 9200, 9217);
1132  RANGE (PORT_PROTOCOL_UDP, 9222, 9222);
1133  RANGE (PORT_PROTOCOL_UDP, 9255, 9255);
1134  RANGE (PORT_PROTOCOL_UDP, 9278, 9287);
1135  RANGE (PORT_PROTOCOL_UDP, 9292, 9295);
1136  RANGE (PORT_PROTOCOL_UDP, 9300, 9300);
1137  RANGE (PORT_PROTOCOL_UDP, 9318, 9318);
1138  RANGE (PORT_PROTOCOL_UDP, 9321, 9321);
1139  RANGE (PORT_PROTOCOL_UDP, 9343, 9344);
1140  RANGE (PORT_PROTOCOL_UDP, 9346, 9346);
1141  RANGE (PORT_PROTOCOL_UDP, 9374, 9374);
1142  RANGE (PORT_PROTOCOL_UDP, 9380, 9380);
1143  RANGE (PORT_PROTOCOL_UDP, 9396, 9397);
1144  RANGE (PORT_PROTOCOL_UDP, 9400, 9402);
1145  RANGE (PORT_PROTOCOL_UDP, 9418, 9418);
1146  RANGE (PORT_PROTOCOL_UDP, 9443, 9444);
1147  RANGE (PORT_PROTOCOL_UDP, 9450, 9450);
1148  RANGE (PORT_PROTOCOL_UDP, 9500, 9500);
1149  RANGE (PORT_PROTOCOL_UDP, 9522, 9522);
1150  RANGE (PORT_PROTOCOL_UDP, 9535, 9536);
1151  RANGE (PORT_PROTOCOL_UDP, 9555, 9555);
1152  RANGE (PORT_PROTOCOL_UDP, 9592, 9600);
1153  RANGE (PORT_PROTOCOL_UDP, 9612, 9612);
1154  RANGE (PORT_PROTOCOL_UDP, 9618, 9618);
1155  RANGE (PORT_PROTOCOL_UDP, 9628, 9629);
1156  RANGE (PORT_PROTOCOL_UDP, 9632, 9632);
1157  RANGE (PORT_PROTOCOL_UDP, 9667, 9668);
1158  RANGE (PORT_PROTOCOL_UDP, 9694, 9695);
1159  RANGE (PORT_PROTOCOL_UDP, 9700, 9700);
1160  RANGE (PORT_PROTOCOL_UDP, 9747, 9747);
1161  RANGE (PORT_PROTOCOL_UDP, 9750, 9750);
1162  RANGE (PORT_PROTOCOL_UDP, 9753, 9753);
1163  RANGE (PORT_PROTOCOL_UDP, 9762, 9762);
1164  RANGE (PORT_PROTOCOL_UDP, 9800, 9802);
1165  RANGE (PORT_PROTOCOL_UDP, 9875, 9876);
1166  RANGE (PORT_PROTOCOL_UDP, 9888, 9889);
1167  RANGE (PORT_PROTOCOL_UDP, 9898, 9901);
1168  RANGE (PORT_PROTOCOL_UDP, 9903, 9903);
1169  RANGE (PORT_PROTOCOL_UDP, 9909, 9909);
1170  RANGE (PORT_PROTOCOL_UDP, 9911, 9911);
1171  RANGE (PORT_PROTOCOL_UDP, 9950, 9953);
1172  RANGE (PORT_PROTOCOL_UDP, 9956, 9956);
1173  RANGE (PORT_PROTOCOL_UDP, 9966, 9966);
1174  RANGE (PORT_PROTOCOL_UDP, 9987, 9987);
1175  RANGE (PORT_PROTOCOL_UDP, 9990, 10003);
1176  RANGE (PORT_PROTOCOL_UDP, 10007, 10009);
1177  RANGE (PORT_PROTOCOL_UDP, 10050, 10051);
1178  RANGE (PORT_PROTOCOL_UDP, 10080, 10081);
1179  RANGE (PORT_PROTOCOL_UDP, 10100, 10104);
1180  RANGE (PORT_PROTOCOL_UDP, 10107, 10107);
1181  RANGE (PORT_PROTOCOL_UDP, 10110, 10111);
1182  RANGE (PORT_PROTOCOL_UDP, 10113, 10117);
1183  RANGE (PORT_PROTOCOL_UDP, 10128, 10128);
1184  RANGE (PORT_PROTOCOL_UDP, 10160, 10162);
1185  RANGE (PORT_PROTOCOL_UDP, 10200, 10201);
1186  RANGE (PORT_PROTOCOL_UDP, 10252, 10252);
1187  RANGE (PORT_PROTOCOL_UDP, 10260, 10260);
1188  RANGE (PORT_PROTOCOL_UDP, 10288, 10288);
1189  RANGE (PORT_PROTOCOL_UDP, 10500, 10500);
1190  RANGE (PORT_PROTOCOL_UDP, 10540, 10544);
1191  RANGE (PORT_PROTOCOL_UDP, 10800, 10800);
1192  RANGE (PORT_PROTOCOL_UDP, 10805, 10805);
1193  RANGE (PORT_PROTOCOL_UDP, 10810, 10810);
1194  RANGE (PORT_PROTOCOL_UDP, 10860, 10860);
1195  RANGE (PORT_PROTOCOL_UDP, 10990, 10990);
1196  RANGE (PORT_PROTOCOL_UDP, 11000, 11001);
1197  RANGE (PORT_PROTOCOL_UDP, 11106, 11106);
1198  RANGE (PORT_PROTOCOL_UDP, 11111, 11112);
1199  RANGE (PORT_PROTOCOL_UDP, 11161, 11165);
1200  RANGE (PORT_PROTOCOL_UDP, 11171, 11171);
1201  RANGE (PORT_PROTOCOL_UDP, 11201, 11201);
1202  RANGE (PORT_PROTOCOL_UDP, 11208, 11208);
1203  RANGE (PORT_PROTOCOL_UDP, 11211, 11211);
1204  RANGE (PORT_PROTOCOL_UDP, 11319, 11321);
1205  RANGE (PORT_PROTOCOL_UDP, 11367, 11367);
1206  RANGE (PORT_PROTOCOL_UDP, 11371, 11371);
1207  RANGE (PORT_PROTOCOL_UDP, 11600, 11600);
1208  RANGE (PORT_PROTOCOL_UDP, 11720, 11720);
1209  RANGE (PORT_PROTOCOL_UDP, 11751, 11751);
1210  RANGE (PORT_PROTOCOL_UDP, 11876, 11877);
1211  RANGE (PORT_PROTOCOL_UDP, 11967, 11967);
1212  RANGE (PORT_PROTOCOL_UDP, 12000, 12009);
1213  RANGE (PORT_PROTOCOL_UDP, 12012, 12013);
1214  RANGE (PORT_PROTOCOL_UDP, 12109, 12109);
1215  RANGE (PORT_PROTOCOL_UDP, 12121, 12121);
1216  RANGE (PORT_PROTOCOL_UDP, 12168, 12168);
1217  RANGE (PORT_PROTOCOL_UDP, 12172, 12172);
1218  RANGE (PORT_PROTOCOL_UDP, 12300, 12300);
1219  RANGE (PORT_PROTOCOL_UDP, 12321, 12322);
1220  RANGE (PORT_PROTOCOL_UDP, 12345, 12345);
1221  RANGE (PORT_PROTOCOL_UDP, 12753, 12753);
1222  RANGE (PORT_PROTOCOL_UDP, 13160, 13160);
1223  RANGE (PORT_PROTOCOL_UDP, 13216, 13218);
1224  RANGE (PORT_PROTOCOL_UDP, 13223, 13224);
1225  RANGE (PORT_PROTOCOL_UDP, 13400, 13400);
1226  RANGE (PORT_PROTOCOL_UDP, 13720, 13722);
1227  RANGE (PORT_PROTOCOL_UDP, 13724, 13724);
1228  RANGE (PORT_PROTOCOL_UDP, 13782, 13783);
1229  RANGE (PORT_PROTOCOL_UDP, 13785, 13786);
1230  RANGE (PORT_PROTOCOL_UDP, 13818, 13822);
1231  RANGE (PORT_PROTOCOL_UDP, 13929, 13929);
1232  RANGE (PORT_PROTOCOL_UDP, 14000, 14001);
1233  RANGE (PORT_PROTOCOL_UDP, 14033, 14034);
1234  RANGE (PORT_PROTOCOL_UDP, 14141, 14142);
1235  RANGE (PORT_PROTOCOL_UDP, 14145, 14145);
1236  RANGE (PORT_PROTOCOL_UDP, 14149, 14149);
1237  RANGE (PORT_PROTOCOL_UDP, 14154, 14154);
1238  RANGE (PORT_PROTOCOL_UDP, 14250, 14250);
1239  RANGE (PORT_PROTOCOL_UDP, 14414, 14414);
1240  RANGE (PORT_PROTOCOL_UDP, 14936, 14937);
1241  RANGE (PORT_PROTOCOL_UDP, 15000, 15000);
1242  RANGE (PORT_PROTOCOL_UDP, 15118, 15118);
1243  RANGE (PORT_PROTOCOL_UDP, 15345, 15345);
1244  RANGE (PORT_PROTOCOL_UDP, 15363, 15363);
1245  RANGE (PORT_PROTOCOL_UDP, 15555, 15555);
1246  RANGE (PORT_PROTOCOL_UDP, 15660, 15660);
1247  RANGE (PORT_PROTOCOL_UDP, 15740, 15740);
1248  RANGE (PORT_PROTOCOL_UDP, 15998, 15998);
1249  RANGE (PORT_PROTOCOL_UDP, 16003, 16003);
1250  RANGE (PORT_PROTOCOL_UDP, 16161, 16161);
1251  RANGE (PORT_PROTOCOL_UDP, 16309, 16311);
1252  RANGE (PORT_PROTOCOL_UDP, 16360, 16361);
1253  RANGE (PORT_PROTOCOL_UDP, 16367, 16368);
1254  RANGE (PORT_PROTOCOL_UDP, 16384, 16384);
1255  RANGE (PORT_PROTOCOL_UDP, 16666, 16666);
1256  RANGE (PORT_PROTOCOL_UDP, 16900, 16900);
1257  RANGE (PORT_PROTOCOL_UDP, 16950, 16950);
1258  RANGE (PORT_PROTOCOL_UDP, 16991, 16995);
1259  RANGE (PORT_PROTOCOL_UDP, 17007, 17007);
1260  RANGE (PORT_PROTOCOL_UDP, 17185, 17185);
1261  RANGE (PORT_PROTOCOL_UDP, 17219, 17219);
1262  RANGE (PORT_PROTOCOL_UDP, 17221, 17222);
1263  RANGE (PORT_PROTOCOL_UDP, 17234, 17235);
1264  RANGE (PORT_PROTOCOL_UDP, 17500, 17500);
1265  RANGE (PORT_PROTOCOL_UDP, 17729, 17729);
1266  RANGE (PORT_PROTOCOL_UDP, 17754, 17756);
1267  RANGE (PORT_PROTOCOL_UDP, 18000, 18000);
1268  RANGE (PORT_PROTOCOL_UDP, 18181, 18187);
1269  RANGE (PORT_PROTOCOL_UDP, 18241, 18241);
1270  RANGE (PORT_PROTOCOL_UDP, 18262, 18262);
1271  RANGE (PORT_PROTOCOL_UDP, 18463, 18463);
1272  RANGE (PORT_PROTOCOL_UDP, 18634, 18635);
1273  RANGE (PORT_PROTOCOL_UDP, 18769, 18769);
1274  RANGE (PORT_PROTOCOL_UDP, 18881, 18881);
1275  RANGE (PORT_PROTOCOL_UDP, 18888, 18888);
1276  RANGE (PORT_PROTOCOL_UDP, 19000, 19000);
1277  RANGE (PORT_PROTOCOL_UDP, 19191, 19191);
1278  RANGE (PORT_PROTOCOL_UDP, 19194, 19194);
1279  RANGE (PORT_PROTOCOL_UDP, 19283, 19283);
1280  RANGE (PORT_PROTOCOL_UDP, 19315, 19315);
1281  RANGE (PORT_PROTOCOL_UDP, 19398, 19398);
1282  RANGE (PORT_PROTOCOL_UDP, 19410, 19412);
1283  RANGE (PORT_PROTOCOL_UDP, 19539, 19541);
1284  RANGE (PORT_PROTOCOL_UDP, 19999, 20003);
1285  RANGE (PORT_PROTOCOL_UDP, 20005, 20005);
1286  RANGE (PORT_PROTOCOL_UDP, 20012, 20012);
1287  RANGE (PORT_PROTOCOL_UDP, 20014, 20014);
1288  RANGE (PORT_PROTOCOL_UDP, 20034, 20034);
1289  RANGE (PORT_PROTOCOL_UDP, 20046, 20046);
1290  RANGE (PORT_PROTOCOL_UDP, 20048, 20049);
1291  RANGE (PORT_PROTOCOL_UDP, 20167, 20167);
1292  RANGE (PORT_PROTOCOL_UDP, 20202, 20202);
1293  RANGE (PORT_PROTOCOL_UDP, 20222, 20222);
1294  RANGE (PORT_PROTOCOL_UDP, 20480, 20480);
1295  RANGE (PORT_PROTOCOL_UDP, 20670, 20670);
1296  RANGE (PORT_PROTOCOL_UDP, 20999, 21000);
1297  RANGE (PORT_PROTOCOL_UDP, 21554, 21554);
1298  RANGE (PORT_PROTOCOL_UDP, 21590, 21590);
1299  RANGE (PORT_PROTOCOL_UDP, 21800, 21800);
1300  RANGE (PORT_PROTOCOL_UDP, 21845, 21849);
1301  RANGE (PORT_PROTOCOL_UDP, 22000, 22005);
1302  RANGE (PORT_PROTOCOL_UDP, 22273, 22273);
1303  RANGE (PORT_PROTOCOL_UDP, 22305, 22305);
1304  RANGE (PORT_PROTOCOL_UDP, 22343, 22343);
1305  RANGE (PORT_PROTOCOL_UDP, 22347, 22347);
1306  RANGE (PORT_PROTOCOL_UDP, 22350, 22350);
1307  RANGE (PORT_PROTOCOL_UDP, 22555, 22555);
1308  RANGE (PORT_PROTOCOL_UDP, 22763, 22763);
1309  RANGE (PORT_PROTOCOL_UDP, 22800, 22800);
1310  RANGE (PORT_PROTOCOL_UDP, 22951, 22951);
1311  RANGE (PORT_PROTOCOL_UDP, 23000, 23005);
1312  RANGE (PORT_PROTOCOL_UDP, 23272, 23272);
1313  RANGE (PORT_PROTOCOL_UDP, 23333, 23333);
1314  RANGE (PORT_PROTOCOL_UDP, 23400, 23402);
1315  RANGE (PORT_PROTOCOL_UDP, 24000, 24006);
1316  RANGE (PORT_PROTOCOL_UDP, 24242, 24242);
1317  RANGE (PORT_PROTOCOL_UDP, 24249, 24249);
1318  RANGE (PORT_PROTOCOL_UDP, 24321, 24321);
1319  RANGE (PORT_PROTOCOL_UDP, 24386, 24386);
1320  RANGE (PORT_PROTOCOL_UDP, 24465, 24465);
1321  RANGE (PORT_PROTOCOL_UDP, 24554, 24554);
1322  RANGE (PORT_PROTOCOL_UDP, 24676, 24678);
1323  RANGE (PORT_PROTOCOL_UDP, 24680, 24680);
1324  RANGE (PORT_PROTOCOL_UDP, 24922, 24922);
1325  RANGE (PORT_PROTOCOL_UDP, 25000, 25009);
1326  RANGE (PORT_PROTOCOL_UDP, 25793, 25793);
1327  RANGE (PORT_PROTOCOL_UDP, 25900, 25903);
1328  RANGE (PORT_PROTOCOL_UDP, 26000, 26000);
1329  RANGE (PORT_PROTOCOL_UDP, 26133, 26133);
1330  RANGE (PORT_PROTOCOL_UDP, 26208, 26208);
1331  RANGE (PORT_PROTOCOL_UDP, 26260, 26263);
1332  RANGE (PORT_PROTOCOL_UDP, 26486, 26487);
1333  RANGE (PORT_PROTOCOL_UDP, 26489, 26489);
1334  RANGE (PORT_PROTOCOL_UDP, 27345, 27345);
1335  RANGE (PORT_PROTOCOL_UDP, 27442, 27442);
1336  RANGE (PORT_PROTOCOL_UDP, 27504, 27504);
1337  RANGE (PORT_PROTOCOL_UDP, 27782, 27782);
1338  RANGE (PORT_PROTOCOL_UDP, 27999, 28000);
1339  RANGE (PORT_PROTOCOL_UDP, 28240, 28240);
1340  RANGE (PORT_PROTOCOL_UDP, 29167, 29167);
1341  RANGE (PORT_PROTOCOL_UDP, 30001, 30002);
1342  RANGE (PORT_PROTOCOL_UDP, 30260, 30260);
1343  RANGE (PORT_PROTOCOL_UDP, 30999, 30999);
1344  RANGE (PORT_PROTOCOL_UDP, 31029, 31029);
1345  RANGE (PORT_PROTOCOL_UDP, 31416, 31416);
1346  RANGE (PORT_PROTOCOL_UDP, 31457, 31457);
1347  RANGE (PORT_PROTOCOL_UDP, 31620, 31620);
1348  RANGE (PORT_PROTOCOL_UDP, 31765, 31765);
1349  RANGE (PORT_PROTOCOL_UDP, 31948, 31949);
1350  RANGE (PORT_PROTOCOL_UDP, 32034, 32034);
1351  RANGE (PORT_PROTOCOL_UDP, 32249, 32249);
1352  RANGE (PORT_PROTOCOL_UDP, 32483, 32483);
1353  RANGE (PORT_PROTOCOL_UDP, 32635, 32636);
1354  RANGE (PORT_PROTOCOL_UDP, 32767, 32777);
1355  RANGE (PORT_PROTOCOL_UDP, 32801, 32801);
1356  RANGE (PORT_PROTOCOL_UDP, 32896, 32896);
1357  RANGE (PORT_PROTOCOL_UDP, 33123, 33123);
1358  RANGE (PORT_PROTOCOL_UDP, 33331, 33331);
1359  RANGE (PORT_PROTOCOL_UDP, 33334, 33334);
1360  RANGE (PORT_PROTOCOL_UDP, 33434, 33434);
1361  RANGE (PORT_PROTOCOL_UDP, 33656, 33656);
1362  RANGE (PORT_PROTOCOL_UDP, 34249, 34249);
1363  RANGE (PORT_PROTOCOL_UDP, 34378, 34379);
1364  RANGE (PORT_PROTOCOL_UDP, 34962, 34964);
1365  RANGE (PORT_PROTOCOL_UDP, 34980, 34980);
1366  RANGE (PORT_PROTOCOL_UDP, 35355, 35355);
1367  RANGE (PORT_PROTOCOL_UDP, 36001, 36001);
1368  RANGE (PORT_PROTOCOL_UDP, 36865, 36865);
1369  RANGE (PORT_PROTOCOL_UDP, 37475, 37475);
1370  RANGE (PORT_PROTOCOL_UDP, 37654, 37654);
1371  RANGE (PORT_PROTOCOL_UDP, 38201, 38203);
1372  RANGE (PORT_PROTOCOL_UDP, 39681, 39681);
1373  RANGE (PORT_PROTOCOL_UDP, 40000, 40000);
1374  RANGE (PORT_PROTOCOL_UDP, 40841, 40843);
1375  RANGE (PORT_PROTOCOL_UDP, 40853, 40853);
1376  RANGE (PORT_PROTOCOL_UDP, 41111, 41111);
1377  RANGE (PORT_PROTOCOL_UDP, 41794, 41795);
1378  RANGE (PORT_PROTOCOL_UDP, 42508, 42510);
1379  RANGE (PORT_PROTOCOL_UDP, 43188, 43190);
1380  RANGE (PORT_PROTOCOL_UDP, 43439, 43441);
1381  RANGE (PORT_PROTOCOL_UDP, 44321, 44323);
1382  RANGE (PORT_PROTOCOL_UDP, 44544, 44544);
1383  RANGE (PORT_PROTOCOL_UDP, 44553, 44553);
1384  RANGE (PORT_PROTOCOL_UDP, 44600, 44600);
1385  RANGE (PORT_PROTOCOL_UDP, 44818, 44818);
1386  RANGE (PORT_PROTOCOL_UDP, 45000, 45000);
1387  RANGE (PORT_PROTOCOL_UDP, 45054, 45054);
1388  RANGE (PORT_PROTOCOL_UDP, 45678, 45678);
1389  RANGE (PORT_PROTOCOL_UDP, 45825, 45825);
1390  RANGE (PORT_PROTOCOL_UDP, 45966, 45966);
1391  RANGE (PORT_PROTOCOL_UDP, 46999, 47000);
1392  RANGE (PORT_PROTOCOL_UDP, 47557, 47557);
1393  RANGE (PORT_PROTOCOL_UDP, 47624, 47624);
1394  RANGE (PORT_PROTOCOL_UDP, 47806, 47806);
1395  RANGE (PORT_PROTOCOL_UDP, 47808, 47808);
1396  RANGE (PORT_PROTOCOL_UDP, 48000, 48003);
1397  RANGE (PORT_PROTOCOL_UDP, 48128, 48129);
1398  RANGE (PORT_PROTOCOL_UDP, 48556, 48556);
1399 }
#define RANGE(type, start, end)
Insert a port range.

◆ make_port_ranges_nmap_5_51_top_2000_top_100()

void make_port_ranges_nmap_5_51_top_2000_top_100 ( port_list_t  list)

Make port ranges for Nmap top 2000 top 100.

Caller must lock the db.

Parameters
[in]listPort list.

Definition at line 48 of file manage_ranges_nmap_5_51_top_2000_top_100.c.

References RANGE.

49 {
50  RANGE (PORT_PROTOCOL_TCP, 1, 1);
51  RANGE (PORT_PROTOCOL_TCP, 3, 4);
52  RANGE (PORT_PROTOCOL_TCP, 6, 7);
53  RANGE (PORT_PROTOCOL_TCP, 9, 9);
54  RANGE (PORT_PROTOCOL_TCP, 13, 13);
55  RANGE (PORT_PROTOCOL_TCP, 17, 17);
56  RANGE (PORT_PROTOCOL_TCP, 19, 27);
57  RANGE (PORT_PROTOCOL_TCP, 30, 30);
58  RANGE (PORT_PROTOCOL_TCP, 32, 33);
59  RANGE (PORT_PROTOCOL_TCP, 37, 37);
60  RANGE (PORT_PROTOCOL_TCP, 42, 43);
61  RANGE (PORT_PROTOCOL_TCP, 49, 49);
62  RANGE (PORT_PROTOCOL_TCP, 53, 53);
63  RANGE (PORT_PROTOCOL_TCP, 55, 55);
64  RANGE (PORT_PROTOCOL_TCP, 57, 57);
65  RANGE (PORT_PROTOCOL_TCP, 59, 59);
66  RANGE (PORT_PROTOCOL_TCP, 70, 70);
67  RANGE (PORT_PROTOCOL_TCP, 77, 77);
68  RANGE (PORT_PROTOCOL_TCP, 79, 90);
69  RANGE (PORT_PROTOCOL_TCP, 98, 100);
70  RANGE (PORT_PROTOCOL_TCP, 102, 102);
71  RANGE (PORT_PROTOCOL_TCP, 106, 106);
72  RANGE (PORT_PROTOCOL_TCP, 109, 111);
73  RANGE (PORT_PROTOCOL_TCP, 113, 113);
74  RANGE (PORT_PROTOCOL_TCP, 119, 119);
75  RANGE (PORT_PROTOCOL_TCP, 123, 123);
76  RANGE (PORT_PROTOCOL_TCP, 125, 125);
77  RANGE (PORT_PROTOCOL_TCP, 127, 127);
78  RANGE (PORT_PROTOCOL_TCP, 135, 135);
79  RANGE (PORT_PROTOCOL_TCP, 139, 139);
80  RANGE (PORT_PROTOCOL_TCP, 143, 144);
81  RANGE (PORT_PROTOCOL_TCP, 146, 146);
82  RANGE (PORT_PROTOCOL_TCP, 157, 157);
83  RANGE (PORT_PROTOCOL_TCP, 161, 161);
84  RANGE (PORT_PROTOCOL_TCP, 163, 163);
85  RANGE (PORT_PROTOCOL_TCP, 179, 179);
86  RANGE (PORT_PROTOCOL_TCP, 199, 199);
87  RANGE (PORT_PROTOCOL_TCP, 210, 212);
88  RANGE (PORT_PROTOCOL_TCP, 220, 220);
89  RANGE (PORT_PROTOCOL_TCP, 222, 223);
90  RANGE (PORT_PROTOCOL_TCP, 225, 225);
91  RANGE (PORT_PROTOCOL_TCP, 250, 252);
92  RANGE (PORT_PROTOCOL_TCP, 254, 257);
93  RANGE (PORT_PROTOCOL_TCP, 259, 259);
94  RANGE (PORT_PROTOCOL_TCP, 264, 264);
95  RANGE (PORT_PROTOCOL_TCP, 280, 280);
96  RANGE (PORT_PROTOCOL_TCP, 301, 301);
97  RANGE (PORT_PROTOCOL_TCP, 306, 306);
98  RANGE (PORT_PROTOCOL_TCP, 311, 311);
99  RANGE (PORT_PROTOCOL_TCP, 333, 333);
100  RANGE (PORT_PROTOCOL_TCP, 340, 340);
101  RANGE (PORT_PROTOCOL_TCP, 366, 366);
102  RANGE (PORT_PROTOCOL_TCP, 388, 389);
103  RANGE (PORT_PROTOCOL_TCP, 406, 407);
104  RANGE (PORT_PROTOCOL_TCP, 411, 411);
105  RANGE (PORT_PROTOCOL_TCP, 416, 417);
106  RANGE (PORT_PROTOCOL_TCP, 419, 419);
107  RANGE (PORT_PROTOCOL_TCP, 425, 425);
108  RANGE (PORT_PROTOCOL_TCP, 427, 427);
109  RANGE (PORT_PROTOCOL_TCP, 441, 445);
110  RANGE (PORT_PROTOCOL_TCP, 447, 447);
111  RANGE (PORT_PROTOCOL_TCP, 458, 458);
112  RANGE (PORT_PROTOCOL_TCP, 464, 465);
113  RANGE (PORT_PROTOCOL_TCP, 475, 475);
114  RANGE (PORT_PROTOCOL_TCP, 481, 481);
115  RANGE (PORT_PROTOCOL_TCP, 497, 497);
116  RANGE (PORT_PROTOCOL_TCP, 500, 500);
117  RANGE (PORT_PROTOCOL_TCP, 502, 502);
118  RANGE (PORT_PROTOCOL_TCP, 512, 515);
119  RANGE (PORT_PROTOCOL_TCP, 523, 524);
120  RANGE (PORT_PROTOCOL_TCP, 540, 541);
121  RANGE (PORT_PROTOCOL_TCP, 543, 545);
122  RANGE (PORT_PROTOCOL_TCP, 548, 548);
123  RANGE (PORT_PROTOCOL_TCP, 554, 557);
124  RANGE (PORT_PROTOCOL_TCP, 563, 563);
125  RANGE (PORT_PROTOCOL_TCP, 587, 587);
126  RANGE (PORT_PROTOCOL_TCP, 593, 593);
127  RANGE (PORT_PROTOCOL_TCP, 600, 600);
128  RANGE (PORT_PROTOCOL_TCP, 602, 602);
129  RANGE (PORT_PROTOCOL_TCP, 606, 606);
130  RANGE (PORT_PROTOCOL_TCP, 610, 610);
131  RANGE (PORT_PROTOCOL_TCP, 616, 617);
132  RANGE (PORT_PROTOCOL_TCP, 621, 621);
133  RANGE (PORT_PROTOCOL_TCP, 623, 623);
134  RANGE (PORT_PROTOCOL_TCP, 625, 625);
135  RANGE (PORT_PROTOCOL_TCP, 631, 631);
136  RANGE (PORT_PROTOCOL_TCP, 636, 636);
137  RANGE (PORT_PROTOCOL_TCP, 639, 639);
138  RANGE (PORT_PROTOCOL_TCP, 641, 641);
139  RANGE (PORT_PROTOCOL_TCP, 646, 646);
140  RANGE (PORT_PROTOCOL_TCP, 648, 648);
141  RANGE (PORT_PROTOCOL_TCP, 655, 655);
142  RANGE (PORT_PROTOCOL_TCP, 657, 657);
143  RANGE (PORT_PROTOCOL_TCP, 659, 660);
144  RANGE (PORT_PROTOCOL_TCP, 666, 669);
145  RANGE (PORT_PROTOCOL_TCP, 674, 674);
146  RANGE (PORT_PROTOCOL_TCP, 683, 684);
147  RANGE (PORT_PROTOCOL_TCP, 687, 687);
148  RANGE (PORT_PROTOCOL_TCP, 690, 691);
149  RANGE (PORT_PROTOCOL_TCP, 700, 701);
150  RANGE (PORT_PROTOCOL_TCP, 705, 705);
151  RANGE (PORT_PROTOCOL_TCP, 709, 711);
152  RANGE (PORT_PROTOCOL_TCP, 713, 715);
153  RANGE (PORT_PROTOCOL_TCP, 720, 720);
154  RANGE (PORT_PROTOCOL_TCP, 722, 722);
155  RANGE (PORT_PROTOCOL_TCP, 725, 726);
156  RANGE (PORT_PROTOCOL_TCP, 728, 732);
157  RANGE (PORT_PROTOCOL_TCP, 740, 740);
158  RANGE (PORT_PROTOCOL_TCP, 748, 749);
159  RANGE (PORT_PROTOCOL_TCP, 754, 754);
160  RANGE (PORT_PROTOCOL_TCP, 757, 758);
161  RANGE (PORT_PROTOCOL_TCP, 765, 765);
162  RANGE (PORT_PROTOCOL_TCP, 777, 778);
163  RANGE (PORT_PROTOCOL_TCP, 780, 780);
164  RANGE (PORT_PROTOCOL_TCP, 782, 783);
165  RANGE (PORT_PROTOCOL_TCP, 786, 787);
166  RANGE (PORT_PROTOCOL_TCP, 790, 790);
167  RANGE (PORT_PROTOCOL_TCP, 792, 792);
168  RANGE (PORT_PROTOCOL_TCP, 795, 795);
169  RANGE (PORT_PROTOCOL_TCP, 800, 803);
170  RANGE (PORT_PROTOCOL_TCP, 805, 806);
171  RANGE (PORT_PROTOCOL_TCP, 808, 808);
172  RANGE (PORT_PROTOCOL_TCP, 822, 823);
173  RANGE (PORT_PROTOCOL_TCP, 825, 825);
174  RANGE (PORT_PROTOCOL_TCP, 829, 829);
175  RANGE (PORT_PROTOCOL_TCP, 839, 840);
176  RANGE (PORT_PROTOCOL_TCP, 843, 843);
177  RANGE (PORT_PROTOCOL_TCP, 846, 846);
178  RANGE (PORT_PROTOCOL_TCP, 856, 856);
179  RANGE (PORT_PROTOCOL_TCP, 859, 859);
180  RANGE (PORT_PROTOCOL_TCP, 862, 862);
181  RANGE (PORT_PROTOCOL_TCP, 864, 864);
182  RANGE (PORT_PROTOCOL_TCP, 873, 874);
183  RANGE (PORT_PROTOCOL_TCP, 878, 878);
184  RANGE (PORT_PROTOCOL_TCP, 880, 880);
185  RANGE (PORT_PROTOCOL_TCP, 888, 888);
186  RANGE (PORT_PROTOCOL_TCP, 898, 898);
187  RANGE (PORT_PROTOCOL_TCP, 900, 905);
188  RANGE (PORT_PROTOCOL_TCP, 911, 913);
189  RANGE (PORT_PROTOCOL_TCP, 918, 918);
190  RANGE (PORT_PROTOCOL_TCP, 921, 922);
191  RANGE (PORT_PROTOCOL_TCP, 924, 924);
192  RANGE (PORT_PROTOCOL_TCP, 928, 928);
193  RANGE (PORT_PROTOCOL_TCP, 930, 931);
194  RANGE (PORT_PROTOCOL_TCP, 943, 943);
195  RANGE (PORT_PROTOCOL_TCP, 953, 953);
196  RANGE (PORT_PROTOCOL_TCP, 969, 969);
197  RANGE (PORT_PROTOCOL_TCP, 971, 971);
198  RANGE (PORT_PROTOCOL_TCP, 980, 981);
199  RANGE (PORT_PROTOCOL_TCP, 987, 987);
200  RANGE (PORT_PROTOCOL_TCP, 990, 990);
201  RANGE (PORT_PROTOCOL_TCP, 992, 993);
202  RANGE (PORT_PROTOCOL_TCP, 995, 996);
203  RANGE (PORT_PROTOCOL_TCP, 998, 1002);
204  RANGE (PORT_PROTOCOL_TCP, 1004, 1015);
205  RANGE (PORT_PROTOCOL_TCP, 1020, 1114);
206  RANGE (PORT_PROTOCOL_TCP, 1116, 1119);
207  RANGE (PORT_PROTOCOL_TCP, 1121, 1128);
208  RANGE (PORT_PROTOCOL_TCP, 1130, 1132);
209  RANGE (PORT_PROTOCOL_TCP, 1134, 1138);
210  RANGE (PORT_PROTOCOL_TCP, 1141, 1141);
211  RANGE (PORT_PROTOCOL_TCP, 1143, 1145);
212  RANGE (PORT_PROTOCOL_TCP, 1147, 1154);
213  RANGE (PORT_PROTOCOL_TCP, 1156, 1159);
214  RANGE (PORT_PROTOCOL_TCP, 1162, 1169);
215  RANGE (PORT_PROTOCOL_TCP, 1173, 1176);
216  RANGE (PORT_PROTOCOL_TCP, 1179, 1180);
217  RANGE (PORT_PROTOCOL_TCP, 1182, 1188);
218  RANGE (PORT_PROTOCOL_TCP, 1190, 1192);
219  RANGE (PORT_PROTOCOL_TCP, 1194, 1196);
220  RANGE (PORT_PROTOCOL_TCP, 1198, 1201);
221  RANGE (PORT_PROTOCOL_TCP, 1204, 1204);
222  RANGE (PORT_PROTOCOL_TCP, 1207, 1213);
223  RANGE (PORT_PROTOCOL_TCP, 1215, 1218);
224  RANGE (PORT_PROTOCOL_TCP, 1220, 1223);
225  RANGE (PORT_PROTOCOL_TCP, 1228, 1229);
226  RANGE (PORT_PROTOCOL_TCP, 1233, 1234);
227  RANGE (PORT_PROTOCOL_TCP, 1236, 1236);
228  RANGE (PORT_PROTOCOL_TCP, 1239, 1241);
229  RANGE (PORT_PROTOCOL_TCP, 1243, 1244);
230  RANGE (PORT_PROTOCOL_TCP, 1247, 1251);
231  RANGE (PORT_PROTOCOL_TCP, 1259, 1259);
232  RANGE (PORT_PROTOCOL_TCP, 1261, 1262);
233  RANGE (PORT_PROTOCOL_TCP, 1264, 1264);
234  RANGE (PORT_PROTOCOL_TCP, 1268, 1268);
235  RANGE (PORT_PROTOCOL_TCP, 1270, 1272);
236  RANGE (PORT_PROTOCOL_TCP, 1276, 1277);
237  RANGE (PORT_PROTOCOL_TCP, 1279, 1279);
238  RANGE (PORT_PROTOCOL_TCP, 1282, 1282);
239  RANGE (PORT_PROTOCOL_TCP, 1287, 1287);
240  RANGE (PORT_PROTOCOL_TCP, 1290, 1291);
241  RANGE (PORT_PROTOCOL_TCP, 1296, 1297);
242  RANGE (PORT_PROTOCOL_TCP, 1299, 1303);
243  RANGE (PORT_PROTOCOL_TCP, 1305, 1311);
244  RANGE (PORT_PROTOCOL_TCP, 1314, 1319);
245  RANGE (PORT_PROTOCOL_TCP, 1321, 1322);
246  RANGE (PORT_PROTOCOL_TCP, 1324, 1324);
247  RANGE (PORT_PROTOCOL_TCP, 1327, 1328);
248  RANGE (PORT_PROTOCOL_TCP, 1330, 1331);
249  RANGE (PORT_PROTOCOL_TCP, 1334, 1334);
250  RANGE (PORT_PROTOCOL_TCP, 1336, 1337);
251  RANGE (PORT_PROTOCOL_TCP, 1339, 1340);
252  RANGE (PORT_PROTOCOL_TCP, 1347, 1347);
253  RANGE (PORT_PROTOCOL_TCP, 1350, 1353);
254  RANGE (PORT_PROTOCOL_TCP, 1357, 1357);
255  RANGE (PORT_PROTOCOL_TCP, 1413, 1414);
256  RANGE (PORT_PROTOCOL_TCP, 1417, 1417);
257  RANGE (PORT_PROTOCOL_TCP, 1433, 1434);
258  RANGE (PORT_PROTOCOL_TCP, 1443, 1443);
259  RANGE (PORT_PROTOCOL_TCP, 1455, 1455);
260  RANGE (PORT_PROTOCOL_TCP, 1461, 1461);
261  RANGE (PORT_PROTOCOL_TCP, 1494, 1494);
262  RANGE (PORT_PROTOCOL_TCP, 1500, 1501);
263  RANGE (PORT_PROTOCOL_TCP, 1503, 1503);
264  RANGE (PORT_PROTOCOL_TCP, 1516, 1516);
265  RANGE (PORT_PROTOCOL_TCP, 1521, 1522);
266  RANGE (PORT_PROTOCOL_TCP, 1524, 1526);
267  RANGE (PORT_PROTOCOL_TCP, 1533, 1533);
268  RANGE (PORT_PROTOCOL_TCP, 1547, 1547);
269  RANGE (PORT_PROTOCOL_TCP, 1550, 1550);
270  RANGE (PORT_PROTOCOL_TCP, 1556, 1556);
271  RANGE (PORT_PROTOCOL_TCP, 1558, 1560);
272  RANGE (PORT_PROTOCOL_TCP, 1565, 1566);
273  RANGE (PORT_PROTOCOL_TCP, 1569, 1569);
274  RANGE (PORT_PROTOCOL_TCP, 1580, 1580);
275  RANGE (PORT_PROTOCOL_TCP, 1583, 1584);
276  RANGE (PORT_PROTOCOL_TCP, 1592, 1592);
277  RANGE (PORT_PROTOCOL_TCP, 1594, 1594);
278  RANGE (PORT_PROTOCOL_TCP, 1598, 1598);
279  RANGE (PORT_PROTOCOL_TCP, 1600, 1600);
280  RANGE (PORT_PROTOCOL_TCP, 1605, 1605);
281  RANGE (PORT_PROTOCOL_TCP, 1607, 1607);
282  RANGE (PORT_PROTOCOL_TCP, 1615, 1615);
283  RANGE (PORT_PROTOCOL_TCP, 1620, 1620);
284  RANGE (PORT_PROTOCOL_TCP, 1622, 1622);
285  RANGE (PORT_PROTOCOL_TCP, 1632, 1632);
286  RANGE (PORT_PROTOCOL_TCP, 1635, 1635);
287  RANGE (PORT_PROTOCOL_TCP, 1638, 1638);
288  RANGE (PORT_PROTOCOL_TCP, 1641, 1641);
289  RANGE (PORT_PROTOCOL_TCP, 1645, 1645);
290  RANGE (PORT_PROTOCOL_TCP, 1658, 1658);
291  RANGE (PORT_PROTOCOL_TCP, 1666, 1666);
292  RANGE (PORT_PROTOCOL_TCP, 1677, 1677);
293  RANGE (PORT_PROTOCOL_TCP, 1683, 1683);
294  RANGE (PORT_PROTOCOL_TCP, 1687, 1688);
295  RANGE (PORT_PROTOCOL_TCP, 1691, 1691);
296  RANGE (PORT_PROTOCOL_TCP, 1694, 1694);
297  RANGE (PORT_PROTOCOL_TCP, 1699, 1701);
298  RANGE (PORT_PROTOCOL_TCP, 1703, 1703);
299  RANGE (PORT_PROTOCOL_TCP, 1707, 1709);
300  RANGE (PORT_PROTOCOL_TCP, 1711, 1713);
301  RANGE (PORT_PROTOCOL_TCP, 1715, 1715);
302  RANGE (PORT_PROTOCOL_TCP, 1717, 1723);
303  RANGE (PORT_PROTOCOL_TCP, 1730, 1730);
304  RANGE (PORT_PROTOCOL_TCP, 1735, 1736);
305  RANGE (PORT_PROTOCOL_TCP, 1745, 1745);
306  RANGE (PORT_PROTOCOL_TCP, 1750, 1750);
307  RANGE (PORT_PROTOCOL_TCP, 1752, 1753);
308  RANGE (PORT_PROTOCOL_TCP, 1755, 1755);
309  RANGE (PORT_PROTOCOL_TCP, 1761, 1761);
310  RANGE (PORT_PROTOCOL_TCP, 1782, 1783);
311  RANGE (PORT_PROTOCOL_TCP, 1791, 1792);
312  RANGE (PORT_PROTOCOL_TCP, 1799, 1801);
313  RANGE (PORT_PROTOCOL_TCP, 1805, 1808);
314  RANGE (PORT_PROTOCOL_TCP, 1811, 1812);
315  RANGE (PORT_PROTOCOL_TCP, 1823, 1823);
316  RANGE (PORT_PROTOCOL_TCP, 1825, 1825);
317  RANGE (PORT_PROTOCOL_TCP, 1835, 1835);
318  RANGE (PORT_PROTOCOL_TCP, 1839, 1840);
319  RANGE (PORT_PROTOCOL_TCP, 1858, 1858);
320  RANGE (PORT_PROTOCOL_TCP, 1861, 1864);
321  RANGE (PORT_PROTOCOL_TCP, 1871, 1871);
322  RANGE (PORT_PROTOCOL_TCP, 1875, 1875);
323  RANGE (PORT_PROTOCOL_TCP, 1900, 1901);
324  RANGE (PORT_PROTOCOL_TCP, 1911, 1912);
325  RANGE (PORT_PROTOCOL_TCP, 1914, 1914);
326  RANGE (PORT_PROTOCOL_TCP, 1918, 1918);
327  RANGE (PORT_PROTOCOL_TCP, 1924, 1924);
328  RANGE (PORT_PROTOCOL_TCP, 1927, 1927);
329  RANGE (PORT_PROTOCOL_TCP, 1935, 1935);
330  RANGE (PORT_PROTOCOL_TCP, 1947, 1947);
331  RANGE (PORT_PROTOCOL_TCP, 1954, 1954);
332  RANGE (PORT_PROTOCOL_TCP, 1958, 1958);
333  RANGE (PORT_PROTOCOL_TCP, 1971, 1976);
334  RANGE (PORT_PROTOCOL_TCP, 1981, 1981);
335  RANGE (PORT_PROTOCOL_TCP, 1984, 1984);
336  RANGE (PORT_PROTOCOL_TCP, 1998, 2013);
337  RANGE (PORT_PROTOCOL_TCP, 2020, 2022);
338  RANGE (PORT_PROTOCOL_TCP, 2025, 2025);
339  RANGE (PORT_PROTOCOL_TCP, 2030, 2031);
340  RANGE (PORT_PROTOCOL_TCP, 2033, 2035);
341  RANGE (PORT_PROTOCOL_TCP, 2038, 2038);
342  RANGE (PORT_PROTOCOL_TCP, 2040, 2049);
343  RANGE (PORT_PROTOCOL_TCP, 2062, 2062);
344  RANGE (PORT_PROTOCOL_TCP, 2065, 2065);
345  RANGE (PORT_PROTOCOL_TCP, 2067, 2070);
346  RANGE (PORT_PROTOCOL_TCP, 2080, 2083);
347  RANGE (PORT_PROTOCOL_TCP, 2086, 2087);
348  RANGE (PORT_PROTOCOL_TCP, 2095, 2096);
349  RANGE (PORT_PROTOCOL_TCP, 2099, 2101);
350  RANGE (PORT_PROTOCOL_TCP, 2103, 2107);
351  RANGE (PORT_PROTOCOL_TCP, 2111, 2112);
352  RANGE (PORT_PROTOCOL_TCP, 2115, 2115);
353  RANGE (PORT_PROTOCOL_TCP, 2119, 2119);
354  RANGE (PORT_PROTOCOL_TCP, 2121, 2121);
355  RANGE (PORT_PROTOCOL_TCP, 2124, 2124);
356  RANGE (PORT_PROTOCOL_TCP, 2126, 2126);
357  RANGE (PORT_PROTOCOL_TCP, 2134, 2135);
358  RANGE (PORT_PROTOCOL_TCP, 2142, 2142);
359  RANGE (PORT_PROTOCOL_TCP, 2144, 2144);
360  RANGE (PORT_PROTOCOL_TCP, 2148, 2148);
361  RANGE (PORT_PROTOCOL_TCP, 2150, 2150);
362  RANGE (PORT_PROTOCOL_TCP, 2160, 2161);
363  RANGE (PORT_PROTOCOL_TCP, 2170, 2170);
364  RANGE (PORT_PROTOCOL_TCP, 2179, 2179);
365  RANGE (PORT_PROTOCOL_TCP, 2187, 2187);
366  RANGE (PORT_PROTOCOL_TCP, 2190, 2191);
367  RANGE (PORT_PROTOCOL_TCP, 2196, 2197);
368  RANGE (PORT_PROTOCOL_TCP, 2200, 2201);
369  RANGE (PORT_PROTOCOL_TCP, 2203, 2203);
370  RANGE (PORT_PROTOCOL_TCP, 2222, 2222);
371  RANGE (PORT_PROTOCOL_TCP, 2224, 2224);
372  RANGE (PORT_PROTOCOL_TCP, 2232, 2232);
373  RANGE (PORT_PROTOCOL_TCP, 2241, 2241);
374  RANGE (PORT_PROTOCOL_TCP, 2250, 2251);
375  RANGE (PORT_PROTOCOL_TCP, 2253, 2253);
376  RANGE (PORT_PROTOCOL_TCP, 2260, 2262);
377  RANGE (PORT_PROTOCOL_TCP, 2265, 2265);
378  RANGE (PORT_PROTOCOL_TCP, 2269, 2271);
379  RANGE (PORT_PROTOCOL_TCP, 2280, 2280);
380  RANGE (PORT_PROTOCOL_TCP, 2288, 2288);
381  RANGE (PORT_PROTOCOL_TCP, 2291, 2292);
382  RANGE (PORT_PROTOCOL_TCP, 2300, 2302);
383  RANGE (PORT_PROTOCOL_TCP, 2304, 2304);
384  RANGE (PORT_PROTOCOL_TCP, 2312, 2313);
385  RANGE (PORT_PROTOCOL_TCP, 2323, 2323);
386  RANGE (PORT_PROTOCOL_TCP, 2325, 2326);
387  RANGE (PORT_PROTOCOL_TCP, 2330, 2330);
388  RANGE (PORT_PROTOCOL_TCP, 2335, 2335);
389  RANGE (PORT_PROTOCOL_TCP, 2340, 2340);
390  RANGE (PORT_PROTOCOL_TCP, 2366, 2366);
391  RANGE (PORT_PROTOCOL_TCP, 2371, 2372);
392  RANGE (PORT_PROTOCOL_TCP, 2381, 2383);
393  RANGE (PORT_PROTOCOL_TCP, 2391, 2391);
394  RANGE (PORT_PROTOCOL_TCP, 2393, 2394);
395  RANGE (PORT_PROTOCOL_TCP, 2399, 2399);
396  RANGE (PORT_PROTOCOL_TCP, 2401, 2401);
397  RANGE (PORT_PROTOCOL_TCP, 2418, 2418);
398  RANGE (PORT_PROTOCOL_TCP, 2425, 2425);
399  RANGE (PORT_PROTOCOL_TCP, 2433, 2433);
400  RANGE (PORT_PROTOCOL_TCP, 2435, 2436);
401  RANGE (PORT_PROTOCOL_TCP, 2438, 2439);
402  RANGE (PORT_PROTOCOL_TCP, 2449, 2449);
403  RANGE (PORT_PROTOCOL_TCP, 2456, 2456);
404  RANGE (PORT_PROTOCOL_TCP, 2463, 2463);
405  RANGE (PORT_PROTOCOL_TCP, 2472, 2472);
406  RANGE (PORT_PROTOCOL_TCP, 2492, 2492);
407  RANGE (PORT_PROTOCOL_TCP, 2500, 2501);
408  RANGE (PORT_PROTOCOL_TCP, 2505, 2505);
409  RANGE (PORT_PROTOCOL_TCP, 2522, 2522);
410  RANGE (PORT_PROTOCOL_TCP, 2525, 2525);
411  RANGE (PORT_PROTOCOL_TCP, 2531, 2532);
412  RANGE (PORT_PROTOCOL_TCP, 2550, 2551);
413  RANGE (PORT_PROTOCOL_TCP, 2557, 2558);
414  RANGE (PORT_PROTOCOL_TCP, 2567, 2567);
415  RANGE (PORT_PROTOCOL_TCP, 2580, 2580);
416  RANGE (PORT_PROTOCOL_TCP, 2583, 2584);
417  RANGE (PORT_PROTOCOL_TCP, 2598, 2598);
418  RANGE (PORT_PROTOCOL_TCP, 2600, 2602);
419  RANGE (PORT_PROTOCOL_TCP, 2604, 2608);
420  RANGE (PORT_PROTOCOL_TCP, 2622, 2623);
421  RANGE (PORT_PROTOCOL_TCP, 2628, 2628);
422  RANGE (PORT_PROTOCOL_TCP, 2631, 2631);
423  RANGE (PORT_PROTOCOL_TCP, 2638, 2638);
424  RANGE (PORT_PROTOCOL_TCP, 2644, 2644);
425  RANGE (PORT_PROTOCOL_TCP, 2691, 2691);
426  RANGE (PORT_PROTOCOL_TCP, 2700, 2702);
427  RANGE (PORT_PROTOCOL_TCP, 2706, 2706);
428  RANGE (PORT_PROTOCOL_TCP, 2710, 2712);
429  RANGE (PORT_PROTOCOL_TCP, 2717, 2718);
430  RANGE (PORT_PROTOCOL_TCP, 2723, 2723);
431  RANGE (PORT_PROTOCOL_TCP, 2725, 2725);
432  RANGE (PORT_PROTOCOL_TCP, 2728, 2728);
433  RANGE (PORT_PROTOCOL_TCP, 2734, 2734);
434  RANGE (PORT_PROTOCOL_TCP, 2800, 2800);
435  RANGE (PORT_PROTOCOL_TCP, 2804, 2804);
436  RANGE (PORT_PROTOCOL_TCP, 2806, 2806);
437  RANGE (PORT_PROTOCOL_TCP, 2809, 2809);
438  RANGE (PORT_PROTOCOL_TCP, 2811, 2812);
439  RANGE (PORT_PROTOCOL_TCP, 2847, 2847);
440  RANGE (PORT_PROTOCOL_TCP, 2850, 2850);
441  RANGE (PORT_PROTOCOL_TCP, 2869, 2869);
442  RANGE (PORT_PROTOCOL_TCP, 2875, 2875);
443  RANGE (PORT_PROTOCOL_TCP, 2882, 2882);
444  RANGE (PORT_PROTOCOL_TCP, 2888, 2889);
445  RANGE (PORT_PROTOCOL_TCP, 2898, 2898);
446  RANGE (PORT_PROTOCOL_TCP, 2901, 2903);
447  RANGE (PORT_PROTOCOL_TCP, 2908, 2910);
448  RANGE (PORT_PROTOCOL_TCP, 2920, 2920);
449  RANGE (PORT_PROTOCOL_TCP, 2930, 2930);
450  RANGE (PORT_PROTOCOL_TCP, 2957, 2958);
451  RANGE (PORT_PROTOCOL_TCP, 2967, 2968);
452  RANGE (PORT_PROTOCOL_TCP, 2973, 2973);
453  RANGE (PORT_PROTOCOL_TCP, 2984, 2984);
454  RANGE (PORT_PROTOCOL_TCP, 2987, 2988);
455  RANGE (PORT_PROTOCOL_TCP, 2991, 2991);
456  RANGE (PORT_PROTOCOL_TCP, 2997, 2998);
457  RANGE (PORT_PROTOCOL_TCP, 3000, 3003);
458  RANGE (PORT_PROTOCOL_TCP, 3005, 3007);
459  RANGE (PORT_PROTOCOL_TCP, 3011, 3011);
460  RANGE (PORT_PROTOCOL_TCP, 3013, 3014);
461  RANGE (PORT_PROTOCOL_TCP, 3017, 3017);
462  RANGE (PORT_PROTOCOL_TCP, 3023, 3023);
463  RANGE (PORT_PROTOCOL_TCP, 3025, 3025);
464  RANGE (PORT_PROTOCOL_TCP, 3030, 3031);
465  RANGE (PORT_PROTOCOL_TCP, 3050, 3050);
466  RANGE (PORT_PROTOCOL_TCP, 3052, 3052);
467  RANGE (PORT_PROTOCOL_TCP, 3057, 3057);
468  RANGE (PORT_PROTOCOL_TCP, 3062, 3063);
469  RANGE (PORT_PROTOCOL_TCP, 3071, 3071);
470  RANGE (PORT_PROTOCOL_TCP, 3077, 3077);
471  RANGE (PORT_PROTOCOL_TCP, 3080, 3080);
472  RANGE (PORT_PROTOCOL_TCP, 3089, 3089);
473  RANGE (PORT_PROTOCOL_TCP, 3102, 3103);
474  RANGE (PORT_PROTOCOL_TCP, 3118, 3119);
475  RANGE (PORT_PROTOCOL_TCP, 3121, 3121);
476  RANGE (PORT_PROTOCOL_TCP, 3128, 3128);
477  RANGE (PORT_PROTOCOL_TCP, 3146, 3146);
478  RANGE (PORT_PROTOCOL_TCP, 3162, 3162);
479  RANGE (PORT_PROTOCOL_TCP, 3167, 3168);
480  RANGE (PORT_PROTOCOL_TCP, 3190, 3190);
481  RANGE (PORT_PROTOCOL_TCP, 3200, 3200);
482  RANGE (PORT_PROTOCOL_TCP, 3210, 3211);
483  RANGE (PORT_PROTOCOL_TCP, 3220, 3221);
484  RANGE (PORT_PROTOCOL_TCP, 3240, 3240);
485  RANGE (PORT_PROTOCOL_TCP, 3260, 3261);
486  RANGE (PORT_PROTOCOL_TCP, 3263, 3263);
487  RANGE (PORT_PROTOCOL_TCP, 3268, 3269);
488  RANGE (PORT_PROTOCOL_TCP, 3280, 3281);
489  RANGE (PORT_PROTOCOL_TCP, 3283, 3283);
490  RANGE (PORT_PROTOCOL_TCP, 3291, 3291);
491  RANGE (PORT_PROTOCOL_TCP, 3299, 3301);
492  RANGE (PORT_PROTOCOL_TCP, 3304, 3304);
493  RANGE (PORT_PROTOCOL_TCP, 3306, 3307);
494  RANGE (PORT_PROTOCOL_TCP, 3310, 3311);
495  RANGE (PORT_PROTOCOL_TCP, 3319, 3319);
496  RANGE (PORT_PROTOCOL_TCP, 3322, 3325);
497  RANGE (PORT_PROTOCOL_TCP, 3333, 3334);
498  RANGE (PORT_PROTOCOL_TCP, 3351, 3351);
499  RANGE (PORT_PROTOCOL_TCP, 3362, 3363);
500  RANGE (PORT_PROTOCOL_TCP, 3365, 3365);
501  RANGE (PORT_PROTOCOL_TCP, 3367, 3372);
502  RANGE (PORT_PROTOCOL_TCP, 3374, 3374);
503  RANGE (PORT_PROTOCOL_TCP, 3376, 3376);
504  RANGE (PORT_PROTOCOL_TCP, 3388, 3390);
505  RANGE (PORT_PROTOCOL_TCP, 3396, 3396);
506  RANGE (PORT_PROTOCOL_TCP, 3399, 3400);
507  RANGE (PORT_PROTOCOL_TCP, 3404, 3404);
508  RANGE (PORT_PROTOCOL_TCP, 3410, 3410);
509  RANGE (PORT_PROTOCOL_TCP, 3414, 3415);
510  RANGE (PORT_PROTOCOL_TCP, 3419, 3419);
511  RANGE (PORT_PROTOCOL_TCP, 3425, 3425);
512  RANGE (PORT_PROTOCOL_TCP, 3430, 3430);
513  RANGE (PORT_PROTOCOL_TCP, 3439, 3439);
514  RANGE (PORT_PROTOCOL_TCP, 3443, 3443);
515  RANGE (PORT_PROTOCOL_TCP, 3456, 3456);
516  RANGE (PORT_PROTOCOL_TCP, 3476, 3476);
517  RANGE (PORT_PROTOCOL_TCP, 3479, 3479);
518  RANGE (PORT_PROTOCOL_TCP, 3483, 3483);
519  RANGE (PORT_PROTOCOL_TCP, 3485, 3486);
520  RANGE (PORT_PROTOCOL_TCP, 3493, 3493);
521  RANGE (PORT_PROTOCOL_TCP, 3497, 3497);
522  RANGE (PORT_PROTOCOL_TCP, 3503, 3503);
523  RANGE (PORT_PROTOCOL_TCP, 3505, 3506);
524  RANGE (PORT_PROTOCOL_TCP, 3511, 3511);
525  RANGE (PORT_PROTOCOL_TCP, 3513, 3515);
526  RANGE (PORT_PROTOCOL_TCP, 3517, 3517);
527  RANGE (PORT_PROTOCOL_TCP, 3519, 3520);
528  RANGE (PORT_PROTOCOL_TCP, 3526, 3527);
529  RANGE (PORT_PROTOCOL_TCP, 3530, 3530);
530  RANGE (PORT_PROTOCOL_TCP, 3532, 3532);
531  RANGE (PORT_PROTOCOL_TCP, 3546, 3546);
532  RANGE (PORT_PROTOCOL_TCP, 3551, 3551);
533  RANGE (PORT_PROTOCOL_TCP, 3577, 3577);
534  RANGE (PORT_PROTOCOL_TCP, 3580, 3580);
535  RANGE (PORT_PROTOCOL_TCP, 3586, 3586);
536  RANGE (PORT_PROTOCOL_TCP, 3599, 3600);
537  RANGE (PORT_PROTOCOL_TCP, 3602, 3603);
538  RANGE (PORT_PROTOCOL_TCP, 3621, 3622);
539  RANGE (PORT_PROTOCOL_TCP, 3632, 3632);
540  RANGE (PORT_PROTOCOL_TCP, 3636, 3637);
541  RANGE (PORT_PROTOCOL_TCP, 3652, 3653);
542  RANGE (PORT_PROTOCOL_TCP, 3656, 3656);
543  RANGE (PORT_PROTOCOL_TCP, 3658, 3659);
544  RANGE (PORT_PROTOCOL_TCP, 3663, 3663);
545  RANGE (PORT_PROTOCOL_TCP, 3669, 3670);
546  RANGE (PORT_PROTOCOL_TCP, 3672, 3672);
547  RANGE (PORT_PROTOCOL_TCP, 3680, 3681);
548  RANGE (PORT_PROTOCOL_TCP, 3683, 3684);
549  RANGE (PORT_PROTOCOL_TCP, 3689, 3690);
550  RANGE (PORT_PROTOCOL_TCP, 3697, 3697);
551  RANGE (PORT_PROTOCOL_TCP, 3700, 3700);
552  RANGE (PORT_PROTOCOL_TCP, 3703, 3703);
553  RANGE (PORT_PROTOCOL_TCP, 3712, 3712);
554  RANGE (PORT_PROTOCOL_TCP, 3728, 3728);
555  RANGE (PORT_PROTOCOL_TCP, 3731, 3731);
556  RANGE (PORT_PROTOCOL_TCP, 3737, 3737);
557  RANGE (PORT_PROTOCOL_TCP, 3742, 3742);
558  RANGE (PORT_PROTOCOL_TCP, 3749, 3749);
559  RANGE (PORT_PROTOCOL_TCP, 3765, 3766);
560  RANGE (PORT_PROTOCOL_TCP, 3784, 3784);
561  RANGE (PORT_PROTOCOL_TCP, 3787, 3788);
562  RANGE (PORT_PROTOCOL_TCP, 3790, 3790);
563  RANGE (PORT_PROTOCOL_TCP, 3792, 3793);
564  RANGE (PORT_PROTOCOL_TCP, 3795, 3796);
565  RANGE (PORT_PROTOCOL_TCP, 3798, 3801);
566  RANGE (PORT_PROTOCOL_TCP, 3803, 3803);
567  RANGE (PORT_PROTOCOL_TCP, 3806, 3806);
568  RANGE (PORT_PROTOCOL_TCP, 3808, 3814);
569  RANGE (PORT_PROTOCOL_TCP, 3817, 3817);
570  RANGE (PORT_PROTOCOL_TCP, 3820, 3820);
571  RANGE (PORT_PROTOCOL_TCP, 3823, 3828);
572  RANGE (PORT_PROTOCOL_TCP, 3830, 3831);
573  RANGE (PORT_PROTOCOL_TCP, 3837, 3837);
574  RANGE (PORT_PROTOCOL_TCP, 3839, 3839);
575  RANGE (PORT_PROTOCOL_TCP, 3842, 3842);
576  RANGE (PORT_PROTOCOL_TCP, 3846, 3853);
577  RANGE (PORT_PROTOCOL_TCP, 3856, 3856);
578  RANGE (PORT_PROTOCOL_TCP, 3859, 3860);
579  RANGE (PORT_PROTOCOL_TCP, 3863, 3863);
580  RANGE (PORT_PROTOCOL_TCP, 3868, 3872);
581  RANGE (PORT_PROTOCOL_TCP, 3876, 3876);
582  RANGE (PORT_PROTOCOL_TCP, 3878, 3880);
583  RANGE (PORT_PROTOCOL_TCP, 3882, 3882);
584  RANGE (PORT_PROTOCOL_TCP, 3888, 3890);
585  RANGE (PORT_PROTOCOL_TCP, 3897, 3897);
586  RANGE (PORT_PROTOCOL_TCP, 3899, 3899);
587  RANGE (PORT_PROTOCOL_TCP, 3901, 3902);
588  RANGE (PORT_PROTOCOL_TCP, 3904, 3909);
589  RANGE (PORT_PROTOCOL_TCP, 3911, 3911);
590  RANGE (PORT_PROTOCOL_TCP, 3913, 3916);
591  RANGE (PORT_PROTOCOL_TCP, 3918, 3920);
592  RANGE (PORT_PROTOCOL_TCP, 3922, 3923);
593  RANGE (PORT_PROTOCOL_TCP, 3928, 3931);
594  RANGE (PORT_PROTOCOL_TCP, 3935, 3937);
595  RANGE (PORT_PROTOCOL_TCP, 3940, 3941);
596  RANGE (PORT_PROTOCOL_TCP, 3943, 3946);
597  RANGE (PORT_PROTOCOL_TCP, 3948, 3949);
598  RANGE (PORT_PROTOCOL_TCP, 3952, 3952);
599  RANGE (PORT_PROTOCOL_TCP, 3956, 3957);
600  RANGE (PORT_PROTOCOL_TCP, 3961, 3964);
601  RANGE (PORT_PROTOCOL_TCP, 3967, 3969);
602  RANGE (PORT_PROTOCOL_TCP, 3971, 3972);
603  RANGE (PORT_PROTOCOL_TCP, 3975, 3975);
604  RANGE (PORT_PROTOCOL_TCP, 3979, 3983);
605  RANGE (PORT_PROTOCOL_TCP, 3986, 3986);
606  RANGE (PORT_PROTOCOL_TCP, 3989, 4007);
607  RANGE (PORT_PROTOCOL_TCP, 4009, 4010);
608  RANGE (PORT_PROTOCOL_TCP, 4016, 4016);
609  RANGE (PORT_PROTOCOL_TCP, 4020, 4020);
610  RANGE (PORT_PROTOCOL_TCP, 4022, 4022);
611  RANGE (PORT_PROTOCOL_TCP, 4024, 4025);
612  RANGE (PORT_PROTOCOL_TCP, 4029, 4029);
613  RANGE (PORT_PROTOCOL_TCP, 4035, 4036);
614  RANGE (PORT_PROTOCOL_TCP, 4039, 4040);
615  RANGE (PORT_PROTOCOL_TCP, 4045, 4045);
616  RANGE (PORT_PROTOCOL_TCP, 4056, 4056);
617  RANGE (PORT_PROTOCOL_TCP, 4058, 4058);
618  RANGE (PORT_PROTOCOL_TCP, 4065, 4065);
619  RANGE (PORT_PROTOCOL_TCP, 4080, 4080);
620  RANGE (PORT_PROTOCOL_TCP, 4087, 4087);
621  RANGE (PORT_PROTOCOL_TCP, 4090, 4090);
622  RANGE (PORT_PROTOCOL_TCP, 4096, 4096);
623  RANGE (PORT_PROTOCOL_TCP, 4100, 4101);
624  RANGE (PORT_PROTOCOL_TCP, 4111, 4113);
625  RANGE (PORT_PROTOCOL_TCP, 4118, 4121);
626  RANGE (PORT_PROTOCOL_TCP, 4125, 4126);
627  RANGE (PORT_PROTOCOL_TCP, 4129, 4129);
628  RANGE (PORT_PROTOCOL_TCP, 4135, 4135);
629  RANGE (PORT_PROTOCOL_TCP, 4141, 4141);
630  RANGE (PORT_PROTOCOL_TCP, 4143, 4143);
631  RANGE (PORT_PROTOCOL_TCP, 4147, 4147);
632  RANGE (PORT_PROTOCOL_TCP, 4158, 4158);
633  RANGE (PORT_PROTOCOL_TCP, 4161, 4161);
634  RANGE (PORT_PROTOCOL_TCP, 4164, 4164);
635  RANGE (PORT_PROTOCOL_TCP, 4174, 4174);
636  RANGE (PORT_PROTOCOL_TCP, 4190, 4190);
637  RANGE (PORT_PROTOCOL_TCP, 4192, 4192);
638  RANGE (PORT_PROTOCOL_TCP, 4200, 4200);
639  RANGE (PORT_PROTOCOL_TCP, 4206, 4206);
640  RANGE (PORT_PROTOCOL_TCP, 4220, 4220);
641  RANGE (PORT_PROTOCOL_TCP, 4224, 4224);
642  RANGE (PORT_PROTOCOL_TCP, 4234, 4234);
643  RANGE (PORT_PROTOCOL_TCP, 4242, 4242);
644  RANGE (PORT_PROTOCOL_TCP, 4252, 4252);
645  RANGE (PORT_PROTOCOL_TCP, 4262, 4262);
646  RANGE (PORT_PROTOCOL_TCP, 4279, 4279);
647  RANGE (PORT_PROTOCOL_TCP, 4294, 4294);
648  RANGE (PORT_PROTOCOL_TCP, 4297, 4298);
649  RANGE (PORT_PROTOCOL_TCP, 4300, 4300);
650  RANGE (PORT_PROTOCOL_TCP, 4302, 4302);
651  RANGE (PORT_PROTOCOL_TCP, 4321, 4321);
652  RANGE (PORT_PROTOCOL_TCP, 4325, 4325);
653  RANGE (PORT_PROTOCOL_TCP, 4328, 4328);
654  RANGE (PORT_PROTOCOL_TCP, 4333, 4333);
655  RANGE (PORT_PROTOCOL_TCP, 4342, 4343);
656  RANGE (PORT_PROTOCOL_TCP, 4355, 4358);
657  RANGE (PORT_PROTOCOL_TCP, 4369, 4369);
658  RANGE (PORT_PROTOCOL_TCP, 4374, 4376);
659  RANGE (PORT_PROTOCOL_TCP, 4384, 4384);
660  RANGE (PORT_PROTOCOL_TCP, 4388, 4388);
661  RANGE (PORT_PROTOCOL_TCP, 4401, 4401);
662  RANGE (PORT_PROTOCOL_TCP, 4407, 4407);
663  RANGE (PORT_PROTOCOL_TCP, 4414, 4415);
664  RANGE (PORT_PROTOCOL_TCP, 4418, 4418);
665  RANGE (PORT_PROTOCOL_TCP, 4430, 4430);
666  RANGE (PORT_PROTOCOL_TCP, 4433, 4433);
667  RANGE (PORT_PROTOCOL_TCP, 4442, 4447);
668  RANGE (PORT_PROTOCOL_TCP, 4449, 4449);
669  RANGE (PORT_PROTOCOL_TCP, 4454, 4454);
670  RANGE (PORT_PROTOCOL_TCP, 4464, 4464);
671  RANGE (PORT_PROTOCOL_TCP, 4471, 4471);
672  RANGE (PORT_PROTOCOL_TCP, 4476, 4476);
673  RANGE (PORT_PROTOCOL_TCP, 4516, 4517);
674  RANGE (PORT_PROTOCOL_TCP, 4530, 4530);
675  RANGE (PORT_PROTOCOL_TCP, 4534, 4534);
676  RANGE (PORT_PROTOCOL_TCP, 4545, 4545);
677  RANGE (PORT_PROTOCOL_TCP, 4550, 4550);
678  RANGE (PORT_PROTOCOL_TCP, 4555, 4555);
679  RANGE (PORT_PROTOCOL_TCP, 4558, 4559);
680  RANGE (PORT_PROTOCOL_TCP, 4567, 4567);
681  RANGE (PORT_PROTOCOL_TCP, 4570, 4570);
682  RANGE (PORT_PROTOCOL_TCP, 4599, 4602);
683  RANGE (PORT_PROTOCOL_TCP, 4606, 4606);
684  RANGE (PORT_PROTOCOL_TCP, 4609, 4609);
685  RANGE (PORT_PROTOCOL_TCP, 4644, 4644);
686  RANGE (PORT_PROTOCOL_TCP, 4649, 4649);
687  RANGE (PORT_PROTOCOL_TCP, 4658, 4658);
688  RANGE (PORT_PROTOCOL_TCP, 4662, 4662);
689  RANGE (PORT_PROTOCOL_TCP, 4665, 4665);
690  RANGE (PORT_PROTOCOL_TCP, 4687, 4687);
691  RANGE (PORT_PROTOCOL_TCP, 4689, 4689);
692  RANGE (PORT_PROTOCOL_TCP, 4700, 4700);
693  RANGE (PORT_PROTOCOL_TCP, 4712, 4712);
694  RANGE (PORT_PROTOCOL_TCP, 4745, 4745);
695  RANGE (PORT_PROTOCOL_TCP, 4760, 4760);
696  RANGE (PORT_PROTOCOL_TCP, 4767, 4767);
697  RANGE (PORT_PROTOCOL_TCP, 4770, 4771);
698  RANGE (PORT_PROTOCOL_TCP, 4778, 4778);
699  RANGE (PORT_PROTOCOL_TCP, 4793, 4793);
700  RANGE (PORT_PROTOCOL_TCP, 4800, 4800);
701  RANGE (PORT_PROTOCOL_TCP, 4819, 4819);
702  RANGE (PORT_PROTOCOL_TCP, 4848, 4848);
703  RANGE (PORT_PROTOCOL_TCP, 4859, 4860);
704  RANGE (PORT_PROTOCOL_TCP, 4875, 4877);
705  RANGE (PORT_PROTOCOL_TCP, 4881, 4881);
706  RANGE (PORT_PROTOCOL_TCP, 4899, 4900);
707  RANGE (PORT_PROTOCOL_TCP, 4903, 4903);
708  RANGE (PORT_PROTOCOL_TCP, 4912, 4912);
709  RANGE (PORT_PROTOCOL_TCP, 4931, 4931);
710  RANGE (PORT_PROTOCOL_TCP, 4949, 4949);
711  RANGE (PORT_PROTOCOL_TCP, 4998, 5005);
712  RANGE (PORT_PROTOCOL_TCP, 5009, 5017);
713  RANGE (PORT_PROTOCOL_TCP, 5020, 5021);
714  RANGE (PORT_PROTOCOL_TCP, 5023, 5023);
715  RANGE (PORT_PROTOCOL_TCP, 5030, 5030);
716  RANGE (PORT_PROTOCOL_TCP, 5033, 5033);
717  RANGE (PORT_PROTOCOL_TCP, 5040, 5040);
718  RANGE (PORT_PROTOCOL_TCP, 5050, 5055);
719  RANGE (PORT_PROTOCOL_TCP, 5060, 5061);
720  RANGE (PORT_PROTOCOL_TCP, 5063, 5063);
721  RANGE (PORT_PROTOCOL_TCP, 5066, 5066);
722  RANGE (PORT_PROTOCOL_TCP, 5070, 5070);
723  RANGE (PORT_PROTOCOL_TCP, 5074, 5074);
724  RANGE (PORT_PROTOCOL_TCP, 5080, 5081);
725  RANGE (PORT_PROTOCOL_TCP, 5087, 5088);
726  RANGE (PORT_PROTOCOL_TCP, 5090, 5090);
727  RANGE (PORT_PROTOCOL_TCP, 5095, 5096);
728  RANGE (PORT_PROTOCOL_TCP, 5098, 5098);
729  RANGE (PORT_PROTOCOL_TCP, 5100, 5102);
730  RANGE (PORT_PROTOCOL_TCP, 5111, 5111);
731  RANGE (PORT_PROTOCOL_TCP, 5114, 5114);
732  RANGE (PORT_PROTOCOL_TCP, 5120, 5122);
733  RANGE (PORT_PROTOCOL_TCP, 5125, 5125);
734  RANGE (PORT_PROTOCOL_TCP, 5133, 5133);
735  RANGE (PORT_PROTOCOL_TCP, 5137, 5137);
736  RANGE (PORT_PROTOCOL_TCP, 5147, 5147);
737  RANGE (PORT_PROTOCOL_TCP, 5151, 5152);
738  RANGE (PORT_PROTOCOL_TCP, 5190, 5190);
739  RANGE (PORT_PROTOCOL_TCP, 5200, 5202);
740  RANGE (PORT_PROTOCOL_TCP, 5212, 5212);
741  RANGE (PORT_PROTOCOL_TCP, 5214, 5214);
742  RANGE (PORT_PROTOCOL_TCP, 5219, 5219);
743  RANGE (PORT_PROTOCOL_TCP, 5221, 5223);
744  RANGE (PORT_PROTOCOL_TCP, 5225, 5226);
745  RANGE (PORT_PROTOCOL_TCP, 5233, 5235);
746  RANGE (PORT_PROTOCOL_TCP, 5242, 5242);
747  RANGE (PORT_PROTOCOL_TCP, 5250, 5250);
748  RANGE (PORT_PROTOCOL_TCP, 5252, 5252);
749  RANGE (PORT_PROTOCOL_TCP, 5259, 5259);
750  RANGE (PORT_PROTOCOL_TCP, 5261, 5261);
751  RANGE (PORT_PROTOCOL_TCP, 5269, 5269);
752  RANGE (PORT_PROTOCOL_TCP, 5279, 5280);
753  RANGE (PORT_PROTOCOL_TCP, 5291, 5291);
754  RANGE (PORT_PROTOCOL_TCP, 5298, 5298);
755  RANGE (PORT_PROTOCOL_TCP, 5339, 5339);
756  RANGE (PORT_PROTOCOL_TCP, 5347, 5347);
757  RANGE (PORT_PROTOCOL_TCP, 5353, 5353);
758  RANGE (PORT_PROTOCOL_TCP, 5357, 5357);
759  RANGE (PORT_PROTOCOL_TCP, 5370, 5370);
760  RANGE (PORT_PROTOCOL_TCP, 5377, 5377);
761  RANGE (PORT_PROTOCOL_TCP, 5405, 5405);
762  RANGE (PORT_PROTOCOL_TCP, 5414, 5414);
763  RANGE (PORT_PROTOCOL_TCP, 5423, 5423);
764  RANGE (PORT_PROTOCOL_TCP, 5431, 5433);
765  RANGE (PORT_PROTOCOL_TCP, 5440, 5442);
766  RANGE (PORT_PROTOCOL_TCP, 5444, 5444);
767  RANGE (PORT_PROTOCOL_TCP, 5457, 5458);
768  RANGE (PORT_PROTOCOL_TCP, 5473, 5473);
769  RANGE (PORT_PROTOCOL_TCP, 5475, 5475);
770  RANGE (PORT_PROTOCOL_TCP, 5500, 5502);
771  RANGE (PORT_PROTOCOL_TCP, 5510, 5510);
772  RANGE (PORT_PROTOCOL_TCP, 5520, 5520);
773  RANGE (PORT_PROTOCOL_TCP, 5544, 5544);
774  RANGE (PORT_PROTOCOL_TCP, 5550, 5550);
775  RANGE (PORT_PROTOCOL_TCP, 5552, 5555);
776  RANGE (PORT_PROTOCOL_TCP, 5557, 5557);
777  RANGE (PORT_PROTOCOL_TCP, 5560, 5560);
778  RANGE (PORT_PROTOCOL_TCP, 5566, 5566);
779  RANGE (PORT_PROTOCOL_TCP, 5631, 5631);
780  RANGE (PORT_PROTOCOL_TCP, 5633, 5633);
781  RANGE (PORT_PROTOCOL_TCP, 5666, 5666);
782  RANGE (PORT_PROTOCOL_TCP, 5678, 5680);
783  RANGE (PORT_PROTOCOL_TCP, 5718, 5718);
784  RANGE (PORT_PROTOCOL_TCP, 5730, 5730);
785  RANGE (PORT_PROTOCOL_TCP, 5800, 5803);
786  RANGE (PORT_PROTOCOL_TCP, 5807, 5807);
787  RANGE (PORT_PROTOCOL_TCP, 5810, 5812);
788  RANGE (PORT_PROTOCOL_TCP, 5815, 5815);
789  RANGE (PORT_PROTOCOL_TCP, 5818, 5818);
790  RANGE (PORT_PROTOCOL_TCP, 5822, 5823);
791  RANGE (PORT_PROTOCOL_TCP, 5825, 5825);
792  RANGE (PORT_PROTOCOL_TCP, 5850, 5850);
793  RANGE (PORT_PROTOCOL_TCP, 5859, 5859);
794  RANGE (PORT_PROTOCOL_TCP, 5862, 5862);
795  RANGE (PORT_PROTOCOL_TCP, 5868, 5869);
796  RANGE (PORT_PROTOCOL_TCP, 5877, 5877);
797  RANGE (PORT_PROTOCOL_TCP, 5899, 5907);
798  RANGE (PORT_PROTOCOL_TCP, 5909, 5911);
799  RANGE (PORT_PROTOCOL_TCP, 5914, 5915);
800  RANGE (PORT_PROTOCOL_TCP, 5918, 5918);
801  RANGE (PORT_PROTOCOL_TCP, 5922, 5922);
802  RANGE (PORT_PROTOCOL_TCP, 5925, 5925);
803  RANGE (PORT_PROTOCOL_TCP, 5938, 5938);
804  RANGE (PORT_PROTOCOL_TCP, 5940, 5940);
805  RANGE (PORT_PROTOCOL_TCP, 5950, 5950);
806  RANGE (PORT_PROTOCOL_TCP, 5952, 5952);
807  RANGE (PORT_PROTOCOL_TCP, 5959, 5963);
808  RANGE (PORT_PROTOCOL_TCP, 5968, 5968);
809  RANGE (PORT_PROTOCOL_TCP, 5981, 5981);
810  RANGE (PORT_PROTOCOL_TCP, 5987, 5989);
811  RANGE (PORT_PROTOCOL_TCP, 5998, 6009);
812  RANGE (PORT_PROTOCOL_TCP, 6017, 6017);
813  RANGE (PORT_PROTOCOL_TCP, 6025, 6025);
814  RANGE (PORT_PROTOCOL_TCP, 6050, 6051);
815  RANGE (PORT_PROTOCOL_TCP, 6059, 6060);
816  RANGE (PORT_PROTOCOL_TCP, 6068, 6068);
817  RANGE (PORT_PROTOCOL_TCP, 6100, 6101);
818  RANGE (PORT_PROTOCOL_TCP, 6103, 6103);
819  RANGE (PORT_PROTOCOL_TCP, 6106, 6106);
820  RANGE (PORT_PROTOCOL_TCP, 6112, 6112);
821  RANGE (PORT_PROTOCOL_TCP, 6123, 6123);
822  RANGE (PORT_PROTOCOL_TCP, 6129, 6129);
823  RANGE (PORT_PROTOCOL_TCP, 6156, 6156);
824  RANGE (PORT_PROTOCOL_TCP, 6203, 6203);
825  RANGE (PORT_PROTOCOL_TCP, 6222, 6222);
826  RANGE (PORT_PROTOCOL_TCP, 6247, 6247);
827  RANGE (PORT_PROTOCOL_TCP, 6346, 6346);
828  RANGE (PORT_PROTOCOL_TCP, 6389, 6389);
829  RANGE (PORT_PROTOCOL_TCP, 6481, 6481);
830  RANGE (PORT_PROTOCOL_TCP, 6500, 6500);
831  RANGE (PORT_PROTOCOL_TCP, 6502, 6502);
832  RANGE (PORT_PROTOCOL_TCP, 6504, 6504);
833  RANGE (PORT_PROTOCOL_TCP, 6510, 6510);
834  RANGE (PORT_PROTOCOL_TCP, 6520, 6520);
835  RANGE (PORT_PROTOCOL_TCP, 6543, 6543);
836  RANGE (PORT_PROTOCOL_TCP, 6547, 6547);
837  RANGE (PORT_PROTOCOL_TCP, 6550, 6550);
838  RANGE (PORT_PROTOCOL_TCP, 6565, 6567);
839  RANGE (PORT_PROTOCOL_TCP, 6580, 6580);
840  RANGE (PORT_PROTOCOL_TCP, 6600, 6600);
841  RANGE (PORT_PROTOCOL_TCP, 6646, 6646);
842  RANGE (PORT_PROTOCOL_TCP, 6662, 6662);
843  RANGE (PORT_PROTOCOL_TCP, 6666, 6670);
844  RANGE (PORT_PROTOCOL_TCP, 6689, 6689);
845  RANGE (PORT_PROTOCOL_TCP, 6692, 6692);
846  RANGE (PORT_PROTOCOL_TCP, 6699, 6699);
847  RANGE (PORT_PROTOCOL_TCP, 6711, 6711);
848  RANGE (PORT_PROTOCOL_TCP, 6732, 6732);
849  RANGE (PORT_PROTOCOL_TCP, 6779, 6779);
850  RANGE (PORT_PROTOCOL_TCP, 6788, 6789);
851  RANGE (PORT_PROTOCOL_TCP, 6792, 6792);
852  RANGE (PORT_PROTOCOL_TCP, 6839, 6839);
853  RANGE (PORT_PROTOCOL_TCP, 6881, 6881);
854  RANGE (PORT_PROTOCOL_TCP, 6896, 6896);
855  RANGE (PORT_PROTOCOL_TCP, 6901, 6901);
856  RANGE (PORT_PROTOCOL_TCP, 6969, 6969);
857  RANGE (PORT_PROTOCOL_TCP, 7000, 7004);
858  RANGE (PORT_PROTOCOL_TCP, 7007, 7007);
859  RANGE (PORT_PROTOCOL_TCP, 7010, 7010);
860  RANGE (PORT_PROTOCOL_TCP, 7019, 7019);
861  RANGE (PORT_PROTOCOL_TCP, 7024, 7025);
862  RANGE (PORT_PROTOCOL_TCP, 7050, 7051);
863  RANGE (PORT_PROTOCOL_TCP, 7070, 7070);
864  RANGE (PORT_PROTOCOL_TCP, 7080, 7080);
865  RANGE (PORT_PROTOCOL_TCP, 7100, 7100);
866  RANGE (PORT_PROTOCOL_TCP, 7103, 7103);
867  RANGE (PORT_PROTOCOL_TCP, 7106, 7106);
868  RANGE (PORT_PROTOCOL_TCP, 7123, 7123);
869  RANGE (PORT_PROTOCOL_TCP, 7200, 7201);
870  RANGE (PORT_PROTOCOL_TCP, 7241, 7241);
871  RANGE (PORT_PROTOCOL_TCP, 7272, 7272);
872  RANGE (PORT_PROTOCOL_TCP, 7278, 7278);
873  RANGE (PORT_PROTOCOL_TCP, 7281, 7281);
874  RANGE (PORT_PROTOCOL_TCP, 7402, 7402);
875  RANGE (PORT_PROTOCOL_TCP, 7435, 7435);
876  RANGE (PORT_PROTOCOL_TCP, 7438, 7438);
877  RANGE (PORT_PROTOCOL_TCP, 7443, 7443);
878  RANGE (PORT_PROTOCOL_TCP, 7496, 7496);
879  RANGE (PORT_PROTOCOL_TCP, 7512, 7512);
880  RANGE (PORT_PROTOCOL_TCP, 7625, 7625);
881  RANGE (PORT_PROTOCOL_TCP, 7627, 7627);
882  RANGE (PORT_PROTOCOL_TCP, 7676, 7676);
883  RANGE (PORT_PROTOCOL_TCP, 7725, 7725);
884  RANGE (PORT_PROTOCOL_TCP, 7741, 7741);
885  RANGE (PORT_PROTOCOL_TCP, 7744, 7744);
886  RANGE (PORT_PROTOCOL_TCP, 7749, 7749);
887  RANGE (PORT_PROTOCOL_TCP, 7770, 7770);
888  RANGE (PORT_PROTOCOL_TCP, 7777, 7778);
889  RANGE (PORT_PROTOCOL_TCP, 7800, 7800);
890  RANGE (PORT_PROTOCOL_TCP, 7878, 7878);
891  RANGE (PORT_PROTOCOL_TCP, 7900, 7900);
892  RANGE (PORT_PROTOCOL_TCP, 7911, 7911);
893  RANGE (PORT_PROTOCOL_TCP, 7913, 7913);
894  RANGE (PORT_PROTOCOL_TCP, 7920, 7921);
895  RANGE (PORT_PROTOCOL_TCP, 7929, 7929);
896  RANGE (PORT_PROTOCOL_TCP, 7937, 7938);
897  RANGE (PORT_PROTOCOL_TCP, 7999, 8002);
898  RANGE (PORT_PROTOCOL_TCP, 8007, 8011);
899  RANGE (PORT_PROTOCOL_TCP, 8015, 8016);
900  RANGE (PORT_PROTOCOL_TCP, 8019, 8019);
901  RANGE (PORT_PROTOCOL_TCP, 8021, 8022);
902  RANGE (PORT_PROTOCOL_TCP, 8031, 8031);
903  RANGE (PORT_PROTOCOL_TCP, 8042, 8042);
904  RANGE (PORT_PROTOCOL_TCP, 8045, 8045);
905  RANGE (PORT_PROTOCOL_TCP, 8050, 8050);
906  RANGE (PORT_PROTOCOL_TCP, 8080, 8090);
907  RANGE (PORT_PROTOCOL_TCP, 8093, 8093);
908  RANGE (PORT_PROTOCOL_TCP, 8095, 8095);
909  RANGE (PORT_PROTOCOL_TCP, 8097, 8100);
910  RANGE (PORT_PROTOCOL_TCP, 8118, 8118);
911  RANGE (PORT_PROTOCOL_TCP, 8180, 8181);
912  RANGE (PORT_PROTOCOL_TCP, 8189, 8189);
913  RANGE (PORT_PROTOCOL_TCP, 8192, 8194);
914  RANGE (PORT_PROTOCOL_TCP, 8200, 8200);
915  RANGE (PORT_PROTOCOL_TCP, 8222, 8222);
916  RANGE (PORT_PROTOCOL_TCP, 8254, 8254);
917  RANGE (PORT_PROTOCOL_TCP, 8290, 8294);
918  RANGE (PORT_PROTOCOL_TCP, 8300, 8300);
919  RANGE (PORT_PROTOCOL_TCP, 8333, 8333);
920  RANGE (PORT_PROTOCOL_TCP, 8383, 8383);
921  RANGE (PORT_PROTOCOL_TCP, 8385, 8385);
922  RANGE (PORT_PROTOCOL_TCP, 8400, 8400);
923  RANGE (PORT_PROTOCOL_TCP, 8402, 8402);
924  RANGE (PORT_PROTOCOL_TCP, 8443, 8443);
925  RANGE (PORT_PROTOCOL_TCP, 8481, 8481);
926  RANGE (PORT_PROTOCOL_TCP, 8500, 8500);
927  RANGE (PORT_PROTOCOL_TCP, 8540, 8540);
928  RANGE (PORT_PROTOCOL_TCP, 8600, 8600);
929  RANGE (PORT_PROTOCOL_TCP, 8648, 8649);
930  RANGE (PORT_PROTOCOL_TCP, 8651, 8652);
931  RANGE (PORT_PROTOCOL_TCP, 8654, 8654);
932  RANGE (PORT_PROTOCOL_TCP, 8675, 8676);
933  RANGE (PORT_PROTOCOL_TCP, 8686, 8686);
934  RANGE (PORT_PROTOCOL_TCP, 8701, 8701);
935  RANGE (PORT_PROTOCOL_TCP, 8765, 8766);
936  RANGE (PORT_PROTOCOL_TCP, 8800, 8800);
937  RANGE (PORT_PROTOCOL_TCP, 8873, 8873);
938  RANGE (PORT_PROTOCOL_TCP, 8877, 8877);
939  RANGE (PORT_PROTOCOL_TCP, 8888, 8889);
940  RANGE (PORT_PROTOCOL_TCP, 8899, 8899);
941  RANGE (PORT_PROTOCOL_TCP, 8987, 8987);
942  RANGE (PORT_PROTOCOL_TCP, 8994, 8994);
943  RANGE (PORT_PROTOCOL_TCP, 8996, 8996);
944  RANGE (PORT_PROTOCOL_TCP, 9000, 9003);
945  RANGE (PORT_PROTOCOL_TCP, 9009, 9011);
946  RANGE (PORT_PROTOCOL_TCP, 9040, 9040);
947  RANGE (PORT_PROTOCOL_TCP, 9050, 9050);
948  RANGE (PORT_PROTOCOL_TCP, 9071, 9071);
949  RANGE (PORT_PROTOCOL_TCP, 9080, 9081);
950  RANGE (PORT_PROTOCOL_TCP, 9090, 9091);
951  RANGE (PORT_PROTOCOL_TCP, 9098, 9103);
952  RANGE (PORT_PROTOCOL_TCP, 9110, 9111);
953  RANGE (PORT_PROTOCOL_TCP, 9152, 9152);
954  RANGE (PORT_PROTOCOL_TCP, 9191, 9191);
955  RANGE (PORT_PROTOCOL_TCP, 9197, 9198);
956  RANGE (PORT_PROTOCOL_TCP, 9200, 9200);
957  RANGE (PORT_PROTOCOL_TCP, 9207, 9207);
958  RANGE (PORT_PROTOCOL_TCP, 9220, 9220);
959  RANGE (PORT_PROTOCOL_TCP, 9290, 9290);
960  RANGE (PORT_PROTOCOL_TCP, 9409, 9409);
961  RANGE (PORT_PROTOCOL_TCP, 9415, 9415);
962  RANGE (PORT_PROTOCOL_TCP, 9418, 9418);
963  RANGE (PORT_PROTOCOL_TCP, 9443, 9444);
964  RANGE (PORT_PROTOCOL_TCP, 9485, 9485);
965  RANGE (PORT_PROTOCOL_TCP, 9500, 9503);
966  RANGE (PORT_PROTOCOL_TCP, 9535, 9535);
967  RANGE (PORT_PROTOCOL_TCP, 9575, 9575);
968  RANGE (PORT_PROTOCOL_TCP, 9593, 9595);
969  RANGE (PORT_PROTOCOL_TCP, 9600, 9600);
970  RANGE (PORT_PROTOCOL_TCP, 9618, 9618);
971  RANGE (PORT_PROTOCOL_TCP, 9621, 9621);
972  RANGE (PORT_PROTOCOL_TCP, 9643, 9643);
973  RANGE (PORT_PROTOCOL_TCP, 9666, 9666);
974  RANGE (PORT_PROTOCOL_TCP, 9673, 9673);
975  RANGE (PORT_PROTOCOL_TCP, 9815, 9815);
976  RANGE (PORT_PROTOCOL_TCP, 9876, 9878);
977  RANGE (PORT_PROTOCOL_TCP, 9898, 9898);
978  RANGE (PORT_PROTOCOL_TCP, 9900, 9900);
979  RANGE (PORT_PROTOCOL_TCP, 9914, 9914);
980  RANGE (PORT_PROTOCOL_TCP, 9917, 9917);
981  RANGE (PORT_PROTOCOL_TCP, 9929, 9929);
982  RANGE (PORT_PROTOCOL_TCP, 9941, 9941);
983  RANGE (PORT_PROTOCOL_TCP, 9943, 9944);
984  RANGE (PORT_PROTOCOL_TCP, 9968, 9968);
985  RANGE (PORT_PROTOCOL_TCP, 9988, 9988);
986  RANGE (PORT_PROTOCOL_TCP, 9992, 9992);
987  RANGE (PORT_PROTOCOL_TCP, 9998, 10005);
988  RANGE (PORT_PROTOCOL_TCP, 10008, 10012);
989  RANGE (PORT_PROTOCOL_TCP, 10022, 10025);
990  RANGE (PORT_PROTOCOL_TCP, 10034, 10034);
991  RANGE (PORT_PROTOCOL_TCP, 10058, 10058);
992  RANGE (PORT_PROTOCOL_TCP, 10082, 10083);
993  RANGE (PORT_PROTOCOL_TCP, 10160, 10160);
994  RANGE (PORT_PROTOCOL_TCP, 10180, 10180);
995  RANGE (PORT_PROTOCOL_TCP, 10215, 10215);
996  RANGE (PORT_PROTOCOL_TCP, 10243, 10243);
997  RANGE (PORT_PROTOCOL_TCP, 10566, 10566);
998  RANGE (PORT_PROTOCOL_TCP, 10616, 10617);
999  RANGE (PORT_PROTOCOL_TCP, 10621, 10621);
1000  RANGE (PORT_PROTOCOL_TCP, 10626, 10626);
1001  RANGE (PORT_PROTOCOL_TCP, 10628, 10629);
1002  RANGE (PORT_PROTOCOL_TCP, 10778, 10778);
1003  RANGE (PORT_PROTOCOL_TCP, 10873, 10873);
1004  RANGE (PORT_PROTOCOL_TCP, 11110, 11111);
1005  RANGE (PORT_PROTOCOL_TCP, 11967, 11967);
1006  RANGE (PORT_PROTOCOL_TCP, 12000, 12000);
1007  RANGE (PORT_PROTOCOL_TCP, 12006, 12006);
1008  RANGE (PORT_PROTOCOL_TCP, 12021, 12021);
1009  RANGE (PORT_PROTOCOL_TCP, 12059, 12059);
1010  RANGE (PORT_PROTOCOL_TCP, 12174, 12174);
1011  RANGE (PORT_PROTOCOL_TCP, 12215, 12215);
1012  RANGE (PORT_PROTOCOL_TCP, 12262, 12262);
1013  RANGE (PORT_PROTOCOL_TCP, 12265, 12265);
1014  RANGE (PORT_PROTOCOL_TCP, 12345, 12346);
1015  RANGE (PORT_PROTOCOL_TCP, 12380, 12380);
1016  RANGE (PORT_PROTOCOL_TCP, 12452, 12452);
1017  RANGE (PORT_PROTOCOL_TCP, 13456, 13456);
1018  RANGE (PORT_PROTOCOL_TCP, 13722, 13722);
1019  RANGE (PORT_PROTOCOL_TCP, 13724, 13724);
1020  RANGE (PORT_PROTOCOL_TCP, 13782, 13783);
1021  RANGE (PORT_PROTOCOL_TCP, 14000, 14000);
1022  RANGE (PORT_PROTOCOL_TCP, 14238, 14238);
1023  RANGE (PORT_PROTOCOL_TCP, 14441, 14442);
1024  RANGE (PORT_PROTOCOL_TCP, 15000, 15004);
1025  RANGE (PORT_PROTOCOL_TCP, 15402, 15402);
1026  RANGE (PORT_PROTOCOL_TCP, 15660, 15660);
1027  RANGE (PORT_PROTOCOL_TCP, 15742, 15742);
1028  RANGE (PORT_PROTOCOL_TCP, 16000, 16001);
1029  RANGE (PORT_PROTOCOL_TCP, 16012, 16012);
1030  RANGE (PORT_PROTOCOL_TCP, 16016, 16016);
1031  RANGE (PORT_PROTOCOL_TCP, 16018, 16018);
1032  RANGE (PORT_PROTOCOL_TCP, 16080, 16080);
1033  RANGE (PORT_PROTOCOL_TCP, 16113, 16113);
1034  RANGE (PORT_PROTOCOL_TCP, 16705, 16705);
1035  RANGE (PORT_PROTOCOL_TCP, 16800, 16800);
1036  RANGE (PORT_PROTOCOL_TCP, 16851, 16851);
1037  RANGE (PORT_PROTOCOL_TCP, 16992, 16993);
1038  RANGE (PORT_PROTOCOL_TCP, 17595, 17595);
1039  RANGE (PORT_PROTOCOL_TCP, 17877, 17877);
1040  RANGE (PORT_PROTOCOL_TCP, 17988, 17988);
1041  RANGE (PORT_PROTOCOL_TCP, 18000, 18000);
1042  RANGE (PORT_PROTOCOL_TCP, 18018, 18018);
1043  RANGE (PORT_PROTOCOL_TCP, 18040, 18040);
1044  RANGE (PORT_PROTOCOL_TCP, 18101, 18101);
1045  RANGE (PORT_PROTOCOL_TCP, 18264, 18264);
1046  RANGE (PORT_PROTOCOL_TCP, 18988, 18988);
1047  RANGE (PORT_PROTOCOL_TCP, 19101, 19101);
1048  RANGE (PORT_PROTOCOL_TCP, 19283, 19283);
1049  RANGE (PORT_PROTOCOL_TCP, 19315, 19315);
1050  RANGE (PORT_PROTOCOL_TCP, 19350, 19350);
1051  RANGE (PORT_PROTOCOL_TCP, 19780, 19780);
1052  RANGE (PORT_PROTOCOL_TCP, 19801, 19801);
1053  RANGE (PORT_PROTOCOL_TCP, 19842, 19842);
1054  RANGE (PORT_PROTOCOL_TCP, 19900, 19900);
1055  RANGE (PORT_PROTOCOL_TCP, 20000, 20000);
1056  RANGE (PORT_PROTOCOL_TCP, 20002, 20002);
1057  RANGE (PORT_PROTOCOL_TCP, 20005, 20005);
1058  RANGE (PORT_PROTOCOL_TCP, 20031, 20031);
1059  RANGE (PORT_PROTOCOL_TCP, 20221, 20222);
1060  RANGE (PORT_PROTOCOL_TCP, 20828, 20828);
1061  RANGE (PORT_PROTOCOL_TCP, 21571, 21571);
1062  RANGE (PORT_PROTOCOL_TCP, 21792, 21792);
1063  RANGE (PORT_PROTOCOL_TCP, 22222, 22222);
1064  RANGE (PORT_PROTOCOL_TCP, 22939, 22939);
1065  RANGE (PORT_PROTOCOL_TCP, 23052, 23052);
1066  RANGE (PORT_PROTOCOL_TCP, 23502, 23502);
1067  RANGE (PORT_PROTOCOL_TCP, 23796, 23796);
1068  RANGE (PORT_PROTOCOL_TCP, 24444, 24444);
1069  RANGE (PORT_PROTOCOL_TCP, 24800, 24800);
1070  RANGE (PORT_PROTOCOL_TCP, 25734, 25735);
1071  RANGE (PORT_PROTOCOL_TCP, 26000, 26000);
1072  RANGE (PORT_PROTOCOL_TCP, 26214, 26214);
1073  RANGE (PORT_PROTOCOL_TCP, 26470, 26470);
1074  RANGE (PORT_PROTOCOL_TCP, 27000, 27000);
1075  RANGE (PORT_PROTOCOL_TCP, 27352, 27353);
1076  RANGE (PORT_PROTOCOL_TCP, 27355, 27357);
1077  RANGE (PORT_PROTOCOL_TCP, 27715, 27715);
1078  RANGE (PORT_PROTOCOL_TCP, 28201, 28201);
1079  RANGE (PORT_PROTOCOL_TCP, 28211, 28211);
1080  RANGE (PORT_PROTOCOL_TCP, 29672, 29672);
1081  RANGE (PORT_PROTOCOL_TCP, 29831, 29831);
1082  RANGE (PORT_PROTOCOL_TCP, 30000, 30000);
1083  RANGE (PORT_PROTOCOL_TCP, 30005, 30005);
1084  RANGE (PORT_PROTOCOL_TCP, 30704, 30704);
1085  RANGE (PORT_PROTOCOL_TCP, 30718, 30718);
1086  RANGE (PORT_PROTOCOL_TCP, 30951, 30951);
1087  RANGE (PORT_PROTOCOL_TCP, 31038, 31038);
1088  RANGE (PORT_PROTOCOL_TCP, 31337, 31337);
1089  RANGE (PORT_PROTOCOL_TCP, 31727, 31727);
1090  RANGE (PORT_PROTOCOL_TCP, 32768, 32785);
1091  RANGE (PORT_PROTOCOL_TCP, 32791, 32792);
1092  RANGE (PORT_PROTOCOL_TCP, 32803, 32803);
1093  RANGE (PORT_PROTOCOL_TCP, 32816, 32816);
1094  RANGE (PORT_PROTOCOL_TCP, 32822, 32822);
1095  RANGE (PORT_PROTOCOL_TCP, 32835, 32835);
1096  RANGE (PORT_PROTOCOL_TCP, 33354, 33354);
1097  RANGE (PORT_PROTOCOL_TCP, 33453, 33453);
1098  RANGE (PORT_PROTOCOL_TCP, 33554, 33554);
1099  RANGE (PORT_PROTOCOL_TCP, 33899, 33899);
1100  RANGE (PORT_PROTOCOL_TCP, 34571, 34573);
1101  RANGE (PORT_PROTOCOL_TCP, 35500, 35500);
1102  RANGE (PORT_PROTOCOL_TCP, 35513, 35513);
1103  RANGE (PORT_PROTOCOL_TCP, 37839, 37839);
1104  RANGE (PORT_PROTOCOL_TCP, 38037, 38037);
1105  RANGE (PORT_PROTOCOL_TCP, 38185, 38185);
1106  RANGE (PORT_PROTOCOL_TCP, 38188, 38188);
1107  RANGE (PORT_PROTOCOL_TCP, 38292, 38292);
1108  RANGE (PORT_PROTOCOL_TCP, 39136, 39136);
1109  RANGE (PORT_PROTOCOL_TCP, 39376, 39376);
1110  RANGE (PORT_PROTOCOL_TCP, 39659, 39659);
1111  RANGE (PORT_PROTOCOL_TCP, 40000, 40000);
1112  RANGE (PORT_PROTOCOL_TCP, 40193, 40193);
1113  RANGE (PORT_PROTOCOL_TCP, 40811, 40811);
1114  RANGE (PORT_PROTOCOL_TCP, 40911, 40911);
1115  RANGE (PORT_PROTOCOL_TCP, 41064, 41064);
1116  RANGE (PORT_PROTOCOL_TCP, 41511, 41511);
1117  RANGE (PORT_PROTOCOL_TCP, 41523, 41523);
1118  RANGE (PORT_PROTOCOL_TCP, 42510, 42510);
1119  RANGE (PORT_PROTOCOL_TCP, 44176, 44176);
1120  RANGE (PORT_PROTOCOL_TCP, 44334, 44334);
1121  RANGE (PORT_PROTOCOL_TCP, 44442, 44443);
1122  RANGE (PORT_PROTOCOL_TCP, 44501, 44501);
1123  RANGE (PORT_PROTOCOL_TCP, 44709, 44709);
1124  RANGE (PORT_PROTOCOL_TCP, 45100, 45100);
1125  RANGE (PORT_PROTOCOL_TCP, 46200, 46200);
1126  RANGE (PORT_PROTOCOL_TCP, 46996, 46996);
1127  RANGE (PORT_PROTOCOL_TCP, 47544, 47544);
1128  RANGE (PORT_PROTOCOL_TCP, 48080, 48080);
1129  RANGE (PORT_PROTOCOL_TCP, 49152, 49161);
1130  RANGE (PORT_PROTOCOL_TCP, 49163, 49165);
1131  RANGE (PORT_PROTOCOL_TCP, 49167, 49168);
1132  RANGE (PORT_PROTOCOL_TCP, 49171, 49171);
1133  RANGE (PORT_PROTOCOL_TCP, 49175, 49176);
1134  RANGE (PORT_PROTOCOL_TCP, 49186, 49186);
1135  RANGE (PORT_PROTOCOL_TCP, 49195, 49195);
1136  RANGE (PORT_PROTOCOL_TCP, 49236, 49236);
1137  RANGE (PORT_PROTOCOL_TCP, 49400, 49401);
1138  RANGE (PORT_PROTOCOL_TCP, 49999, 50003);
1139  RANGE (PORT_PROTOCOL_TCP, 50006, 50006);
1140  RANGE (PORT_PROTOCOL_TCP, 50050, 50050);
1141  RANGE (PORT_PROTOCOL_TCP, 50300, 50300);
1142  RANGE (PORT_PROTOCOL_TCP, 50389, 50389);
1143  RANGE (PORT_PROTOCOL_TCP, 50500, 50500);
1144  RANGE (PORT_PROTOCOL_TCP, 50636, 50636);
1145  RANGE (PORT_PROTOCOL_TCP, 50800, 50800);
1146  RANGE (PORT_PROTOCOL_TCP, 51103, 51103);
1147  RANGE (PORT_PROTOCOL_TCP, 51191, 51191);
1148  RANGE (PORT_PROTOCOL_TCP, 51413, 51413);
1149  RANGE (PORT_PROTOCOL_TCP, 51493, 51493);
1150  RANGE (PORT_PROTOCOL_TCP, 52660, 52660);
1151  RANGE (PORT_PROTOCOL_TCP, 52673, 52673);
1152  RANGE (PORT_PROTOCOL_TCP, 52710, 52710);
1153  RANGE (PORT_PROTOCOL_TCP, 52735, 52735);
1154  RANGE (PORT_PROTOCOL_TCP, 52822, 52822);
1155  RANGE (PORT_PROTOCOL_TCP, 52847, 52851);
1156  RANGE (PORT_PROTOCOL_TCP, 52853, 52853);
1157  RANGE (PORT_PROTOCOL_TCP, 52869, 52869);
1158  RANGE (PORT_PROTOCOL_TCP, 53211, 53211);
1159  RANGE (PORT_PROTOCOL_TCP, 53313, 53314);
1160  RANGE (PORT_PROTOCOL_TCP, 53535, 53535);
1161  RANGE (PORT_PROTOCOL_TCP, 54045, 54045);
1162  RANGE (PORT_PROTOCOL_TCP, 54328, 54328);
1163  RANGE (PORT_PROTOCOL_TCP, 55020, 55020);
1164  RANGE (PORT_PROTOCOL_TCP, 55055, 55056);
1165  RANGE (PORT_PROTOCOL_TCP, 55555, 55555);
1166  RANGE (PORT_PROTOCOL_TCP, 55576, 55576);
1167  RANGE (PORT_PROTOCOL_TCP, 55600, 55600);
1168  RANGE (PORT_PROTOCOL_TCP, 56737, 56738);
1169  RANGE (PORT_PROTOCOL_TCP, 57294, 57294);
1170  RANGE (PORT_PROTOCOL_TCP, 57665, 57665);
1171  RANGE (PORT_PROTOCOL_TCP, 57797, 57797);
1172  RANGE (PORT_PROTOCOL_TCP, 58001, 58002);
1173  RANGE (PORT_PROTOCOL_TCP, 58080, 58080);
1174  RANGE (PORT_PROTOCOL_TCP, 58630, 58630);
1175  RANGE (PORT_PROTOCOL_TCP, 58632, 58632);
1176  RANGE (PORT_PROTOCOL_TCP, 58838, 58838);
1177  RANGE (PORT_PROTOCOL_TCP, 59110, 59110);
1178  RANGE (PORT_PROTOCOL_TCP, 59200, 59202);
1179  RANGE (PORT_PROTOCOL_TCP, 60020, 60020);
1180  RANGE (PORT_PROTOCOL_TCP, 60123, 60123);
1181  RANGE (PORT_PROTOCOL_TCP, 60146, 60146);
1182  RANGE (PORT_PROTOCOL_TCP, 60443, 60443);
1183  RANGE (PORT_PROTOCOL_TCP, 60642, 60642);
1184  RANGE (PORT_PROTOCOL_TCP, 61532, 61532);
1185  RANGE (PORT_PROTOCOL_TCP, 61613, 61613);
1186  RANGE (PORT_PROTOCOL_TCP, 61900, 61900);
1187  RANGE (PORT_PROTOCOL_TCP, 62078, 62078);
1188  RANGE (PORT_PROTOCOL_TCP, 63331, 63331);
1189  RANGE (PORT_PROTOCOL_TCP, 64623, 64623);
1190  RANGE (PORT_PROTOCOL_TCP, 64680, 64680);
1191  RANGE (PORT_PROTOCOL_TCP, 65000, 65000);
1192  RANGE (PORT_PROTOCOL_TCP, 65129, 65129);
1193  RANGE (PORT_PROTOCOL_TCP, 65310, 65310);
1194 
1195  RANGE (PORT_PROTOCOL_UDP, 7, 7);
1196  RANGE (PORT_PROTOCOL_UDP, 9, 9);
1197  RANGE (PORT_PROTOCOL_UDP, 17, 17);
1198  RANGE (PORT_PROTOCOL_UDP, 19, 19);
1199  RANGE (PORT_PROTOCOL_UDP, 49, 49);
1200  RANGE (PORT_PROTOCOL_UDP, 53, 53);
1201  RANGE (PORT_PROTOCOL_UDP, 67, 69);
1202  RANGE (PORT_PROTOCOL_UDP, 80, 80);
1203  RANGE (PORT_PROTOCOL_UDP, 88, 88);
1204  RANGE (PORT_PROTOCOL_UDP, 111, 111);
1205  RANGE (PORT_PROTOCOL_UDP, 120, 120);
1206  RANGE (PORT_PROTOCOL_UDP, 123, 123);
1207  RANGE (PORT_PROTOCOL_UDP, 135, 139);
1208  RANGE (PORT_PROTOCOL_UDP, 158, 158);
1209  RANGE (PORT_PROTOCOL_UDP, 161, 162);
1210  RANGE (PORT_PROTOCOL_UDP, 177, 177);
1211  RANGE (PORT_PROTOCOL_UDP, 427, 427);
1212  RANGE (PORT_PROTOCOL_UDP, 443, 443);
1213  RANGE (PORT_PROTOCOL_UDP, 445, 445);
1214  RANGE (PORT_PROTOCOL_UDP, 497, 497);
1215  RANGE (PORT_PROTOCOL_UDP, 500, 500);
1216  RANGE (PORT_PROTOCOL_UDP, 514, 515);
1217  RANGE (PORT_PROTOCOL_UDP, 518, 518);
1218  RANGE (PORT_PROTOCOL_UDP, 520, 520);
1219  RANGE (PORT_PROTOCOL_UDP, 593, 593);
1220  RANGE (PORT_PROTOCOL_UDP, 623, 623);
1221  RANGE (PORT_PROTOCOL_UDP, 626, 626);
1222  RANGE (PORT_PROTOCOL_UDP, 631, 631);
1223  RANGE (PORT_PROTOCOL_UDP, 996, 999);
1224  RANGE (PORT_PROTOCOL_UDP, 1022, 1023);
1225  RANGE (PORT_PROTOCOL_UDP, 1025, 1030);
1226  RANGE (PORT_PROTOCOL_UDP, 1433, 1434);
1227  RANGE (PORT_PROTOCOL_UDP, 1645, 1646);
1228  RANGE (PORT_PROTOCOL_UDP, 1701, 1701);
1229  RANGE (PORT_PROTOCOL_UDP, 1718, 1719);
1230  RANGE (PORT_PROTOCOL_UDP, 1812, 1813);
1231  RANGE (PORT_PROTOCOL_UDP, 1900, 1900);
1232  RANGE (PORT_PROTOCOL_UDP, 2000, 2000);
1233  RANGE (PORT_PROTOCOL_UDP, 2048, 2049);
1234  RANGE (PORT_PROTOCOL_UDP, 2222, 2223);
1235  RANGE (PORT_PROTOCOL_UDP, 3283, 3283);
1236  RANGE (PORT_PROTOCOL_UDP, 3456, 3456);
1237  RANGE (PORT_PROTOCOL_UDP, 3703, 3703);
1238  RANGE (PORT_PROTOCOL_UDP, 4444, 4444);
1239  RANGE (PORT_PROTOCOL_UDP, 4500, 4500);
1240  RANGE (PORT_PROTOCOL_UDP, 5000, 5000);
1241  RANGE (PORT_PROTOCOL_UDP, 5060, 5060);
1242  RANGE (PORT_PROTOCOL_UDP, 5353, 5353);
1243  RANGE (PORT_PROTOCOL_UDP, 5632, 5632);
1244  RANGE (PORT_PROTOCOL_UDP, 9200, 9200);
1245  RANGE (PORT_PROTOCOL_UDP, 10000, 10000);
1246  RANGE (PORT_PROTOCOL_UDP, 17185, 17185);
1247  RANGE (PORT_PROTOCOL_UDP, 20031, 20031);
1248  RANGE (PORT_PROTOCOL_UDP, 30718, 30718);
1249  RANGE (PORT_PROTOCOL_UDP, 31337, 31337);
1250  RANGE (PORT_PROTOCOL_UDP, 32768, 32769);
1251  RANGE (PORT_PROTOCOL_UDP, 32771, 32771);
1252  RANGE (PORT_PROTOCOL_UDP, 32815, 32815);
1253  RANGE (PORT_PROTOCOL_UDP, 33281, 33281);
1254  RANGE (PORT_PROTOCOL_UDP, 49152, 49154);
1255  RANGE (PORT_PROTOCOL_UDP, 49156, 49156);
1256  RANGE (PORT_PROTOCOL_UDP, 49181, 49182);
1257  RANGE (PORT_PROTOCOL_UDP, 49185, 49186);
1258  RANGE (PORT_PROTOCOL_UDP, 49188, 49188);
1259  RANGE (PORT_PROTOCOL_UDP, 49190, 49194);
1260  RANGE (PORT_PROTOCOL_UDP, 49200, 49201);
1261 }
#define RANGE(type, start, end)
Insert a port range.

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

Definition at line 12984 of file manage_sql.c.

12986 {
12987  alert_t alert;
12988  task_t task;
12989  alert_condition_t condition;
12990  alert_method_t method;
12991 
12992  if (acl_user_may ("test_alert") == 0)
12993  return 99;
12994 
12995  if (find_alert_with_permission (alert_id, &alert, "test_alert"))
12996  return -1;
12997  if (alert == 0)
12998  return 1;
12999 
13000  if (task_id == NULL || strcmp (task_id, "0") == 0)
13001  task = 0;
13002  else
13003  {
13004  if (find_task_with_permission (task_id, &task, NULL))
13005  return -1;
13006  if (task == 0)
13007  return 2;
13008  }
13009 
13010  condition = alert_condition (alert);
13011  method = alert_method (alert);
13012  return escalate_1 (alert, task, 0, event, event_data, method, condition,
13013  script_message);
13014 }
alert_condition_t
Types of alert conditions.
Definition: manage.h:501
long long int alert_t
Definition: manage.h:280
alert_method_t
Types of alerts.
Definition: manage.h:482
gboolean find_alert_with_permission(const char *uuid, alert_t *alert, const char *permission)
Find a alert for a specific permission, given a UUID.
Definition: manage_sql.c:6983
gboolean find_task_with_permission(const char *, task_t *, const char *)
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
Definition: manage_acl.c:56
long long int task_t
Definition: manage.h:286

◆ manage_attach_databases()

void manage_attach_databases ( )

Attach external databases.

Definition at line 2624 of file manage_pg.c.

References manage_cert_loaded(), manage_scap_loaded(), sql(), and sql_error().

2625 {
2626  if (manage_scap_loaded ())
2627  sql ("SELECT set_config ('search_path',"
2628  " current_setting ('search_path') || ',scap',"
2629  " false);");
2630 
2631  if (manage_cert_loaded ())
2632  sql ("SELECT set_config ('search_path',"
2633  " current_setting ('search_path') || ',cert',"
2634  " false);");
2635 }
int manage_cert_loaded()
Check whether CERT is available.
Definition: manage_pg.c:2643
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
int manage_scap_loaded()
Check whether SCAP is available.
Definition: manage_pg.c:2659
Here is the call graph for this function:

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

Definition at line 6322 of file manage_sql.c.

6323 {
6324  return OPENVASMD_CERT_DATABASE_VERSION;
6325 }

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

Definition at line 6333 of file manage_sql.c.

References manage_cert_loaded(), and sql_string().

6334 {
6335  if (manage_cert_loaded () == 0)
6336  return -1;
6337 
6338  int number;
6339  char *version = sql_string ("SELECT value FROM cert.meta"
6340  " WHERE name = 'database_version' LIMIT 1;");
6341  if (version)
6342  {
6343  number = atoi (version);
6344  free (version);
6345  return number;
6346  }
6347  return -1;
6348 }
int manage_cert_loaded()
Check whether CERT is available.
Definition: manage_pg.c:2643
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ manage_cert_loaded()

int manage_cert_loaded ( )

Check whether CERT is available.

Returns
1 if CERT database is loaded, else 0.

Definition at line 2643 of file manage_pg.c.

References sql_database(), sql_error(), and sql_int().

Referenced by init_aggregate_iterator(), manage_attach_databases(), and manage_cert_db_version().

2644 {
2645  return !!sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
2646  " WHERE table_catalog = '%s'"
2647  " AND table_schema = 'cert'"
2648  " AND table_name = 'dfn_cert_advs')"
2649  " ::integer;",
2650  sql_database ());
2651 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
const char * sql_database()
Return name of current database.
Definition: sql_pg.c:226
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_check_alerts()

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

Check if any SecInfo alerts are due.

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

Definition at line 6886 of file manage_sql.c.

6887 {
6888  int ret;
6889 
6890  g_info (" Checking alerts.\n");
6891 
6892  ret = manage_option_setup (log_config, database);
6893  if (ret)
6894  return ret;
6895 
6896  /* Setup a dummy user, so that create_user will work. */
6897  current_credentials.uuid = "";
6898 
6899  if (manage_scap_loaded ())
6900  {
6901  int max_time;
6902 
6903  max_time
6904  = sql_int ("SELECT %s"
6905  " ((SELECT max (modification_time) FROM scap.cves),"
6906  " (SELECT max (modification_time) FROM scap.cpes),"
6907  " (SELECT max (modification_time) FROM scap.ovaldefs),"
6908  " (SELECT max (creation_time) FROM scap.cves),"
6909  " (SELECT max (creation_time) FROM scap.cpes),"
6910  " (SELECT max (creation_time) FROM scap.ovaldefs));",
6911  sql_greatest ());
6912 
6913  if (sql_int ("SELECT NOT EXISTS (SELECT * FROM meta"
6914  " WHERE name = 'scap_check_time')"))
6915  sql ("INSERT INTO meta (name, value)"
6916  " VALUES ('scap_check_time', %i);",
6917  max_time);
6918  else if (sql_int ("SELECT value = '0' FROM meta"
6919  " WHERE name = 'scap_check_time';"))
6920  sql ("UPDATE meta SET value = %i"
6921  " WHERE name = 'scap_check_time';",
6922  max_time);
6923  else
6924  {
6925  check_for_new_scap ();
6926  check_for_updated_scap ();
6927  sql ("UPDATE meta SET value = %i"
6928  " WHERE name = 'scap_check_time';",
6929  max_time);
6930  }
6931  }
6932 
6933  if (manage_cert_loaded ())
6934  {
6935  int max_time;
6936 
6937  max_time
6938  = sql_int ("SELECT"
6939  " %s"
6940  " ((SELECT max (modification_time) FROM cert.cert_bund_advs),"
6941  " (SELECT max (modification_time) FROM cert.dfn_cert_advs),"
6942  " (SELECT max (creation_time) FROM cert.cert_bund_advs),"
6943  " (SELECT max (creation_time) FROM cert.dfn_cert_advs));",
6944  sql_greatest ());
6945 
6946  if (sql_int ("SELECT NOT EXISTS (SELECT * FROM meta"
6947  " WHERE name = 'cert_check_time')"))
6948  sql ("INSERT INTO meta (name, value)"
6949  " VALUES ('cert_check_time', %i);",
6950  max_time);
6951  else if (sql_int ("SELECT value = '0' FROM meta"
6952  " WHERE name = 'cert_check_time';"))
6953  sql ("UPDATE meta SET value = %i"
6954  " WHERE name = 'cert_check_time';",
6955  max_time);
6956  else
6957  {
6958  check_for_new_cert ();
6959  check_for_updated_cert ();
6960  sql ("UPDATE meta SET value = %i"
6961  " WHERE name = 'cert_check_time';",
6962  max_time);
6963  }
6964  }
6965 
6966  current_credentials.uuid = NULL;
6967 
6969 
6970  return ret;
6971 }
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
const char * sql_greatest()
Get keyword for "greatest" SQL function.
Definition: sql_pg.c:114
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
void manage_option_cleanup()
Cleanup for an option process.
Definition: manage_sql.c:1504
int manage_cert_loaded()
Check whether CERT is available.
Definition: manage_pg.c:2643
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
#define g_info(...)
Defines g_info for glib versions older than 2.40.
Definition: manage.h:55
int manage_option_setup(GSList *log_config, const gchar *database)
Setup for an option process.
Definition: manage_sql.c:1463
int manage_scap_loaded()
Check whether SCAP is available.
Definition: manage_pg.c:2659

◆ manage_clean_filter()

gchar* manage_clean_filter ( const gchar *  filter)

Clean a filter.

Parameters
[in]filterFilter.
Returns
Cleaned filter.

Definition at line 2818 of file manage_sql.c.

References manage_clean_filter_remove().

2819 {
2820  return manage_clean_filter_remove (filter, NULL);
2821 }
gchar * manage_clean_filter_remove(const gchar *filter, const gchar *column)
Clean a filter, removing a keyword in the process.
Definition: manage_sql.c:2743
Here is the call graph for this function:

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

Definition at line 2743 of file manage_sql.c.

References keyword::column, KEYWORD_RELATION_COLUMN_EQUAL, keyword::relation, and split_filter().

Referenced by init_get(), and manage_clean_filter().

2744 {
2745  GString *clean;
2746  keyword_t **point;
2747  array_t *split;
2748 
2749  if (filter == NULL)
2750  return g_strdup ("");
2751 
2752  clean = g_string_new ("");
2753  split = split_filter (filter);
2754  point = (keyword_t**) split->pdata;
2755  while (*point)
2756  {
2757  keyword_t *keyword;
2758 
2759  keyword = *point;
2760  if (keyword->column
2761  && column
2762  && strlen (column)
2763  && ((strcasecmp (keyword->column, column) == 0)
2764  || (keyword->column[0] == '_'
2765  && strcasecmp (keyword->column + 1, column) == 0)))
2766  {
2767  /* Remove this keyword. */;
2768  }
2769  else if (keyword->column)
2770  switch (keyword->relation)
2771  {
2773  append_relation (clean, keyword, '=');
2774  break;
2776  append_relation (clean, keyword, '~');
2777  break;
2779  append_relation (clean, keyword, '>');
2780  break;
2782  append_relation (clean, keyword, '<');
2783  break;
2785  append_relation (clean, keyword, ':');
2786  break;
2787 
2789  if (keyword->quoted)
2790  g_string_append_printf (clean, " \"%s\"", keyword->string);
2791  else
2792  g_string_append_printf (clean, " %s", keyword->string);
2793  break;
2794  }
2795  else
2796  if (keyword->quoted)
2797  g_string_append_printf (clean, " %s\"%s\"",
2798  keyword->equal ? "=" : "",
2799  keyword->string);
2800  else
2801  g_string_append_printf (clean, " %s%s",
2802  keyword->equal ? "=" : "",
2803  keyword->string);
2804  point++;
2805  }
2806  filter_free (split);
2807  return g_strstrip (g_string_free (clean, FALSE));
2808 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
void filter_free(array_t *split)
Free a split filter.
Definition: manage_sql.c:2018
int equal
Whether the keyword is like "=example".
Definition: manage.h:3431
keyword_relation_t relation
The relation.
Definition: manage.h:3437
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
int quoted
Whether the keyword was quoted.
Definition: manage.h:3434
array_t * split_filter(const gchar *given_filter)
Split the filter term into parts.
Definition: manage_sql.c:2043
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 17154 of file manage_sql.c.

References current_scanner_task, set_task_run_status(), sql_close(), sql_is_open(), and TASK_STATUS_INTERNAL_ERROR.

Referenced by handle_sigabrt(), and handle_sigsegv().

17155 {
17156  g_debug ("Received %s signal.\n", sys_siglist[signal]);
17157  if (sql_is_open ())
17158  {
17160  {
17161  g_warning ("%s: Error exit, setting running task to Internal Error",
17162  __FUNCTION__);
17164  }
17165  sql_close ();
17166  }
17167 }
int sql_is_open()
Check whether the database is open.
Definition: sql_pg.c:201
task_t current_scanner_task
The task currently running on the scanner.
Definition: manage.c:998
void sql_close()
Close the database.
Definition: sql_pg.c:363
void set_task_run_status(task_t task, task_status_t status)
Set the run state of a task.
Definition: manage_sql.c:18307
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_create_sql_functions()

int manage_create_sql_functions ( )

Create functions.

Returns
0 success, -1 error.

Definition at line 113 of file manage_pg.c.

References LOCATION_TABLE, LOCATION_TRASH, manage_db_version(), manage_scap_loaded(), OVERRIDES_SQL, SEVERITY_DEBUG, SEVERITY_ERROR, SEVERITY_FP, SEVERITY_LOG, sql(), sql_clean_hosts(), sql_common_cve(), sql_cpe_title(), sql_credential_value(), sql_current_offset(), sql_database(), sql_days_from_now(), sql_hosts_contains(), sql_int(), sql_iso_time(), sql_make_uuid(), sql_max_hosts(), sql_next_time(), sql_now(), sql_order_inet(), sql_order_message_type(), sql_order_port(), sql_order_role(), sql_order_threat(), sql_parse_time(), sql_regexp(), sql_report_host_count(), sql_report_progress(), sql_report_result_host_count(), sql_report_severity(), sql_report_severity_count(), sql_resource_exists(), sql_resource_name(), sql_run_status_name(), sql_severity_in_level(), sql_severity_matches_ov(), sql_severity_to_level(), sql_severity_to_type(), sql_strpos(), sql_t(), sql_tag(), sql_target_credential(), sql_target_login_port(), sql_task_last_report(), sql_task_severity(), sql_task_threat_level(), sql_task_trend(), sql_trash_target_credential_location(), sql_uniquify(), sql_user_can_everything(), sql_user_owns(), task_db, TASK_STATUS_DELETE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_WAITING, TASK_STATUS_DELETE_WAITING, TASK_STATUS_DONE, TASK_STATUS_NEW, TASK_STATUS_REQUESTED, TASK_STATUS_RUNNING, TASK_STATUS_STOP_REQUESTED, TASK_STATUS_STOP_REQUESTED_GIVEUP, TASK_STATUS_STOP_WAITING, and TASK_STATUS_STOPPED.

Referenced by create_tables().

114 {
115  static int created = 0;
116  int current_db_version = manage_db_version ();
117 
118  if (created)
119  return 0;
120 
121  if (sql_int ("SELECT count (*) FROM pg_available_extensions"
122  " WHERE name = 'uuid-ossp' AND installed_version IS NOT NULL;")
123  == 0)
124  {
125  g_warning ("%s: PostgreSQL extension uuid-ossp required", __FUNCTION__);
126  return -1;
127  }
128 
129  /* Functions in C. */
130 
131  sql ("SET role dba;");
132 
133  sql ("CREATE OR REPLACE FUNCTION max_hosts (text, text)"
134  " RETURNS integer"
135  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_max_hosts'"
136  " LANGUAGE C;",
137  OPENVAS_LIB_INSTALL_DIR);
138 
139  sql ("CREATE OR REPLACE FUNCTION level_max_severity (text, text)"
140  " RETURNS double precision"
141  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_level_max_severity'"
142  " LANGUAGE C;",
143  OPENVAS_LIB_INSTALL_DIR);
144 
145  sql ("CREATE OR REPLACE FUNCTION level_min_severity (text, text)"
146  " RETURNS double precision"
147  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_level_min_severity'"
148  " LANGUAGE C;",
149  OPENVAS_LIB_INSTALL_DIR);
150 
151  sql ("CREATE OR REPLACE FUNCTION next_time (integer, integer, integer)"
152  " RETURNS integer"
153  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_next_time'"
154  " LANGUAGE C;",
155  OPENVAS_LIB_INSTALL_DIR);
156 
157  sql ("CREATE OR REPLACE FUNCTION next_time (integer, integer, integer, text)"
158  " RETURNS integer"
159  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_next_time'"
160  " LANGUAGE C;",
161  OPENVAS_LIB_INSTALL_DIR);
162 
163  sql ("CREATE OR REPLACE FUNCTION next_time (integer, integer, integer, text, integer)"
164  " RETURNS integer"
165  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_next_time'"
166  " LANGUAGE C;",
167  OPENVAS_LIB_INSTALL_DIR);
168 
169  sql ("CREATE OR REPLACE FUNCTION severity_matches_ov (double precision,"
170  " double precision)"
171  " RETURNS boolean"
172  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_severity_matches_ov'"
173  " LANGUAGE C"
174  " IMMUTABLE;",
175  OPENVAS_LIB_INSTALL_DIR);
176 
177  sql ("CREATE OR REPLACE FUNCTION valid_db_resource_type (text)"
178  " RETURNS boolean"
179  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_valid_db_resource_type'"
180  " LANGUAGE C;",
181  OPENVAS_LIB_INSTALL_DIR);
182 
183  sql ("CREATE OR REPLACE FUNCTION regexp (text, text)"
184  " RETURNS boolean"
185  " AS '%s/openvasmd/pg/libmanage-pg-server', 'sql_regexp'"
186  " LANGUAGE C;",
187  OPENVAS_LIB_INSTALL_DIR);
188 
189  if (sql_int ("SELECT count(*) FROM pg_operator"
190  " WHERE oprname = '?~#';")
191  == 0)
192  {
193  sql ("CREATE OPERATOR ?~#"
194  " (PROCEDURE = regexp, LEFTARG = text, RIGHTARG = text);");
195  }
196 
197  sql ("RESET role;");
198 
199  /* Functions in pl/pgsql. */
200 
201  if (sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
202  " WHERE table_catalog = '%s'"
203  " AND table_schema = 'public'"
204  " AND table_name = 'meta')"
205  " ::integer;",
206  sql_database ()))
207  {
208  sql ("CREATE OR REPLACE FUNCTION resource_name (text, text, integer)"
209  " RETURNS text AS $$"
210  /* Get the name of a resource by its type and ID. */
211  " DECLARE"
212  " execute_name text;"
213  " BEGIN"
214  " CASE"
215  " WHEN NOT valid_db_resource_type ($1)"
216  " THEN RAISE EXCEPTION 'Invalid resource type argument: %', $1;"
217  " WHEN $1 = 'note'"
218  " AND $3 = " G_STRINGIFY (LOCATION_TABLE)
219  " THEN RETURN (SELECT 'Note for: '"
220  " || (SELECT name"
221  " FROM nvts"
222  " WHERE nvts.uuid = notes.nvt)"
223  " FROM notes"
224  " WHERE uuid = $2);"
225  " WHEN $1 = 'note'"
226  " THEN RETURN (SELECT 'Note for: '"
227  " || (SELECT name"
228  " FROM nvts"
229  " WHERE nvts.uuid = notes_trash.nvt)"
230  " FROM notes_trash"
231  " WHERE uuid = $2);"
232  " WHEN $1 = 'override'"
233  " AND $3 = " G_STRINGIFY (LOCATION_TABLE)
234  " THEN RETURN (SELECT 'Override for: '"
235  " || (SELECT name"
236  " FROM nvts"
237  " WHERE nvts.uuid = overrides.nvt)"
238  " FROM overrides"
239  " WHERE uuid = $2);"
240  " WHEN $1 = 'override'"
241  " THEN RETURN (SELECT 'Override for: '"
242  " || (SELECT name"
243  " FROM nvts"
244  " WHERE nvts.uuid = overrides_trash.nvt)"
245  " FROM overrides_trash"
246  " WHERE uuid = $2);"
247  " WHEN $1 = 'report'"
248  " THEN RETURN (SELECT (SELECT name FROM tasks WHERE id = task)"
249  " || ' - '"
250  " || (SELECT"
251  " CASE (SELECT end_time FROM tasks"
252  " WHERE id = task)"
253  " WHEN 0 THEN 'N/A'"
254  " ELSE (SELECT end_time::text"
255  " FROM tasks WHERE id = task)"
256  " END)"
257  " FROM reports"
258  " WHERE uuid = $2);"
259  " WHEN $1 = 'result'"
260  " THEN RETURN (SELECT (SELECT name FROM tasks WHERE id = task)"
261  " || ' - '"
262  " || (SELECT name FROM nvts WHERE oid = nvt)"
263  " || ' - '"
264  " || (SELECT"
265  " CASE (SELECT end_time FROM tasks"
266  " WHERE id = task)"
267  " WHEN 0 THEN 'N/A'"
268  " ELSE (SELECT end_time::text"
269  " FROM tasks WHERE id = task)"
270  " END)"
271  " FROM results"
272  " WHERE uuid = $2);"
273  " WHEN $1 = 'task'"
274  " THEN RETURN (SELECT name FROM tasks WHERE uuid = $2);"
275  " WHEN $3 = " G_STRINGIFY (LOCATION_TABLE)
276  " THEN EXECUTE 'SELECT name FROM ' || $1 || 's"
277  " WHERE uuid = $1'"
278  " INTO execute_name"
279  " USING $2;"
280  " RETURN execute_name;"
281  " WHEN $1 NOT IN ('nvt', 'cpe', 'cve', 'ovaldef', 'cert_bund_adv',"
282  " 'dfn_cert_adv', 'report', 'result', 'user')"
283  " THEN EXECUTE 'SELECT name FROM ' || $1 || 's_trash"
284  " WHERE uuid = $1'"
285  " INTO execute_name"
286  " USING $2;"
287  " RETURN execute_name;"
288  " ELSE RETURN NULL;"
289  " END CASE;"
290  " END;"
291  "$$ LANGUAGE plpgsql;");
292 
293  created = 1;
294  }
295 
296  sql ("CREATE OR REPLACE FUNCTION report_progress_active (integer)"
297  " RETURNS integer AS $$"
298  /* Calculate the progress of an active report. */
299  " DECLARE"
300  " report_task integer;"
301  " task_target integer;"
302  " target_hosts text;"
303  " target_exclude_hosts text;"
304  " progress integer;"
305  " total integer;"
306  " maximum_hosts integer;"
307  " total_progress integer;"
308  " report_host record;"
309  " dead_hosts integer;"
310  " BEGIN"
311  " total := 0;"
312  " dead_hosts := 0;"
313  " report_task := (SELECT task FROM reports WHERE id = $1);"
314  " task_target := (SELECT target FROM tasks WHERE id = report_task);"
315  " IF task_target IS NULL THEN"
316  " target_hosts := NULL;"
317  " target_exclude_hosts := NULL;"
318  " ELSIF (SELECT target_location = " G_STRINGIFY (LOCATION_TRASH)
319  " FROM tasks WHERE id = report_task)"
320  " THEN"
321  " target_hosts := (SELECT hosts FROM targets_trash"
322  " WHERE id = task_target);"
323  " target_exclude_hosts := (SELECT exclude_hosts FROM targets_trash"
324  " WHERE id = task_target);"
325  " ELSE"
326  " target_hosts := (SELECT hosts FROM targets"
327  " WHERE id = task_target);"
328  " target_exclude_hosts := (SELECT exclude_hosts FROM targets"
329  " WHERE id = task_target);"
330  " END IF;"
331  " IF target_hosts IS NULL THEN"
332  " RETURN 0;"
333  " END IF;"
334  " maximum_hosts := max_hosts (target_hosts, target_exclude_hosts);"
335  " IF maximum_hosts = 0 THEN"
336  " RETURN 0;"
337  " END IF;"
338  " FOR report_host IN SELECT current_port, max_port"
339  " FROM report_hosts WHERE report = $1"
340  " LOOP"
341  " IF report_host.max_port = -1 THEN"
342  " progress := 0;"
343  " dead_hosts := dead_hosts + 1;"
344  " ELSEIF report_host.max_port IS NOT NULL"
345  " AND report_host.max_port != 0"
346  " THEN"
347  " progress := (report_host.current_port * 100)"
348  " / report_host.max_port;"
349  " ELSIF report_host.current_port IS NULL"
350  " OR report_host.current_port = 0"
351  " THEN"
352  " progress := 0;"
353  " ELSE"
354  " progress := 100;"
355  " END IF;"
356  " total := total + progress;"
357  " END LOOP;"
358  " IF (maximum_hosts - dead_hosts) > 0 THEN"
359  " total_progress := total / (maximum_hosts - dead_hosts);"
360  " ELSE"
361  " total_progress := 0;"
362  " END IF;"
363  " IF total_progress = 0 THEN"
364  " RETURN 1;"
365  " ELSIF total_progress = 100 THEN"
366  " RETURN 99;"
367  " END IF;"
368  " RETURN total_progress;"
369  " END;"
370  "$$ LANGUAGE plpgsql;");
371 
372  sql ("CREATE OR REPLACE FUNCTION order_inet (text)"
373  " RETURNS text AS $$"
374  " BEGIN"
375  " IF $1 ~ '^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$' THEN"
376  " RETURN chr (1)" /* Make IPs sort before hostnames. */
377  " || to_char (split_part ($1, '.', 1)::integer, 'fm000')"
378  " || '.'"
379  " || to_char (split_part ($1, '.', 2)::integer, 'fm000')"
380  " || '.'"
381  " || to_char (split_part ($1, '.', 3)::integer, 'fm000')"
382  " || '.'"
383  " || to_char (split_part ($1, '.', 4)::integer, 'fm000');"
384  " ELSE"
385  " RETURN $1;"
386  " END IF;"
387  " END;"
388  "$$ LANGUAGE plpgsql"
389  " IMMUTABLE;");
390 
391  sql ("CREATE OR REPLACE FUNCTION order_message_type (text)"
392  " RETURNS integer AS $$"
393  " BEGIN"
394  " IF $1 = 'Security Hole' THEN"
395  " RETURN 1;"
396  " ELSIF $1 = 'Security Warning' THEN"
397  " RETURN 2;"
398  " ELSIF $1 = 'Security Note' THEN"
399  " RETURN 3;"
400  " ELSIF $1 = 'Log Message' THEN"
401  " RETURN 4;"
402  " ELSIF $1 = 'Debug Message' THEN"
403  " RETURN 5;"
404  " ELSIF $1 = 'Error Message' THEN"
405  " RETURN 6;"
406  " ELSE"
407  " RETURN 7;"
408  " END IF;"
409  " END;"
410  "$$ LANGUAGE plpgsql"
411  " IMMUTABLE;");
412 
413  sql ("CREATE OR REPLACE FUNCTION order_port (text)"
414  " RETURNS integer AS $$"
415  " BEGIN"
416  " IF $1 ~ '^[0-9]+' THEN"
417  " RETURN CAST (substring ($1, '^[0-9]+') as integer);"
418  " ELSIF $1 ~ '^[^0-9]* \\([0-9]+/' THEN"
419  " RETURN CAST (substring ($1, '^[^0-9]* \\(([0-9]+)/') as integer);"
420  " ELSE"
421  " RETURN 0;"
422  " END IF;"
423  " END;"
424  "$$ LANGUAGE plpgsql"
425  " IMMUTABLE;");
426 
427  sql ("CREATE OR REPLACE FUNCTION order_role (text)"
428  " RETURNS text AS $$"
429  " BEGIN"
430  " IF $1 = 'Admin' THEN"
431  " RETURN ' !';"
432  " ELSE"
433  " RETURN $1;"
434  " END IF;"
435  " END;"
436  "$$ LANGUAGE plpgsql"
437  " IMMUTABLE;");
438 
439  sql ("CREATE OR REPLACE FUNCTION order_threat (text)"
440  " RETURNS integer AS $$"
441  " BEGIN"
442  " IF $1 = 'High' THEN"
443  " RETURN 1;"
444  " ELSIF $1 = 'Medium' THEN"
445  " RETURN 2;"
446  " ELSIF $1 = 'Low' THEN"
447  " RETURN 3;"
448  " ELSIF $1 = 'Log' THEN"
449  " RETURN 4;"
450  " ELSIF $1 = 'Debug' THEN"
451  " RETURN 5;"
452  " ELSIF $1 = 'False Positive' THEN"
453  " RETURN 6;"
454  " ELSIF $1 = 'None' THEN"
455  " RETURN 7;"
456  " ELSE"
457  " RETURN 8;"
458  " END IF;"
459  " END;"
460  "$$ LANGUAGE plpgsql"
461  " IMMUTABLE;");
462 
463  sql ("CREATE OR REPLACE FUNCTION severity_to_type (double precision)"
464  " RETURNS text AS $$"
465  " BEGIN"
466  " IF $1 IS NULL THEN"
467  " RETURN NULL;"
468  " ELSIF $1 = " G_STRINGIFY (SEVERITY_LOG) " THEN"
469  " RETURN 'Log Message';"
470  " ELSIF $1 = " G_STRINGIFY (SEVERITY_FP) " THEN"
471  " RETURN 'False Positive';"
472  " ELSIF $1 = " G_STRINGIFY (SEVERITY_DEBUG) " THEN"
473  " RETURN 'Debug Message';"
474  " ELSIF $1 = " G_STRINGIFY (SEVERITY_ERROR) " THEN"
475  " RETURN 'Error Message';"
476  " ELSIF $1 > 0.0 AND $1 <= 10.0 THEN"
477  " RETURN 'Alarm';"
478  " ELSE"
479  " RAISE EXCEPTION 'Invalid severity score given: %', $1;"
480  " END IF;"
481  " END;"
482  "$$ LANGUAGE plpgsql"
483  " IMMUTABLE;");
484 
485  sql ("CREATE OR REPLACE FUNCTION iso_time (seconds integer)"
486  " RETURNS text AS $$"
487  " DECLARE"
488  " user_zone text;"
489  " user_offset interval;"
490  " BEGIN"
491  " user_zone :="
492  " coalesce ((SELECT tz_override FROM current_credentials),"
493  " (SELECT timezone FROM users"
494  " WHERE uuid = (SELECT uuid"
495  " FROM current_credentials)));"
496  " BEGIN"
497  " user_offset := age (now () AT TIME ZONE user_zone,"
498  " now () AT TIME ZONE 'UTC');"
499  " EXCEPTION WHEN invalid_parameter_value THEN"
500  " user_zone = 'UTC';"
501  " user_offset = 0;"
502  " END;"
503  " RETURN CASE"
504  " WHEN $1 = 0"
505  " THEN ''"
506  " WHEN user_zone IS NULL"
507  " OR EXTRACT (EPOCH FROM user_offset) = 0"
508  " THEN to_char (to_timestamp ($1) AT TIME ZONE 'UTC',"
509  " 'FMYYYY-MM-DD')"
510  " || to_char (to_timestamp ($1) AT TIME ZONE 'UTC',"
511  " 'FMTHH24:MI:SSZ')"
512  " ELSE to_char (to_timestamp ($1) AT TIME ZONE user_zone,"
513  " 'FMYYYY-MM-DD')"
514  " || to_char (to_timestamp ($1) AT TIME ZONE user_zone,"
515  " 'FMTHH24:MI:SS')"
516  " || CASE WHEN (extract (epoch FROM user_offset) > 0)"
517  " THEN '+' ELSE '' END"
518  " || to_char (extract (hours FROM user_offset)::integer,"
519  " 'FM00')"
520  " || ':'"
521  " || to_char (abs (extract (minutes FROM user_offset)"
522  " ::integer),"
523  " 'FM00')"
524  " END;"
525  " END;"
526  "$$ LANGUAGE plpgsql;");
527 
528  sql ("CREATE OR REPLACE FUNCTION days_from_now (seconds integer)"
529  " RETURNS integer AS $$"
530  " DECLARE"
531  " diff interval;"
532  " BEGIN"
533  " diff := age ( to_timestamp( seconds ), now() );"
534  " RETURN CASE"
535  " WHEN seconds = 0"
536  " THEN -2"
537  " WHEN diff < interval '0 seconds'"
538  " THEN -1"
539  " ELSE date_part( 'day', diff )"
540  " END;"
541  " END;"
542  "$$ LANGUAGE plpgsql"
543  " IMMUTABLE;");
544 
545  sql ("CREATE OR REPLACE FUNCTION uniquify (type text, proposed_name text,"
546  " owner integer, suffix text)"
547  " RETURNS text AS $$"
548  " DECLARE"
549  " number integer := 1;"
550  " candidate text := '';"
551  " separator text := ' ';"
552  " unique_candidate boolean;"
553  " BEGIN"
554  " IF type = 'user' THEN separator := '_'; END IF;"
555  " candidate := proposed_name || suffix || separator || number::text;"
556  " LOOP"
557  " EXECUTE 'SELECT count (*) = 0 FROM ' || type || 's"
558  " WHERE name = $1"
559  " AND ((owner IS NULL) OR (owner = $2))'"
560  " INTO unique_candidate"
561  " USING candidate, owner;"
562  " EXIT WHEN unique_candidate;"
563  " number := number + 1;"
564  " candidate := proposed_name || suffix || separator || number::text;"
565  " END LOOP;"
566  " RETURN candidate;"
567  " END;"
568  "$$ LANGUAGE plpgsql;");
569 
570  sql ("CREATE OR REPLACE FUNCTION create_index (schema_name text,"
571  " index_name text,"
572  " table_name text,"
573  " columns text)"
574  " RETURNS void AS $$"
575  " BEGIN"
576  " IF (SELECT count(*) = 0 FROM pg_indexes"
577  " WHERE schemaname = lower (schema_name)"
578  " AND tablename = lower (table_name)"
579  " AND indexname = lower (index_name))"
580  " THEN"
581  " EXECUTE 'CREATE INDEX ' || index_name"
582  " || ' ON ' || table_name || ' (' || columns || ');';"
583  " END IF;"
584  " END;"
585  "$$ LANGUAGE plpgsql;");
586 
587  sql ("CREATE OR REPLACE FUNCTION create_index (index_name text,"
588  " table_name text,"
589  " columns text)"
590  " RETURNS void AS $$"
591  " BEGIN"
592  " PERFORM create_index ('public', index_name, table_name, columns);"
593  " END;"
594  "$$ LANGUAGE plpgsql;");
595 
596  sql ("CREATE OR REPLACE FUNCTION user_has_super_on_resource (arg_type text, arg_id integer)"
597  " RETURNS boolean AS $$"
598  /* Test whether a user has super permissions on a resource.
599  *
600  * This must match user_has_super_on_resource in manage_acl.c. */
601  " DECLARE"
602  " owns boolean;"
603  " BEGIN"
604  " EXECUTE"
605  " 'SELECT"
606  " EXISTS (SELECT * FROM permissions"
607  " WHERE name = ''Super''"
608  /* Super on everyone. */
609  " AND ((resource = 0)"
610  /* Super on other_user. */
611  " OR ((resource_type = ''user'')"
612  " AND (resource = (SELECT ' || $1 || 's.owner"
613  " FROM ' || $1 || 's"
614  " WHERE id = $2)))"
615  /* Super on other_user's role. */
616  " OR ((resource_type = ''role'')"
617  " AND (resource"
618  " IN (SELECT DISTINCT role"
619  " FROM role_users"
620  " WHERE \"user\""
621  " = (SELECT ' || $1 || 's.owner"
622  " FROM ' || $1 || 's"
623  " WHERE id = $2))))"
624  /* Super on other_user's group. */
625  " OR ((resource_type = ''group'')"
626  " AND (resource"
627  " IN (SELECT DISTINCT \"group\""
628  " FROM group_users"
629  " WHERE \"user\""
630  " = (SELECT ' || $1 || 's.owner"
631  " FROM ' || $1 || 's"
632  " WHERE id = $2)))))"
633  " AND subject_location = " G_STRINGIFY (LOCATION_TABLE)
634  " AND ((subject_type = ''user''"
635  " AND subject"
636  " = (SELECT id FROM users"
637  " WHERE users.uuid"
638  " = (SELECT uuid"
639  " FROM current_credentials)))"
640  " OR (subject_type = ''group''"
641  " AND subject"
642  " IN (SELECT DISTINCT \"group\""
643  " FROM group_users"
644  " WHERE"
645  " \"user\""
646  " = (SELECT id"
647  " FROM users"
648  " WHERE users.uuid"
649  " = (SELECT uuid"
650  " FROM current_credentials))))"
651  " OR (subject_type = ''role''"
652  " AND subject"
653  " IN (SELECT DISTINCT role"
654  " FROM role_users"
655  " WHERE"
656  " \"user\""
657  " = (SELECT id"
658  " FROM users"
659  " WHERE users.uuid"
660  " = (SELECT uuid"
661  " FROM current_credentials))))))'"
662  " USING arg_type, arg_id"
663  " INTO owns;"
664  " RETURN owns;"
665  " END;"
666  "$$ LANGUAGE plpgsql;");
667 
668  sql ("CREATE OR REPLACE FUNCTION user_owns (arg_type text, arg_id integer)"
669  " RETURNS boolean AS $$"
670  /* Test whether a user owns a resource.
671  *
672  * This must match user_owns in manage_acl.c. */
673  " DECLARE"
674  " owns boolean;"
675  " BEGIN"
676  " CASE"
677  " WHEN arg_type = 'nvt'"
678  " OR arg_type = 'cve'"
679  " OR arg_type = 'cpe'"
680  " OR arg_type = 'ovaldef'"
681  " OR arg_type = 'cert_bund_adv'"
682  " OR arg_type = 'dfn_cert_adv'"
683  " THEN RETURN true;"
684  " WHEN user_has_super_on_resource (arg_type, arg_id)"
685  " THEN RETURN true;"
686  " WHEN arg_type = 'result'"
687  " THEN CASE"
688  " WHEN EXISTS (SELECT * FROM results, reports"
689  " WHERE results.id = arg_id"
690  " AND results.report = reports.id"
691  " AND ((reports.owner IS NULL)"
692  " OR (reports.owner"
693  " = (SELECT id FROM users"
694  " WHERE users.uuid"
695  " = (SELECT uuid"
696  " FROM current_credentials)))))"
697  " THEN RETURN true;"
698  " ELSE RETURN false;"
699  " END CASE;"
700  " WHEN arg_type = 'task'"
701  " THEN CASE"
702  " WHEN EXISTS (SELECT * FROM tasks"
703  " WHERE id = arg_id"
704  " AND hidden < 2"
705  " AND ((owner IS NULL)"
706  " OR (owner"
707  " = (SELECT id FROM users"
708  " WHERE users.uuid"
709  " = (SELECT uuid"
710  " FROM current_credentials)))))"
711  " THEN RETURN true;"
712  " ELSE RETURN false;"
713  " END CASE;"
714  " ELSE"
715  " EXECUTE"
716  " 'SELECT EXISTS (SELECT * FROM ' || $1 || 's"
717  " WHERE id = $2"
718  " AND ((owner IS NULL)"
719  " OR (owner = (SELECT id FROM users"
720  " WHERE users.uuid = (SELECT uuid"
721  " FROM current_credentials))))'"
722  " USING arg_type, arg_id"
723  " INTO owns;"
724  " RETURN owns;"
725  " END CASE;"
726  " END;"
727  "$$ LANGUAGE plpgsql;");
728 
729  /* Functions in SQL. */
730 
731  sql ("CREATE OR REPLACE FUNCTION t () RETURNS boolean AS $$"
732  " SELECT true;"
733  "$$ LANGUAGE SQL"
734  " IMMUTABLE;");
735 
736  sql ("CREATE OR REPLACE FUNCTION m_now () RETURNS integer AS $$"
737  " SELECT extract (epoch FROM now ())::integer;"
738  "$$ LANGUAGE SQL"
739  " STABLE;");
740 
741  sql ("CREATE OR REPLACE FUNCTION common_cve (text, text)"
742  " RETURNS boolean AS $$"
743  /* Check if two CVE lists contain a common CVE. */
744  " SELECT EXISTS (SELECT trim (unnest (string_to_array ($1, ',')))"
745  " INTERSECT"
746  " SELECT trim (unnest (string_to_array ($2, ','))));"
747  "$$ LANGUAGE SQL;");
748 
749  if (manage_scap_loaded ())
750  {
751  sql ("CREATE OR REPLACE FUNCTION cpe_title (text)"
752  " RETURNS text AS $$"
753  " SELECT title FROM scap.cpes WHERE uuid = $1;"
754  "$$ LANGUAGE SQL;");
755  }
756  else
757  {
758  sql ("CREATE OR REPLACE FUNCTION cpe_title (text)"
759  " RETURNS text AS $$"
760  " SELECT null::text;"
761  "$$ LANGUAGE SQL;");
762  }
763 
764  sql ("CREATE OR REPLACE FUNCTION hosts_contains (text, text)"
765  " RETURNS boolean AS $$"
766  /* Check if a host list contains a host. */
767  " SELECT trim ($2)"
768  " IN (SELECT trim (unnest (string_to_array ($1, ','))));"
769  "$$ LANGUAGE SQL"
770  " IMMUTABLE;");
771 
772  sql ("CREATE OR REPLACE FUNCTION make_uuid () RETURNS text AS $$"
773  " SELECT uuid_generate_v4 ()::text AS result;"
774  "$$ LANGUAGE SQL;");
775 
776  sql ("CREATE OR REPLACE FUNCTION tag (text, text) RETURNS text AS $$"
777  /* Extract a tag from an OTP tag list. */
778  " SELECT split_part (unnest, '=', 2)"
779  " FROM unnest (string_to_array ($1, '|'))"
780  " WHERE split_part (unnest, '=', 1) = $2;"
781  "$$ LANGUAGE SQL;");
782 
783  if (sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
784  " WHERE table_catalog = '%s'"
785  " AND table_schema = 'public'"
786  " AND table_name = 'meta')"
787  " ::integer;",
788  sql_database ()))
789  {
790  sql ("CREATE OR REPLACE FUNCTION report_active (integer)"
791  " RETURNS boolean AS $$"
792  /* Check whether a report is active. */
793  " SELECT CASE"
794  " WHEN (SELECT scan_run_status FROM reports"
795  " WHERE reports.id = $1)"
796  " IN (SELECT unnest (ARRAY [%i, %i, %i, %i, %i, %i,"
797  " %i]))"
798  " THEN true"
799  " ELSE false"
800  " END;"
801  "$$ LANGUAGE SQL;",
809 
810  sql ("CREATE OR REPLACE FUNCTION report_progress (integer)"
811  " RETURNS integer AS $$"
812  /* Calculate the progress of a report. */
813  " SELECT CASE"
814  " WHEN $1 = 0"
815  " THEN -1"
816  " WHEN (SELECT slave_task_uuid FROM reports WHERE id = $1)"
817  " != ''"
818  " THEN (SELECT slave_progress FROM reports WHERE id = $1)"
819  " WHEN report_active ($1)"
820  " THEN report_progress_active ($1)"
821  " ELSE -1"
822  " END;"
823  "$$ LANGUAGE SQL;");
824 
825  sql ("CREATE OR REPLACE FUNCTION dynamic_severity ()"
826  " RETURNS boolean AS $$"
827  /* Get Dynamic Severity user setting. */
828  " SELECT CAST (value AS integer) = 1 FROM settings"
829  " WHERE name = 'Dynamic Severity'"
830  " AND ((owner IS NULL)"
831  " OR (owner = (SELECT id FROM users"
832  " WHERE users.uuid"
833  " = (SELECT uuid"
834  " FROM current_credentials))))"
835  " ORDER BY coalesce (owner, 0) DESC LIMIT 1;"
836  "$$ LANGUAGE SQL;");
837 
838  sql ("CREATE OR REPLACE FUNCTION current_severity (real, text)"
839  " RETURNS double precision AS $$"
840  " SELECT coalesce ((CASE WHEN $1 > " G_STRINGIFY (SEVERITY_LOG)
841  " THEN (SELECT CAST (cvss_base"
842  " AS double precision)"
843  " FROM nvts"
844  " WHERE nvts.oid = $2)"
845  " ELSE $1"
846  " END),"
847  " $1);"
848  "$$ LANGUAGE SQL;");
849 
850 #define OVERRIDES_SQL(severity_sql) \
851  " coalesce" \
852  " ((SELECT overrides.new_severity" \
853  " FROM overrides" \
854  " WHERE overrides.nvt = results.nvt" \
855  " AND ((overrides.owner IS NULL)" \
856  " OR (overrides.owner =" \
857  " (SELECT id FROM users" \
858  " WHERE users.uuid" \
859  " = (SELECT uuid" \
860  " FROM current_credentials))))" \
861  " AND ((overrides.end_time = 0)" \
862  " OR (overrides.end_time >= m_now ()))" \
863  " AND (overrides.task = results.task" \
864  " OR overrides.task = 0)" \
865  " AND (overrides.result = results.id" \
866  " OR overrides.result = 0)" \
867  " AND (overrides.hosts is NULL" \
868  " OR overrides.hosts = ''" \
869  " OR hosts_contains (overrides.hosts," \
870  " results.host))" \
871  " AND (overrides.port is NULL" \
872  " OR overrides.port = ''" \
873  " OR overrides.port = results.port)" \
874  " AND severity_matches_ov" \
875  " (" severity_sql ", overrides.severity)" \
876  " ORDER BY overrides.result DESC," \
877  " overrides.task DESC," \
878  " overrides.port DESC," \
879  " overrides.severity ASC," \
880  " overrides.creation_time DESC" \
881  " LIMIT 1)," \
882  " " severity_sql ")"
883 
884  /* min_qod column was added in version 147 */
885  if (current_db_version >= 147)
886  sql ("CREATE OR REPLACE FUNCTION report_severity (report integer,"
887  " overrides integer,"
888  " min_qod integer)"
889  " RETURNS double precision AS $$"
890  /* Calculate the severity of a report. */
891  " WITH max_severity AS (SELECT max(severity) AS max"
892  " FROM report_counts"
893  // FIX should have user like report_counts_cache_exists? c version too?
894  " WHERE report = $1"
895  " AND override = $2"
896  " AND min_qod = $3"
897  " AND (end_time = 0 or end_time >= m_now ()))"
898  " SELECT CASE"
899  " WHEN EXISTS (SELECT max FROM max_severity)"
900  " AND (SELECT max FROM max_severity) IS NOT NULL"
901  " THEN (SELECT max::double precision FROM max_severity)"
902  " WHEN dynamic_severity () AND $2::boolean"
903  /* Dynamic severity, overrides on. */
904  " THEN (SELECT max"
905  " (" OVERRIDES_SQL
906  ("current_severity (results.severity,"
907  " results.nvt)") ")"
908  " FROM results"
909  " WHERE results.report = $1"
910  " AND results.qod >= $3)"
911  " WHEN dynamic_severity ()"
912  /* Dynamic severity, overrides off. */
913  " THEN (SELECT max (CASE"
914  " WHEN results.type IS NULL"
915  " THEN 0::real"
916  " ELSE current_severity"
917  " (results.severity, results.nvt)"
918  " END)"
919  " FROM results"
920  " WHERE results.report = $1"
921  " AND results.qod >= $3)"
922  " WHEN $2::boolean"
923  /* Overrides on. */
924  " THEN (SELECT max (" OVERRIDES_SQL ("results.severity") ")"
925  " FROM results"
926  " WHERE results.report = $1"
927  " AND results.qod >= $3)"
928  /* Overrides off. */
929  " ELSE (SELECT max (CASE"
930  " WHEN results.type IS NULL"
931  " THEN 0::real"
932  " ELSE results.severity"
933  " END)"
934  " FROM results"
935  " WHERE results.report = $1"
936  " AND results.qod >= $3)"
937  " END;"
938  "$$ LANGUAGE SQL;");
939 
940  sql ("CREATE OR REPLACE FUNCTION report_host_count (report integer)"
941  " RETURNS bigint AS $$"
942  " SELECT count (DISTINCT id) FROM report_hosts"
943  " WHERE report_hosts.report = $1;"
944  "$$ LANGUAGE SQL;");
945 
946  sql ("CREATE OR REPLACE FUNCTION report_result_host_count (report integer,"
947  " min_qod integer)"
948  " RETURNS bigint AS $$"
949  " SELECT count (DISTINCT id) FROM report_hosts"
950  " WHERE report_hosts.report = $1"
951  " AND EXISTS (SELECT * FROM results"
952  " WHERE results.host = report_hosts.host"
953  " AND results.qod >= $2)"
954  "$$ LANGUAGE SQL;");
955 
956  sql ("CREATE OR REPLACE FUNCTION severity_class ()"
957  " RETURNS text AS $$"
958  /* Get the user's severity class setting. */
959  " SELECT value FROM settings"
960  " WHERE name = 'Severity Class'"
961  " AND ((owner IS NULL)"
962  " OR (owner = (SELECT id FROM users"
963  " WHERE users.uuid = (SELECT uuid"
964  " FROM current_credentials))))"
965  " ORDER BY coalesce (owner, 0) DESC LIMIT 1;"
966  "$$ LANGUAGE SQL;");
967 
968  /* min_qod column was added in version 147 */
969  if (current_db_version >= 147)
970  sql ("CREATE OR REPLACE FUNCTION"
971  " report_severity_count (report integer, overrides integer,"
972  " min_qod integer, level text)"
973  " RETURNS bigint AS $$"
974  /* Calculate the severity of a report. */
975  " WITH severity_count AS (SELECT sum (count) AS total"
976  " FROM report_counts"
977  " WHERE report = $1"
978  " AND override = $2"
979  " AND min_qod = $3"
980  " AND (end_time = 0"
981  " or end_time >= m_now ())"
982  " AND (severity"
983  " BETWEEN level_min_severity"
984  " ($4, severity_class ())"
985  " AND level_max_severity"
986  " ($4, severity_class ())))"
987  " SELECT CASE"
988  " WHEN EXISTS (SELECT total FROM severity_count)"
989  " AND (SELECT total FROM severity_count) IS NOT NULL"
990  " THEN (SELECT total FROM severity_count)"
991  " WHEN dynamic_severity () AND $2::boolean"
992  /* Dynamic severity, overrides on. */
993  " THEN (SELECT count (*)"
994  " FROM results"
995  " WHERE results.report = $1"
996  " AND results.qod >= $3"
997  " AND (" OVERRIDES_SQL
998  ("current_severity (results.severity,"
999  " results.nvt)")
1000  " BETWEEN level_min_severity"
1001  " ($4, severity_class ())"
1002  " AND level_max_severity"
1003  " ($4, severity_class ())))"
1004  " WHEN dynamic_severity ()"
1005  /* Dynamic severity, overrides off. */
1006  " THEN (SELECT count (*)"
1007  " FROM results"
1008  " WHERE results.report = $1"
1009  " AND results.qod >= $3"
1010  " AND ((CASE"
1011  " WHEN results.type IS NULL"
1012  " THEN 0::real"
1013  " ELSE current_severity (results.severity,"
1014  " results.nvt)"
1015  " END)"
1016  " BETWEEN level_min_severity ($4, severity_class ())"
1017  " AND level_max_severity"
1018  " ($4, severity_class ())))"
1019  " WHEN $2::boolean"
1020  /* Overrides on. */
1021  " THEN (SELECT count (*)"
1022  " FROM results"
1023  " WHERE results.report = $1"
1024  " AND results.qod >= $3"
1025  " AND (" OVERRIDES_SQL ("results.severity")
1026  " BETWEEN level_min_severity ($4, severity_class ())"
1027  " AND level_max_severity"
1028  " ($4, severity_class ())))"
1029  /* Overrides off. */
1030  " ELSE (SELECT count (*)"
1031  " FROM results"
1032  " WHERE results.report = $1"
1033  " AND results.qod >= $3"
1034  " AND ((CASE"
1035  " WHEN results.type IS NULL"
1036  " THEN 0::real"
1037  " ELSE results.severity"
1038  " END)"
1039  " BETWEEN level_min_severity ($4, severity_class ())"
1040  " AND level_max_severity"
1041  " ($4, severity_class ())))"
1042  " END;"
1043  "$$ LANGUAGE SQL;");
1044 
1045  sql ("CREATE OR REPLACE FUNCTION task_last_report (integer)"
1046  " RETURNS integer AS $$"
1047  /* Get the report from the most recently completed invocation of task. */
1048  " SELECT id FROM reports WHERE task = $1 AND scan_run_status = %u"
1049  " ORDER BY date DESC LIMIT 1;"
1050  "$$ LANGUAGE SQL;",
1052 
1053  sql ("CREATE OR REPLACE FUNCTION task_second_last_report (integer)"
1054  " RETURNS integer AS $$"
1055  /* Get report from second most recently completed invocation of task. */
1056  " SELECT id FROM reports WHERE task = $1 AND scan_run_status = %u"
1057  " ORDER BY date DESC LIMIT 1 OFFSET 1;"
1058  "$$ LANGUAGE SQL;",
1060 
1061  if (current_db_version >= 147)
1062  {
1063  sql ("CREATE OR REPLACE FUNCTION task_severity (integer, integer,"
1064  " integer)"
1065  " RETURNS double precision AS $$"
1066  /* Calculate the severity of a task. */
1067  " SELECT CASE"
1068  " WHEN (SELECT target IS NULL OR target = 0"
1069  " FROM tasks WHERE id = $1)"
1070  " THEN CAST (NULL AS double precision)"
1071  " ELSE"
1072  " (SELECT report_severity ((SELECT id FROM reports"
1073  " WHERE task = $1"
1074  " AND scan_run_status = %u"
1075  " ORDER BY date DESC"
1076  " LIMIT 1 OFFSET 0), $2, $3))"
1077  " END;"
1078  "$$ LANGUAGE SQL;",
1080 
1081  sql ("CREATE OR REPLACE FUNCTION task_trend (integer, integer, integer)"
1082  " RETURNS text AS $$"
1083  /* Calculate the trend of a task. */
1084  " DECLARE"
1085  " last_report integer;"
1086  " second_last_report integer;"
1087  " severity_a double precision;"
1088  " severity_b double precision;"
1089  " high_a bigint;"
1090  " high_b bigint;"
1091  " medium_a bigint;"
1092  " medium_b bigint;"
1093  " low_a bigint;"
1094  " low_b bigint;"
1095  " threat_a integer;"
1096  " threat_b integer;"
1097  " BEGIN"
1098  " CASE"
1099  /* Ensure there are enough reports. */
1100  " WHEN (SELECT count(*) <= 1 FROM reports"
1101  " WHERE task = $1"
1102  " AND scan_run_status = %u)"
1103  " THEN RETURN ''::text;"
1104  /* Get trend only for authenticated users. */
1105  " WHEN NOT EXISTS (SELECT uuid FROM current_credentials)"
1106  " OR (SELECT uuid = '' FROM current_credentials)"
1107  " THEN RETURN ''::text;"
1108  /* Skip running and container tasks. */
1109  " WHEN (SELECT run_status = %u OR target = 0"
1110  " FROM tasks WHERE id = $1)"
1111  " THEN RETURN ''::text;"
1112  " ELSE"
1113  " END CASE;"
1114  /* Check if the severity score changed. */
1115  " last_report := task_last_report ($1);"
1116  " second_last_report := task_second_last_report ($1);"
1117  " severity_a := report_severity (last_report, $2, $3);"
1118  " severity_b := report_severity (second_last_report, $2, $3);"
1119  " IF severity_a > severity_b THEN"
1120  " RETURN 'up'::text;"
1121  " ELSIF severity_b > severity_a THEN"
1122  " RETURN 'down'::text;"
1123  " END IF;"
1124  /* Calculate trend. */
1125  " high_a := report_severity_count (last_report, $2, $3,"
1126  " 'high');"
1127  " high_b := report_severity_count (second_last_report, $2, $3,"
1128  " 'high');"
1129  " medium_a := report_severity_count (last_report, $2, $3,"
1130  " 'medium');"
1131  " medium_b := report_severity_count (second_last_report, $2, $3,"
1132  " 'medium');"
1133  " low_a := report_severity_count (last_report, $2, $3,"
1134  " 'low');"
1135  " low_b := report_severity_count (second_last_report, $2, $3,"
1136  " 'low');"
1137  " IF high_a > 0 THEN"
1138  " threat_a := 4;"
1139  " ELSIF medium_a > 0 THEN"
1140  " threat_a := 3;"
1141  " ELSIF low_a > 0 THEN"
1142  " threat_a := 2;"
1143  " ELSE"
1144  " threat_a := 1;"
1145  " END IF;"
1146  " IF high_b > 0 THEN"
1147  " threat_b := 4;"
1148  " ELSIF medium_b > 0 THEN"
1149  " threat_b := 3;"
1150  " ELSIF low_b > 0 THEN"
1151  " threat_b := 2;"
1152  " ELSE"
1153  " threat_b := 1;"
1154  " END IF;"
1155  /* Check if the threat level changed. */
1156  " IF threat_a > threat_b THEN"
1157  " RETURN 'up'::text;"
1158  " ELSIF threat_b > threat_a THEN"
1159  " RETURN 'down'::text;"
1160  " END IF;"
1161  /* Check if the threat count changed. */
1162  " IF high_a > 0 THEN"
1163  " IF high_a > high_b THEN"
1164  " RETURN 'more'::text;"
1165  " ELSIF high_a < high_b THEN"
1166  " RETURN 'less'::text;"
1167  " END IF;"
1168  " RETURN 'same'::text;"
1169  " END IF;"
1170  " IF medium_a > 0 THEN"
1171  " IF medium_a > medium_b THEN"
1172  " RETURN 'more'::text;"
1173  " ELSIF medium_a < medium_b THEN"
1174  " RETURN 'less'::text;"
1175  " END IF;"
1176  " RETURN 'same'::text;"
1177  " END IF;"
1178  " IF low_a > 0 THEN"
1179  " IF low_a > low_b THEN"
1180  " RETURN 'more'::text;"
1181  " ELSIF low_a < low_b THEN"
1182  " RETURN 'less'::text;"
1183  " END IF;"
1184  " RETURN 'same'::text;"
1185  " END IF;"
1186  " RETURN 'same'::text;"
1187  " END;"
1188  "$$ LANGUAGE plpgsql;",
1191  }
1192  }
1193 
1194  sql ("CREATE OR REPLACE FUNCTION run_status_name (integer)"
1195  " RETURNS text AS $$"
1196  /* Get the name of a task run status. */
1197  " SELECT CASE"
1198  " WHEN $1 = %i"
1199  " OR $1 = %i"
1200  " THEN 'Delete Requested'"
1201  " WHEN $1 = %i OR $1 = %i"
1202  " THEN 'Ultimate Delete Requested'"
1203  " WHEN $1 = %i"
1204  " THEN 'Done'"
1205  " WHEN $1 = %i"
1206  " THEN 'New'"
1207  " WHEN $1 = %i"
1208  " THEN 'Requested'"
1209  " WHEN $1 = %i"
1210  " THEN 'Running'"
1211  " WHEN $1 = %i OR $1 = %i OR $1 = %i"
1212  " THEN 'Stop Requested'"
1213  " WHEN $1 = %i"
1214  " THEN 'Stopped'"
1215  " ELSE 'Internal Error'"
1216  " END;"
1217  "$$ LANGUAGE SQL"
1218  " IMMUTABLE;",
1231 
1232  if (sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
1233  " WHERE table_catalog = '%s'"
1234  " AND table_schema = 'public'"
1235  " AND table_name = 'permissions')"
1236  " ::integer;",
1237  sql_database ()))
1238  sql ("CREATE OR REPLACE FUNCTION user_can_everything (text)"
1239  " RETURNS boolean AS $$"
1240  /* Test whether a user may perform any operation.
1241  *
1242  * This must match user_can_everything in manage_acl.c. */
1243  " SELECT count(*) > 0 FROM permissions"
1244  " WHERE resource = 0"
1245  " AND ((subject_type = 'user'"
1246  " AND subject"
1247  " = (SELECT id FROM users"
1248  " WHERE users.uuid = $1))"
1249  " OR (subject_type = 'group'"
1250  " AND subject"
1251  " IN (SELECT DISTINCT \"group\""
1252  " FROM group_users"
1253  " WHERE \"user\" = (SELECT id"
1254  " FROM users"
1255  " WHERE users.uuid"
1256  " = $1)))"
1257  " OR (subject_type = 'role'"
1258  " AND subject"
1259  " IN (SELECT DISTINCT role"
1260  " FROM role_users"
1261  " WHERE \"user\" = (SELECT id"
1262  " FROM users"
1263  " WHERE users.uuid"
1264  " = $1))))"
1265  " AND name = 'Everything';"
1266  "$$ LANGUAGE SQL;");
1267 
1268  sql ("CREATE OR REPLACE FUNCTION group_concat_pair (text, text, text)"
1269  " RETURNS text AS $$"
1270  " SELECT CASE"
1271  " WHEN $1 IS NULL OR $1 = ''"
1272  " THEN $2"
1273  " ELSE $1 || $3 || $2"
1274  " END;"
1275  "$$ LANGUAGE SQL"
1276  " IMMUTABLE;");
1277 
1278  sql ("DROP AGGREGATE IF EXISTS group_concat (text, text);");
1279 
1280  sql ("CREATE AGGREGATE group_concat (text, text)"
1281  " (sfunc = group_concat_pair,"
1282  " stype = text,"
1283  " initcond = '');");
1284 
1285  if (sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
1286  " WHERE table_catalog = '%s'"
1287  " AND table_schema = 'public'"
1288  " AND table_name = 'meta')"
1289  " ::integer;",
1290  sql_database ()))
1291  {
1292  sql ("CREATE OR REPLACE FUNCTION severity_in_level (double precision,"
1293  " text)"
1294  " RETURNS boolean AS $$"
1295  " SELECT CASE (SELECT value FROM settings"
1296  " WHERE name = 'Severity Class'"
1297  " AND ((owner IS NULL)"
1298  " OR (owner = (SELECT id FROM users"
1299  " WHERE users.uuid"
1300  " = (SELECT uuid"
1301  " FROM current_credentials))))"
1302  " ORDER BY coalesce (owner, 0) DESC LIMIT 1)"
1303  " WHEN 'classic'"
1304  " THEN (CASE lower ($2)"
1305  " WHEN 'high'"
1306  " THEN $1 > 5"
1307  " AND $1 <= 10"
1308  " WHEN 'medium'"
1309  " THEN $1 > 2"
1310  " AND $1 <= 5"
1311  " WHEN 'low'"
1312  " THEN $1 > 0"
1313  " AND $1 <= 2"
1314  " WHEN 'none'"
1315  " THEN $1 = 0"
1316  " WHEN 'log'"
1317  " THEN $1 = 0"
1318  " ELSE 0::boolean"
1319  " END)"
1320  " WHEN 'pci-dss'"
1321  " THEN (CASE lower ($2)"
1322  " WHEN 'high'"
1323  " THEN $1 >= 4.0"
1324  " WHEN 'none'"
1325  " THEN $1 >= 0.0 AND $1 < 4.0"
1326  " WHEN 'log'"
1327  " THEN $1 >= 0.0 AND $1 < 4.0"
1328  " ELSE 0::boolean"
1329  " END)"
1330  " ELSE " /* NIST/BSI */
1331  " (CASE lower ($2)"
1332  " WHEN 'high'"
1333  " THEN $1 >= 7"
1334  " AND $1 <= 10"
1335  " WHEN 'medium'"
1336  " THEN $1 >= 4"
1337  " AND $1 < 7"
1338  " WHEN 'low'"
1339  " THEN $1 > 0"
1340  " AND $1 < 4"
1341  " WHEN 'none'"
1342  " THEN $1 = 0"
1343  " WHEN 'log'"
1344  " THEN $1 = 0"
1345  " ELSE 0::boolean"
1346  " END)"
1347  " END;"
1348  "$$ LANGUAGE SQL;");
1349 
1350  sql ("CREATE OR REPLACE FUNCTION severity_to_level (text, integer)"
1351  " RETURNS text AS $$"
1352  " SELECT CASE"
1353  " WHEN $1::double precision = " G_STRINGIFY (SEVERITY_LOG)
1354  " THEN 'Log'"
1355  " WHEN $1::double precision = " G_STRINGIFY (SEVERITY_FP)
1356  " THEN 'False Positive'"
1357  " WHEN $1::double precision = " G_STRINGIFY (SEVERITY_DEBUG)
1358  " THEN 'Debug'"
1359  " WHEN $1::double precision = " G_STRINGIFY (SEVERITY_ERROR)
1360  " THEN 'Error'"
1361  " WHEN $1::double precision > 0.0"
1362  " AND $1::double precision <= 10.0"
1363  " THEN (SELECT CASE"
1364  " WHEN $2 = 1"
1365  " THEN 'Alarm'"
1366  " WHEN severity_in_level ($1::double precision,"
1367  " 'high')"
1368  " THEN 'High'"
1369  " WHEN severity_in_level ($1::double precision,"
1370  " 'medium')"
1371  " THEN 'Medium'"
1372  " WHEN severity_in_level ($1::double precision,"
1373  " 'low')"
1374  " THEN 'Low'"
1375  " ELSE 'Log'"
1376  " END)"
1377  " ELSE 'Internal Error'"
1378  " END;"
1379  "$$ LANGUAGE SQL"
1380  " IMMUTABLE;");
1381 
1382  sql ("CREATE OR REPLACE FUNCTION severity_to_level (double precision,"
1383  " integer)"
1384  " RETURNS text AS $$"
1385  " SELECT CASE"
1386  " WHEN $1 = " G_STRINGIFY (SEVERITY_LOG)
1387  " THEN 'Log'"
1388  " WHEN $1 = " G_STRINGIFY (SEVERITY_FP)
1389  " THEN 'False Positive'"
1390  " WHEN $1 = " G_STRINGIFY (SEVERITY_DEBUG)
1391  " THEN 'Debug'"
1392  " WHEN $1 = " G_STRINGIFY (SEVERITY_ERROR)
1393  " THEN 'Error'"
1394  " WHEN $1 > 0.0 AND $1 <= 10.0"
1395  " THEN (SELECT CASE"
1396  " WHEN $2 = 1"
1397  " THEN 'Alarm'"
1398  " WHEN severity_in_level ($1, 'high')"
1399  " THEN 'High'"
1400  " WHEN severity_in_level ($1, 'medium')"
1401  " THEN 'Medium'"
1402  " WHEN severity_in_level ($1, 'low')"
1403  " THEN 'Low'"
1404  " ELSE 'Log'"
1405  " END)"
1406  " ELSE 'Internal Error'"
1407  " END;"
1408  "$$ LANGUAGE SQL"
1409  " IMMUTABLE;");
1410 
1411  if (current_db_version >= 147)
1412  sql ("CREATE OR REPLACE FUNCTION task_threat_level (integer, integer,"
1413  " integer)"
1414  " RETURNS text AS $$"
1415  /* Calculate the threat level of a task. */
1416  " SELECT severity_to_level (task_severity ($1, $2, $3), 0);"
1417  "$$ LANGUAGE SQL"
1418  " IMMUTABLE;");
1419  }
1420 
1421  if (sql_int ("SELECT (EXISTS (SELECT * FROM information_schema.tables"
1422  " WHERE table_catalog = '%s'"
1423  " AND table_schema = 'public'"
1424  " AND table_name = 'credentials_data')"
1425  " AND EXISTS (SELECT * FROM information_schema.tables"
1426  " WHERE table_catalog = '%s'"
1427  " AND table_schema = 'public'"
1428  " AND table_name = 'credentials_trash_data'))"
1429  " ::integer;",
1430  sql_database (), sql_database ()))
1431  {
1432  sql ("CREATE OR REPLACE FUNCTION credential_value (integer, integer, text)"
1433  " RETURNS text AS $$"
1434  " SELECT CASE"
1435  " WHEN $2 != 0"
1436  " THEN"
1437  " (SELECT value FROM credentials_trash_data"
1438  " WHERE credential = $1 AND type = $3)"
1439  " ELSE"
1440  " (SELECT value FROM credentials_data"
1441  " WHERE credential = $1 AND type = $3)"
1442  " END;"
1443  "$$ LANGUAGE SQL;");
1444  }
1445 
1446  if (sql_int ("SELECT (EXISTS (SELECT * FROM information_schema.tables"
1447  " WHERE table_catalog = '%s'"
1448  " AND table_schema = 'public'"
1449  " AND table_name = 'targets_login_data')"
1450  " AND EXISTS (SELECT * FROM information_schema.tables"
1451  " WHERE table_catalog = '%s'"
1452  " AND table_schema = 'public'"
1453  " AND table_name = 'targets_trash_login_data'))"
1454  " ::integer;",
1455  sql_database (), sql_database ()))
1456  {
1457  sql ("CREATE OR REPLACE FUNCTION target_credential (integer, integer, text)"
1458  " RETURNS integer AS $$"
1459  " SELECT CASE"
1460  " WHEN $2 != 0"
1461  " THEN"
1462  " (SELECT credential FROM targets_trash_login_data"
1463  " WHERE target = $1 AND type = $3)"
1464  " ELSE"
1465  " (SELECT credential FROM targets_login_data"
1466  " WHERE target = $1 AND type = $3)"
1467  " END;"
1468  "$$ LANGUAGE SQL;");
1469 
1470  sql ("CREATE OR REPLACE FUNCTION trash_target_credential_location (integer, text)"
1471  " RETURNS integer AS $$"
1472  " SELECT credential_location FROM targets_trash_login_data"
1473  " WHERE target = $1 AND type = $2"
1474  "$$ LANGUAGE SQL;");
1475 
1476  sql ("CREATE OR REPLACE FUNCTION target_login_port (integer, integer, text)"
1477  " RETURNS integer AS $$"
1478  " SELECT CASE"
1479  " WHEN $2 != 0"
1480  " THEN"
1481  " (SELECT port FROM targets_trash_login_data"
1482  " WHERE target = $1 AND type = $3)"
1483  " ELSE"
1484  " (SELECT port FROM targets_login_data"
1485  " WHERE target = $1 AND type = $3)"
1486  " END;"
1487  "$$ LANGUAGE SQL;");
1488  }
1489 
1490  sql ("CREATE OR REPLACE FUNCTION lower (integer)"
1491  " RETURNS integer AS $$"
1492  " SELECT $1;"
1493  "$$ LANGUAGE SQL"
1494  " IMMUTABLE;");
1495 
1496  return 0;
1497 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
#define OVERRIDES_SQL(severity_sql)
#define SEVERITY_ERROR
Definition: manage_utils.h:38
#define SEVERITY_FP
Definition: manage_utils.h:34
#define SEVERITY_DEBUG
Definition: manage_utils.h:36
int manage_db_version()
Return the database version of the actual database.
Definition: manage_sql.c:6262
const char * sql_database()
Return name of current database.
Definition: sql_pg.c:226
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
int manage_scap_loaded()
Check whether SCAP is available.
Definition: manage_pg.c:2659
#define SEVERITY_LOG
Definition: manage_utils.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_db_supported_version()

int manage_db_supported_version ( )

Return the database version supported by this manager.

Returns
Database version supported by this manager.

Definition at line 6250 of file manage_sql.c.

6251 {
6252  return OPENVASMD_DATABASE_VERSION;
6253 }

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

Definition at line 6262 of file manage_sql.c.

References manage_db_empty(), sql_schema(), and sql_string().

Referenced by manage_create_sql_functions(), migrate_0_to_1(), migrate_100_to_101(), migrate_101_to_102(), migrate_102_to_103(), migrate_103_to_104(), migrate_104_to_105(), migrate_105_to_106(), migrate_106_to_107(), migrate_107_to_108(), migrate_108_to_109(), migrate_109_to_110(), migrate_10_to_11(), migrate_110_to_111(), migrate_111_to_112(), migrate_112_to_113(), migrate_113_to_114(), migrate_114_to_115(), migrate_115_to_116(), migrate_116_to_117(), migrate_117_to_118(), migrate_118_to_119(), migrate_119_to_120(), migrate_11_to_12(), migrate_120_to_121(), migrate_121_to_122(), migrate_122_to_123(), migrate_123_to_124(), migrate_124_to_125(), migrate_125_to_126(), migrate_126_to_127(), migrate_127_to_128(), migrate_128_to_129(), migrate_129_to_130(), migrate_12_to_13(), migrate_130_to_131(), migrate_131_to_132(), migrate_132_to_133(), migrate_133_to_134(), migrate_134_to_135(), migrate_135_to_136(), migrate_136_to_137(), migrate_137_to_138(), migrate_138_to_139(), migrate_139_to_140(), migrate_13_to_14(), migrate_140_to_141(), migrate_141_to_142(), migrate_142_to_143(), migrate_143_to_144(), migrate_144_to_145(), migrate_145_to_146(), migrate_146_to_147(), migrate_147_to_148(), migrate_148_to_149(), migrate_149_to_150(), migrate_14_to_15(), migrate_150_to_151(), migrate_151_to_152(), migrate_152_to_153(), migrate_153_to_154(), migrate_154_to_155(), migrate_155_to_156(), migrate_156_to_157(), migrate_157_to_158(), migrate_158_to_159(), migrate_159_to_160(), migrate_15_to_16(), migrate_160_to_161(), migrate_161_to_162(), migrate_162_to_163(), migrate_163_to_164(), migrate_164_to_165(), migrate_165_to_166(), migrate_166_to_167(), migrate_167_to_168(), migrate_168_to_169(), migrate_169_to_170(), migrate_16_to_17(), migrate_170_to_171(), migrate_171_to_172(), migrate_172_to_173(), migrate_173_to_174(), migrate_174_to_175(), migrate_175_to_176(), migrate_176_to_177(), migrate_177_to_178(), migrate_178_to_179(), migrate_179_to_180(), migrate_17_to_18(), migrate_180_to_181(), migrate_181_to_182(), migrate_182_to_183(), migrate_183_to_184(), migrate_18_to_19(), migrate_19_to_20(), migrate_1_to_2(), migrate_20_to_21(), migrate_21_to_22(), migrate_22_to_23(), migrate_23_to_24(), migrate_24_to_25(), migrate_25_to_26(), migrate_26_to_27(), migrate_27_to_28(), migrate_28_to_29(), migrate_29_to_30(), migrate_2_to_3(), migrate_30_to_31(), migrate_31_to_32(), migrate_32_to_33(), migrate_33_to_34(), migrate_34_to_35(), migrate_35_to_36(), migrate_36_to_37(), migrate_37_to_38(), migrate_38_to_39(), migrate_39_to_40(), migrate_3_to_4(), migrate_40_to_41(), migrate_41_to_42(), migrate_42_to_43(), migrate_43_to_44(), migrate_44_to_45(), migrate_45_to_46(), migrate_46_to_47(), migrate_47_to_48(), migrate_48_to_49(), migrate_49_to_50(), migrate_4_to_5(), migrate_50_to_51(), migrate_51_to_52(), migrate_52_to_53(), migrate_53_to_54(), migrate_54_to_55(), migrate_55_to_56(), migrate_56_to_57(), migrate_57_to_58(), migrate_58_to_59(), migrate_59_to_60(), migrate_5_to_6(), migrate_60_to_61(), migrate_61_to_62(), migrate_62_to_63(), migrate_63_to_64(), migrate_64_to_65(), migrate_65_to_66(), migrate_66_to_67(), migrate_67_to_68(), migrate_68_to_69(), migrate_69_to_70(), migrate_6_to_7(), migrate_70_to_71(), migrate_71_to_72(), migrate_72_to_73(), migrate_73_to_74(), migrate_74_to_75(), migrate_75_to_76(), migrate_76_to_77(), migrate_77_to_78(), migrate_78_to_79(), migrate_7_to_8(), migrate_80_to_81(), migrate_81_to_82(), migrate_82_to_83(), migrate_83_to_84(), migrate_84_to_85(), migrate_85_to_86(), migrate_86_to_87(), migrate_87_to_88(), migrate_88_to_89(), migrate_89_to_90(), migrate_8_to_9(), migrate_90_to_91(), migrate_91_to_92(), migrate_92_to_93(), migrate_93_to_94(), migrate_94_to_95(), migrate_95_to_96(), migrate_96_to_97(), migrate_97_to_98(), migrate_98_to_99(), migrate_99_to_100(), and migrate_9_to_10().

6263 {
6264  int number;
6265  char *version;
6266 
6267  if (manage_db_empty ())
6268  return -2;
6269 
6270  version = sql_string ("SELECT value FROM %s.meta"
6271  " WHERE name = 'database_version' LIMIT 1;",
6272  sql_schema ());
6273  if (version)
6274  {
6275  number = atoi (version);
6276  free (version);
6277  return number;
6278  }
6279  return -1;
6280 }
const char * sql_schema()
Get main schema name.
Definition: sql_pg.c:103
int manage_db_empty()
Check whether database is empty.
Definition: manage_pg.c:78
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ manage_decrypt_all_credentials()

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

Decrypt all credentials.

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

Definition at line 6599 of file manage_sql.c.

6600 {
6601  int ret;
6602 
6603  g_info (" Decrypting all credentials.\n");
6604 
6605  ret = manage_option_setup (log_config, database);
6606  if (ret)
6607  return ret;
6608 
6609  ret = encrypt_all_credentials (TRUE);
6610  if (ret)
6611  printf ("Decryption failed.\n");
6612  else
6613  printf ("Decryption succeeded.\n");
6614 
6616 
6617  return ret;
6618 }
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310
void manage_option_cleanup()
Cleanup for an option process.
Definition: manage_sql.c:1504
#define g_info(...)
Defines g_info for glib versions older than 2.40.
Definition: manage.h:55
int manage_option_setup(GSList *log_config, const gchar *database)
Setup for an option process.
Definition: manage_sql.c:1463

◆ manage_encrypt_all_credentials()

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

Encrypt or re-encrypt all credentials.

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

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

Definition at line 6567 of file manage_sql.c.

6568 {
6569  int ret;
6570 
6571  g_info (" (Re-)encrypting all credentials.\n");
6572 
6573  ret = manage_option_setup (log_config, database);
6574  if (ret)
6575  return ret;
6576 
6577  ret = encrypt_all_credentials (FALSE);
6578  if (ret)
6579  printf ("Encryption failed.\n");
6580  else
6581  printf ("Encryption succeeded.\n");
6582 
6584 
6585  return ret;
6586 }
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310
void manage_option_cleanup()
Cleanup for an option process.
Definition: manage_sql.c:1504
#define g_info(...)
Defines g_info for glib versions older than 2.40.
Definition: manage.h:55
int manage_option_setup(GSList *log_config, const gchar *database)
Setup for an option process.
Definition: manage_sql.c:1463

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

Definition at line 2289 of file manage_sql.c.

References keyword::column, filter_free(), SETTING_UUID_ROWS_PER_PAGE, setting_value_int(), split_filter(), and keyword::string.

Referenced by init_get().

2291 {
2292  keyword_t **point;
2293  array_t *split;
2294 
2295  if (filter == NULL)
2296  {
2297  if (first)
2298  *first = 1;
2299  if (max)
2300  *max = -1;
2301  if (sort_field)
2302  *sort_field = g_strdup ("name");
2303  if (sort_order)
2304  *sort_order = 1;
2305  return;
2306  }
2307 
2308  split = split_filter (filter);
2309  point = (keyword_t**) split->pdata;
2310  if (first)
2311  {
2312  *first = 1;
2313  while (*point)
2314  {
2315  keyword_t *keyword;
2316 
2317  keyword = *point;
2318  if (keyword->column && (strcmp (keyword->column, "first") == 0))
2319  {
2320  *first = atoi (keyword->string);
2321  if (*first < 0)
2322  *first = 0;
2323  break;
2324  }
2325  point++;
2326  }
2327  }
2328 
2329  point = (keyword_t**) split->pdata;
2330  if (max)
2331  {
2332  *max = -1;
2333  while (*point)
2334  {
2335  keyword_t *keyword;
2336 
2337  keyword = *point;
2338  if (keyword->column && (strcmp (keyword->column, "rows") == 0))
2339  {
2340  *max = atoi (keyword->string);
2341  if (*max == -2)
2343  else if (*max < 1)
2344  *max = -1;
2345  break;
2346  }
2347  point++;
2348  }
2349  }
2350 
2351  point = (keyword_t**) split->pdata;
2352  if (sort_field || sort_order)
2353  {
2354  if (sort_field) *sort_field = NULL;
2355  if (sort_order) *sort_order = 1;
2356  while (*point)
2357  {
2358  keyword_t *keyword;
2359 
2360  keyword = *point;
2361  if (keyword->column
2362  && (strcmp (keyword->column, "sort") == 0))
2363  {
2364  if (sort_field) *sort_field = g_strdup (keyword->string);
2365  if (sort_order) *sort_order = 1;
2366  break;
2367  }
2368  if (keyword->column
2369  && (strcmp (keyword->column, "sort-reverse") == 0))
2370  {
2371  if (sort_field) *sort_field = g_strdup (keyword->string);
2372  if (sort_order) *sort_order = 0;
2373  break;
2374  }
2375  point++;
2376  }
2377  if (sort_field && (*sort_field == NULL))
2378  *sort_field = g_strdup ("name");
2379  }
2380 
2381  filter_free (split);
2382  return;
2383 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
void filter_free(array_t *split)
Free a split filter.
Definition: manage_sql.c:2018
int setting_value_int(const char *, int *)
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
array_t * split_filter(const gchar *given_filter)
Split the filter term into parts.
Definition: manage_sql.c:2043
#define SETTING_UUID_ROWS_PER_PAGE
UUID of &#39;Rows Per Page&#39; setting.
Definition: manage_sql.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_option_cleanup()

void manage_option_cleanup ( )

Cleanup for an option process.

Definition at line 1504 of file manage_sql.c.

References cleanup_manage_process().

1505 {
1506  cleanup_manage_process (TRUE);
1507 }
void cleanup_manage_process(gboolean cleanup)
Cleanup the manage library.
Definition: manage_sql.c:17128
Here is the call graph for this function:

◆ manage_option_setup()

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

Setup for an option process.

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

Definition at line 1463 of file manage_sql.c.

1464 {
1465  const gchar *db;
1466  int ret;
1467 
1468  if (openvas_auth_init ())
1469  {
1470  fprintf (stderr, "Authentication init failed\n");
1471  return -1;
1472  }
1473 
1474  db = database ? database : sql_default_database ();
1475 
1477  assert (ret != -4);
1478  switch (ret)
1479  {
1480  case 0:
1481  break;
1482  case -2:
1483  fprintf (stderr, "Database is wrong version.\n");
1484  return ret;
1485  case -3:
1486  fprintf (stderr,
1487  "Database must be initialised"
1488  " (with --update or --rebuild).\n");
1489  return ret;
1490  default:
1491  fprintf (stderr, "Internal error.\n");
1492  return ret;
1493  }
1494 
1495  init_manage_process (0, db);
1496 
1497  return 0;
1498 }
void init_manage_process(int update_nvt_cache, const gchar *database)
Initialize the manage library for a process.
Definition: manage_sql.c:14303
GSList * log_config
Logging parameters, as passed to setup_log_handlers.
Definition: openvasmd.c:310
#define MANAGE_ABSOLUTE_MAX_IPS_PER_TARGET
Absolute maximum number of IPs per target.
Definition: manage.h:1531
const char * sql_default_database()
Return name of default database.
Definition: sql_pg.c:237
int init_manage_helper(GSList *log_config, const gchar *database, int max_ips_per_target, void(*update_progress)())
Initialize the manage library for a helper program.
Definition: manage_sql.c:17102

◆ manage_port_name()

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

Returns associated name for a tcp/ip port.

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

Definition at line 6359 of file manage_sql.c.

References sql_string().

Referenced by port_name_formatted().

6360 {
6361  if (protocol == NULL || number <= 0 || number > 65535)
6362  return NULL;
6363 
6364  return sql_string ("SELECT name FROM port_names"
6365  " WHERE number = %i AND protocol = '%s' LIMIT 1;",
6366  number, protocol);
6367 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_report_filter_controls()

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

Get info from a filter for report.

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

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

Definition at line 2474 of file manage_sql.c.

References keyword::column, keyword::equal, filter_control_int(), filter_control_str(), filter_free(), SETTING_UUID_ROWS_PER_PAGE, setting_value_int(), split_filter(), and keyword::string.

2481 {
2482  keyword_t **point;
2483  array_t *split;
2484  int val;
2485  gchar *string;
2486 
2487  if (filter == NULL)
2488  return;
2489 
2490  split = split_filter (filter);
2491  point = (keyword_t**) split->pdata;
2492  if (first)
2493  {
2494  *first = 1;
2495  while (*point)
2496  {
2497  keyword_t *keyword;
2498 
2499  keyword = *point;
2500  if (keyword->column && (strcmp (keyword->column, "first") == 0))
2501  {
2502  *first = atoi (keyword->string);
2503  if (*first < 0)
2504  *first = 0;
2505  break;
2506  }
2507  point++;
2508  }
2509  /* Switch from 1 to 0 indexing. */
2510 
2511  (*first)--;
2512  }
2513 
2514  point = (keyword_t**) split->pdata;
2515  if (max)
2516  {
2517  *max = 100;
2518  while (*point)
2519  {
2520  keyword_t *keyword;
2521 
2522  keyword = *point;
2523  if (keyword->column && (strcmp (keyword->column, "rows") == 0))
2524  {
2525  *max = atoi (keyword->string);
2526  if (*max == -2)
2528  else if (*max < 1)
2529  *max = -1;
2530  break;
2531  }
2532  point++;
2533  }
2534  }
2535 
2536  point = (keyword_t**) split->pdata;
2537  if (sort_field || sort_order)
2538  {
2539  if (sort_field) *sort_field = NULL;
2540  if (sort_order) *sort_order = 1;
2541  while (*point)
2542  {
2543  keyword_t *keyword;
2544 
2545  keyword = *point;
2546  if (keyword->column
2547  && (strcmp (keyword->column, "sort") == 0))
2548  {
2549  if (sort_field) *sort_field = g_strdup (keyword->string);
2550  if (sort_order) *sort_order = 1;
2551  break;
2552  }
2553  if (keyword->column
2554  && (strcmp (keyword->column, "sort-reverse") == 0))
2555  {
2556  if (sort_field) *sort_field = g_strdup (keyword->string);
2557  if (sort_order) *sort_order = 0;
2558  break;
2559  }
2560  point++;
2561  }
2562  if (sort_field && (*sort_field == NULL))
2563  // FIX name??
2564  *sort_field = g_strdup ("name");
2565  }
2566 
2567  if (search_phrase)
2568  {
2569  GString *phrase;
2570  phrase = g_string_new ("");
2571  point = (keyword_t**) split->pdata;
2572  if (search_phrase_exact)
2573  *search_phrase_exact = 0;
2574  while (*point)
2575  {
2576  keyword_t *keyword;
2577 
2578  keyword = *point;
2579  if (keyword->column == NULL)
2580  {
2581  if (search_phrase_exact && keyword->equal)
2582  /* If one term is "exact" then the search is "exact", because
2583  * for reports the filter terms are combined into a single
2584  * search term. */
2585  *search_phrase_exact = 1;
2586  g_string_append_printf (phrase, "%s ", keyword->string);
2587  }
2588  point++;
2589  }
2590  *search_phrase = g_strchomp (phrase->str);
2591  g_string_free (phrase, FALSE);
2592  }
2593 
2594  if (result_hosts_only)
2595  {
2596  if (filter_control_int ((keyword_t **) split->pdata,
2597  "result_hosts_only",
2598  &val))
2599  *result_hosts_only = 1;
2600  else
2601  *result_hosts_only = val;
2602  }
2603 
2604  if (autofp)
2605  {
2606  if (filter_control_int ((keyword_t **) split->pdata,
2607  "autofp",
2608  &val))
2609  *autofp = 0;
2610  else
2611  *autofp = val;
2612  }
2613 
2614  if (notes)
2615  {
2616  if (filter_control_int ((keyword_t **) split->pdata,
2617  "notes",
2618  &val))
2619  *notes = 1;
2620  else
2621  *notes = val;
2622  }
2623 
2624  if (overrides)
2625  {
2626  if (filter_control_int ((keyword_t **) split->pdata,
2627  "overrides",
2628  &val))
2629  *overrides = 1;
2630  else
2631  *overrides = val;
2632  }
2633 
2634  if (apply_overrides)
2635  {
2636  if (filter_control_int ((keyword_t **) split->pdata,
2637  "apply_overrides",
2638  &val))
2639  {
2640  if (filter_control_int ((keyword_t **) split->pdata,
2641  "overrides",
2642  &val))
2643  *apply_overrides = 1;
2644  else
2645  *apply_overrides = val;
2646  }
2647  else
2648  *apply_overrides = val;
2649  }
2650 
2651  if (delta_states)
2652  {
2653  if (filter_control_str ((keyword_t **) split->pdata,
2654  "delta_states",
2655  &string))
2656  *delta_states = NULL;
2657  else
2658  *delta_states = string;
2659  }
2660 
2661  if (levels)
2662  {
2663  if (filter_control_str ((keyword_t **) split->pdata,
2664  "levels",
2665  &string))
2666  *levels = NULL;
2667  else
2668  *levels = string;
2669  }
2670 
2671  if (min_qod)
2672  {
2673  if (filter_control_str ((keyword_t **) split->pdata,
2674  "min_qod",
2675  &string))
2676  *min_qod = NULL;
2677  else
2678  *min_qod = string;
2679  }
2680 
2681  if (zone)
2682  {
2683  if (filter_control_str ((keyword_t **) split->pdata,
2684  "timezone",
2685  &string))
2686  *zone = NULL;
2687  else
2688  *zone = string;
2689  }
2690 
2691  filter_free (split);
2692  return;
2693 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
void filter_free(array_t *split)
Free a split filter.
Definition: manage_sql.c:2018
int filter_control_int(keyword_t **point, const char *column, int *val)
Get an int column from a filter split.
Definition: manage_sql.c:2395
int setting_value_int(const char *, int *)
int equal
Whether the keyword is like "=example".
Definition: manage.h:3431
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
int filter_control_str(keyword_t **point, const char *column, gchar **string)
Get a string column from a filter split.
Definition: manage_sql.c:2424
array_t * split_filter(const gchar *given_filter)
Split the filter term into parts.
Definition: manage_sql.c:2043
#define SETTING_UUID_ROWS_PER_PAGE
UUID of &#39;Rows Per Page&#39; setting.
Definition: manage_sql.h:213
Here is the call graph for this function:

◆ manage_reset_currents()

void manage_reset_currents ( )

Cleanup as immediately as possible.

Definition at line 17173 of file manage_sql.c.

References current_report, and current_scanner_task.

17174 {
17175  current_report = 0;
17177 }
task_t current_scanner_task
The task currently running on the scanner.
Definition: manage.c:998
report_t current_report
The report of the current task.
Definition: manage.c:1003
long long int task_t
Definition: manage.h:286

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

Definition at line 4942 of file manage_sql.c.

References LOCATION_TABLE, and resource_name().

4943 {
4944  return resource_name (type, uuid, LOCATION_TABLE, name);
4945 }
int resource_name(const char *type, const char *uuid, int location, char **name)
Get the name of a resource.
Definition: manage_sql.c:4852
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

◆ manage_scanner_set()

int manage_scanner_set ( const char *  uuid)

Set the address of scanner to connect to.

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

Definition at line 17377 of file manage_sql.c.

References current_credentials, find_scanner(), openvas_scanner_set_address(), openvas_scanner_set_unix(), scanner_ca_pub(), scanner_host(), scanner_key_priv(), scanner_key_pub(), scanner_port(), SCANNER_TYPE_OPENVAS, and set_certs().

Referenced by manage_scanner_set_default().

17378 {
17379  scanner_t scanner = 0;
17380  char *host;
17381  int type, ret = 0;
17382 
17383  if (uuid == NULL)
17384  return -1;
17385 
17386  if (!current_credentials.uuid)
17387  current_credentials.uuid = "";
17388  if (find_scanner (uuid, &scanner) || scanner == 0)
17389  {
17390  g_warning ("Failed to find scanner %s\n", uuid);
17391  return -1;
17392  }
17393  if (!strcmp (current_credentials.uuid, ""))
17394  current_credentials.uuid = NULL;
17395 
17396  type = scanner_type (scanner);
17397  if (type != SCANNER_TYPE_OPENVAS)
17398  {
17399  g_warning ("Scanner %s not an OpenVAS Scanner\n", uuid);
17400  return -1;
17401  }
17402  host = scanner_host (scanner);
17403  if (host && *host == '/')
17404  {
17405  /* XXX: Workaround for unix socket case. Should add a flag. */
17406  openvas_scanner_set_unix (host);
17407  }
17408  else
17409  {
17410  char *ca_pub, *key_pub, *key_priv;
17411  int port;
17412 
17413  port = scanner_port (scanner);
17414  if (openvas_scanner_set_address (host, port))
17415  {
17416  g_warning ("Failed to set %s:%d as scanner\n", host, port);
17417  g_free (host);
17418  return -1;
17419  }
17420  ca_pub = scanner_ca_pub (scanner);
17421  key_pub = scanner_key_pub (scanner);
17422  key_priv = scanner_key_priv (scanner);
17423  ret = set_certs (ca_pub, key_pub, key_priv);
17424  g_free (ca_pub);
17425  g_free (key_pub);
17426  g_free (key_priv);
17427  }
17428  g_free (host);
17429  if (ret)
17430  return -2;
17431  return 0;
17432 }
int set_certs(const char *, const char *, const char *)
Initialise OpenVAS scanner variables, checking for defaults.
Definition: manage.c:4312
int openvas_scanner_set_address(const char *addr, int port)
Set the scanner&#39;s address and port. Will try to resolve addr if it is a hostname. ...
Definition: scanner.c:807
char * scanner_host(scanner_t)
int scanner_port(scanner_t)
char * scanner_ca_pub(scanner_t)
char * scanner_key_priv(scanner_t)
gboolean find_scanner(const char *, scanner_t *)
int openvas_scanner_set_unix(const char *path)
Set the scanner&#39;s unix socket path.
Definition: scanner.c:833
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
scanner_type
Scanner types.
Definition: manage.h:267
long long int scanner_t
Definition: manage.h:300
char * scanner_key_pub(scanner_t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ manage_scanner_set_default()

int manage_scanner_set_default ( )

Set the default scanner as the scanner to connect to.

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

Definition at line 17440 of file manage_sql.c.

References manage_scanner_set(), and SCANNER_UUID_DEFAULT.

17441 {
17443 }
#define SCANNER_UUID_DEFAULT
UUID of &#39;OpenVAS Default&#39; scanner.
Definition: manage_sql.h:203
int manage_scanner_set(const char *uuid)
Set the address of scanner to connect to.
Definition: manage_sql.c:17377
Here is the call graph for this function:

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

Definition at line 6288 of file manage_sql.c.

6289 {
6290  return OPENVASMD_SCAP_DATABASE_VERSION;
6291 }

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

Definition at line 6299 of file manage_sql.c.

References manage_scap_loaded(), and sql_string().

6300 {
6301  if (manage_scap_loaded () == 0)
6302  return -1;
6303 
6304  int number;
6305  char *version = sql_string ("SELECT value FROM scap.meta"
6306  " WHERE name = 'database_version' LIMIT 1;");
6307  if (version)
6308  {
6309  number = atoi (version);
6310  free (version);
6311  return number;
6312  }
6313  return -1;
6314 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
int manage_scap_loaded()
Check whether SCAP is available.
Definition: manage_pg.c:2659
Here is the call graph for this function:

◆ manage_scap_loaded()

int manage_scap_loaded ( )

Check whether SCAP is available.

Returns
1 if SCAP database is loaded, else 0.

Definition at line 2659 of file manage_pg.c.

References sql_database(), sql_error(), and sql_int().

Referenced by init_aggregate_iterator(), manage_attach_databases(), manage_create_sql_functions(), manage_scap_db_version(), and sql_cpe_title().

2660 {
2661  return !!sql_int ("SELECT EXISTS (SELECT * FROM information_schema.tables"
2662  " WHERE table_catalog = '%s'"
2663  " AND table_schema = 'scap'"
2664  " AND table_name = 'cves')"
2665  " ::integer;",
2666  sql_database ());
2667 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
const char * sql_database()
Return name of current database.
Definition: sql_pg.c:226
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 13084 of file manage_sql.c.

References acl_user_may(), find_alert_with_permission(), and task_id().

13085 {
13086  int ret;
13087  alert_t alert;
13088  task_t task;
13089  report_t report;
13090  result_t result;
13091  char *task_id, *report_id;
13092  time_t now;
13093  const char *now_string;
13094  gchar *clean;
13095 
13096  if (acl_user_may ("test_alert") == 0)
13097  return 99;
13098 
13099  if (find_alert_with_permission (alert_id, &alert, "test_alert"))
13100  return -1;
13101  if (alert == 0)
13102  return 1;
13103 
13104  if (alert_event (alert) == EVENT_NEW_SECINFO
13105  || alert_event (alert) == EVENT_UPDATED_SECINFO)
13106  {
13107  int ret;
13108  char *alert_event_data;
13109  gchar *type;
13110 
13111  alert_event_data = alert_data (alert, "event", "secinfo_type");
13112  type = g_strdup_printf ("%s_example", alert_event_data ?: "NVT");
13113  free (alert_event_data);
13114 
13115  if (alert_event (alert) == EVENT_NEW_SECINFO)
13116  ret = manage_alert (alert_id, "0", EVENT_NEW_SECINFO, (void*) type,
13117  script_message);
13118  else
13119  ret = manage_alert (alert_id, "0", EVENT_UPDATED_SECINFO, (void*) type,
13120  script_message);
13121 
13122  g_free (type);
13123 
13124  return ret;
13125  }
13126 
13127  task = make_task (g_strdup ("Temporary Task for Alert"),
13128  g_strdup (""),
13129  0, /* Exclude from assets. */
13130  0); /* Skip event and log. */
13131 
13132  report_id = openvas_uuid_make ();
13133  if (report_id == NULL)
13134  return -1;
13135  task_uuid (task, &task_id);
13136  report = make_report (task, report_id, TASK_STATUS_DONE);
13137  result = make_result (task, "127.0.0.1", "telnet (23/tcp)",
13138  "1.3.6.1.4.1.25623.1.0.10330", "Alarm",
13139  "A telnet server seems to be running on this port.");
13140  if (result == 0)
13141  {
13142  ret = -1;
13143  goto exit;
13144  }
13145  now = time (NULL);
13146  now_string = ctime (&now);
13147  if (strlen (now_string) == 0)
13148  {
13149  ret = -1;
13150  goto exit;
13151  }
13152  clean = g_strdup (now_string);
13153  if (clean[strlen (clean) - 1] == '\n')
13154  clean[strlen (clean) - 1] = '\0';
13155  set_task_start_time_otp (task, g_strdup (clean));
13156  set_scan_start_time_otp (report, g_strdup (clean));
13157  set_scan_host_start_time_otp (report, "127.0.0.1", clean);
13158  report_add_result (report, result);
13159  set_scan_host_end_time_otp (report, "127.0.0.1", clean);
13160  set_scan_end_time_otp (report, clean);
13161  g_free (clean);
13162  ret = manage_alert (alert_id,
13163  task_id,
13165  (void*) TASK_STATUS_DONE,
13166  script_message);
13167  exit:
13168  delete_task (task, 1);
13169  free (task_id);
13170  free (report_id);
13171  return ret;
13172 }
void report_add_result(report_t, result_t)
char * alert_data(alert_t alert, const char *type, const char *name)
Return data associated with an alert.
Definition: manage_sql.c:8810
void set_scan_host_start_time_otp(report_t, const char *, const char *)
long long int alert_t
Definition: manage.h:280
int delete_task(task_t, int)
long long int result_t
Definition: manage.h:287
void set_scan_start_time_otp(report_t, const char *)
void set_scan_host_end_time_otp(report_t, const char *, const char *)
result_t make_result(task_t, const char *, const char *, const char *, const char *, const char *)
long long int report_t
Definition: manage.h:288
void set_task_start_time_otp(task_t task, char *time)
Set the start time of a task.
Definition: manage_sql.c:18524
task_t make_task(char *, char *, int, int)
int task_uuid(task_t task, char **id)
Return the UUID of a task.
Definition: manage_sql.c:17885
gboolean find_alert_with_permission(const char *uuid, alert_t *alert, const char *permission)
Find a alert for a specific permission, given a UUID.
Definition: manage_sql.c:6983
report_t make_report(task_t, const char *, task_status_t)
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
void set_scan_end_time_otp(report_t, const char *)
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
Definition: manage_acl.c:56
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.
Definition: manage_sql.c:12984
long long int task_t
Definition: manage.h:286
Here is the call graph for this function:

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

Definition at line 4957 of file manage_sql.c.

References LOCATION_TRASH, and resource_name().

4958 {
4959  return resource_name (type, uuid, LOCATION_TRASH, name);
4960 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int resource_name(const char *type, const char *uuid, int location, char **name)
Get the name of a resource.
Definition: manage_sql.c:4852
Here is the call graph for this function:

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

Definition at line 14475 of file manage_sql.c.

References sql_begin_immediate_giveup(), sql_int(), and sql_schema().

Referenced by manage_schedule().

14476 {
14477  int ret;
14478 
14479  ret = sql_begin_immediate_giveup ();
14480  if (ret)
14481  return ret;
14482  if (sql_int ("SELECT value FROM %s.meta"
14483  " WHERE name = 'update_nvti_cache';",
14484  sql_schema ()))
14485  {
14486  update_nvti_cache ();
14487  sql ("UPDATE %s.meta SET value = 0 WHERE name = 'update_nvti_cache';",
14488  sql_schema ());
14489  }
14490  sql_commit ();
14491  return 0;
14492 }
const char * sql_schema()
Get main schema name.
Definition: sql_pg.c:103
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
int sql_begin_immediate_giveup()
Begin an immediate transaction.
Definition: sql_pg.c:639
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 17189 of file manage_sql.c.

References sql_quote(), and sql_string().

17190 {
17191  gchar *hash, *quoted_username;
17192  quoted_username = sql_quote (username);
17193  hash = sql_string ("SELECT password FROM users WHERE name = '%s';",
17194  quoted_username);
17195  g_free (quoted_username);
17196  return hash;
17197 }
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ message_type_threat()

const char* message_type_threat ( const char *  type)

Get the threat of a message type.

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

Definition at line 553 of file manage.c.

554 {
555  if (strcasecmp (type, "Alarm") == 0)
556  return "Alarm";
557  if (strcasecmp (type, "Security Hole") == 0)
558  return "High";
559  if (strcasecmp (type, "Security Warning") == 0)
560  return "Medium";
561  if (strcasecmp (type, "Security Note") == 0)
562  return "Low";
563  if (strcasecmp (type, "Log Message") == 0)
564  return "Log";
565  if (strcasecmp (type, "Debug Message") == 0)
566  return "Debug";
567  if (strcasecmp (type, "Error Message") == 0)
568  return "Error";
569  if (strcasecmp (type, "False Positive") == 0)
570  return "False Positive";
571  return NULL;
572 }

◆ modify_alert()

int modify_alert ( const char *  alert_id,
const char *  name,
const char *  comment,
const char *  filter_id,
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]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, 50 invalid TippingPoint credential, 51 invalid TippingPoint hostname, 52 invalid TippingPoint certificate, 53 invalid TippingPoint TLS workaround setting. 99 permission denied, -1 internal error.

Definition at line 7894 of file manage_sql.c.

7898 {
7899  int index, ret;
7900  gchar *quoted_name, *quoted_comment, *item;
7901  alert_t alert;
7902  filter_t filter;
7903 
7904  if (alert_id == NULL)
7905  return 3;
7906 
7908 
7909  assert (current_credentials.uuid);
7910 
7911  if (acl_user_may ("modify_alert") == 0)
7912  {
7913  sql_rollback ();
7914  return 99;
7915  }
7916 
7917  ret = check_alert_params (event, condition, method);
7918  if (ret)
7919  {
7920  sql_rollback ();
7921  return ret;
7922  }
7923 
7924  alert = 0;
7925  if (find_alert_with_permission (alert_id, &alert, "modify_alert"))
7926  {
7927  sql_rollback ();
7928  return -1;
7929  }
7930 
7931  if (alert == 0)
7932  {
7933  sql_rollback ();
7934  return 1;
7935  }
7936 
7937  /* Check whether an alert with the same name exists already. */
7938  if (resource_with_name_exists (name, "alert", alert))
7939  {
7940  sql_rollback ();
7941  return 2;
7942  }
7943 
7944  /* Check filter. */
7945  filter = 0;
7946  if (event != EVENT_NEW_SECINFO && event != EVENT_UPDATED_SECINFO && filter_id
7947  && strcmp (filter_id, "0"))
7948  {
7949  char *type;
7950 
7951  if (find_filter_with_permission (filter_id, &filter, "get_filters"))
7952  {
7953  sql_rollback ();
7954  return -1;
7955  }
7956 
7957  if (filter == 0)
7958  {
7959  sql_rollback ();
7960  return 4;
7961  }
7962 
7963  /* Filter type must be report if specified. */
7964 
7965  type = sql_string ("SELECT type FROM filters WHERE id = %llu;",
7966  filter);
7967  if (type && strcasecmp (type, "result"))
7968  {
7969  free (type);
7970  sql_rollback ();
7971  return 5;
7972  }
7973  free (type);
7974  }
7975 
7976  quoted_name = sql_quote (name ?: "");
7977  quoted_comment = sql_quote (comment ? comment : "");
7978 
7979  sql ("UPDATE alerts SET"
7980  " name = '%s',"
7981  " comment = '%s',"
7982  " filter = %llu,"
7983  " modification_time = m_now ()"
7984  " WHERE id = %llu;",
7985  quoted_name,
7986  quoted_comment,
7987  filter,
7988  alert);
7989 
7990  g_free (quoted_comment);
7991  g_free (quoted_name);
7992 
7993  /* Modify alert event */
7994  if (event != EVENT_ERROR)
7995  {
7996  sql ("UPDATE alerts set event = %i WHERE id = %llu", event, alert);
7997  sql ("DELETE FROM alert_event_data WHERE alert = %llu", alert);
7998  index = 0;
7999  while ((item = (gchar*) g_ptr_array_index (event_data, index++)))
8000  {
8001  int validation_result;
8002  gchar *name = sql_quote (item);
8003  gchar *data = sql_quote (item + strlen (item) + 1);
8004 
8005  validation_result = validate_alert_event_data (name, data, event);
8006 
8007  if (validation_result)
8008  {
8009  g_free (name);
8010  g_free (data);
8011  sql_rollback ();
8012 
8013  switch (validation_result)
8014  {
8015  case 1:
8016  return 31;
8017  case 2:
8018  return 32;
8019  default:
8020  return -1;
8021  }
8022  }
8023 
8024  sql ("INSERT INTO alert_event_data (alert, name, data)"
8025  " VALUES (%llu, '%s', '%s');",
8026  alert,
8027  name,
8028  data);
8029  g_free (name);
8030  g_free (data);
8031  }
8032  }
8033 
8034  /* Modify alert condition */
8035  if (condition != ALERT_CONDITION_ERROR)
8036  {
8037  sql ("UPDATE alerts set condition = %i WHERE id = %llu",
8038  condition,
8039  alert);
8040  sql ("DELETE FROM alert_condition_data WHERE alert = %llu", alert);
8041  index = 0;
8042  while ((item = (gchar*) g_ptr_array_index (condition_data, index++)))
8043  {
8044  int validation_result;
8045  gchar *name = sql_quote (item);
8046  gchar *data = sql_quote (item + strlen (item) + 1);
8047 
8048  validation_result = validate_alert_condition_data (name, data,
8049  condition);
8050 
8051  if (validation_result)
8052  {
8053  g_free (name);
8054  g_free (data);
8055  sql_rollback ();
8056 
8057  switch (validation_result)
8058  {
8059  case 1:
8060  return 7;
8061  case 2:
8062  return 8;
8063  case 3:
8064  return 11;
8065  default:
8066  return -1;
8067  }
8068  }
8069 
8070  sql ("INSERT INTO alert_condition_data (alert, name, data)"
8071  " VALUES (%llu, '%s', '%s');",
8072  alert,
8073  name,
8074  data);
8075  g_free (name);
8076  g_free (data);
8077  }
8078  }
8079 
8080  /* Modify alert method */
8081  if (method != ALERT_METHOD_ERROR)
8082  {
8083  sql ("UPDATE alerts set method = %i WHERE id = %llu", method, alert);
8084  sql ("DELETE FROM alert_method_data WHERE alert = %llu", alert);
8085  index = 0;
8086  while ((item = (gchar*) g_ptr_array_index (method_data, index++)))
8087  {
8088  int ret;
8089  gchar *name, *data;
8090 
8091  name = sql_quote (item);
8092  data = sql_quote (item + strlen (item) + 1);
8093 
8094  if (method == ALERT_METHOD_EMAIL
8095  && strcmp (name, "to_address") == 0
8096  && validate_email_list (data))
8097  {
8098  g_free (name);
8099  g_free (data);
8100  sql_rollback ();
8101  return 6;
8102  }
8103 
8104  if (method == ALERT_METHOD_EMAIL
8105  && strcmp (name, "from_address") == 0
8106  && validate_email (data))
8107  {
8108  g_free (name);
8109  g_free (data);
8110  sql_rollback ();
8111  return 6;
8112  }
8113 
8114  if (method == ALERT_METHOD_EMAIL
8115  && strcmp (name, "subject") == 0
8116  && strlen (data) > 80)
8117  {
8118  g_free (name);
8119  g_free (data);
8120  sql_rollback ();
8121  return 9;
8122  }
8123 
8124  if (method == ALERT_METHOD_EMAIL
8125  && strcmp (name, "message") == 0
8126  && strlen (data) > max_email_message_length)
8127  {
8128  g_free (name);
8129  g_free (data);
8130  sql_rollback ();
8131  return 10;
8132  }
8133 
8134  ret = validate_scp_data (method, name, &data);
8135  if (ret)
8136  {
8137  g_free (name);
8138  g_free (data);
8139  sql_rollback ();
8140  return ret;
8141  }
8142 
8143  ret = validate_send_data (method, name, &data);
8144  if (ret)
8145  {
8146  g_free (name);
8147  g_free (data);
8148  sql_rollback ();
8149  return ret;
8150  }
8151 
8152  ret = validate_smb_data (method, name, &data);
8153  if (ret)
8154  {
8155  g_free (name);
8156  g_free (data);
8157  sql_rollback ();
8158  return ret;
8159  }
8160 
8161  ret = validate_tippingpoint_data (method, name, &data);
8162  if (ret)
8163  {
8164  g_free (name);
8165  g_free (data);
8166  sql_rollback ();
8167  return ret;
8168  }
8169 
8170  sql ("INSERT INTO alert_method_data (alert, name, data)"
8171  " VALUES (%llu, '%s', '%s');",
8172  alert,
8173  name,
8174  data);
8175  g_free (name);
8176  g_free (data);
8177  }
8178  }
8179 
8180  sql_commit ();
8181 
8182  return 0;
8183 }
long long int filter_t
Definition: manage.h:281
long long int alert_t
Definition: manage.h:280
int validate_send_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the Send method.
Definition: manage_sql.c:7304
int validate_scp_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the SCP method.
Definition: manage_sql.c:7222
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
int validate_smb_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the Send method.
Definition: manage_sql.c:7368
gboolean find_alert_with_permission(const char *uuid, alert_t *alert, const char *permission)
Find a alert for a specific permission, given a UUID.
Definition: manage_sql.c:6983
gboolean find_filter_with_permission(const char *, filter_t *, const char *)
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
int acl_user_may(const char *operation)
Test whether a user may perform an operation.
Definition: manage_acl.c:56
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
int validate_tippingpoint_data(alert_method_t method, const gchar *name, gchar **data)
Validate method data for the TippingPoint method.
Definition: manage_sql.c:7435
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649

◆ omp_command_type()

gchar* omp_command_type ( const char *  name)

Get the type associated with an OMP command.

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

Definition at line 565 of file manage_sql.c.

References valid_type().

566 {
567  const char *under;
568  under = strchr (name, '_');
569  if (under && (strlen (under) > 1))
570  {
571  gchar *command;
572  under++;
573  command = g_strdup (under);
574  if (command[strlen (command) - 1] == 's')
575  command[strlen (command) - 1] = '\0';
576  if (valid_type (command))
577  return command;
578  g_free (command);
579  }
580  return NULL;
581 }
int valid_type(const char *)
Check whether a resource type name is valid.
Definition: manage_sql.c:4201
Here is the call graph for this function:

◆ parse_iso_time()

int parse_iso_time ( const char *  text_time)

Convert an ISO time into seconds since epoch.

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

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

Definition at line 875 of file manage_sql.c.

Referenced by manage_system_report(), and set_task_start_time().

876 {
877  int epoch_time;
878  struct tm tm;
879 
880  memset (&tm, 0, sizeof (struct tm));
881  tm.tm_isdst = -1;
882  if (strptime ((char*) text_time, "%FT%T%z", &tm) == NULL)
883  {
884  gchar *tz;
885 
886  memset (&tm, 0, sizeof (struct tm));
887  tm.tm_isdst = -1;
888  if (strptime ((char*) text_time, "%FT%TZ", &tm) == NULL)
889  {
890  /* Try time without timezone suffix, applying timezone of user */
891 
892  memset (&tm, 0, sizeof (struct tm));
893  tm.tm_isdst = -1;
894  if (strptime ((char*) text_time, "%FT%T", &tm) == NULL)
895  return parse_ctime (text_time);
896 
897  /* Store current TZ. */
898  tz = getenv ("TZ") ? g_strdup (getenv ("TZ")) : NULL;
899 
900  if (setenv ("TZ", current_credentials.timezone, 1) == -1)
901  {
902  g_warning ("%s: Failed to switch to timezone %s",
903  __FUNCTION__, current_credentials.timezone);
904  if (tz != NULL)
905  setenv ("TZ", tz, 1);
906  g_free (tz);
907  return 0;
908  }
909 
910  memset (&tm, 0, sizeof (struct tm));
911  tm.tm_isdst = -1;
912  if (strptime ((char*) text_time, "%FT%T", &tm) == NULL)
913  {
914  assert (0);
915  g_warning ("%s: Failed to parse time", __FUNCTION__);
916  if (tz != NULL)
917  setenv ("TZ", tz, 1);
918  g_free (tz);
919  return 0;
920  }
921  }
922  else
923  {
924  /* Time has "Z" suffix for UTC */
925 
926  /* Store current TZ. */
927  tz = getenv ("TZ") ? g_strdup (getenv ("TZ")) : NULL;
928 
929  if (setenv ("TZ", "UTC", 1) == -1)
930  {
931  g_warning ("%s: Failed to switch to UTC", __FUNCTION__);
932  if (tz != NULL)
933  setenv ("TZ", tz, 1);
934  g_free (tz);
935  return 0;
936  }
937 
938  memset (&tm, 0, sizeof (struct tm));
939  tm.tm_isdst = -1;
940  if (strptime ((char*) text_time, "%FT%TZ", &tm) == NULL)
941  {
942  assert (0);
943  g_warning ("%s: Failed to parse time", __FUNCTION__);
944  if (tz != NULL)
945  setenv ("TZ", tz, 1);
946  g_free (tz);
947  return 0;
948  }
949  }
950 
951  epoch_time = mktime (&tm);
952  if (epoch_time == -1)
953  {
954  g_warning ("%s: Failed to make time", __FUNCTION__);
955  if (tz != NULL)
956  setenv ("TZ", tz, 1);
957  g_free (tz);
958  return 0;
959  }
960 
961  /* Revert to stored TZ. */
962  if (tz)
963  {
964  if (setenv ("TZ", tz, 1) == -1)
965  {
966  g_warning ("%s: Failed to switch to original TZ", __FUNCTION__);
967  g_free (tz);
968  return 0;
969  }
970  }
971  else
972  unsetenv ("TZ");
973 
974  g_free (tz);
975  }
976  else
977  {
978  gchar *tz, *new_tz;
979  int offset_hour, offset_minute;
980  char sign;
981 
982  /* Get the timezone offset from the string. */
983 
984  if (sscanf ((char*) text_time,
985  "%*u-%*u-%*uT%*u:%*u:%*u%[-+]%d:%d",
986  &sign, &offset_hour, &offset_minute)
987  != 3)
988  {
989  /* Perhaps %z is an acronym like "CEST". Assume it's local time. */
990  epoch_time = mktime (&tm);
991  if (epoch_time == -1)
992  {
993  g_warning ("%s: Failed to make time", __FUNCTION__);
994  return 0;
995  }
996  return epoch_time;
997  }
998 
999  /* Store current TZ. */
1000 
1001  tz = getenv ("TZ") ? g_strdup (getenv ("TZ")) : NULL;
1002 
1003  /* Switch to the timezone in the time string. */
1004 
1005  new_tz = g_strdup_printf ("UTC%c%d:%d",
1006  sign == '-' ? '+' : '-',
1007  offset_hour,
1008  offset_minute);
1009  if (setenv ("TZ", new_tz, 1) == -1)
1010  {
1011  g_warning ("%s: Failed to switch to %s", __FUNCTION__, new_tz);
1012  g_free (new_tz);
1013  if (tz != NULL)
1014  setenv ("TZ", tz, 1);
1015  g_free (tz);
1016  return 0;
1017  }
1018  g_free (new_tz);
1019 
1020  /* Parse time again under the new timezone. */
1021 
1022  memset (&tm, 0, sizeof (struct tm));
1023  tm.tm_isdst = -1;
1024  if (strptime ((char*) text_time, "%FT%T%z", &tm) == NULL)
1025  {
1026  assert (0);
1027  g_warning ("%s: Failed to parse time", __FUNCTION__);
1028  if (tz != NULL)
1029  setenv ("TZ", tz, 1);
1030  g_free (tz);
1031  return 0;
1032  }
1033 
1034  epoch_time = mktime (&tm);
1035  if (epoch_time == -1)
1036  {
1037  g_warning ("%s: Failed to make time", __FUNCTION__);
1038  if (tz != NULL)
1039  setenv ("TZ", tz, 1);
1040  g_free (tz);
1041  return 0;
1042  }
1043 
1044  /* Revert to stored TZ. */
1045  if (tz)
1046  {
1047  if (setenv ("TZ", tz, 1) == -1)
1048  {
1049  g_warning ("%s: Failed to switch to original TZ", __FUNCTION__);
1050  g_free (tz);
1051  return 0;
1052  }
1053  }
1054  else
1055  unsetenv ("TZ");
1056 
1057  g_free (tz);
1058  }
1059 
1060  return epoch_time;
1061 }
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
Here is the caller graph for this function:

◆ parse_time()

int parse_time ( const gchar *  string,
int *  seconds 
)

Try convert an OTP NVT tag time string into epoch time.

Parameters
[in]stringString.
[out]secondsTime as seconds since the epoch.
Returns
-1 failed to parse time, -2 failed to make time, -3 failed to parse timezone offset, 0 success.

Definition at line 1308 of file manage_sql.c.

Referenced by sql_parse_time().

1309 {
1310  int epoch_time, offset;
1311  struct tm tm;
1312 
1313  if ((strcmp ((char*) string, "") == 0)
1314  || (strcmp ((char*) string, "$Date: $") == 0)
1315  || (strcmp ((char*) string, "$Date$") == 0)
1316  || (strcmp ((char*) string, "$Date:$") == 0)
1317  || (strcmp ((char*) string, "$Date") == 0)
1318  || (strcmp ((char*) string, "$$") == 0))
1319  {
1320  if (seconds)
1321  *seconds = 0;
1322  return 0;
1323  }
1324 
1325  /* Parse the time. */
1326 
1327  /* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */
1328  /* $Date: 2012-02-17 16:05:26 +0100 (Fr, 17. Feb 2012) $ */
1329  /* $Date: Fri, 11 Nov 2011 14:42:28 +0100 $ */
1330  memset (&tm, 0, sizeof (struct tm));
1331  if (strptime ((char*) string, "%F %T %z", &tm) == NULL)
1332  {
1333  memset (&tm, 0, sizeof (struct tm));
1334  if (strptime ((char*) string, "$Date: %F %T %z", &tm) == NULL)
1335  {
1336  memset (&tm, 0, sizeof (struct tm));
1337  if (strptime ((char*) string, "%a %b %d %T %Y %z", &tm) == NULL)
1338  {
1339  memset (&tm, 0, sizeof (struct tm));
1340  if (strptime ((char*) string, "$Date: %a, %d %b %Y %T %z", &tm)
1341  == NULL)
1342  {
1343  memset (&tm, 0, sizeof (struct tm));
1344  if (strptime ((char*) string, "$Date: %a %b %d %T %Y %z", &tm)
1345  == NULL)
1346  {
1347  g_warning ("%s: Failed to parse time: %s",
1348  __FUNCTION__, string);
1349  return -1;
1350  }
1351  }
1352  }
1353  }
1354  }
1355  epoch_time = mktime (&tm);
1356  if (epoch_time == -1)
1357  {
1358  g_warning ("%s: Failed to make time: %s", __FUNCTION__, string);
1359  return -2;
1360  }
1361 
1362  /* Get the timezone offset from the string. */
1363 
1364  if ((sscanf ((char*) string, "%*u-%*u-%*u %*u:%*u:%*u %d%*[^]]", &offset)
1365  != 1)
1366  && (sscanf ((char*) string, "$Date: %*u-%*u-%*u %*u:%*u:%*u %d%*[^]]",
1367  &offset)
1368  != 1)
1369  && (sscanf ((char*) string, "%*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
1370  &offset)
1371  != 1)
1372  && (sscanf ((char*) string,
1373  "$Date: %*s %*s %*s %*u %*u:%*u:%*u %d%*[^]]",
1374  &offset)
1375  != 1)
1376  && (sscanf ((char*) string, "$Date: %*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
1377  &offset)
1378  != 1))
1379  {
1380  g_warning ("%s: Failed to parse timezone offset: %s", __FUNCTION__,
1381  string);
1382  return -3;
1383  }
1384 
1385  /* Use the offset to convert to UTC. */
1386 
1387  if (offset < 0)
1388  {
1389  epoch_time += ((-offset) / 100) * 60 * 60;
1390  epoch_time += ((-offset) % 100) * 60;
1391  }
1392  else if (offset > 0)
1393  {
1394  epoch_time -= (offset / 100) * 60 * 60;
1395  epoch_time -= (offset % 100) * 60;
1396  }
1397 
1398  if (seconds)
1399  *seconds = epoch_time;
1400  return 0;
1401 }
Here is the caller graph for this function:

◆ permission_subject()

resource_t permission_subject ( permission_t  )

◆ permission_subject_type()

char* permission_subject_type ( permission_t  )

◆ permissions_set_locations()

void permissions_set_locations ( const char *  ,
resource_t  ,
resource_t  ,
int   
)

◆ permissions_set_orphans()

void permissions_set_orphans ( const char *  ,
resource_t  ,
int   
)

◆ permissions_set_subjects()

void permissions_set_subjects ( const char *  ,
resource_t  ,
resource_t  ,
int   
)

◆ port_name_formatted()

gchar* port_name_formatted ( const char *  field)

Returns formatted port number, protocol and iana name from.

field in "number/proto" form.

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

Definition at line 6378 of file manage_sql.c.

References manage_port_name().

6379 {
6380  int number;
6381  char *protocol, *port_name;
6382 
6383  if (field == NULL)
6384  return NULL;
6385 
6386  protocol = g_newa (char, strlen (field));
6387 
6388  if (sscanf (field, "%i/%s",
6389  &number, protocol)
6390  != 2)
6391  return g_strdup (field);
6392 
6393  port_name = manage_port_name (number, protocol);
6394  if (port_name)
6395  {
6396  char *formatted = g_strdup_printf
6397  ("%i/%s (IANA: %s)",
6398  number,
6399  protocol,
6400  port_name);
6401  free (port_name);
6402  return formatted;
6403  }
6404  else
6405  return g_strdup (field);
6406 }
char * manage_port_name(int number, const char *protocol)
Returns associated name for a tcp/ip port.
Definition: manage_sql.c:6359
Here is the call graph for this function:

◆ predefined_report_format_dir()

gchar* predefined_report_format_dir ( const gchar *  uuid)

Get the directory of a report format.

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

Definition at line 7077 of file manage.c.

Referenced by init_report_format_file_iterator().

7078 {
7079  return g_build_filename (OPENVAS_DATA_DIR,
7080  "openvasmd",
7081  "report_formats",
7082  uuid,
7083  NULL);
7084 }
Here is the caller graph for this function:

◆ refresh_nvt_cves()

void refresh_nvt_cves ( )

Refresh nvt_cves table.

Caller must organise transaction.

Definition at line 15545 of file manage_sql.c.

References cleanup_iterator(), init_iterator(), iterator_int64(), iterator_string(), next(), sql(), sql_insert(), and sql_is_sqlite3().

15546 {
15547  iterator_t nvts;
15548 
15549  sql ("DELETE FROM nvt_cves;");
15550 
15551  init_iterator (&nvts, "SELECT id, oid, cve FROM nvts;");
15552  while (next (&nvts))
15553  {
15554  gchar **split, **point;
15555 
15556  split = g_strsplit_set (iterator_string (&nvts, 2), " ,", 0);
15557 
15558  point = split;
15559  while (*point)
15560  {
15561  g_strstrip (*point);
15562  if (strlen (*point))
15563  {
15564  gchar *quoted_cve, *quoted_oid;
15565 
15566  quoted_cve = sql_insert (*point);
15567  quoted_oid = sql_insert (iterator_string (&nvts, 1));
15568  sql ("INSERT INTO nvt_cves (nvt, oid, cve_name)"
15569  " VALUES (%llu, %s, %s);",
15570  iterator_int64 (&nvts, 0),
15571  quoted_oid,
15572  quoted_cve);
15573  g_free (quoted_cve);
15574  g_free (quoted_oid);
15575  }
15576  point++;
15577  }
15578  g_strfreev (split);
15579  }
15580  cleanup_iterator (&nvts);
15581 
15582  if (sql_is_sqlite3 ())
15583  sql ("REINDEX nvt_cves_by_oid;");
15584 }
int sql_is_sqlite3()
Get whether backend is SQLite3.
Definition: sql_pg.c:92
A generic SQL iterator.
Definition: iterator.h:52
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
gchar * sql_insert(const char *string)
Get the SQL insert expression for a string.
Definition: sql.c:136
gboolean next(iterator_t *)
Increment an iterator.
Definition: sql.c:689
void init_iterator(iterator_t *iterator, const char *sql,...)
Initialise an iterator.
Definition: sql.c:577
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
Definition: sql.c:637
Here is the call graph for this function:

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

Definition at line 14347 of file manage_sql.c.

References cleanup_manage_process(), init_manage_process(), and task_db_name.

Referenced by manage_schedule().

14348 {
14349  cleanup_manage_process (FALSE);
14351 }
void init_manage_process(int update_nvt_cache, const gchar *database)
Initialize the manage library for a process.
Definition: manage_sql.c:14303
gchar * task_db_name
Name of the database file.
Definition: manage_sql.c:403
void cleanup_manage_process(gboolean cleanup)
Cleanup the manage library.
Definition: manage_sql.c:17128
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 17704 of file manage_sql.c.

References get_data_t::filter, SEVERITY_ERROR, get_data_t::trash, and type_owned().

17705 {
17706  static const char *filter_columns[] = { "owner", NULL };
17707  static column_t select_columns[] = {{ "owner", NULL }, { NULL, NULL }};
17708  get_data_t count_get;
17709 
17710  const char *extra_where;
17711 
17712  memset (&count_get, '\0', sizeof (count_get));
17713  count_get.trash = get->trash;
17714  if (type_owned (type))
17715  count_get.filter = "rows=-1 first=1 permission=any owner=any";
17716  else
17717  count_get.filter = "rows=-1 first=1 permission=any";
17718 
17719  if (strcmp (type, "task") == 0)
17720  {
17721  extra_where = (get->trash
17722  ? " AND hidden = 2"
17723  : " AND hidden = 0");
17724  }
17725  else if (strcmp (type, "report") == 0)
17726  {
17727  extra_where = " AND (SELECT hidden FROM tasks"
17728  " WHERE tasks.id = task)"
17729  " = 0";
17730  }
17731  else if (strcmp (type, "result") == 0)
17732  {
17733  extra_where = " AND (severity != " G_STRINGIFY (SEVERITY_ERROR) ")"
17734  " AND (SELECT hidden FROM tasks"
17735  " WHERE tasks.id = task)"
17736  " = 0";
17737  }
17738  else
17739  extra_where = NULL;
17740 
17741  return count (get->subtype ? get->subtype : type,
17742  &count_get,
17743  type_owned (type) ? select_columns : NULL,
17744  type_owned (type) ? select_columns : NULL,
17745  type_owned (type) ? filter_columns : NULL,
17746  0, NULL,
17747  extra_where,
17748  type_owned (type));
17749 }
int trash
Boolean. Whether to return from trashcan.
Definition: manage.h:318
gchar * subtype
Subtype, or NULL.
Definition: manage.h:320
Command data for a get command.
Definition: manage.h:310
Iterator column.
Definition: manage_sql.c:1512
#define SEVERITY_ERROR
Definition: manage_utils.h:38
int type_owned(const char *type)
Check whether a resource type has an owner.
Definition: manage_sql.c:4376
char * filter
Filter term.
Definition: manage.h:314
Here is the call graph for this function:

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

Definition at line 4826 of file manage_sql.c.

References LOCATION_TABLE, sql_int(), and valid_db_resource_type().

Referenced by sql_resource_exists().

4827 {
4828  if (valid_db_resource_type (type) == 0)
4829  return -1;
4830 
4831  if (location == LOCATION_TABLE)
4832  return sql_int ("SELECT EXISTS (SELECT id FROM %ss WHERE id = %llu);",
4833  type,
4834  resource);
4835  return sql_int ("SELECT EXISTS (SELECT id FROM %ss%s WHERE id = %llu);",
4836  type,
4837  strcmp (type, "task") ? "_trash" : "",
4838  resource);
4839 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
int valid_db_resource_type(const char *)
Check whether a resource type table name is valid.
Definition: manage_utils.c:504
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resource_id_exists()

int resource_id_exists ( const char *  type,
const char *  id 
)

Test whether a resource of the given type and unique ID exists.

Parameters
[in]typeType.
[in]idUnique ID.
Returns
1 if the resource exists, 0 otherwise.

Definition at line 17760 of file manage_sql.c.

References sql_int().

17761 {
17762  return !!sql_int ("SELECT count(*)"
17763  " FROM %ss"
17764  " WHERE uuid='%s'"
17765  " %s;",
17766  type,
17767  id,
17768  (strcmp (type, "task") == 0) ? "AND hidden=0" : "");
17769 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 4852 of file manage_sql.c.

References LOCATION_TABLE, sql_string(), and valid_db_resource_type().

Referenced by manage_resource_name(), and manage_trash_resource_name().

4853 {
4854  if (valid_db_resource_type (type) == 0)
4855  return 1;
4856 
4857  if (strcasecmp (type, "note") == 0)
4858  *name = sql_string ("SELECT 'Note for: '"
4859  " || (SELECT name"
4860  " FROM nvts"
4861  " WHERE nvts.uuid = notes%s.nvt)"
4862  " FROM notes%s"
4863  " WHERE uuid = '%s';",
4864  location == LOCATION_TABLE ? "" : "_trash",
4865  location == LOCATION_TABLE ? "" : "_trash",
4866  uuid);
4867  else if (strcasecmp (type, "override") == 0)
4868  *name = sql_string ("SELECT 'Override for: '"
4869  " || (SELECT name"
4870  " FROM nvts"
4871  " WHERE nvts.uuid = overrides%s.nvt)"
4872  " FROM overrides%s"
4873  " WHERE uuid = '%s';",
4874  location == LOCATION_TABLE ? "" : "_trash",
4875  location == LOCATION_TABLE ? "" : "_trash",
4876  uuid);
4877  else if (strcasecmp (type, "report") == 0)
4878  *name = sql_string ("SELECT (SELECT name FROM tasks WHERE id = task)"
4879  " || ' - '"
4880  " || (SELECT"
4881  " CASE (SELECT end_time FROM tasks"
4882  " WHERE id = task)"
4883  " WHEN 0 THEN 'N/A'"
4884  " ELSE (SELECT iso_time (end_time)"
4885  " FROM tasks WHERE id = task)"
4886  " END)"
4887  " FROM reports"
4888  " WHERE uuid = '%s';",
4889  uuid);
4890  else if (strcasecmp (type, "result") == 0)
4891  *name = sql_string ("SELECT (SELECT name FROM tasks WHERE id = task)"
4892  " || ' - '"
4893  " || (SELECT name FROM nvts WHERE oid = nvt)"
4894  " || ' - '"
4895  " || (SELECT"
4896  " CASE (SELECT end_time FROM tasks"
4897  " WHERE id = task)"
4898  " WHEN 0 THEN 'N/A'"
4899  " ELSE (SELECT iso_time (end_time)"
4900  " FROM tasks WHERE id = task)"
4901  " END)"
4902  " FROM results"
4903  " WHERE uuid = '%s';",
4904  uuid);
4905  else if (location == LOCATION_TABLE)
4906  *name = sql_string ("SELECT name"
4907  " FROM %ss"
4908  " WHERE uuid = '%s';",
4909  type,
4910  uuid);
4911  else if ((strcmp (type, "nvt"))
4912  && (strcmp (type, "cpe"))
4913  && (strcmp (type, "cve"))
4914  && (strcmp (type, "ovaldef"))
4915  && (strcmp (type, "cert_bund_adv"))
4916  && (strcmp (type, "dfn_cert_adv"))
4917  && (strcmp (type, "report"))
4918  && (strcmp (type, "result"))
4919  && (strcmp (type, "user")))
4920  *name = sql_string ("SELECT name"
4921  " FROM %ss%s"
4922  " WHERE uuid = '%s';",
4923  type,
4924  strcmp (type, "task") ? "_trash" : "",
4925  uuid);
4926  else
4927  *name = NULL;
4928 
4929  return 0;
4930 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
int valid_db_resource_type(const char *)
Check whether a resource type table name is valid.
Definition: manage_utils.c:504
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 4971 of file manage_sql.c.

References sql_string(), and valid_db_resource_type().

4972 {
4973  assert (valid_db_resource_type (type));
4974 
4975  return sql_string ("SELECT uuid FROM %ss WHERE id = %llu;",
4976  type,
4977  resource);
4978 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
int valid_db_resource_type(const char *)
Check whether a resource type table name is valid.
Definition: manage_utils.c:504
Here is the call graph for this function:

◆ role_is_predefined()

int role_is_predefined ( role_t  )

◆ role_is_predefined_id()

int role_is_predefined_id ( const char *  )

◆ set_certs()

int set_certs ( const char *  ca_pub,
const char *  key_pub,
const char *  key_priv 
)

Initialise OpenVAS scanner variables, checking for defaults.

Parameters
[in]ca_pubCA Certificate.
[in]key_pubScanner Certificate.
[in]key_privScanner private key.
Returns
0 success, 1 both default CA cert setting and ca_pub were NULL.

Definition at line 4312 of file manage.c.

References manage_default_ca_cert(), and openvas_scanner_set_certs().

Referenced by manage_scanner_set().

4313 {
4314  const char *fallback;
4315 
4316  if (ca_pub == NULL)
4317  fallback = manage_default_ca_cert ();
4318  else
4319  fallback = NULL;
4320 
4321  openvas_scanner_set_certs (fallback ? fallback : ca_pub, key_pub, key_priv);
4322 
4323  if (ca_pub || fallback)
4324  return 0;
4325  return 1;
4326 }
void openvas_scanner_set_certs(const char *ca_pub, const char *key_pub, const char *key_priv)
Set the scanner&#39;s CA Certificate, and public/private key pair.
Definition: scanner.c:853
char * manage_default_ca_cert()
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 6416 of file manage_sql.c.

References sql(), and sql_schema().

Referenced by migrate_0_to_1(), migrate_100_to_101(), migrate_101_to_102(), migrate_102_to_103(), migrate_103_to_104(), migrate_104_to_105(), migrate_105_to_106(), migrate_106_to_107(), migrate_107_to_108(), migrate_108_to_109(), migrate_109_to_110(), migrate_10_to_11(), migrate_110_to_111(), migrate_111_to_112(), migrate_112_to_113(), migrate_113_to_114(), migrate_114_to_115(), migrate_115_to_116(), migrate_116_to_117(), migrate_117_to_118(), migrate_118_to_119(), migrate_119_to_120(), migrate_11_to_12(), migrate_120_to_121(), migrate_121_to_122(), migrate_122_to_123(), migrate_123_to_124(), migrate_124_to_125(), migrate_125_to_126(), migrate_126_to_127(), migrate_127_to_128(), migrate_128_to_129(), migrate_129_to_130(), migrate_12_to_13(), migrate_130_to_131(), migrate_131_to_132(), migrate_132_to_133(), migrate_133_to_134(), migrate_134_to_135(), migrate_135_to_136(), migrate_136_to_137(), migrate_137_to_138(), migrate_138_to_139(), migrate_139_to_140(), migrate_13_to_14(), migrate_140_to_141(), migrate_141_to_142(), migrate_142_to_143(), migrate_143_to_144(), migrate_144_to_145(), migrate_145_to_146(), migrate_146_to_147(), migrate_147_to_148(), migrate_148_to_149(), migrate_149_to_150(), migrate_14_to_15(), migrate_150_to_151(), migrate_151_to_152(), migrate_152_to_153(), migrate_153_to_154(), migrate_154_to_155(), migrate_155_to_156(), migrate_156_to_157(), migrate_157_to_158(), migrate_158_to_159(), migrate_159_to_160(), migrate_15_to_16(), migrate_160_to_161(), migrate_161_to_162(), migrate_162_to_163(), migrate_163_to_164(), migrate_164_to_165(), migrate_165_to_166(), migrate_167_to_168(), migrate_16_to_17(), migrate_170_to_171(), migrate_171_to_172(), migrate_172_to_173(), migrate_173_to_174(), migrate_174_to_175(), migrate_175_to_176(), migrate_176_to_177(), migrate_177_to_178(), migrate_178_to_179(), migrate_179_to_180(), migrate_17_to_18(), migrate_180_to_181(), migrate_181_to_182(), migrate_182_to_183(), migrate_183_to_184(), migrate_18_to_19(), migrate_19_to_20(), migrate_1_to_2(), migrate_20_to_21(), migrate_21_to_22(), migrate_22_to_23(), migrate_23_to_24(), migrate_25_to_26(), migrate_26_to_27(), migrate_27_to_28(), migrate_28_to_29(), migrate_29_to_30(), migrate_2_to_3(), migrate_30_to_31(), migrate_31_to_32(), migrate_32_to_33(), migrate_33_to_34(), migrate_34_to_35(), migrate_35_to_36(), migrate_36_to_37(), migrate_37_to_38(), migrate_38_to_39(), migrate_39_to_40(), migrate_3_to_4(), migrate_40_to_41(), migrate_41_to_42(), migrate_42_to_43(), migrate_43_to_44(), migrate_44_to_45(), migrate_45_to_46(), migrate_46_to_47(), migrate_47_to_48(), migrate_48_to_49(), migrate_49_to_50(), migrate_50_to_51(), migrate_51_to_52(), migrate_52_to_53(), migrate_53_to_54(), migrate_54_to_55(), migrate_55_to_56(), migrate_56_to_57(), migrate_57_to_58(), migrate_58_to_59(), migrate_59_to_60(), migrate_60_to_61(), migrate_61_to_62(), migrate_62_to_63(), migrate_63_to_64(), migrate_64_to_65(), migrate_65_to_66(), migrate_66_to_67(), migrate_67_to_68(), migrate_68_to_69(), migrate_69_to_70(), migrate_6_to_7(), migrate_70_to_71(), migrate_71_to_72(), migrate_72_to_73(), migrate_73_to_74(), migrate_74_to_75(), migrate_75_to_76(), migrate_76_to_77(), migrate_77_to_78(), migrate_78_to_79(), migrate_7_to_8(), migrate_80_to_81(), migrate_81_to_82(), migrate_82_to_83(), migrate_83_to_84(), migrate_84_to_85(), migrate_85_to_86(), migrate_86_to_87(), migrate_87_to_88(), migrate_88_to_89(), migrate_89_to_90(), migrate_8_to_9(), migrate_90_to_91(), migrate_91_to_92(), migrate_92_to_93(), migrate_93_to_94(), migrate_94_to_95(), migrate_95_to_96(), migrate_96_to_97(), migrate_97_to_98(), migrate_98_to_99(), migrate_99_to_100(), and migrate_9_to_10().

6417 {
6418  sql ("DELETE FROM %s.meta WHERE name = 'database_version';",
6419  sql_schema ());
6420  sql ("INSERT INTO %s.meta (name, value)"
6421  " VALUES ('database_version', '%i');",
6422  sql_schema (),
6423  version);
6424 }
const char * sql_schema()
Get main schema name.
Definition: sql_pg.c:103
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_password()

int set_password ( const gchar *  ,
const gchar *  ,
const gchar *  ,
gchar **   
)

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

Definition at line 18252 of file manage_sql.c.

References authenticate_allow_all, and sql().

18253 {
18254  if (authenticate_allow_all == 1)
18255  /* The task was scheduled. */
18256  sql ("UPDATE reports SET flags = 1 WHERE id = %llu;",
18257  report);
18258  else
18259  sql ("UPDATE reports SET flags = 0 WHERE id = %llu;",
18260  report);
18261 }
int authenticate_allow_all
Flag to force authentication to succeed.
Definition: manage_sql.c:120
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_task_alerts()

int set_task_alerts ( task_t  task,
array_t *  alerts,
gchar **  alert_id_return 
)

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.

Definition at line 18674 of file manage_sql.c.

References find_alert_with_permission(), LOCATION_TABLE, sql(), sql_begin_immediate(), sql_commit(), and sql_rollback().

18675 {
18676  alert_t alert = 0;
18677  guint index;
18678 
18680 
18681  sql ("DELETE FROM task_alerts where task = %llu;", task);
18682 
18683  index = alerts->len;
18684  while (index--)
18685  {
18686  gchar *alert_id;
18687 
18688  alert_id = (gchar*) g_ptr_array_index (alerts, index);
18689  if (strcmp (alert_id, "0") == 0)
18690  continue;
18691 
18692  if (find_alert_with_permission (alert_id, &alert, "get_alerts"))
18693  {
18694  sql_rollback ();
18695  return -1;
18696  }
18697 
18698  if (alert == 0)
18699  {
18700  sql_rollback ();
18701  if (alert_id_return) *alert_id_return = alert_id;
18702  return 1;
18703  }
18704 
18705  sql ("INSERT INTO task_alerts (task, alert, alert_location)"
18706  " VALUES (%llu, %llu, " G_STRINGIFY (LOCATION_TABLE) ");",
18707  task,
18708  alert);
18709  }
18710 
18711  sql_commit ();
18712  return 0;
18713 }
long long int alert_t
Definition: manage.h:280
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gboolean find_alert_with_permission(const char *uuid, alert_t *alert, const char *permission)
Find a alert for a specific permission, given a UUID.
Definition: manage_sql.c:6983
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

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

Definition at line 18722 of file manage_sql.c.

References sql().

18723 {
18724  sql ("UPDATE tasks SET alterable = %i WHERE id = %llu;",
18725  alterable,
18726  task);
18727 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_task_config()

void set_task_config ( task_t  task,
config_t  config 
)

Set the config of a task.

Parameters
[in]taskTask.
[in]configConfig.

Definition at line 18095 of file manage_sql.c.

References sql().

18096 {
18097  sql ("UPDATE tasks SET config = %llu, modification_time = m_now ()"
18098  " WHERE id = %llu;",
18099  config,
18100  task);
18101 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

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

Definition at line 18739 of file manage_sql.c.

References current_credentials, find_group(), LOCATION_TABLE, sql(), sql_begin_immediate(), sql_commit(), and sql_rollback().

18740 {
18741  group_t group = 0;
18742  guint index;
18743 
18745 
18746  sql ("DELETE FROM permissions"
18747  " WHERE resource_type = 'task'"
18748  " AND resource = %llu"
18749  " AND subject_type = 'group'"
18750  " AND name = 'get';",
18751  task);
18752 
18753  index = 0;
18754  while (index < groups->len)
18755  {
18756  gchar *group_id;
18757 
18758  group_id = (gchar*) g_ptr_array_index (groups, index);
18759  if (strcmp (group_id, "0") == 0)
18760  {
18761  index++;
18762  continue;
18763  }
18764 
18765  if (find_group (group_id, &group))
18766  {
18767  sql_rollback ();
18768  return -1;
18769  }
18770 
18771  if (group == 0)
18772  {
18773  sql_rollback ();
18774  if (group_id_return) *group_id_return = group_id;
18775  return 1;
18776  }
18777 
18778  sql ("INSERT INTO permissions"
18779  " (uuid, owner, name, comment, resource_type, resource,"
18780  " resource_uuid, resource_location, subject_type, subject,"
18781  " subject_location, creation_time, modification_time)"
18782  " VALUES"
18783  " (make_uuid (),"
18784  " (SELECT id FROM users WHERE users.uuid = '%s'),"
18785  " 'get_tasks', '', 'task', %llu,"
18786  " (SELECT uuid FROM tasks WHERE tasks.id = %llu),"
18787  " " G_STRINGIFY (LOCATION_TABLE) ", 'group', %llu,"
18788  " " G_STRINGIFY (LOCATION_TABLE) ", m_now (), m_now ());",
18789  current_credentials.uuid, task, task, group);
18790 
18791  index++;
18792  }
18793 
18794  sql_commit ();
18795  return 0;
18796 }
void sql_rollback()
Roll a transaction back.
Definition: sql_pg.c:658
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
long long int group_t
Definition: manage.h:282
gboolean find_group(const char *, group_t *)
void sql_begin_immediate()
Begin an immediate transaction.
Definition: sql_pg.c:627
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
#define LOCATION_TABLE
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:81
Here is the call graph for this function:

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

Definition at line 18152 of file manage_sql.c.

References sql(), and sql_quote().

18153 {
18154  char *quoted_ordering = sql_quote (ordering ?: "");
18155  sql ("UPDATE tasks SET hosts_ordering = '%s', modification_time = m_now ()"
18156  " WHERE id = %llu;", quoted_ordering, task);
18157  g_free (quoted_ordering);
18158 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
Here is the call graph for this function:

◆ 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.
Todo:
Similar to validate_user in openvas-administrator.

Definition at line 19148 of file manage_sql.c.

References current_credentials, sql(), sql_begin_immediate(), sql_rollback(), and user_exists().

Here is the call graph for this function:

◆ set_task_requested()

int set_task_requested ( task_t  task,
task_status_t status 
)

Atomically set the run state of a task to requested.

Parameters
[in]taskTask.
[out]statusOld run status of task.
Returns
0 success, 1 task is active already.

Definition at line 18336 of file manage_sql.c.

References set_task_run_status(), sql_begin_exclusive(), sql_commit(), task_run_status(), TASK_STATUS_DELETE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_WAITING, TASK_STATUS_DELETE_WAITING, TASK_STATUS_REQUESTED, TASK_STATUS_RUNNING, TASK_STATUS_STOP_REQUESTED, TASK_STATUS_STOP_REQUESTED_GIVEUP, and TASK_STATUS_STOP_WAITING.

18337 {
18338  task_status_t run_status;
18339 
18341 
18342  run_status = task_run_status (task);
18343  if (run_status == TASK_STATUS_REQUESTED
18344  || run_status == TASK_STATUS_RUNNING
18345  || run_status == TASK_STATUS_STOP_REQUESTED
18346  || run_status == TASK_STATUS_STOP_REQUESTED_GIVEUP
18347  || run_status == TASK_STATUS_STOP_WAITING
18348  || run_status == TASK_STATUS_DELETE_REQUESTED
18349  || run_status == TASK_STATUS_DELETE_ULTIMATE_REQUESTED
18350  || run_status == TASK_STATUS_DELETE_ULTIMATE_WAITING
18351  || run_status == TASK_STATUS_DELETE_WAITING)
18352  {
18353  sql_commit ();
18354  *status = run_status;
18355  return 1;
18356  }
18357 
18359 
18360  sql_commit ();
18361 
18362  *status = run_status;
18363  return 0;
18364 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
void sql_begin_exclusive()
Begin an exclusive transaction.
Definition: sql_pg.c:598
task_status_t task_run_status(task_t task)
Return the run state of a task.
Definition: manage_sql.c:18238
void sql_commit()
Commit a transaction.
Definition: sql_pg.c:649
void set_task_run_status(task_t task, task_status_t status)
Set the run state of a task.
Definition: manage_sql.c:18307
Here is the call graph for this function:

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

Definition at line 18307 of file manage_sql.c.

Referenced by manage_check_current_task(), manage_cleanup_process_error(), and set_task_requested().

18308 {
18309  char *uuid;
18310  char *name;
18311 
18312  set_task_run_status_internal (task, status);
18313 
18314  task_uuid (task, &uuid);
18315  name = task_name (task);
18316  g_log ("event task", G_LOG_LEVEL_MESSAGE,
18317  "Status of task %s (%s) has changed to %s",
18318  name, uuid, run_status_name (status));
18319  free (uuid);
18320  free (name);
18321 
18322  event (task,
18323  (task == current_scanner_task) ? current_report : 0,
18324  EVENT_TASK_RUN_STATUS_CHANGED, (void*) status);
18325 }
task_t current_scanner_task
The task currently running on the scanner.
Definition: manage.c:998
int task_uuid(task_t task, char **id)
Return the UUID of a task.
Definition: manage_sql.c:17885
const char * run_status_name(task_status_t status)
Get the name of a run status.
Definition: manage.c:1253
report_t current_report
The report of the current task.
Definition: manage.c:1003
char * task_name(task_t task)
Return the name of a task.
Definition: manage_sql.c:17945
Here is the caller graph for this function:

◆ set_task_scanner()

void set_task_scanner ( task_t  task,
scanner_t  scanner 
)

Set the scanner of a task.

Parameters
[in]taskTask.
[in]scannerScanner.

Definition at line 18208 of file manage_sql.c.

References SCANNER_TYPE_CVE, and sql().

Referenced by move_task().

18209 {
18210  sql ("UPDATE tasks SET scanner = %llu, modification_time = m_now ()"
18211  " WHERE id = %llu;", scanner, task);
18212  if (scanner_type (scanner) == SCANNER_TYPE_CVE)
18213  sql ("UPDATE tasks SET config = 0 WHERE id = %llu;", task);
18214 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
scanner_type
Scanner types.
Definition: manage.h:267
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18808 of file manage_sql.c.

References sql().

18809 {
18810  sql ("UPDATE tasks"
18811  " SET schedule = %llu,"
18812  " schedule_periods = %i,"
18813  " schedule_next_time = (SELECT next_time (first_time,"
18814  " period,"
18815  " period_months,"
18816  " timezone)"
18817  " FROM schedules"
18818  " WHERE id = %llu),"
18819  " modification_time = m_now ()"
18820  " WHERE id = %llu;",
18821  schedule, periods, schedule, task);
18822 
18823  return 0;
18824 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

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

Definition at line 19058 of file manage_sql.c.

References sql().

Referenced by manage_schedule().

19059 {
19060  sql ("UPDATE tasks SET schedule_next_time = %i WHERE id = %llu;",
19061  time, task);
19062 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 19071 of file manage_sql.c.

References sql(), sql_quote(), and task_id().

Referenced by manage_schedule().

19072 {
19073  gchar *quoted_task_id;
19074 
19075  quoted_task_id = sql_quote (task_id);
19076  sql ("UPDATE tasks SET schedule_next_time = %i WHERE uuid = '%s';",
19077  time, quoted_task_id);
19078  g_free (quoted_task_id);
19079 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18869 of file manage_sql.c.

References sql(), sql_quote(), and task_id().

Referenced by manage_schedule().

18870 {
18871  gchar *quoted_task_id;
18872 
18873  quoted_task_id = sql_quote (task_id);
18874  sql ("UPDATE tasks"
18875  " SET schedule_periods = %i"
18876  " WHERE uuid = '%s';",
18877  periods, quoted_task_id);
18878  g_free (quoted_task_id);
18879 
18880  return 0;
18881 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18894 of file manage_sql.c.

References sql().

18895 {
18896  sql ("UPDATE tasks"
18897  " SET schedule_periods = %i"
18898  " WHERE id = %llu;",
18899  periods, task);
18900  return 0;
18901 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_task_schedule_uuid()

int set_task_schedule_uuid ( const gchar *  task_id,
schedule_t  schedule,
int  periods 
)

Set the schedule of a task.

Parameters
[in]task_idTask UUID.
[in]scheduleSchedule.
[in]periodsNumber of schedule periods.
Returns
0 success, -1 error.

Definition at line 18836 of file manage_sql.c.

References sql(), sql_quote(), and task_id().

Referenced by manage_schedule().

18837 {
18838  gchar *quoted_task_id;
18839 
18840  quoted_task_id = sql_quote (task_id);
18841  sql ("UPDATE tasks"
18842  " SET schedule = %llu,"
18843  " schedule_periods = %i,"
18844  " schedule_next_time = (SELECT next_time (first_time,"
18845  " period,"
18846  " period_months,"
18847  " timezone)"
18848  " FROM schedules"
18849  " WHERE id = %llu),"
18850  " modification_time = m_now ()"
18851  " WHERE uuid = '%s';",
18852  schedule, periods, schedule, quoted_task_id);
18853  g_free (quoted_task_id);
18854 
18855  return 0;
18856 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_task_start_time()

void set_task_start_time ( task_t  task,
char *  time 
)

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. ISO format. Freed before return.

Definition at line 18493 of file manage_sql.c.

References parse_iso_time(), and sql().

18494 {
18495  sql ("UPDATE tasks SET start_time = %i, modification_time = m_now ()"
18496  " WHERE id = %llu;",
18497  parse_iso_time (time),
18498  task);
18499  free (time);
18500 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
int parse_iso_time(const char *text_time)
Convert an ISO time into seconds since epoch.
Definition: manage_sql.c:875
Here is the call graph for this function:

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

Definition at line 18509 of file manage_sql.c.

References sql().

18510 {
18511  sql ("UPDATE tasks SET start_time = %i, modification_time = m_now ()"
18512  " WHERE id = %llu;",
18513  time,
18514  task);
18515 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_task_start_time_otp()

void set_task_start_time_otp ( task_t  task,
char *  time 
)

Set the start time of a task.

Parameters
[in]taskTask.
[in]timeNew time. OTP format (ctime). Freed before return.

Definition at line 18524 of file manage_sql.c.

References sql().

18525 {
18526  sql ("UPDATE tasks SET start_time = %i, modification_time = m_now ()"
18527  " WHERE id = %llu;",
18528  parse_otp_time (time),
18529  task);
18530  free (time);
18531 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

◆ set_task_target()

void set_task_target ( task_t  task,
target_t  target 
)

Set the target of a task.

Parameters
[in]taskTask.
[in]targetTarget.

Definition at line 18137 of file manage_sql.c.

References sql().

18138 {
18139  sql ("UPDATE tasks SET target = %llu, modification_time = m_now ()"
18140  " WHERE id = %llu;",
18141  target,
18142  task);
18143 }
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
Here is the call graph for this function:

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

Definition at line 2043 of file manage_sql.c.

References keyword::column, keyword::equal, KEYWORD_RELATION_COLUMN_ABOVE, KEYWORD_RELATION_COLUMN_APPROX, KEYWORD_RELATION_COLUMN_BELOW, KEYWORD_RELATION_COLUMN_EQUAL, KEYWORD_RELATION_COLUMN_REGEXP, keyword::relation, and keyword::string.

Referenced by manage_clean_filter_remove(), manage_filter_controls(), and manage_report_filter_controls().

2044 {
2045  int in_quote, between;
2046  array_t *parts;
2047  const gchar *current_part, *filter;
2048  keyword_t *keyword;
2049 
2050  assert (given_filter);
2051 
2052  filter = given_filter;
2053  parts = make_array ();
2054  in_quote = 0;
2055  between = 1;
2056  keyword = NULL;
2057  current_part = filter; /* To silence compiler warning. */
2058  while (*filter)
2059  {
2060  switch (*filter)
2061  {
2062  case '=':
2063  if (between)
2064  {
2065  /* Empty index. Start a part. */
2066  keyword = g_malloc0 (sizeof (keyword_t));
2067  keyword->equal = 1;
2068  current_part = filter + 1;
2069  between = 0;
2070  break;
2071  }
2072  case ':':
2073  case '~':
2074  case '>':
2075  case '<':
2076  if (between)
2077  {
2078  /* Empty index. Just start a part for now. */
2079  keyword = g_malloc0 (sizeof (keyword_t));
2080  current_part = filter;
2081  between = 0;
2082  break;
2083  }
2084  if (in_quote)
2085  break;
2086  /* End of an index. */
2087  if (keyword == NULL)
2088  {
2089  assert (0);
2090  break;
2091  }
2092  if (keyword->column)
2093  /* Already had an index char. */
2094  break;
2095  if (filter <= (current_part - 1))
2096  {
2097  assert (0);
2098  break;
2099  }
2100  keyword->column = g_strndup (current_part,
2101  filter - current_part);
2102  current_part = filter + 1;
2103  switch (*filter)
2104  {
2105  case '=':
2107  break;
2108  case '~':
2110  break;
2111  case '>':
2113  break;
2114  case '<':
2116  break;
2117  case ':':
2119  break;
2120  }
2121  break;
2122 
2123  case ' ':
2124  case '\t':
2125  case '\n':
2126  case '\r':
2127  if (in_quote || between)
2128  break;
2129  /* End of a part. */
2130  if (keyword == NULL)
2131  {
2132  assert (0);
2133  break;
2134  }
2135  keyword->string = g_strndup (current_part, filter - current_part);
2136  parse_keyword (keyword);
2137  if (keyword_applies (parts, keyword))
2138  array_add (parts, keyword);
2139  keyword = NULL;
2140  between = 1;
2141  break;
2142 
2143  case '"':
2144  if (in_quote)
2145  {
2146  /* End of a quoted part. */
2147  if (keyword == NULL)
2148  {
2149  assert (0);
2150  break;
2151  }
2152  keyword->quoted = 1;
2153  keyword->string = g_strndup (current_part,
2154  filter - current_part);
2155  parse_keyword (keyword);
2156  if (keyword_applies (parts, keyword))
2157  array_add (parts, keyword);
2158  keyword = NULL;
2159  in_quote = 0;
2160  between = 1;
2161  }
2162  else if (between)
2163  {
2164  /* Start of a quoted part. */
2165  keyword = g_malloc0 (sizeof (keyword_t));
2166  in_quote = 1;
2167  current_part = filter + 1;
2168  between = 0;
2169  }
2170  else if (keyword->column && filter == current_part)
2171  {
2172  /* A quoted index. */
2173  in_quote = 1;
2174  current_part++;
2175  }
2176  else if (keyword->equal && filter == current_part)
2177  {
2178  /* A quoted exact term, like ="abc". */
2179  in_quote = 1;
2180  current_part++;
2181  }
2182  /* Else just a quote in a keyword, like ab"cd. */
2183  break;
2184 
2185  default:
2186  if (between)
2187  {
2188  /* Start of a part. */
2189  keyword = g_malloc0 (sizeof (keyword_t));
2190  current_part = filter;
2191  between = 0;
2192  }
2193  break;
2194  }
2195  filter++;
2196  }
2197  if (between == 0)
2198  {
2199  if (keyword == NULL)
2200  assert (0);
2201  else
2202  {
2203  keyword->quoted = in_quote;
2204  keyword->string = g_strdup (current_part);
2205  parse_keyword (keyword);
2206  if (keyword_applies (parts, keyword))
2207  array_add (parts, keyword);
2208  keyword = NULL;
2209  }
2210  }
2211  assert (keyword == NULL);
2212 
2213  {
2214  int index, first, max, sort;
2215  keyword_t *keyword;
2216 
2217  index = parts->len;
2218  first = max = sort = 0;
2219  while (index--)
2220  {
2221  keyword_t *item;
2222  item = (keyword_t*) g_ptr_array_index (parts, index);
2223  if (item->column && (strcmp (item->column, "first") == 0))
2224  first = 1;
2225  else if (item->column && (strcmp (item->column, "rows") == 0))
2226  max = 1;
2227  else if (item->column
2228  && ((strcmp (item->column, "sort") == 0)
2229  || (strcmp (item->column, "sort-reverse") == 0)))
2230  sort = 1;
2231  }
2232 
2233  if (first == 0)
2234  {
2235  keyword = g_malloc0 (sizeof (keyword_t));
2236  keyword->column = g_strdup ("first");
2237  keyword->string = g_strdup ("1");
2240  array_add (parts, keyword);
2241  }
2242 
2243  if (max == 0)
2244  {
2245  keyword = g_malloc0 (sizeof (keyword_t));
2246  keyword->column = g_strdup ("rows");
2247  /* If there was a filter, make max_return default to Rows Per
2248  * Page. This keeps the pre-filters OMP behaviour when the filter
2249  * is empty, but is more convenenient for clients that set the
2250  * filter. */
2251  if (strlen (given_filter))
2252  keyword->string = g_strdup ("-2");
2253  else
2254  keyword->string = g_strdup ("-1");
2257  array_add (parts, keyword);
2258  }
2259 
2260  if (table_order_if_sort_not_specified == 0 && sort == 0)
2261  {
2262  keyword = g_malloc0 (sizeof (keyword_t));
2263  keyword->column = g_strdup ("sort");
2264  keyword->string = g_strdup ("name");
2267  array_add (parts, keyword);
2268  }
2269  }
2270 
2271  array_add (parts, NULL);
2272 
2273  return parts;
2274 }
gchar * column
The column prefix, or NULL.
Definition: manage.h:3430
keyword_type_t type
Type of keyword.
Definition: manage.h:3436
int equal
Whether the keyword is like "=example".
Definition: manage.h:3431
int table_order_if_sort_not_specified
Flag to control the default sorting produced by split filter.
Definition: manage_sql.c:2033
keyword_relation_t relation
The relation.
Definition: manage.h:3437
gchar * string
The keyword string, outer quotes removed.
Definition: manage.h:3435
Keyword.
Definition: manage.h:3428
int quoted
Whether the keyword was quoted.
Definition: manage.h:3434
Here is the caller graph for this function:

◆ stop_active_tasks()

void stop_active_tasks ( )

Stop any active tasks.

Definition at line 16767 of file manage_sql.c.

References current_credentials, get_iterator_resource(), init_task_iterator(), next(), task_iterator_run_status(), TASK_STATUS_DELETE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_WAITING, TASK_STATUS_DELETE_WAITING, TASK_STATUS_REQUESTED, TASK_STATUS_RUNNING, TASK_STATUS_STOP_REQUESTED, TASK_STATUS_STOP_REQUESTED_GIVEUP, and TASK_STATUS_STOP_WAITING.

16768 {
16769  iterator_t tasks;
16770  get_data_t get;
16771 
16772  /* Set requested and running tasks to stopped. */
16773 
16774  assert (current_credentials.uuid == NULL);
16775  memset (&get, '\0', sizeof (get));
16776  init_task_iterator (&tasks, &get);
16777  while (next (&tasks))
16778  {
16779  switch (task_iterator_run_status (&tasks))
16780  {
16785  case TASK_STATUS_REQUESTED:
16786  case TASK_STATUS_RUNNING:
16790  {
16791  task_t index = get_iterator_resource (&tasks);
16792  /* Set the current user, for event checks. */
16793  current_credentials.uuid = task_owner_uuid (index);
16795  free (current_credentials.uuid);
16796  break;
16797  }
16798  default:
16799  break;
16800  }
16801  }
16802  cleanup_iterator (&tasks);
16803  current_credentials.uuid = NULL;
16804 
16805  /* Set requested and running reports to stopped. */
16806 
16807  sql ("UPDATE reports SET scan_run_status = %u"
16808  " WHERE scan_run_status = %u"
16809  " OR scan_run_status = %u"
16810  " OR scan_run_status = %u"
16811  " OR scan_run_status = %u"
16812  " OR scan_run_status = %u"
16813  " OR scan_run_status = %u"
16814  " OR scan_run_status = %u"
16815  " OR scan_run_status = %u"
16816  " OR scan_run_status = %u;",
16827 }
resource_t get_iterator_resource(iterator_t *)
A generic SQL iterator.
Definition: iterator.h:52
int init_task_iterator(iterator_t *iterator, const get_data_t *get)
Initialise a task iterator.
Definition: manage_sql.c:14024
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
task_status_t task_iterator_run_status(iterator_t *iterator)
Get the run status from a task iterator.
Definition: manage_sql.c:14088
Command data for a get command.
Definition: manage.h:310
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
gboolean next(iterator_t *)
Increment an iterator.
Definition: sql.c:689
void set_task_run_status(task_t task, task_status_t status)
Set the run state of a task.
Definition: manage_sql.c:18307
long long int task_t
Definition: manage.h:286
Here is the call graph for this function:

◆ stop_task_internal()

int stop_task_internal ( task_t  task)

Initiate stopping a task.

Use send_to_server to queue the task stop sequence in the scanner output buffer.

Parameters
[in]taskTask.
Returns
0 on success, 1 if stop requested, -1 if out of space in scanner output buffer, -5 scanner down, -7 no CA cert.

Definition at line 5447 of file manage.c.

References current_scanner_task, task_run_status(), task_scanner(), TASK_STATUS_REQUESTED, and TASK_STATUS_RUNNING.

Referenced by move_task().

5448 {
5449  task_status_t run_status;
5450 
5451  run_status = task_run_status (task);
5452  if (run_status == TASK_STATUS_REQUESTED
5453  || run_status == TASK_STATUS_RUNNING)
5454  {
5455  if (current_scanner_task == task)
5456  {
5457  scanner_t scanner = task_scanner (task);
5458 
5459  assert (scanner);
5460  switch (scanner_setup (scanner))
5461  {
5462  case 0:
5463  break;
5464  case 1:
5465  return -7;
5466  default:
5467  return -5;
5468  }
5471  return -5;
5472  if (send_to_server ("CLIENT <|> STOP_WHOLE_TEST <|> CLIENT\n"))
5473  return -1;
5474  }
5476  return 1;
5477  }
5478  else if (run_status == TASK_STATUS_DELETE_REQUESTED
5479  || run_status == TASK_STATUS_DELETE_WAITING
5480  || run_status == TASK_STATUS_DELETE_ULTIMATE_REQUESTED
5481  || run_status == TASK_STATUS_DELETE_ULTIMATE_WAITING
5482  || run_status == TASK_STATUS_STOP_REQUESTED
5483  || run_status == TASK_STATUS_STOP_WAITING)
5484  {
5485  scanner_t scanner;
5486 
5487  scanner = task_scanner (task);
5488  assert (scanner);
5489  if (scanner_type (scanner) == SCANNER_TYPE_OMP)
5490  {
5491  /* A special request from the user to get the task out of a requested
5492  * state when contact with the slave is lost. */
5494  return 1;
5495  }
5496  }
5497 
5498  return 0;
5499 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
void set_task_run_status(task_t, task_status_t)
Set the run state of a task.
Definition: manage_sql.c:18307
task_t current_scanner_task
The task currently running on the scanner.
Definition: manage.c:998
int openvas_scanner_connected()
Whether we have started a connection to the Scanner using openvas_scanner_connect().
Definition: scanner.c:764
task_status_t task_run_status(task_t)
Return the run state of a task.
Definition: manage_sql.c:18238
int send_to_server(const char *msg)
Send a message to the server.
int openvas_scanner_connect()
Create a new connection to the scanner and set it as current scanner.
Definition: scanner.c:619
scanner_t task_scanner(task_t)
Return the scanner of a task.
Definition: manage_sql.c:18183
int openvas_scanner_init(int cache_mode)
Initializes the already setup connection with the Scanner.
Definition: scanner.c:778
scanner_type
Scanner types.
Definition: manage.h:267
long long int scanner_t
Definition: manage.h:300
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tag_value()

gchar* tag_value ( const gchar *  tags,
const gchar *  tag 
)

Extract a tag from an OTP tag list.

Parameters
[in]tagsTag list.
[out]tagTag name.
Returns
Newly allocated tag value.

Definition at line 1269 of file manage_sql.c.

Referenced by migrate_138_to_139(), migrate_143_to_144(), and sql_tag().

1270 {
1271  gchar **split, **point;
1272 
1273  /* creation_date=2009-04-09 14:18:58 +0200 (Thu, 09 Apr 2009)|... */
1274 
1275  if (tags == NULL)
1276  return g_strdup ("");
1277 
1278  split = g_strsplit (tags, "|", 0);
1279  point = split;
1280 
1281  while (*point)
1282  {
1283  if ((strlen (*point) > strlen (tag))
1284  && (strncmp (*point, tag, strlen (tag)) == 0)
1285  && ((*point)[strlen (tag)] == '='))
1286  {
1287  gchar *ret;
1288  ret = g_strdup (*point + strlen (tag) + 1);
1289  g_strfreev (split);
1290  return ret;
1291  }
1292  point++;
1293  }
1294  g_strfreev (split);
1295  return g_strdup ("");
1296 }
Here is the caller graph for this function:

◆ tags_set_locations()

void tags_set_locations ( const char *  ,
resource_t  ,
resource_t  ,
int   
)

◆ tags_set_orphans()

void tags_set_orphans ( const char *  ,
resource_t  ,
int   
)

◆ task_alert_iterator_alert()

alert_t task_alert_iterator_alert ( iterator_t iterator)

Get the alert from a task alert iterator.

Parameters
[in]iteratorIterator.
Returns
alert.

Definition at line 8894 of file manage_sql.c.

References iterator::done, and iterator_int64().

8895 {
8896  if (iterator->done) return 0;
8897  return (task_t) iterator_int64 (iterator, 0);
8898 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
long long int task_t
Definition: manage.h:286
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
Definition: sql.c:637
Here is the call graph for this function:

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

Definition at line 14238 of file manage_sql.c.

References sql_int().

14239 {
14240  return sql_int ("SELECT alterable FROM tasks"
14241  " WHERE id = %llu",
14242  task);
14243 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 14283 of file manage_sql.c.

References sql_int(), and TASK_STATUS_DONE.

14284 {
14285  return sql_int ("SELECT avg (end_time - start_time) FROM reports"
14286  " WHERE task = %llu"
14287  " AND scan_run_status = %d"
14288  " AND coalesce (end_time, 0) != 0"
14289  " AND coalesce (start_time, 0) != 0;",
14290  task, TASK_STATUS_DONE);
14291 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

◆ task_comment()

char* task_comment ( task_t  task)

Return the comment of a task.

Parameters
[in]taskTask.
Returns
Comment of task.

Definition at line 17959 of file manage_sql.c.

References sql_string().

17960 {
17961  return sql_string ("SELECT comment FROM tasks WHERE id = %llu;",
17962  task);
17963 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ task_config()

config_t task_config ( task_t  task)

Return the config of a task.

Parameters
[in]taskTask.
Returns
Config of task.

Definition at line 18016 of file manage_sql.c.

References sql_int64().

Referenced by stop_task().

18017 {
18018  config_t config;
18019  switch (sql_int64 (&config,
18020  "SELECT config FROM tasks WHERE id = %llu;",
18021  task))
18022  {
18023  case 0:
18024  return config;
18025  default: /* Programming error. */
18026  case 1: /* Too few rows in result of query. */
18027  case -1: /* Error. */
18028  /* Every task should have a config. */
18029  assert (0);
18030  return 0;
18031  break;
18032  }
18033 }
long long int config_t
Definition: manage.h:278
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18081 of file manage_sql.c.

References LOCATION_TRASH, and sql_int().

Referenced by task_config_name(), and task_config_uuid().

18082 {
18083  return sql_int ("SELECT config_location = " G_STRINGIFY (LOCATION_TRASH)
18084  " FROM tasks WHERE id = %llu;",
18085  task);
18086 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18062 of file manage_sql.c.

References sql_string(), and task_config_in_trash().

18063 {
18064  if (task_config_in_trash (task))
18065  return sql_string ("SELECT name FROM configs_trash WHERE id ="
18066  " (SELECT config FROM tasks WHERE id = %llu);",
18067  task);
18068  return sql_string ("SELECT name FROM configs WHERE id ="
18069  " (SELECT config FROM tasks WHERE id = %llu);",
18070  task);
18071 }
int task_config_in_trash(task_t task)
Return whether the config of a task is in the trashcan.
Definition: manage_sql.c:18081
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 18043 of file manage_sql.c.

References sql_string(), and task_config_in_trash().

18044 {
18045  if (task_config_in_trash (task))
18046  return sql_string ("SELECT uuid FROM configs_trash WHERE id ="
18047  " (SELECT config FROM tasks WHERE id = %llu);",
18048  task);
18049  return sql_string ("SELECT uuid FROM configs WHERE id ="
18050  " (SELECT config FROM tasks WHERE id = %llu);",
18051  task);
18052 }
int task_config_in_trash(task_t task)
Return whether the config of a task is in the trashcan.
Definition: manage_sql.c:18081
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 17814 of file manage_sql.c.

References filter_term(), filter_term_value(), MIN_QOD_DEFAULT, TASK_ITERATOR_COLUMNS, TASK_ITERATOR_FILTER_COLUMNS, and TASK_ITERATOR_WHERE_COLUMNS.

17815 {
17816  static const char *extra_columns[] = TASK_ITERATOR_FILTER_COLUMNS;
17817  static column_t columns[] = TASK_ITERATOR_COLUMNS;
17818  static column_t where_columns[] = TASK_ITERATOR_WHERE_COLUMNS;
17819  char *filter;
17820  gchar *value;
17821  int overrides, min_qod;
17822  gchar *extra_tables;
17823  int ret;
17824 
17825  if (get->filt_id && strcmp (get->filt_id, "0"))
17826  {
17827  filter = filter_term (get->filt_id);
17828  if (filter == NULL)
17829  return 2;
17830  }
17831  else
17832  filter = NULL;
17833  value = filter_term_value (filter ? filter : get->filter, "apply_overrides");
17834  overrides = value && strcmp (value, "0");
17835  g_free (value);
17836 
17837  value = filter_term_value (filter ? filter : get->filter, "min_qod");
17838  if (value == NULL || sscanf (value, "%d", &min_qod) != 1)
17839  min_qod = MIN_QOD_DEFAULT;
17840  g_free (value);
17841  free (filter);
17842 
17843  extra_tables = task_iterator_opts_table (overrides, min_qod, 0);
17844 
17845  ret = count2 ("task", get,
17846  columns,
17847  columns,
17848  where_columns,
17849  where_columns,
17850  extra_columns, 0,
17851  extra_tables,
17852  get->trash
17853  ? " AND hidden = 2"
17854  : " AND hidden = 0",
17855  TRUE);
17856 
17857  g_free (extra_tables);
17858  return ret;
17859 }
int trash
Boolean. Whether to return from trashcan.
Definition: manage.h:318
#define MIN_QOD_DEFAULT
Default min quality of detection percentage for filters.
Definition: manage.h:1110
#define TASK_ITERATOR_COLUMNS
Task iterator columns.
Definition: manage_sql.c:13934
char * filt_id
Filter ID. Overrides "filter".
Definition: manage.h:313
gchar * filter_term_value(const char *, const char *)
#define TASK_ITERATOR_FILTER_COLUMNS
Filter columns for task iterator.
Definition: manage_sql.c:13703
Iterator column.
Definition: manage_sql.c:1512
gchar * filter_term(const char *)
#define TASK_ITERATOR_WHERE_COLUMNS
Task iterator WHERE columns.
Definition: manage_sql.c:13925
char * filter
Filter term.
Definition: manage.h:314
Here is the call graph for this function:

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

Definition at line 17973 of file manage_sql.c.

References sql_string().

17974 {
17975  return sql_string ("SELECT hosts_ordering FROM tasks WHERE id = %llu;",
17976  task);
17977 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ task_id()

unsigned int task_id ( task_t  task)

Return the identifier of a task.

Parameters
[in]taskTask.
Returns
ID of task.
Todo:
The cast is a hack for compatibility with the old, alternate, FS based storage mechanism.

Definition at line 17869 of file manage_sql.c.

Referenced by manage_test_alert(), move_task(), resume_task(), set_task_schedule_next_time_uuid(), set_task_schedule_periods(), set_task_schedule_uuid(), stop_task(), task_schedule_next_time_uuid(), task_schedule_periods_uuid(), and task_schedule_uuid().

17870 {
17873  return (unsigned int) task;
17874 }
Here is the caller graph for this function:

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

Definition at line 17900 of file manage_sql.c.

References sql_int().

17901 {
17902  return sql_int ("SELECT hidden = 2"
17903  " FROM tasks WHERE id = %llu;",
17904  task);
17905 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 14202 of file manage_sql.c.

References task_run_status(), TASK_STATUS_DELETE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_WAITING, TASK_STATUS_DELETE_WAITING, TASK_STATUS_REQUESTED, TASK_STATUS_RUNNING, TASK_STATUS_STOP_REQUESTED, TASK_STATUS_STOP_REQUESTED_GIVEUP, and TASK_STATUS_STOP_WAITING.

Referenced by trash_task_in_use().

14203 {
14204  task_status_t status;
14205  status = task_run_status (task);
14206  return status == TASK_STATUS_DELETE_REQUESTED
14207  || status == TASK_STATUS_DELETE_WAITING
14210  || status == TASK_STATUS_REQUESTED
14211  || status == TASK_STATUS_RUNNING
14213  || status == TASK_STATUS_STOP_REQUESTED
14214  || status == TASK_STATUS_STOP_WAITING;
14215 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
task_status_t task_run_status(task_t task)
Return the run state of a task.
Definition: manage_sql.c:18238
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18416 of file manage_sql.c.

References get_iterator_resource(), sql_int(), task_iterator_run_status(), TASK_STATUS_DELETE_REQUESTED, TASK_STATUS_DELETE_ULTIMATE_REQUESTED, TASK_STATUS_INTERNAL_ERROR, TASK_STATUS_REQUESTED, TASK_STATUS_RUNNING, TASK_STATUS_STOP_REQUESTED, TASK_STATUS_STOP_REQUESTED_GIVEUP, and TASK_STATUS_STOPPED.

18417 {
18420  if (run_status == TASK_STATUS_REQUESTED
18421  || run_status == TASK_STATUS_RUNNING
18422  || run_status == TASK_STATUS_DELETE_REQUESTED
18423  || run_status == TASK_STATUS_DELETE_ULTIMATE_REQUESTED
18424  || run_status == TASK_STATUS_STOP_REQUESTED
18425  || run_status == TASK_STATUS_STOP_REQUESTED_GIVEUP
18426  || run_status == TASK_STATUS_STOPPED
18427  || run_status == TASK_STATUS_INTERNAL_ERROR)
18428  {
18429  return (unsigned int) sql_int ("SELECT max(id) FROM reports"
18430  " WHERE task = %llu"
18431  " AND (scan_run_status = %u"
18432  " OR scan_run_status = %u"
18433  " OR scan_run_status = %u"
18434  " OR scan_run_status = %u"
18435  " OR scan_run_status = %u"
18436  " OR scan_run_status = %u"
18437  " OR scan_run_status = %u"
18438  " OR scan_run_status = %u);",
18439  task,
18448  }
18449  return (report_t) 0;
18450 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
resource_t get_iterator_resource(iterator_t *)
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
A generic SQL iterator.
Definition: iterator.h:52
task_status_t task_iterator_run_status(iterator_t *iterator)
Get the run status from a task iterator.
Definition: manage_sql.c:14088
long long int report_t
Definition: manage.h:288
long long int task_t
Definition: manage.h:286
Here is the call graph for this function:

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

Definition at line 14160 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int().

14161 {
14162  if (iterator->done) return 0;
14164 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14118 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_string().

14119 {
14120  if (iterator->done) return 0;
14122 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14174 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_string().

14175 {
14176  if (iterator->done) return 0;
14178 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14146 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_string().

14147 {
14148  if (iterator->done) return 0;
14150 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14088 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, iterator_int(), and TASK_STATUS_INTERNAL_ERROR.

Referenced by stop_active_tasks(), and task_iterator_current_report().

14089 {
14090  task_status_t ret;
14092  ret = (unsigned int) iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT);
14093  return ret;
14094 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 14132 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_string().

14133 {
14134  if (iterator->done) return 0;
14136 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
const char * iterator_string(iterator_t *iterator, int col)
Get a string column from an iterator.
Definition: sql.c:652
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14188 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int64().

14189 {
14190  if (iterator->done) return 0;
14192 }
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
long long int iterator_int64(iterator_t *iterator, int col)
Get an integer column from an iterator.
Definition: sql.c:637
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

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

Definition at line 14104 of file manage_sql.c.

References iterator::done, GET_ITERATOR_COLUMN_COUNT, and iterator_int().

14105 {
14106  if (iterator->done) return 0;
14108 }
int iterator_int(iterator_t *iterator, int col)
Get a int column from an iterator.
Definition: sql.c:622
A generic SQL iterator.
Definition: iterator.h:52
gboolean done
End flag.
Definition: iterator.h:55
#define GET_ITERATOR_COLUMN_COUNT
Number of columns for GET iterator.
Definition: manage_sql.c:4191
Here is the call graph for this function:

◆ 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 succesfully failed to select report.
Returns
0 success, -1 error.

Definition at line 18542 of file manage_sql.c.

References sql_int64(), and TASK_STATUS_DONE.

Referenced by sql_task_last_report().

18543 {
18544  switch (sql_int64 (report,
18545  "SELECT id FROM reports WHERE task = %llu"
18546  " AND scan_run_status = %u"
18547  " ORDER BY date DESC LIMIT 1;",
18548  task,
18550  {
18551  case 0:
18552  break;
18553  case 1: /* Too few rows in result of query. */
18554  *report = 0;
18555  return 0;
18556  break;
18557  default: /* Programming error. */
18558  assert (0);
18559  case -1:
18560  return -1;
18561  break;
18562  }
18563  return 0;
18564 }
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
Here is the call graph for this function:
Here is the caller graph for this function:

◆ task_last_stopped_report()

int task_last_stopped_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 succesfully failed to select report.
Returns
0 success, -1 error.

Definition at line 18608 of file manage_sql.c.

References sql_int64(), and TASK_STATUS_STOPPED.

18609 {
18610  switch (sql_int64 (report,
18611  "SELECT id FROM reports WHERE task = %llu"
18612  " AND scan_run_status = %u"
18613  " ORDER BY date DESC LIMIT 1;",
18614  task,
18616  {
18617  case 0:
18618  break;
18619  case 1: /* Too few rows in result of query. */
18620  *report = 0;
18621  return 0;
18622  break;
18623  default: /* Programming error. */
18624  assert (0);
18625  case -1:
18626  return -1;
18627  break;
18628  }
18629  return 0;
18630 }
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
Here is the call graph for this function:

◆ task_name()

char* task_name ( task_t  task)

Return the name of a task.

Parameters
[in]taskTask.
Returns
Task name.

Definition at line 17945 of file manage_sql.c.

References sql_string().

17946 {
17947  return sql_string ("SELECT name FROM tasks WHERE id = %llu;",
17948  task);
17949 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ task_observers()

char* task_observers ( task_t  task)

Return the observers of a task.

Parameters
[in]taskTask.
Returns
Observers of task.

Definition at line 17987 of file manage_sql.c.

References cleanup_iterator(), init_task_user_iterator(), and next().

17988 {
17989  iterator_t users;
17990  GString *observers;
17991 
17992  observers = g_string_new ("");
17993 
17994  init_task_user_iterator (&users, task);
17995  if (next (&users))
17996  {
17997  g_string_append (observers, task_user_iterator_name (&users));
17998  while (next (&users))
17999  g_string_append_printf (observers,
18000  " %s",
18001  task_user_iterator_name (&users));
18002  }
18003  cleanup_iterator (&users);
18004 
18005  return g_string_free (observers, FALSE);
18006 }
A generic SQL iterator.
Definition: iterator.h:52
void init_task_user_iterator(iterator_t *iterator, task_t task)
Initialise a task user iterator.
Definition: manage_sql.c:6797
void cleanup_iterator(iterator_t *)
Cleanup an iterator.
Definition: sql.c:664
gboolean next(iterator_t *)
Increment an iterator.
Definition: sql.c:689
Here is the call graph for this function:

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

Definition at line 17915 of file manage_sql.c.

References sql_string().

17916 {
17917  return sql_string ("SELECT name FROM users WHERE id ="
17918  " (SELECT owner FROM tasks WHERE id = %llu);",
17919  task);
17920 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

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

Definition at line 18375 of file manage_sql.c.

References SEVERITY_ERROR, and sql_int().

18376 {
18377  return sql_int ("SELECT count (*) FROM results"
18378  " WHERE task = %llu"
18379  " AND qod > %i"
18380  " AND severity > " G_STRINGIFY (SEVERITY_ERROR) ";",
18381  task,
18382  min_qod);
18383 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
#define SEVERITY_ERROR
Definition: manage_utils.h:38
Here is the call graph for this function:

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

Definition at line 18238 of file manage_sql.c.

References sql_int().

Referenced by manage_check_current_task(), move_task(), resume_task(), set_task_requested(), stop_task_internal(), task_in_use(), and task_running_report().

18239 {
18240  return (unsigned int) sql_int ("SELECT run_status FROM tasks WHERE id = %llu;",
18241  task);
18242 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18393 of file manage_sql.c.

References sql_int(), task_run_status(), TASK_STATUS_REQUESTED, and TASK_STATUS_RUNNING.

Referenced by task_upload_progress().

18394 {
18395  task_status_t run_status = task_run_status (task);
18396  if (run_status == TASK_STATUS_REQUESTED
18397  || run_status == TASK_STATUS_RUNNING)
18398  {
18399  return (unsigned int) sql_int ("SELECT max(id) FROM reports"
18400  " WHERE task = %llu AND end_time IS NULL"
18401  " AND scan_run_status = %u;",
18402  task,
18404  }
18405  return (report_t) 0;
18406 }
task_status_t
Task statuses, also used as scan/report statuses.
Definition: manage.h:218
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
long long int report_t
Definition: manage.h:288
task_status_t task_run_status(task_t task)
Return the run state of a task.
Definition: manage_sql.c:18238
Here is the call graph for this function:
Here is the caller graph for this function:

◆ task_scanner()

scanner_t task_scanner ( task_t  task)

Return the scanner of a task.

Parameters
[in]taskTask.
Returns
scanner of task.

Definition at line 18183 of file manage_sql.c.

References sql_int64().

Referenced by move_task(), and stop_task_internal().

18184 {
18185  scanner_t scanner = 0;
18186  switch (sql_int64 (&scanner, "SELECT scanner FROM tasks WHERE id = %llu;",
18187  task))
18188  {
18189  case 0:
18190  return scanner;
18191  break;
18192  case 1: /* Too few rows in result of query. */
18193  default: /* Programming error. */
18194  assert (0);
18195  case -1:
18196  return 0;
18197  break;
18198  }
18199 }
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
long long int scanner_t
Definition: manage.h:300
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18224 of file manage_sql.c.

References LOCATION_TRASH, and sql_int().

18225 {
18226  return sql_int ("SELECT scanner_location = " G_STRINGIFY (LOCATION_TRASH)
18227  " FROM tasks WHERE id = %llu;", task);
18228 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

◆ task_schedule()

schedule_t task_schedule ( task_t  task)

Return the schedule of a task.

Parameters
[in]taskTask.
Returns
Schedule.

Definition at line 18911 of file manage_sql.c.

References sql_int64().

18912 {
18913  schedule_t schedule = 0;
18914  switch (sql_int64 (&schedule,
18915  "SELECT schedule FROM tasks WHERE id = %llu;",
18916  task))
18917  {
18918  case 0:
18919  return schedule;
18920  break;
18921  case 1: /* Too few rows in result of query. */
18922  default: /* Programming error. */
18923  assert (0);
18924  case -1:
18925  return 0;
18926  break;
18927  }
18928 }
long long int schedule_t
Definition: manage.h:299
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
Here is the call graph for this function:

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

Definition at line 18971 of file manage_sql.c.

References LOCATION_TRASH, and sql_int().

18972 {
18973  return sql_int ("SELECT schedule_location = " G_STRINGIFY (LOCATION_TRASH)
18974  " FROM tasks"
18975  " WHERE id = %llu;",
18976  task);
18977 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 19021 of file manage_sql.c.

References next_time(), and sql_int().

19022 {
19023  int next_time;
19024 
19025  next_time = sql_int ("SELECT schedule_next_time FROM tasks"
19026  " WHERE id = %llu;",
19027  task);
19028 
19029  return next_time;
19030 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
time_t next_time(time_t first, int period, int period_months, const char *timezone, int periods_offset)
Calculate the next time from now given a start time and a period.
Definition: manage_utils.c:287
Here is the call graph for this function:

◆ task_schedule_next_time_uuid()

time_t task_schedule_next_time_uuid ( const gchar *  task_id)

Set the next time a scheduled task will be due.

Parameters
[in]task_idTask UUID.

Definition at line 19038 of file manage_sql.c.

References sql_int(), sql_quote(), and task_id().

Referenced by manage_schedule().

19039 {
19040  gchar *quoted_task_id;
19041  time_t ret;
19042 
19043  quoted_task_id = sql_quote (task_id);
19044  ret = (time_t) sql_int ("SELECT schedule_next_time FROM tasks"
19045  " WHERE uuid = '%s';",
19046  quoted_task_id);
19047  g_free (quoted_task_id);
19048  return ret;
19049 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18987 of file manage_sql.c.

References sql_int().

18988 {
18989  return sql_int ("SELECT schedule_periods FROM tasks WHERE id = %llu;", task);
18990 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 19000 of file manage_sql.c.

References sql_int(), sql_quote(), and task_id().

Referenced by manage_schedule().

19001 {
19002  gchar *quoted_task_id;
19003  int ret;
19004 
19005  quoted_task_id = sql_quote (task_id);
19006  ret = sql_int ("SELECT schedule_periods FROM tasks WHERE uuid = '%s';",
19007  quoted_task_id);
19008  g_free (quoted_task_id);
19009  return ret;
19010 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18938 of file manage_sql.c.

References sql_int64(), sql_quote(), and task_id().

Referenced by manage_schedule().

18939 {
18940  schedule_t schedule;
18941  gchar *quoted_task_id;
18942 
18943  quoted_task_id = sql_quote (task_id);
18944  schedule = 0;
18945  switch (sql_int64 (&schedule,
18946  "SELECT schedule FROM tasks WHERE uuid = '%s';",
18947  quoted_task_id))
18948  {
18949  case 0:
18950  g_free (quoted_task_id);
18951  return schedule;
18952  break;
18953  case 1: /* Too few rows in result of query. */
18954  default: /* Programming error. */
18955  assert (0);
18956  case -1:
18957  g_free (quoted_task_id);
18958  return 0;
18959  break;
18960  }
18961 }
long long int schedule_t
Definition: manage.h:299
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
unsigned int task_id(task_t task)
Return the identifier of a task.
Definition: manage_sql.c:17869
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18640 of file manage_sql.c.

References sql_string(), and TASK_STATUS_DONE.

18641 {
18642  return sql_string ("SELECT uuid FROM reports WHERE task = %llu"
18643  " AND scan_run_status = %u"
18644  " ORDER BY date DESC LIMIT 1 OFFSET 1;",
18645  task,
18647 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ task_severity()

char* task_severity ( task_t  task,
int  overrides,
int  min_qod,
int  offset 
)

Return the severity score of a task, taking overrides into account.

Parameters
[in]taskTask.
[in]overridesWhether to apply overrides.
[in]min_qodMinimum QoD of results to count.
[in]offsetOffset of report to get severity from: 0 = use last report, 1 = use next to last report
Returns
Severity score of last report on task if there is one, as a freshly allocated string, else NULL.

Definition at line 19094 of file manage_sql.c.

References SEVERITY_MISSING, and task_severity_double().

19095 {
19096  double severity;
19097 
19098  severity = task_severity_double (task, overrides, min_qod, offset);
19099 
19100  if (severity == SEVERITY_MISSING)
19101  return NULL;
19102  else
19103  return g_strdup_printf ("%0.1f", severity);
19104 }
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.
Definition: manage_sql.c:19119
#define SEVERITY_MISSING
Definition: manage_utils.h:40
Here is the call graph for this function:

◆ task_severity_double()

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.

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.

Definition at line 19119 of file manage_sql.c.

References current_credentials, report_severity(), SEVERITY_MISSING, sql_int64(), TASK_STATUS_DONE, and task_target().

Referenced by task_severity().

19120 {
19121  report_t report;
19122 
19123  if (current_credentials.uuid == NULL
19124  || task_target (task) == 0 /* Container task. */)
19125  return SEVERITY_MISSING;
19126 
19127  sql_int64 (&report,
19128  "SELECT id FROM reports"
19129  " WHERE reports.task = %llu"
19130  " AND reports.scan_run_status = %u"
19131  " ORDER BY reports.date DESC"
19132  " LIMIT 1 OFFSET %d",
19133  task, TASK_STATUS_DONE, offset);
19134 
19135  return report_severity (report, overrides, min_qod);
19136 }
double report_severity(report_t, int, int)
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
long long int report_t
Definition: manage.h:288
#define SEVERITY_MISSING
Definition: manage_utils.h:40
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
target_t task_target(task_t task)
Return the target of a task.
Definition: manage_sql.c:18111
Here is the call graph for this function:
Here is the caller graph for this function:

◆ task_target()

target_t task_target ( task_t  task)

Return the target of a task.

Parameters
[in]taskTask.
Returns
Target of task.

Definition at line 18111 of file manage_sql.c.

References sql_int64().

Referenced by run_osp_task(), and task_severity_double().

18112 {
18113  target_t target = 0;
18114  switch (sql_int64 (&target,
18115  "SELECT target FROM tasks WHERE id = %llu;",
18116  task))
18117  {
18118  case 0:
18119  return target;
18120  break;
18121  case 1: /* Too few rows in result of query. */
18122  default: /* Programming error. */
18123  assert (0);
18124  case -1:
18125  return 0;
18126  break;
18127  }
18128 }
long long int target_t
Definition: manage.h:285
int sql_int64(long long int *ret, char *sql,...)
Get a particular cell from a SQL query, as an int64.
Definition: sql.c:501
Here is the call graph for this function:
Here is the caller graph for this function:

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

Definition at line 18168 of file manage_sql.c.

References LOCATION_TRASH, and sql_int().

18169 {
18170  return sql_int ("SELECT target_location = " G_STRINGIFY (LOCATION_TRASH)
18171  " FROM tasks WHERE id = %llu;",
18172  task);
18173 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 18460 of file manage_sql.c.

References task_running_report().

18461 {
18462  report_t report;
18463  report = task_running_report (task);
18464  if (report)
18465  {
18466  int count;
18467  int using_sqlite = sql_is_sqlite3 ();
18468  get_data_t get;
18469  memset (&get, 0, sizeof (get_data_t));
18470  get.filter = g_strdup ("min_qod=0");
18471  count = result_count (&get, report, NULL);
18472  get_data_reset (&get);
18473 
18474  return sql_int ("SELECT"
18475  " %s (%s (((%i * 100) / upload_result_count), 100), -1)"
18476  " FROM tasks"
18477  " WHERE id = %llu;",
18478  using_sqlite ? "max" : "greatest",
18479  using_sqlite ? "min" : "least",
18480  count,
18481  task);
18482  }
18483  return -1;
18484 }
int sql_is_sqlite3()
Get whether backend is SQLite3.
Definition: sql_pg.c:92
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
int result_count(const get_data_t *, report_t, const char *)
Command data for a get command.
Definition: manage.h:310
long long int report_t
Definition: manage.h:288
void get_data_reset(get_data_t *)
Reset command data.
Definition: omp.c:2322
report_t task_running_report(task_t task)
Return the running report of a task.
Definition: manage_sql.c:18393
Here is the call graph for this function:

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

Definition at line 17885 of file manage_sql.c.

References sql_string().

Referenced by acl_user_has_access_uuid(), and manage_schedule().

17886 {
17887  *id = sql_string ("SELECT uuid FROM tasks WHERE id = %llu;",
17888  task);
17889  return 0;
17890 }
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:
Here is the caller graph for this function:

◆ task_writable()

int task_writable ( task_t  task)

Return whether a task is writable.

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

Definition at line 14253 of file manage_sql.c.

References sql_int().

14254 {
14255  return sql_int ("SELECT hidden = 0 FROM tasks"
14256  " WHERE id = %llu",
14257  task);
14258 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 526 of file manage.c.

527 {
528  if (strcasecmp (threat, "High") == 0)
529  return "Alarm";
530  if (strcasecmp (threat, "Medium") == 0)
531  return "Alarm";
532  if (strcasecmp (threat, "Low") == 0)
533  return "Alarm";
534  if (strcasecmp (threat, "Log") == 0)
535  return "Log Message";
536  if (strcasecmp (threat, "Debug") == 0)
537  return "Debug Message";
538  if (strcasecmp (threat, "Error") == 0)
539  return "Error Message";
540  if (strcasecmp (threat, "False Positive") == 0)
541  return "False Positive";
542  return NULL;
543 }

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

Definition at line 8520 of file manage_sql.c.

References LOCATION_TRASH, and sql_int().

8521 {
8522  return !!sql_int ("SELECT count(*) FROM task_alerts"
8523  " WHERE alert = %llu"
8524  " AND alert_location = " G_STRINGIFY (LOCATION_TRASH),
8525  alert);
8526 }
#define LOCATION_TRASH
Location of a constituent of a trashcan resource.
Definition: manage_sql.h:86
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 8549 of file manage_sql.c.

8550 {
8551  return 1;
8552 }

◆ trash_id_exists()

int trash_id_exists ( const char *  type,
const char *  id 
)

Test Whether a resource of the given type and ID exists in the trash.

Parameters
[in]typeType.
[in]idUnique ID.
Returns
1 if the resource exists, 0 otherwise.

Definition at line 17780 of file manage_sql.c.

References sql_int().

17781 {
17782  if ((strcmp (type, "nvt") == 0)
17783  || (strcmp (type, "cpe") == 0)
17784  || (strcmp (type, "cve") == 0)
17785  || (strcmp (type, "ovaldef") == 0)
17786  || (strcmp (type, "cert_bund_adv") == 0)
17787  || (strcmp (type, "dfn_cert_adv") == 0)
17788  || (strcmp (type, "report") == 0)
17789  || (strcmp (type, "result") == 0)
17790  || (strcmp (type, "user") == 0))
17791  return 0;
17792  else if (strcmp (type, "task"))
17793  return !!sql_int ("SELECT count(*)"
17794  " FROM %ss_trash"
17795  " WHERE uuid='%s';",
17796  type,
17797  id);
17798  else
17799  return !!sql_int ("SELECT count(*)"
17800  " FROM tasks"
17801  " WHERE uuid='%s'"
17802  " AND hidden=2;",
17803  id);
17804 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

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

Definition at line 14225 of file manage_sql.c.

References task_in_use().

14226 {
14227  return task_in_use (task);
14228 }
int task_in_use(task_t task)
Return whether a task is in use by a task.
Definition: manage_sql.c:14202
Here is the call graph for this function:

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

Definition at line 14268 of file manage_sql.c.

References sql_int().

14269 {
14270  return sql_int ("SELECT hidden = 2 FROM tasks"
14271  " WHERE id = %llu",
14272  task);
14273 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
Here is the call graph for this function:

◆ type_db_name()

const char* type_db_name ( const char *  type)

Return DB name of type.

Parameters
[in]typeDatabase or pretty name.
Returns
Database name of type if possible, else NULL.

Definition at line 4290 of file manage_sql.c.

References valid_type().

4291 {
4292  if (type == NULL)
4293  return NULL;
4294 
4295  if (valid_type (type))
4296  return type;
4297 
4298  if (strcasecmp (type, "Agent") == 0)
4299  return "agent";
4300  if (strcasecmp (type, "Alert") == 0)
4301  return "alert";
4302  if (strcasecmp (type, "Asset") == 0)
4303  return "asset";
4304  if (strcasecmp (type, "Config") == 0)
4305  return "config";
4306  if (strcasecmp (type, "Credential") == 0)
4307  return "credential";
4308  if (strcasecmp (type, "Filter") == 0)
4309  return "filter";
4310  if (strcasecmp (type, "Note") == 0)
4311  return "note";
4312  if (strcasecmp (type, "Override") == 0)
4313  return "override";
4314  if (strcasecmp (type, "Permission") == 0)
4315  return "permission";
4316  if (strcasecmp (type, "Port List") == 0)
4317  return "port_list";
4318  if (strcasecmp (type, "Report") == 0)
4319  return "report";
4320  if (strcasecmp (type, "Report Format") == 0)
4321  return "report_format";
4322  if (strcasecmp (type, "Result") == 0)
4323  return "result";
4324  if (strcasecmp (type, "Role") == 0)
4325  return "role";
4326  if (strcasecmp (type, "Scanner") == 0)
4327  return "scanner";
4328  if (strcasecmp (type, "Schedule") == 0)
4329  return "schedule";
4330  if (strcasecmp (type, "Tag") == 0)
4331  return "tag";
4332  if (strcasecmp (type, "Target") == 0)
4333  return "target";
4334  if (strcasecmp (type, "Task") == 0)
4335  return "task";
4336  if (strcasecmp (type, "SecInfo") == 0)
4337  return "info";
4338  return NULL;
4339 }
int valid_type(const char *)
Check whether a resource type name is valid.
Definition: manage_sql.c:4201
Here is the call graph for this function:

◆ type_has_comment()

int type_has_comment ( const char *  type)

Check whether a type has a comment.

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

Definition at line 4363 of file manage_sql.c.

4364 {
4365  return strcasecmp (type, "report_format");
4366 }

◆ type_named()

int type_named ( const char *  type)

Check whether a type has a name and comment.

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

Definition at line 4349 of file manage_sql.c.

4350 {
4351  return strcasecmp (type, "note")
4352  && strcasecmp (type, "override");
4353 }

◆ type_owned()

int type_owned ( const char *  type)

Check whether a resource type has an owner.

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

Definition at line 4376 of file manage_sql.c.

Referenced by init_aggregate_iterator(), and resource_count().

4377 {
4378  return (strcasecmp (type, "info")
4379  && strcasecmp (type, "nvt")
4380  && strcasecmp (type, "cve")
4381  && strcasecmp (type, "cpe")
4382  && strcasecmp (type, "ovaldef")
4383  && strcasecmp (type, "cert_bund_adv")
4384  && strcasecmp (type, "dfn_cert_adv")
4385  && strcasecmp (type, "allinfo"));
4386 }
Here is the caller graph for this function:

◆ type_pretty_name()

const char* type_pretty_name ( const char *  type)

Return pretty name of type.

Parameters
[in]typeDatabase name.
Returns
1 yes, 0 no.

Definition at line 4237 of file manage_sql.c.

4238 {
4239  if (strcasecmp (type, "agent") == 0)
4240  return "Agent";
4241  if (strcasecmp (type, "alert") == 0)
4242  return "Alert";
4243  if (strcasecmp (type, "asset") == 0)
4244  return "Asset";
4245  if (strcasecmp (type, "config") == 0)
4246  return "Config";
4247  if (strcasecmp (type, "credential") == 0)
4248  return "Credential";
4249  if (strcasecmp (type, "filter") == 0)
4250  return "Filter";
4251  if (strcasecmp (type, "note") == 0)
4252  return "Note";
4253  if (strcasecmp (type, "override") == 0)
4254  return "Override";
4255  if (strcasecmp (type, "permission") == 0)
4256  return "Permission";
4257  if (strcasecmp (type, "port_list") == 0)
4258  return "Port List";
4259  if (strcasecmp (type, "report") == 0)
4260  return "Report";
4261  if (strcasecmp (type, "report_format") == 0)
4262  return "Report Format";
4263  if (strcasecmp (type, "result") == 0)
4264  return "Result";
4265  if (strcasecmp (type, "role") == 0)
4266  return "Role";
4267  if (strcasecmp (type, "scanner") == 0)
4268  return "Scanner";
4269  if (strcasecmp (type, "schedule") == 0)
4270  return "Schedule";
4271  if (strcasecmp (type, "tag") == 0)
4272  return "Tag";
4273  if (strcasecmp (type, "target") == 0)
4274  return "Target";
4275  if (strcasecmp (type, "task") == 0)
4276  return "Task";
4277  if (strcasecmp (type, "info") == 0)
4278  return "SecInfo";
4279  return "";
4280 }

◆ type_select_columns()

column_t* type_select_columns ( const char *  type,
int   
)

Referenced by init_aggregate_iterator().

Here is the caller graph for this function:

◆ type_where_columns()

column_t* type_where_columns ( const char *  type,
int   
)

Referenced by init_aggregate_iterator().

Here is the caller graph for this function:

◆ user_ensure_in_db()

int user_ensure_in_db ( const gchar *  name,
const gchar *  method 
)

Ensure the user exists in the database.

Parameters
[in]nameUser name.
[in]methodAuth method.
Returns
0 success.

Definition at line 17309 of file manage_sql.c.

References current_credentials, sql(), sql_int(), and sql_quote().

17310 {
17311  gchar *quoted_name, *quoted_method;
17312 
17313  if ((method == NULL) || (strcasecmp (method, "file") == 0))
17314  /* A "file" user, now entirely stored in db. */
17315  return 0;
17316 
17317  /* SELECT then INSERT instead of using "INSERT OR REPLACE", so that the
17318  * id stays the same. */
17319 
17320  quoted_name = sql_quote (name);
17321  quoted_method = sql_quote (method);
17322 
17323  if (sql_int ("SELECT count(*)"
17324  " FROM users WHERE name = '%s' and method = '%s';",
17325  quoted_name,
17326  quoted_method))
17327  {
17328  g_free (quoted_method);
17329  g_free (quoted_name);
17330  return 0;
17331  }
17332 
17333  sql ("INSERT INTO users"
17334  " (uuid, owner, name, comment, password, timezone, method, hosts,"
17335  " hosts_allow, ifaces, ifaces_allow, creation_time, modification_time)"
17336  " VALUES"
17337  " (make_uuid (),"
17338  " (SELECT id FROM users WHERE users.uuid = '%s'),"
17339  " '%s', '', NULL, NULL, '%s', '', 2, '', 2, m_now (), m_now ());",
17340  current_credentials.uuid,
17341  quoted_name,
17342  quoted_method);
17343 
17344  g_free (quoted_method);
17345  g_free (quoted_name);
17346 
17347  return 0;
17348 }
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
Definition: sql.c:438
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
Definition: sql.c:199
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
credentials_t current_credentials
Current credentials during any OMP command.
Definition: manage.c:717
Here is the call graph for this function:

◆ user_exists()

int user_exists ( const gchar *  name)

Check if user exists.

Parameters
[in]nameUser name.
Returns
1 yes, 0 no.

Definition at line 17358 of file manage_sql.c.

Referenced by set_task_observers().

17359 {
17360  if (ldap_auth_enabled ()
17361  && user_exists_method (name, AUTHENTICATION_METHOD_LDAP_CONNECT))
17362  return 1;
17363  if (radius_auth_enabled ()
17364  && user_exists_method (name, AUTHENTICATION_METHOD_RADIUS_CONNECT))
17365  return 1;
17366  return user_exists_method (name, AUTHENTICATION_METHOD_FILE);
17367 }
Here is the caller graph for this function:

◆ user_uuid_any_method()

gchar* user_uuid_any_method ( const gchar *  name)

Get user uuid, trying all authentication methods.

Parameters
[in]nameUser name.
Returns
UUID.

Definition at line 17287 of file manage_sql.c.

17288 {
17289  if (ldap_auth_enabled ()
17290  && user_exists_method (name, AUTHENTICATION_METHOD_LDAP_CONNECT))
17291  return user_uuid_method (name, AUTHENTICATION_METHOD_LDAP_CONNECT);
17292  if (radius_auth_enabled ()
17293  && user_exists_method (name, AUTHENTICATION_METHOD_RADIUS_CONNECT))
17294  return user_uuid_method (name, AUTHENTICATION_METHOD_RADIUS_CONNECT);
17295  if (user_exists_method (name, AUTHENTICATION_METHOD_FILE))
17296  return user_uuid_method (name, AUTHENTICATION_METHOD_FILE);
17297  return NULL;
17298 }
gchar * user_uuid_method(const gchar *username, auth_method_t method)
Get user uuid.
Definition: manage_sql.c:17208

◆ user_uuid_method()

gchar* user_uuid_method ( const gchar *  username,
auth_method_t  method 
)

Get user uuid.

Parameters
[in]usernameUser name.
[in]methodAuthentication method.
Returns
UUID.

Definition at line 17208 of file manage_sql.c.

References sql_quote(), and sql_string().

17209 {
17210  gchar *uuid, *quoted_username, *quoted_method;
17211  quoted_username = sql_quote (username);
17212  quoted_method = sql_quote (auth_method_name (method));
17213  uuid = sql_string ("SELECT uuid FROM users"
17214  " WHERE name = '%s' AND method = '%s';",
17215  quoted_username,
17216  quoted_method);
17217  g_free (quoted_username);
17218  g_free (quoted_method);
17219  return uuid;
17220 }
gchar * sql_quote(const char *string)
Quotes a string to be passed to sql statements.
Definition: sql.c:121
char * sql_string(char *sql,...)
Get a particular cell from a SQL query, as an string.
Definition: sql.c:469
Here is the call graph for this function:

◆ valid_omp_command()

int valid_omp_command ( const char *  name)

Check whether a command name is valid.

Parameters
[in]nameCommand name.
Returns
1 yes, 0 no.

Definition at line 545 of file manage_sql.c.

References omp_commands.

Referenced by acl_user_has_access_uuid().

546 {
547  command_t *command;
548  command = omp_commands;
549  while (command[0].name)
550  if (strcasecmp (command[0].name, name) == 0)
551  return 1;
552  else
553  command++;
554  return 0;
555 }
A command.
Definition: manage.h:95
command_t omp_commands[]
The OMP command list.
Definition: manage_sql.c:422
Here is the caller graph for this function:

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

Definition at line 4201 of file manage_sql.c.

Referenced by find_resource_with_permission(), omp_command_type(), and type_db_name().

4202 {
4203  return (strcasecmp (type, "agent") == 0)
4204  || (strcasecmp (type, "alert") == 0)
4205  || (strcasecmp (type, "asset") == 0)
4206  || (strcasecmp (type, "config") == 0)
4207  || (strcasecmp (type, "credential") == 0)
4208  || (strcasecmp (type, "filter") == 0)
4209  || (strcasecmp (type, "group") == 0)
4210  || (strcasecmp (type, "host") == 0)
4211  || (strcasecmp (type, "info") == 0)
4212  || (strcasecmp (type, "note") == 0)
4213  || (strcasecmp (type, "os") == 0)
4214  || (strcasecmp (type, "override") == 0)
4215  || (strcasecmp (type, "permission") == 0)
4216  || (strcasecmp (type, "port_list") == 0)
4217  || (strcasecmp (type, "report") == 0)
4218  || (strcasecmp (type, "report_format") == 0)
4219  || (strcasecmp (type, "result") == 0)
4220  || (strcasecmp (type, "role") == 0)
4221  || (strcasecmp (type, "scanner") == 0)
4222  || (strcasecmp (type, "schedule") == 0)
4223  || (strcasecmp (type, "tag") == 0)
4224  || (strcasecmp (type, "target") == 0)
4225  || (strcasecmp (type, "task") == 0)
4226  || (strcasecmp (type, "user") == 0);
4227 }
Here is the caller graph for this function:

◆ validate_scp_data()

int validate_scp_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)

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.

Definition at line 7222 of file manage_sql.c.

References ALERT_METHOD_SCP, credential_value(), find_credential_with_permission(), and find_report_format_with_permission().

7223 {
7224  if (method == ALERT_METHOD_SCP
7225  && strcmp (name, "scp_credential") == 0)
7226  {
7227  credential_t credential;
7228  if (find_credential_with_permission (*data, &credential,
7229  "get_credentials"))
7230  return -1;
7231  else if (credential == 0)
7232  return 18;
7233  else
7234  {
7235  gchar *username;
7236  username = credential_value (credential, "username");
7237 
7238  if (username == NULL || strlen (username) == 0)
7239  {
7240  g_free (username);
7241  return 18;
7242  }
7243 
7244  if (strchr (username, '@') || strchr (username, ':'))
7245  {
7246  g_free (username);
7247  return 18;
7248  }
7249 
7250  g_free (username);
7251  }
7252  }
7253 
7254  if (method == ALERT_METHOD_SCP
7255  && strcmp (name, "scp_path") == 0)
7256  {
7257  if (strlen (*data) == 0)
7258  return 19;
7259  }
7260 
7261  if (method == ALERT_METHOD_SCP
7262  && strcmp (name, "scp_host") == 0)
7263  {
7264  int type;
7265  gchar *stripped;
7266 
7267  stripped = g_strstrip (g_strdup (*data));
7268  type = openvas_get_host_type (stripped);
7269  g_free (stripped);
7270  if ((type != HOST_TYPE_IPV4)
7271  && (type != HOST_TYPE_IPV6)
7272  && (type != HOST_TYPE_NAME))
7273  return 15;
7274  }
7275 
7276  if (method == ALERT_METHOD_SCP
7277  && strcmp (name, "scp_report_format") == 0)
7278  {
7279  report_format_t report_format;
7280 
7281  report_format = 0;
7283  &report_format,
7284  "get_report_formats"))
7285  return -1;
7286  if (report_format == 0)
7287  return 17;
7288  }
7289 
7290  return 0;
7291 }
long long int credential_t
Definition: manage.h:279
gboolean find_credential_with_permission(const char *, credential_t *, const char *)
gchar * credential_value(credential_t, const char *)
gboolean find_report_format_with_permission(const char *, report_format_t *, const char *)
long long int report_format_t
Definition: manage.h:290
Here is the call graph for this function:

◆ validate_send_data()

int validate_send_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)

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.

Definition at line 7304 of file manage_sql.c.

References ALERT_METHOD_SEND, and find_report_format_with_permission().

7305 {
7306  if (method == ALERT_METHOD_SEND
7307  && strcmp (name, "send_host") == 0)
7308  {
7309  int type;
7310  gchar *stripped;
7311 
7312  stripped = g_strstrip (g_strdup (*data));
7313  type = openvas_get_host_type (stripped);
7314  g_free (stripped);
7315  if ((type != HOST_TYPE_IPV4)
7316  && (type != HOST_TYPE_IPV6)
7317  && (type != HOST_TYPE_NAME))
7318  return 12;
7319  }
7320 
7321  if (method == ALERT_METHOD_SEND
7322  && strcmp (name, "send_port") == 0)
7323  {
7324  int port;
7325  gchar *stripped, *end;
7326 
7327  stripped = g_strstrip (g_strdup (*data));
7328  port = strtol (stripped, &end, 10);
7329  if (*end != '\0')
7330  {
7331  g_free (stripped);
7332  return 13;
7333  }
7334 
7335  g_free (stripped);
7336  g_free (*data);
7337  *data = g_strdup_printf ("%i", port);
7338  }
7339 
7340  if (method == ALERT_METHOD_SEND
7341  && strcmp (name, "send_report_format") == 0)
7342  {
7343  report_format_t report_format;
7344 
7345  report_format = 0;
7347  &report_format,
7348  "get_report_formats"))
7349  return -1;
7350  if (report_format == 0)
7351  return 14;
7352  }
7353 
7354  return 0;
7355 }
gboolean find_report_format_with_permission(const char *, report_format_t *, const char *)
long long int report_format_t
Definition: manage.h:290
Here is the call graph for this function:

◆ validate_smb_data()

int validate_smb_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)

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, -1 error.

Definition at line 7368 of file manage_sql.c.

References ALERT_METHOD_SMB, credential_value(), and find_credential_with_permission().

7369 {
7370  if (method == ALERT_METHOD_SMB)
7371  {
7372  if (strcmp (name, "smb_credential") == 0)
7373  {
7374  credential_t credential;
7375  if (find_credential_with_permission (*data, &credential,
7376  "get_credentials"))
7377  return -1;
7378  else if (credential == 0)
7379  return 40;
7380  else
7381  {
7382  gchar *username;
7383  username = credential_value (credential, "username");
7384 
7385  if (username == NULL || strlen (username) == 0)
7386  {
7387  g_free (username);
7388  return 40;
7389  }
7390 
7391  if (strchr (username, '@') || strchr (username, ':'))
7392  {
7393  g_free (username);
7394  return 40;
7395  }
7396 
7397  g_free (username);
7398  }
7399  }
7400 
7401  if (strcmp (name, "smb_share_path") == 0)
7402  {
7403  if (g_regex_match_simple ("^(?>\\\\\\\\|\\/\\/)[^:?<>|]+"
7404  "(?>\\\\|\\/)[^:?<>|]+$", *data, 0, 0)
7405  == FALSE)
7406  {
7407  return 41;
7408  }
7409  }
7410 
7411  if (strcmp (name, "smb_file_path") == 0)
7412  {
7413  if (g_regex_match_simple ("^[^:?<>|]+$", *data, 0, 0)
7414  == FALSE)
7415  {
7416  return 42;
7417  }
7418  }
7419  }
7420 
7421  return 0;
7422 }
long long int credential_t
Definition: manage.h:279
gboolean find_credential_with_permission(const char *, credential_t *, const char *)
gchar * credential_value(credential_t, const char *)
Here is the call graph for this function:

◆ validate_tippingpoint_data()

int validate_tippingpoint_data ( alert_method_t  method,
const gchar *  name,
gchar **  data 
)

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.

Definition at line 7435 of file manage_sql.c.

References ALERT_METHOD_TIPPINGPOINT, credential_type(), and find_credential_with_permission().

7437 {
7438  if (method == ALERT_METHOD_TIPPINGPOINT)
7439  {
7440  if (strcmp (name, "tp_sms_credential") == 0)
7441  {
7442  credential_t credential;
7443  if (find_credential_with_permission (*data, &credential,
7444  "get_credentials"))
7445  return -1;
7446  else if (credential == 0)
7447  return 50;
7448  else
7449  {
7450  if (strcmp (credential_type (credential), "up"))
7451  return 50;
7452 
7453  }
7454  }
7455 
7456  if (strcmp (name, "tp_sms_hostname") == 0)
7457  {
7458  if (g_regex_match_simple ("^[0-9A-Za-z][0-9A-Za-z.-]*$",
7459  *data, 0, 0)
7460  == FALSE)
7461  {
7462  return 51;
7463  }
7464  }
7465 
7466  if (strcmp (name, "tp_sms_tls_certificate") == 0)
7467  {
7468  // TODO: Check certificate, return 52 on failure
7469  }
7470 
7471  if (strcmp (name, "tp_sms_tls_workaround") == 0)
7472  {
7473  if (g_regex_match_simple ("^0|1$", *data, 0, 0)
7474  == FALSE)
7475  {
7476  return 53;
7477  }
7478  }
7479  }
7480 
7481  return 0;
7482 }
long long int credential_t
Definition: manage.h:279
char * credential_type(credential_t)
gboolean find_credential_with_permission(const char *, credential_t *, const char *)
Here is the call graph for this function:

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

Definition at line 8001 of file manage.c.

Variable Documentation

◆ authenticate_allow_all

int authenticate_allow_all

Flag to force authentication to succeed.

1 if set via scheduler, 2 if set via event, else 0.

Definition at line 120 of file manage_sql.c.

Referenced by authenticate(), and set_report_scheduled().

◆ manage_fork_connection

int(* manage_fork_connection) (openvas_connection_t *, gchar *) = NULL

Function to fork a connection that will accept OMP requests.

Definition at line 347 of file manage_sql.c.

◆ nvti_cache

nvtis_t* nvti_cache = NULL

Memory cache of NVT information from the database.

Definition at line 398 of file manage_sql.c.

◆ omp_commands

command_t omp_commands[]

The OMP command list.

Definition at line 422 of file manage_sql.c.

Referenced by valid_omp_command().

◆ progress

void(* progress) () = NULL

Function to mark progress.

Definition at line 352 of file manage_sql.c.

◆ table_order_if_sort_not_specified

int table_order_if_sort_not_specified = 0

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.

Definition at line 2033 of file manage_sql.c.

◆ task_db_name

gchar* task_db_name = NULL

Name of the database file.

Definition at line 403 of file manage_sql.c.

Referenced by migrate_43_to_44(), and reinit_manage_process().