|
OpenVAS Manager
7.0.3~git
|
#include "sql.h"#include "manage.h"#include "manage_utils.h"#include "manage_acl.h"#include <sqlite3.h>#include <time.h>#include <unistd.h>#include <openvas/misc/openvas_uuid.h>
Go to the source code of this file.
Data Structures | |
| struct | sql_severity_t |
| Severity. More... | |
Macros | |
| #define | _XOPEN_SOURCE /* Glibc2 needs this for strptime. */ |
| #define | G_LOG_DOMAIN "md manage" |
| GLib log domain. More... | |
Functions | |
| gchar * | clean_hosts (const char *, int *) |
| char * | iso_time (time_t *) |
| Create an ISO time from seconds since epoch. More... | |
| int | days_from_now (time_t *) |
| Calculate difference between now and epoch_time in days. More... | |
| long | current_offset (const char *) |
| Get the current offset from UTC of a timezone. More... | |
| int | user_can_everything (const char *) |
| int | user_owns (const char *, resource_t, int) |
| int | resource_name (const char *, const char *, int, gchar **) |
| int | resource_exists (const char *, resource_t, int) |
| Get whether a resource exists. More... | |
| int | parse_time (const gchar *, int *) |
| Try convert an OTP NVT tag time string into epoch time. More... | |
| gchar * | tag_value (const gchar *tags, const gchar *tag) |
| Extract a tag from an OTP tag list. More... | |
| void | manage_session_init (const char *uuid) |
| Setup session. More... | |
| void | manage_session_set_timezone (const char *timezone) |
| Setup session timezone. More... | |
| int | manage_db_empty () |
| Check whether database is empty. More... | |
| void | sql_t (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Return 1. More... | |
| void | sql_strpos (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get position of a substring like the strpos function in PostgreSQL. More... | |
| void | sql_order_inet (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert an IP address into a sortable form. More... | |
| void | sql_order_message_type (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert a message type into an integer for sorting. More... | |
| void | sql_order_port (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert a port into an integer for sorting. More... | |
| void | sql_order_role (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert a role for sorting. More... | |
| void | sql_order_threat (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert a threat into an integer for sorting. More... | |
| void | sql_make_uuid (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Make a UUID. More... | |
| void | sql_hosts_contains (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check if a host list contains a host. More... | |
| void | sql_clean_hosts (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Clean a host list. More... | |
| void | sql_uniquify (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Make a name unique. More... | |
| void | sql_iso_time (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert an epoch time into a string in ISO format. More... | |
| void | sql_days_from_now (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate difference between now and epoch time in days. More... | |
| void | sql_parse_time (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Try convert an OTP NVT tag time string into epoch time. More... | |
| void | sql_next_time (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the next time from now given a start time and a period. More... | |
| void | sql_now (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the current time as an epoch integer. More... | |
| void | sql_tag (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Extract a tag from an OTP tag list. More... | |
| void | sql_max_hosts (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Return number of hosts. More... | |
| void | sql_rename_column (const char *old_table, const char *new_table, const char *old_name, const char *new_name) |
| Move data from a table to a new table, heeding column rename. More... | |
| void | sql_common_cve (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check if two CVE lists contain a common CVE. More... | |
| void | sql_cpe_title (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check if two CVE lists contain a common CVE. More... | |
| void | sql_credential_value (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get a value from the data of a credential. More... | |
| void | sql_current_offset (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the offset from UTC of the current time for a timezone. More... | |
| void | sql_task_trend (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the trend of a task. More... | |
| void | sql_task_threat_level (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the threat level of a task. More... | |
| void | sql_report_progress (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the progress of a report. More... | |
| void | sql_report_severity (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the severity of a report. More... | |
| void | sql_report_severity_count (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the number of results of a given severity level in a report. More... | |
| void | sql_report_host_count (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Count the number of hosts of a report. More... | |
| void | sql_report_result_host_count (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Count the number of hosts of a report with results. More... | |
| void | sql_task_severity (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Calculate the severity of a task. More... | |
| void | sql_task_last_report (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the last report of a task. More... | |
| void | sql_severity_matches_ov (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Test if a severity score matches an override's severity. More... | |
| void | sql_severity_to_level (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the threat level matching a severity score. More... | |
| void | sql_severity_to_type (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the message type matching a severity score. More... | |
| void | sql_regexp (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Do a regexp match. Implements SQL REGEXP. More... | |
| void | sql_run_status_name (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the name of a task run status. More... | |
| void | sql_resource_exists (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get if a resource exists by its type and ID. More... | |
| void | sql_resource_name (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the name of a resource by its type and ID. More... | |
| void | sql_severity_in_level (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check whether a severity falls within a threat level. More... | |
| void | sql_target_credential (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get a target credential. More... | |
| void | sql_trash_target_credential_location (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get the location of a trash target credential. More... | |
| void | sql_target_login_port (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Get a target port. More... | |
| void | sql_user_can_everything (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check if a user can do anything. More... | |
| void | sql_user_owns (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Check if a user owns or effectively owns a resource. More... | |
| 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... | |
| int | manage_backup_db (const gchar *database) |
| Backup the database to a file. More... | |
| void | migrate_51_to_52_sql_convert (sqlite3_context *context, int argc, sqlite3_value **argv) |
| Convert a UTC text time to an integer time since the Epoch. More... | |
| int | manage_create_migrate_51_to_52_convert () |
| Setup SQL function for migrate_51_to_52. More... | |
Variables | |
| sqlite3 * | task_db |
| Handle on the database. More... | |
| #define _XOPEN_SOURCE /* Glibc2 needs this for strptime. */ |
Definition at line 26 of file manage_sqlite3.c.
| #define G_LOG_DOMAIN "md manage" |
GLib log domain.
Definition at line 43 of file manage_sqlite3.c.
| void check_db_sequences | ( | ) |
Ensure sequences for automatic ids are in a consistent state.
Caller must organise a transaction.
Definition at line 3164 of file manage_sqlite3.c.
References cleanup_iterator(), init_iterator(), iterator_string(), next(), sql(), and sql_int64().

| gchar* clean_hosts | ( | const char * | , |
| int * | |||
| ) |
| void create_tables | ( | ) |
Create all tables.
Definition at line 2656 of file manage_sqlite3.c.
References acl_where_owned_for_get(), LSC_FAMILY_LIST, manage_create_sql_functions(), SEVERITY_ERROR, SEVERITY_LOG, and sql().

| long current_offset | ( | const char * | zone | ) |
Get the current offset from UTC of a timezone.
| [in] | zone | Timezone, or NULL for UTC. |
Definition at line 117 of file manage_utils.c.
Referenced by sql_current_offset().

| int days_from_now | ( | time_t * | epoch_time | ) |
Calculate difference between now and epoch_time in days.
| [in] | epoch_time | Time in seconds from epoch. |
Definition at line 1072 of file manage_sql.c.
Referenced by sql_days_from_now().

| char* iso_time | ( | time_t * | epoch_time | ) |
Create an ISO time from seconds since epoch.
| [in] | epoch_time | Time in seconds from epoch. |
Definition at line 1138 of file manage_sql.c.
Referenced by iso_time_tz(), and sql_iso_time().

| void manage_attach_databases | ( | ) |
Attach external databases.
Definition at line 3176 of file manage_sqlite3.c.
References manage_cert_loaded(), manage_scap_loaded(), sql(), and sql_error().

| int manage_backup_db | ( | const gchar * | database | ) |
Backup the database to a file.
| [in] | database | Location of manage database. |
Definition at line 3372 of file manage_sqlite3.c.
| int manage_cert_loaded | ( | ) |
Check whether CERT is available.
Definition at line 3219 of file manage_sqlite3.c.
References sql_database(), sql_error(), and sql_int().
Referenced by get_nvti_xml(), init_aggregate_iterator(), manage_cert_db_version(), and migrate_116_to_117().


| int manage_create_migrate_51_to_52_convert | ( | ) |
Setup SQL function for migrate_51_to_52.
Dummy for SQLite3 compatibility.
Definition at line 3451 of file manage_sqlite3.c.
References migrate_51_to_52_sql_convert(), and task_db.
Referenced by migrate_51_to_52().


| int manage_create_sql_functions | ( | ) |
Create functions.
Definition at line 1986 of file manage_sqlite3.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.

| int manage_db_empty | ( | ) |
Check whether database is empty.
Definition at line 124 of file manage_sqlite3.c.
References sql_database(), and sql_int().

| int manage_scap_loaded | ( | ) |
Check whether SCAP is available.
Definition at line 3255 of file manage_sqlite3.c.
References sql_database(), sql_error(), and sql_int().
Referenced by init_aggregate_iterator(), manage_scap_db_version(), migrate_116_to_117(), and sql_cpe_title().


| void manage_session_init | ( | const char * | uuid | ) |
Setup session.
| [in] | uuid | User UUID. |
Definition at line 93 of file manage_sqlite3.c.
References sql().

| void manage_session_set_timezone | ( | const char * | timezone | ) |
Setup session timezone.
| [in] | timezone | Timezone. |
Definition at line 110 of file manage_sqlite3.c.
| void migrate_51_to_52_sql_convert | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert a UTC text time to an integer time since the Epoch.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 3399 of file manage_sqlite3.c.
Referenced by manage_create_migrate_51_to_52_convert().

| int parse_time | ( | const gchar * | string, |
| int * | seconds | ||
| ) |
Try convert an OTP NVT tag time string into epoch time.
| [in] | string | String. |
| [out] | seconds | Time as seconds since the epoch. |
Definition at line 1308 of file manage_sql.c.
Referenced by sql_parse_time().

| int resource_exists | ( | const char * | type, |
| resource_t | resource, | ||
| int | location | ||
| ) |
Get whether a resource exists.
| [in] | type | Type. |
| [in] | resource | Resource. |
| [in] | location | Location. |
Definition at line 4826 of file manage_sql.c.
References LOCATION_TABLE, sql_int(), and valid_db_resource_type().
Referenced by sql_resource_exists().


| int resource_name | ( | const char * | , |
| const char * | , | ||
| int | , | ||
| gchar ** | |||
| ) |
| void sql_clean_hosts | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Clean a host list.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 446 of file manage_sqlite3.c.
References clean_hosts().
Referenced by manage_create_sql_functions().


| void sql_common_cve | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check if two CVE lists contain a common CVE.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 836 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_cpe_title | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check if two CVE lists contain a common CVE.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 895 of file manage_sqlite3.c.
References manage_scap_loaded(), sql_quote(), and sql_string().
Referenced by manage_create_sql_functions().


| void sql_credential_value | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get a value from the data of a credential.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 940 of file manage_sqlite3.c.
References sql_quote(), and sql_string().
Referenced by manage_create_sql_functions().


| void sql_current_offset | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the offset from UTC of the current time for a timezone.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 985 of file manage_sqlite3.c.
References current_offset().
Referenced by manage_create_sql_functions().


| void sql_days_from_now | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate difference between now and epoch time in days.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 582 of file manage_sqlite3.c.
References days_from_now().
Referenced by manage_create_sql_functions().


| void sql_hosts_contains | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check if a host list contains a host.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 395 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_iso_time | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert an epoch time into a string in ISO format.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 551 of file manage_sqlite3.c.
References iso_time().
Referenced by manage_create_sql_functions().


| void sql_make_uuid | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Make a UUID.
This is a callback for a scalar SQL function of zero arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 369 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_max_hosts | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Return number of hosts.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 743 of file manage_sqlite3.c.
References manage_count_hosts().
Referenced by manage_create_sql_functions().


| void sql_next_time | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the next time from now given a start time and a period.
This is a callback for a scalar SQL function of three to five arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 652 of file manage_sqlite3.c.
References next_time().
Referenced by manage_create_sql_functions().


| void sql_now | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the current time as an epoch integer.
This is a callback for a scalar SQL function of zero arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 689 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_order_inet | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert an IP address into a sortable form.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 203 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_order_message_type | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert a message type into an integer for sorting.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 243 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_order_port | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert a port into an integer for sorting.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 279 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_order_role | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert a role for sorting.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 307 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_order_threat | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Convert a threat into an integer for sorting.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 332 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_parse_time | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Try convert an OTP NVT tag time string into epoch time.
This is a callback for a scalar SQL function of one argument.
This is only used by the SQLite backend, in the SQL of some older migrators.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 612 of file manage_sqlite3.c.
References parse_time().
Referenced by manage_create_sql_functions().


| void sql_regexp | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Do a regexp match. Implements SQL REGEXP.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1620 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_rename_column | ( | const char * | old_table, |
| const char * | new_table, | ||
| const char * | old_name, | ||
| const char * | new_name | ||
| ) |
Move data from a table to a new table, heeding column rename.
| [in] | old_table | Existing table. |
| [in] | new_table | New empty table with renamed column. |
| [in] | old_name | Name of column in old table. |
| [in] | new_name | Name of column in new table. |
Definition at line 774 of file manage_sqlite3.c.
References cleanup_iterator(), init_iterator(), iterator_column_count(), iterator_column_name(), next(), and sql().

| void sql_report_host_count | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Count the number of hosts of a report.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1368 of file manage_sqlite3.c.
References report_host_count().
Referenced by manage_create_sql_functions().


| void sql_report_progress | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the progress of a report.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1201 of file manage_sqlite3.c.
References report_progress(), and report_task().
Referenced by manage_create_sql_functions().


| void sql_report_result_host_count | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Count the number of hosts of a report with results.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1399 of file manage_sqlite3.c.
References MIN_QOD_DEFAULT, and report_result_host_count().
Referenced by manage_create_sql_functions().


| void sql_report_severity | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the severity of a report.
This is a callback for a scalar SQL function of three arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1235 of file manage_sqlite3.c.
References MIN_QOD_DEFAULT, and report_severity().
Referenced by manage_create_sql_functions().


| void sql_report_severity_count | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the number of results of a given severity level in a report.
This is a callback for a scalar SQL function of four arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1320 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_resource_exists | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get if a resource exists by its type and ID.
This is a callback for a scalar SQL function of three arguments.
Used by migrate_119_to_120 to check if a permission refers to a resource that has been removed.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1687 of file manage_sqlite3.c.
References resource_exists(), and valid_db_resource_type().
Referenced by manage_create_sql_functions().


| void sql_resource_name | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the name of a resource by its type and ID.
This is a callback for a scalar SQL function of three arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1739 of file manage_sqlite3.c.
References resource_name().
Referenced by manage_create_sql_functions().


| void sql_run_status_name | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the name of a task run status.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1660 of file manage_sqlite3.c.
References run_status_name().
Referenced by manage_create_sql_functions().


| void sql_severity_in_level | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check whether a severity falls within a threat level.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1792 of file manage_sqlite3.c.
References severity_in_level().
Referenced by manage_create_sql_functions().


| void sql_severity_matches_ov | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Test if a severity score matches an override's severity.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1515 of file manage_sqlite3.c.
References severity_matches_ov().
Referenced by manage_create_sql_functions().


| void sql_severity_to_level | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the threat level matching a severity score.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1555 of file manage_sqlite3.c.
References severity_to_level().
Referenced by manage_create_sql_functions().


| void sql_severity_to_type | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the message type matching a severity score.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1589 of file manage_sqlite3.c.
References severity_to_type().
Referenced by manage_create_sql_functions().


| void sql_strpos | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get position of a substring like the strpos function in PostgreSQL.
This is a callback for a scalar SQL function of two arguments. The SQLite function instr could be used as replacement, but is only available in versions >= 3.7.15.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 164 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_t | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Return 1.
This is a callback for a scalar SQL function of zero arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 145 of file manage_sqlite3.c.
Referenced by manage_create_sql_functions().

| void sql_tag | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Extract a tag from an OTP tag list.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 705 of file manage_sqlite3.c.
References tag_value().
Referenced by manage_create_sql_functions().


| void sql_target_credential | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get a target credential.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1823 of file manage_sqlite3.c.
References target_credential(), and trash_target_credential().
Referenced by manage_create_sql_functions().


| void sql_target_login_port | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get a target port.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1891 of file manage_sqlite3.c.
References target_login_port(), and trash_target_login_port().
Referenced by manage_create_sql_functions().


| void sql_task_last_report | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the last report of a task.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1491 of file manage_sqlite3.c.
References task_last_report().
Referenced by manage_create_sql_functions().


| void sql_task_severity | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the severity of a task.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1436 of file manage_sqlite3.c.
References MIN_QOD_DEFAULT.
Referenced by manage_create_sql_functions().

| void sql_task_threat_level | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the threat level of a task.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1139 of file manage_sqlite3.c.
References MIN_QOD_DEFAULT.
Referenced by manage_create_sql_functions().

| void sql_task_trend | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Calculate the trend of a task.
This is a callback for a scalar SQL function of two argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1003 of file manage_sqlite3.c.
References MIN_QOD_DEFAULT, and task_trend().
Referenced by manage_create_sql_functions().


| void sql_trash_target_credential_location | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Get the location of a trash target credential.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1859 of file manage_sqlite3.c.
References trash_target_credential_location().
Referenced by manage_create_sql_functions().


| void sql_uniquify | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Make a name unique.
This is a callback for a scalar SQL function of four argument.
It's up to the caller to ensure there is a read-only transaction.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 477 of file manage_sqlite3.c.
References sql_int(), and sql_quote().
Referenced by manage_create_sql_functions().


| void sql_user_can_everything | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check if a user can do anything.
This is a callback for a scalar SQL function of one argument.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1928 of file manage_sqlite3.c.
References acl_user_can_everything().
Referenced by manage_create_sql_functions().


| void sql_user_owns | ( | sqlite3_context * | context, |
| int | argc, | ||
| sqlite3_value ** | argv | ||
| ) |
Check if a user owns or effectively owns a resource.
This is a callback for a scalar SQL function of two arguments.
| [in] | context | SQL context. |
| [in] | argc | Number of arguments. |
| [in] | argv | Argument array. |
Definition at line 1955 of file manage_sqlite3.c.
References acl_user_owns().
Referenced by manage_create_sql_functions().


| gchar* tag_value | ( | const gchar * | tags, |
| const gchar * | tag | ||
| ) |
Extract a tag from an OTP tag list.
| [in] | tags | Tag list. |
| [out] | tag | Tag name. |
Definition at line 1269 of file manage_sql.c.
Referenced by migrate_138_to_139(), migrate_143_to_144(), and sql_tag().

| int user_can_everything | ( | const char * | ) |
| int user_owns | ( | const char * | , |
| resource_t | , | ||
| int | |||
| ) |
| sqlite3* task_db |
Handle on the database.
Definition at line 73 of file sql_sqlite3.c.
Referenced by manage_create_migrate_51_to_52_convert(), manage_create_sql_functions(), sql_bind_blob(), sql_bind_double(), sql_bind_int64(), sql_bind_text(), sql_cancel_internal(), sql_changes(), sql_close(), sql_close_fork(), sql_exec_internal(), sql_is_open(), sql_last_insert_id(), sql_prepare_internal(), and sql_reset().