Greenbone Security Assistant  9.0.1
gsad_gmp.c File Reference

GMP communication module of Greenbone Security Assistant daemon. More...

#include "gsad_gmp.h"
#include "gsad_base.h"
#include "gsad_credentials.h"
#include "gsad_gmp_arguments.h"
#include "gsad_gmp_request.h"
#include "gsad_http.h"
#include "gsad_i18n.h"
#include "gsad_params.h"
#include "gsad_session.h"
#include "gsad_settings.h"
#include "utils.h"
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
#include <gvm/base/cvss.h>
#include <gvm/gmp/gmp.h>
#include <gvm/util/fileutils.h>
#include <gvm/util/serverutils.h>
#include <gvm/util/xmlutils.h>
#include <microhttpd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/un.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for gsad_gmp.c:

Go to the source code of this file.

Data Structures

struct  find_by_value_t
 Structure to search a key by value. More...
 

Macros

#define G_LOG_DOMAIN   "gsad gmp"
 GLib log domain. More...
 
#define OPENVASMD_ADDRESS   "127.0.0.1"
 Manager (gvmd) address. More...
 
#define GSAD_MESSAGE_INVALID
 Answer for invalid input. More...
 
#define GSAD_MESSAGE_INVALID_PARAM(op)
 Answer for invalid input. More...
 
#define GSAD_STATUS_INVALID_REQUEST   MHD_HTTP_UNPROCESSABLE_ENTITY
 HTTP status code for expected failure of gmp requests e.g. if some parameter was missing or invalid. More...
 
#define RESULTS_PER_PAGE   100
 Initial filtered results per page on the report summary. More...
 
#define FILT_ID_NONE   "0"
 filt_id value to use term or built-in default filter. More...
 
#define FILT_ID_USER_SETTING   "-2"
 filt_id value to use the filter in the user setting if possible. More...
 
#define CHECK_VARIABLE_INVALID(name, op_name)
 Check if variable is NULL. More...
 
#define XML_REPORT_FORMAT_ID   "a994b278-1f62-11e1-96ac-406186ea4fc5"
 
#define ANONXML_REPORT_FORMAT_ID   "5057e5cc-b825-11e4-9d0e-28d24461215b"
 
#define PARAM_OR_SETTING(value, param, setting_id, cleanup)
 Get a value from a param or fall back to a setting. More...
 
#define EVENT_TYPE_NEW_SECINFO   "New SecInfo arrived"
 
#define EVENT_TYPE_UPDATED_SECINFO   "Updated SecInfo arrived"
 
#define EVENT_TYPE_TASK_RUN_STATUS_CHANGED   "Task run status changed"
 
#define EVENT_TYPE_TICKET_RECEIVED   "Ticket received"
 
#define EVENT_TYPE_ASSIGNED_TICKET_CHANGED   "Assigned ticket changed"
 
#define EVENT_TYPE_OWNED_TICKET_CHANGED   "Owned ticket changed"
 
#define GET_TRASH_RESOURCE(capability, command, name)
 
#define CHECK_GMPF_RET
 
#define INCLUDE_RELATED_CURRENT_RESOURCE_ONLY   0
 
#define INCLUDE_RELATED_ALL_RESOURCES   1
 
#define INCLUDE_RELATED_RESOURCES_ONLY   2
 
#define AUTH_CONF_SETTING(key, value)
 Generate AUTH_CONF_SETTING element for save_auth_gmp. More...
 

Functions

static int gmp (gvm_connection_t *connection, credentials_t *credentials, gchar **response, entity_t *entity_return, cmd_response_data_t *response_data, const char *command)
 Run a single GMP command. More...
 
static int gmpf (gvm_connection_t *connection, credentials_t *credentials, gchar **response, entity_t *entity_return, cmd_response_data_t *response_data, const char *format,...)
 Run a single formatted GMP command. More...
 
static char * get_alert (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one alert, envelope the result. More...
 
static char * get_agent (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one agent, envelope the result. More...
 
static char * get_asset (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Request an asset. More...
 
static char * get_trash (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup trash page XML, envelope the result. More...
 
static char * get_config_family (gvm_connection_t *connection, credentials_t *credentials, params_t *params, int edit, cmd_response_data_t *response_data)
 Get details of a family for a config, envelope the result. More...
 
static char * get_filter (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one filter, envelope the result. More...
 
static char * get_group (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one group, envelope the result. More...
 
static char * get_credential (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one credential, envelope the result. More...
 
static char * get_note (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get a note, envelope the result. More...
 
static char * get_override (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get a override, envelope the result. More...
 
static char * get_permission (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one permission, envelope the result. More...
 
static char * get_port_list (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one port_list, envelope the result. More...
 
static char * get_tag (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one tag, envelope the result. More...
 
static char * get_target (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one target, envelope the result. More...
 
static char * get_report_format (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one report format, envelope the result. More...
 
static char * get_role (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one role, envelope the result. More...
 
static char * get_scanner (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one scanner, envelope the result. More...
 
static char * get_schedule (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one schedule, envelope the result. More...
 
static char * get_user (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get one user, envelope the result. More...
 
static char * wizard (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Returns a wizard page. More...
 
static char * wizard_get (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Returns a wizard_get page. More...
 
static int gmp_success (entity_t entity)
 Check whether an GMP command failed. More...
 
static gchar * response_from_entity (gvm_connection_t *connection, credentials_t *credentials, params_t *params, entity_t entity, const char *action, cmd_response_data_t *response_data)
 Set redirect or return a basic action_result page based on entity. More...
 
static gchar * action_result (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *action, const char *message, const char *details, const char *id)
 Generate a enveloped GMP XML containing an action result. More...
 
int command_enabled (credentials_t *credentials, const gchar *name)
 Init the GSA GMP library. More...
 
void gmp_init (const gchar *manager_address_unix, const gchar *manager_address_tls, int port_manager)
 Init the GSA GMP library. More...
 
static char * envelope_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
 Wrap some XML in an envelope. More...
 
static int member (params_t *params, const char *string)
 Look for a param with name equal to a given string. More...
 
int member1 (params_t *params, const char *string)
 Look for param with value 1 and name equal to given string. More...
 
static char * check_modify_config (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
 Check a modify_config response. More...
 
void set_http_status_from_entity (entity_t entity, cmd_response_data_t *response_data)
 Set the HTTP status according to GMP response entity. More...
 
static int setting_get_value (gvm_connection_t *connection, const char *setting_id, gchar **value, cmd_response_data_t *response_data)
 Get a setting by UUID for the current user of an GMP connection. More...
 
gchar * message_invalid (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *op_name)
 Check a param using the direct response method. More...
 
char * get_entity (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
 Get a single entity, envelope the result. More...
 
char * get_one (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
 Get one resource, envelope the result. More...
 
static char * get_entities (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
 Get all entities of a particular type, envelope the result. More...
 
static char * get_many (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
 Get all of a particular type of resource, envelope the result. More...
 
char * edit_resource (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_get_attribs, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit XML, envelope the result. More...
 
gchar * format_file_name (gchar *fname_format, credentials_t *credentials, const char *type, const char *uuid, entity_t resource_entity)
 Generates a file name for exporting. More...
 
char * export_resource (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a resource. More...
 
static char * export_many (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of resources. More...
 
char * delete_resource (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
 Delete a resource, get all resources, envelope the result. More...
 
char * move_resource_to_trash (gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Move a resource to the trashcan. More...
 
char * delete_from_trash_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a resource from the trashcan. More...
 
char * resource_action (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
 Perform action on resource, get next page, envelope result. More...
 
char * create_report_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new container task. More...
 
char * import_report_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report, get all reports, envelope the result. More...
 
char * create_container_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a container task, serve next page. More...
 
char * create_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a task, get all tasks, envelope the result. More...
 
char * delete_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a task, get all tasks, envelope the result. More...
 
char * save_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save task, get next page, envelope the result. More...
 
char * save_container_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save container task, get next page, envelope the result. More...
 
char * export_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a task. More...
 
char * export_tasks_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of tasks. More...
 
char * stop_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Stop a task, get all tasks, envelope the result. More...
 
char * resume_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Resume a task, get all tasks, envelope the result. More...
 
char * start_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Start a task, get all tasks, envelope the result. More...
 
char * move_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Reassign a task to a new GMP slave. More...
 
char * get_info_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get info, envelope the result. More...
 
char * get_tasks_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tasks, envelope the result. More...
 
char * get_task_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a task, envelope the result. More...
 
char * create_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a credential, get all credentials, envelope result. More...
 
char * get_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one credential, envelope the result. More...
 
int download_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, char **html, char **login, cmd_response_data_t *response_data)
 Export a Credential in a defined format. More...
 
char * export_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a Credential. More...
 
char * export_credentials_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of Credentials. More...
 
char * get_credentials_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one or all credentials, envelope the result. More...
 
char * delete_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete credential, get all credentials, envelope result. More...
 
char * save_credential_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save credential, get next page, envelope the result. More...
 
char * create_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an agent, get all agents, envelope result. More...
 
char * delete_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete agent, get all agents, envelope result. More...
 
int download_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, char **html, char **filename, cmd_response_data_t *response_data)
 Get an agent, envelope the result. More...
 
char * save_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a agent, get all agents, envelope the result. More...
 
char * get_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one agent, envelope the result. More...
 
char * get_agents_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all agents, envelope the result. More...
 
char * verify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify agent, get agents, envelope the result. More...
 
char * export_agent_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a agent. More...
 
char * export_agents_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of agents. More...
 
char * get_aggregate_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an aggregate of resources. More...
 
static char * new_alert (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Returns page to create a new alert. More...
 
char * new_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new alert. More...
 
char * get_alerts (gvm_connection_t *connection, credentials_t *, params_t *, const char *, cmd_response_data_t *)
 
static void append_alert_event_data (GString *xml, params_t *data, const char *event)
 Send event data for an alert. More...
 
static void append_alert_condition_data (GString *xml, params_t *data, const char *condition)
 Send condition data for an alert. More...
 
static void append_alert_method_data (GString *xml, params_t *data, const char *method, params_t *report_formats)
 Send method data for an alert. More...
 
char * create_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an alert, get all alerts, envelope the result. More...
 
char * delete_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete an alert, get all alerts, envelope the result. More...
 
char * get_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one alert, envelope the result. More...
 
char * get_alerts_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all alerts, envelope the result. More...
 
char * edit_alert (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_alert XML, envelope the result. More...
 
char * edit_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_alert XML, envelope the result. More...
 
char * save_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an alert, get all alerts, envelope the result. More...
 
char * test_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Test an alert, get all alerts envelope the result. More...
 
char * export_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export an alert. More...
 
char * export_alerts_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of alerts. More...
 
char * create_target_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a target, get all targets, envelope the result. More...
 
char * clone_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Clone a resource, envelope the result. More...
 
char * delete_target_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a target, get all targets, envelope the result. More...
 
char * restore_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Restore a resource, get all trash, envelope the result. More...
 
char * empty_trashcan_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Empty the trashcan, get all trash, envelope the result. More...
 
char * create_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a tag, envelope the result. More...
 
char * delete_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, envelope the result. More...
 
char * save_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a tag, get all tags, envelope the result. More...
 
char * export_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a tag. More...
 
char * export_tags_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of tags. More...
 
char * get_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one tag, envelope the result. More...
 
char * get_tags_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tags, envelope the result. More...
 
char * toggle_tag_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Set tag enabled status. More...
 
char * get_target_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one target, envelope the result. More...
 
char * get_targets_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all targets, envelope the result. More...
 
char * save_target_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a target, get all targets, envelope the result. More...
 
char * export_target_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a target. More...
 
char * export_targets_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of targets. More...
 
char * create_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create config, get all configs, envelope the result. More...
 
char * import_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import config, get all configs, envelope the result. More...
 
char * get_configs_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scan configs, envelope the result. More...
 
char * get_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a config, envelope the result. More...
 
static char * save_osp_prefs (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
 Save OSP file preferences. More...
 
char * save_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save details of an NVT for a config and return the next page. More...
 
char * get_config_family_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for a config, envelope the result. More...
 
char * edit_config_family_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for editing a config, envelope result. More...
 
char * save_config_family_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, envelope the result. More...
 
char * get_config_nvt_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, envelope the result. More...
 
char * get_nvt_families_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all nvt_families, envelope the result. More...
 
char * save_config_nvt_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save NVT prefs for a config, get NVT details, envelope result. More...
 
char * delete_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete config, get all configs, envelope the result. More...
 
char * export_config_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a config. More...
 
char * export_configs_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of scan configs. More...
 
char * export_note_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a note. More...
 
char * export_notes_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of notes. More...
 
char * export_override_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export an override. More...
 
char * export_overrides_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of overrides. More...
 
char * export_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a Port List. More...
 
char * export_port_lists_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of Port Lists. More...
 
char * export_preference_file_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a file preference. More...
 
char * export_report_format_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a report format. More...
 
char * export_report_formats_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of Report Formats. More...
 
char * delete_report_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report, get task status, envelope the result. More...
 
char * get_report (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Get a report and return the result. More...
 
char * get_report_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a report and envelope the result. More...
 
char * report_alert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Run alert for a report. More...
 
char * get_reports_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all reports, envelope the result. More...
 
char * download_ssl_cert (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an SSL Certificate. More...
 
char * download_ca_pub (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a Scanner's CA Certificate. More...
 
char * download_key_pub (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a Scanner's Certificate. More...
 
char * export_result_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a result. More...
 
char * export_results_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of results. More...
 
char * get_results_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all results, envelope the result. More...
 
char * get_result_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one result, envelope the result. More...
 
char * get_notes_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all notes, envelope the result. More...
 
char * get_note_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a note, envelope the result. More...
 
const char * get_port_from_params (params_t *params)
 Get a port from request params. More...
 
const char * get_hosts_from_params (params_t *params)
 Get hosts from request params. More...
 
const char * get_task_id_from_params (params_t *params)
 Get task_id from request params. More...
 
const char * get_severity_from_params (params_t *params)
 Get severity from request params. More...
 
const char * get_result_id_from_params (params_t *params)
 Get result_id from request params. More...
 
char * create_note_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a note, get report, envelope the result. More...
 
char * delete_note_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, envelope the result. More...
 
char * save_note_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save note, get next page, envelope the result. More...
 
char * get_overrides_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all overrides, envelope the result. More...
 
char * get_override_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an override, envelope the result. More...
 
char * create_override_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an override, get report, envelope the result. More...
 
char * delete_override_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete override, get next page, envelope the result. More...
 
char * save_override_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save override, get next page, envelope the result. More...
 
char * get_scanners_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scanners, envelope the result. More...
 
char * get_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one scanner, envelope the result. More...
 
char * export_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a scanner. More...
 
char * export_scanners_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of scanners. More...
 
char * verify_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify scanner, get scanners, envelope the result. More...
 
char * create_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a scanner, get all scanners, envelope the result. More...
 
char * delete_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a scanner, get all scanners, envelope the result. More...
 
char * save_scanner_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save scanner, get next page, envelope the result. More...
 
char * get_schedule_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one schedule, envelope the result. More...
 
char * get_schedules_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all schedules, envelope the result. More...
 
char * create_schedule_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a schedule, get all schedules, envelope the result. More...
 
char * delete_schedule_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a schedule, get all schedules, envelope the result. More...
 
char * get_system_reports_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all system reports, envelope the result. More...
 
char * get_system_report_gmp (gvm_connection_t *connection, credentials_t *credentials, const char *url, params_t *params, cmd_response_data_t *response_data)
 Return system report image. More...
 
char * get_report_format_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one report format, envelope the result. More...
 
char * get_report_formats_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all Report Formats, envelope the result. More...
 
char * delete_report_format_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report format, get report formats, envelope the result. More...
 
char * import_report_format_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report format, get all report formats, envelope result. More...
 
char * save_report_format_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save report_format, get next page, envelope the result. More...
 
char * run_wizard_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Run a wizard and envelope the result. More...
 
char * get_trash_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all trash, envelope the result. More...
 
static int send_settings_filters (gvm_connection_t *connection, params_t *data, params_t *changed, GString *xml, int *modify_failed_flag, cmd_response_data_t *response_data)
 Send settings resource filters. More...
 
char * save_my_settings_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const gchar *accept_language, cmd_response_data_t *response_data)
 Returns page with user's settings, for editing. More...
 
char * get_group_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one group, envelope the result. More...
 
char * get_groups_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all groups, envelope the result. More...
 
char * delete_group_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a group, get all groups, envelope the result. More...
 
char * create_group_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a group, get all groups, envelope the result. More...
 
char * export_group_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a group. More...
 
char * export_groups_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of groups. More...
 
char * save_group_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a group, return the next page. More...
 
char * get_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one permission, envelope the result. More...
 
char * get_permissions_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all permissions, envelope the result. More...
 
char * delete_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a permission, get all permissions, envelope the result. More...
 
char * create_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a permission, get all permissions, envelope the result. More...
 
char * create_permissions_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create multiple permission, get next page, envelope the result. More...
 
char * export_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a permission. More...
 
char * export_permissions_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of permissions. More...
 
char * save_permission_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a permission, get all permissions, envelope the result. More...
 
char * create_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a port list, get all port lists, envelope the result. More...
 
char * create_port_range_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Add a range to a port list, envelope the result. More...
 
char * get_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one port_list, envelope the result. More...
 
char * get_port_lists_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all port_lists, envelope the result. More...
 
char * save_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a port list, get all port list, envelope the result. More...
 
char * delete_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port list, get all port lists, envelope the result. More...
 
char * delete_port_range_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port range, get the port list, envelope the result. More...
 
char * import_port_list_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import port list, get all port_lists, envelope the result. More...
 
char * delete_role_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a role, get all roles, envelope the result. More...
 
char * create_role_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a role, get all roles, envelope the result. More...
 
char * get_role_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one role, envelope the result. More...
 
char * get_roles_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all roles, envelope the result. More...
 
char * export_role_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a role. More...
 
char * export_roles_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of roles. More...
 
char * save_role_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a role, return the next page. More...
 
char * get_feeds_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get descriptions of the feeds connected to the manager. More...
 
static char * sync_feed (gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
 Synchronize with a feed and envelope the result. More...
 
char * sync_feed_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with an NVT feed and envelope the result. More...
 
char * sync_scap_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a SCAP feed and envelope the result. More...
 
char * sync_cert_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a CERT feed and envelope the result. More...
 
char * get_filter_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one filter, envelope the result. More...
 
char * get_filters_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all filters, envelope the result. More...
 
char * create_filter_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a filter, get all filters, envelope the result. More...
 
char * delete_filter_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a filter, get all filters, envelope the result. More...
 
char * export_filter_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a filter. More...
 
char * export_filters_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of filters. More...
 
char * save_filter_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a filter, get all filters, envelope the result. More...
 
char * export_schedule_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a schedule. More...
 
char * export_schedules_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of schedules. More...
 
char * save_schedule_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save schedule, get next page, envelope the result. More...
 
char * delete_user_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a user, get all users, envelope the result. More...
 
char * get_user_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one user, envelope the result. More...
 
char * get_users_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all users, envelope the result. More...
 
char * create_user_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a user, get all users, envelope the result. More...
 
char * get_vulns_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get multiple vulns, envelope the result. More...
 
char * auth_settings_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * save_user_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a user, get all users, envelope the result. More...
 
char * export_user_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a user. More...
 
char * export_users_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of users. More...
 
char * cvss_calculator (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * save_auth_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save authentication settings. More...
 
char * get_settings_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all user defined settings. More...
 
char * save_setting_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save user setting. More...
 
char * get_setting_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * wizard_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard page. More...
 
char * wizard_get_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard_get page. More...
 
char * bulk_delete_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete multiple resources, get next page, envelope the result. More...
 
char * bulk_export_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export multiple resources. More...
 
char * create_host_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a host, serve next page. More...
 
char * get_asset_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get asset, envelope the result. More...
 
char * get_assets_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Request assets. More...
 
char * create_asset_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an asset, get report, envelope the result. More...
 
char * delete_asset_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete an asset, go to the next page. More...
 
char * export_asset_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export an asset. More...
 
char * export_assets_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Export a list of assets. More...
 
char * save_asset_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an asset, get all assets, envelope the result. More...
 
char * get_tickets_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tickets, envelope the result. More...
 
char * get_ticket_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get single tickets, envelope the result. More...
 
char * create_ticket_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a ticket. More...
 
char * save_ticket_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a ticket. More...
 
char * delete_ticket_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a ticket. More...
 
char * get_tls_certificates_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all TLS certificates, envelope the result. More...
 
char * get_tls_certificate_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get single TLS certificates, envelope the result. More...
 
char * create_tls_certificate_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a TLS certificate. More...
 
char * save_tls_certificate_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a TLS certificate. More...
 
char * delete_tls_certificate_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a TLS certificate. More...
 
char * renew_session_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * ping_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get assets, envelope the result. More...
 
char * get_capabilities_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
int connect_unix (const gchar *path)
 Connect to Greenbone Vulnerability Manager daemon. More...
 
int gvm_connection_open (gvm_connection_t *connection, const gchar *address, int port)
 Connect to an address. More...
 
int authenticate_gmp (const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning)
 Check authentication credentials. More...
 
int login (http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
 Login and create a session. More...
 
int manager_connect (credentials_t *credentials, gvm_connection_t *connection, cmd_response_data_t *response_data)
 Connect to Greenbone Vulnerability Manager daemon. More...
 

Variables

int manager_use_tls = 0
 Whether to use TLS for Manager connections. More...
 
gchar * manager_address = NULL
 The address the manager is on. More...
 
int manager_port = 9390
 The port the manager is on. More...
 

Detailed Description

GMP communication module of Greenbone Security Assistant daemon.

This file implements an API for GMP. The functions call the Greenbone Vulnerability Manager via GMP properly.

Definition in file gsad_gmp.c.

Macro Definition Documentation

◆ ANONXML_REPORT_FORMAT_ID

#define ANONXML_REPORT_FORMAT_ID   "5057e5cc-b825-11e4-9d0e-28d24461215b"

Definition at line 145 of file gsad_gmp.c.

◆ AUTH_CONF_SETTING

#define AUTH_CONF_SETTING (   key,
  value 
)
Value:
"<auth_conf_setting>" \
"<key>" key "</key>" \
"<value>" value "</value>" \
"</auth_conf_setting>"

Generate AUTH_CONF_SETTING element for save_auth_gmp.

Definition at line 15362 of file gsad_gmp.c.

◆ CHECK_GMPF_RET

#define CHECK_GMPF_RET

Definition at line 12800 of file gsad_gmp.c.

◆ CHECK_VARIABLE_INVALID

#define CHECK_VARIABLE_INVALID (   name,
  op_name 
)
Value:
if (name == NULL) \
{ \
return message_invalid (connection, credentials, params, response_data, \
"Given " G_STRINGIFY (name) " was invalid", \
op_name); \
}

Check if variable is NULL.

Parameters
[in]nameParam name.
[in]op_nameOperation name.

Definition at line 121 of file gsad_gmp.c.

◆ EVENT_TYPE_ASSIGNED_TICKET_CHANGED

#define EVENT_TYPE_ASSIGNED_TICKET_CHANGED   "Assigned ticket changed"

Definition at line 4917 of file gsad_gmp.c.

◆ EVENT_TYPE_NEW_SECINFO

#define EVENT_TYPE_NEW_SECINFO   "New SecInfo arrived"

Definition at line 4913 of file gsad_gmp.c.

◆ EVENT_TYPE_OWNED_TICKET_CHANGED

#define EVENT_TYPE_OWNED_TICKET_CHANGED   "Owned ticket changed"

Definition at line 4918 of file gsad_gmp.c.

◆ EVENT_TYPE_TASK_RUN_STATUS_CHANGED

#define EVENT_TYPE_TASK_RUN_STATUS_CHANGED   "Task run status changed"

Definition at line 4915 of file gsad_gmp.c.

◆ EVENT_TYPE_TICKET_RECEIVED

#define EVENT_TYPE_TICKET_RECEIVED   "Ticket received"

Definition at line 4916 of file gsad_gmp.c.

◆ EVENT_TYPE_UPDATED_SECINFO

#define EVENT_TYPE_UPDATED_SECINFO   "Updated SecInfo arrived"

Definition at line 4914 of file gsad_gmp.c.

◆ FILT_ID_NONE

#define FILT_ID_NONE   "0"

filt_id value to use term or built-in default filter.

Definition at line 108 of file gsad_gmp.c.

◆ FILT_ID_USER_SETTING

#define FILT_ID_USER_SETTING   "-2"

filt_id value to use the filter in the user setting if possible.

Definition at line 113 of file gsad_gmp.c.

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "gsad gmp"

GLib log domain.

Definition at line 67 of file gsad_gmp.c.

◆ GET_TRASH_RESOURCE

#define GET_TRASH_RESOURCE (   capability,
  command,
  name 
)

Definition at line 11385 of file gsad_gmp.c.

◆ GSAD_MESSAGE_INVALID

#define GSAD_MESSAGE_INVALID
Value:
"<gsad_msg status_text=\"%s\" operation=\"%s\">" \
"At least one entered value contains invalid characters or exceeds" \
" a size limit. You may use the Back button of your browser to adjust" \
" the entered values. If in doubt, the online help of the respective " \
"section" \
" will lead you to the appropriate help page." \
"</gsad_msg>"

Answer for invalid input.

Definition at line 75 of file gsad_gmp.c.

◆ GSAD_MESSAGE_INVALID_PARAM

#define GSAD_MESSAGE_INVALID_PARAM (   op)
Value:
"<gsad_msg status_text=\"Invalid parameter\" operation=\"" op "\">" \
"At least one entered value contains invalid characters or exceeds" \
" a size limit. You may use the Back button of your browser to adjust" \
" the entered values. If in doubt, the online help of the respective " \
"section" \
" will lead you to the appropriate help page." \
"</gsad_msg>"

Answer for invalid input.

Definition at line 85 of file gsad_gmp.c.

◆ GSAD_STATUS_INVALID_REQUEST

#define GSAD_STATUS_INVALID_REQUEST   MHD_HTTP_UNPROCESSABLE_ENTITY

HTTP status code for expected failure of gmp requests e.g. if some parameter was missing or invalid.

Definition at line 98 of file gsad_gmp.c.

◆ INCLUDE_RELATED_ALL_RESOURCES

#define INCLUDE_RELATED_ALL_RESOURCES   1

Definition at line 12850 of file gsad_gmp.c.

◆ INCLUDE_RELATED_CURRENT_RESOURCE_ONLY

#define INCLUDE_RELATED_CURRENT_RESOURCE_ONLY   0

Definition at line 12849 of file gsad_gmp.c.

◆ INCLUDE_RELATED_RESOURCES_ONLY

#define INCLUDE_RELATED_RESOURCES_ONLY   2

Definition at line 12851 of file gsad_gmp.c.

◆ OPENVASMD_ADDRESS

#define OPENVASMD_ADDRESS   "127.0.0.1"

Manager (gvmd) address.

Definition at line 72 of file gsad_gmp.c.

◆ PARAM_OR_SETTING

#define PARAM_OR_SETTING (   value,
  param,
  setting_id,
  cleanup 
)
Value:
if (params_valid (params, param)) \
value = g_strdup (params_value (params, param)); \
else \
{ \
char *message; \
message = setting_get_value_error (connection, credentials, setting_id, \
&value, response_data); \
if (message) \
{ \
cleanup; \
return message; \
} \
}

Get a value from a param or fall back to a setting.

Todo:
Consider doing the input sanatizing in the page handlers.

Currently the input sanatizing is done in serve_post, exec_gmp_post and exec_gmp_get in gsad.c. This means that the information about what input is suitable for a page is separate from the page handler.

Doing the input sanatizing in the page handler will probably also help in responding with more detailed messages when an input error occurs.

Todo:
Take care of XML in input.

Anything that is printed into the XML directly (usually via g_string_append_printf below) must use something like g_markup_printf_escaped or g_markup_escape_text to ensure that any XML special sequences in the string are escaped.

Todo:
Unify the style of page handlers.

There are variations in the style of the page handlers that run multiple GMP commands.

Some, like delete_credential_gmp, simply run the GMP commands inside one GMP COMMANDS.

Others, like create_target_gmp, run each command separately and wrap the responses in a unique page tag.

One handler, delete_target_gmp, runs all the commands in a single COMMANDS and also wraps the response in a unique page tag to convey the context to the enveloped XML. This is probably the way to go.

Parameters
[out]valueVariable to assign the value to.
[in]paramThe param to try get the value from first.
[in]setting_idThe UUID of the setting to try next.
[in]cleanupCode to run on failure.

Definition at line 1887 of file gsad_gmp.c.

◆ RESULTS_PER_PAGE

#define RESULTS_PER_PAGE   100

Initial filtered results per page on the report summary.

Definition at line 103 of file gsad_gmp.c.

◆ XML_REPORT_FORMAT_ID

#define XML_REPORT_FORMAT_ID   "a994b278-1f62-11e1-96ac-406186ea4fc5"

Definition at line 144 of file gsad_gmp.c.

Function Documentation

◆ action_result()

static gchar * action_result ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data,
const char *  action,
const char *  message,
const char *  details,
const char *  id 
)
static

Generate a enveloped GMP XML containing an action result.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsHTTP request params
[out]response_dataExtra data return for the HTTP response.
[in]actionName of the action.
[in]messageStatus message.
[in]detailsStatus details (optional).
[in]idID of the handled entity (optional).
Returns
Enveloped XML object.

Definition at line 725 of file gsad_gmp.c.

729 {
730  GString *xml;
731 
732  xml = g_string_new ("");
733  xml_string_append (xml,
734  "<action_result>"
735  "<action>%s</action>"
736  "<message>%s</message>",
737  action ? action : "", message ? message : "");
738 
739  if (details)
740  xml_string_append (xml, "<details>%s</details>", details);
741 
742  if (id)
743  xml_string_append (xml, "<id>%s</id>", id);
744 
745  g_string_append (xml, "</action_result>");
746 
747  return envelope_gmp (connection, credentials, params,
748  g_string_free (xml, FALSE), response_data);
749 }

References envelope_gmp().

Referenced by check_modify_config(), create_permissions_gmp(), message_invalid(), ping_gmp(), renew_session_gmp(), response_from_entity(), and save_config_nvt_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_alert_condition_data()

static void append_alert_condition_data ( GString *  xml,
params_t *  data,
const char *  condition 
)
static

Send condition data for an alert.

Parameters
[in]xmlXML.
[out]dataData.
[out]conditionCondition.

Definition at line 4957 of file gsad_gmp.c.

4959 {
4960  if (data)
4961  {
4962  params_iterator_t iter;
4963  char *name;
4964  param_t *param;
4965 
4966  params_iterator_init (&iter, data);
4967  while (params_iterator_next (&iter, &name, &param))
4968  {
4969  if (strcmp (condition, "Filter count at least") == 0)
4970  {
4971  if (strcmp (name, "at_least_count") == 0)
4972  xml_string_append (xml, "<data><name>count</name>%s</data>",
4973  param->value ? param->value : "");
4974  if (strcmp (name, "at_least_filter_id") == 0)
4975  xml_string_append (xml, "<data><name>filter_id</name>%s</data>",
4976  param->value ? param->value : "");
4977  }
4978  else if (strcmp (condition, "Filter count changed") == 0)
4979  {
4980  if (strcmp (name, "count") == 0
4981  || strcmp (name, "filter_id") == 0)
4982  xml_string_append (xml, "<data><name>%s</name>%s</data>", name,
4983  param->value ? param->value : "");
4984  else if (strcmp (name, "filter_direction") == 0)
4985  xml_string_append (xml, "<data><name>direction</name>%s</data>",
4986  param->value ? param->value : "");
4987  }
4988  else if ((strcmp (condition, "Severity at least") == 0
4989  && strcmp (name, "severity") == 0)
4990  || (strcmp (condition, "Severity changed") == 0
4991  && strcmp (name, "direction") == 0))
4992  xml_string_append (xml, "<data><name>%s</name>%s</data>", name,
4993  param->value ? param->value : "");
4994  }
4995  }
4996 }

References params_iterator_init, params_iterator_next(), params_iterator_t, and param::value.

Referenced by create_alert_gmp(), and save_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_alert_event_data()

static void append_alert_event_data ( GString *  xml,
params_t *  data,
const char *  event 
)
static

Send event data for an alert.

Parameters
[in]xmlXML.
[out]dataData.
[out]eventEvent.
Returns
0 on success, -1 on error.

Definition at line 4929 of file gsad_gmp.c.

4930 {
4931  if (data)
4932  {
4933  params_iterator_t iter;
4934  char *name;
4935  param_t *param;
4936 
4937  params_iterator_init (&iter, data);
4938  while (params_iterator_next (&iter, &name, &param))
4940  && str_equal (name, "status"))
4941  || ((str_equal (event, EVENT_TYPE_NEW_SECINFO)
4943  && str_equal (name, "secinfo_type")))
4944  xml_string_append (xml, "<data><name>%s</name>%s</data>", name,
4945  param->value ? param->value : "");
4946  }
4947 }

References EVENT_TYPE_NEW_SECINFO, EVENT_TYPE_TASK_RUN_STATUS_CHANGED, EVENT_TYPE_UPDATED_SECINFO, params_iterator_init, params_iterator_next(), params_iterator_t, str_equal(), and param::value.

Referenced by create_alert_gmp(), and save_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_alert_method_data()

static void append_alert_method_data ( GString *  xml,
params_t *  data,
const char *  method,
params_t *  report_formats 
)
static

Send method data for an alert.

Parameters
[in]xmlCommand XML to append to.
[in]dataAlert method data params.
[in]methodName of the Alert method.
[in]report_formatsReport formats to use if multiple are supported.

Definition at line 5007 of file gsad_gmp.c.

5009 {
5010  params_iterator_t iter;
5011  char *name;
5012  param_t *param;
5013  int notice;
5014 
5015  if (data == NULL)
5016  return;
5017 
5018  /* Add report formats for methods that support multiple */
5019  if (strcmp (method, "Alemba vFire") == 0)
5020  {
5021  g_string_append (xml, "<data><name>report_formats</name>");
5022 
5023  if (report_formats && g_hash_table_size (report_formats))
5024  {
5025  int report_formats_count = g_hash_table_size (report_formats);
5026  int index;
5027  params_iterator_init (&iter, report_formats);
5028 
5029  for (index = 1; index <= report_formats_count; index++)
5030  {
5031  gchar *index_str = g_strdup_printf ("%d", index);
5032  const char *value;
5033  value = params_value (report_formats, index_str);
5034 
5035  if (index > 1)
5036  xml_string_append (xml, ", %s", value);
5037  else
5038  xml_string_append (xml, "%s", value);
5039 
5040  g_free (index_str);
5041  }
5042  }
5043  g_string_append (xml, "</data>");
5044  }
5045 
5046  /* Add single-value method data items */
5047  params_iterator_init (&iter, data);
5048  /* Used to check email notice type before sending report formats values */
5049  notice = 1;
5050  while (params_iterator_next (&iter, &name, &param))
5051  if (strcmp (name, "notice") == 0)
5052  {
5053  notice = atoi (param->value);
5054  break;
5055  }
5056 
5057  if (strcmp (method, "Sourcefire Connector"))
5058  {
5059  params_iterator_init (&iter, data);
5060 
5061  while (params_iterator_next (&iter, &name, &param))
5062  if ((strcmp (method, "HTTP Get") == 0 && strcmp (name, "URL") == 0)
5063  || (strcmp (method, "Send") == 0
5064  && (strcmp (name, "send_host") == 0
5065  || strcmp (name, "send_port") == 0
5066  || strcmp (name, "send_report_format") == 0))
5067  || (strcmp (method, "SCP") == 0
5068  && (strcmp (name, "scp_credential") == 0
5069  || strcmp (name, "scp_host") == 0
5070  || strcmp (name, "scp_known_hosts") == 0
5071  || strcmp (name, "scp_path") == 0
5072  || strcmp (name, "scp_report_format") == 0))
5073  || (strcmp (method, "SMB") == 0
5074  && (strcmp (name, "smb_credential") == 0
5075  || strcmp (name, "smb_file_path") == 0
5076  || strcmp (name, "smb_report_format") == 0
5077  || strcmp (name, "smb_share_path") == 0))
5078  || (strcmp (method, "SNMP") == 0
5079  && (strcmp (name, "snmp_community") == 0
5080  || strcmp (name, "snmp_agent") == 0
5081  || strcmp (name, "snmp_message") == 0))
5082  || (strcmp (method, "TippingPoint SMS") == 0
5083  && (strcmp (name, "tp_sms_credential") == 0
5084  || strcmp (name, "tp_sms_hostname") == 0
5085  || strcmp (name, "tp_sms_tls_certificate") == 0
5086  || strcmp (name, "tp_sms_tls_workaround") == 0))
5087  || (strcmp (method, "verinice Connector") == 0
5088  && (strcmp (name, "verinice_server_credential") == 0
5089  || strcmp (name, "verinice_server_url") == 0
5090  || strcmp (name, "verinice_server_report_format") == 0))
5091  || (strcmp (method, "Alemba vFire") == 0
5092  && (strcmp (name, "vfire_base_url") == 0
5093  || strcmp (name, "vfire_call_description") == 0
5094  || strcmp (name, "vfire_call_impact_name") == 0
5095  || strcmp (name, "vfire_call_partition_name") == 0
5096  || strcmp (name, "vfire_call_template_name") == 0
5097  || strcmp (name, "vfire_call_type_name") == 0
5098  || strcmp (name, "vfire_call_urgency_name") == 0
5099  || strcmp (name, "vfire_client_id") == 0
5100  || strcmp (name, "vfire_credential") == 0
5101  || strcmp (name, "vfire_session_type") == 0))
5102  || (strcmp (method, "Email") == 0
5103  && (strcmp (name, "to_address") == 0
5104  || strcmp (name, "from_address") == 0
5105  || strcmp (name, "subject") == 0
5106  || strcmp (name, "notice") == 0
5107  || (strcmp (name, "notice_report_format") == 0
5108  && notice == 0)
5109  || (strcmp (name, "notice_attach_format") == 0
5110  && notice == 2)
5111  || (str_equal (name, "recipient_credential")
5112  && !str_equal (param->value, "0"))))
5113  || (strcmp (method, "Syslog") == 0
5114  && strcmp (name, "submethod") == 0)
5115  || (strcmp (method, "Start Task") == 0
5116  && strcmp (name, "start_task_task") == 0)
5117  || strcmp (name, "details_url") == 0
5118  || strcmp (name, "delta_type") == 0
5119  || strcmp (name, "delta_report_id") == 0
5120  || strcmp (name, "composer_include_notes") == 0
5121  || strcmp (name, "composer_include_overrides") == 0)
5122  xml_string_append (xml, "<data><name>%s</name>%s</data>", name,
5123  param->value ? param->value : "");
5124  else if (strcmp (method, "Email") == 0 && notice == 0
5125  && strcmp (name, "message") == 0)
5126  xml_string_append (xml, "<data><name>message</name>%s</data>",
5127  param->value ? param->value : "");
5128  else if (strcmp (method, "Email") == 0 && notice == 2
5129  && strcmp (name, "message_attach") == 0)
5130  xml_string_append (xml, "<data><name>message</name>%s</data>",
5131  param->value ? param->value : "");
5132 
5133  return;
5134  }
5135 
5136  params_iterator_init (&iter, data);
5137  while (params_iterator_next (&iter, &name, &param))
5138  if (strcmp (name, "pkcs12"))
5139  {
5140  if (strcmp (name, "defense_center_ip") == 0
5141  || strcmp (name, "defense_center_port") == 0
5142  || (strcmp (name, "pkcs12_credential") == 0
5143  && !str_equal (param->value, "0")))
5144  xml_string_append (xml, "<data><name>%s</name>%s</data>", name,
5145  param->value ? param->value : "");
5146  }
5147  else
5148  {
5149  gchar *base64;
5150 
5151  /* Special case the pkcs12 file, which is binary. */
5152 
5153  base64 =
5154  (param->value && param->value_size)
5155  ? g_base64_encode ((guchar *) param->value, param->value_size)
5156  : g_strdup ("");
5157  xml_string_append (xml, "<data><name>%s</name>%s</data>", name, base64);
5158  g_free (base64);
5159  }
5160 }

References params_iterator_init, params_iterator_next(), params_iterator_t, params_value(), str_equal(), param::value, and param::value_size.

Referenced by create_alert_gmp(), and save_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ auth_settings_gmp()

char* auth_settings_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Definition at line 14943 of file gsad_gmp.c.

14945 {
14946  GString *xml;
14947  gchar *buf;
14948  const char *name;
14949 
14950  name = params_value (params, "name");
14951 
14952  CHECK_VARIABLE_INVALID (name, "Auth settings");
14953 
14954  xml = g_string_new ("");
14955  buf = g_markup_printf_escaped ("<auth_settings name=\"%s\">", name);
14956  g_string_append (xml, buf);
14957  g_free (buf);
14958 
14959  if (command_enabled (credentials, "DESCRIBE_AUTH"))
14960  {
14961  gchar *response = NULL;
14962  entity_t entity = NULL;
14963 
14964  switch (gmp (connection, credentials, &response, &entity, response_data,
14965  "<describe_auth/>"))
14966  {
14967  case 0:
14968  case -1:
14969  break;
14970  case 1:
14971  cmd_response_data_set_status_code (response_data,
14972  MHD_HTTP_INTERNAL_SERVER_ERROR);
14973  return gsad_message (
14974  credentials, "Internal error", __FUNCTION__, __LINE__,
14975  "An internal error occurred getting the auth list. "
14976  "Diagnostics: Failure to send command to manager daemon.",
14977  response_data);
14978  case 2:
14979  cmd_response_data_set_status_code (response_data,
14980  MHD_HTTP_INTERNAL_SERVER_ERROR);
14981  return gsad_message (
14982  credentials, "Internal error", __FUNCTION__, __LINE__,
14983  "An internal error occurred getting the auth list. "
14984  "Diagnostics: Failure to receive response from manager daemon.",
14985  response_data);
14986  default:
14987  cmd_response_data_set_status_code (response_data,
14988  MHD_HTTP_INTERNAL_SERVER_ERROR);
14989  return gsad_message (
14990  credentials, "Internal error", __FUNCTION__, __LINE__,
14991  "An internal error occurred getting the auth list. "
14992  "Diagnostics: Internal Error.",
14993  response_data);
14994  }
14995 
14996  g_string_append (xml, response);
14997  free_entity (entity);
14998  g_free (response);
14999  }
15000 
15001  g_string_append (xml, "</auth_settings>");
15002 
15003  return envelope_gmp (connection, credentials, params,
15004  g_string_free (xml, FALSE), response_data);
15005 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), command_enabled(), envelope_gmp(), gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ authenticate_gmp()

int authenticate_gmp ( const gchar *  username,
const gchar *  password,
gchar **  role,
gchar **  timezone,
gchar **  severity,
gchar **  capabilities,
gchar **  language,
gchar **  pw_warning 
)

Check authentication credentials.

Parameters
[in]usernameUsername.
[in]passwordPassword.
[out]roleRole.
[out]timezoneTimezone.
[out]severitySeverity class.
[out]capabilitiesCapabilities of manager.
[out]languageUser Interface Language, or NULL.
[out]pw_warningPassword warning message, NULL if password is OK.
Returns
0 if valid, 1 manager down, 2 failed, 3 timeout, -1 error.

Definition at line 17223 of file gsad_gmp.c.

17226 {
17227  gvm_connection_t connection;
17228  int auth;
17229  gmp_authenticate_info_opts_t auth_opts;
17230 
17231  if (gvm_connection_open (&connection, manager_address, manager_port))
17232  {
17233  g_debug ("%s failed to acquire socket!\n", __FUNCTION__);
17234  return 1;
17235  }
17236 
17237  auth_opts = gmp_authenticate_info_opts_defaults;
17238  auth_opts.username = username;
17239  auth_opts.password = password;
17240  auth_opts.role = role;
17241  auth_opts.severity = severity;
17242  auth_opts.timezone = timezone;
17243  auth_opts.pw_warning = pw_warning;
17244 
17245  auth = gmp_authenticate_info_ext_c (&connection, auth_opts);
17246  if (auth == 0)
17247  {
17248  entity_t entity;
17249  const char *status;
17250  char first;
17251  gchar *response;
17252  int ret;
17253 
17254  /* Get language setting. */
17255 
17256  ret = setting_get_value (
17257  &connection, "6765549a-934e-11e3-b358-406186ea4fc5", language, NULL);
17258 
17259  switch (ret)
17260  {
17261  case 0:
17262  break;
17263  case 1:
17264  case 2:
17265  gvm_connection_close (&connection);
17266  return 1;
17267  default:
17268  gvm_connection_close (&connection);
17269  return -1;
17270  }
17271 
17272  /* Request help. */
17273 
17274  ret = gvm_connection_sendf (&connection,
17275  "<help format=\"XML\" type=\"brief\"/>");
17276  if (ret)
17277  {
17278  gvm_connection_close (&connection);
17279  return 1;
17280  }
17281 
17282  /* Read the response. */
17283 
17284  entity = NULL;
17285  if (read_entity_and_text_c (&connection, &entity, &response))
17286  {
17287  gvm_connection_close (&connection);
17288  return 1;
17289  }
17290 
17291  /* Check the response. */
17292 
17293  status = entity_attribute (entity, "status");
17294  if (status == NULL || strlen (status) == 0)
17295  {
17296  g_free (response);
17297  free_entity (entity);
17298  return -1;
17299  }
17300 
17301  first = status[0];
17302  free_entity (entity);
17303 
17304  if (first == '2')
17305  {
17306  *capabilities = response;
17307  }
17308  else
17309  {
17310  gvm_connection_close (&connection);
17311  g_free (response);
17312  return -1;
17313  }
17314 
17315  gvm_connection_close (&connection);
17316  return 0;
17317  }
17318  else
17319  {
17320  gvm_connection_close (&connection);
17321 
17322  switch (auth)
17323  {
17324  case 1: /* manager closed connection */
17325  case 2: /* auth failed */
17326  case 3: /* timeout */
17327  return auth;
17328  default:
17329  return -1;
17330  }
17331  }
17332 }

References gvm_connection_open(), manager_address, manager_port, and setting_get_value().

Referenced by login().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bulk_delete_gmp()

char* bulk_delete_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete multiple resources, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15965 of file gsad_gmp.c.

15967 {
15968  const char *type;
15969  GString *commands_xml;
15970  params_t *selected_ids;
15971  params_iterator_t iter;
15972  param_t *param;
15973  gchar *param_name;
15974  gchar *html, *response;
15975  entity_t entity;
15976  gchar *extra_attribs;
15977 
15978  type = params_value (params, "resource_type");
15979  if (type == NULL)
15980  {
15981  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
15982  return gsad_message (
15983  credentials, "Internal error", __FUNCTION__, __LINE__,
15984  "An internal error occurred while deleting resources. "
15985  "The resources were not deleted. "
15986  "Diagnostics: Required parameter 'resource_type' was NULL.",
15987  response_data);
15988  }
15989 
15990  /* Extra attributes */
15991  extra_attribs = NULL;
15992 
15993  /* Inheritor of user's resource */
15994  if (strcmp (type, "user") == 0)
15995  {
15996  const char *inheritor_id;
15997  inheritor_id = params_value (params, "inheritor_id");
15998  if (inheritor_id)
15999  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
16000  }
16001 
16002  commands_xml = g_string_new ("<commands>");
16003 
16004  selected_ids = params_values (params, "bulk_selected:");
16005  if (selected_ids)
16006  {
16007  params_iterator_init (&iter, selected_ids);
16008  while (params_iterator_next (&iter, &param_name, &param))
16009  {
16010  xml_string_append (commands_xml,
16011  "<delete_%s %s_id=\"%s\" ultimate=\"0\"", type,
16012  type, param_name);
16013  if (extra_attribs)
16014  g_string_append_printf (commands_xml, " %s/>", extra_attribs);
16015  else
16016  g_string_append (commands_xml, "/>");
16017  }
16018  }
16019 
16020  g_string_append (commands_xml, "</commands>");
16021 
16022  /* Delete the resources and get all resources. */
16023 
16024  if (gvm_connection_sendf_xml (connection, commands_xml->str) == -1)
16025  {
16026  g_string_free (commands_xml, TRUE);
16027  cmd_response_data_set_status_code (response_data,
16028  MHD_HTTP_INTERNAL_SERVER_ERROR);
16029  return gsad_message (
16030  credentials, "Internal error", __FUNCTION__, __LINE__,
16031  "An internal error occurred while deleting resources. "
16032  "The resources were not deleted. "
16033  "Diagnostics: Failure to send command to manager daemon.",
16034  response_data);
16035  }
16036  g_string_free (commands_xml, TRUE);
16037 
16038  entity = NULL;
16039  if (read_entity_and_text_c (connection, &entity, &response))
16040  {
16041  cmd_response_data_set_status_code (response_data,
16042  MHD_HTTP_INTERNAL_SERVER_ERROR);
16043  return gsad_message (
16044  credentials, "Internal error", __FUNCTION__, __LINE__,
16045  "An internal error occurred while deleting resources. "
16046  "It is unclear whether the resources have been deleted or not. "
16047  "Diagnostics: Failure to read response from manager daemon.",
16048  response_data);
16049  }
16050 
16051  /* Cleanup, and return transformed XML. */
16052  html = response_from_entity (connection, credentials, params, entity,
16053  "Bulk Delete", response_data);
16054  g_free (response);
16055  free_entity (entity);
16056 
16057  return html;
16058 }

References cmd_response_data_set_status_code(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and response_from_entity().

Here is the call graph for this function:

◆ bulk_export_gmp()

char* bulk_export_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export multiple resources.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16071 of file gsad_gmp.c.

16073 {
16074  const gchar *type, *filter, *bulk_select;
16075  gchar *param_name;
16076  GString *bulk_string;
16077  params_t *selected_ids;
16078  params_iterator_t iter;
16079  param_t *param;
16080 
16081  type = params_value (params, "resource_type");
16082  filter = params_value (params, "filter");
16083  bulk_select = params_value (params, "bulk_select");
16084 
16085  CHECK_VARIABLE_INVALID (type, "Bulk Export")
16086  CHECK_VARIABLE_INVALID (bulk_select, "Bulk Export")
16087 
16088  if (bulk_select && str_equal (bulk_select, "1"))
16089  {
16090  bulk_string = g_string_new ("first=1 rows=-1 uuid=");
16091 
16092  selected_ids = params_values (params, "bulk_selected:");
16093  if (selected_ids)
16094  {
16095  params_iterator_init (&iter, selected_ids);
16096  while (params_iterator_next (&iter, &param_name, &param))
16097  {
16098  xml_string_append (bulk_string, " uuid=%s", param_name);
16099  }
16100  }
16101  }
16102  else
16103  {
16104  bulk_string = g_string_new (filter ?: "");
16105  }
16106 
16107  params_add (params, "filter", g_string_free (bulk_string, FALSE));
16108 
16109  return export_many (connection, type, credentials, params, response_data);
16110 }

References CHECK_VARIABLE_INVALID, export_many(), params_add(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and str_equal().

Here is the call graph for this function:

◆ check_modify_config()

static char* check_modify_config ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  next,
const char *  fail_next,
int *  success,
cmd_response_data_t *  response_data 
)
static

Check a modify_config response.

Parameters
[in]connectionConnection with manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsHTTP request parameters.
[in]nextNext page command on success.
[in]fail_nextNext page command on failure.
[out]successWhether the command returned a success response.
[out]response_dataExtra data return for the HTTP response.
Returns
Error message on failure, NULL on success.
Todo:
This would be much easier with real error codes.

Definition at line 440 of file gsad_gmp.c.

443 {
444  entity_t entity;
445  gchar *response;
446  const char *status_text;
447 
448  if (success)
449  *success = 0;
450 
453  /* Read the response. */
454 
455  if (read_entity_c (connection, &entity))
456  {
457  cmd_response_data_set_status_code (response_data,
458  MHD_HTTP_INTERNAL_SERVER_ERROR);
459  return gsad_message (
460  credentials, "Internal error", __FUNCTION__, __LINE__,
461  "An internal error occurred while saving a config. "
462  "It is unclear whether the entire config has been saved. "
463  "Diagnostics: Failure to read command to manager daemon.",
464  response_data);
465  }
466 
467  /* Check the response. */
468 
469  status_text = entity_attribute (entity, "status_text");
470  if (status_text == NULL)
471  {
472  free_entity (entity);
473  cmd_response_data_set_status_code (response_data,
474  MHD_HTTP_INTERNAL_SERVER_ERROR);
475  return gsad_message (
476  credentials, "Internal error", __FUNCTION__, __LINE__,
477  "An internal error occurred while saving a config. "
478  "It is unclear whether the entire config has been saved. "
479  "Diagnostics: Failure to parse status_text from response.",
480  response_data);
481  }
482 
483  if (str_equal (status_text, "Config is in use"))
484  {
485  const char *message = "The config is now in use by a task,"
486  " so only name and comment can be modified.";
487 
488  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
489  response = action_result (connection, credentials, params, response_data,
490  "Save Config", message, NULL, NULL);
491 
492  free_entity (entity);
493  return response;
494  }
495  else if (str_equal (status_text, "MODIFY_CONFIG name must be unique"))
496  {
497  const char *message = "A config with the given name exists already.";
498 
499  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
500  response = action_result (connection, credentials, params, response_data,
501  "Save Config", message, NULL, NULL);
502 
503  free_entity (entity);
504  return response;
505  }
506  else if (success && gmp_success (entity))
507  {
508  *success = 1;
509  }
510 
511  response = response_from_entity (connection, credentials, params, entity,
512  "Save Config", response_data);
513  free_entity (entity);
514 
515  return response;
516 }

References action_result(), cmd_response_data_set_status_code(), gmp_success(), gsad_message(), response_from_entity(), and str_equal().

Referenced by save_config_family_gmp(), save_config_gmp(), save_config_nvt_gmp(), and save_osp_prefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone_gmp()

char* clone_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Clone a resource, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6078 of file gsad_gmp.c.

6080 {
6081  gchar *html, *response;
6082  const char *id, *type, *alterable;
6083  entity_t entity;
6084 
6085  id = params_value (params, "id");
6086  type = params_value (params, "resource_type");
6087  alterable = params_value (params, "alterable");
6088 
6089  CHECK_VARIABLE_INVALID (id, "Clone");
6090  CHECK_VARIABLE_INVALID (type, "Clone");
6091 
6092  /* Clone the resource. */
6093 
6094  if (alterable && strcmp (alterable, "0"))
6095  {
6096  if (gvm_connection_sendf (connection,
6097  "<create_%s>"
6098  "<copy>%s</copy>"
6099  "<alterable>1</alterable>"
6100  "</create_%s>",
6101  type, id, type)
6102  == -1)
6103  {
6104  cmd_response_data_set_status_code (response_data,
6105  MHD_HTTP_INTERNAL_SERVER_ERROR);
6106  return gsad_message (
6107  credentials, "Internal error", __FUNCTION__, __LINE__,
6108  "An internal error occurred while cloning a resource. "
6109  "The resource was not cloned. "
6110  "Diagnostics: Failure to send command to manager daemon.",
6111  response_data);
6112  }
6113  }
6114  else if (gvm_connection_sendf (connection,
6115  "<create_%s>"
6116  "<copy>%s</copy>"
6117  "</create_%s>",
6118  type, id, type)
6119  == -1)
6120  {
6121  cmd_response_data_set_status_code (response_data,
6122  MHD_HTTP_INTERNAL_SERVER_ERROR);
6123  return gsad_message (
6124  credentials, "Internal error", __FUNCTION__, __LINE__,
6125  "An internal error occurred while cloning a resource. "
6126  "The resource was not cloned. "
6127  "Diagnostics: Failure to send command to manager daemon.",
6128  response_data);
6129  }
6130 
6131  entity = NULL;
6132  if (read_entity_and_text_c (connection, &entity, &response))
6133  {
6134  cmd_response_data_set_status_code (response_data,
6135  MHD_HTTP_INTERNAL_SERVER_ERROR);
6136  return gsad_message (
6137  credentials, "Internal error", __FUNCTION__, __LINE__,
6138  "An internal error occurred while cloning a resource. "
6139  "It is unclear whether the resource has been cloned or not. "
6140  "Diagnostics: Failure to read response from manager daemon.",
6141  response_data);
6142  }
6143 
6144  /* Cleanup, and return next page. */
6145  html = response_from_entity (connection, credentials, params, entity, "Clone",
6146  response_data);
6147 
6148  free_entity (entity);
6149  g_free (response);
6150 
6151  return html;
6152 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ command_enabled()

int command_enabled ( credentials_t *  credentials,
const gchar *  name 
)

Init the GSA GMP library.

Parameters
[in]credentialsCredentials.
[in]nameCommand name.

Definition at line 261 of file gsad_gmp.c.

262 {
263  /* TODO Hack. Fails if command named in summary of another command. */
264  user_t *user =
265  credentials_get_user (credentials); // TODO pass user_t directly
266  return strstr (user_get_capabilities (user), name) ? 1 : 0;
267 }

References credentials_get_user(), and user_get_capabilities().

Referenced by auth_settings_gmp(), edit_alert(), get_system_reports_gmp(), and get_user().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_unix()

int connect_unix ( const gchar *  path)

Connect to Greenbone Vulnerability Manager daemon.

Parameters
[in]pathPath to the Manager socket.
Returns
Socket, or -1 on error.

Definition at line 17146 of file gsad_gmp.c.

17147 {
17148  struct sockaddr_un address;
17149  int sock;
17150 
17151  /* Make socket. */
17152 
17153  sock = socket (AF_UNIX, SOCK_STREAM, 0);
17154  if (sock == -1)
17155  {
17156  g_warning ("Failed to create server socket");
17157  return -1;
17158  }
17159 
17160  /* Connect to server. */
17161 
17162  address.sun_family = AF_UNIX;
17163  strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
17164  if (connect (sock, (struct sockaddr *) &address, sizeof (address)) == -1)
17165  {
17166  g_warning ("Failed to connect to server at %s: %s", path,
17167  strerror (errno));
17168  close (sock);
17169  return -1;
17170  }
17171 
17172  return sock;
17173 }

Referenced by gvm_connection_open().

Here is the caller graph for this function:

◆ create_agent_gmp()

char* create_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create an agent, get all agents, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3926 of file gsad_gmp.c.

3928 {
3929  entity_t entity;
3930  gchar *response, *html;
3931  const char *name, *comment, *installer, *installer_filename, *installer_sig;
3932  const char *howto_install, *howto_use;
3933  int installer_size, installer_sig_size, howto_install_size, howto_use_size;
3934  int ret;
3935  gchar *name_escaped, *comment_escaped;
3936  gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
3937  gchar *command;
3938 
3939  name = params_value (params, "name");
3940  comment = params_value (params, "comment");
3941  installer = params_value (params, "installer");
3942  installer_filename = params_filename (params, "installer");
3943  installer_size = params_value_size (params, "installer");
3944  installer_sig = params_value (params, "installer_sig");
3945  installer_sig_size = params_value_size (params, "installer_sig");
3946  howto_install = params_value (params, "howto_install");
3947  howto_install_size = params_value_size (params, "howto_install");
3948  howto_use = params_value (params, "howto_use");
3949  howto_use_size = params_value_size (params, "howto_use");
3950 
3951  CHECK_VARIABLE_INVALID (name, "Create Agent");
3952  CHECK_VARIABLE_INVALID (comment, "Create Agent");
3953 
3954  /* Create the agent. */
3955 
3956  installer_64 = (installer_size > 0)
3957  ? g_base64_encode ((guchar *) installer, installer_size)
3958  : g_strdup ("");
3959 
3960  installer_sig_64 =
3961  (installer_sig_size > 0)
3962  ? g_base64_encode ((guchar *) installer_sig, installer_sig_size)
3963  : g_strdup ("");
3964 
3965  howto_install_64 =
3966  (howto_install_size > 0)
3967  ? g_base64_encode ((guchar *) howto_install, howto_install_size)
3968  : g_strdup ("");
3969 
3970  howto_use_64 = (howto_use_size > 0)
3971  ? g_base64_encode ((guchar *) howto_use, howto_use_size)
3972  : g_strdup ("");
3973 
3974  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
3975  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
3976 
3977  command = g_strdup_printf ("<create_agent>"
3978  "<name>%s</name>"
3979  "%s%s%s"
3980  "<installer>"
3981  "%s"
3982  "<signature>%s</signature>"
3983  "<filename>%s</filename>"
3984  "</installer>"
3985  "<howto_install>%s</howto_install>"
3986  "<howto_use>%s</howto_use>"
3987  "</create_agent>",
3988  name_escaped, comment_escaped ? "<comment>" : "",
3989  comment_escaped ? comment_escaped : "",
3990  comment_escaped ? "</comment>" : "", installer_64,
3991  installer_sig_64,
3992  installer_filename ? installer_filename : "",
3993  howto_install_64, howto_use_64);
3994 
3995  ret =
3996  gmp (connection, credentials, &response, &entity, response_data, command);
3997  g_free (command);
3998 
3999  g_free (installer_64);
4000  g_free (howto_install_64);
4001  g_free (howto_use_64);
4002  g_free (name_escaped);
4003  g_free (comment_escaped);
4004 
4005  switch (ret)
4006  {
4007  case 0:
4008  break;
4009  case -1:
4010  /* 'gmp' set response. */
4011  return response;
4012  case 1:
4013  cmd_response_data_set_status_code (response_data,
4014  MHD_HTTP_INTERNAL_SERVER_ERROR);
4015  return gsad_message (
4016  credentials, "Internal error", __FUNCTION__, __LINE__,
4017  "An internal error occurred while creating a new agent. "
4018  "No new agent was created. "
4019  "Diagnostics: Failure to send command to manager daemon.",
4020  response_data);
4021  case 2:
4022  cmd_response_data_set_status_code (response_data,
4023  MHD_HTTP_INTERNAL_SERVER_ERROR);
4024  return gsad_message (
4025  credentials, "Internal error", __FUNCTION__, __LINE__,
4026  "An internal error occurred while creating a new agent. "
4027  "It is unclear whether the agent has been created or not. "
4028  "Diagnostics: Failure to receive response from manager daemon.",
4029  response_data);
4030  default:
4031  cmd_response_data_set_status_code (response_data,
4032  MHD_HTTP_INTERNAL_SERVER_ERROR);
4033  return gsad_message (
4034  credentials, "Internal error", __FUNCTION__, __LINE__,
4035  "An internal error occurred while creating a new agent. "
4036  "It is unclear whether the agent has been created or not. "
4037  "Diagnostics: Internal Error.",
4038  response_data);
4039  }
4040 
4041  if (entity_attribute (entity, "id"))
4042  params_add (params, "agent_id", entity_attribute (entity, "id"));
4043  html = response_from_entity (connection, credentials, params, entity,
4044  "Create Agent", response_data);
4045  free_entity (entity);
4046  g_free (response);
4047  return html;
4048 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_filename(), params_value(), params_value_size(), and response_from_entity().

Here is the call graph for this function:

◆ create_alert_gmp()

char* create_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create an alert, get all alerts, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5173 of file gsad_gmp.c.

5175 {
5176  int ret;
5177  gchar *html, *response;
5178  const char *name, *comment, *active, *condition, *event, *method, *filter_id;
5179  params_t *method_data, *event_data, *condition_data, *report_formats;
5180  entity_t entity;
5181  GString *xml;
5182 
5183  name = params_value (params, "name");
5184  comment = params_value (params, "comment");
5185  active = params_value (params, "active");
5186  condition = params_value (params, "condition");
5187  event = params_value (params, "event");
5188  method = params_value (params, "method");
5189  filter_id = params_value (params, "filter_id");
5190 
5191  CHECK_VARIABLE_INVALID (name, "Create Alert");
5192  CHECK_VARIABLE_INVALID (active, "Create Alert");
5193  CHECK_VARIABLE_INVALID (comment, "Create Alert");
5194  CHECK_VARIABLE_INVALID (condition, "Create Alert");
5195  CHECK_VARIABLE_INVALID (event, "Create Alert");
5196  CHECK_VARIABLE_INVALID (method, "Create Alert");
5197 
5198  /* Create the alert. */
5199 
5200  method_data = params_values (params, "method_data:");
5201  event_data = params_values (params, "event_data:");
5202  condition_data = params_values (params, "condition_data:");
5203  report_formats = params_values (params, "report_format_ids:");
5204 
5205  xml = g_string_new ("");
5206 
5207  if (str_equal (event, EVENT_TYPE_NEW_SECINFO) && event_data)
5208  {
5209  params_iterator_t iter;
5210  char *name;
5211  param_t *param;
5212 
5213  params_iterator_init (&iter, event_data);
5214  while (params_iterator_next (&iter, &name, &param))
5215  if (str_equal (name, "feed_event") && param->value
5216  && str_equal (param->value, "updated"))
5217  {
5219  break;
5220  }
5221  }
5222 
5223  xml_string_append (xml,
5224  "<create_alert>"
5225  "<name>%s</name>"
5226  "<filter id=\"%s\"/>"
5227  "<active>%s</active>"
5228  "<comment>%s</comment>"
5229  "<event>%s",
5230  name, filter_id ? filter_id : FILT_ID_NONE, active,
5231  comment ? comment : "", event);
5232 
5233  append_alert_event_data (xml, event_data, event);
5234 
5235  xml_string_append (xml,
5236  "</event>"
5237  "<method>%s",
5238  method);
5239 
5240  append_alert_method_data (xml, method_data, method, report_formats);
5241 
5242  xml_string_append (xml,
5243  "</method>"
5244  "<condition>%s",
5245  condition);
5246 
5247  append_alert_condition_data (xml, condition_data, condition);
5248 
5249  xml_string_append (xml, "</condition>"
5250  "</create_alert>");
5251 
5252  ret =
5253  gmp (connection, credentials, &response, &entity, response_data, xml->str);
5254  g_string_free (xml, TRUE);
5255  switch (ret)
5256  {
5257  case 0:
5258  case -1:
5259  break;
5260  case 1:
5261  cmd_response_data_set_status_code (response_data,
5262  MHD_HTTP_INTERNAL_SERVER_ERROR);
5263  return gsad_message (
5264  credentials, "Internal error", __FUNCTION__, __LINE__,
5265  "An internal error occurred while creating a new alert. "
5266  "No new alert was created. "
5267  "Diagnostics: Failure to send command to manager daemon.",
5268  response_data);
5269  case 2:
5270  cmd_response_data_set_status_code (response_data,
5271  MHD_HTTP_INTERNAL_SERVER_ERROR);
5272  return gsad_message (
5273  credentials, "Internal error", __FUNCTION__, __LINE__,
5274  "An internal error occurred while creating a new alert. "
5275  "It is unclear whether the alert has been created or not. "
5276  "Diagnostics: Failure to receive response from manager daemon.",
5277  response_data);
5278  default:
5279  cmd_response_data_set_status_code (response_data,
5280  MHD_HTTP_INTERNAL_SERVER_ERROR);
5281  return gsad_message (
5282  credentials, "Internal error", __FUNCTION__, __LINE__,
5283  "An internal error occurred while creating a new alert. "
5284  "It is unclear whether the alert has been created or not. "
5285  "Diagnostics: Internal Error.",
5286  response_data);
5287  }
5288 
5289  if (entity_attribute (entity, "id"))
5290  params_add (params, "alert_id", entity_attribute (entity, "id"));
5291  html = response_from_entity (connection, credentials, params, entity,
5292  "Create Alert", response_data);
5293  free_entity (entity);
5294  g_free (response);
5295  return html;
5296 }

References append_alert_condition_data(), append_alert_event_data(), append_alert_method_data(), CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), EVENT_TYPE_NEW_SECINFO, EVENT_TYPE_UPDATED_SECINFO, FILT_ID_NONE, gmp(), gsad_message(), params_add(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), str_equal(), and param::value.

Here is the call graph for this function:

◆ create_asset_gmp()

char* create_asset_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create an asset, get report, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16311 of file gsad_gmp.c.

16313 {
16314  char *ret;
16315  gchar *response;
16316  const char *report_id, *filter;
16317  entity_t entity;
16318 
16319  report_id = params_value (params, "report_id");
16320  filter = params_value (params, "filter");
16321 
16322  CHECK_VARIABLE_INVALID (report_id, "Create Asset");
16323  CHECK_VARIABLE_INVALID (filter, "Create Asset");
16324 
16325  response = NULL;
16326  entity = NULL;
16327  switch (gmpf (connection, credentials, &response, &entity, response_data,
16328  "<create_asset>"
16329  "<report id=\"%s\">"
16330  "<filter><term>%s</term></filter>"
16331  "</report>"
16332  "</create_asset>",
16333  report_id, filter))
16334  {
16335  case 0:
16336  case -1:
16337  break;
16338  case 1:
16339  cmd_response_data_set_status_code (response_data,
16340  MHD_HTTP_INTERNAL_SERVER_ERROR);
16341  return gsad_message (
16342  credentials, "Internal error", __FUNCTION__, __LINE__,
16343  "An internal error occurred while creating an asset. "
16344  "No new asset was created. "
16345  "Diagnostics: Failure to send command to manager daemon.",
16346  response_data);
16347  case 2:
16348  cmd_response_data_set_status_code (response_data,
16349  MHD_HTTP_INTERNAL_SERVER_ERROR);
16350  return gsad_message (
16351  credentials, "Internal error", __FUNCTION__, __LINE__,
16352  "An internal error occurred while creating an asset. "
16353  "It is unclear whether the asset has been created or not. "
16354  "Diagnostics: Failure to receive response from manager daemon.",
16355  response_data);
16356  default:
16357  cmd_response_data_set_status_code (response_data,
16358  MHD_HTTP_INTERNAL_SERVER_ERROR);
16359  return gsad_message (
16360  credentials, "Internal error", __FUNCTION__, __LINE__,
16361  "An internal error occurred while creating an asset. "
16362  "It is unclear whether the asset has been created or not. "
16363  "Diagnostics: Internal Error.",
16364  response_data);
16365  }
16366 
16367  ret = response_from_entity (connection, credentials, params, entity,
16368  "Create Asset", response_data);
16369  free_entity (entity);
16370  g_free (response);
16371  return ret;
16372 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_config_gmp()

char* create_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create config, get all configs, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7061 of file gsad_gmp.c.

7063 {
7064  gchar *html, *response;
7065  const char *name, *comment, *base, *usage_type, *scanner = NULL;
7066  entity_t entity;
7067 
7068  name = params_value (params, "name");
7069  comment = params_value (params, "comment");
7070  base = params_value (params, "base");
7071  usage_type = params_value (params, "usage_type");
7072 
7073  CHECK_VARIABLE_INVALID (name, "New Config");
7074  CHECK_VARIABLE_INVALID (comment, "New Config");
7075  CHECK_VARIABLE_INVALID (base, "New Config");
7076  CHECK_VARIABLE_INVALID (usage_type, "New Config");
7077  if (str_equal (base, "0"))
7078  {
7079  scanner = params_value (params, "scanner_id");
7080  CHECK_VARIABLE_INVALID (scanner, "New Config");
7081  }
7082 
7083  /* Create the config. */
7084  switch (gmpf (connection, credentials, &response, &entity, response_data,
7085  "<create_config>"
7086  "<name>%s</name>"
7087  "<copy>%s</copy>"
7088  "<comment>%s</comment>"
7089  "<scanner>%s</scanner>"
7090  "<usage_type>%s</usage_type>"
7091  "</create_config>",
7092  name, base, comment, scanner ?: "", usage_type))
7093  {
7094  case 0:
7095  case -1:
7096  break;
7097  case 1:
7098  cmd_response_data_set_status_code (response_data,
7099  MHD_HTTP_INTERNAL_SERVER_ERROR);
7100  return gsad_message (
7101  credentials, "Internal error", __FUNCTION__, __LINE__,
7102  "An internal error occurred while creating a new config. "
7103  "No new config was created. "
7104  "Diagnostics: Failure to send command to manager daemon.",
7105  response_data);
7106  case 2:
7107  cmd_response_data_set_status_code (response_data,
7108  MHD_HTTP_INTERNAL_SERVER_ERROR);
7109  return gsad_message (
7110  credentials, "Internal error", __FUNCTION__, __LINE__,
7111  "An internal error occurred while creating a new config. "
7112  "It is unclear whether the config has been created or not. "
7113  "Diagnostics: Failure to receive response from manager daemon.",
7114  response_data);
7115  default:
7116  cmd_response_data_set_status_code (response_data,
7117  MHD_HTTP_INTERNAL_SERVER_ERROR);
7118  return gsad_message (
7119  credentials, "Internal error", __FUNCTION__, __LINE__,
7120  "An internal error occurred while creating a new config. "
7121  "It is unclear whether the config has been created or not. "
7122  "Diagnostics: Internal Error.",
7123  response_data);
7124  }
7125 
7126  if (entity_attribute (entity, "id"))
7127  params_add (params, "config_id", entity_attribute (entity, "id"));
7128  html = response_from_entity (connection, credentials, params, entity,
7129  "Create Config", response_data);
7130 
7131  free_entity (entity);
7132  g_free (response);
7133  return html;
7134 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_value(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ create_container_task_gmp()

char* create_container_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a container task, serve next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2037 of file gsad_gmp.c.

2040 {
2041  entity_t entity;
2042  int ret;
2043  gchar *command, *html, *response;
2044  const char *name, *comment, *usage_type;
2045 
2046  name = params_value (params, "name");
2047  comment = params_value (params, "comment");
2048  usage_type = params_value (params, "usage_type");
2049 
2050  CHECK_VARIABLE_INVALID (name, "Create Container Task");
2051  CHECK_VARIABLE_INVALID (comment, "Create Container Task");
2052  CHECK_VARIABLE_INVALID (usage_type, "Create Container Task");
2053 
2054  command = g_markup_printf_escaped ("<create_task>"
2055  "<target id=\"0\"/>"
2056  "<name>%s</name>"
2057  "<comment>%s</comment>"
2058  "<usage_type>%s</usage_type>"
2059  "</create_task>",
2060  name, comment, usage_type);
2061  ret =
2062  gmp (connection, credentials, &response, &entity, response_data, command);
2063  g_free (command);
2064 
2065  switch (ret)
2066  {
2067  case 0:
2068  break;
2069  case -1:
2070  /* 'gmp' set response. */
2071  return response;
2072  case 1:
2073  cmd_response_data_set_status_code (response_data,
2074  MHD_HTTP_INTERNAL_SERVER_ERROR);
2075  return gsad_message (
2076  credentials, "Internal error", __FUNCTION__, __LINE__,
2077  "An internal error occurred while creating a container task. "
2078  "No task was created. "
2079  "Diagnostics: Failure to send command to manager daemon.",
2080  response_data);
2081  case 2:
2082  cmd_response_data_set_status_code (response_data,
2083  MHD_HTTP_INTERNAL_SERVER_ERROR);
2084  return gsad_message (
2085  credentials, "Internal error", __FUNCTION__, __LINE__,
2086  "An internal error occurred while creating a container task. "
2087  "It is unclear whether the task has been created or not. "
2088  "Diagnostics: Failure to receive response from manager daemon.",
2089  response_data);
2090  default:
2091  cmd_response_data_set_status_code (response_data,
2092  MHD_HTTP_INTERNAL_SERVER_ERROR);
2093  return gsad_message (
2094  credentials, "Internal error", __FUNCTION__, __LINE__,
2095  "An internal error occurred while creating a container task. "
2096  "It is unclear whether the task has been created or not. "
2097  "Diagnostics: Internal Error.",
2098  response_data);
2099  }
2100 
2101  if (entity_attribute (entity, "id"))
2102  params_add (params, "task_id", entity_attribute (entity, "id"));
2103  html = response_from_entity (connection, credentials, params, entity,
2104  "Create Container Task", response_data);
2105  free_entity (entity);
2106  g_free (response);
2107  return html;
2108 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_credential_gmp()

char* create_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a credential, get all credentials, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3082 of file gsad_gmp.c.

3084 {
3085  int ret;
3086  gchar *html, *response;
3087  const char *name, *comment, *login, *type, *password, *passphrase;
3088  const char *private_key, *public_key, *certificate, *community;
3089  const char *privacy_password, *auth_algorithm, *privacy_algorithm;
3090  const char *autogenerate, *allow_insecure;
3091  entity_t entity;
3092 
3093  name = params_value (params, "name");
3094  comment = params_value (params, "comment");
3095  login = params_value (params, "credential_login");
3096  type = params_value (params, "credential_type");
3097  password = params_value (params, "lsc_password");
3098  passphrase = params_value (params, "passphrase");
3099  private_key = params_value (params, "private_key");
3100  public_key = params_value (params, "public_key");
3101  certificate = params_value (params, "certificate");
3102  community = params_value (params, "community");
3103  privacy_password = params_value (params, "privacy_password");
3104  auth_algorithm = params_value (params, "auth_algorithm");
3105  privacy_algorithm = params_value (params, "privacy_algorithm");
3106  allow_insecure = params_value (params, "allow_insecure");
3107  autogenerate = params_value (params, "autogenerate");
3108 
3109  CHECK_VARIABLE_INVALID (name, "Create Credential");
3110  CHECK_VARIABLE_INVALID (comment, "Create Credential");
3111  CHECK_VARIABLE_INVALID (type, "Create Credential");
3112  CHECK_VARIABLE_INVALID (allow_insecure, "Create Credential");
3113  CHECK_VARIABLE_INVALID (autogenerate, "Create Credential");
3114 
3115  if (str_equal (autogenerate, "1"))
3116  {
3117  if (str_equal (type, "cc"))
3118  {
3119  // Auto-generate types without username
3120  ret =
3121  gmpf (connection, credentials, &response, &entity, response_data,
3122  "<create_credential>"
3123  "<name>%s</name>"
3124  "<comment>%s</comment>"
3125  "<type>%s</type>"
3126  "<allow_insecure>%s</allow_insecure>"
3127  "</create_credential>",
3128  name, comment ? comment : "", type, allow_insecure);
3129  }
3130  else
3131  {
3132  // Auto-generate types with username
3133  CHECK_VARIABLE_INVALID (login, "Create Credential");
3134 
3135  ret =
3136  gmpf (connection, credentials, &response, &entity, response_data,
3137  "<create_credential>"
3138  "<name>%s</name>"
3139  "<comment>%s</comment>"
3140  "<type>%s</type>"
3141  "<login>%s</login>"
3142  "<allow_insecure>%s</allow_insecure>"
3143  "</create_credential>",
3144  name, comment ? comment : "", type, login, allow_insecure);
3145  }
3146  }
3147  else
3148  {
3149  if (str_equal (type, "up"))
3150  {
3151  CHECK_VARIABLE_INVALID (login, "Create Credential");
3152  CHECK_VARIABLE_INVALID (password, "Create Credential");
3153 
3154  ret =
3155  gmpf (connection, credentials, &response, &entity, response_data,
3156  "<create_credential>"
3157  "<name>%s</name>"
3158  "<comment>%s</comment>"
3159  "<type>%s</type>"
3160  "<login>%s</login>"
3161  "<password>%s</password>"
3162  "<allow_insecure>%s</allow_insecure>"
3163  "</create_credential>",
3164  name, comment ? comment : "", type, login ? login : "",
3165  password ? password : "", allow_insecure);
3166  }
3167  else if (str_equal (type, "usk"))
3168  {
3169  CHECK_VARIABLE_INVALID (login, "Create Credential");
3170  CHECK_VARIABLE_INVALID (passphrase, "Create Credential");
3171  CHECK_VARIABLE_INVALID (private_key, "Create Credential");
3172 
3173  ret =
3174  gmpf (connection, credentials, &response, &entity, response_data,
3175  "<create_credential>"
3176  "<name>%s</name>"
3177  "<comment>%s</comment>"
3178  "<type>%s</type>"
3179  "<login>%s</login>"
3180  "<key>"
3181  "<private>%s</private>"
3182  "<phrase>%s</phrase>"
3183  "</key>"
3184  "<allow_insecure>%s</allow_insecure>"
3185  "</create_credential>",
3186  name, comment ? comment : "", type, login ? login : "",
3187  private_key ? private_key : "", passphrase ? passphrase : "",
3188  allow_insecure);
3189  }
3190  else if (str_equal (type, "cc"))
3191  {
3192  CHECK_VARIABLE_INVALID (certificate, "Create Credential");
3193  CHECK_VARIABLE_INVALID (passphrase, "Create Credential");
3194  CHECK_VARIABLE_INVALID (private_key, "Create Credential");
3195 
3196  ret = gmpf (
3197  connection, credentials, &response, &entity, response_data,
3198  "<create_credential>"
3199  "<name>%s</name>"
3200  "<comment>%s</comment>"
3201  "<type>%s</type>"
3202  "<certificate>%s</certificate>"
3203  "<key>"
3204  "<private>%s</private>"
3205  "<phrase>%s</phrase>"
3206  "</key>"
3207  "<allow_insecure>%s</allow_insecure>"
3208  "</create_credential>",
3209  name, comment ? comment : "", type, certificate ? certificate : "",
3210  private_key ? private_key : "", passphrase ? passphrase : "",
3211  allow_insecure);
3212  }
3213  else if (str_equal (type, "snmp"))
3214  {
3215  CHECK_VARIABLE_INVALID (community, "Create Credential");
3216  CHECK_VARIABLE_INVALID (login, "Create Credential");
3217  CHECK_VARIABLE_INVALID (password, "Create Credential");
3218  CHECK_VARIABLE_INVALID (privacy_password, "Create Credential");
3219  CHECK_VARIABLE_INVALID (auth_algorithm, "Create Credential");
3220  CHECK_VARIABLE_INVALID (privacy_algorithm, "Create Credential");
3221 
3222  if (privacy_password && strcmp (privacy_password, ""))
3223  ret = gmpf (
3224  connection, credentials, &response, &entity, response_data,
3225  "<create_credential>"
3226  "<name>%s</name>"
3227  "<comment>%s</comment>"
3228  "<type>%s</type>"
3229  "<community>%s</community>"
3230  "<login>%s</login>"
3231  "<password>%s</password>"
3232  "<privacy>"
3233  "<password>%s</password>"
3234  "<algorithm>%s</algorithm>"
3235  "</privacy>"
3236  "<auth_algorithm>%s</auth_algorithm>"
3237  "<allow_insecure>%s</allow_insecure>"
3238  "</create_credential>",
3239  name, comment ? comment : "", type, community ? community : "",
3240  login ? login : "", password ? password : "",
3241  privacy_password ? privacy_password : "",
3242  privacy_algorithm ? privacy_algorithm : "",
3243  auth_algorithm ? auth_algorithm : "", allow_insecure);
3244  else
3245  ret = gmpf (
3246  connection, credentials, &response, &entity, response_data,
3247  "<create_credential>"
3248  "<name>%s</name>"
3249  "<comment>%s</comment>"
3250  "<type>%s</type>"
3251  "<community>%s</community>"
3252  "<login>%s</login>"
3253  "<password>%s</password>"
3254  "<auth_algorithm>%s</auth_algorithm>"
3255  "<allow_insecure>%s</allow_insecure>"
3256  "</create_credential>",
3257  name, comment ? comment : "", type, community ? community : "",
3258  login ? login : "", password ? password : "",
3259  auth_algorithm ? auth_algorithm : "", allow_insecure);
3260  }
3261  else if (str_equal (type, "pgp"))
3262  {
3263  CHECK_VARIABLE_INVALID (public_key, "Create Credential");
3264 
3265  ret = gmpf (
3266  connection, credentials, &response, &entity, response_data,
3267  "<create_credential>"
3268  "<name>%s</name>"
3269  "<comment>%s</comment>"
3270  "<type>%s</type>"
3271  "<key>"
3272  "<public>%s</public>"
3273  "</key>"
3274  "<allow_insecure>%s</allow_insecure>"
3275  "</create_credential>",
3276  name, comment ? comment : "", type, public_key, allow_insecure);
3277  }
3278  else if (str_equal (type, "smime"))
3279  {
3280  CHECK_VARIABLE_INVALID (certificate, "Create Credential");
3281 
3282  ret = gmpf (
3283  connection, credentials, &response, &entity, response_data,
3284  "<create_credential>"
3285  "<name>%s</name>"
3286  "<comment>%s</comment>"
3287  "<type>%s</type>"
3288  "<certificate>%s</certificate>"
3289  "<allow_insecure>%s</allow_insecure>"
3290  "</create_credential>",
3291  name, comment ? comment : "", type, certificate, allow_insecure);
3292  }
3293  else if (type && (strcmp (type, "pw") == 0))
3294  {
3295  CHECK_VARIABLE_INVALID (password, "Create Credential");
3296 
3297  ret =
3298  gmpf (connection, credentials, &response, &entity, response_data,
3299  "<create_credential>"
3300  "<name>%s</name>"
3301  "<comment>%s</comment>"
3302  "<type>%s</type>"
3303  "<password>%s</password>"
3304  "<allow_insecure>%s</allow_insecure>"
3305  "</create_credential>",
3306  name, comment ? comment : "", type, password ? password : "",
3307  allow_insecure);
3308  }
3309  else
3310  {
3311  cmd_response_data_set_status_code (response_data,
3312  MHD_HTTP_INTERNAL_SERVER_ERROR);
3313  return gsad_message (
3314  credentials, "Internal error", __FUNCTION__, __LINE__,
3315  "An internal error occurred while creating a new credential. "
3316  "The credential could not be created. "
3317  "Diagnostics: Unrecognized credential type.",
3318  response_data);
3319  }
3320  }
3321 
3322  /* Create the credential. */
3323  switch (ret)
3324  {
3325  case 0:
3326  case -1:
3327  break;
3328  case 1:
3329  cmd_response_data_set_status_code (response_data,
3330  MHD_HTTP_INTERNAL_SERVER_ERROR);
3331  return gsad_message (
3332  credentials, "Internal error", __FUNCTION__, __LINE__,
3333  "An internal error occurred while creating a new credential. "
3334  "It is unclear whether the credential has been created or not. "
3335  "Diagnostics: Failure to send command to manager daemon.",
3336  response_data);
3337  case 2:
3338  cmd_response_data_set_status_code (response_data,
3339  MHD_HTTP_INTERNAL_SERVER_ERROR);
3340  return gsad_message (
3341  credentials, "Internal error", __FUNCTION__, __LINE__,
3342  "An internal error occurred while creating a new credential. "
3343  "It is unclear whether the credential has been created or not. "
3344  "Diagnostics: Failure to receive response from manager daemon.",
3345  response_data);
3346  default:
3347  cmd_response_data_set_status_code (response_data,
3348  MHD_HTTP_INTERNAL_SERVER_ERROR);
3349  return gsad_message (
3350  credentials, "Internal error", __FUNCTION__, __LINE__,
3351  "An internal error occurred while creating a new credential. "
3352  "It is unclear whether the credential has been created or not. "
3353  "Diagnostics: Internal Error.",
3354  response_data);
3355  }
3356 
3357  if (entity_attribute (entity, "id"))
3358  params_add (params, "credential_id", entity_attribute (entity, "id"));
3359  html = response_from_entity (connection, credentials, params, entity,
3360  "Create Credential", response_data);
3361  free_entity (entity);
3362  g_free (response);
3363  return html;
3364 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), login(), params_add(), params_value(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ create_filter_gmp()

char* create_filter_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a filter, get all filters, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14306 of file gsad_gmp.c.

14308 {
14309  gchar *html, *response;
14310  const char *name, *comment, *term, *type;
14311  entity_t entity;
14312 
14313  name = params_value (params, "name");
14314  comment = params_value (params, "comment");
14315  term = params_value (params, "term");
14316  type = params_value (params, "resource_type");
14317 
14318  CHECK_VARIABLE_INVALID (name, "Create Filter");
14319  CHECK_VARIABLE_INVALID (comment, "Create Filter");
14320  CHECK_VARIABLE_INVALID (term, "Create Filter");
14321  CHECK_VARIABLE_INVALID (type, "Create Filter");
14322 
14323  switch (gmpf (connection, credentials, &response, &entity, response_data,
14324  "<create_filter>"
14325  "<name>%s</name>"
14326  "<comment>%s</comment>"
14327  "<term>%s</term>"
14328  "<type>%s</type>"
14329  "</create_filter>",
14330  name, comment, term, type))
14331  {
14332  case 0:
14333  case -1:
14334  break;
14335  case 1:
14336  cmd_response_data_set_status_code (response_data,
14337  MHD_HTTP_INTERNAL_SERVER_ERROR);
14338  return gsad_message (
14339  credentials, "Internal error", __FUNCTION__, __LINE__,
14340  "An internal error occurred while creating a new alert. "
14341  "No new alert was created. "
14342  "Diagnostics: Failure to send command to manager daemon.",
14343  response_data);
14344  case 2:
14345  cmd_response_data_set_status_code (response_data,
14346  MHD_HTTP_INTERNAL_SERVER_ERROR);
14347  return gsad_message (
14348  credentials, "Internal error", __FUNCTION__, __LINE__,
14349  "An internal error occurred while creating a new alert. "
14350  "It is unclear whether the alert has been created or not. "
14351  "Diagnostics: Failure to receive response from manager daemon.",
14352  response_data);
14353  default:
14354  cmd_response_data_set_status_code (response_data,
14355  MHD_HTTP_INTERNAL_SERVER_ERROR);
14356  return gsad_message (
14357  credentials, "Internal error", __FUNCTION__, __LINE__,
14358  "An internal error occurred while creating a new alert. "
14359  "It is unclear whether the alert has been created or not. "
14360  "Diagnostics: Internal Error.",
14361  response_data);
14362  }
14363 
14364  html = response_from_entity (connection, credentials, params, entity,
14365  "Create Filter", response_data);
14366  free_entity (entity);
14367  g_free (response);
14368  return html;
14369 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_group_gmp()

char* create_group_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a group, get all groups, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12406 of file gsad_gmp.c.

12408 {
12409  gchar *html, *response, *command, *specials_element;
12410  const char *name, *comment, *users, *grant_full;
12411  entity_t entity;
12412  GString *xml;
12413  int ret;
12414 
12415  name = params_value (params, "name");
12416  comment = params_value (params, "comment");
12417  grant_full = params_value (params, "grant_full");
12418  users = params_value (params, "users");
12419 
12420  CHECK_VARIABLE_INVALID (name, "Create Group");
12421  CHECK_VARIABLE_INVALID (comment, "Create Group");
12422  CHECK_VARIABLE_INVALID (users, "Create Group");
12423 
12424  /* Create the group. */
12425 
12426  xml = g_string_new ("");
12427 
12428  xml_string_append (xml,
12429  "<name>%s</name>"
12430  "<comment>%s</comment>"
12431  "<users>%s</users>",
12432  name, comment, users);
12433 
12434  if (grant_full)
12435  specials_element = g_strdup_printf ("<full/>");
12436  else
12437  specials_element = NULL;
12438 
12439  command = g_strdup_printf ("<create_group>"
12440  "%s"
12441  "<specials>"
12442  "%s"
12443  "</specials>"
12444  "</create_group>",
12445  xml->str, specials_element);
12446 
12447  g_string_free (xml, TRUE);
12448  g_free (specials_element);
12449 
12450  ret =
12451  gmp (connection, credentials, &response, &entity, response_data, command);
12452  g_free (command);
12453  switch (ret)
12454  {
12455  case 0:
12456  case -1:
12457  break;
12458  case 1:
12459  cmd_response_data_set_status_code (response_data,
12460  MHD_HTTP_INTERNAL_SERVER_ERROR);
12461  return gsad_message (
12462  credentials, "Internal error", __FUNCTION__, __LINE__,
12463  "An internal error occurred while creating a new group. "
12464  "No new group was created. "
12465  "Diagnostics: Failure to send command to manager daemon.",
12466  response_data);
12467  case 2:
12468  cmd_response_data_set_status_code (response_data,
12469  MHD_HTTP_INTERNAL_SERVER_ERROR);
12470  return gsad_message (
12471  credentials, "Internal error", __FUNCTION__, __LINE__,
12472  "An internal error occurred while creating a new group. "
12473  "It is unclear whether the group has been created or not. "
12474  "Diagnostics: Failure to receive response from manager daemon.",
12475  response_data);
12476  default:
12477  cmd_response_data_set_status_code (response_data,
12478  MHD_HTTP_INTERNAL_SERVER_ERROR);
12479  return gsad_message (
12480  credentials, "Internal error", __FUNCTION__, __LINE__,
12481  "An internal error occurred while creating a new group. "
12482  "It is unclear whether the group has been created or not. "
12483  "Diagnostics: Internal Error.",
12484  response_data);
12485  }
12486 
12487  if (entity_attribute (entity, "id"))
12488  params_add (params, "group_id", entity_attribute (entity, "id"));
12489  html = response_from_entity (connection, credentials, params, entity,
12490  "Create Group", response_data);
12491  free_entity (entity);
12492  g_free (response);
12493  return html;
12494 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_value(), response_from_entity(), and users.

Here is the call graph for this function:

◆ create_host_gmp()

char* create_host_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a host, serve next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16125 of file gsad_gmp.c.

16127 {
16128  int ret;
16129  gchar *html, *response;
16130  const char *name, *comment;
16131  entity_t entity;
16132  GString *xml;
16133 
16134  name = params_value (params, "name");
16135  CHECK_VARIABLE_INVALID (name, "Create Host");
16136 
16137  comment = params_value (params, "comment");
16138  CHECK_VARIABLE_INVALID (comment, "Create Host");
16139 
16140  /* Create the host. */
16141 
16142  xml = g_string_new ("");
16143 
16144  xml_string_append (xml,
16145  "<create_asset>"
16146  "<asset>"
16147  "<type>host</type>"
16148  "<name>%s</name>"
16149  "<comment>%s</comment>"
16150  "</asset>"
16151  "</create_asset>",
16152  name, comment);
16153 
16154  ret =
16155  gmp (connection, credentials, &response, &entity, response_data, xml->str);
16156  g_string_free (xml, TRUE);
16157  switch (ret)
16158  {
16159  case 0:
16160  case -1:
16161  break;
16162  case 1:
16163  cmd_response_data_set_status_code (response_data,
16164  MHD_HTTP_INTERNAL_SERVER_ERROR);
16165  return gsad_message (
16166  credentials, "Internal error", __FUNCTION__, __LINE__,
16167  "An internal error occurred while creating a new host. "
16168  "No new host was created. "
16169  "Diagnostics: Failure to send command to manager daemon.",
16170  response_data);
16171  case 2:
16172  cmd_response_data_set_status_code (response_data,
16173  MHD_HTTP_INTERNAL_SERVER_ERROR);
16174  return gsad_message (
16175  credentials, "Internal error", __FUNCTION__, __LINE__,
16176  "An internal error occurred while creating a new host. "
16177  "It is unclear whether the host has been created or not. "
16178  "Diagnostics: Failure to receive response from manager daemon.",
16179  response_data);
16180  default:
16181  cmd_response_data_set_status_code (response_data,
16182  MHD_HTTP_INTERNAL_SERVER_ERROR);
16183  return gsad_message (
16184  credentials, "Internal error", __FUNCTION__, __LINE__,
16185  "An internal error occurred while creating a new host. "
16186  "It is unclear whether the host has been created or not. "
16187  "Diagnostics: Internal Error.",
16188  response_data);
16189  }
16190 
16191  if (entity_attribute (entity, "id"))
16192  params_add (params, "asset_id", entity_attribute (entity, "id"));
16193  html = response_from_entity (connection, credentials, params, entity,
16194  "Create Host", response_data);
16195  free_entity (entity);
16196  g_free (response);
16197  return html;
16198 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_note_gmp()

char* create_note_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a note, get report, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9426 of file gsad_gmp.c.

9428 {
9429  char *ret;
9430  gchar *response;
9431  const char *oid, *severity, *port, *hosts;
9432  const char *text, *task_id, *result_id;
9433  /* For get_report. */
9434  const char *active, *days;
9435  entity_t entity;
9436 
9437  oid = params_value (params, "oid");
9438  CHECK_VARIABLE_INVALID (oid, "Create Note");
9439 
9440  port = get_port_from_params (params);
9441  hosts = get_hosts_from_params (params);
9442  task_id = get_task_id_from_params (params);
9443  severity = get_severity_from_params (params);
9444  result_id = get_result_id_from_params (params);
9445 
9446  CHECK_VARIABLE_INVALID (severity, "Create Note");
9447  CHECK_VARIABLE_INVALID (hosts, "Create Note");
9448 
9449  active = params_value (params, "active");
9450  CHECK_VARIABLE_INVALID (active, "Create Note");
9451 
9452  text = params_value (params, "text");
9453  days = params_value (params, "days");
9454 
9455  response = NULL;
9456  entity = NULL;
9457  switch (gmpf (connection, credentials, &response, &entity, response_data,
9458  "<create_note>"
9459  "<active>%s</active>"
9460  "<nvt oid=\"%s\"/>"
9461  "<hosts>%s</hosts>"
9462  "<port>%s</port>"
9463  "<severity>%s</severity>"
9464  "<text>%s</text>"
9465  "<task id=\"%s\"/>"
9466  "<result id=\"%s\"/>"
9467  "</create_note>",
9468  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
9469  hosts ? hosts : "", port ? port : "", severity ? severity : "",
9470  text ? text : "", task_id ? task_id : "",
9471  result_id ? result_id : ""))
9472  {
9473  case 0:
9474  case -1:
9475  break;
9476  case 1:
9477  cmd_response_data_set_status_code (response_data,
9478  MHD_HTTP_INTERNAL_SERVER_ERROR);
9479  return gsad_message (
9480  credentials, "Internal error", __FUNCTION__, __LINE__,
9481  "An internal error occurred while creating a new note. "
9482  "No new note was created. "
9483  "Diagnostics: Failure to send command to manager daemon.",
9484  response_data);
9485  case 2:
9486  cmd_response_data_set_status_code (response_data,
9487  MHD_HTTP_INTERNAL_SERVER_ERROR);
9488  return gsad_message (
9489  credentials, "Internal error", __FUNCTION__, __LINE__,
9490  "An internal error occurred while creating a new note. "
9491  "It is unclear whether the note has been created or not. "
9492  "Diagnostics: Failure to receive response from manager daemon.",
9493  response_data);
9494  default:
9495  cmd_response_data_set_status_code (response_data,
9496  MHD_HTTP_INTERNAL_SERVER_ERROR);
9497  return gsad_message (
9498  credentials, "Internal error", __FUNCTION__, __LINE__,
9499  "An internal error occurred while creating a new note. "
9500  "It is unclear whether the note has been created or not. "
9501  "Diagnostics: Internal Error.",
9502  response_data);
9503  }
9504 
9505  if (entity_attribute (entity, "id"))
9506  params_add (params, "note_id", entity_attribute (entity, "id"));
9507  ret = response_from_entity (connection, credentials, params, entity,
9508  "Create Note", response_data);
9509  free_entity (entity);
9510  g_free (response);
9511  return ret;
9512 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_hosts_from_params(), get_port_from_params(), get_result_id_from_params(), get_severity_from_params(), get_task_id_from_params(), gmpf(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_override_gmp()

char* create_override_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create an override, get report, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9703 of file gsad_gmp.c.

9705 {
9706  char *ret;
9707  gchar *response;
9708  const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
9709  const char *text, *task_id, *result_id;
9710  /* For get_report. */
9711  const char *active, *days;
9712  entity_t entity;
9713 
9714  oid = params_value (params, "oid");
9715  CHECK_VARIABLE_INVALID (oid, "Create Override");
9716 
9717  port = get_port_from_params (params);
9718  hosts = get_hosts_from_params (params);
9719  task_id = get_task_id_from_params (params);
9720  severity = get_severity_from_params (params);
9721  result_id = get_result_id_from_params (params);
9722 
9723  custom_severity = params_value (params, "custom_severity");
9724  CHECK_VARIABLE_INVALID (custom_severity, "Create Override");
9725 
9726  if (custom_severity != NULL && strcmp (custom_severity, "0"))
9727  {
9728  if (params_valid (params, "new_severity"))
9729  new_severity = params_value (params, "new_severity");
9730  else if (params_original_value (params, "new_severity") == NULL
9731  || strcmp (params_original_value (params, "new_severity"), ""))
9732  new_severity = NULL;
9733  else
9734  new_severity = "";
9735  CHECK_VARIABLE_INVALID (new_severity, "Create Override");
9736  }
9737  else
9738  {
9739  if (params_valid (params, "new_severity_from_list"))
9740  new_severity = params_value (params, "new_severity_from_list");
9741  else if (params_original_value (params, "new_severity_from_list") == NULL
9742  || strcmp (
9743  params_original_value (params, "new_severity_from_list"),
9744  ""))
9745  new_severity = NULL;
9746  else
9747  new_severity = "";
9748  CHECK_VARIABLE_INVALID (new_severity, "Create Override");
9749  }
9750 
9751  active = params_value (params, "active");
9752  CHECK_VARIABLE_INVALID (active, "Create Override");
9753 
9754  text = params_value (params, "text");
9755  days = params_value (params, "days");
9756 
9757  response = NULL;
9758  entity = NULL;
9759  switch (gmpf (connection, credentials, &response, &entity, response_data,
9760  "<create_override>"
9761  "<active>%s</active>"
9762  "<nvt oid=\"%s\"/>"
9763  "<hosts>%s</hosts>"
9764  "<port>%s</port>"
9765  "<severity>%s</severity>"
9766  "<new_severity>%s</new_severity>"
9767  "<text>%s</text>"
9768  "<task id=\"%s\"/>"
9769  "<result id=\"%s\"/>"
9770  "</create_override>",
9771  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
9772  hosts ? hosts : "", port ? port : "", severity ? severity : "",
9773  new_severity, text ? text : "", task_id ? task_id : "",
9774  result_id ? result_id : ""))
9775  {
9776  case 0:
9777  case -1:
9778  break;
9779  case 1:
9780  cmd_response_data_set_status_code (response_data,
9781  MHD_HTTP_INTERNAL_SERVER_ERROR);
9782  return gsad_message (
9783  credentials, "Internal error", __FUNCTION__, __LINE__,
9784  "An internal error occurred while creating a new override. "
9785  "No new override was created. "
9786  "Diagnostics: Failure to send command to manager daemon.",
9787  response_data);
9788  case 2:
9789  cmd_response_data_set_status_code (response_data,
9790  MHD_HTTP_INTERNAL_SERVER_ERROR);
9791  return gsad_message (
9792  credentials, "Internal error", __FUNCTION__, __LINE__,
9793  "An internal error occurred while creating a new override. "
9794  "It is unclear whether the override has been created or not. "
9795  "Diagnostics: Failure to receive response from manager daemon.",
9796  response_data);
9797  default:
9798  cmd_response_data_set_status_code (response_data,
9799  MHD_HTTP_INTERNAL_SERVER_ERROR);
9800  return gsad_message (
9801  credentials, "Internal error", __FUNCTION__, __LINE__,
9802  "An internal error occurred while creating a new override. "
9803  "It is unclear whether the override has been created or not. "
9804  "Diagnostics: Internal Error.",
9805  response_data);
9806  }
9807 
9808  if (entity_attribute (entity, "id"))
9809  params_add (params, "override_id", entity_attribute (entity, "id"));
9810  ret = response_from_entity (connection, credentials, params, entity,
9811  "Create Override", response_data);
9812  free_entity (entity);
9813  g_free (response);
9814  return ret;
9815 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_hosts_from_params(), get_port_from_params(), get_result_id_from_params(), get_severity_from_params(), get_task_id_from_params(), gmpf(), gsad_message(), params_add(), params_original_value(), params_valid(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_permission_gmp()

char* create_permission_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a permission, get all permissions, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12705 of file gsad_gmp.c.

12707 {
12708  int ret;
12709  gchar *html, *response;
12710  const char *name, *comment, *resource_id, *resource_type;
12711  const char *subject_id, *subject_type;
12712  entity_t entity;
12713 
12714  name = params_value (params, "permission");
12715  comment = params_value (params, "comment");
12716  resource_id = params_value (params, "id_or_empty");
12717  resource_type = params_value (params, "optional_resource_type");
12718  subject_type = params_value (params, "subject_type");
12719 
12720  CHECK_VARIABLE_INVALID (name, "Create Permission");
12721  CHECK_VARIABLE_INVALID (comment, "Create Permission");
12722  if (params_given (params, "id_or_empty"))
12723  CHECK_VARIABLE_INVALID (resource_id, "Create Permission");
12724  CHECK_VARIABLE_INVALID (subject_type, "Create Permission");
12725  if (params_given (params, "optional_resource_type"))
12726  CHECK_VARIABLE_INVALID (resource_type, "Create Permission");
12727 
12728  if (str_equal (subject_type, "user"))
12729  subject_id = params_value (params, "permission_user_id");
12730  else if (str_equal (subject_type, "group"))
12731  subject_id = params_value (params, "permission_group_id");
12732  else if (str_equal (subject_type, "role"))
12733  subject_id = params_value (params, "permission_role_id");
12734  else
12735  subject_id = NULL;
12736 
12737  CHECK_VARIABLE_INVALID (subject_id, "Create Permission");
12738 
12739  /* Create the permission(s). */
12740 
12741  response = NULL;
12742  entity = NULL;
12743  ret = gmpf (connection, credentials, &response, &entity, response_data,
12744  "<create_permission>"
12745  "<name>%s</name>"
12746  "<comment>%s</comment>"
12747  "<resource id=\"%s\">"
12748  "<type>%s</type>"
12749  "</resource>"
12750  "<subject id=\"%s\"><type>%s</type></subject>"
12751  "</create_permission>",
12752  name, comment ? comment : "", resource_id ? resource_id : "",
12753  resource_type ? resource_type : "", subject_id, subject_type);
12754 
12755  switch (ret)
12756  {
12757  case 0:
12758  case -1:
12759  break;
12760  case 1:
12761  cmd_response_data_set_status_code (response_data,
12762  MHD_HTTP_INTERNAL_SERVER_ERROR);
12763  return gsad_message (
12764  credentials, "Internal error", __FUNCTION__, __LINE__,
12765  "An internal error occurred while creating a permission. "
12766  "The permission was not created. "
12767  "Diagnostics: Failure to send command to manager daemon.",
12768  response_data);
12769  case 2:
12770  cmd_response_data_set_status_code (response_data,
12771  MHD_HTTP_INTERNAL_SERVER_ERROR);
12772  return gsad_message (
12773  credentials, "Internal error", __FUNCTION__, __LINE__,
12774  "An internal error occurred while creating a permission. "
12775  "It is unclear whether the permission has been created or not. "
12776  "Diagnostics: Failure to receive response from manager daemon.",
12777  response_data);
12778  default:
12779  cmd_response_data_set_status_code (response_data,
12780  MHD_HTTP_INTERNAL_SERVER_ERROR);
12781  return gsad_message (
12782  credentials, "Internal error", __FUNCTION__, __LINE__,
12783  "An internal error occurred while creating a permission. "
12784  "It is unclear whether the permission has been created or not. "
12785  "Diagnostics: Internal Error.",
12786  response_data);
12787  }
12788 
12789  if (entity_attribute (entity, "id"))
12790  params_add (params, "permission_id", entity_attribute (entity, "id"));
12791 
12792  html = response_from_entity (connection, credentials, params, entity,
12793  "Create Permission", response_data);
12794 
12795  free_entity (entity);
12796  g_free (response);
12797  return html;
12798 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_given(), params_value(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ create_permissions_gmp()

char* create_permissions_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create multiple permission, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12864 of file gsad_gmp.c.

12867 {
12868  int ret;
12869  gchar *html, *response, *summary_response;
12870  int successes;
12871  const char *permission, *comment, *resource_id, *resource_type;
12872  const char *subject_id, *subject_type;
12873  const char *permission_resource_type;
12874  int include_related;
12875 
12876  entity_t entity;
12877 
12878  permission = params_value (params, "permission_type");
12879  comment = params_value (params, "comment");
12880  resource_id = params_value (params, "resource_id");
12881  resource_type = params_value (params, "resource_type");
12882  subject_type = params_value (params, "subject_type");
12883 
12884  CHECK_VARIABLE_INVALID (params_value (params, "include_related"),
12885  "Create Permission");
12886  CHECK_VARIABLE_INVALID (permission, "Create Permission");
12887  CHECK_VARIABLE_INVALID (comment, "Create Permission");
12888  CHECK_VARIABLE_INVALID (resource_id, "Create Permission");
12889  CHECK_VARIABLE_INVALID (subject_type, "Create Permission");
12890  CHECK_VARIABLE_INVALID (resource_type, "Create Permission");
12891 
12892  if (str_equal (resource_type, "host") || str_equal (resource_type, "os"))
12893  {
12894  permission_resource_type = "asset";
12895  }
12896  else
12897  permission_resource_type = resource_type;
12898 
12899  include_related = atoi (params_value (params, "include_related"));
12900 
12901  if (str_equal (subject_type, "user"))
12902  subject_id = params_value (params, "permission_user_id");
12903  else if (str_equal (subject_type, "group"))
12904  subject_id = params_value (params, "permission_group_id");
12905  else if (str_equal (subject_type, "role"))
12906  subject_id = params_value (params, "permission_role_id");
12907  else
12908  subject_id = NULL;
12909 
12910  CHECK_VARIABLE_INVALID (subject_id, "Create Permission");
12911 
12912  successes = 0;
12913 
12914  /* Create the permission(s). */
12915 
12916  // Main resource permissions
12917  if (include_related != INCLUDE_RELATED_RESOURCES_ONLY)
12918  {
12919  if (str_equal (permission, "read") || str_equal (permission, "write"))
12920  {
12921  response = NULL;
12922  entity = NULL;
12923  ret =
12924  gmpf (connection, credentials, &response, &entity, response_data,
12925  "<create_permission>"
12926  "<name>get_%ss</name>"
12927  "<comment>%s</comment>"
12928  "<resource id=\"%s\">"
12929  "</resource>"
12930  "<subject id=\"%s\"><type>%s</type></subject>"
12931  "</create_permission>",
12932  permission_resource_type, comment ? comment : "", resource_id,
12933  subject_id, subject_type);
12934 
12936  }
12937 
12938  if ((str_equal (permission, "write"))
12939  && !str_equal (permission_resource_type, "result")
12940  && !str_equal (permission_resource_type, "report"))
12941  {
12942  // create modify permission for resource
12943  response = NULL;
12944  entity = NULL;
12945  ret =
12946  gmpf (connection, credentials, &response, &entity, response_data,
12947  "<create_permission>"
12948  "<name>modify_%s</name>"
12949  "<comment>%s</comment>"
12950  "<resource id=\"%s\">"
12951  "</resource>"
12952  "<subject id=\"%s\"><type>%s</type></subject>"
12953  "</create_permission>",
12954  permission_resource_type, comment ? comment : "", resource_id,
12955  subject_id, subject_type);
12956 
12958 
12959  if (str_equal (permission_resource_type, "task"))
12960  {
12961  // create start_task, stop_task and resume_task permission
12962  response = NULL;
12963  entity = NULL;
12964  ret = gmpf (connection, credentials, &response, &entity,
12965  response_data,
12966  "<create_permission>"
12967  "<name>start_%s</name>"
12968  "<comment>%s</comment>"
12969  "<resource id=\"%s\">"
12970  "</resource>"
12971  "<subject id=\"%s\"><type>%s</type></subject>"
12972  "</create_permission>",
12973  permission_resource_type, comment ? comment : "",
12974  resource_id, subject_id, subject_type);
12975 
12977 
12978  response = NULL;
12979  entity = NULL;
12980  ret = gmpf (connection, credentials, &response, &entity,
12981  response_data,
12982  "<create_permission>"
12983  "<name>stop_%s</name>"
12984  "<comment>%s</comment>"
12985  "<resource id=\"%s\">"
12986  "</resource>"
12987  "<subject id=\"%s\"><type>%s</type></subject>"
12988  "</create_permission>",
12989  permission_resource_type, comment ? comment : "",
12990  resource_id, subject_id, subject_type);
12991 
12993 
12994  response = NULL;
12995  entity = NULL;
12996  ret = gmpf (connection, credentials, &response, &entity,
12997  response_data,
12998  "<create_permission>"
12999  "<name>resume_%s</name>"
13000  "<comment>%s</comment>"
13001  "<resource id=\"%s\">"
13002  "</resource>"
13003  "<subject id=\"%s\"><type>%s</type></subject>"
13004  "</create_permission>",
13005  permission_resource_type, comment ? comment : "",
13006  resource_id, subject_id, subject_type);
13007 
13009  }
13010 
13011  if (str_equal (permission_resource_type, "alert"))
13012  {
13013  // create test permission
13014  response = NULL;
13015  entity = NULL;
13016  ret = gmpf (connection, credentials, &response, &entity,
13017  response_data,
13018  "<create_permission>"
13019  "<name>test_%s</name>"
13020  "<comment>%s</comment>"
13021  "<resource id=\"%s\">"
13022  "</resource>"
13023  "<subject id=\"%s\"><type>%s</type></subject>"
13024  "</create_permission>",
13025  permission_resource_type, comment ? comment : "",
13026  resource_id, subject_id, subject_type);
13027 
13029  }
13030 
13031  if (str_equal (permission_resource_type, "agent")
13032  || str_equal (permission_resource_type, "report_format")
13033  || str_equal (permission_resource_type, "scanner"))
13034  {
13035  // create verify permission
13036  response = NULL;
13037  entity = NULL;
13038  ret = gmpf (connection, credentials, &response, &entity,
13039  response_data,
13040  "<create_permission>"
13041  "<name>verify_%s</name>"
13042  "<comment>%s</comment>"
13043  "<resource id=\"%s\">"
13044  "</resource>"
13045  "<subject id=\"%s\"><type>%s</type></subject>"
13046  "</create_permission>",
13047  permission_resource_type, comment ? comment : "",
13048  resource_id, subject_id, subject_type);
13049 
13051  }
13052  }
13053  }
13054 
13055  // Related permissions
13056  if (include_related != INCLUDE_RELATED_CURRENT_RESOURCE_ONLY)
13057  {
13058  params_t *related;
13059  related = params_values (params, "related:");
13060  if (related)
13061  {
13062  params_iterator_t iter;
13063  char *name;
13064  param_t *param;
13065 
13066  params_iterator_init (&iter, related);
13067  while (params_iterator_next (&iter, &name, &param))
13068  {
13069  char *related_id = name;
13070  char *related_type;
13071 
13072  if (str_equal (param->value, "host")
13073  || str_equal (param->value, "os"))
13074  {
13075  related_type = "asset";
13076  }
13077  else
13078  related_type = param->value;
13079 
13080  if (str_equal (permission, "read") == 0
13081  || str_equal (permission, "write") == 0)
13082  {
13083  response = NULL;
13084  entity = NULL;
13085  ret = gmpf (connection, credentials, &response, &entity,
13086  response_data,
13087  "<create_permission>"
13088  "<name>get_%ss</name>"
13089  "<comment>%s</comment>"
13090  "<resource id=\"%s\">"
13091  "</resource>"
13092  "<subject id=\"%s\"><type>%s</type></subject>"
13093  "</create_permission>",
13094  related_type, comment ? comment : "", related_id,
13095  subject_id, subject_type);
13096 
13098  }
13099 
13100  if ((str_equal (permission, "write"))
13101  && !str_equal (related_type, "result")
13102  && !str_equal (related_type, "report"))
13103  {
13104  response = NULL;
13105  entity = NULL;
13106  ret = gmpf (connection, credentials, &response, &entity,
13107  response_data,
13108  "<create_permission>"
13109  "<name>modify_%s</name>"
13110  "<comment>%s</comment>"
13111  "<resource id=\"%s\">"
13112  "</resource>"
13113  "<subject id=\"%s\"><type>%s</type></subject>"
13114  "</create_permission>",
13115  related_type, comment ? comment : "", related_id,
13116  subject_id, subject_type);
13117 
13119 
13120  if (str_equal (related_type, "task"))
13121  {
13122  response = NULL;
13123  entity = NULL;
13124  ret = gmpf (connection, credentials, &response, &entity,
13125  response_data,
13126  "<create_permission>"
13127  "<name>start_%s</name>"
13128  "<comment>%s</comment>"
13129  "<resource id=\"%s\">"
13130  "</resource>"
13131  "<subject id=\"%s\"><type>%s</type></subject>"
13132  "</create_permission>",
13133  related_type, comment ? comment : "",
13134  related_id, subject_id, subject_type);
13135 
13137 
13138  response = NULL;
13139  entity = NULL;
13140  ret = gmpf (connection, credentials, &response, &entity,
13141  response_data,
13142  "<create_permission>"
13143  "<name>stop_%s</name>"
13144  "<comment>%s</comment>"
13145  "<resource id=\"%s\">"
13146  "</resource>"
13147  "<subject id=\"%s\"><type>%s</type></subject>"
13148  "</create_permission>",
13149  related_type, comment ? comment : "",
13150  related_id, subject_id, subject_type);
13151 
13153 
13154  response = NULL;
13155  entity = NULL;
13156  ret = gmpf (connection, credentials, &response, &entity,
13157  response_data,
13158  "<create_permission>"
13159  "<name>resume_%s</name>"
13160  "<comment>%s</comment>"
13161  "<resource id=\"%s\">"
13162  "</resource>"
13163  "<subject id=\"%s\"><type>%s</type></subject>"
13164  "</create_permission>",
13165  related_type, comment ? comment : "",
13166  related_id, subject_id, subject_type);
13167 
13169  }
13170 
13171  if (str_equal (related_type, "alert"))
13172  {
13173  response = NULL;
13174  entity = NULL;
13175  ret = gmpf (connection, credentials, &response, &entity,
13176  response_data,
13177  "<create_permission>"
13178  "<name>test_%s</name>"
13179  "<comment>%s</comment>"
13180  "<resource id=\"%s\">"
13181  "</resource>"
13182  "<subject id=\"%s\"><type>%s</type></subject>"
13183  "</create_permission>",
13184  related_type, comment ? comment : "",
13185  related_id, subject_id, subject_type);
13186 
13188  }
13189 
13190  if (str_equal (related_type, "agent")
13191  || str_equal (related_type, "report_format")
13192  || str_equal (related_type, "scanner"))
13193  {
13194  response = NULL;
13195  entity = NULL;
13196  ret = gmpf (connection, credentials, &response, &entity,
13197  response_data,
13198  "<create_permission>"
13199  "<name>verify_%s</name>"
13200  "<comment>%s</comment>"
13201  "<resource id=\"%s\">"
13202  "</resource>"
13203  "<subject id=\"%s\"><type>%s</type></subject>"
13204  "</create_permission>",
13205  related_type, comment ? comment : "",
13206  related_id, subject_id, subject_type);
13207 
13209  }
13210  }
13211  }
13212  }
13213  }
13214 
13215  summary_response =
13216  g_strdup_printf ("Successfully created %i permissions", successes);
13217 
13218  html = action_result (connection, credentials, params, response_data,
13219  "Create Permissions", summary_response, NULL, NULL);
13220  return html;
13221 }

References action_result(), CHECK_GMPF_RET, CHECK_VARIABLE_INVALID, gmpf(), INCLUDE_RELATED_CURRENT_RESOURCE_ONLY, INCLUDE_RELATED_RESOURCES_ONLY, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), str_equal(), and param::value.

Here is the call graph for this function:

◆ create_port_list_gmp()

char* create_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a port list, get all port lists, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13380 of file gsad_gmp.c.

13382 {
13383  gchar *html, *response;
13384  const char *name, *comment, *port_range, *from_file;
13385  entity_t entity;
13386 
13387  name = params_value (params, "name");
13388  comment = params_value (params, "comment");
13389  port_range = params_value (params, "port_range");
13390  from_file = params_value (params, "from_file");
13391 
13392  CHECK_VARIABLE_INVALID (name, "Create Port List");
13393  CHECK_VARIABLE_INVALID (comment, "Create Port List");
13394  CHECK_VARIABLE_INVALID (port_range, "Create Port List");
13395  CHECK_VARIABLE_INVALID (from_file, "Create Port List");
13396 
13397  /* Create the port_list. */
13398 
13399  switch (gmpf (
13400  connection, credentials, &response, &entity, response_data,
13401  "<create_port_list>"
13402  "<name>%s</name>"
13403  "<port_range>%s</port_range>"
13404  "<comment>%s</comment>"
13405  "</create_port_list>",
13406  name, strcmp (from_file, "0") ? params_value (params, "file") : port_range,
13407  comment ? comment : ""))
13408  {
13409  case 0:
13410  case -1:
13411  break;
13412  case 1:
13413  cmd_response_data_set_status_code (response_data,
13414  MHD_HTTP_INTERNAL_SERVER_ERROR);
13415  return gsad_message (
13416  credentials, "Internal error", __FUNCTION__, __LINE__,
13417  "An internal error occurred while creating a new port list. "
13418  "No new port list was created. "
13419  "Diagnostics: Failure to send command to manager daemon.",
13420  response_data);
13421  case 2:
13422  cmd_response_data_set_status_code (response_data,
13423  MHD_HTTP_INTERNAL_SERVER_ERROR);
13424  return gsad_message (
13425  credentials, "Internal error", __FUNCTION__, __LINE__,
13426  "An internal error occurred while creating a new port list. "
13427  "It is unclear whether the port list has been created or not. "
13428  "Diagnostics: Failure to receive response from manager daemon.",
13429  response_data);
13430  default:
13431  cmd_response_data_set_status_code (response_data,
13432  MHD_HTTP_INTERNAL_SERVER_ERROR);
13433  return gsad_message (
13434  credentials, "Internal error", __FUNCTION__, __LINE__,
13435  "An internal error occurred while creating a new port list. "
13436  "It is unclear whether the port list has been created or not. "
13437  "Diagnostics: Internal Error.",
13438  response_data);
13439  }
13440 
13441  if (entity_attribute (entity, "id"))
13442  params_add (params, "port_list_id", entity_attribute (entity, "id"));
13443  html = response_from_entity (connection, credentials, params, entity,
13444  "Create Port List", response_data);
13445  free_entity (entity);
13446  g_free (response);
13447  return html;
13448 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_port_range_gmp()

char* create_port_range_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Add a range to a port list, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13461 of file gsad_gmp.c.

13463 {
13464  int ret;
13465  gchar *html, *response;
13466  const char *port_list_id, *start, *end, *type;
13467  entity_t entity;
13468 
13469  port_list_id = params_value (params, "port_list_id");
13470  start = params_value (params, "port_range_start");
13471  end = params_value (params, "port_range_end");
13472  type = params_value (params, "port_type");
13473 
13474  CHECK_VARIABLE_INVALID (port_list_id, "Create Port Range");
13475  CHECK_VARIABLE_INVALID (start, "Create Port Range");
13476  CHECK_VARIABLE_INVALID (end, "Create Port Range");
13477  CHECK_VARIABLE_INVALID (type, "Create Port Range");
13478 
13479  /* Create the port range. */
13480 
13481  response = NULL;
13482  entity = NULL;
13483  ret = gmpf (connection, credentials, &response, &entity, response_data,
13484  "<create_port_range>"
13485  "<port_list id=\"%s\"/>"
13486  "<start>%s</start>"
13487  "<end>%s</end>"
13488  "<type>%s</type>"
13489  "</create_port_range>",
13490  port_list_id, start, end, type);
13491 
13492  switch (ret)
13493  {
13494  case 0:
13495  case -1:
13496  break;
13497  case 1:
13498  cmd_response_data_set_status_code (response_data,
13499  MHD_HTTP_INTERNAL_SERVER_ERROR);
13500  return gsad_message (
13501  credentials, "Internal error", __FUNCTION__, __LINE__,
13502  "An internal error occurred while creating a Port Range. "
13503  "The Port Range was not created. "
13504  "Diagnostics: Failure to send command to manager daemon.",
13505  response_data);
13506  case 2:
13507  cmd_response_data_set_status_code (response_data,
13508  MHD_HTTP_INTERNAL_SERVER_ERROR);
13509  return gsad_message (
13510  credentials, "Internal error", __FUNCTION__, __LINE__,
13511  "An internal error occurred while creating a Port Range. "
13512  "It is unclear whether the Port Range has been created or not. "
13513  "Diagnostics: Failure to receive response from manager daemon.",
13514  response_data);
13515  default:
13516  cmd_response_data_set_status_code (response_data,
13517  MHD_HTTP_INTERNAL_SERVER_ERROR);
13518  return gsad_message (
13519  credentials, "Internal error", __FUNCTION__, __LINE__,
13520  "An internal error occurred while creating a Port Range. "
13521  "It is unclear whether the Port Range has been created or not. "
13522  "Diagnostics: Internal Error.",
13523  response_data);
13524  }
13525 
13526  html = response_from_entity (connection, credentials, params, entity,
13527  "Create Port Range", response_data);
13528  free_entity (entity);
13529  g_free (response);
13530  return html;
13531 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_report_gmp()

char* create_report_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Returns page to create a new container task.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]messageIf not NULL, display message.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Create a report, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1926 of file gsad_gmp.c.

1928 {
1929  entity_t entity;
1930  int ret;
1931  gchar **xml_file_array, *xml_file_escaped;
1932  gchar *command, *html, *response;
1933  const char *task_id = params_value (params, "task_id"),
1934  *xml_file = params_value (params, "xml_file"),
1935  *in_assets = params_value (params, "in_assets");
1936 
1937  CHECK_VARIABLE_INVALID (task_id, "Create Report");
1938  CHECK_VARIABLE_INVALID (xml_file, "Create Report");
1939 
1940  if (strlen (xml_file) == 0)
1941  {
1942  return message_invalid (connection, credentials, params, response_data,
1943  "Report required", "Create Report");
1944  }
1945 
1946  xml_file_array = g_strsplit (xml_file, "%", -1);
1947  if (xml_file_array != NULL && xml_file_array[0] != NULL)
1948  xml_file_escaped = g_strjoinv ("%%", xml_file_array);
1949  else
1950  xml_file_escaped = g_strdup (xml_file);
1951  g_strfreev (xml_file_array);
1952 
1953  command = g_strdup_printf ("<create_report>"
1954  "<in_assets>%s</in_assets>"
1955  "<task id=\"%s\"/>"
1956  "%s"
1957  "</create_report>",
1958  in_assets ? in_assets : "0", task_id,
1959  xml_file_escaped ? xml_file_escaped : "");
1960  g_free (xml_file_escaped);
1961 
1962  ret =
1963  gmp (connection, credentials, &response, &entity, response_data, command);
1964  g_free (command);
1965 
1966  switch (ret)
1967  {
1968  case 0:
1969  break;
1970  case -1:
1971  /* 'gmp' set response. */
1972  return response;
1973  case 1:
1974  cmd_response_data_set_status_code (response_data,
1975  MHD_HTTP_INTERNAL_SERVER_ERROR);
1976  return gsad_message (
1977  credentials, "Internal error", __FUNCTION__, __LINE__,
1978  "An internal error occurred while creating a new report. "
1979  "No new report was created. "
1980  "Diagnostics: Failure to send command to manager daemon.",
1981  response_data);
1982  case 2:
1983  cmd_response_data_set_status_code (response_data,
1984  MHD_HTTP_INTERNAL_SERVER_ERROR);
1985  return gsad_message (
1986  credentials, "Internal error", __FUNCTION__, __LINE__,
1987  "An internal error occurred while creating a new report. "
1988  "It is unclear whether the report has been created or not. "
1989  "Diagnostics: Failure to receive response from manager daemon.",
1990  response_data);
1991  default:
1992  cmd_response_data_set_status_code (response_data,
1993  MHD_HTTP_INTERNAL_SERVER_ERROR);
1994  return gsad_message (
1995  credentials, "Internal error", __FUNCTION__, __LINE__,
1996  "An internal error occurred while creating a new report. "
1997  "It is unclear whether the report has been created or not. "
1998  "Diagnostics: Internal Error.",
1999  response_data);
2000  }
2001 
2002  html = response_from_entity (connection, credentials, params, entity,
2003  "Import Report", response_data);
2004  free_entity (entity);
2005  g_free (response);
2006  return html;
2007 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), message_invalid(), params_value(), and response_from_entity().

Referenced by import_report_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_role_gmp()

char* create_role_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a role, get all roles, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13812 of file gsad_gmp.c.

13814 {
13815  char *ret;
13816  gchar *response;
13817  const char *name, *comment, *users;
13818  entity_t entity;
13819 
13820  name = params_value (params, "name");
13821  comment = params_value (params, "comment");
13822  users = params_value (params, "users");
13823 
13824  CHECK_VARIABLE_INVALID (name, "Create Role");
13825  CHECK_VARIABLE_INVALID (comment, "Create Role");
13826  CHECK_VARIABLE_INVALID (users, "Create Role");
13827 
13828  response = NULL;
13829  entity = NULL;
13830  switch (gmpf (connection, credentials, &response, &entity, response_data,
13831  "<create_role>"
13832  "<name>%s</name>"
13833  "<comment>%s</comment>"
13834  "<users>%s</users>"
13835  "</create_role>",
13836  name, comment, users))
13837  {
13838  case 0:
13839  case -1:
13840  break;
13841  case 1:
13842  cmd_response_data_set_status_code (response_data,
13843  MHD_HTTP_INTERNAL_SERVER_ERROR);
13844  return gsad_message (
13845  credentials, "Internal error", __FUNCTION__, __LINE__,
13846  "An internal error occurred while creating a new role. "
13847  "No new role was created. "
13848  "Diagnostics: Failure to send command to manager daemon.",
13849  response_data);
13850  case 2:
13851  cmd_response_data_set_status_code (response_data,
13852  MHD_HTTP_INTERNAL_SERVER_ERROR);
13853  return gsad_message (
13854  credentials, "Internal error", __FUNCTION__, __LINE__,
13855  "An internal error occurred while creating a new role. "
13856  "It is unclear whether the role has been created or not. "
13857  "Diagnostics: Failure to receive response from manager daemon.",
13858  response_data);
13859  default:
13860  cmd_response_data_set_status_code (response_data,
13861  MHD_HTTP_INTERNAL_SERVER_ERROR);
13862  return gsad_message (
13863  credentials, "Internal error", __FUNCTION__, __LINE__,
13864  "An internal error occurred while creating a new role. "
13865  "It is unclear whether the role has been created or not. "
13866  "Diagnostics: Internal Error.",
13867  response_data);
13868  }
13869 
13870  if (entity_attribute (entity, "id"))
13871  params_add (params, "role_id", entity_attribute (entity, "id"));
13872  ret = response_from_entity (connection, credentials, params, entity,
13873  "Create Role", response_data);
13874  free_entity (entity);
13875  g_free (response);
13876  return ret;
13877 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_value(), response_from_entity(), and users.

Here is the call graph for this function:

◆ create_scanner_gmp()

char* create_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a scanner, get all scanners, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10114 of file gsad_gmp.c.

10116 {
10117  int ret;
10118  char *html;
10119  gchar *response = NULL;
10120  const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
10121  entity_t entity = NULL;
10122 
10123  name = params_value (params, "name");
10124  comment = params_value (params, "comment");
10125  host = params_value (params, "scanner_host");
10126  port = params_value (params, "port");
10127  type = params_value (params, "scanner_type");
10128  ca_pub = params_value (params, "ca_pub");
10129  credential_id = params_value (params, "credential_id");
10130  CHECK_VARIABLE_INVALID (name, "Create Scanner");
10131  CHECK_VARIABLE_INVALID (comment, "Create Scanner");
10132  CHECK_VARIABLE_INVALID (host, "Create Scanner");
10133  CHECK_VARIABLE_INVALID (port, "Create Scanner");
10134  CHECK_VARIABLE_INVALID (type, "Create Scanner");
10135  if (params_given (params, "ca_pub"))
10136  CHECK_VARIABLE_INVALID (ca_pub, "Create Scanner");
10137 
10138  if (ca_pub)
10139  ret = gmpf (connection, credentials, &response, &entity, response_data,
10140  "<create_scanner>"
10141  "<name>%s</name><comment>%s</comment>"
10142  "<host>%s</host><port>%s</port><type>%s</type>"
10143  "<ca_pub>%s</ca_pub>"
10144  "<credential id=\"%s\"/>"
10145  "</create_scanner>",
10146  name, comment, host, port, type, ca_pub,
10147  credential_id ? credential_id : "");
10148  else
10149  ret = gmpf (connection, credentials, &response, &entity, response_data,
10150  "<create_scanner>"
10151  "<name>%s</name><comment>%s</comment>"
10152  "<host>%s</host><port>%s</port><type>%s</type>"
10153  "<credential id=\"%s\"/>"
10154  "</create_scanner>",
10155  name, comment, host, port, type,
10156  credential_id ? credential_id : "");
10157  switch (ret)
10158  {
10159  case 0:
10160  case -1:
10161  break;
10162  case 1:
10163  cmd_response_data_set_status_code (response_data,
10164  MHD_HTTP_INTERNAL_SERVER_ERROR);
10165  return gsad_message (
10166  credentials, "Internal error", __FUNCTION__, __LINE__,
10167  "An internal error occurred while creating a new scanner. "
10168  "No new scanner was created. "
10169  "Diagnostics: Failure to send command to manager daemon.",
10170  response_data);
10171  case 2:
10172  cmd_response_data_set_status_code (response_data,
10173  MHD_HTTP_INTERNAL_SERVER_ERROR);
10174  return gsad_message (
10175  credentials, "Internal error", __FUNCTION__, __LINE__,
10176  "An internal error occurred while creating a new scanner. "
10177  "It is unclear whether the scanner has been created or not. "
10178  "Diagnostics: Failure to receive response from manager daemon.",
10179  response_data);
10180  default:
10181  cmd_response_data_set_status_code (response_data,
10182  MHD_HTTP_INTERNAL_SERVER_ERROR);
10183  return gsad_message (
10184  credentials, "Internal error", __FUNCTION__, __LINE__,
10185  "An internal error occurred while creating a new scanner. "
10186  "It is unclear whether the scanner has been created or not. "
10187  "Diagnostics: Internal Error.",
10188  response_data);
10189  }
10190 
10191  if (entity_attribute (entity, "id"))
10192  params_add (params, "scanner_id", entity_attribute (entity, "id"));
10193  html = response_from_entity (connection, credentials, params, entity,
10194  "Create Scanner", response_data);
10195  free_entity (entity);
10196  g_free (response);
10197  return html;
10198 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_schedule_gmp()

char* create_schedule_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a schedule, get all schedules, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10446 of file gsad_gmp.c.

10448 {
10449  char *ret;
10450  gchar *response;
10451  const char *name, *comment, *timezone, *icalendar;
10452  entity_t entity;
10453 
10454  name = params_value (params, "name");
10455  comment = params_value (params, "comment");
10456  timezone = params_value (params, "timezone");
10457  icalendar = params_value (params, "icalendar");
10458 
10459  CHECK_VARIABLE_INVALID (name, "Create Schedule");
10460  CHECK_VARIABLE_INVALID (comment, "Create Schedule");
10461  CHECK_VARIABLE_INVALID (timezone, "Create Schedule");
10462  CHECK_VARIABLE_INVALID (icalendar, "Create Schedule");
10463 
10464  response = NULL;
10465  entity = NULL;
10466  switch (gmpf (connection, credentials, &response, &entity, response_data,
10467  "<create_schedule>"
10468  "<name>%s</name>"
10469  "<comment>%s</comment>"
10470  "<timezone>%s</timezone>"
10471  "<icalendar>%s</icalendar>"
10472  "</create_schedule>",
10473  name, comment, timezone, icalendar))
10474  {
10475  case 0:
10476  case -1:
10477  break;
10478  case 1:
10479  cmd_response_data_set_status_code (response_data,
10480  MHD_HTTP_INTERNAL_SERVER_ERROR);
10481  return gsad_message (
10482  credentials, "Internal error", __FUNCTION__, __LINE__,
10483  "An internal error occurred while creating a new schedule. "
10484  "No new schedule was created. "
10485  "Diagnostics: Failure to send command to manager daemon.",
10486  response_data);
10487  case 2:
10488  cmd_response_data_set_status_code (response_data,
10489  MHD_HTTP_INTERNAL_SERVER_ERROR);
10490  return gsad_message (
10491  credentials, "Internal error", __FUNCTION__, __LINE__,
10492  "An internal error occurred while creating a new schedule. "
10493  "It is unclear whether the schedule has been created or not. "
10494  "Diagnostics: Failure to receive response from manager daemon.",
10495  response_data);
10496  default:
10497  cmd_response_data_set_status_code (response_data,
10498  MHD_HTTP_INTERNAL_SERVER_ERROR);
10499  return gsad_message (
10500  credentials, "Internal error", __FUNCTION__, __LINE__,
10501  "An internal error occurred while creating a new schedule. "
10502  "It is unclear whether the schedule has been created or not. "
10503  "Diagnostics: Internal Error.",
10504  response_data);
10505  }
10506 
10507  if (entity_attribute (entity, "id"))
10508  params_add (params, "schedule_id", entity_attribute (entity, "id"));
10509  ret = response_from_entity (connection, credentials, params, entity,
10510  "Create Schedule", response_data);
10511  free_entity (entity);
10512  g_free (response);
10513  return ret;
10514 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_tag_gmp()

char* create_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a tag, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6305 of file gsad_gmp.c.

6307 {
6308  char *ret;
6309  gchar *response;
6310  const char *name, *comment, *filter, *value, *resource_type, *active;
6311  params_t *resource_ids;
6312  GString *command;
6313  entity_t entity;
6314 
6315  name = params_value (params, "tag_name");
6316  comment = params_value (params, "comment");
6317  filter = params_value (params, "filter");
6318  value = params_value (params, "tag_value");
6319  resource_type = params_value (params, "resource_type");
6320  resource_ids = params_values (params, "resource_ids:");
6321  active = params_value (params, "active");
6322 
6323  CHECK_VARIABLE_INVALID (name, "Create Tags")
6324  CHECK_VARIABLE_INVALID (comment, "Create Tags")
6325  if (params_given (params, "filter"))
6326  CHECK_VARIABLE_INVALID (filter, "Create Tags")
6327  CHECK_VARIABLE_INVALID (value, "Create Tags")
6328  CHECK_VARIABLE_INVALID (resource_type, "Create Tags")
6329  CHECK_VARIABLE_INVALID (active, "Create Tags")
6330 
6331  command = g_string_new ("");
6332 
6333  xml_string_append (command,
6334  "<create_tag>"
6335  "<name>%s</name>"
6336  "<comment>%s</comment>"
6337  "<value>%s</value>"
6338  "<active>%s</active>"
6339  "<resources filter=\"%s\">"
6340  "<type>%s</type>",
6341  name, comment, value, active, filter ? filter : "",
6342  resource_type);
6343 
6344  if (resource_ids)
6345  {
6346  params_iterator_t iter;
6347  char *name;
6348  param_t *param;
6349 
6350  params_iterator_init (&iter, resource_ids);
6351  while (params_iterator_next (&iter, &name, &param))
6352  if (param->value && strcmp (param->value, "0"))
6353  g_string_append_printf (command, "<resource id=\"%s\"/>",
6354  param->value ? param->value : "");
6355  }
6356 
6357  xml_string_append (command, "</resources>"
6358  "</create_tag>");
6359 
6360  response = NULL;
6361  entity = NULL;
6362  switch (gmp (connection, credentials, &response, &entity, response_data,
6363  command->str))
6364  {
6365  case 0:
6366  case -1:
6367  break;
6368  case 1:
6369  cmd_response_data_set_status_code (response_data,
6370  MHD_HTTP_INTERNAL_SERVER_ERROR);
6371  g_string_free (command, TRUE);
6372  return gsad_message (
6373  credentials, "Internal error", __FUNCTION__, __LINE__,
6374  "An internal error occurred while creating a new tag. "
6375  "No new tag was created. "
6376  "Diagnostics: Failure to send command to manager daemon.",
6377  response_data);
6378  case 2:
6379  cmd_response_data_set_status_code (response_data,
6380  MHD_HTTP_INTERNAL_SERVER_ERROR);
6381  g_string_free (command, TRUE);
6382  return gsad_message (
6383  credentials, "Internal error", __FUNCTION__, __LINE__,
6384  "An internal error occurred while creating a new tag. "
6385  "It is unclear whether the tag has been created or not. "
6386  "Diagnostics: Failure to receive response from manager daemon.",
6387  response_data);
6388  default:
6389  cmd_response_data_set_status_code (response_data,
6390  MHD_HTTP_INTERNAL_SERVER_ERROR);
6391  g_string_free (command, TRUE);
6392  return gsad_message (
6393  credentials, "Internal error", __FUNCTION__, __LINE__,
6394  "An internal error occurred while creating a new tag. "
6395  "It is unclear whether the tag has been created or not. "
6396  "Diagnostics: Internal Error.",
6397  response_data);
6398  }
6399 
6400  g_string_free (command, TRUE);
6401  ret = response_from_entity (connection, credentials, params, entity,
6402  "Create Tag", response_data);
6403 
6404  free_entity (entity);
6405  g_free (response);
6406  return ret;
6407 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), and param::value.

Here is the call graph for this function:

◆ create_target_gmp()

char* create_target_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a target, get all targets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5878 of file gsad_gmp.c.

5880 {
5881  int ret;
5882  gchar *html, *response, *command;
5883  const char *name, *hosts, *exclude_hosts, *comment;
5884  const char *target_ssh_credential, *port, *target_smb_credential;
5885  const char *target_esxi_credential, *target_snmp_credential, *target_source;
5886  const char *target_exclude_source;
5887  const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
5888  const char *alive_tests, *hosts_filter, *file, *exclude_file;
5889  gchar *ssh_credentials_element, *smb_credentials_element;
5890  gchar *esxi_credentials_element, *snmp_credentials_element;
5891  gchar *asset_hosts_element;
5892  gchar *comment_element = NULL;
5893  entity_t entity;
5894  GString *xml;
5895 
5896  name = params_value (params, "name");
5897  hosts = params_value (params, "hosts");
5898  exclude_hosts = params_value (params, "exclude_hosts");
5899  reverse_lookup_only = params_value (params, "reverse_lookup_only");
5900  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
5901  target_source = params_value (params, "target_source");
5902  target_exclude_source = params_value (params, "target_exclude_source");
5903  comment = params_value (params, "comment");
5904  port_list_id = params_value (params, "port_list_id");
5905  target_ssh_credential = params_value (params, "ssh_credential_id");
5906  port = params_value (params, "port");
5907  target_smb_credential = params_value (params, "smb_credential_id");
5908  target_esxi_credential = params_value (params, "esxi_credential_id");
5909  target_snmp_credential = params_value (params, "snmp_credential_id");
5910  alive_tests = params_value (params, "alive_tests");
5911  hosts_filter = params_value (params, "hosts_filter");
5912  file = params_value (params, "file");
5913  exclude_file = params_value (params, "exclude_file");
5914 
5915  CHECK_VARIABLE_INVALID (name, "Create Target");
5916  CHECK_VARIABLE_INVALID (target_source, "Create Target")
5917  if (strcmp (target_source, "manual") == 0)
5918  CHECK_VARIABLE_INVALID (hosts, "Create Target");
5919  if (strcmp (target_source, "file") == 0)
5920  CHECK_VARIABLE_INVALID (file, "Create Target")
5921  /* require hosts_filter if target_source is "asset_hosts" */
5922  if (strcmp (target_source, "asset_hosts") == 0)
5923  CHECK_VARIABLE_INVALID (hosts_filter, "Create Target");
5924 
5925  if (params_given (params, "target_exclude_source"))
5926  {
5927  CHECK_VARIABLE_INVALID (target_exclude_source, "Create Target")
5928  if (strcmp (target_exclude_source, "manual") == 0
5929  /* In case browser doesn't send empty field. */
5930  && params_given (params, "exclude_hosts"))
5931  CHECK_VARIABLE_INVALID (exclude_hosts, "Create Target");
5932  if (strcmp (target_exclude_source, "file") == 0)
5933  CHECK_VARIABLE_INVALID (exclude_file, "Create Target");
5934  }
5935 
5936  CHECK_VARIABLE_INVALID (comment, "Create Target");
5937  CHECK_VARIABLE_INVALID (port_list_id, "Create Target");
5938  CHECK_VARIABLE_INVALID (target_ssh_credential, "Create Target");
5939  if (strcmp (target_ssh_credential, "--"))
5940  CHECK_VARIABLE_INVALID (port, "Create Target");
5941  CHECK_VARIABLE_INVALID (target_smb_credential, "Create Target");
5942  CHECK_VARIABLE_INVALID (target_esxi_credential, "Create Target");
5943  CHECK_VARIABLE_INVALID (target_snmp_credential, "Create Target");
5944  CHECK_VARIABLE_INVALID (alive_tests, "Create Target");
5945 
5946  if (comment != NULL)
5947  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
5948  else
5949  comment_element = g_strdup ("");
5950 
5951  if (strcmp (target_ssh_credential, "0") == 0)
5952  ssh_credentials_element = g_strdup ("");
5953  else
5954  ssh_credentials_element = g_strdup_printf ("<ssh_credential id=\"%s\">"
5955  "<port>%s</port>"
5956  "</ssh_credential>",
5957  target_ssh_credential, port);
5958 
5959  if (strcmp (target_smb_credential, "0") == 0)
5960  smb_credentials_element = g_strdup ("");
5961  else
5962  smb_credentials_element =
5963  g_strdup_printf ("<smb_credential id=\"%s\"/>", target_smb_credential);
5964 
5965  if (strcmp (target_esxi_credential, "0") == 0)
5966  esxi_credentials_element = g_strdup ("");
5967  else
5968  esxi_credentials_element =
5969  g_strdup_printf ("<esxi_credential id=\"%s\"/>", target_esxi_credential);
5970 
5971  if (strcmp (target_snmp_credential, "0") == 0)
5972  snmp_credentials_element = g_strdup ("");
5973  else
5974  snmp_credentials_element =
5975  g_strdup_printf ("<snmp_credential id=\"%s\"/>", target_snmp_credential);
5976 
5977  if (strcmp (target_source, "asset_hosts") == 0)
5978  asset_hosts_element = g_markup_printf_escaped ("<asset_hosts"
5979  " filter=\"%s\"/>",
5980  hosts_filter);
5981  else
5982  asset_hosts_element = g_strdup ("");
5983 
5984  /* Create the target. */
5985 
5986  xml = g_string_new ("");
5987 
5988  xml_string_append (xml,
5989  "<name>%s</name>"
5990  "<hosts>%s</hosts>"
5991  "<exclude_hosts>%s</exclude_hosts>"
5992  "<reverse_lookup_only>%s</reverse_lookup_only>"
5993  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
5994  "<port_list id=\"%s\"/>"
5995  "<alive_tests>%s</alive_tests>",
5996  name, strcmp (target_source, "file") == 0 ? file : hosts,
5997  target_exclude_source
5998  ? (strcmp (target_exclude_source, "file") == 0
5999  ? exclude_file
6000  : (exclude_hosts ? exclude_hosts : ""))
6001  : "",
6002  reverse_lookup_only ? reverse_lookup_only : "0",
6003  reverse_lookup_unify ? reverse_lookup_unify : "0",
6004  port_list_id, alive_tests);
6005 
6006  command = g_strdup_printf ("<create_target>"
6007  "%s%s%s%s%s%s%s"
6008  "</create_target>",
6009  xml->str, comment_element, ssh_credentials_element,
6010  smb_credentials_element, esxi_credentials_element,
6011  snmp_credentials_element, asset_hosts_element);
6012 
6013  g_string_free (xml, TRUE);
6014  g_free (comment_element);
6015  g_free (ssh_credentials_element);
6016  g_free (smb_credentials_element);
6017  g_free (esxi_credentials_element);
6018 
6019  ret =
6020  gmp (connection, credentials, &response, &entity, response_data, command);
6021  g_free (command);
6022  switch (ret)
6023  {
6024  case 0:
6025  break;
6026  case -1:
6027  /* 'gmp' set response. */
6028  return response;
6029  case 1:
6030  cmd_response_data_set_status_code (response_data,
6031  MHD_HTTP_INTERNAL_SERVER_ERROR);
6032  return gsad_message (
6033  credentials, "Internal error", __FUNCTION__, __LINE__,
6034  "An internal error occurred while creating a new target. "
6035  "No new target was created. "
6036  "Diagnostics: Failure to send command to manager daemon.",
6037  response_data);
6038  case 2:
6039  cmd_response_data_set_status_code (response_data,
6040  MHD_HTTP_INTERNAL_SERVER_ERROR);
6041  return gsad_message (
6042  credentials, "Internal error", __FUNCTION__, __LINE__,
6043  "An internal error occurred while creating a new target. "
6044  "It is unclear whether the target has been created or not. "
6045  "Diagnostics: Failure to receive response from manager daemon.",
6046  response_data);
6047  default:
6048  cmd_response_data_set_status_code (response_data,
6049  MHD_HTTP_INTERNAL_SERVER_ERROR);
6050  return gsad_message (
6051  credentials, "Internal error", __FUNCTION__, __LINE__,
6052  "An internal error occurred while creating a new target. "
6053  "It is unclear whether the target has been created or not. "
6054  "Diagnostics: Internal Error.",
6055  response_data);
6056  }
6057 
6058  if (entity_attribute (entity, "id"))
6059  params_add (params, "target_id", entity_attribute (entity, "id"));
6060  html = response_from_entity (connection, credentials, params, entity,
6061  "Create Target", response_data);
6062  free_entity (entity);
6063  g_free (response);
6064  return html;
6065 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_task_gmp()

char* create_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a task, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2121 of file gsad_gmp.c.

2123 {
2124  entity_t entity;
2125  int ret;
2126  gchar *schedule_element, *command;
2127  gchar *response, *html;
2128  const char *name, *comment, *config_id, *target_id, *scanner_type;
2129  const char *scanner_id, *schedule_id, *schedule_periods;
2130  const char *max_checks, *max_hosts;
2131  const char *in_assets, *hosts_ordering, *alterable, *source_iface;
2132  const char *add_tag, *tag_id, *auto_delete, *auto_delete_data;
2133  const char *apply_overrides, *min_qod, *usage_type;
2134  gchar *name_escaped, *comment_escaped;
2135  params_t *alerts;
2136  GString *alert_element;
2137 
2138  add_tag = params_value (params, "add_tag");
2139  alterable = params_value (params, "alterable");
2140  apply_overrides = params_value (params, "apply_overrides");
2141  auto_delete = params_value (params, "auto_delete");
2142  auto_delete_data = params_value (params, "auto_delete_data");
2143  comment = params_value (params, "comment");
2144  config_id = params_value (params, "config_id");
2145  hosts_ordering = params_value (params, "hosts_ordering");
2146  in_assets = params_value (params, "in_assets");
2147  max_checks = params_value (params, "max_checks");
2148  max_hosts = params_value (params, "max_hosts");
2149  min_qod = params_value (params, "min_qod");
2150  name = params_value (params, "name");
2151  scanner_id = params_value (params, "scanner_id");
2152  scanner_type = params_value (params, "scanner_type");
2153  schedule_id = params_value (params, "schedule_id");
2154  schedule_periods = params_value (params, "schedule_periods");
2155  source_iface = params_value (params, "source_iface");
2156  tag_id = params_value (params, "tag_id");
2157  target_id = params_value (params, "target_id");
2158  usage_type = params_value (params, "usage_type");
2159 
2160  CHECK_VARIABLE_INVALID (scanner_type, "Create Task");
2161  if (!strcmp (scanner_type, "1"))
2162  {
2163  hosts_ordering = "";
2164  max_checks = "";
2165  source_iface = "";
2166  max_hosts = "";
2167  }
2168  else if (!strcmp (scanner_type, "3"))
2169  {
2170  config_id = "";
2171  hosts_ordering = "";
2172  max_checks = "";
2173  source_iface = "";
2174  max_hosts = "";
2175  }
2176 
2177  CHECK_VARIABLE_INVALID (name, "Create Task");
2178  CHECK_VARIABLE_INVALID (comment, "Create Task");
2179  CHECK_VARIABLE_INVALID (usage_type, "Create Task");
2180  CHECK_VARIABLE_INVALID (config_id, "Create Task");
2181  CHECK_VARIABLE_INVALID (target_id, "Create Task");
2182  CHECK_VARIABLE_INVALID (hosts_ordering, "Create Task");
2183  CHECK_VARIABLE_INVALID (scanner_id, "Create Task");
2184  CHECK_VARIABLE_INVALID (schedule_id, "Create Task");
2185 
2186  if (str_equal (target_id, "0"))
2187  {
2188  /* Don't allow to create container task via create_task */
2189  return message_invalid (connection, credentials, params, response_data,
2190  "Given target_id was invalid", "Create Task");
2191  }
2192 
2193  if (params_given (params, "schedule_periods"))
2194  {
2195  CHECK_VARIABLE_INVALID (schedule_periods, "Create Task");
2196  }
2197  else
2198  schedule_periods = "0";
2199 
2200  CHECK_VARIABLE_INVALID (in_assets, "Create Task");
2201 
2202  if (!strcmp (in_assets, "1"))
2203  {
2204  CHECK_VARIABLE_INVALID (apply_overrides, "Create Task");
2205  CHECK_VARIABLE_INVALID (min_qod, "Create Task");
2206  }
2207  else
2208  {
2209  if (!params_given (params, "apply_overrides")
2210  || !params_valid (params, "apply_overrides"))
2211  apply_overrides = "";
2212 
2213  if (!params_given (params, "min_qod")
2214  || !params_valid (params, "min_qod"))
2215  min_qod = "";
2216  }
2217 
2218  CHECK_VARIABLE_INVALID (max_checks, "Create Task");
2219  CHECK_VARIABLE_INVALID (source_iface, "Create Task");
2220  CHECK_VARIABLE_INVALID (auto_delete, "Create Task");
2221  CHECK_VARIABLE_INVALID (auto_delete_data, "Create Task");
2222  CHECK_VARIABLE_INVALID (max_hosts, "Create Task");
2223  CHECK_VARIABLE_INVALID (alterable, "Create Task");
2224 
2225  if (add_tag && strcmp (add_tag, "1") == 0)
2226  {
2227  CHECK_VARIABLE_INVALID (tag_id, "Create Task");
2228  }
2229 
2230  if (schedule_id == NULL || strcmp (schedule_id, "0") == 0)
2231  schedule_element = g_strdup ("");
2232  else
2233  schedule_element = g_strdup_printf ("<schedule id=\"%s\"/>", schedule_id);
2234 
2235  alert_element = g_string_new ("");
2236  if (params_given (params, "alert_id_optional:"))
2237  alerts = params_values (params, "alert_id_optional:");
2238  else
2239  alerts = params_values (params, "alert_ids:");
2240 
2241  if (alerts)
2242  {
2243  params_iterator_t iter;
2244  char *name;
2245  param_t *param;
2246 
2247  params_iterator_init (&iter, alerts);
2248  while (params_iterator_next (&iter, &name, &param))
2249  if (param->value && strcmp (param->value, "0"))
2250  g_string_append_printf (alert_element, "<alert id=\"%s\"/>",
2251  param->value ? param->value : "");
2252  }
2253 
2254  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
2255  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
2256 
2257  command = g_strdup_printf (
2258  "<create_task>"
2259  "<config id=\"%s\"/>"
2260  "<schedule_periods>%s</schedule_periods>"
2261  "%s%s"
2262  "<target id=\"%s\"/>"
2263  "<scanner id=\"%s\"/>"
2264  "<hosts_ordering>%s</hosts_ordering>"
2265  "<name>%s</name>"
2266  "<comment>%s</comment>"
2267  "<preferences>"
2268  "<preference>"
2269  "<scanner_name>max_checks</scanner_name>"
2270  "<value>%s</value>"
2271  "</preference>"
2272  "<preference>"
2273  "<scanner_name>max_hosts</scanner_name>"
2274  "<value>%s</value>"
2275  "</preference>"
2276  "<preference>"
2277  "<scanner_name>in_assets</scanner_name>"
2278  "<value>%s</value>"
2279  "</preference>"
2280  "<preference>"
2281  "<scanner_name>"
2282  "assets_apply_overrides"
2283  "</scanner_name>"
2284  "<value>%s</value>"
2285  "</preference>"
2286  "<preference>"
2287  "<scanner_name>assets_min_qod</scanner_name>"
2288  "<value>%s</value>"
2289  "</preference>"
2290  "<preference>"
2291  "<scanner_name>source_iface</scanner_name>"
2292  "<value>%s</value>"
2293  "</preference>"
2294  "<preference>"
2295  "<scanner_name>auto_delete</scanner_name>"
2296  "<value>%s</value>"
2297  "</preference>"
2298  "<preference>"
2299  "<scanner_name>auto_delete_data</scanner_name>"
2300  "<value>%s</value>"
2301  "</preference>"
2302  "</preferences>"
2303  "<alterable>%i</alterable>"
2304  "<usage_type>%s</usage_type>"
2305  "</create_task>",
2306  config_id, schedule_periods, schedule_element, alert_element->str,
2307  target_id, scanner_id, hosts_ordering, name_escaped, comment_escaped,
2308  max_checks, max_hosts, strcmp (in_assets, "0") ? "yes" : "no",
2309  strcmp (apply_overrides, "0") ? "yes" : "no", min_qod, source_iface,
2310  auto_delete, auto_delete_data, alterable ? strcmp (alterable, "0") : 0,
2311  usage_type);
2312 
2313  g_free (name_escaped);
2314  g_free (comment_escaped);
2315 
2316  ret =
2317  gmp (connection, credentials, &response, &entity, response_data, command);
2318  g_free (command);
2319 
2320  g_free (schedule_element);
2321  g_string_free (alert_element, TRUE);
2322 
2323  switch (ret)
2324  {
2325  case 0:
2326  break;
2327  case -1:
2328  /* 'gmp' set response. */
2329  return response;
2330  case 1:
2331  cmd_response_data_set_status_code (response_data,
2332  MHD_HTTP_INTERNAL_SERVER_ERROR);
2333  return gsad_message (
2334  credentials, "Internal error", __FUNCTION__, __LINE__,
2335  "An internal error occurred while creating a new task. "
2336  "No new task was created. "
2337  "Diagnostics: Failure to send command to manager daemon.",
2338  response_data);
2339  case 2:
2340  cmd_response_data_set_status_code (response_data,
2341  MHD_HTTP_INTERNAL_SERVER_ERROR);
2342  return gsad_message (
2343  credentials, "Internal error", __FUNCTION__, __LINE__,
2344  "An internal error occurred while creating a new task. "
2345  "It is unclear whether the task has been created or not. "
2346  "Diagnostics: Failure to receive response from manager daemon.",
2347  response_data);
2348  default:
2349  cmd_response_data_set_status_code (response_data,
2350  MHD_HTTP_INTERNAL_SERVER_ERROR);
2351  return gsad_message (
2352  credentials, "Internal error", __FUNCTION__, __LINE__,
2353  "An internal error occurred while creating a new task. "
2354  "It is unclear whether the task has been created or not. "
2355  "Diagnostics: Internal Error.",
2356  response_data);
2357  }
2358 
2359  if (gmp_success (entity))
2360  {
2361  if (add_tag && strcmp (add_tag, "1") == 0)
2362  {
2363  const char *new_task_id = entity_attribute (entity, "id");
2364  gchar *tag_command, *tag_response;
2365  entity_t tag_entity;
2366 
2367  tag_command = g_markup_printf_escaped ("<modify_tag tag_id=\"%s\">"
2368  "<resources action=\"add\">"
2369  "<resource id=\"%s\"/>"
2370  "</resources>"
2371  "</modify_tag>",
2372  tag_id, new_task_id);
2373 
2374  ret = gmp (connection, credentials, &tag_response, &tag_entity,
2375  response_data, tag_command);
2376 
2377  switch (ret)
2378  {
2379  case 0:
2380  case -1:
2381  break;
2382  case 1:
2383  free_entity (entity);
2384  g_free (response);
2386  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2387  return gsad_message (
2388  credentials, "Internal error", __FUNCTION__, __LINE__,
2389  "An internal error occurred while creating a new tag. "
2390  "No new tag was created. "
2391  "Diagnostics: Failure to send command to manager daemon.",
2392  response_data);
2393  case 2:
2394  free_entity (entity);
2395  g_free (response);
2397  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2398  return gsad_message (
2399  credentials, "Internal error", __FUNCTION__, __LINE__,
2400  "An internal error occurred while creating a new tag. "
2401  "It is unclear whether the tag has been created or not. "
2402  "Diagnostics: Failure to receive response from manager daemon.",
2403  response_data);
2404  default:
2405  free_entity (entity);
2406  g_free (response);
2408  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2409  return gsad_message (
2410  credentials, "Internal error", __FUNCTION__, __LINE__,
2411  "An internal error occurred while creating a new task. "
2412  "It is unclear whether the tag has been created or not. "
2413  "Diagnostics: Internal Error.",
2414  response_data);
2415  }
2416 
2417  if (entity_attribute (entity, "id"))
2418  params_add (params, "task_id", entity_attribute (entity, "id"));
2419  html =
2420  response_from_entity (connection, credentials, params, tag_entity,
2421  "Create Task and Tag", response_data);
2422  free_entity (tag_entity);
2423  g_free (tag_response);
2424  }
2425  else
2426  {
2427  if (entity_attribute (entity, "id"))
2428  params_add (params, "task_id", entity_attribute (entity, "id"));
2429  html = response_from_entity (connection, credentials, params, entity,
2430  "Create Task", response_data);
2431  }
2432  }
2433  else
2434  {
2435  html = response_from_entity (connection, credentials, params, entity,
2436  "Create Task", response_data);
2437  }
2438  free_entity (entity);
2439  g_free (response);
2440  return html;
2441 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gmp_success(), gsad_message(), message_invalid(), params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_valid(), params_value(), params_values(), response_from_entity(), str_equal(), and param::value.

Here is the call graph for this function:

◆ create_ticket_gmp()

char* create_ticket_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a ticket.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16620 of file gsad_gmp.c.

16622 {
16623  gchar *response = NULL;
16624  entity_t entity = NULL;
16625  const gchar *result_id, *user_id, *note;
16626  char *ret;
16627 
16628  result_id = params_value (params, "result_id");
16629  user_id = params_value (params, "user_id");
16630  note = params_value (params, "note");
16631 
16632  CHECK_VARIABLE_INVALID (result_id, "Create Ticket");
16633  CHECK_VARIABLE_INVALID (user_id, "Create Ticket");
16634  CHECK_VARIABLE_INVALID (note, "Create Ticket")
16635 
16636  switch (gmpf (connection, credentials, &response, &entity, response_data,
16637  "<create_ticket>"
16638  "<result id=\"%s\"/>"
16639  "<assigned_to>"
16640  "<user id=\"%s\"/>"
16641  "</assigned_to>"
16642  "<open_note>%s</open_note>"
16643  "</create_ticket>",
16644  result_id, user_id, note ? note : ""))
16645  {
16646  case 0:
16647  case -1:
16648  break;
16649  case 1:
16650  cmd_response_data_set_status_code (response_data,
16651  MHD_HTTP_INTERNAL_SERVER_ERROR);
16652  return gsad_message (
16653  credentials, "Internal error", __FUNCTION__, __LINE__,
16654  "An internal error occurred while creating a ticket. "
16655  "Diagnostics: Failure to send command to manager daemon.",
16656  response_data);
16657  case 2:
16658  cmd_response_data_set_status_code (response_data,
16659  MHD_HTTP_INTERNAL_SERVER_ERROR);
16660  return gsad_message (
16661  credentials, "Internal error", __FUNCTION__, __LINE__,
16662  "An internal error occurred while creating a ticket. "
16663  "It is unclear whether the ticket has been created or not. "
16664  "Diagnostics: Failure to receive response from manager daemon.",
16665  response_data);
16666  default:
16667  cmd_response_data_set_status_code (response_data,
16668  MHD_HTTP_INTERNAL_SERVER_ERROR);
16669  return gsad_message (
16670  credentials, "Internal error", __FUNCTION__, __LINE__,
16671  "An internal error occurred while creating a ticket. "
16672  "It is unclear whether the ticket has been created or not. "
16673  "Diagnostics: Internal Error.",
16674  response_data);
16675  }
16676 
16677  ret = response_from_entity (connection, credentials, params, entity,
16678  "Create Ticket", response_data);
16679 
16680  free_entity (entity);
16681  g_free (response);
16682  return ret;
16683 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ create_tls_certificate_gmp()

char* create_tls_certificate_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a TLS certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16859 of file gsad_gmp.c.

16862 {
16863  gchar *response = NULL;
16864  entity_t entity = NULL;
16865  const gchar *name, *comment, *trust, *certificate_bin;
16866  size_t certificate_size;
16867  gchar *certificate_b64;
16868  gchar *ret;
16869 
16870  name = params_value (params, "name");
16871  comment = params_value (params, "comment");
16872  trust = params_value (params, "trust");
16873  certificate_bin = params_value (params, "certificate_bin");
16874  certificate_size = params_value_size (params, "certificate_bin");
16875 
16876  certificate_b64 =
16877  (certificate_size > 0)
16878  ? g_base64_encode ((guchar *) certificate_bin, certificate_size)
16879  : g_strdup ("");
16880 
16881  CHECK_VARIABLE_INVALID (name, "Create TLS Certificate");
16882  CHECK_VARIABLE_INVALID (comment, "Create TLS Certificate");
16883  CHECK_VARIABLE_INVALID (trust, "Create TLS Certificate");
16884 
16885  switch (gmpf (connection, credentials, &response, &entity, response_data,
16886  "<create_tls_certificate>"
16887  "<name>%s</name>"
16888  "<comment>%s</comment>"
16889  "<trust>%s</trust>"
16890  "<certificate>%s</certificate>"
16891  "</create_tls_certificate>",
16892  name, comment, trust, certificate_b64))
16893  {
16894  case 0:
16895  case -1:
16896  break;
16897  case 1:
16898  cmd_response_data_set_status_code (response_data,
16899  MHD_HTTP_INTERNAL_SERVER_ERROR);
16900  return gsad_message (
16901  credentials, "Internal error", __FUNCTION__, __LINE__,
16902  "An internal error occurred while creating a TLS certificate. "
16903  "Diagnostics: Failure to send command to manager daemon.",
16904  response_data);
16905  case 2:
16906  cmd_response_data_set_status_code (response_data,
16907  MHD_HTTP_INTERNAL_SERVER_ERROR);
16908  return gsad_message (
16909  credentials, "Internal error", __FUNCTION__, __LINE__,
16910  "An internal error occurred while creating a TLS certificate. "
16911  "It is unclear whether the TLS certificate has been created or not. "
16912  "Diagnostics: Failure to receive response from manager daemon.",
16913  response_data);
16914  default:
16915  cmd_response_data_set_status_code (response_data,
16916  MHD_HTTP_INTERNAL_SERVER_ERROR);
16917  return gsad_message (
16918  credentials, "Internal error", __FUNCTION__, __LINE__,
16919  "An internal error occurred while creating a TLS certificate. "
16920  "It is unclear whether the TLS certificate has been created or not. "
16921  "Diagnostics: Internal Error.",
16922  response_data);
16923  }
16924 
16925  ret = response_from_entity (connection, credentials, params, entity,
16926  "Create TLS Certificate", response_data);
16927 
16928  free_entity (entity);
16929  g_free (response);
16930  g_free (certificate_b64);
16931  return ret;
16932 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), params_value_size(), and response_from_entity().

Here is the call graph for this function:

◆ create_user_gmp()

char* create_user_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Create a user, get all users, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14763 of file gsad_gmp.c.

14765 {
14766  const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
14767  const char *auth_method, *comment;
14768  int ret;
14769  params_t *groups, *roles;
14770  GString *group_elements, *role_elements, *string;
14771  gchar *buf, *response, *html;
14772  entity_t entity;
14773 
14774  name = params_value (params, "login");
14775  password = params_value (params, "password");
14776  hosts = params_value (params, "access_hosts");
14777  hosts_allow = params_value (params, "hosts_allow");
14778  ifaces = params_value (params, "access_ifaces");
14779  ifaces_allow = params_value (params, "ifaces_allow");
14780  auth_method = params_value (params, "auth_method");
14781  comment = params_value (params, "comment");
14782 
14783  CHECK_VARIABLE_INVALID (name, "Create User");
14784  CHECK_VARIABLE_INVALID (hosts, "Create User");
14785  CHECK_VARIABLE_INVALID (hosts_allow, "Create User");
14786  CHECK_VARIABLE_INVALID (ifaces, "Create User");
14787  CHECK_VARIABLE_INVALID (ifaces_allow, "Create User");
14788 
14789  if (auth_method && strcmp (auth_method, "1") == 0)
14790  {
14791  CHECK_VARIABLE_INVALID (password, "Create User");
14792  }
14793 
14794  if (params_given (params, "comment"))
14795  {
14796  CHECK_VARIABLE_INVALID (comment, "Create User");
14797  }
14798 
14799  /* Create the user. */
14800 
14801  string = g_string_new ("<create_user>");
14802  buf = g_markup_printf_escaped ("<name>%s</name>"
14803  "<password>%s</password>",
14804  name, password ? password : "");
14805 
14806  g_string_append (string, buf);
14807  g_free (buf);
14808 
14809  group_elements = g_string_new ("<groups>");
14810  if (params_given (params, "group_id_optional:"))
14811  groups = params_values (params, "group_id_optional:");
14812  else
14813  groups = params_values (params, "group_ids:");
14814 
14815  if (groups)
14816  {
14817  params_iterator_t iter;
14818  char *name;
14819  param_t *param;
14820 
14821  params_iterator_init (&iter, groups);
14822  while (params_iterator_next (&iter, &name, &param))
14823  {
14824  if (param->value && strcmp (param->value, "--"))
14825  g_string_append_printf (group_elements, "<group id=\"%s\"/>",
14826  param->value ? param->value : "");
14827  }
14828  }
14829  g_string_append (string, group_elements->str);
14830  g_string_free (group_elements, TRUE);
14831  g_string_append (string, "</groups>");
14832 
14833  role_elements = g_string_new ("");
14834  if (params_given (params, "role_id_optional:"))
14835  roles = params_values (params, "role_id_optional:");
14836  else
14837  roles = params_values (params, "role_ids:");
14838 
14839  if (roles)
14840  {
14841  params_iterator_t iter;
14842  char *name;
14843  param_t *param;
14844 
14845  params_iterator_init (&iter, roles);
14846  while (params_iterator_next (&iter, &name, &param))
14847  {
14848  if (param->value && strcmp (param->value, "--"))
14849  g_string_append_printf (role_elements, "<role id=\"%s\"/>",
14850  param->value ? param->value : "");
14851  }
14852  }
14853  g_string_append (string, role_elements->str);
14854  g_string_free (role_elements, TRUE);
14855 
14856  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
14857  "<ifaces allow=\"%s\">%s</ifaces>",
14858  hosts_allow, hosts, ifaces_allow, ifaces);
14859  g_string_append (string, buf);
14860  g_free (buf);
14861  if (auth_method && !strcmp (auth_method, "1"))
14862  g_string_append (string,
14863  "<sources><source>ldap_connect</source></sources>");
14864  else if (auth_method && !strcmp (auth_method, "2"))
14865  g_string_append (string,
14866  "<sources><source>radius_connect</source></sources>");
14867 
14868  if (comment)
14869  {
14870  xml_string_append (string, "<comment>%s</comment>", comment);
14871  }
14872 
14873  g_string_append (string, "</create_user>");
14874 
14875  buf = g_string_free (string, FALSE);
14876 
14877  response = NULL;
14878  entity = NULL;
14879  ret = gmp (connection, credentials, &response, &entity, response_data, buf);
14880  g_free (buf);
14881  switch (ret)
14882  {
14883  case 0:
14884  case -1:
14885  break;
14886  case 1:
14887  cmd_response_data_set_status_code (response_data,
14888  MHD_HTTP_INTERNAL_SERVER_ERROR);
14889  return gsad_message (
14890  credentials, "Internal error", __FUNCTION__, __LINE__,
14891  "An internal error occurred while creating a new user. "
14892  "No new user was created. "
14893  "Diagnostics: Failure to send command to manager daemon.",
14894  response_data);
14895  case 2:
14896  cmd_response_data_set_status_code (response_data,
14897  MHD_HTTP_INTERNAL_SERVER_ERROR);
14898  return gsad_message (
14899  credentials, "Internal error", __FUNCTION__, __LINE__,
14900  "An internal error occurred while creating a new user. "
14901  "It is unclear whether the user has been created or not. "
14902  "Diagnostics: Failure to receive response from manager daemon.",
14903  response_data);
14904  default:
14905  cmd_response_data_set_status_code (response_data,
14906  MHD_HTTP_INTERNAL_SERVER_ERROR);
14907  return gsad_message (
14908  credentials, "Internal error", __FUNCTION__, __LINE__,
14909  "An internal error occurred while creating a new user. "
14910  "It is unclear whether the user has been created or not. "
14911  "Diagnostics: Internal Error.",
14912  response_data);
14913  }
14914 
14915  if (entity_attribute (entity, "id"))
14916  params_add (params, "user_id", entity_attribute (entity, "id"));
14917  html = response_from_entity (connection, credentials, params, entity,
14918  "Create User", response_data);
14919  free_entity (entity);
14920  g_free (response);
14921  return html;
14922 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), and param::value.

Here is the call graph for this function:

◆ cvss_calculator()

char* cvss_calculator ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Definition at line 15279 of file gsad_gmp.c.

15281 {
15282  GString *xml;
15283  const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
15284  const char *cvss_vector, *name;
15285 
15286  cvss_av = params_value (params, "cvss_av");
15287  cvss_au = params_value (params, "cvss_au");
15288  cvss_ac = params_value (params, "cvss_ac");
15289  cvss_c = params_value (params, "cvss_c");
15290  cvss_i = params_value (params, "cvss_i");
15291  cvss_a = params_value (params, "cvss_a");
15292  cvss_vector = params_value (params, "cvss_vector");
15293  name = params_value (params, "name");
15294 
15295  xml = g_string_new ("<cvss_calculator>");
15296 
15297  /* Calculate base score */
15298  if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
15299  {
15300  char *vector =
15301  g_strdup_printf ("AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c", *cvss_av, *cvss_ac,
15302  *cvss_au, *cvss_c, *cvss_i, *cvss_a);
15303 
15304  g_string_append_printf (xml,
15305  "<cvss_vector>%s</cvss_vector>"
15306  "<cvss_score>%.1f</cvss_score>",
15307  vector,
15308  get_cvss_score_from_base_metrics (vector));
15309 
15310  g_string_append_printf (xml,
15311  "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>"
15312  "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>"
15313  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
15314  *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i,
15315  *cvss_a);
15316 
15317  g_free (vector);
15318  }
15319  else if (cvss_vector)
15320  {
15321  double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
15322 
15323  g_string_append_printf (xml,
15324  "<cvss_vector>%s</cvss_vector>"
15325  "<cvss_score>%.1f</cvss_score>",
15326  cvss_vector, cvss_score);
15327 
15328  if (cvss_score != -1.0)
15329  {
15330  cvss_av = strstr (cvss_vector, "AV:");
15331  cvss_ac = strstr (cvss_vector, "/AC:");
15332  cvss_au = strstr (cvss_vector, "/Au:");
15333  if (cvss_au == NULL)
15334  cvss_au = strstr (cvss_vector, "/AU:");
15335  cvss_c = strstr (cvss_vector, "/C:");
15336  cvss_i = strstr (cvss_vector, "/I:");
15337  cvss_a = strstr (cvss_vector, "/A:");
15338 
15339  if (cvss_av && cvss_ac && cvss_au && cvss_c && cvss_i && cvss_a)
15340  g_string_append_printf (xml,
15341  "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>"
15342  "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>"
15343  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
15344  *(cvss_av + 3), *(cvss_ac + 4),
15345  *(cvss_au + 4), *(cvss_c + 3),
15346  *(cvss_i + 3), *(cvss_a + 3));
15347  }
15348  }
15349  else if (name && !strcmp ("vector", name))
15350  {
15351  g_string_append_printf (xml, "<cvss_score>%.1f</cvss_score>", -1.0);
15352  }
15353 
15354  g_string_append (xml, "</cvss_calculator>");
15355  return envelope_gmp (connection, credentials, params,
15356  g_string_free (xml, FALSE), response_data);
15357 }

References envelope_gmp(), and params_value().

Here is the call graph for this function:

◆ delete_agent_gmp()

char* delete_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete agent, get all agents, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4061 of file gsad_gmp.c.

4063 {
4064  return move_resource_to_trash (connection, "agent", credentials, params,
4065  response_data);
4066 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_alert_gmp()

char* delete_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete an alert, get all alerts, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5309 of file gsad_gmp.c.

5311 {
5312  return move_resource_to_trash (connection, "alert", credentials, params,
5313  response_data);
5314 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_asset_gmp()

char* delete_asset_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete an asset, go to the next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16385 of file gsad_gmp.c.

16387 {
16388  gchar *html, *response, *resource_id;
16389  const char *next_id;
16390  entity_t entity;
16391 
16392  if (params_value (params, "asset_id"))
16393  resource_id = g_strdup (params_value (params, "asset_id"));
16394  else if (params_value (params, "report_id"))
16395  resource_id = g_strdup (params_value (params, "report_id"));
16396  else
16397  {
16398  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
16399  return gsad_message (
16400  credentials, "Internal error", __FUNCTION__, __LINE__,
16401  "An internal error occurred while deleting an asset. "
16402  "The asset was not deleted. "
16403  "Diagnostics: Required parameter was NULL.",
16404  response_data);
16405  }
16406 
16407  /* This is a hack, needed because asset_id is the param name used for
16408  * both the asset being deleted and the asset on the next page. */
16409  next_id = params_value (params, "next_id");
16410  if (next_id && params_value (params, "asset_id"))
16411  {
16412  param_t *param;
16413  param = params_get (params, "asset_id");
16414  g_free (param->value);
16415  param->value = g_strdup (next_id);
16416  param->value_size = strlen (param->value);
16417  }
16418 
16419  /* Delete the resource and get all resources. */
16420 
16421  if (gvm_connection_sendf (
16422  connection, "<delete_asset %s_id=\"%s\"/>",
16423  params_value (params, "asset_id") ? "asset" : "report", resource_id)
16424  == -1)
16425  {
16426  g_free (resource_id);
16427  cmd_response_data_set_status_code (response_data,
16428  MHD_HTTP_INTERNAL_SERVER_ERROR);
16429  return gsad_message (
16430  credentials, "Internal error", __FUNCTION__, __LINE__,
16431  "An internal error occurred while deleting an asset. "
16432  "The asset is not deleted. "
16433  "Diagnostics: Failure to send command to manager daemon.",
16434  response_data);
16435  }
16436 
16437  g_free (resource_id);
16438 
16439  entity = NULL;
16440  if (read_entity_and_text_c (connection, &entity, &response))
16441  {
16442  cmd_response_data_set_status_code (response_data,
16443  MHD_HTTP_INTERNAL_SERVER_ERROR);
16444  return gsad_message (
16445  credentials, "Internal error", __FUNCTION__, __LINE__,
16446  "An internal error occurred while deleting an asset. "
16447  "It is unclear whether the asset has been deleted or not. "
16448  "Diagnostics: Failure to read response from manager daemon.",
16449  response_data);
16450  }
16451 
16452  /* Cleanup, and return transformed XML. */
16453 
16454  html = response_from_entity (connection, credentials, params, entity,
16455  "Delete Asset", response_data);
16456  g_free (response);
16457  free_entity (entity);
16458  return html;
16459 }

References cmd_response_data_set_status_code(), gsad_message(), params_get(), params_value(), response_from_entity(), param::value, and param::value_size.

Here is the call graph for this function:

◆ delete_config_gmp()

char* delete_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete config, get all configs, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 8147 of file gsad_gmp.c.

8149 {
8150  return move_resource_to_trash (connection, "config", credentials, params,
8151  response_data);
8152 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_credential_gmp()

char* delete_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete credential, get all credentials, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3662 of file gsad_gmp.c.

3664 {
3665  return move_resource_to_trash (connection, "credential", credentials, params,
3666  response_data);
3667 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_filter_gmp()

char* delete_filter_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a filter, get all filters, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14382 of file gsad_gmp.c.

14384 {
14385  return move_resource_to_trash (connection, "filter", credentials, params,
14386  response_data);
14387 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_from_trash_gmp()

char* delete_from_trash_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a resource from the trashcan.

Parameters
[in]connectionConnection to manager.
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1723 of file gsad_gmp.c.

1725 {
1726  const gchar *resource_type;
1727 
1728  resource_type = params_value (params, "resource_type");
1729 
1730  CHECK_VARIABLE_INVALID (resource_type, "Delete from Trashcan");
1731 
1732  return delete_resource (connection, resource_type, credentials, params, TRUE,
1733  response_data);
1734 }

References CHECK_VARIABLE_INVALID, delete_resource(), and params_value().

Here is the call graph for this function:

◆ delete_group_gmp()

char* delete_group_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a group, get all groups, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12388 of file gsad_gmp.c.

12390 {
12391  return move_resource_to_trash (connection, "group", credentials, params,
12392  response_data);
12393 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_note_gmp()

char* delete_note_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete note, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9525 of file gsad_gmp.c.

9527 {
9528  return move_resource_to_trash (connection, "note", credentials, params,
9529  response_data);
9530 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_override_gmp()

char* delete_override_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete override, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9828 of file gsad_gmp.c.

9830 {
9831  return move_resource_to_trash (connection, "override", credentials, params,
9832  response_data);
9833 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_permission_gmp()

char* delete_permission_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a permission, get all permissions, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12687 of file gsad_gmp.c.

12689 {
12690  return move_resource_to_trash (connection, "permission", credentials, params,
12691  response_data);
12692 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_port_list_gmp()

char* delete_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a port list, get all port lists, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13684 of file gsad_gmp.c.

13686 {
13687  return move_resource_to_trash (connection, "port_list", credentials, params,
13688  response_data);
13689 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_port_range_gmp()

char* delete_port_range_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a port range, get the port list, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13702 of file gsad_gmp.c.

13704 {
13705  return delete_resource (connection, "port_range", credentials, params, TRUE,
13706  response_data);
13707 }

References delete_resource().

Here is the call graph for this function:

◆ delete_report_format_gmp()

char* delete_report_format_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete report format, get report formats, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10915 of file gsad_gmp.c.

10918 {
10919  return move_resource_to_trash (connection, "report_format", credentials,
10920  params, response_data);
10921 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_report_gmp()

char* delete_report_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete report, get task status, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 8448 of file gsad_gmp.c.

8450 {
8451  return delete_resource (connection, "report", credentials, params, TRUE,
8452  response_data);
8453 }

References delete_resource().

Here is the call graph for this function:

◆ delete_resource()

char* delete_resource ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
gboolean  ultimate,
cmd_response_data_t *  response_data 
)

Delete a resource, get all resources, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]ultimate0 move to trash, 1 remove entirely.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1596 of file gsad_gmp.c.

1599 {
1600  gchar *html, *response, *id_name, *resource_id, *extra_attribs;
1601  entity_t entity;
1602  gchar *cap_type, *prev_action;
1603 
1604  id_name = g_strdup_printf ("%s_id", type);
1605  if (params_value (params, id_name))
1606  resource_id = g_strdup (params_value (params, id_name));
1607  else
1608  {
1609  g_free (id_name);
1610  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
1611  return gsad_message (
1612  credentials, "Internal error", __FUNCTION__, __LINE__,
1613  "An internal error occurred while deleting a resource. "
1614  "The resource was not deleted. "
1615  "Diagnostics: Required parameter resource_id was NULL.",
1616  response_data);
1617  }
1618 
1619  /* This is a hack for assets, because asset_id is the param name used for
1620  * both the asset being deleted and the asset on the next page. */
1621  g_free (id_name);
1622 
1623  /* Extra attributes */
1624  extra_attribs = NULL;
1625 
1626  /* Inheritor of user's resource */
1627  if (strcmp (type, "user") == 0)
1628  {
1629  const char *inheritor_id;
1630  inheritor_id = params_value (params, "inheritor_id");
1631  if (inheritor_id)
1632  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
1633  else if (params_given (params, "inheritor_id"))
1634  return message_invalid (connection, credentials, params, response_data,
1635  "Invalid inheritor_id", "Delete User");
1636  }
1637 
1638  /* Delete the resource and get all resources. */
1639 
1640  if (gvm_connection_sendf (
1641  connection, "<delete_%s %s_id=\"%s\" ultimate=\"%i\"%s%s/>", type, type,
1642  resource_id, !!ultimate, extra_attribs ? " " : "",
1643  extra_attribs ? extra_attribs : "")
1644  == -1)
1645  {
1646  g_free (resource_id);
1647  g_free (extra_attribs);
1648  cmd_response_data_set_status_code (response_data,
1649  MHD_HTTP_INTERNAL_SERVER_ERROR);
1650  return gsad_message (
1651  credentials, "Internal error", __FUNCTION__, __LINE__,
1652  "An internal error occurred while deleting a resource. "
1653  "The resource is not deleted. "
1654  "Diagnostics: Failure to send command to manager daemon.",
1655  response_data);
1656  }
1657 
1658  g_free (resource_id);
1659  g_free (extra_attribs);
1660 
1661  entity = NULL;
1662  if (read_entity_and_text_c (connection, &entity, &response))
1663  {
1664  cmd_response_data_set_status_code (response_data,
1665  MHD_HTTP_INTERNAL_SERVER_ERROR);
1666  return gsad_message (
1667  credentials, "Internal error", __FUNCTION__, __LINE__,
1668  "An internal error occurred while deleting a resource. "
1669  "It is unclear whether the resource has been deleted or not. "
1670  "Diagnostics: Failure to read response from manager daemon.",
1671  response_data);
1672  }
1673 
1674  if (!gmp_success (entity))
1675  set_http_status_from_entity (entity, response_data);
1676 
1677  cap_type = capitalize (type);
1678  prev_action = g_strdup_printf ("Delete %s", cap_type);
1679 
1680  html = response_from_entity (connection, credentials, params, entity,
1681  prev_action, response_data);
1682 
1683  g_free (response);
1684  free_entity (entity);
1685  g_free (cap_type);
1686  g_free (prev_action);
1687 
1688  return html;
1689 }

References capitalize(), cmd_response_data_set_status_code(), gmp_success(), gsad_message(), message_invalid(), params_given(), params_value(), response_from_entity(), and set_http_status_from_entity().

Referenced by delete_from_trash_gmp(), delete_port_range_gmp(), delete_report_gmp(), and move_resource_to_trash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_role_gmp()

char* delete_role_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a role, get all roles, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13794 of file gsad_gmp.c.

13796 {
13797  return move_resource_to_trash (connection, "role", credentials, params,
13798  response_data);
13799 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_scanner_gmp()

char* delete_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a scanner, get all scanners, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10211 of file gsad_gmp.c.

10213 {
10214  return move_resource_to_trash (connection, "scanner", credentials, params,
10215  response_data);
10216 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_schedule_gmp()

char* delete_schedule_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a schedule, get all schedules, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10527 of file gsad_gmp.c.

10529 {
10530  return move_resource_to_trash (connection, "schedule", credentials, params,
10531  response_data);
10532 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_tag_gmp()

char* delete_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete note, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6420 of file gsad_gmp.c.

6422 {
6423  return move_resource_to_trash (connection, "tag", credentials, params,
6424  response_data);
6425 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_target_gmp()

char* delete_target_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a target, get all targets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6165 of file gsad_gmp.c.

6167 {
6168  return move_resource_to_trash (connection, "target", credentials, params,
6169  response_data);
6170 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_task_gmp()

char* delete_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a task, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2454 of file gsad_gmp.c.

2456 {
2457  return move_resource_to_trash (connection, "task", credentials, params,
2458  response_data);
2459 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_ticket_gmp()

char* delete_ticket_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a ticket.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16779 of file gsad_gmp.c.

16781 {
16782  return move_resource_to_trash (connection, "ticket", credentials, params,
16783  response_data);
16784 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_tls_certificate_gmp()

char* delete_tls_certificate_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a TLS certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 17033 of file gsad_gmp.c.

17036 {
17037  return move_resource_to_trash (connection, "tls_certificate", credentials,
17038  params, response_data);
17039 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_user_gmp()

char* delete_user_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Delete a user, get all users, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14638 of file gsad_gmp.c.

14640 {
14641  return move_resource_to_trash (connection, "user", credentials, params,
14642  response_data);
14643 }

References move_resource_to_trash().

Here is the call graph for this function:

◆ download_agent_gmp()

int download_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
char **  html,
char **  filename,
cmd_response_data_t *  response_data 
)

Get an agent, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]htmlResult. Required.
[out]filenameAgent filename return. NULL to skip. Only set on success with agent_id.
[out]response_dataExtra data return for the HTTP response.
Returns
0 success, 1 failure.

Definition at line 4082 of file gsad_gmp.c.

4085 {
4086  entity_t entity;
4087  const char *agent_id, *format;
4088  gsize result_len = 0;
4089 
4090  agent_id = params_value (params, "agent_id");
4091  format = params_value (params, "agent_format");
4092 
4093  if ((agent_id == NULL) || (format == NULL))
4094  {
4095  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
4096  *html =
4097  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
4098  "An internal error occurred while downloading "
4099  "an agent. "
4100  "Diagnostics: Required parameter was NULL.",
4101  response_data);
4102  return 1;
4103  }
4104 
4105  /* Send the request. */
4106 
4107  if (gvm_connection_sendf (connection,
4108  "<get_agents agent_id=\"%s\" format=\"%s\"/>",
4109  agent_id, format)
4110  == -1)
4111  {
4112  cmd_response_data_set_status_code (response_data,
4113  MHD_HTTP_INTERNAL_SERVER_ERROR);
4114  *html =
4115  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
4116  "An internal error occurred while getting agent list. "
4117  "The current list of agents is not available. "
4118  "Diagnostics: Failure to send command to manager daemon.",
4119  response_data);
4120  return 1;
4121  }
4122 
4123  /* Read and handle the response. */
4124 
4125  if (strcmp (format, "installer") == 0 || strcmp (format, "howto_install") == 0
4126  || strcmp (format, "howto_use") == 0)
4127  {
4128  gchar *package_decoded = NULL;
4129  entity_t package_entity = NULL, agent_entity;
4130 
4131  /* A base64 encoded package. */
4132 
4133  entity = NULL;
4134  if (read_entity_c (connection, &entity))
4135  {
4136  cmd_response_data_set_status_code (response_data,
4137  MHD_HTTP_INTERNAL_SERVER_ERROR);
4138  *html = gsad_message (
4139  credentials, "Internal error", __FUNCTION__, __LINE__,
4140  "An internal error occurred while getting a agent. "
4141  "The agent is not available. "
4142  "Diagnostics: Failure to receive response from manager daemon.",
4143  response_data);
4144  return 1;
4145  }
4146 
4147  agent_entity = entity_child (entity, "agent");
4148  if (agent_entity)
4149  package_entity = entity_child (agent_entity, "package");
4150  if (package_entity != NULL)
4151  {
4152  char *package_encoded = entity_text (package_entity);
4153  if (strlen (package_encoded))
4154  {
4155  package_decoded =
4156  (gchar *) g_base64_decode (package_encoded, &result_len);
4157  if (package_decoded == NULL)
4158  {
4159  package_decoded = (gchar *) g_strdup ("");
4160  result_len = 0;
4161  }
4162  }
4163  else
4164  {
4165  package_decoded = (gchar *) g_strdup ("");
4166  result_len = 0;
4167  }
4168  *html = package_decoded;
4169  if (filename)
4170  {
4171  entity_t filename_entity;
4172  filename_entity = entity_child (package_entity, "filename");
4173  if (filename_entity)
4174  *filename = g_strdup (entity_text (filename_entity));
4175  else
4176  *filename = NULL;
4177  if (!(*filename && strlen (*filename)))
4178  {
4179  g_free (*filename);
4180  *filename = g_strdup_printf ("agent-%s-%s", agent_id, format);
4181  }
4182  }
4183  cmd_response_data_set_content_length (response_data, result_len);
4184  free_entity (entity);
4185  return 0;
4186  }
4187  else
4188  {
4189  free_entity (entity);
4190  cmd_response_data_set_status_code (response_data,
4191  MHD_HTTP_INTERNAL_SERVER_ERROR);
4192  *html = gsad_message (
4193  credentials, "Internal error", __FUNCTION__, __LINE__,
4194  "An internal error occurred while getting a agent. "
4195  "The agent could not be delivered. "
4196  "Diagnostics: Failure to receive agent from manager daemon.",
4197  response_data);
4198  return 1;
4199  }
4200  }
4201  else
4202  {
4203  /* An error. */
4204 
4205  entity = NULL;
4206  if (read_entity_c (connection, &entity))
4207  {
4208  cmd_response_data_set_status_code (response_data,
4209  MHD_HTTP_INTERNAL_SERVER_ERROR);
4210  *html = gsad_message (
4211  credentials, "Internal error", __FUNCTION__, __LINE__,
4212  "An internal error occurred while getting a agent. "
4213  "The agent could not be delivered. "
4214  "Diagnostics: Failure to receive agent from manager daemon.",
4215  response_data);
4216  return 1;
4217  }
4218 
4219  free_entity (entity);
4220  cmd_response_data_set_status_code (response_data,
4221  MHD_HTTP_INTERNAL_SERVER_ERROR);
4222  *html = gsad_message (
4223  credentials, "Internal error", __FUNCTION__, __LINE__,
4224  "An internal error occurred while getting a agent. "
4225  "The agent could not be delivered. "
4226  "Diagnostics: Failure to parse agent from manager daemon.",
4227  response_data);
4228  return 1;
4229  }
4230 }

References cmd_response_data_set_content_length(), cmd_response_data_set_status_code(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ download_ca_pub()

char* download_ca_pub ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a Scanner's CA Certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
CA Certificate.

Definition at line 9086 of file gsad_gmp.c.

9088 {
9089  const char *ca_pub;
9090  char *unescaped;
9091 
9092  ca_pub = params_value (params, "ca_pub");
9093  if (ca_pub == NULL)
9094  {
9095  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
9096  return gsad_message (credentials, "Internal error", __FUNCTION__,
9097  __LINE__,
9098  "An internal error occurred."
9099  " Diagnostics: ca_pub was NULL.",
9100  response_data);
9101  }
9102  /* The Base64 comes URI escaped as it may contain special characters. */
9103  unescaped = g_uri_unescape_string (ca_pub, NULL);
9104  cmd_response_data_set_content_length (response_data, strlen (unescaped));
9105  return unescaped;
9106 }

References cmd_response_data_set_content_length(), cmd_response_data_set_status_code(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ download_credential_gmp()

int download_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
char **  html,
char **  login,
cmd_response_data_t *  response_data 
)

Export a Credential in a defined format.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]htmlResult. Required.
[out]loginLogin name return. NULL to skip. Only set on success with credential_id.
[out]response_dataExtra data return for the HTTP response.
Returns
0 success, 1 failure.

Definition at line 3420 of file gsad_gmp.c.

3424 {
3425  entity_t entity;
3426  const char *credential_id, *format;
3427 
3428  assert (html);
3429 
3430  /* Send the request. */
3431 
3432  credential_id = params_value (params, "credential_id");
3433  format = params_value (params, "package_format");
3434 
3435  if ((credential_id == NULL) || (format == NULL))
3436  {
3437  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
3438  *html =
3439  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
3440  "An internal error occurred while getting a credential. "
3441  "Diagnostics: Required parameter was NULL.",
3442  response_data);
3443  return 1;
3444  }
3445 
3446  if (gvm_connection_sendf (connection,
3447  "<get_credentials"
3448  " credential_id=\"%s\""
3449  " format=\"%s\"/>",
3450  credential_id, format)
3451  == -1)
3452  {
3453  cmd_response_data_set_status_code (response_data,
3454  MHD_HTTP_INTERNAL_SERVER_ERROR);
3455  *html =
3456  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
3457  "An internal error occurred while getting a credential. "
3458  "Diagnostics: Failure to send command to manager daemon.",
3459  response_data);
3460  return 1;
3461  }
3462 
3463  /* Read and handle the response. */
3464 
3465  if (strcmp (format, "rpm") == 0 || strcmp (format, "deb") == 0
3466  || strcmp (format, "exe") == 0)
3467  {
3468  gchar *package_decoded = NULL;
3469  entity_t package_entity = NULL, credential_entity;
3470 
3471  /* A base64 encoded package. */
3472 
3473  entity = NULL;
3474  if (read_entity_c (connection, &entity))
3475  {
3476  cmd_response_data_set_status_code (response_data,
3477  MHD_HTTP_INTERNAL_SERVER_ERROR);
3478  *html = gsad_message (
3479  credentials, "Internal error", __FUNCTION__, __LINE__,
3480  "An internal error occurred while getting a credential. "
3481  "The credential is not available. "
3482  "Diagnostics: Failure to receive response from manager daemon.",
3483  response_data);
3484  return 1;
3485  }
3486 
3487  credential_entity = entity_child (entity, "credential");
3488  if (credential_entity)
3489  package_entity = entity_child (credential_entity, "package");
3490  if (package_entity != NULL)
3491  {
3492  gsize len;
3493  char *package_encoded = entity_text (package_entity);
3494  if (strlen (package_encoded))
3495  {
3496  package_decoded =
3497  (gchar *) g_base64_decode (package_encoded, &len);
3498  if (package_decoded == NULL)
3499  {
3500  package_decoded = (gchar *) g_strdup ("");
3501  len = 0;
3502  }
3503  }
3504  else
3505  {
3506  package_decoded = (gchar *) g_strdup ("");
3507  len = 0;
3508  }
3509 
3510  cmd_response_data_set_content_length (response_data, len);
3511 
3512  *html = package_decoded;
3513  if (login)
3514  {
3515  entity_t login_entity;
3516  login_entity = entity_child (credential_entity, "login");
3517  if (login_entity)
3518  *login = g_strdup (entity_text (login_entity));
3519  else
3520  *login = NULL;
3521  }
3522  free_entity (entity);
3523  return 0;
3524  }
3525  else
3526  {
3527  free_entity (entity);
3528  cmd_response_data_set_status_code (response_data,
3529  MHD_HTTP_INTERNAL_SERVER_ERROR);
3530  *html = gsad_message (
3531  credentials, "Internal error", __FUNCTION__, __LINE__,
3532  "An internal error occurred while getting a credential. "
3533  "The credential could not be delivered. "
3534  "Diagnostics: Failure to receive credential from manager daemon.",
3535  response_data);
3536  return 1;
3537  }
3538  }
3539  else
3540  {
3541  entity_t credential_entity, key_entity = NULL;
3542 
3543  /* A key or certificate. */
3544 
3545  entity = NULL;
3546  if (read_entity_c (connection, &entity))
3547  {
3548  cmd_response_data_set_status_code (response_data,
3549  MHD_HTTP_INTERNAL_SERVER_ERROR);
3550  *html = gsad_message (
3551  credentials, "Internal error", __FUNCTION__, __LINE__,
3552  "An internal error occurred while getting a credential. "
3553  "The credential could not be delivered. "
3554  "Diagnostics: Failure to receive credential from manager daemon.",
3555  response_data);
3556  return 1;
3557  }
3558 
3559  credential_entity = entity_child (entity, "credential");
3560  if (credential_entity)
3561  {
3562  if (strcmp (format, "pem") == 0)
3563  key_entity = entity_child (credential_entity, "certificate");
3564  else
3565  key_entity = entity_child (credential_entity, "public_key");
3566  }
3567  if (key_entity != NULL)
3568  {
3569  *html = g_strdup (entity_text (key_entity));
3570  if (login)
3571  {
3572  entity_t login_entity = entity_child (credential_entity, "login");
3573  if (login_entity)
3574  *login = g_strdup (entity_text (login_entity));
3575  else
3576  *login = NULL;
3577  }
3578  free_entity (entity);
3579  return 0;
3580  }
3581  cmd_response_data_set_status_code (response_data,
3582  MHD_HTTP_INTERNAL_SERVER_ERROR);
3583  *html = gsad_message (
3584  credentials, "Internal error", __FUNCTION__, __LINE__,
3585  "An internal error occurred while getting a credential. "
3586  "The credential could not be delivered. "
3587  "Diagnostics: Failure to parse credential from manager daemon.",
3588  response_data);
3589  free_entity (entity);
3590  return 1;
3591  }
3592 }

References cmd_response_data_set_content_length(), cmd_response_data_set_status_code(), gsad_message(), login(), and params_value().

Here is the call graph for this function:

◆ download_key_pub()

char* download_key_pub ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a Scanner's Certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Certificate.

Definition at line 9119 of file gsad_gmp.c.

9121 {
9122  const char *key_pub;
9123  char *unescaped;
9124 
9125  key_pub = params_value (params, "key_pub");
9126  if (key_pub == NULL)
9127  {
9128  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
9129  return gsad_message (credentials, "Internal error", __FUNCTION__,
9130  __LINE__,
9131  "An internal error occurred."
9132  " Diagnostics: key_pub was NULL.",
9133  response_data);
9134  }
9135 
9136  /* The Base64 comes URI escaped as it may contain special characters. */
9137  unescaped = g_uri_unescape_string (key_pub, NULL);
9138  cmd_response_data_set_content_length (response_data, strlen (unescaped));
9139  return unescaped;
9140 }

References cmd_response_data_set_content_length(), cmd_response_data_set_status_code(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ download_ssl_cert()

char* download_ssl_cert ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get an SSL Certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
SSL Certificate.

Definition at line 9045 of file gsad_gmp.c.

9047 {
9048  const char *ssl_cert;
9049  gchar *cert;
9050  char *unescaped;
9051 
9052  ssl_cert = params_value (params, "ssl_cert");
9053  if (ssl_cert == NULL)
9054  {
9055  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
9056  return gsad_message (credentials, "Internal error", __FUNCTION__,
9057  __LINE__,
9058  "An internal error occurred."
9059  " Diagnostics: ssl_cert was NULL.",
9060  response_data);
9061  }
9062  /* The Base64 comes URI escaped as it may contain special characters. */
9063  unescaped = g_uri_unescape_string (ssl_cert, NULL);
9064 
9065  cert = g_strdup_printf ("-----BEGIN CERTIFICATE-----\n"
9066  "%s\n-----END CERTIFICATE-----\n",
9067  unescaped);
9068 
9069  cmd_response_data_set_content_length (response_data, strlen (cert));
9070 
9071  g_free (unescaped);
9072  return cert;
9073 }

References cmd_response_data_set_content_length(), cmd_response_data_set_status_code(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ edit_alert()

char* edit_alert ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)

Setup edit_alert XML, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5388 of file gsad_gmp.c.

5391 {
5392  GString *xml;
5393  gchar *edit;
5394  const char *alert_id, *next, *filter;
5395 
5396  alert_id = params_value (params, "alert_id");
5397  next = params_value (params, "next");
5398  filter = params_value (params, "filter");
5399 
5400  if (alert_id == NULL)
5401  {
5402  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
5403  return gsad_message (credentials, "Internal error", __FUNCTION__,
5404  __LINE__,
5405  "An internal error occurred while editing an alert. "
5406  "The alert remains as it was. "
5407  "Diagnostics: Required parameter alert_id was NULL.",
5408  response_data);
5409  }
5410 
5411  if (next == NULL)
5412  next = "get_alerts";
5413 
5414  if (gvm_connection_sendf (connection,
5415  "<get_alerts"
5416  " alert_id=\"%s\""
5417  " details=\"1\"/>",
5418  alert_id)
5419  == -1)
5420  {
5421  cmd_response_data_set_status_code (response_data,
5422  MHD_HTTP_INTERNAL_SERVER_ERROR);
5423  return gsad_message (
5424  credentials, "Internal error", __FUNCTION__, __LINE__,
5425  "An internal error occurred while getting alert info. "
5426  "Diagnostics: Failure to send command to manager daemon.",
5427  response_data);
5428  }
5429 
5430  xml = g_string_new ("<edit_alert>");
5431 
5432  if (extra_xml)
5433  g_string_append (xml, extra_xml);
5434 
5435  edit = g_markup_printf_escaped ("<alert id=\"%s\"/>"
5436  /* Page that follows. */
5437  "<next>%s</next>"
5438  /* Passthroughs. */
5439  "<filters><term>%s</term></filters>",
5440  alert_id, next, filter);
5441  g_string_append (xml, edit);
5442  g_free (edit);
5443 
5444  if (read_string_c (connection, &xml))
5445  {
5446  g_string_free (xml, TRUE);
5447  cmd_response_data_set_status_code (response_data,
5448  MHD_HTTP_INTERNAL_SERVER_ERROR);
5449  return gsad_message (
5450  credentials, "Internal error", __FUNCTION__, __LINE__,
5451  "An internal error occurred while getting alert info. "
5452  "Diagnostics: Failure to receive response from manager daemon.",
5453  response_data);
5454  }
5455 
5456  if (command_enabled (credentials, "GET_REPORT_FORMATS"))
5457  {
5458  /* Get the report formats. */
5459 
5460  if (gvm_connection_sendf (connection, "<get_report_formats"
5461  " filter=\"rows=-1\"/>")
5462  == -1)
5463  {
5464  g_string_free (xml, TRUE);
5465  cmd_response_data_set_status_code (response_data,
5466  MHD_HTTP_INTERNAL_SERVER_ERROR);
5467  return gsad_message (
5468  credentials, "Internal error", __FUNCTION__, __LINE__,
5469  "An internal error occurred while getting report formats. "
5470  "The current list of report formats is not available. "
5471  "Diagnostics: Failure to send command to manager daemon.",
5472  response_data);
5473  }
5474 
5475  if (read_string_c (connection, &xml))
5476  {
5477  g_string_free (xml, TRUE);
5478  cmd_response_data_set_status_code (response_data,
5479  MHD_HTTP_INTERNAL_SERVER_ERROR);
5480  return gsad_message (
5481  credentials, "Internal error", __FUNCTION__, __LINE__,
5482  "An internal error occurred while getting report formats. "
5483  "The current list of report formats is not available. "
5484  "Diagnostics: Failure to receive response from manager daemon.",
5485  response_data);
5486  }
5487  }
5488 
5489  if (command_enabled (credentials, "GET_FILTERS"))
5490  {
5491  /* Get filters. */
5492 
5493  if (gvm_connection_sendf (connection, "<get_filters filter=\"rows=-1\"/>")
5494  == -1)
5495  {
5496  g_string_free (xml, TRUE);
5497  cmd_response_data_set_status_code (response_data,
5498  MHD_HTTP_INTERNAL_SERVER_ERROR);
5499  return gsad_message (
5500  credentials, "Internal error", __FUNCTION__, __LINE__,
5501  "An internal error occurred while getting the list "
5502  "of filters. "
5503  "The current list of filters is not available. "
5504  "Diagnostics: Failure to send command to manager daemon.",
5505  response_data);
5506  }
5507 
5508  if (read_string_c (connection, &xml))
5509  {
5510  g_string_free (xml, TRUE);
5511  cmd_response_data_set_status_code (response_data,
5512  MHD_HTTP_INTERNAL_SERVER_ERROR);
5513  return gsad_message (
5514  credentials, "Internal error", __FUNCTION__, __LINE__,
5515  "An internal error occurred while getting the list "
5516  "of filters. "
5517  "The current list of filters is not available. "
5518  "Diagnostics: Failure to receive response from manager daemon.",
5519  response_data);
5520  }
5521  }
5522 
5523  if (command_enabled (credentials, "GET_TASKS"))
5524  {
5525  /* Get tasks. */
5526 
5527  if (gvm_connection_sendf (connection,
5528  "<get_tasks"
5529  " schedules_only=\"1\""
5530  " filter=\"owner=any permission=start_task"
5531  " rows=-1\"/>")
5532  == -1)
5533  {
5534  g_string_free (xml, TRUE);
5535  cmd_response_data_set_status_code (response_data,
5536  MHD_HTTP_INTERNAL_SERVER_ERROR);
5537  return gsad_message (
5538  credentials, "Internal error", __FUNCTION__, __LINE__,
5539  "An internal error occurred while getting the list "
5540  "of tasks. "
5541  "The current list of tasks is not available. "
5542  "Diagnostics: Failure to send command to manager daemon.",
5543  response_data);
5544  }
5545 
5546  if (read_string_c (connection, &xml))
5547  {
5548  g_string_free (xml, TRUE);
5549  cmd_response_data_set_status_code (response_data,
5550  MHD_HTTP_INTERNAL_SERVER_ERROR);
5551  return gsad_message (
5552  credentials, "Internal error", __FUNCTION__, __LINE__,
5553  "An internal error occurred while getting the list "
5554  "of tasks. "
5555  "The current list of tasks is not available. "
5556  "Diagnostics: Failure to receive response from manager daemon.",
5557  response_data);
5558  }
5559  }
5560 
5561  /* Get Credentials. */
5562 
5563  if (command_enabled (credentials, "GET_CREDENTIALS"))
5564  {
5565  if (gvm_connection_sendf (connection, "<get_credentials"
5566  " filter=\"type=up or type=pw"
5567  " owner=any permission=any"
5568  " rows=-1\"/>")
5569  == -1)
5570  {
5571  g_string_free (xml, TRUE);
5572  cmd_response_data_set_status_code (response_data,
5573  MHD_HTTP_INTERNAL_SERVER_ERROR);
5574  return gsad_message (
5575  credentials, "Internal error", __FUNCTION__, __LINE__,
5576  "An internal error occurred while getting the list "
5577  "of credentials. "
5578  "The current list of tasks is not available. "
5579  "Diagnostics: Failure to send command to manager daemon.",
5580  response_data);
5581  }
5582 
5583  if (read_string_c (connection, &xml))
5584  {
5585  g_string_free (xml, TRUE);
5586  cmd_response_data_set_status_code (response_data,
5587  MHD_HTTP_INTERNAL_SERVER_ERROR);
5588  return gsad_message (
5589  credentials, "Internal error", __FUNCTION__, __LINE__,
5590  "An internal error occurred while getting the list "
5591  "of credentials. "
5592  "The current list of tasks is not available. "
5593  "Diagnostics: Failure to receive response from manager daemon.",
5594  response_data);
5595  }
5596  }
5597 
5598  /* Cleanup, and return transformed XML. */
5599 
5600  g_string_append (xml, "</edit_alert>");
5601  return envelope_gmp (connection, credentials, params,
5602  g_string_free (xml, FALSE), response_data);
5603 }

References cmd_response_data_set_status_code(), command_enabled(), envelope_gmp(), gsad_message(), and params_value().

Referenced by edit_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ edit_alert_gmp()

char* edit_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Setup edit_alert XML, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5616 of file gsad_gmp.c.

5618 {
5619  return edit_alert (connection, credentials, params, NULL, response_data);
5620 }

References edit_alert().

Here is the call graph for this function:

◆ edit_config_family_gmp()

char* edit_config_family_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get details of a family for editing a config, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7739 of file gsad_gmp.c.

7742 {
7743  return get_config_family (connection, credentials, params, 1, response_data);
7744 }

References get_config_family().

Here is the call graph for this function:

◆ edit_resource()

char* edit_resource ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
const char *  extra_get_attribs,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)

Setup edit XML, envelope the result.

Parameters
[in]connectionConnection to manager
[in]typeType or resource to edit.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_get_attribsExtra attributes for the get_... command.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1102 of file gsad_gmp.c.

1106 {
1107  GString *xml;
1108  gchar *id_name;
1109  const char *resource_id;
1110 
1111  id_name = g_strdup_printf ("%s_id", type);
1112  resource_id = params_value (params, id_name);
1113  g_free (id_name);
1114 
1115  if (resource_id == NULL)
1116  {
1117  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
1118  return gsad_message (
1119  credentials, "Internal error", __FUNCTION__, __LINE__,
1120  "An internal error occurred while editing a resource. "
1121  "The resource remains as it was. "
1122  "Diagnostics: Required ID parameter was NULL.",
1123  response_data);
1124  }
1125 
1126  if (gvm_connection_sendf (connection,
1127  "<get_%ss"
1128  " %s"
1129  " %s_id=\"%s\""
1130  " details=\"1\"/>",
1131  type, extra_get_attribs ? extra_get_attribs : "",
1132  type, resource_id)
1133  == -1)
1134  {
1135  cmd_response_data_set_status_code (response_data,
1136  MHD_HTTP_INTERNAL_SERVER_ERROR);
1137  return gsad_message (
1138  credentials, "Internal error", __FUNCTION__, __LINE__,
1139  "An internal error occurred while getting a resource. "
1140  "Diagnostics: Failure to send command to manager daemon.",
1141  response_data);
1142  }
1143 
1144  xml = g_string_new ("");
1145 
1146  g_string_append_printf (xml, "<edit_%s>", type);
1147 
1148  if (extra_xml)
1149  g_string_append (xml, extra_xml);
1150 
1151  if (read_string_c (connection, &xml))
1152  {
1153  g_string_free (xml, TRUE);
1154  cmd_response_data_set_status_code (response_data,
1155  MHD_HTTP_INTERNAL_SERVER_ERROR);
1156  return gsad_message (
1157  credentials, "Internal error", __FUNCTION__, __LINE__,
1158  "An internal error occurred while getting a resource. "
1159  "Diagnostics: Failure to receive response from manager daemon.",
1160  response_data);
1161  }
1162 
1163  /* Cleanup, and return transformed XML. */
1164 
1165  g_string_append_printf (xml, "</edit_%s>", type);
1166  return envelope_gmp (connection, credentials, params,
1167  g_string_free (xml, FALSE), response_data);
1168 }

References cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ empty_trashcan_gmp()

char* empty_trashcan_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Empty the trashcan, get all trash, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6250 of file gsad_gmp.c.

6252 {
6253  GString *xml;
6254  gchar *ret;
6255  entity_t entity;
6256 
6257  xml = g_string_new ("");
6258 
6259  /* Empty the trash. */
6260 
6261  if (gvm_connection_sendf (connection, "<empty_trashcan/>") == -1)
6262  {
6263  g_string_free (xml, TRUE);
6264  cmd_response_data_set_status_code (response_data,
6265  MHD_HTTP_INTERNAL_SERVER_ERROR);
6266  return gsad_message (
6267  credentials, "Internal error", __FUNCTION__, __LINE__,
6268  "An internal error occurred while emptying the trashcan. "
6269  "Diagnostics: Failure to send command to manager daemon.",
6270  response_data);
6271  }
6272 
6273  if (read_entity_and_string_c (connection, &entity, &xml))
6274  {
6275  g_string_free (xml, TRUE);
6276  cmd_response_data_set_status_code (response_data,
6277  MHD_HTTP_INTERNAL_SERVER_ERROR);
6278  return gsad_message (
6279  credentials, "Internal error", __FUNCTION__, __LINE__,
6280  "An internal error occurred while emptying the trashcan. "
6281  "Diagnostics: Failure to read response from manager daemon.",
6282  response_data);
6283  }
6284 
6285  /* Cleanup, and return trash page. */
6286 
6287  ret = response_from_entity (connection, credentials, params, entity,
6288  "Empty Trashcan", response_data);
6289  free_entity (entity);
6290  g_string_free (xml, FALSE);
6291  return ret;
6292 }

References cmd_response_data_set_status_code(), gsad_message(), and response_from_entity().

Here is the call graph for this function:

◆ envelope_gmp()

static char* envelope_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
gchar *  xml,
cmd_response_data_t *  response_data 
)
static

Wrap some XML in an envelope.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsHTTP request params (UNUSED)
[in]xmlXML string. Freed before exit.
[out]response_dataExtra data return for the HTTP response or NULL.
Returns
Enveloped GMP XML object.

Definition at line 319 of file gsad_gmp.c.

321 {
322  time_t now;
323  gchar *res;
324  GString *string;
325  char ctime_now[200];
326  struct timeval tv;
327 
328  assert (credentials);
329 
331  const gchar *timezone = user_get_timezone (user);
332  const gchar *pw_warning = user_get_password_warning (user);
333 
334  now = time (NULL);
335  ctime_r_strip_newline (&now, ctime_now);
336 
337  string = g_string_new ("");
338 
339  gettimeofday (&tv, NULL);
340  res = g_markup_printf_escaped (
341  "<envelope>"
342  "<version>%s</version>"
343  "<vendor_version>%s</vendor_version>"
344  "<token>%s</token>"
345  "<time>%s</time>"
346  "<timezone>%s</timezone>"
347  "<login>%s</login>"
348  "<session>%ld</session>"
349  "<role>%s</role>"
350  "<severity>%s</severity>"
351  "<i18n>%s</i18n>"
352  "<client_address>%s</client_address>"
353  "<backend_operation>%.2f</backend_operation>",
354  GSAD_VERSION, vendor_version_get (), user_get_token (user), ctime_now,
355  timezone ? timezone : "", user_get_username (user),
359 
360  g_string_append (string, res);
361  g_free (res);
362 
363  if (pw_warning)
364  {
365  gchar *warning_elem;
366  warning_elem = g_markup_printf_escaped ("<password_warning>"
367  "%s"
368  "</password_warning>",
369  pw_warning);
370  g_string_append (string, warning_elem);
371  g_free (warning_elem);
372  }
373 
374  g_string_append_printf (string, "%s</envelope>", xml);
375  g_free (xml);
376 
378  return g_string_free (string, FALSE);
379 }

References cmd_response_data_set_content_type(), credentials_get_cmd_duration(), credentials_get_language(), credentials_get_user(), ctime_r_strip_newline(), GSAD_CONTENT_TYPE_APP_XML, user_get_client_address(), user_get_password_warning(), user_get_role(), user_get_session_timeout(), user_get_severity(), user_get_timezone(), user_get_token(), user_get_username(), and vendor_version_get().

Referenced by action_result(), auth_settings_gmp(), cvss_calculator(), edit_alert(), edit_resource(), export_preference_file_gmp(), export_resource(), get_aggregate_gmp(), get_capabilities_gmp(), get_config_family(), get_config_nvt_gmp(), get_entities(), get_entity(), get_feeds_gmp(), get_report(), get_setting_gmp(), get_settings_gmp(), get_system_reports_gmp(), get_trash(), login(), new_alert(), save_my_settings_gmp(), wizard(), and wizard_get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_agent_gmp()

char* export_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a agent.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Agent XML on success. Enveloped XML on error.

Definition at line 4452 of file gsad_gmp.c.

4454 {
4455  return export_resource (connection, "agent", credentials, params,
4456  response_data);
4457 }

References export_resource().

Here is the call graph for this function:

◆ export_agents_gmp()

char* export_agents_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of agents.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Agents XML on success. Enveloped XML on error.

Definition at line 4471 of file gsad_gmp.c.

4473 {
4474  return export_many (connection, "agent", credentials, params, response_data);
4475 }

References export_many().

Here is the call graph for this function:

◆ export_alert_gmp()

char* export_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export an alert.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Alert XML on success. Enveloped XML on error.

Definition at line 5842 of file gsad_gmp.c.

5844 {
5845  return export_resource (connection, "alert", credentials, params,
5846  response_data);
5847 }

References export_resource().

Here is the call graph for this function:

◆ export_alerts_gmp()

char* export_alerts_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of alerts.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Alerts XML on success. Enveloped XML on error.

Definition at line 5861 of file gsad_gmp.c.

5863 {
5864  return export_many (connection, "alert", credentials, params, response_data);
5865 }

References export_many().

Here is the call graph for this function:

◆ export_asset_gmp()

char* export_asset_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export an asset.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Asset XML on success. Enveloped XML on error.

Definition at line 16472 of file gsad_gmp.c.

16474 {
16475  return export_resource (connection, "asset", credentials, params,
16476  response_data);
16477 }

References export_resource().

Here is the call graph for this function:

◆ export_assets_gmp()

char* export_assets_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of assets.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Assets XML on success. Enveloped XML on error.

Definition at line 16491 of file gsad_gmp.c.

16493 {
16494  return export_many (connection, "asset", credentials, params, response_data);
16495 }

References export_many().

Here is the call graph for this function:

◆ export_config_gmp()

char* export_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a config.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Config XML on success. Enveloped XML on error.

Definition at line 8165 of file gsad_gmp.c.

8167 {
8168  return export_resource (connection, "config", credentials, params,
8169  response_data);
8170 }

References export_resource().

Here is the call graph for this function:

◆ export_configs_gmp()

char* export_configs_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of scan configs.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Scan configs XML on success. Enveloped XML on error.

Definition at line 8184 of file gsad_gmp.c.

8186 {
8187  return export_many (connection, "config", credentials, params, response_data);
8188 }

References export_many().

Here is the call graph for this function:

◆ export_credential_gmp()

char* export_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a Credential.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Credential XML on success. Enveloped XML on error.

Definition at line 3606 of file gsad_gmp.c.

3608 {
3609  return export_resource (connection, "credential", credentials, params,
3610  response_data);
3611 }

References export_resource().

Here is the call graph for this function:

◆ export_credentials_gmp()

char* export_credentials_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of Credentials.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Credentials XML on success. Enveloped XML on error.

Definition at line 3625 of file gsad_gmp.c.

3628 {
3629  return export_many (connection, "credential", credentials, params,
3630  response_data);
3631 }

References export_many().

Here is the call graph for this function:

◆ export_filter_gmp()

char* export_filter_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a filter.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Filter XML on success. Enveloped XML on error.

Definition at line 14400 of file gsad_gmp.c.

14402 {
14403  return export_resource (connection, "filter", credentials, params,
14404  response_data);
14405 }

References export_resource().

Here is the call graph for this function:

◆ export_filters_gmp()

char* export_filters_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of filters.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Filters XML on success. Enveloped XML on error.

Definition at line 14419 of file gsad_gmp.c.

14421 {
14422  return export_many (connection, "filter", credentials, params, response_data);
14423 }

References export_many().

Here is the call graph for this function:

◆ export_group_gmp()

char* export_group_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a group.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Group XML on success. Enveloped XML on error.

Definition at line 12507 of file gsad_gmp.c.

12509 {
12510  return export_resource (connection, "group", credentials, params,
12511  response_data);
12512 }

References export_resource().

Here is the call graph for this function:

◆ export_groups_gmp()

char* export_groups_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of groups.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Groups XML on success. Enveloped XML on error.

Definition at line 12526 of file gsad_gmp.c.

12528 {
12529  return export_many (connection, "group", credentials, params, response_data);
12530 }

References export_many().

Here is the call graph for this function:

◆ export_many()

static char* export_many ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)
static

Export a list of resources.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
XML on success. XML error object on error.

Definition at line 1419 of file gsad_gmp.c.

1422 {
1423  entity_t entity;
1424  char *content = NULL;
1425  const char *filter;
1426  gchar *filter_escaped;
1427  gchar *type_many;
1428  gchar *fname_format, *file_name;
1429  int ret;
1430 
1431  filter = params_value (params, "filter");
1432 
1433  filter_escaped = g_markup_escape_text (filter, -1);
1434 
1435  if (strcmp (type, "info") == 0)
1436  {
1437  if (gvm_connection_sendf (connection,
1438  "<get_info"
1439  " type=\"%s\""
1440  " export=\"1\""
1441  " details=\"1\""
1442  " filter=\"%s\"/>",
1443  params_value (params, "info_type"),
1444  filter_escaped ? filter_escaped : "")
1445  == -1)
1446  {
1447  g_free (filter_escaped);
1448  cmd_response_data_set_status_code (response_data,
1449  MHD_HTTP_INTERNAL_SERVER_ERROR);
1450  return gsad_message (
1451  credentials, "Internal error", __FUNCTION__, __LINE__,
1452  "An internal error occurred while getting a list. "
1453  "The list could not be delivered. "
1454  "Diagnostics: Failure to send command to manager daemon.",
1455  response_data);
1456  }
1457  }
1458  else if (strcmp (type, "asset") == 0)
1459  {
1460  if (gvm_connection_sendf (connection,
1461  "<get_assets"
1462  " type=\"%s\""
1463  " export=\"1\""
1464  " details=\"1\""
1465  " filter=\"%s\"/>",
1466  params_value (params, "asset_type"),
1467  filter_escaped ? filter_escaped : "")
1468  == -1)
1469  {
1470  g_free (filter_escaped);
1471  cmd_response_data_set_status_code (response_data,
1472  MHD_HTTP_INTERNAL_SERVER_ERROR);
1473  return gsad_message (
1474  credentials, "Internal error", __FUNCTION__, __LINE__,
1475  "An internal error occurred while getting a list. "
1476  "The list could not be delivered. "
1477  "Diagnostics: Failure to send command to manager daemon.",
1478  response_data);
1479  }
1480  }
1481  else
1482  {
1483  if (gvm_connection_sendf (connection,
1484  "<get_%ss"
1485  " export=\"1\""
1486  " details=\"1\""
1487  " filter=\"%s\"/>",
1488  type, filter_escaped ? filter_escaped : "")
1489  == -1)
1490  {
1491  g_free (filter_escaped);
1492  cmd_response_data_set_status_code (response_data,
1493  MHD_HTTP_INTERNAL_SERVER_ERROR);
1494  return gsad_message (
1495  credentials, "Internal error", __FUNCTION__, __LINE__,
1496  "An internal error occurred while getting a list. "
1497  "The list could not be delivered. "
1498  "Diagnostics: Failure to send command to manager daemon.",
1499  response_data);
1500  }
1501  }
1502  g_free (filter_escaped);
1503 
1504  entity = NULL;
1505  if (read_entity_and_text_c (connection, &entity, &content))
1506  {
1507  cmd_response_data_set_status_code (response_data,
1508  MHD_HTTP_INTERNAL_SERVER_ERROR);
1509  return gsad_message (
1510  credentials, "Internal error", __FUNCTION__, __LINE__,
1511  "An internal error occurred while getting a list. "
1512  "The list could not be delivered. "
1513  "Diagnostics: Failure to receive response from manager daemon.",
1514  response_data);
1515  }
1516 
1517  if (!gmp_success (entity))
1518  set_http_status_from_entity (entity, response_data);
1519 
1520  ret = setting_get_value (connection, "0872a6ed-4f85-48c5-ac3f-a5ef5e006745",
1521  &fname_format, response_data);
1522  if (ret)
1523  {
1524  g_free (content);
1525  free_entity (entity);
1526  cmd_response_data_set_status_code (response_data,
1527  MHD_HTTP_INTERNAL_SERVER_ERROR);
1528  switch (ret)
1529  {
1530  case 1:
1531  return gsad_message (
1532  credentials, "Internal error", __FUNCTION__, __LINE__,
1533  "An internal error occurred while getting a setting. "
1534  "The setting could not be delivered. "
1535  "Diagnostics: Failure to send command to manager daemon.",
1536  response_data);
1537  case 2:
1538  return gsad_message (
1539  credentials, "Internal error", __FUNCTION__, __LINE__,
1540  "An internal error occurred while getting a setting. "
1541  "The setting could not be delivered. "
1542  "Diagnostics: Failure to receive response from manager daemon.",
1543  response_data);
1544  default:
1545  return gsad_message (
1546  credentials, "Internal error", __FUNCTION__, __LINE__,
1547  "An internal error occurred while getting a setting. "
1548  "The setting could not be delivered. "
1549  "Diagnostics: Internal error.",
1550  response_data);
1551  }
1552  }
1553 
1554  if (fname_format == NULL)
1555  {
1556  g_warning ("%s : File name format setting not found.", __FUNCTION__);
1557  fname_format = "%T-%D";
1558  }
1559 
1560  if (strcmp (type, "info") == 0)
1561  type_many = g_strdup (type);
1562  else
1563  type_many = g_strdup_printf ("%ss", type);
1564 
1565  file_name =
1566  format_file_name (fname_format, credentials, type_many, "list", NULL);
1567  if (file_name == NULL)
1568  file_name = g_strdup_printf ("%s-%s", type_many, "list");
1569 
1570  g_free (type_many);
1571 
1574  response_data,
1575  g_strdup_printf ("attachment; filename=\"%s.xml\"", file_name));
1576  cmd_response_data_set_content_length (response_data, strlen (content));
1577 
1578  free_entity (entity);
1579  g_free (file_name);
1580  return content;
1581 }

References cmd_response_data_set_content_disposition(), cmd_response_data_set_content_length(), cmd_response_data_set_content_type(), cmd_response_data_set_status_code(), format_file_name(), gmp_success(), GSAD_CONTENT_TYPE_APP_XML, gsad_message(), params_value(), set_http_status_from_entity(), and setting_get_value().

Referenced by bulk_export_gmp(), export_agents_gmp(), export_alerts_gmp(), export_assets_gmp(), export_configs_gmp(), export_credentials_gmp(), export_filters_gmp(), export_groups_gmp(), export_notes_gmp(), export_overrides_gmp(), export_permissions_gmp(), export_port_lists_gmp(), export_report_formats_gmp(), export_results_gmp(), export_roles_gmp(), export_scanners_gmp(), export_schedules_gmp(), export_tags_gmp(), export_targets_gmp(), export_tasks_gmp(), and export_users_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_note_gmp()

char* export_note_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a note.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. Enveloped XML on error.

Definition at line 8201 of file gsad_gmp.c.

8203 {
8204  return export_resource (connection, "note", credentials, params,
8205  response_data);
8206 }

References export_resource().

Here is the call graph for this function:

◆ export_notes_gmp()

char* export_notes_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of notes.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Notes XML on success. Enveloped XML on error.

Definition at line 8220 of file gsad_gmp.c.

8222 {
8223  return export_many (connection, "note", credentials, params, response_data);
8224 }

References export_many().

Here is the call graph for this function:

◆ export_override_gmp()

char* export_override_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export an override.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Override XML on success. Enveloped XML on error.

Definition at line 8237 of file gsad_gmp.c.

8239 {
8240  return export_resource (connection, "override", credentials, params,
8241  response_data);
8242 }

References export_resource().

Here is the call graph for this function:

◆ export_overrides_gmp()

char* export_overrides_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of overrides.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Overrides XML on success. Enveloped XML on error.

Definition at line 8256 of file gsad_gmp.c.

8258 {
8259  return export_many (connection, "override", credentials, params,
8260  response_data);
8261 }

References export_many().

Here is the call graph for this function:

◆ export_permission_gmp()

char* export_permission_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a permission.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Permission XML on success. Enveloped XML on error.

Definition at line 13236 of file gsad_gmp.c.

13238 {
13239  return export_resource (connection, "permission", credentials, params,
13240  response_data);
13241 }

References export_resource().

Here is the call graph for this function:

◆ export_permissions_gmp()

char* export_permissions_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of permissions.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Permissions XML on success. Enveloped XML on error.

Definition at line 13255 of file gsad_gmp.c.

13258 {
13259  return export_many (connection, "permission", credentials, params,
13260  response_data);
13261 }

References export_many().

Here is the call graph for this function:

◆ export_port_list_gmp()

char* export_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a Port List.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Port List XML on success. Enveloped XML on error.

Definition at line 8275 of file gsad_gmp.c.

8277 {
8278  return export_resource (connection, "port_list", credentials, params,
8279  response_data);
8280 }

References export_resource().

Here is the call graph for this function:

◆ export_port_lists_gmp()

char* export_port_lists_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of Port Lists.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Port Lists XML on success. Enveloped XML on error.

Definition at line 8294 of file gsad_gmp.c.

8296 {
8297  return export_many (connection, "port_list", credentials, params,
8298  response_data);
8299 }

References export_many().

Here is the call graph for this function:

◆ export_preference_file_gmp()

char* export_preference_file_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a file preference.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Config XML on success. Enveloped XML on error.

Definition at line 8312 of file gsad_gmp.c.

8315 {
8316  GString *xml;
8317  entity_t entity, preference_entity, value_entity;
8318  const char *config_id, *oid, *preference_name;
8319 
8320  config_id = params_value (params, "config_id");
8321  oid = params_value (params, "oid");
8322  preference_name = params_value (params, "preference_name");
8323 
8324  xml = g_string_new ("<get_preferences_response>");
8325 
8326  CHECK_VARIABLE_INVALID (config_id, "Export Preference File")
8327  CHECK_VARIABLE_INVALID (oid, "Export Preference File")
8328  CHECK_VARIABLE_INVALID (preference_name, "Export Preference File")
8329 
8330  if (gvm_connection_sendf (connection,
8331  "<get_preferences"
8332  " config_id=\"%s\""
8333  " nvt_oid=\"%s\""
8334  " preference=\"%s\"/>",
8335  config_id, oid, preference_name)
8336  == -1)
8337  {
8338  g_string_free (xml, TRUE);
8339  cmd_response_data_set_status_code (response_data,
8340  MHD_HTTP_INTERNAL_SERVER_ERROR);
8341  return gsad_message (
8342  credentials, "Internal error", __FUNCTION__, __LINE__,
8343  "An internal error occurred while getting a preference file. "
8344  "The file could not be delivered. "
8345  "Diagnostics: Failure to send command to manager daemon.",
8346  response_data);
8347  }
8348 
8349  entity = NULL;
8350  if (read_entity_c (connection, &entity))
8351  {
8352  g_string_free (xml, TRUE);
8353  cmd_response_data_set_status_code (response_data,
8354  MHD_HTTP_INTERNAL_SERVER_ERROR);
8355  return gsad_message (
8356  credentials, "Internal error", __FUNCTION__, __LINE__,
8357  "An internal error occurred while getting a preference file. "
8358  "The file could not be delivered. "
8359  "Diagnostics: Failure to receive response from manager daemon.",
8360  response_data);
8361  }
8362 
8363  preference_entity = entity_child (entity, "preference");
8364  if (preference_entity != NULL
8365  && (value_entity = entity_child (preference_entity, "value")))
8366  {
8367  char *content = strdup (entity_text (value_entity));
8368  cmd_response_data_set_content_type (response_data,
8371  response_data,
8372  g_strdup_printf ("attachment; filename=\"pref_file.bin\""));
8373  cmd_response_data_set_content_length (response_data, strlen (content));
8374  free_entity (entity);
8375  g_string_free (xml, TRUE);
8376  return content;
8377  }
8378  else
8379  {
8380  free_entity (entity);
8381  g_string_free (xml, TRUE);
8382  cmd_response_data_set_status_code (response_data,
8383  MHD_HTTP_INTERNAL_SERVER_ERROR);
8384  return gsad_message (
8385  credentials, "Internal error", __FUNCTION__, __LINE__,
8386  "An internal error occurred while getting a preference file. "
8387  "The file could not be delivered. "
8388  "Diagnostics: Failure to receive file from manager daemon.",
8389  response_data);
8390  }
8391 
8392  g_string_append (xml, "</get_preferences_response>");
8393  return envelope_gmp (connection, credentials, params,
8394  g_string_free (xml, FALSE), response_data);
8395 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_content_disposition(), cmd_response_data_set_content_length(), cmd_response_data_set_content_type(), cmd_response_data_set_status_code(), envelope_gmp(), GSAD_CONTENT_TYPE_OCTET_STREAM, gsad_message(), and params_value().

Here is the call graph for this function:

◆ export_report_format_gmp()

char* export_report_format_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a report format.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Report format XML on success. Enveloped XML on error.

Definition at line 8409 of file gsad_gmp.c.

8412 {
8413  return export_resource (connection, "report_format", credentials, params,
8414  response_data);
8415 }

References export_resource().

Here is the call graph for this function:

◆ export_report_formats_gmp()

char* export_report_formats_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of Report Formats.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Report Formats XML on success. Enveloped XML on error.

Definition at line 8429 of file gsad_gmp.c.

8432 {
8433  return export_many (connection, "report_format", credentials, params,
8434  response_data);
8435 }

References export_many().

Here is the call graph for this function:

◆ export_resource()

char* export_resource ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a resource.

Parameters
[in]connectionConnection to manager.
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Resource XML on success. XML error object on error.

Definition at line 1267 of file gsad_gmp.c.

1270 {
1271  GString *xml;
1272  entity_t entity;
1273  entity_t resource_entity;
1274  char *content = NULL;
1275  gchar *id_name;
1276  gchar *fname_format, *file_name;
1277  int ret;
1278  const char *resource_id, *subtype;
1279 
1280  xml = g_string_new ("");
1281 
1282  id_name = g_strdup_printf ("%s_id", type);
1283  resource_id = params_value (params, id_name);
1284  g_free (id_name);
1285 
1286  if (resource_id == NULL)
1287  {
1288  g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Export Resource"));
1289  return envelope_gmp (connection, credentials, params,
1290  g_string_free (xml, FALSE), response_data);
1291  }
1292 
1293  subtype = params_value (params, "subtype");
1294 
1295  if (gvm_connection_sendf (connection,
1296  "<get_%ss"
1297  " %s_id=\"%s\""
1298  "%s%s%s"
1299  " export=\"1\""
1300  " details=\"1\"/>",
1301  type, type, resource_id, subtype ? " type=\"" : "",
1302  subtype ? subtype : "", subtype ? "\"" : "")
1303  == -1)
1304  {
1305  g_string_free (xml, TRUE);
1306  cmd_response_data_set_status_code (response_data,
1307  MHD_HTTP_INTERNAL_SERVER_ERROR);
1308  return gsad_message (
1309  credentials, "Internal error", __FUNCTION__, __LINE__,
1310  "An internal error occurred while getting a resource. "
1311  "The resource could not be delivered. "
1312  "Diagnostics: Failure to send command to manager daemon.",
1313  response_data);
1314  }
1315 
1316  entity = NULL;
1317  if (read_entity_and_text_c (connection, &entity, &content))
1318  {
1319  g_string_free (xml, TRUE);
1320  cmd_response_data_set_status_code (response_data,
1321  MHD_HTTP_INTERNAL_SERVER_ERROR);
1322  return gsad_message (
1323  credentials, "Internal error", __FUNCTION__, __LINE__,
1324  "An internal error occurred while getting a resource. "
1325  "The resource could not be delivered. "
1326  "Diagnostics: Failure to receive response from manager daemon.",
1327  response_data);
1328  }
1329 
1330  if (!gmp_success (entity))
1331  set_http_status_from_entity (entity, response_data);
1332 
1333  resource_entity = entity_child (entity, type);
1334 
1335  if (resource_entity == NULL)
1336  {
1337  g_free (content);
1338  free_entity (entity);
1339  g_string_free (xml, TRUE);
1340  cmd_response_data_set_status_code (response_data,
1341  MHD_HTTP_INTERNAL_SERVER_ERROR);
1342  return gsad_message (
1343  credentials, "Internal error", __FUNCTION__, __LINE__,
1344  "An internal error occurred while getting a resource. "
1345  "The resource could not be delivered. "
1346  "Diagnostics: Failure to receive resource from manager daemon.",
1347  response_data);
1348  }
1349 
1350  ret = setting_get_value (connection, "a6ac88c5-729c-41ba-ac0a-deea4a3441f2",
1351  &fname_format, response_data);
1352  if (ret)
1353  {
1354  g_free (content);
1355  free_entity (entity);
1356  g_string_free (xml, TRUE);
1357  cmd_response_data_set_status_code (response_data,
1358  MHD_HTTP_INTERNAL_SERVER_ERROR);
1359  switch (ret)
1360  {
1361  case 1:
1362  return gsad_message (
1363  credentials, "Internal error", __FUNCTION__, __LINE__,
1364  "An internal error occurred while getting a setting. "
1365  "The setting could not be delivered. "
1366  "Diagnostics: Failure to send command to manager daemon.",
1367  response_data);
1368  case 2:
1369  return gsad_message (
1370  credentials, "Internal error", __FUNCTION__, __LINE__,
1371  "An internal error occurred while getting a setting. "
1372  "The setting could not be delivered. "
1373  "Diagnostics: Failure to receive response from manager daemon.",
1374  response_data);
1375  default:
1376  return gsad_message (
1377  credentials, "Internal error", __FUNCTION__, __LINE__,
1378  "An internal error occurred while getting a setting. "
1379  "The setting could not be delivered. "
1380  "Diagnostics: Internal error.",
1381  response_data);
1382  }
1383  }
1384 
1385  if (fname_format == NULL)
1386  {
1387  g_warning ("%s : File name format setting not found.", __FUNCTION__);
1388  fname_format = "%T-%U";
1389  }
1390 
1391  file_name = format_file_name (fname_format, credentials, type, resource_id,
1392  resource_entity);
1393  if (file_name == NULL)
1394  file_name = g_strdup_printf ("%s-%s", type, resource_id);
1395 
1398  response_data,
1399  g_strdup_printf ("attachment; filename=\"%s.xml\"", file_name));
1400  cmd_response_data_set_content_length (response_data, strlen (content));
1401 
1402  free_entity (entity);
1403  g_free (file_name);
1404  g_string_free (xml, TRUE);
1405  return content;
1406 }

References cmd_response_data_set_content_disposition(), cmd_response_data_set_content_length(), cmd_response_data_set_content_type(), cmd_response_data_set_status_code(), envelope_gmp(), format_file_name(), gmp_success(), GSAD_CONTENT_TYPE_APP_XML, gsad_message(), GSAD_MESSAGE_INVALID_PARAM, params_value(), set_http_status_from_entity(), and setting_get_value().

Referenced by export_agent_gmp(), export_alert_gmp(), export_asset_gmp(), export_config_gmp(), export_credential_gmp(), export_filter_gmp(), export_group_gmp(), export_note_gmp(), export_override_gmp(), export_permission_gmp(), export_port_list_gmp(), export_report_format_gmp(), export_result_gmp(), export_role_gmp(), export_scanner_gmp(), export_schedule_gmp(), export_tag_gmp(), export_target_gmp(), export_task_gmp(), and export_user_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_result_gmp()

char* export_result_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result XML on success. Enveloped XML on error.

Definition at line 9154 of file gsad_gmp.c.

9156 {
9157  return export_resource (connection, "result", credentials, params,
9158  response_data);
9159 }

References export_resource().

Here is the call graph for this function:

◆ export_results_gmp()

char* export_results_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of results.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Results XML on success. Enveloped XML on error.

Definition at line 9173 of file gsad_gmp.c.

9175 {
9176  return export_many (connection, "result", credentials, params, response_data);
9177 }

References export_many().

Here is the call graph for this function:

◆ export_role_gmp()

char* export_role_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a role.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Role XML on success. Enveloped XML on error.

Definition at line 13945 of file gsad_gmp.c.

13947 {
13948  return export_resource (connection, "role", credentials, params,
13949  response_data);
13950 }

References export_resource().

Here is the call graph for this function:

◆ export_roles_gmp()

char* export_roles_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of roles.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Roles XML on success. Enveloped XML on error.

Definition at line 13964 of file gsad_gmp.c.

13966 {
13967  return export_many (connection, "role", credentials, params, response_data);
13968 }

References export_many().

Here is the call graph for this function:

◆ export_scanner_gmp()

char* export_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a scanner.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Scanner XML on success. Enveloped XML on error.

Definition at line 10012 of file gsad_gmp.c.

10014 {
10015  return export_resource (connection, "scanner", credentials, params,
10016  response_data);
10017 }

References export_resource().

Here is the call graph for this function:

◆ export_scanners_gmp()

char* export_scanners_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of scanners.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Scanners XML on success. Enveloped XML on error.

Definition at line 10030 of file gsad_gmp.c.

10032 {
10033  return export_many (connection, "scanner", credentials, params,
10034  response_data);
10035 }

References export_many().

Here is the call graph for this function:

◆ export_schedule_gmp()

char* export_schedule_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a schedule.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Schedule XML on success. Enveloped XML on error.

Definition at line 14518 of file gsad_gmp.c.

14520 {
14521  return export_resource (connection, "schedule", credentials, params,
14522  response_data);
14523 }

References export_resource().

Here is the call graph for this function:

◆ export_schedules_gmp()

char* export_schedules_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of schedules.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Schedules XML on success. Enveloped XML on error.

Definition at line 14536 of file gsad_gmp.c.

14538 {
14539  return export_many (connection, "schedule", credentials, params,
14540  response_data);
14541 }

References export_many().

Here is the call graph for this function:

◆ export_tag_gmp()

char* export_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a tag.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Target XML on success. Enveloped XML on error.

Definition at line 6566 of file gsad_gmp.c.

6568 {
6569  return export_resource (connection, "tag", credentials, params,
6570  response_data);
6571 }

References export_resource().

Here is the call graph for this function:

◆ export_tags_gmp()

char* export_tags_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of tags.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Targets XML on success. Enveloped XML on error.

Definition at line 6585 of file gsad_gmp.c.

6587 {
6588  return export_many (connection, "tag", credentials, params, response_data);
6589 }

References export_many().

Here is the call graph for this function:

◆ export_target_gmp()

char* export_target_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a target.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Target XML on success. Enveloped XML on error.

Definition at line 7025 of file gsad_gmp.c.

7027 {
7028  return export_resource (connection, "target", credentials, params,
7029  response_data);
7030 }

References export_resource().

Here is the call graph for this function:

◆ export_targets_gmp()

char* export_targets_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of targets.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Targets XML on success. Enveloped XML on error.

Definition at line 7044 of file gsad_gmp.c.

7046 {
7047  return export_many (connection, "target", credentials, params, response_data);
7048 }

References export_many().

Here is the call graph for this function:

◆ export_task_gmp()

char* export_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a task.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. Enveloped XML on error.

Definition at line 2804 of file gsad_gmp.c.

2806 {
2807  return export_resource (connection, "task", credentials, params,
2808  response_data);
2809 }

References export_resource().

Here is the call graph for this function:

◆ export_tasks_gmp()

char* export_tasks_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of tasks.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Tasks XML on success. Enveloped XML on error.

Definition at line 2823 of file gsad_gmp.c.

2825 {
2826  return export_many (connection, "task", credentials, params, response_data);
2827 }

References export_many().

Here is the call graph for this function:

◆ export_user_gmp()

char* export_user_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a user.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. Enveloped XML on error.

Definition at line 15253 of file gsad_gmp.c.

15255 {
15256  return export_resource (connection, "user", credentials, params,
15257  response_data);
15258 }

References export_resource().

Here is the call graph for this function:

◆ export_users_gmp()

char* export_users_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Export a list of users.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Users XML on success. Enveloped XML on error.

Definition at line 15272 of file gsad_gmp.c.

15274 {
15275  return export_many (connection, "user", credentials, params, response_data);
15276 }

References export_many().

Here is the call graph for this function:

◆ format_file_name()

gchar* format_file_name ( gchar *  fname_format,
credentials_t *  credentials,
const char *  type,
const char *  uuid,
entity_t  resource_entity 
)

Generates a file name for exporting.

Parameters
[in]fname_formatFormat string.
[in]credentialsCurrent credentials.
[in]typeType of resource.
[in]uuidUUID of resource.
[in]resource_entityResource entity to extract extra data from.
Returns
The file name.

Definition at line 1182 of file gsad_gmp.c.

1184 {
1185  gchar *creation_time, *modification_time, *name, *format_name;
1186  gchar *ret;
1187 
1188  if (resource_entity)
1189  {
1190  entity_t creation_time_entity, modification_time_entity;
1191  entity_t task_entity, format_entity, format_name_entity, name_entity;
1192 
1193  creation_time_entity = entity_child (resource_entity, "creation_time");
1194 
1195  if (creation_time_entity)
1196  creation_time = entity_text (creation_time_entity);
1197  else
1198  creation_time = NULL;
1199 
1200  modification_time_entity =
1201  entity_child (resource_entity, "modification_time");
1202 
1203  if (modification_time_entity)
1204  modification_time = entity_text (modification_time_entity);
1205  else
1206  modification_time = NULL;
1207 
1208  if (strcasecmp (type, "report") == 0)
1209  {
1210  task_entity = entity_child (resource_entity, "task");
1211  if (task_entity)
1212  name_entity = entity_child (task_entity, "name");
1213  else
1214  name_entity = NULL;
1215 
1216  format_entity = entity_child (resource_entity, "report_format");
1217  if (format_entity)
1218  {
1219  format_name_entity = entity_child (format_entity, "name");
1220  }
1221  else
1222  format_name_entity = NULL;
1223 
1224  if (format_name_entity && strlen (entity_text (format_name_entity)))
1225  format_name = entity_text (format_name_entity);
1226  else
1227  format_name = NULL;
1228  }
1229  else
1230  {
1231  name_entity = entity_child (resource_entity, "name");
1232  format_name = NULL;
1233  }
1234 
1235  if (name_entity)
1236  name = entity_text (name_entity);
1237  else
1238  name = NULL;
1239  }
1240  else
1241  {
1242  creation_time = NULL;
1243  modification_time = NULL;
1244  name = NULL;
1245  format_name = NULL;
1246  }
1247 
1249  ret =
1250  gvm_export_file_name (fname_format, user_get_username (user), type, uuid,
1251  creation_time, modification_time, name, format_name);
1252  return ret;
1253 }

References credentials_get_user(), and user_get_username().

Referenced by export_many(), export_resource(), and get_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_agent()

char * get_agent ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one agent, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4323 of file gsad_gmp.c.

4326 {
4327  return get_one (connection, "agent", credentials, params, extra_xml, NULL,
4328  response_data);
4329 }

References get_one().

Referenced by get_agent_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_agent_gmp()

char* get_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one agent, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4342 of file gsad_gmp.c.

4344 {
4345  return get_agent (connection, credentials, params, NULL, response_data);
4346 }

References get_agent().

Here is the call graph for this function:

◆ get_agents_gmp()

char* get_agents_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all agents, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4359 of file gsad_gmp.c.

4361 {
4362  return get_many (connection, "agents", credentials, params, NULL,
4363  response_data);
4364 }

References get_many().

Here is the call graph for this function:

◆ get_aggregate_gmp()

char* get_aggregate_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get an aggregate of resources.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
The aggregate.

Definition at line 4488 of file gsad_gmp.c.

4490 {
4491  params_t *data_columns, *text_columns;
4492  params_t *sort_fields, *sort_stats, *sort_orders;
4493  params_iterator_t data_columns_iterator, text_columns_iterator;
4494  params_iterator_t sort_fields_iterator, sort_stats_iterator;
4495  params_iterator_t sort_orders_iterator;
4496  char *param_name;
4497  param_t *param;
4498 
4499  const char *data_column, *group_column, *subgroup_column, *type;
4500  const char *filter, *filter_id;
4501  const char *first_group, *max_groups;
4502  const char *mode;
4503  const char *usage_type;
4504  gchar *filter_escaped, *command_escaped, *response;
4505  entity_t entity;
4506  GString *xml, *command;
4507  int ret;
4508 
4509  data_columns = params_values (params, "data_columns:");
4510  data_column = params_value (params, "data_column");
4511  text_columns = params_values (params, "text_columns:");
4512  group_column = params_value (params, "group_column");
4513  subgroup_column = params_value (params, "subgroup_column");
4514  type = params_value (params, "aggregate_type");
4515  filter = params_value (params, "filter");
4516  filter_id = params_value (params, "filter_id");
4517  sort_fields = params_values (params, "sort_fields:");
4518  sort_stats = params_values (params, "sort_stats:");
4519  sort_orders = params_values (params, "sort_orders:");
4520  first_group = params_value (params, "first_group");
4521  max_groups = params_value (params, "max_groups");
4522  mode = params_value (params, "aggregate_mode");
4523  usage_type = params_value (params, "usage_type");
4524 
4525  if (filter && !str_equal (filter, ""))
4526  filter_escaped = g_markup_escape_text (filter, -1);
4527  else
4528  {
4529  if (filter_id == NULL || str_equal (filter_id, "")
4530  || str_equal (filter_id, FILT_ID_NONE))
4531  filter_escaped = g_strdup ("rows=-2");
4532  else
4533  filter_escaped = NULL;
4534  }
4535 
4536  xml = g_string_new ("<get_aggregate>");
4537 
4538  command = g_string_new ("<get_aggregates");
4539  g_string_append_printf (command, " type=\"%s\"", type);
4540  if (data_column)
4541  g_string_append_printf (command, " data_column=\"%s\"", data_column);
4542 
4543  if (group_column)
4544  g_string_append_printf (command, " group_column=\"%s\"", group_column);
4545 
4546  if (subgroup_column)
4547  g_string_append_printf (command, " subgroup_column=\"%s\"",
4548  subgroup_column);
4549  if (filter_escaped && strcmp (filter_escaped, ""))
4550  g_string_append_printf (command, " filter=\"%s\"", filter_escaped);
4551 
4552  if (filter_id && !str_equal (filter_id, ""))
4553  g_string_append_printf (command, " filt_id=\"%s\"", filter_id);
4554 
4555  if (first_group && strcmp (first_group, ""))
4556  g_string_append_printf (command, " first_group=\"%s\"", first_group);
4557 
4558  if (max_groups && strcmp (max_groups, ""))
4559  g_string_append_printf (command, " max_groups=\"%s\"", max_groups);
4560 
4561  if (mode && strcmp (mode, ""))
4562  g_string_append_printf (command, " mode=\"%s\"", mode);
4563 
4564  if (usage_type && strcmp (usage_type, ""))
4565  g_string_append_printf (command, " usage_type=\"%s\"", usage_type);
4566 
4567  g_string_append (command, ">");
4568 
4569  if (sort_fields && sort_stats && sort_orders)
4570  {
4571  param_t *field_param, *stat_param, *order_param;
4572  gchar *field_i, *stat_i, *order_i;
4573 
4574  params_iterator_init (&sort_fields_iterator, sort_fields);
4575  params_iterator_init (&sort_stats_iterator, sort_stats);
4576  params_iterator_init (&sort_orders_iterator, sort_orders);
4577 
4578  while (
4579  params_iterator_next (&sort_fields_iterator, &field_i, &field_param)
4580  && params_iterator_next (&sort_stats_iterator, &stat_i, &stat_param)
4581  && params_iterator_next (&sort_orders_iterator, &order_i, &order_param))
4582  {
4583  if (field_param->valid && stat_param->valid && order_param->valid)
4584  {
4585  xml_string_append (command,
4586  "<sort field=\"%s\""
4587  " stat=\"%s\""
4588  " order=\"%s\"/>",
4589  field_param->value ? field_param->value : "",
4590  stat_param->value ? stat_param->value : "",
4591  order_param->value ? order_param->value : "");
4592  }
4593  }
4594  }
4595 
4596  if (data_columns)
4597  {
4598  params_iterator_init (&data_columns_iterator, data_columns);
4599  while (params_iterator_next (&data_columns_iterator, &param_name, &param))
4600  {
4601  if (param->valid)
4602  {
4603  xml_string_append (command, "<data_column>%s</data_column>",
4604  param->value);
4605  }
4606  }
4607  }
4608 
4609  if (text_columns)
4610  {
4611  params_iterator_init (&text_columns_iterator, text_columns);
4612  while (params_iterator_next (&text_columns_iterator, &param_name, &param))
4613  {
4614  if (param->valid)
4615  {
4616  xml_string_append (command, "<text_column>%s</text_column>",
4617  param->value);
4618  }
4619  }
4620  }
4621 
4622  g_string_append (command, "</get_aggregates>");
4623 
4624  g_free (filter_escaped);
4625 
4626  command_escaped = g_markup_escape_text (command->str, -1);
4627  g_string_append (xml, command_escaped);
4628  g_free (command_escaped);
4629 
4630  response = NULL;
4631  ret = gmp (connection, credentials, &response, &entity, response_data,
4632  command->str);
4633  g_string_free (command, TRUE);
4634 
4635  if (ret)
4636  {
4637  free_entity (entity);
4638  g_string_free (xml, TRUE);
4639  }
4640 
4641  switch (ret)
4642  {
4643  case 0:
4644  break;
4645  case 1:
4646  cmd_response_data_set_status_code (response_data,
4647  MHD_HTTP_INTERNAL_SERVER_ERROR);
4648  return gsad_message (
4649  credentials, "Internal error", __FUNCTION__, __LINE__,
4650  "An internal error occurred while getting aggregates. "
4651  "Diagnostics: Failure to send command to manager daemon.",
4652  response_data);
4653  case 2:
4654  cmd_response_data_set_status_code (response_data,
4655  MHD_HTTP_INTERNAL_SERVER_ERROR);
4656  return gsad_message (
4657  credentials, "Internal error", __FUNCTION__, __LINE__,
4658  "An internal error occurred while getting aggregates. "
4659  "Diagnostics: Failure to receive response from manager daemon.",
4660  response_data);
4661  default:
4662  cmd_response_data_set_status_code (response_data,
4663  MHD_HTTP_INTERNAL_SERVER_ERROR);
4664  return gsad_message (
4665  credentials, "Internal error", __FUNCTION__, __LINE__,
4666  "An internal error occurred while getting aggregates. "
4667  "Diagnostics: Internal Error.",
4668  response_data);
4669  }
4670 
4671  if (gmp_success (entity) == 0)
4672  set_http_status_from_entity (entity, response_data);
4673 
4674  g_string_append (xml, response);
4675 
4676  g_string_append (xml, "</get_aggregate>");
4677 
4678  free_entity (entity);
4679  g_free (response);
4680  return envelope_gmp (connection, credentials, params,
4681  g_string_free (xml, FALSE), response_data);
4682 }

References cmd_response_data_set_status_code(), envelope_gmp(), FILT_ID_NONE, gmp(), gmp_success(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), set_http_status_from_entity(), str_equal(), param::valid, and param::value.

Here is the call graph for this function:

◆ get_alert()

char * get_alert ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one alert, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5328 of file gsad_gmp.c.

5331 {
5332  gmp_arguments_t *arguments;
5333  arguments = gmp_arguments_new ();
5334 
5335  gmp_arguments_add (arguments, "tasks", "1");
5336 
5337  return get_one (connection, "alert", credentials, params, NULL, arguments,
5338  response_data);
5339 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_alert_gmp()

char* get_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one alert, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5352 of file gsad_gmp.c.

5354 {
5355  return get_alert (connection, credentials, params, NULL, response_data);
5356 }

References get_alert().

Here is the call graph for this function:

◆ get_alerts()

char* get_alerts ( gvm_connection_t *  connection,
credentials_t *  ,
params_t *  ,
const char *  ,
cmd_response_data_t *   
)

◆ get_alerts_gmp()

char* get_alerts_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all alerts, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5369 of file gsad_gmp.c.

5371 {
5372  return get_many (connection, "alerts", credentials, params, NULL,
5373  response_data);
5374 }

References get_many().

Here is the call graph for this function:

◆ get_asset()

char * get_asset ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Request an asset.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials for the manager connection.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
XML enveloped asset response or error message.

Definition at line 16212 of file gsad_gmp.c.

16215 {
16216  const gchar *asset_type;
16217  gmp_arguments_t *arguments;
16218 
16219  asset_type = params_value (params, "asset_type");
16220 
16221  CHECK_VARIABLE_INVALID (asset_type, "Get Asset")
16222 
16223  if (params_value (params, "asset_name") && params_value (params, "asset_id"))
16224  {
16225  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
16226  return gsad_message (credentials, "Internal error", __FUNCTION__,
16227  __LINE__,
16228  "An internal error occurred while getting an asset. "
16229  "Diagnostics: Both ID and Name set.",
16230  response_data);
16231  }
16232 
16233  arguments = gmp_arguments_new ();
16234 
16235  gmp_arguments_add (arguments, "type", asset_type);
16236 
16237  if (params_value (params, "asset_name"))
16238  {
16239  gmp_arguments_add (arguments, "name",
16240  params_value (params, "asset_name"));
16241  }
16242 
16243  return get_one (connection, "asset", credentials, params, NULL, arguments,
16244  response_data);
16245 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_one(), gmp_arguments_add(), gmp_arguments_new(), gsad_message(), and params_value().

Referenced by get_asset_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_asset_gmp()

char* get_asset_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get asset, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16258 of file gsad_gmp.c.

16260 {
16261  return get_asset (connection, credentials, params, NULL, response_data);
16262 }

References get_asset().

Here is the call graph for this function:

◆ get_assets_gmp()

char* get_assets_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Request assets.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials for the manager connection.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
XML enveloped assets response or error message.

Definition at line 16276 of file gsad_gmp.c.

16278 {
16279  gmp_arguments_t *arguments;
16280  const char *asset_type;
16281 
16282  asset_type = params_value (params, "asset_type");
16283 
16284  CHECK_VARIABLE_INVALID (asset_type, "Get Assets");
16285 
16286  arguments = gmp_arguments_new ();
16287 
16288  gmp_arguments_add (arguments, "type", asset_type);
16289 
16290  if (params_value (params, "ignore_pagination"))
16291  {
16292  gmp_arguments_add (arguments, "ignore_pagination",
16293  params_value (params, "ignore_pagination"));
16294  }
16295 
16296  return get_many (connection, "assets", credentials, params, arguments,
16297  response_data);
16298 }

References CHECK_VARIABLE_INVALID, get_many(), gmp_arguments_add(), gmp_arguments_new(), and params_value().

Here is the call graph for this function:

◆ get_capabilities_gmp()

char* get_capabilities_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Definition at line 17079 of file gsad_gmp.c.

17081 {
17082  entity_t entity = NULL;
17083  GString *xml;
17084 
17085  if (gvm_connection_sendf (connection,
17086  "<help format=\"XML\" type=\"brief\"/>"))
17087  {
17088  cmd_response_data_set_status_code (response_data,
17089  MHD_HTTP_INTERNAL_SERVER_ERROR);
17090  return gsad_message (
17091  credentials, "Internal error", __FUNCTION__, __LINE__,
17092  "An internal error occurred while getting the user credentials. "
17093  "Diagnostics: Failure to send command to manager daemon.",
17094  response_data);
17095  }
17096 
17097  xml = g_string_new ("");
17098  g_string_append (xml, "<get_capabilities>");
17099 
17100  /* Read the response. */
17101  if (read_entity_and_string_c (connection, &entity, &xml))
17102  {
17103  g_string_free (xml, TRUE);
17104  cmd_response_data_set_status_code (response_data,
17105  MHD_HTTP_INTERNAL_SERVER_ERROR);
17106  return gsad_message (
17107  credentials, "Internal error", __FUNCTION__, __LINE__,
17108  "An internal error occurred while getting the user credentials. "
17109  "Diagnostics: Failure to receive response from manager daemon.",
17110  response_data);
17111  }
17112 
17113  if (gmp_success (entity) != 1)
17114  {
17115  gchar *message;
17116 
17117  set_http_status_from_entity (entity, response_data);
17118 
17119  message =
17120  gsad_message (credentials, "Error", __FUNCTION__, __LINE__,
17121  entity_attribute (entity, "status_text"), response_data);
17122 
17123  g_string_free (xml, TRUE);
17124  free_entity (entity);
17125  return message;
17126  }
17127 
17128  /* Cleanup, and return transformed XML. */
17129  free_entity (entity);
17130 
17131  g_string_append (xml, "</get_capabilities>");
17132  return envelope_gmp (connection, credentials, params,
17133  g_string_free (xml, FALSE), response_data);
17134 }

References cmd_response_data_set_status_code(), envelope_gmp(), gmp_success(), gsad_message(), and set_http_status_from_entity().

Here is the call graph for this function:

◆ get_config_family()

static char * get_config_family ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
int  edit,
cmd_response_data_t *  response_data 
)
static

Get details of a family for a config, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]edit0 for config view page, else config edit page.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7605 of file gsad_gmp.c.

7608 {
7609  GString *xml;
7610  const char *config_id, *family, *sort_field, *sort_order;
7611 
7612  config_id = params_value (params, "config_id");
7613  family = params_value (params, "family");
7614 
7615  CHECK_VARIABLE_INVALID (config_id, "Get Scan Config Family")
7616  CHECK_VARIABLE_INVALID (family, "Get Scan Config Family")
7617 
7618  xml = g_string_new ("<get_config_family_response>");
7619 
7620  /* Get the details for all NVT's in the config in the family. */
7621 
7622  sort_field = params_value (params, "sort_field");
7623  sort_order = params_value (params, "sort_order");
7624 
7625  if (gvm_connection_sendf (
7626  connection,
7627  "<get_nvts"
7628  " config_id=\"%s\" details=\"1\""
7629  " family=\"%s\" timeout=\"1\" preference_count=\"1\""
7630  " sort_field=\"%s\" sort_order=\"%s\"/>",
7631  config_id, family, sort_field ? sort_field : "nvts.name",
7632  sort_order ? sort_order : "ascending")
7633  == -1)
7634  {
7635  g_string_free (xml, TRUE);
7636  cmd_response_data_set_status_code (response_data,
7637  MHD_HTTP_INTERNAL_SERVER_ERROR);
7638  return gsad_message (
7639  credentials, "Internal error", __FUNCTION__, __LINE__,
7640  "An internal error occurred while getting list of configs. "
7641  "The current list of configs is not available. "
7642  "Diagnostics: Failure to send command to manager daemon.",
7643  response_data);
7644  }
7645 
7646  if (read_string_c (connection, &xml))
7647  {
7648  g_string_free (xml, TRUE);
7649  cmd_response_data_set_status_code (response_data,
7650  MHD_HTTP_INTERNAL_SERVER_ERROR);
7651  return gsad_message (
7652  credentials, "Internal error", __FUNCTION__, __LINE__,
7653  "An internal error occurred while getting list of configs. "
7654  "The current list of configs is not available. "
7655  "Diagnostics: Failure to receive response from manager daemon.",
7656  response_data);
7657  }
7658 
7659  if (edit)
7660  {
7661  /* Get the details for all NVT's in the family. */
7662 
7663  g_string_append (xml, "<all>");
7664 
7665  if (gvm_connection_sendf (connection,
7666  "<get_nvts"
7667  " details=\"1\""
7668  " timeout=\"1\""
7669  " family=\"%s\""
7670  " preferences_config_id=\"%s\""
7671  " preference_count=\"1\""
7672  " sort_field=\"%s\""
7673  " sort_order=\"%s\"/>",
7674  family, config_id,
7675  sort_field ? sort_field : "nvts.name",
7676  sort_order ? sort_order : "ascending")
7677  == -1)
7678  {
7679  g_string_free (xml, TRUE);
7680  cmd_response_data_set_status_code (response_data,
7681  MHD_HTTP_INTERNAL_SERVER_ERROR);
7682  return gsad_message (
7683  credentials, "Internal error", __FUNCTION__, __LINE__,
7684  "An internal error occurred while getting list of configs. "
7685  "The current list of configs is not available. "
7686  "Diagnostics: Failure to send command to manager daemon.",
7687  response_data);
7688  }
7689 
7690  if (read_string_c (connection, &xml))
7691  {
7692  g_string_free (xml, TRUE);
7693  cmd_response_data_set_status_code (response_data,
7694  MHD_HTTP_INTERNAL_SERVER_ERROR);
7695  return gsad_message (
7696  credentials, "Internal error", __FUNCTION__, __LINE__,
7697  "An internal error occurred while getting list of configs. "
7698  "The current list of configs is not available. "
7699  "Diagnostics: Failure to receive response from manager daemon.",
7700  response_data);
7701  }
7702 
7703  g_string_append (xml, "</all>");
7704  }
7705 
7706  g_string_append (xml, "</get_config_family_response>");
7707  return envelope_gmp (connection, credentials, params,
7708  g_string_free (xml, FALSE), response_data);
7709 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Referenced by edit_config_family_gmp(), and get_config_family_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_config_family_gmp()

char* get_config_family_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get details of a family for a config, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7722 of file gsad_gmp.c.

7724 {
7725  return get_config_family (connection, credentials, params, 0, response_data);
7726 }

References get_config_family().

Here is the call graph for this function:

◆ get_config_gmp()

char* get_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a config, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7250 of file gsad_gmp.c.

7252 {
7253  gmp_arguments_t *arguments;
7254 
7255  arguments = gmp_arguments_new ();
7256 
7257  gmp_arguments_add (arguments, "families", "1");
7258  gmp_arguments_add (arguments, "tasks", "1");
7259  gmp_arguments_add (arguments, "preferences", "1");
7260 
7261  return get_one (connection, "config", credentials, params, NULL, arguments,
7262  response_data);
7263 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Here is the call graph for this function:

◆ get_config_nvt_gmp()

char* get_config_nvt_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get details of an NVT for a config, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7844 of file gsad_gmp.c.

7846 {
7847  GString *xml;
7848  const char *config_id, *sort_field, *sort_order, *nvt;
7849 
7850  config_id = params_value (params, "config_id");
7851  nvt = params_value (params, "oid");
7852 
7853  CHECK_VARIABLE_INVALID (config_id, "Get Config")
7854 
7855  xml = g_string_new ("<get_config_nvt_response>");
7856 
7857  sort_field = params_value (params, "sort_field");
7858  sort_order = params_value (params, "sort_order");
7859 
7860  if (gvm_connection_sendf (connection,
7861  "<get_nvts"
7862  " config_id=\"%s\" nvt_oid=\"%s\""
7863  " details=\"1\" preferences=\"1\""
7864  " sort_field=\"%s\" sort_order=\"%s\"/>",
7865  config_id, nvt,
7866  sort_field ? sort_field : "nvts.name",
7867  sort_order ? sort_order : "ascending")
7868  == -1)
7869  {
7870  g_string_free (xml, TRUE);
7871  cmd_response_data_set_status_code (response_data,
7872  MHD_HTTP_INTERNAL_SERVER_ERROR);
7873  return gsad_message (
7874  credentials, "Internal error", __FUNCTION__, __LINE__,
7875  "An internal error occurred while getting list of configs. "
7876  "The current list of configs is not available. "
7877  "Diagnostics: Failure to send command to manager daemon.",
7878  response_data);
7879  }
7880 
7881  if (read_string_c (connection, &xml))
7882  {
7883  g_string_free (xml, TRUE);
7884  cmd_response_data_set_status_code (response_data,
7885  MHD_HTTP_INTERNAL_SERVER_ERROR);
7886  return gsad_message (
7887  credentials, "Internal error", __FUNCTION__, __LINE__,
7888  "An internal error occurred while getting list of configs. "
7889  "The current list of configs is not available. "
7890  "Diagnostics: Failure to receive response from manager daemon.",
7891  response_data);
7892  }
7893 
7894  g_string_append (xml, "</get_config_nvt_response>");
7895 
7896  return envelope_gmp (connection, credentials, params,
7897  g_string_free (xml, FALSE), response_data);
7898 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ get_configs_gmp()

char* get_configs_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all scan configs, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7219 of file gsad_gmp.c.

7221 {
7222  const char *usage_type;
7223  gmp_arguments_t *arguments = NULL;
7224 
7225  usage_type = params_value (params, "usage_type");
7226  if (params_given (params, "usage_type"))
7227  CHECK_VARIABLE_INVALID (usage_type, "Get Configs")
7228 
7229  if (usage_type)
7230  {
7231  arguments = gmp_arguments_new ();
7232  gmp_arguments_add (arguments, "usage_type", usage_type);
7233  }
7234 
7235  return get_many (connection, "configs", credentials, params, arguments,
7236  response_data);
7237 }

References CHECK_VARIABLE_INVALID, get_many(), gmp_arguments_add(), gmp_arguments_new(), params_given(), and params_value().

Here is the call graph for this function:

◆ get_credential()

static char * get_credential ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one credential, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]commandsExtra commands to run before the others.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3378 of file gsad_gmp.c.

3381 {
3382  gmp_arguments_t *arguments = gmp_arguments_new ();
3383  gmp_arguments_add (arguments, "targets", "1");
3384  gmp_arguments_add (arguments, "scanners", "1");
3385  return get_one (connection, "credential", credentials, params, extra_xml,
3386  arguments, response_data);
3387 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_credential_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_credential_gmp()

char* get_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one credential, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3400 of file gsad_gmp.c.

3402 {
3403  return get_credential (connection, credentials, params, NULL, response_data);
3404 }

References get_credential().

Here is the call graph for this function:

◆ get_credentials_gmp()

char* get_credentials_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one or all credentials, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
0 success, 1 failure.

Definition at line 3644 of file gsad_gmp.c.

3646 {
3647  return get_many (connection, "credentials", credentials, params, NULL,
3648  response_data);
3649 }

References get_many().

Here is the call graph for this function:

◆ get_entities()

static char* get_entities ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
gmp_arguments_t *  arguments,
cmd_response_data_t *  response_data 
)
static

Get all entities of a particular type, envelope the result.

Parameters
[in]connectionConnection to manager
[in]typeEntity type.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[in]argumentsExtra arguments for GMP GET command.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 964 of file gsad_gmp.c.

967 {
968  GString *xml;
969  gchar *cmd;
970  entity_t entity;
971 
972  cmd = g_strdup_printf ("get_%s", type);
973 
974  if (gmp_request (connection, cmd, arguments))
975  {
976  g_free (cmd);
977 
978  gmp_arguments_free (arguments);
979 
980  cmd_response_data_set_status_code (response_data,
981  MHD_HTTP_INTERNAL_SERVER_ERROR);
982  return gsad_message (
983  credentials, "Internal error", __FUNCTION__, __LINE__,
984  "An internal error occurred while getting a resource list. "
985  "The current list of resources is not available. "
986  "Diagnostics: Failure to send command to manager daemon.",
987  response_data);
988  }
989 
990  gmp_arguments_free (arguments);
991 
992  xml = g_string_new ("");
993  g_string_append_printf (xml, "<%s>", cmd);
994 
995  if (read_entity_and_string_c (connection, &entity, &xml))
996  {
997  g_free (cmd);
998  g_string_free (xml, TRUE);
999 
1000  cmd_response_data_set_status_code (response_data,
1001  MHD_HTTP_INTERNAL_SERVER_ERROR);
1002  return gsad_message (
1003  credentials, "Internal error", __FUNCTION__, __LINE__,
1004  "An internal error occurred while getting resources list. "
1005  "The current list of resources is not available. "
1006  "Diagnostics: Failure to receive response from manager daemon.",
1007  response_data);
1008  }
1009 
1010  if (gmp_success (entity) != 1)
1011  {
1012  gchar *message;
1013 
1014  set_http_status_from_entity (entity, response_data);
1015 
1016  message =
1017  gsad_message (credentials, "Error", __FUNCTION__, __LINE__,
1018  entity_attribute (entity, "status_text"), response_data);
1019 
1020  g_free (cmd);
1021  g_string_free (xml, TRUE);
1022  free_entity (entity);
1023  return message;
1024  }
1025 
1026  g_string_append_printf (xml, "</%s>", cmd);
1027 
1028  g_free (cmd);
1029  free_entity (entity);
1030 
1031  return envelope_gmp (connection, credentials, params,
1032  g_string_free (xml, FALSE), response_data);
1033 }

References cmd_response_data_set_status_code(), envelope_gmp(), gmp_arguments_free(), gmp_request(), gmp_success(), gsad_message(), and set_http_status_from_entity().

Referenced by get_many(), get_nvt_families_gmp(), and get_reports_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_entity()

char* get_entity ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
gmp_arguments_t *  arguments,
cmd_response_data_t *  response_data 
)

Get a single entity, envelope the result.

Parameters
[in]connectionConnection to manager
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[in]argumentsExtra arguments for GMP GET command.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 820 of file gsad_gmp.c.

823 {
824  GString *xml;
825  gchar *cmd;
826  entity_t entity;
827 
828  xml = g_string_new ("");
829 
830  if (str_equal (type, "info"))
831  {
832  cmd = g_strdup_printf ("get_%s", type);
833  }
834  else
835  {
836  cmd = g_strdup_printf ("get_%ss", type);
837  }
838 
839  g_string_append_printf (xml, "<get_%s>", type);
840 
841  if (gmp_request (connection, cmd, arguments))
842  {
843  g_free (cmd);
844 
845  gmp_arguments_free (arguments);
846 
847  cmd_response_data_set_status_code (response_data,
848  MHD_HTTP_INTERNAL_SERVER_ERROR);
849  return gsad_message (
850  credentials, "Internal error", __FUNCTION__, __LINE__,
851  "An internal error occurred while getting a resource list. "
852  "The current list of resources is not available. "
853  "Diagnostics: Failure to send command to manager daemon.",
854  response_data);
855  }
856 
857  gmp_arguments_free (arguments);
858 
859  if (read_entity_and_string_c (connection, &entity, &xml))
860  {
861  g_string_free (xml, TRUE);
862  g_free (cmd);
863 
864  cmd_response_data_set_status_code (response_data,
865  MHD_HTTP_INTERNAL_SERVER_ERROR);
866  return gsad_message (
867  credentials, "Internal error", __FUNCTION__, __LINE__,
868  "An internal error occurred while getting resources list. "
869  "The current list of resources is not available. "
870  "Diagnostics: Failure to receive response from manager daemon.",
871  response_data);
872  }
873 
874  if (gmp_success (entity) != 1)
875  {
876  gchar *message;
877 
878  set_http_status_from_entity (entity, response_data);
879 
880  message =
881  gsad_message (credentials, "Error", __FUNCTION__, __LINE__,
882  entity_attribute (entity, "status_text"), response_data);
883 
884  g_string_free (xml, TRUE);
885  g_free (cmd);
886  free_entity (entity);
887  return message;
888  }
889 
890  g_string_append_printf (xml, "</get_%s>", type);
891 
892  g_free (cmd);
893  free_entity (entity);
894 
895  return envelope_gmp (connection, credentials, params,
896  g_string_free (xml, FALSE), response_data);
897 }

References cmd_response_data_set_status_code(), envelope_gmp(), gmp_arguments_free(), gmp_request(), gmp_success(), gsad_message(), set_http_status_from_entity(), and str_equal().

Referenced by get_info_gmp(), and get_one().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_feeds_gmp()

char* get_feeds_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get descriptions of the feeds connected to the manager.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14065 of file gsad_gmp.c.

14067 {
14068  entity_t entity;
14069  char *text = NULL;
14070  gchar *response;
14071  time_t now;
14072  struct tm *tm;
14073  gchar current_timestamp[30];
14074 
14075  if (gvm_connection_sendf (connection, "<get_feeds/>") == -1)
14076  {
14077  cmd_response_data_set_status_code (response_data,
14078  MHD_HTTP_INTERNAL_SERVER_ERROR);
14079  return gsad_message (
14080  credentials, "Internal error", __FUNCTION__, __LINE__,
14081  "An internal error occurred while getting the feed list. "
14082  "The current list of feeds is not available. "
14083  "Diagnostics: Failure to send command to manager daemon.",
14084  response_data);
14085  }
14086 
14087  if (read_entity_and_text_c (connection, &entity, &text))
14088  {
14089  cmd_response_data_set_status_code (response_data,
14090  MHD_HTTP_INTERNAL_SERVER_ERROR);
14091  return gsad_message (
14092  credentials, "Internal error", __FUNCTION__, __LINE__,
14093  "An internal error occurred while getting the feed. "
14094  "The current list of feeds is not available. "
14095  "Diagnostics: Failure to receive response from manager daemon.",
14096  response_data);
14097  }
14098 
14099  time (&now);
14100  tm = gmtime (&now);
14101  if (tm == NULL
14102  || (strftime (current_timestamp, 29, "%Y-%m-%dT%H:%M:%S", tm) == 0))
14103  {
14104  current_timestamp[0] = '\0';
14105  }
14106 
14107  response = g_strdup_printf ("<get_feeds>"
14108  "%s"
14109  "<current_time_utc>%s</current_time_utc>"
14110  "</get_feeds>",
14111  text, current_timestamp);
14112 
14113  g_free (text);
14114 
14115  return envelope_gmp (connection, credentials, params, response,
14116  response_data);
14117 }

References cmd_response_data_set_status_code(), envelope_gmp(), and gsad_message().

Here is the call graph for this function:

◆ get_filter()

char * get_filter ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one filter, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14247 of file gsad_gmp.c.

14250 {
14251  gmp_arguments_t *arguments;
14252  arguments = gmp_arguments_new ();
14253 
14254  gmp_arguments_add (arguments, "alerts", "1");
14255 
14256  return get_one (connection, "filter", credentials, params, extra_xml,
14257  arguments, response_data);
14258 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_filter_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_filter_gmp()

char* get_filter_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one filter, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14271 of file gsad_gmp.c.

14273 {
14274  return get_filter (connection, credentials, params, NULL, response_data);
14275 }

References get_filter().

Here is the call graph for this function:

◆ get_filters_gmp()

char* get_filters_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all filters, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14288 of file gsad_gmp.c.

14290 {
14291  return get_many (connection, "filters", credentials, params, NULL,
14292  response_data);
14293 }

References get_many().

Here is the call graph for this function:

◆ get_group()

static char * get_group ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one group, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12334 of file gsad_gmp.c.

12337 {
12338  return get_one (connection, "group", credentials, params, extra_xml, NULL,
12339  response_data);
12340 }

References get_one().

Referenced by get_group_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_group_gmp()

char* get_group_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one group, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12353 of file gsad_gmp.c.

12355 {
12356  return get_group (connection, credentials, params, NULL, response_data);
12357 }

References get_group().

Here is the call graph for this function:

◆ get_groups_gmp()

char* get_groups_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all groups, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12370 of file gsad_gmp.c.

12372 {
12373  return get_many (connection, "groups", credentials, params, NULL,
12374  response_data);
12375 }

References get_many().

Here is the call graph for this function:

◆ get_hosts_from_params()

const char* get_hosts_from_params ( params_t *  params)

Get hosts from request params.

Parameters
[in]paramsRequest parameters.
Returns
The hosts

Definition at line 9323 of file gsad_gmp.c.

9324 {
9325  const char *hosts;
9326 
9327  if (params_valid (params, "hosts"))
9328  {
9329  hosts = params_value (params, "hosts");
9330  if (strcmp (hosts, "--") == 0)
9331  {
9332  if (params_valid (params, "hosts_manual"))
9333  hosts = params_value (params, "hosts_manual");
9334  else if (params_given (params, "hosts_manual")
9335  && strcmp (params_original_value (params, "hosts_manual"),
9336  ""))
9337  hosts = NULL;
9338  else
9339  hosts = "";
9340  }
9341  }
9342  else if (strcmp (params_original_value (params, "hosts"), ""))
9343  hosts = NULL;
9344  else
9345  hosts = "";
9346 
9347  return hosts;
9348 }

References params_given(), params_original_value(), params_valid(), and params_value().

Referenced by create_note_gmp(), create_override_gmp(), save_note_gmp(), and save_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_info_gmp()

char* get_info_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get info, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2968 of file gsad_gmp.c.

2970 {
2971  const gchar *info_type;
2972  const gchar *info_name;
2973  const gchar *info_id;
2974  const gchar *details;
2975 
2976  gmp_arguments_t *arguments;
2977 
2978  info_type = params_value (params, "info_type");
2979  info_name = params_value (params, "info_name");
2980  info_id = params_value (params, "info_id");
2981  details = params_value (params, "details");
2982 
2983  CHECK_VARIABLE_INVALID (info_type, "Get SecInfo")
2984 
2985  arguments = gmp_arguments_new ();
2986 
2987  gmp_arguments_add (arguments, "type", info_type);
2988  if (details)
2989  {
2990  gmp_arguments_add (arguments, "details", details);
2991  }
2992 
2993  if (info_id)
2994  {
2995  gmp_arguments_add (arguments, "info_id", info_id);
2996 
2997  return get_entity (connection, "info", credentials, params, arguments,
2998  response_data);
2999  }
3000  else if (info_name)
3001  {
3002  gmp_arguments_add (arguments, "name", info_name);
3003  }
3004 
3005  return get_many (connection, "info", credentials, params, arguments,
3006  response_data);
3007 }

References CHECK_VARIABLE_INVALID, get_entity(), get_many(), gmp_arguments_add(), gmp_arguments_new(), and params_value().

Here is the call graph for this function:

◆ get_many()

static char* get_many ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
gmp_arguments_t *  arguments,
cmd_response_data_t *  response_data 
)
static

Get all of a particular type of resource, envelope the result.

Parameters
[in]connectionConnection to manager
[in]typeResource type in plural form.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]argumentsExtra arguments for GMP GET command.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1048 of file gsad_gmp.c.

1051 {
1052  const gchar *filter_id, *filter;
1053  const gchar *details;
1054 
1055  filter_id = params_value (params, "filter_id");
1056  filter = params_value (params, "filter");
1057  details = params_value (params, "details");
1058 
1059  if (arguments == NULL)
1060  {
1061  arguments = gmp_arguments_new ();
1062  }
1063 
1064  if (details && !str_equal (details, ""))
1065  {
1066  gmp_arguments_add (arguments, "details", details);
1067  }
1068 
1069  if (!filter_id && !filter)
1070  {
1071  filter_id = FILT_ID_USER_SETTING;
1072  }
1073 
1074  if (filter_id)
1075  {
1076  gmp_arguments_add (arguments, "filt_id", filter_id);
1077  }
1078 
1079  if (filter)
1080  {
1081  gmp_arguments_add (arguments, "filter", filter);
1082  }
1083 
1084  return get_entities (connection, type, credentials, params, arguments,
1085  response_data);
1086 }

References FILT_ID_USER_SETTING, get_entities(), gmp_arguments_add(), gmp_arguments_new(), params_value(), and str_equal().

Referenced by get_agents_gmp(), get_alerts_gmp(), get_assets_gmp(), get_configs_gmp(), get_credentials_gmp(), get_filters_gmp(), get_groups_gmp(), get_info_gmp(), get_notes_gmp(), get_overrides_gmp(), get_permissions_gmp(), get_port_lists_gmp(), get_report_formats_gmp(), get_results_gmp(), get_roles_gmp(), get_scanners_gmp(), get_schedules_gmp(), get_tags_gmp(), get_targets_gmp(), get_tasks_gmp(), get_tickets_gmp(), get_tls_certificates_gmp(), get_users_gmp(), and get_vulns_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_note()

static char * get_note ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get a note, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9259 of file gsad_gmp.c.

9262 {
9263  gmp_arguments_t *arguments;
9264  arguments = gmp_arguments_new ();
9265 
9266  gmp_arguments_add (arguments, "result", "1");
9267 
9268  return get_one (connection, "note", credentials, params, extra_xml, arguments,
9269  response_data);
9270 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_note_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_note_gmp()

char* get_note_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a note, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9283 of file gsad_gmp.c.

9285 {
9286  return get_note (connection, credentials, params, NULL, response_data);
9287 }

References get_note().

Here is the call graph for this function:

◆ get_notes_gmp()

char* get_notes_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all notes, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9240 of file gsad_gmp.c.

9242 {
9243  return get_many (connection, "notes", credentials, params, NULL,
9244  response_data);
9245 }

References get_many().

Here is the call graph for this function:

◆ get_nvt_families_gmp()

char* get_nvt_families_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all nvt_families, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7911 of file gsad_gmp.c.

7913 {
7914  return get_entities (connection, "nvt_families", credentials, params, NULL,
7915  response_data);
7916 }

References get_entities().

Here is the call graph for this function:

◆ get_one()

char* get_one ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
gmp_arguments_t *  arguments,
cmd_response_data_t *  response_data 
)

Get one resource, envelope the result.

Parameters
[in]connectionConnection to manager
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[in]argumentsExtra arguments for GMP GET command.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 913 of file gsad_gmp.c.

916 {
917  gchar *id_name;
918  const gchar *id;
919  const gchar *details;
920 
921  id_name = g_strdup_printf ("%s_id", type);
922  id = params_value (params, id_name);
923 
924  CHECK_VARIABLE_INVALID (id, "Get")
925 
926  details = params_value (params, "details");
927  if (!details)
928  {
929  details = "1";
930  }
931 
932  if (arguments == NULL)
933  {
934  arguments = gmp_arguments_new ();
935  }
936 
937  gmp_arguments_add (arguments, id_name, id);
938 
939  if (details && !str_equal (details, ""))
940  {
941  gmp_arguments_add (arguments, "details", details);
942  }
943 
944  g_free (id_name);
945 
946  return get_entity (connection, type, credentials, params, arguments,
947  response_data);
948 }

References CHECK_VARIABLE_INVALID, get_entity(), gmp_arguments_add(), gmp_arguments_new(), params_value(), and str_equal().

Referenced by get_agent(), get_alert(), get_asset(), get_config_gmp(), get_credential(), get_filter(), get_group(), get_note(), get_override(), get_permission(), get_port_list(), get_report_format(), get_result_gmp(), get_role(), get_scanner(), get_schedule(), get_tag(), get_target(), get_task_gmp(), get_ticket_gmp(), get_tls_certificate_gmp(), and get_user().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_override()

static char * get_override ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get a override, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9662 of file gsad_gmp.c.

9665 {
9666  gmp_arguments_t *arguments;
9667  arguments = gmp_arguments_new ();
9668 
9669  gmp_arguments_add (arguments, "result", "1");
9670 
9671  return get_one (connection, "override", credentials, params, extra_xml,
9672  arguments, response_data);
9673 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_override_gmp()

char* get_override_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get an override, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9686 of file gsad_gmp.c.

9688 {
9689  return get_override (connection, credentials, params, NULL, response_data);
9690 }

References get_override().

Here is the call graph for this function:

◆ get_overrides_gmp()

char* get_overrides_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all overrides, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9643 of file gsad_gmp.c.

9645 {
9646  return get_many (connection, "overrides", credentials, params, NULL,
9647  response_data);
9648 }

References get_many().

Here is the call graph for this function:

◆ get_permission()

char * get_permission ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one permission, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12628 of file gsad_gmp.c.

12631 {
12632  gmp_arguments_t *arguments;
12633  arguments = gmp_arguments_new ();
12634 
12635  gmp_arguments_add (arguments, "alerts", "1");
12636 
12637  return get_one (connection, "permission", credentials, params, extra_xml,
12638  arguments, response_data);
12639 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_permission_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_permission_gmp()

char* get_permission_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one permission, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12652 of file gsad_gmp.c.

12654 {
12655  return get_permission (connection, credentials, params, NULL, response_data);
12656 }

References get_permission().

Here is the call graph for this function:

◆ get_permissions_gmp()

char* get_permissions_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all permissions, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12669 of file gsad_gmp.c.

12671 {
12672  return get_many (connection, "permissions", credentials, params, NULL,
12673  response_data);
12674 }

References get_many().

Here is the call graph for this function:

◆ get_port_from_params()

const char* get_port_from_params ( params_t *  params)

Get a port from request params.

Parameters
[in]paramsRequest parameters.
Returns
The port

Definition at line 9297 of file gsad_gmp.c.

9298 {
9299  const char *port;
9300 
9301  port = params_value (params, "port");
9302 
9303  if (port == NULL)
9304  return "";
9305 
9306  if (strcmp (port, "--") == 0)
9307  port = params_value (params, "port_manual");
9308 
9309  if (port == NULL)
9310  port = "";
9311 
9312  return port;
9313 }

References params_value().

Referenced by create_note_gmp(), create_override_gmp(), save_note_gmp(), and save_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_port_list()

static char * get_port_list ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one port_list, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]commandsExtra commands to run before the others.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13545 of file gsad_gmp.c.

13548 {
13549  gmp_arguments_t *arguments;
13550  arguments = gmp_arguments_new ();
13551 
13552  gmp_arguments_add (arguments, "targets", "1");
13553  gmp_arguments_add (arguments, "details", "1");
13554 
13555  return get_one (connection, "port_list", credentials, params, extra_xml,
13556  arguments, response_data);
13557 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_port_list_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_port_list_gmp()

char* get_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one port_list, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13570 of file gsad_gmp.c.

13572 {
13573  return get_port_list (connection, credentials, params, NULL, response_data);
13574 }

References get_port_list().

Here is the call graph for this function:

◆ get_port_lists_gmp()

char* get_port_lists_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all port_lists, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13587 of file gsad_gmp.c.

13589 {
13590  return get_many (connection, "port_lists", credentials, params, NULL,
13591  response_data);
13592 }

References get_many().

Here is the call graph for this function:

◆ get_report()

char* get_report ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)

Get a report and return the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]commandsExtra commands to run before the others.
[in]extra_xmlExtra XML to insert inside page element.
[out]errorSet to 1 if error, else 0.
[out]response_dataExtra data return for the HTTP response.
Returns
Report.

Definition at line 8469 of file gsad_gmp.c.

8472 {
8473  GString *xml;
8474  entity_t entity;
8475  entity_t report_entity;
8476  const char *report_id, *delta_report_id;
8477  const char *format_id;
8478  const char *filter;
8479  const char *filter_id;
8480  gboolean lean, ignore_pagination, details;
8481  int ret;
8482  gchar *fname_format;
8483  const gchar *extension, *requested_content_type;
8484 
8485  details = params_value_bool (params, "details");
8486  ignore_pagination = params_value_bool (params, "ignore_pagination");
8487  lean = params_value_bool (params, "lean");
8488 
8489  report_id = params_value (params, "report_id");
8490 
8491  CHECK_VARIABLE_INVALID (report_id, "Get Report");
8492 
8493  delta_report_id = params_value (params, "delta_report_id");
8494  format_id = params_value (params, "report_format_id");
8495 
8496  filter = params_value (params, "filter");
8497  filter_id = params_value (params, "filter_id");
8498 
8499  details = params_value_bool (params, "details");
8500 
8501  if (filter == NULL || filter_id)
8502  filter = "";
8503 
8504  ret = gvm_connection_sendf_xml (
8505  connection,
8506  "<get_reports"
8507  " details=\"%d\""
8508  " ignore_pagination=\"%d\""
8509  " lean=\"%d\""
8510  " filter=\"%s\""
8511  " filt_id=\"%s\""
8512  " report_id=\"%s\""
8513  " delta_report_id=\"%s\""
8514  " format_id=\"%s\"/>",
8515  details, ignore_pagination, lean, filter,
8516  filter_id ? filter_id : FILT_ID_NONE, report_id,
8517  delta_report_id ? delta_report_id : "0", format_id ? format_id : "");
8518 
8519  if (ret == -1)
8520  {
8521  cmd_response_data_set_status_code (response_data,
8522  MHD_HTTP_INTERNAL_SERVER_ERROR);
8523  return gsad_message (
8524  credentials, "Internal error", __FUNCTION__, __LINE__,
8525  "An internal error occurred while getting a report. "
8526  "The report could not be delivered. "
8527  "Diagnostics: Failure to send command to manager daemon.",
8528  response_data);
8529  }
8530 
8531  if (format_id)
8532  {
8533  if ((str_equal (format_id, XML_REPORT_FORMAT_ID))
8534  || str_equal (format_id, ANONXML_REPORT_FORMAT_ID))
8535  {
8536  /* Manager sends XML report as plain XML. */
8537 
8538  if (read_entity_c (connection, &entity))
8539  {
8541  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8542  return gsad_message (
8543  credentials, "Internal error", __FUNCTION__, __LINE__,
8544  "An internal error occurred while getting a report. "
8545  "The report could not be delivered. "
8546  "Diagnostics: Failure to receive response from manager daemon.",
8547  response_data);
8548  }
8549  entity_t report = entity_child (entity, "report");
8550  if (report == NULL)
8551  {
8552  free_entity (entity);
8554  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8555  return gsad_message (
8556  credentials, "Internal error", __FUNCTION__, __LINE__,
8557  "An internal error occurred while getting a report. "
8558  "The report could not be delivered. "
8559  "Diagnostics: Response from manager daemon did not contain a "
8560  "report.",
8561  response_data);
8562  }
8563  extension = entity_attribute (report, "extension");
8564  requested_content_type = entity_attribute (report, "content_type");
8565  if (extension && requested_content_type)
8566  {
8567  gchar *file_name;
8568  ret = setting_get_value (connection,
8569  "e1a2ae0b-736e-4484-b029-330c9e15b900",
8570  &fname_format, response_data);
8571  if (ret)
8572  {
8573  switch (ret)
8574  {
8575  case 1:
8577  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8578  return gsad_message (
8579  credentials, "Internal error", __FUNCTION__, __LINE__,
8580  "An internal error occurred while getting a setting. "
8581  "The setting could not be delivered. "
8582  "Diagnostics: Failure to send command to manager "
8583  "daemon.",
8584  response_data);
8585  case 2:
8587  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8588  return gsad_message (
8589  credentials, "Internal error", __FUNCTION__, __LINE__,
8590  "An internal error occurred while getting a setting. "
8591  "The setting could not be delivered. "
8592  "Diagnostics: Failure to receive response from manager "
8593  "daemon.",
8594  response_data);
8595  default:
8597  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8598  return gsad_message (
8599  credentials, "Internal error", __FUNCTION__, __LINE__,
8600  "An internal error occurred while getting a setting. "
8601  "The setting could not be delivered. "
8602  "Diagnostics: Internal error.",
8603  response_data);
8604  }
8605  }
8606 
8607  if (fname_format == NULL)
8608  {
8609  g_warning ("%s : File name format setting not found.",
8610  __FUNCTION__);
8611  fname_format = "%T-%U";
8612  }
8613 
8614  file_name = format_file_name (fname_format, credentials, "report",
8615  report_id, report);
8616  if (file_name == NULL)
8617  file_name = g_strdup_printf ("%s-%s", "report", report_id);
8618 
8620  response_data, g_strdup (requested_content_type));
8622  response_data,
8623  g_strdup_printf ("attachment; filename=\"%s.%s\"", file_name,
8624  extension));
8625 
8626  g_free (file_name);
8627  }
8628  xml = g_string_new ("");
8629  print_entity_to_string (report, xml);
8630  free_entity (entity);
8631  return g_string_free (xml, FALSE);
8632  }
8633  else
8634  {
8635  /* "nbe", "pdf", "dvi", "html", "html-pdf"... */
8636 
8637  entity = NULL;
8638  if (read_entity_c (connection, &entity))
8639  {
8641  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8642  return gsad_message (
8643  credentials, "Internal error", __FUNCTION__, __LINE__,
8644  "An internal error occurred while getting a report. "
8645  "The report could not be delivered. "
8646  "Diagnostics: Failure to receive response from manager daemon.",
8647  response_data);
8648  }
8649 
8650  report_entity = entity_child (entity, "report");
8651  if (report_entity != NULL)
8652  {
8653  char *report_encoded;
8654  gsize report_len;
8655  gchar *report_decoded;
8656  extension = entity_attribute (report_entity, "extension");
8657  requested_content_type =
8658  entity_attribute (report_entity, "content_type");
8659  report_encoded = entity_text (report_entity);
8660  report_decoded =
8661  (gchar *) g_base64_decode (report_encoded, &report_len);
8662  /* g_base64_decode can return NULL (Glib 2.12.4-2), at least
8663  * when *report_len is zero. */
8664  if (report_decoded == NULL)
8665  {
8666  report_decoded = g_strdup ("");
8667  report_len = 0;
8668  }
8669  if (extension && requested_content_type)
8670  {
8671  gchar *file_name;
8672  const char *id;
8673  if (report_id)
8674  id = report_id;
8675  else
8676  id = "ERROR";
8677 
8678  ret = setting_get_value (
8679  connection, "e1a2ae0b-736e-4484-b029-330c9e15b900",
8680  &fname_format, response_data);
8681  if (ret)
8682  {
8683  switch (ret)
8684  {
8685  case 1:
8687  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8688  return gsad_message (
8689  credentials, "Internal error", __FUNCTION__,
8690  __LINE__,
8691  "An internal error occurred while getting a "
8692  "setting. "
8693  "The setting could not be delivered. "
8694  "Diagnostics: Failure to send command to manager "
8695  "daemon.",
8696  response_data);
8697  case 2:
8699  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8700  return gsad_message (
8701  credentials, "Internal error", __FUNCTION__,
8702  __LINE__,
8703  "An internal error occurred while getting a "
8704  "setting. "
8705  "The setting could not be delivered. "
8706  "Diagnostics: Failure to receive response from "
8707  "manager daemon.",
8708  response_data);
8709  default:
8711  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8712  return gsad_message (
8713  credentials, "Internal error", __FUNCTION__,
8714  __LINE__,
8715  "An internal error occurred while getting a "
8716  "setting. "
8717  "The setting could not be delivered. "
8718  "Diagnostics: Internal error.",
8719  response_data);
8720  }
8721  }
8722 
8723  if (fname_format == NULL)
8724  {
8725  g_warning ("%s : File name format setting not found.",
8726  __FUNCTION__);
8727  fname_format = "%T-%U";
8728  }
8729 
8730  file_name = format_file_name (fname_format, credentials,
8731  "report", id, report_entity);
8732  if (file_name == NULL)
8733  file_name = g_strdup_printf ("%s-%s", "report", id);
8734 
8736  response_data, g_strdup (requested_content_type));
8738  response_data,
8739  g_strdup_printf ("attachment; filename=\"%s.%s\"",
8740  file_name, extension));
8741 
8742  g_free (file_name);
8743  }
8744 
8745  free_entity (entity);
8746 
8747  cmd_response_data_set_content_length (response_data, report_len);
8748  return report_decoded;
8749  }
8750  else
8751  {
8752  free_entity (entity);
8754  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8755  return gsad_message (
8756  credentials, "Internal error", __FUNCTION__, __LINE__,
8757  "An internal error occurred while getting a report. "
8758  "The report could not be delivered. "
8759  "Diagnostics: Failure to receive report from manager daemon.",
8760  response_data);
8761  }
8762  }
8763  }
8764  else
8765  {
8766  /* Format is NULL, send enveloped XML. */
8767 
8768  xml = g_string_new ("<get_report>");
8769 
8770  if (extra_xml)
8771  g_string_append (xml, extra_xml);
8772 
8773  if (delta_report_id)
8774  {
8775  g_string_append_printf (xml, "<delta>%s</delta>", delta_report_id);
8776 
8777  entity = NULL;
8778  if (read_entity_and_string_c (connection, &entity, &xml))
8779  {
8780  cmd_response_data_set_status_code (response_data,
8781  MHD_HTTP_INTERNAL_SERVER_ERROR);
8782  return gsad_message (
8783  credentials, "Internal error", __FUNCTION__, __LINE__,
8784  "An internal error occurred while getting a report. "
8785  "The report could not be delivered. "
8786  "Diagnostics: Failure to receive response from manager daemon.",
8787  response_data);
8788  }
8789 
8790  if (gmp_success (entity) != 1)
8791  {
8792  gchar *message;
8793 
8794  set_http_status_from_entity (entity, response_data);
8795 
8796  message = gsad_message (credentials, "Error", __FUNCTION__, __LINE__,
8797  entity_attribute (entity, "status_text"),
8798  response_data);
8799 
8800  g_string_free (xml, TRUE);
8801  free_entity (entity);
8802  return message;
8803  }
8804 
8805  report_entity = entity_child (entity, "report");
8806  if (report_entity)
8807  report_entity = entity_child (report_entity, "report");
8808  if (report_entity)
8809  {
8810  const char *id;
8811  entity_t task_entity, name;
8812 
8813  id = NULL;
8814  task_entity = entity_child (report_entity, "task");
8815  if (task_entity)
8816  {
8817  id = entity_attribute (task_entity, "id");
8818  name = entity_child (task_entity, "name");
8819  }
8820  else
8821  name = NULL;
8822 
8823  if (delta_report_id && id && name)
8824  g_string_append_printf (xml,
8825  "<task id=\"%s\"><name>%s</name></task>",
8826  id, entity_text (name));
8827 
8828  free_entity (entity);
8829  }
8830 
8831  g_string_append (xml, "</get_report>");
8832 
8833  return envelope_gmp (connection, credentials, params,
8834  g_string_free (xml, FALSE), response_data);
8835  }
8836 
8837  if (read_string_c (connection, &xml))
8838  {
8839  cmd_response_data_set_status_code (response_data,
8840  MHD_HTTP_INTERNAL_SERVER_ERROR);
8841  return gsad_message (
8842  credentials, "Internal error", __FUNCTION__, __LINE__,
8843  "An internal error occurred while getting a report. "
8844  "The report could not be delivered. "
8845  "Diagnostics: Failure to receive response from manager daemon.",
8846  response_data);
8847  }
8848 
8849  g_string_append (xml, "</get_report>");
8850 
8851  return envelope_gmp (connection, credentials, params,
8852  g_string_free (xml, FALSE), response_data);
8853  }
8854 }

References ANONXML_REPORT_FORMAT_ID, CHECK_VARIABLE_INVALID, cmd_response_data_set_content_disposition(), cmd_response_data_set_content_length(), cmd_response_data_set_content_type_string(), cmd_response_data_set_status_code(), envelope_gmp(), FILT_ID_NONE, format_file_name(), gmp_success(), gsad_message(), params_value(), params_value_bool(), set_http_status_from_entity(), setting_get_value(), str_equal(), and XML_REPORT_FORMAT_ID.

Referenced by get_report_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_report_format()

static char * get_report_format ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one report format, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10853 of file gsad_gmp.c.

10856 {
10857  gmp_arguments_t *arguments;
10858  arguments = gmp_arguments_new ();
10859 
10860  gmp_arguments_add (arguments, "alerts", "1");
10861  gmp_arguments_add (arguments, "params", "1");
10862 
10863  return get_one (connection, "report_format", credentials, params, extra_xml,
10864  arguments, response_data);
10865 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_report_format_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_report_format_gmp()

char* get_report_format_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one report format, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10878 of file gsad_gmp.c.

10880 {
10881  return get_report_format (connection, credentials, params, NULL,
10882  response_data);
10883 }

References get_report_format().

Here is the call graph for this function:

◆ get_report_formats_gmp()

char* get_report_formats_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all Report Formats, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10896 of file gsad_gmp.c.

10899 {
10900  return get_many (connection, "report_formats", credentials, params, NULL,
10901  response_data);
10902 }

References get_many().

Here is the call graph for this function:

◆ get_report_gmp()

char* get_report_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a report and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Report.

Definition at line 8867 of file gsad_gmp.c.

8869 {
8870  return get_report (connection, credentials, params, NULL, response_data);
8871 }

References get_report().

Here is the call graph for this function:

◆ get_reports_gmp()

char* get_reports_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all reports, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 8990 of file gsad_gmp.c.

8992 {
8993  const gchar *filter, *filter_id, *details;
8994  gmp_arguments_t *arguments;
8995 
8996  filter = params_value (params, "filter");
8997  filter_id = params_value (params, "filter_id");
8998  details = params_value (params, "details");
8999 
9000  arguments = gmp_arguments_new ();
9001 
9002  if (!filter && !filter_id)
9003  {
9004  filter_id = FILT_ID_USER_SETTING;
9005  }
9006 
9007  if (filter)
9008  {
9009  gmp_arguments_add (arguments, "report_filter", filter);
9010  }
9011 
9012  if (!filter_id && !filter)
9013  {
9014  filter_id = FILT_ID_USER_SETTING;
9015  }
9016 
9017  if (filter_id)
9018  {
9019  gmp_arguments_add (arguments, "report_filt_id", filter_id);
9020  }
9021 
9022  if (details && !str_equal (details, ""))
9023  {
9024  gmp_arguments_add (arguments, "details", details);
9025  }
9026 
9027  params_remove (params, "filter");
9028  params_remove (params, "filter_id");
9029 
9030  return get_entities (connection, "reports", credentials, params, arguments,
9031  response_data);
9032 }

References FILT_ID_USER_SETTING, get_entities(), gmp_arguments_add(), gmp_arguments_new(), params_remove(), params_value(), and str_equal().

Here is the call graph for this function:

◆ get_result_gmp()

char* get_result_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one result, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9222 of file gsad_gmp.c.

9224 {
9225  return get_one (connection, "result", credentials, params, NULL, NULL,
9226  response_data);
9227 }

References get_one().

Here is the call graph for this function:

◆ get_result_id_from_params()

const char* get_result_id_from_params ( params_t *  params)

Get result_id from request params.

Parameters
[in]paramsRequest parameters.
Returns
The result_id

Definition at line 9401 of file gsad_gmp.c.

9402 {
9403  const char *result_id;
9404 
9405  result_id = params_value (params, "result_id");
9406 
9407  if (result_id && (strcmp (result_id, "0") == 0))
9408  {
9409  result_id = params_value (params, "result_uuid");
9410  }
9411 
9412  return result_id;
9413 }

References params_value().

Referenced by create_note_gmp(), create_override_gmp(), save_note_gmp(), and save_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_results_gmp()

char* get_results_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all results, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9190 of file gsad_gmp.c.

9192 {
9193  const gchar *_and_report_id;
9194  gmp_arguments_t *arguments = NULL;
9195 
9196  _and_report_id = params_value (params, "_and_report_id");
9197 
9198  if (params_given (params, "_and_report_id"))
9199  {
9200  CHECK_VARIABLE_INVALID (_and_report_id, "Get results");
9201 
9202  arguments = gmp_arguments_new ();
9203 
9204  gmp_arguments_add (arguments, "_and_report_id", _and_report_id);
9205  }
9206 
9207  return get_many (connection, "results", credentials, params, arguments,
9208  response_data);
9209 }

References CHECK_VARIABLE_INVALID, get_many(), gmp_arguments_add(), gmp_arguments_new(), params_given(), and params_value().

Here is the call graph for this function:

◆ get_role()

static char * get_role ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one role, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13891 of file gsad_gmp.c.

13894 {
13895  return get_one (connection, "role", credentials, params, extra_xml, NULL,
13896  response_data);
13897 }

References get_one().

Referenced by get_role_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_role_gmp()

char* get_role_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one role, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13910 of file gsad_gmp.c.

13912 {
13913  return get_role (connection, credentials, params, NULL, response_data);
13914 }

References get_role().

Here is the call graph for this function:

◆ get_roles_gmp()

char* get_roles_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all roles, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13927 of file gsad_gmp.c.

13929 {
13930  return get_many (connection, "roles", credentials, params, NULL,
13931  response_data);
13932 }

References get_many().

Here is the call graph for this function:

◆ get_scanner()

static char * get_scanner ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one scanner, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9976 of file gsad_gmp.c.

9979 {
9980  return get_one (connection, "scanner", credentials, params, extra_xml, NULL,
9981  response_data);
9982 }

References get_one().

Referenced by get_scanner_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_scanner_gmp()

char* get_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one scanner, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9995 of file gsad_gmp.c.

9997 {
9998  return get_scanner (connection, credentials, params, NULL, response_data);
9999 }

References get_scanner().

Here is the call graph for this function:

◆ get_scanners_gmp()

char* get_scanners_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all scanners, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9957 of file gsad_gmp.c.

9959 {
9960  return get_many (connection, "scanners", credentials, params, NULL,
9961  response_data);
9962 }

References get_many().

Here is the call graph for this function:

◆ get_schedule()

static char * get_schedule ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one schedule, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10387 of file gsad_gmp.c.

10390 {
10391  gmp_arguments_t *arguments;
10392  arguments = gmp_arguments_new ();
10393 
10394  gmp_arguments_add (arguments, "tasks", "1");
10395 
10396  return get_one (connection, "schedule", credentials, params, extra_xml,
10397  arguments, response_data);
10398 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_schedule_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_schedule_gmp()

char* get_schedule_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one schedule, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10411 of file gsad_gmp.c.

10413 {
10414  return get_schedule (connection, credentials, params, NULL, response_data);
10415 }

References get_schedule().

Here is the call graph for this function:

◆ get_schedules_gmp()

char* get_schedules_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all schedules, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10428 of file gsad_gmp.c.

10430 {
10431  return get_many (connection, "schedules", credentials, params, NULL,
10432  response_data);
10433 }

References get_many().

Here is the call graph for this function:

◆ get_setting_gmp()

char* get_setting_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Definition at line 15664 of file gsad_gmp.c.

15666 {
15667  const gchar *setting_id = params_value (params, "setting_id");
15668  CHECK_VARIABLE_INVALID (setting_id, "Get Setting");
15669  GString *xml = g_string_new ("<get_settings>");
15670 
15671  if (gvm_connection_sendf_xml (connection,
15672  "<get_settings"
15673  " setting_id=\"%s\"/>",
15674  setting_id))
15675  {
15676  g_string_free (xml, TRUE);
15677  cmd_response_data_set_status_code (response_data,
15678  MHD_HTTP_INTERNAL_SERVER_ERROR);
15679  return gsad_message (credentials, "Internal error", __FUNCTION__,
15680  __LINE__,
15681  "An internal error occurred while getting the "
15682  "dashboard settings"
15683  "Diagnostics: Failure to send command to manager "
15684  "daemon.",
15685  response_data);
15686  }
15687 
15688  if (read_string_c (connection, &xml))
15689  {
15690  g_string_free (xml, TRUE);
15691  cmd_response_data_set_status_code (response_data,
15692  MHD_HTTP_INTERNAL_SERVER_ERROR);
15693  return gsad_message (credentials, "Internal error", __FUNCTION__,
15694  __LINE__,
15695  "An internal error occurred while getting the "
15696  "dashboard settings"
15697  "Diagnostics: Failure to receive response from "
15698  "manager daemon.",
15699  response_data);
15700  }
15701 
15702  g_string_append (xml, "</get_settings>");
15703  return envelope_gmp (connection, credentials, params,
15704  g_string_free (xml, FALSE), response_data);
15705 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ get_settings_gmp()

char* get_settings_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all user defined settings.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15504 of file gsad_gmp.c.

15506 {
15507  GString *xml;
15508  gchar *command;
15509  const gchar *filter;
15510 
15511  xml = g_string_new ("<get_settings>");
15512 
15513  /* Get the settings. */
15514 
15515  filter = params_value (params, "filter");
15516  if (filter)
15517  {
15518  command = g_markup_printf_escaped ("<get_settings"
15519  " filter=\"%s\""
15520  " sort_field=\"name\""
15521  " sort_order=\"ascending\"/>",
15522  filter);
15523  }
15524  else
15525  {
15526  command = g_strdup ("<get_settings"
15527  " sort_field=\"name\""
15528  " sort_order=\"ascending\"/>");
15529  }
15530 
15531  if (gvm_connection_sendf (connection, command))
15532  {
15533  g_free (command);
15534 
15535  g_string_free (xml, TRUE);
15536  cmd_response_data_set_status_code (response_data,
15537  MHD_HTTP_INTERNAL_SERVER_ERROR);
15538  return gsad_message (
15539  credentials, "Internal error", __FUNCTION__, __LINE__,
15540  "An internal error occurred while getting the settings. "
15541  "The current list of settings is not available. "
15542  "Diagnostics: Failure to send command to manager daemon.",
15543  response_data);
15544  }
15545 
15546  if (read_string_c (connection, &xml))
15547  {
15548  g_free (command);
15549  g_string_free (xml, TRUE);
15550  cmd_response_data_set_status_code (response_data,
15551  MHD_HTTP_INTERNAL_SERVER_ERROR);
15552  return gsad_message (
15553  credentials, "Internal error", __FUNCTION__, __LINE__,
15554  "An internal error occurred while getting the settings. "
15555  "The current list of settings is not available. "
15556  "Diagnostics: Failure to receive response from manager daemon.",
15557  response_data);
15558  }
15559 
15560  g_free (command);
15561  g_string_append (xml, "</get_settings>");
15562  return envelope_gmp (connection, credentials, params,
15563  g_string_free (xml, FALSE), response_data);
15564 }

References cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ get_severity_from_params()

const char* get_severity_from_params ( params_t *  params)

Get severity from request params.

Parameters
[in]paramsRequest parameters.
Returns
The severity

Definition at line 9378 of file gsad_gmp.c.

9379 {
9380  const char *severity;
9381 
9382  if (params_valid (params, "severity"))
9383  severity = params_value (params, "severity");
9384  else if (params_given (params, "severity")
9385  && strcmp (params_original_value (params, "severity"), ""))
9386  severity = NULL;
9387  else
9388  severity = "";
9389 
9390  return severity;
9391 }

References params_given(), params_original_value(), params_valid(), and params_value().

Referenced by create_note_gmp(), create_override_gmp(), save_note_gmp(), and save_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_system_report_gmp()

char* get_system_report_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
const char *  url,
params_t *  params,
cmd_response_data_t *  response_data 
)

Return system report image.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]urlURL of report image.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Image, or NULL.

Definition at line 10736 of file gsad_gmp.c.

10739 {
10740  entity_t entity;
10741  entity_t report_entity;
10742  char name[501];
10743  gchar *gmp_command;
10744  const char *slave_id, *duration;
10745 
10746  const char *start_time;
10747  const char *end_time;
10748 
10749  if (url == NULL)
10750  return NULL;
10751 
10752  /* fan/report.png */
10753  if (sscanf (url, "%500[^ /]./report.png", name) == 1)
10754  {
10755  slave_id = params_value (params, "slave_id");
10756 
10757  duration = params_value (params, "duration");
10758 
10759  if (duration && strcmp (duration, ""))
10760  {
10761  gmp_command =
10762  g_markup_printf_escaped ("<get_system_reports"
10763  " name=\"%s\""
10764  " duration=\"%s\""
10765  " slave_id=\"%s\"/>",
10766  name, duration, slave_id ? slave_id : "0");
10767  }
10768  else
10769  {
10770  start_time = params_value (params, "start_time");
10771  end_time = params_value (params, "end_time");
10772 
10773  CHECK_VARIABLE_INVALID (start_time, "Get System Report")
10774  CHECK_VARIABLE_INVALID (end_time, "Get System Report")
10775 
10776  gmp_command = g_markup_printf_escaped ("<get_system_reports"
10777  " name=\"%s\""
10778  " start_time=\"%s\""
10779  " end_time=\"%s\""
10780  " slave_id=\"%s\"/>",
10781  name, start_time, end_time,
10782  slave_id ? slave_id : "0");
10783  }
10784 
10785  if (gvm_connection_sendf (connection, "%s", gmp_command) == -1)
10786  {
10787  g_free (gmp_command);
10788  return NULL;
10789  }
10790  g_free (gmp_command);
10791 
10792  entity = NULL;
10793  if (read_entity_c (connection, &entity))
10794  {
10795  return NULL;
10796  }
10797 
10798  report_entity = entity_child (entity, "system_report");
10799  if (report_entity == NULL)
10800  {
10801  free_entity (entity);
10802  return NULL;
10803  }
10804 
10805  report_entity = entity_child (report_entity, "report");
10806  if (report_entity == NULL)
10807  {
10808  free_entity (entity);
10809  return NULL;
10810  }
10811  else
10812  {
10813  char *content_64 = entity_text (report_entity);
10814  char *content = NULL;
10815  gsize content_length = 0;
10816 
10817  if (content_64 && strlen (content_64))
10818  {
10819  content = (char *) g_base64_decode (content_64, &content_length);
10820 
10821 #if 1
10822  cmd_response_data_set_content_type (response_data,
10824  //*content_disposition = g_strdup_printf ("attachment;
10825  // filename=\"xxx.png\"");
10826 #else
10827  g_free (content);
10828  content = g_strdup ("helo");
10829 #endif
10830  }
10831 
10832  cmd_response_data_set_content_length (response_data, content_length);
10833  free_entity (entity);
10834  return content;
10835  }
10836  }
10837 
10838  return NULL;
10839 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_content_length(), cmd_response_data_set_content_type(), GSAD_CONTENT_TYPE_IMAGE_PNG, and params_value().

Referenced by handle_system_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_system_reports_gmp()

char* get_system_reports_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all system reports, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10545 of file gsad_gmp.c.

10548 {
10549  GString *xml;
10550  time_t now, duration, duration_start;
10551  struct tm start_time, end_time;
10552 
10553  const char *slave_id, *given_duration, *range_type;
10554  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
10555  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
10556 
10557  slave_id = params_value (params, "slave_id");
10558 
10559  now = time (NULL);
10560 
10561  given_duration = params_value (params, "duration");
10562  range_type = params_value (params, "range_type");
10563  if (!range_type)
10564  range_type = "duration";
10565 
10566  duration = given_duration ? atoi (given_duration) : 86400;
10567  duration_start = now - duration;
10568 
10569  xml = g_string_new ("<get_system_reports>");
10570 
10571  g_string_append_printf (xml, "<slave id=\"%s\"/>", slave_id ? slave_id : "0");
10572 
10573  if (strcmp (range_type, "duration") == 0)
10574  {
10575  struct tm *time_broken;
10576  time_broken = localtime (&now);
10577  end_time.tm_year = time_broken->tm_year;
10578  end_time.tm_mon = time_broken->tm_mon;
10579  end_time.tm_mday = time_broken->tm_mday;
10580  end_time.tm_hour = time_broken->tm_hour;
10581  end_time.tm_min = time_broken->tm_min;
10582 
10583  time_broken = localtime (&duration_start);
10584  start_time.tm_year = time_broken->tm_year;
10585  start_time.tm_mon = time_broken->tm_mon;
10586  start_time.tm_mday = time_broken->tm_mday;
10587  start_time.tm_hour = time_broken->tm_hour;
10588  start_time.tm_min = time_broken->tm_min;
10589 
10590  g_string_append_printf (xml, "<duration>%ld</duration>", duration);
10591  }
10592  else
10593  {
10594  struct tm *time_broken;
10595  time_broken = localtime (&now);
10596 
10597  start_year = params_value (params, "start_year");
10598  start_month = params_value (params, "start_month");
10599  start_day = params_value (params, "start_day");
10600  start_hour = params_value (params, "start_hour");
10601  start_minute = params_value (params, "start_minute");
10602 
10603  end_year = params_value (params, "end_year");
10604  end_month = params_value (params, "end_month");
10605  end_day = params_value (params, "end_day");
10606  end_hour = params_value (params, "end_hour");
10607  end_minute = params_value (params, "end_minute");
10608 
10609  start_time.tm_year =
10610  start_year ? atoi (start_year) - 1900 : time_broken->tm_year;
10611  start_time.tm_mon =
10612  start_month ? atoi (start_month) - 1 : time_broken->tm_mon;
10613  start_time.tm_mday = start_day ? atoi (start_day) : time_broken->tm_mday;
10614  start_time.tm_hour =
10615  start_hour ? atoi (start_hour) : time_broken->tm_hour;
10616  start_time.tm_min =
10617  start_minute ? atoi (start_minute) : time_broken->tm_min;
10618 
10619  end_time.tm_year =
10620  end_year ? atoi (end_year) - 1900 : time_broken->tm_year;
10621  end_time.tm_mon = end_month ? atoi (end_month) - 1 : time_broken->tm_mon;
10622  end_time.tm_mday = end_day ? atoi (end_day) : time_broken->tm_mday;
10623  end_time.tm_hour = end_hour ? atoi (end_hour) : time_broken->tm_hour;
10624  end_time.tm_min = end_minute ? atoi (end_minute) : time_broken->tm_min;
10625  }
10626 
10627  g_string_append_printf (xml,
10628  "<start_time>"
10629  "<minute>%i</minute>"
10630  "<hour>%i</hour>"
10631  "<day_of_month>%i</day_of_month>"
10632  "<month>%i</month>"
10633  "<year>%i</year>"
10634  "</start_time>",
10635  start_time.tm_min, start_time.tm_hour,
10636  start_time.tm_mday, start_time.tm_mon + 1,
10637  start_time.tm_year + 1900);
10638 
10639  g_string_append_printf (xml,
10640  "<end_time>"
10641  "<minute>%i</minute>"
10642  "<hour>%i</hour>"
10643  "<day_of_month>%i</day_of_month>"
10644  "<month>%i</month>"
10645  "<year>%i</year>"
10646  "</end_time>"
10647  "<range_type>%s</range_type>",
10648  end_time.tm_min, end_time.tm_hour, end_time.tm_mday,
10649  end_time.tm_mon + 1, end_time.tm_year + 1900,
10650  range_type);
10651 
10652  /* Get the system reports. */
10653 
10654  if (gvm_connection_sendf (connection,
10655  "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
10656  slave_id ? slave_id : "0")
10657  == -1)
10658  {
10659  g_string_free (xml, TRUE);
10660  cmd_response_data_set_status_code (response_data,
10661  MHD_HTTP_INTERNAL_SERVER_ERROR);
10662  return gsad_message (
10663  credentials, "Internal error", __FUNCTION__, __LINE__,
10664  "An internal error occurred while getting the system reports. "
10665  "The current list of system reports is not available. "
10666  "Diagnostics: Failure to send command to manager daemon.",
10667  response_data);
10668  }
10669 
10670  if (read_string_c (connection, &xml))
10671  {
10672  g_string_free (xml, TRUE);
10673  cmd_response_data_set_status_code (response_data,
10674  MHD_HTTP_INTERNAL_SERVER_ERROR);
10675  return gsad_message (
10676  credentials, "Internal error", __FUNCTION__, __LINE__,
10677  "An internal error occurred while getting the system reports. "
10678  "The current list of system reports is not available. "
10679  "Diagnostics: Failure to receive response from manager daemon.",
10680  response_data);
10681  }
10682 
10683  if (command_enabled (credentials, "GET_SCANNERS"))
10684  {
10685  /* Get the GMP scanners. */
10686 
10687  if (gvm_connection_sendf (connection,
10688  "<get_scanners"
10689  " filter=\"sort=name rows=-1 type=4\"/>")
10690  == -1)
10691  {
10692  g_string_free (xml, TRUE);
10693  cmd_response_data_set_status_code (response_data,
10694  MHD_HTTP_INTERNAL_SERVER_ERROR);
10695  return gsad_message (
10696  credentials, "Internal error", __FUNCTION__, __LINE__,
10697  "An internal error occurred while getting the system reports. "
10698  "The current list of system reports is not available. "
10699  "Diagnostics: Failure to send command to manager daemon.",
10700  response_data);
10701  }
10702 
10703  if (read_string_c (connection, &xml))
10704  {
10705  g_string_free (xml, TRUE);
10706  cmd_response_data_set_status_code (response_data,
10707  MHD_HTTP_INTERNAL_SERVER_ERROR);
10708  return gsad_message (
10709  credentials, "Internal error", __FUNCTION__, __LINE__,
10710  "An internal error occurred while getting the system reports. "
10711  "The current list of system reports is not available. "
10712  "Diagnostics: Failure to receive response from manager daemon.",
10713  response_data);
10714  }
10715  }
10716 
10717  /* Cleanup, and return transformed XML. */
10718 
10719  g_string_append (xml, "</get_system_reports>");
10720  return envelope_gmp (connection, credentials, params,
10721  g_string_free (xml, FALSE), response_data);
10722 }

References cmd_response_data_set_status_code(), command_enabled(), envelope_gmp(), gsad_message(), and params_value().

Here is the call graph for this function:

◆ get_tag()

static char * get_tag ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one tag, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6603 of file gsad_gmp.c.

6606 {
6607  return get_one (connection, "tag", credentials, params, extra_xml, NULL,
6608  response_data);
6609 }

References get_one().

Referenced by get_tag_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_tag_gmp()

char* get_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one tag, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6622 of file gsad_gmp.c.

6624 {
6625  return get_tag (connection, credentials, params, NULL, response_data);
6626 }

References get_tag().

Here is the call graph for this function:

◆ get_tags_gmp()

char* get_tags_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all tags, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6639 of file gsad_gmp.c.

6641 {
6642  return get_many (connection, "tags", credentials, params, NULL,
6643  response_data);
6644 }

References get_many().

Here is the call graph for this function:

◆ get_target()

static char * get_target ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one target, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6726 of file gsad_gmp.c.

6729 {
6730  gmp_arguments_t *arguments;
6731  arguments = gmp_arguments_new ();
6732 
6733  gmp_arguments_add (arguments, "tasks", "1");
6734 
6735  return get_one (connection, "target", credentials, params, extra_xml,
6736  arguments, response_data);
6737 }

References get_one(), gmp_arguments_add(), and gmp_arguments_new().

Referenced by get_target_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_target_gmp()

char* get_target_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one target, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6750 of file gsad_gmp.c.

6752 {
6753  return get_target (connection, credentials, params, NULL, response_data);
6754 }

References get_target().

Here is the call graph for this function:

◆ get_targets_gmp()

char* get_targets_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all targets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6767 of file gsad_gmp.c.

6769 {
6770  return get_many (connection, "targets", credentials, params, NULL,
6771  response_data);
6772 }

References get_many().

Here is the call graph for this function:

◆ get_task_gmp()

char* get_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get a task, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3064 of file gsad_gmp.c.

3066 {
3067  return get_one (connection, "task", credentials, params, NULL, NULL,
3068  response_data);
3069 }

References get_one().

Here is the call graph for this function:

◆ get_task_id_from_params()

const char* get_task_id_from_params ( params_t *  params)

Get task_id from request params.

Parameters
[in]paramsRequest parameters.
Returns
The task_id

Definition at line 9358 of file gsad_gmp.c.

9359 {
9360  const char *task_id;
9361 
9362  task_id = params_value (params, "task_id");
9363 
9364  if (task_id && (strcmp (task_id, "0") == 0))
9365  task_id = params_value (params, "task_uuid");
9366 
9367  return task_id;
9368 }

References params_value().

Referenced by create_note_gmp(), create_override_gmp(), save_note_gmp(), and save_override_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_tasks_gmp()

char* get_tasks_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3020 of file gsad_gmp.c.

3022 {
3023  const char *schedules_only, *ignore_pagination, *usage_type;
3024  gmp_arguments_t *arguments;
3025 
3026  schedules_only = params_value (params, "schedules_only");
3027  ignore_pagination = params_value (params, "ignore_pagination");
3028  usage_type = params_value (params, "usage_type");
3029  if (params_given (params, "usage_type"))
3030  CHECK_VARIABLE_INVALID (usage_type, "Get Tasks");
3031 
3032  arguments = gmp_arguments_new ();
3033 
3034  if (schedules_only)
3035  {
3036  gmp_arguments_add (arguments, "schedules_only", schedules_only);
3037  }
3038 
3039  if (ignore_pagination)
3040  {
3041  gmp_arguments_add (arguments, "ignore_pargination", ignore_pagination);
3042  }
3043 
3044  if (usage_type)
3045  {
3046  gmp_arguments_add (arguments, "usage_type", usage_type);
3047  }
3048 
3049  return get_many (connection, "tasks", credentials, params, arguments,
3050  response_data);
3051 }

References CHECK_VARIABLE_INVALID, get_many(), gmp_arguments_add(), gmp_arguments_new(), params_given(), and params_value().

Here is the call graph for this function:

◆ get_ticket_gmp()

char* get_ticket_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get single tickets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16602 of file gsad_gmp.c.

16604 {
16605  return get_one (connection, "ticket", credentials, params, NULL, NULL,
16606  response_data);
16607 }

References get_one().

Here is the call graph for this function:

◆ get_tickets_gmp()

char* get_tickets_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all tickets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16584 of file gsad_gmp.c.

16586 {
16587  return get_many (connection, "tickets", credentials, params, NULL,
16588  response_data);
16589 }

References get_many().

Here is the call graph for this function:

◆ get_tls_certificate_gmp()

char* get_tls_certificate_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get single TLS certificates, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16828 of file gsad_gmp.c.

16831 {
16832  gmp_arguments_t *arguments = gmp_arguments_new ();
16833  const char *include_certificate_data;
16834 
16835  if (params_given (params, "include_certificate_data"))
16836  {
16837  include_certificate_data =
16838  params_value (params, "include_certificate_data");
16839  CHECK_VARIABLE_INVALID (include_certificate_data, "Get TLS Certificate");
16840  gmp_arguments_add (arguments, "include_certificate_data",
16841  include_certificate_data);
16842  }
16843 
16844  return get_one (connection, "tls_certificate", credentials, params, NULL,
16845  arguments, response_data);
16846 }

References CHECK_VARIABLE_INVALID, get_one(), gmp_arguments_add(), gmp_arguments_new(), params_given(), and params_value().

Here is the call graph for this function:

◆ get_tls_certificates_gmp()

char* get_tls_certificates_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all TLS certificates, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16797 of file gsad_gmp.c.

16800 {
16801  gmp_arguments_t *arguments = gmp_arguments_new ();
16802  const char *include_certificate_data;
16803 
16804  if (params_given (params, "include_certificate_data"))
16805  {
16806  include_certificate_data =
16807  params_value (params, "include_certificate_data");
16808  CHECK_VARIABLE_INVALID (include_certificate_data, "Get TLS Certificate");
16809  gmp_arguments_add (arguments, "include_certificate_data",
16810  include_certificate_data);
16811  }
16812 
16813  return get_many (connection, "tls_certificates", credentials, params,
16814  arguments, response_data);
16815 }

References CHECK_VARIABLE_INVALID, get_many(), gmp_arguments_add(), gmp_arguments_new(), params_given(), and params_value().

Here is the call graph for this function:

◆ get_trash()

char * get_trash ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Setup trash page XML, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 11431 of file gsad_gmp.c.

11434 {
11435  GString *xml;
11436 
11437  xml = g_string_new ("<get_trash>");
11438 
11439  if (extra_xml)
11440  g_string_append (xml, extra_xml);
11441 
11442  GET_TRASH_RESOURCE ("GET_AGENTS", "get_agents", "agents");
11443 
11444  GET_TRASH_RESOURCE ("GET_CONFIGS", "get_configs", "configs");
11445 
11446  GET_TRASH_RESOURCE ("GET_CREDENTIALS", "get_credentials", "credentials");
11447 
11448  GET_TRASH_RESOURCE ("GET_ALERTS", "get_alerts", "alerts");
11449 
11450  GET_TRASH_RESOURCE ("GET_GROUPS", "get_groups", "groups");
11451 
11452  GET_TRASH_RESOURCE ("GET_FILTERS", "get_filters", "filters");
11453 
11454  GET_TRASH_RESOURCE ("GET_NOTES", "get_notes", "notes");
11455 
11456  GET_TRASH_RESOURCE ("GET_OVERRIDES", "get_overrides", "overrides");
11457 
11458  GET_TRASH_RESOURCE ("GET_PERMISSIONS", "get_permissions", "permissions");
11459 
11460  GET_TRASH_RESOURCE ("GET_PORT_LISTS", "get_port_lists", "port lists");
11461 
11462  GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats",
11463  "report formats");
11464 
11465  GET_TRASH_RESOURCE ("GET_ROLES", "get_roles", "roles");
11466 
11467  GET_TRASH_RESOURCE ("GET_SCANNERS", "get_scanners", "scanners");
11468 
11469  GET_TRASH_RESOURCE ("GET_SCHEDULES", "get_schedules", "schedules");
11470 
11471  GET_TRASH_RESOURCE ("GET_TAGS", "get_tags", "tags");
11472 
11473  GET_TRASH_RESOURCE ("GET_TARGETS", "get_targets", "targets");
11474 
11475  GET_TRASH_RESOURCE ("GET_TASKS", "get_tasks", "tasks");
11476 
11477  GET_TRASH_RESOURCE ("GET_TICKETS", "get_tickets", "tickets");
11478 
11479  /* Cleanup, and return transformed XML. */
11480 
11481  g_string_append (xml, "</get_trash>");
11482  return envelope_gmp (connection, credentials, params,
11483  g_string_free (xml, FALSE), response_data);
11484 }

References envelope_gmp(), and GET_TRASH_RESOURCE.

Referenced by get_trash_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_trash_gmp()

char* get_trash_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all trash, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 11498 of file gsad_gmp.c.

11500 {
11501  return get_trash (connection, credentials, params, NULL, response_data);
11502 }

References get_trash().

Here is the call graph for this function:

◆ get_user()

char * get_user ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Get one user, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14657 of file gsad_gmp.c.

14660 {
14661  gchar *html;
14662  GString *extra;
14663 
14664  extra = g_string_new ("");
14665  if (extra_xml)
14666  g_string_append (extra, extra_xml);
14667  if (command_enabled (credentials, "DESCRIBE_AUTH"))
14668  {
14669  gchar *response;
14670  entity_t entity;
14671 
14672  response = NULL;
14673  entity = NULL;
14674  switch (gmp (connection, credentials, &response, &entity, response_data,
14675  "<describe_auth/>"))
14676  {
14677  case 0:
14678  case -1:
14679  break;
14680  case 1:
14681  cmd_response_data_set_status_code (response_data,
14682  MHD_HTTP_INTERNAL_SERVER_ERROR);
14683  return gsad_message (
14684  credentials, "Internal error", __FUNCTION__, __LINE__,
14685  "An internal error occurred getting the auth list. "
14686  "Diagnostics: Failure to send command to manager daemon.",
14687  response_data);
14688  case 2:
14689  cmd_response_data_set_status_code (response_data,
14690  MHD_HTTP_INTERNAL_SERVER_ERROR);
14691  return gsad_message (
14692  credentials, "Internal error", __FUNCTION__, __LINE__,
14693  "An internal error occurred getting the auth list. "
14694  "Diagnostics: Failure to receive response from manager daemon.",
14695  response_data);
14696  default:
14697  cmd_response_data_set_status_code (response_data,
14698  MHD_HTTP_INTERNAL_SERVER_ERROR);
14699  return gsad_message (
14700  credentials, "Internal error", __FUNCTION__, __LINE__,
14701  "An internal error occurred getting the auth list. "
14702  "Diagnostics: Internal Error.",
14703  response_data);
14704  }
14705 
14706  g_string_append (extra, response);
14707 
14708  free_entity (entity);
14709  g_free (response);
14710  }
14711  html = get_one (connection, "user", credentials, params, extra->str, NULL,
14712  response_data);
14713  g_string_free (extra, TRUE);
14714  return html;
14715 }

References cmd_response_data_set_status_code(), command_enabled(), get_one(), gmp(), and gsad_message().

Referenced by get_user_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_user_gmp()

char* get_user_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get one user, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14728 of file gsad_gmp.c.

14730 {
14731  return get_user (connection, credentials, params, NULL, response_data);
14732 }

References get_user().

Here is the call graph for this function:

◆ get_users_gmp()

char* get_users_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get all users, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14745 of file gsad_gmp.c.

14747 {
14748  return get_many (connection, "users", credentials, params, NULL,
14749  response_data);
14750 }

References get_many().

Here is the call graph for this function:

◆ get_vulns_gmp()

char* get_vulns_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get multiple vulns, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14935 of file gsad_gmp.c.

14937 {
14938  return get_many (connection, "vulns", credentials, params, NULL,
14939  response_data);
14940 }

References get_many().

Here is the call graph for this function:

◆ gmp()

static int gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
gchar **  response,
entity_t *  entity_return,
cmd_response_data_t *  response_data,
const char *  command 
)
static

Run a single GMP command.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[out]responseResponse.
[out]entity_returnResponse entity.
[out]response_dataExtra data return for the HTTP response.
[in]commandCommand.
Returns
0 success, -1 failed to connect (response set), 1 send error, 2 read error.

Definition at line 576 of file gsad_gmp.c.

579 {
580  int ret;
581  entity_t entity;
582 
583  if (entity_return)
584  *entity_return = NULL;
585 
586  ret = gvm_connection_sendf (connection, "%s", command);
587  if (ret == -1)
588  {
589  return 1;
590  }
591 
592  entity = NULL;
593  if (read_entity_and_text_c (connection, &entity, response))
594  {
595  return 2;
596  }
597  if (entity_return)
598  *entity_return = entity;
599  else
600  free_entity (entity);
601  return 0;
602 }

Referenced by auth_settings_gmp(), create_agent_gmp(), create_alert_gmp(), create_container_task_gmp(), create_group_gmp(), create_host_gmp(), create_report_gmp(), create_tag_gmp(), create_target_gmp(), create_task_gmp(), create_user_gmp(), get_aggregate_gmp(), get_user(), gmpf(), import_config_gmp(), import_port_list_gmp(), import_report_format_gmp(), move_task_gmp(), new_alert(), run_wizard_gmp(), save_alert_gmp(), save_credential_gmp(), save_setting_gmp(), save_tag_gmp(), save_target_gmp(), save_user_gmp(), and wizard_get().

Here is the caller graph for this function:

◆ gmp_init()

void gmp_init ( const gchar *  manager_address_unix,
const gchar *  manager_address_tls,
int  port_manager 
)

Init the GSA GMP library.

Parameters
[in]manager_address_unixManager address when using UNIX socket.
[in]manager_address_tlsManager address when using TLS-TCP.
[in]port_managerManager port.

Definition at line 277 of file gsad_gmp.c.

279 {
280  if (manager_address_unix)
281  {
282  manager_address = g_strdup (manager_address_unix);
283  manager_use_tls = 0;
284  }
285  else if (manager_address_tls)
286  {
287  manager_address = g_strdup (manager_address_tls);
288  manager_use_tls = 1;
289  }
290  else
291  {
292  manager_address = g_build_filename (GVM_RUN_DIR, "gvmd.sock", NULL);
293  manager_use_tls = 0;
294  }
295  manager_port = port_manager;
296 }

References manager_address, manager_port, and manager_use_tls.

◆ gmp_success()

static int gmp_success ( entity_t  entity)
static

Check whether an GMP command failed.

Parameters
[in]entityResponse entity.
Returns
1 success, 0 fail, -1 error.

Definition at line 526 of file gsad_gmp.c.

527 {
528  const char *status;
529 
530  if (entity == NULL)
531  return 0;
532 
533  status = entity_attribute (entity, "status");
534  if ((status == NULL) || (strlen (status) == 0))
535  return -1;
536 
537  return status[0] == '2';
538 }

Referenced by check_modify_config(), create_task_gmp(), delete_resource(), export_many(), export_resource(), get_aggregate_gmp(), get_capabilities_gmp(), get_entities(), get_entity(), get_report(), resource_action(), response_from_entity(), save_my_settings_gmp(), save_user_gmp(), and send_settings_filters().

Here is the caller graph for this function:

◆ gmpf()

static int gmpf ( gvm_connection_t *  connection,
credentials_t *  credentials,
gchar **  response,
entity_t *  entity_return,
cmd_response_data_t *  response_data,
const char *  format,
  ... 
)
static

Run a single formatted GMP command.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[out]responseResponse.
[out]entity_returnResponse entity.
[out]response_dataExtra data return for the HTTP response.
[in]formatCommand.
[in]...Arguments for format string.
Returns
0 success, -1 failed to connect (response set), 1 send error, 2 read error.

Definition at line 619 of file gsad_gmp.c.

622 {
623  int ret;
624  gchar *command;
625  va_list args;
626 
627  va_start (args, format);
628  command = g_markup_vprintf_escaped (format, args);
629  va_end (args);
630 
631  ret = gmp (connection, credentials, response, entity_return, response_data,
632  command);
633  g_free (command);
634  return ret;
635 }

References gmp().

Referenced by create_asset_gmp(), create_config_gmp(), create_credential_gmp(), create_filter_gmp(), create_note_gmp(), create_override_gmp(), create_permission_gmp(), create_permissions_gmp(), create_port_list_gmp(), create_port_range_gmp(), create_role_gmp(), create_scanner_gmp(), create_schedule_gmp(), create_ticket_gmp(), create_tls_certificate_gmp(), resource_action(), save_agent_gmp(), save_asset_gmp(), save_auth_gmp(), save_container_task_gmp(), save_group_gmp(), save_note_gmp(), save_override_gmp(), save_permission_gmp(), save_port_list_gmp(), save_report_format_gmp(), save_role_gmp(), save_scanner_gmp(), save_schedule_gmp(), save_task_gmp(), save_ticket_gmp(), save_tls_certificate_gmp(), verify_agent_gmp(), and verify_scanner_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gvm_connection_open()

int gvm_connection_open ( gvm_connection_t *  connection,
const gchar *  address,
int  port 
)

Connect to an address.

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

Definition at line 17185 of file gsad_gmp.c.

17187 {
17188  if (address == NULL)
17189  return -1;
17190 
17191  connection->tls = manager_use_tls;
17192 
17193  if (manager_use_tls)
17194  {
17195  connection->socket =
17196  gvm_server_open (&connection->session, address, port);
17197  connection->credentials = NULL;
17198  }
17199  else
17200  connection->socket = connect_unix (address);
17201 
17202  if (connection->socket == -1)
17203  return -1;
17204 
17205  return 0;
17206 }

References connect_unix(), and manager_use_tls.

Referenced by authenticate_gmp(), and manager_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ import_config_gmp()

char* import_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Import config, get all configs, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7147 of file gsad_gmp.c.

7149 {
7150  gchar *command, *html, *response;
7151  entity_t entity;
7152  int ret;
7153 
7154  /* Create the config. */
7155 
7156  response = NULL;
7157  entity = NULL;
7158  command = g_strdup_printf ("<create_config>"
7159  "%s"
7160  "</create_config>",
7161  params_value (params, "xml_file"));
7162  ret =
7163  gmp (connection, credentials, &response, &entity, response_data, command);
7164  g_free (command);
7165  switch (ret)
7166  {
7167  case 0:
7168  case -1:
7169  break;
7170  case 1:
7171  cmd_response_data_set_status_code (response_data,
7172  MHD_HTTP_INTERNAL_SERVER_ERROR);
7173  return gsad_message (
7174  credentials, "Internal error", __FUNCTION__, __LINE__,
7175  "An internal error occurred while importing a config. "
7176  "The schedule remains the same. "
7177  "Diagnostics: Failure to send command to manager daemon.",
7178  response_data);
7179  case 2:
7180  cmd_response_data_set_status_code (response_data,
7181  MHD_HTTP_INTERNAL_SERVER_ERROR);
7182  return gsad_message (
7183  credentials, "Internal error", __FUNCTION__, __LINE__,
7184  "An internal error occurred while importing a config. "
7185  "It is unclear whether the schedule has been saved or not. "
7186  "Diagnostics: Failure to receive response from manager daemon.",
7187  response_data);
7188  default:
7189  cmd_response_data_set_status_code (response_data,
7190  MHD_HTTP_INTERNAL_SERVER_ERROR);
7191  return gsad_message (
7192  credentials, "Internal error", __FUNCTION__, __LINE__,
7193  "An internal error occurred while importing a config. "
7194  "It is unclear whether the schedule has been saved or not. "
7195  "Diagnostics: Internal Error.",
7196  response_data);
7197  }
7198 
7199  /* Cleanup, and return transformed XML. */
7200 
7201  html = response_from_entity (connection, credentials, params, entity,
7202  "Import Config", response_data);
7203  free_entity (entity);
7204  g_free (response);
7205  return html;
7206 }

References cmd_response_data_set_status_code(), gmp(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ import_port_list_gmp()

char* import_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Import port list, get all port_lists, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13720 of file gsad_gmp.c.

13722 {
13723  gchar *command, *html, *response;
13724  entity_t entity;
13725  int ret;
13726 
13727  /* Create the port list. */
13728 
13729  response = NULL;
13730  entity = NULL;
13731  command = g_strdup_printf ("<create_port_list>"
13732  "%s"
13733  "</create_port_list>",
13734  params_value (params, "xml_file"));
13735  ret =
13736  gmp (connection, credentials, &response, &entity, response_data, command);
13737  g_free (command);
13738  switch (ret)
13739  {
13740  case 0:
13741  case -1:
13742  break;
13743  case 1:
13744  cmd_response_data_set_status_code (response_data,
13745  MHD_HTTP_INTERNAL_SERVER_ERROR);
13746  return gsad_message (
13747  credentials, "Internal error", __FUNCTION__, __LINE__,
13748  "An internal error occurred while importing a port_list. "
13749  "The schedule remains the same. "
13750  "Diagnostics: Failure to send command to manager daemon.",
13751  response_data);
13752  case 2:
13753  cmd_response_data_set_status_code (response_data,
13754  MHD_HTTP_INTERNAL_SERVER_ERROR);
13755  return gsad_message (
13756  credentials, "Internal error", __FUNCTION__, __LINE__,
13757  "An internal error occurred while importing a port_list. "
13758  "It is unclear whether the schedule has been saved or not. "
13759  "Diagnostics: Failure to receive response from manager daemon.",
13760  response_data);
13761  default:
13762  cmd_response_data_set_status_code (response_data,
13763  MHD_HTTP_INTERNAL_SERVER_ERROR);
13764  return gsad_message (
13765  credentials, "Internal error", __FUNCTION__, __LINE__,
13766  "An internal error occurred while importing a port_list. "
13767  "It is unclear whether the schedule has been saved or not. "
13768  "Diagnostics: Internal Error.",
13769  response_data);
13770  }
13771 
13772  /* Cleanup, and return transformed XML. */
13773 
13774  html = response_from_entity (connection, credentials, params, entity,
13775  "Import Port List", response_data);
13776  free_entity (entity);
13777  g_free (response);
13778  return html;
13779 }

References cmd_response_data_set_status_code(), gmp(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ import_report_format_gmp()

char* import_report_format_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Import report format, get all report formats, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10934 of file gsad_gmp.c.

10937 {
10938  gchar *command, *html, *response;
10939  entity_t entity;
10940  int ret;
10941 
10942  /* Create the report format. */
10943 
10944  response = NULL;
10945  entity = NULL;
10946  command = g_strdup_printf ("<create_report_format>"
10947  "%s"
10948  "</create_report_format>",
10949  params_value (params, "xml_file"));
10950  ret =
10951  gmp (connection, credentials, &response, &entity, response_data, command);
10952  g_free (command);
10953  switch (ret)
10954  {
10955  case 0:
10956  case -1:
10957  break;
10958  case 1:
10959  cmd_response_data_set_status_code (response_data,
10960  MHD_HTTP_INTERNAL_SERVER_ERROR);
10961  return gsad_message (
10962  credentials, "Internal error", __FUNCTION__, __LINE__,
10963  "An internal error occurred while importing a report format. "
10964  "The schedule remains the same. "
10965  "Diagnostics: Failure to send command to manager daemon.",
10966  response_data);
10967  case 2:
10968  cmd_response_data_set_status_code (response_data,
10969  MHD_HTTP_INTERNAL_SERVER_ERROR);
10970  return gsad_message (
10971  credentials, "Internal error", __FUNCTION__, __LINE__,
10972  "An internal error occurred while importing a report format. "
10973  "It is unclear whether the schedule has been saved or not. "
10974  "Diagnostics: Failure to receive response from manager daemon.",
10975  response_data);
10976  default:
10977  cmd_response_data_set_status_code (response_data,
10978  MHD_HTTP_INTERNAL_SERVER_ERROR);
10979  return gsad_message (
10980  credentials, "Internal error", __FUNCTION__, __LINE__,
10981  "An internal error occurred while importing a report format. "
10982  "It is unclear whether the schedule has been saved or not. "
10983  "Diagnostics: Internal Error.",
10984  response_data);
10985  }
10986 
10987  /* Cleanup, and return transformed XML. */
10988 
10989  if (entity_attribute (entity, "id"))
10990  params_add (params, "report_format_id", entity_attribute (entity, "id"));
10991  html = response_from_entity (connection, credentials, params, entity,
10992  "Create Report Format", response_data);
10993 
10994  free_entity (entity);
10995  g_free (response);
10996  return html;
10997 }

References cmd_response_data_set_status_code(), gmp(), gsad_message(), params_add(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ import_report_gmp()

char* import_report_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Import report, get all reports, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2020 of file gsad_gmp.c.

2022 {
2023  return create_report_gmp (connection, credentials, params, response_data);
2024 }

References create_report_gmp().

Here is the call graph for this function:

◆ login()

int login ( http_connection_t *  con,
params_t *  params,
cmd_response_data_t *  response_data,
const char *  client_address 
)

Login and create a session.

Parameters
[in]conHTTP Connection
[in]paramsRequest parameters
[out]response_dataExtra data return for the HTTP response
[in]client_addressClient address
Returns
MHD_YES on success. MHD_NO on errors.

Definition at line 17345 of file gsad_gmp.c.

17347 {
17348  int ret, status;
17349  authentication_reason_t auth_reason;
17351  gchar *timezone;
17352  gchar *role;
17353  gchar *capabilities;
17354  gchar *severity;
17355  gchar *language;
17356  gchar *pw_warning;
17357 
17358  const char *password = params_value (params, "password");
17359  const char *login = params_value (params, "login");
17360 
17361  if ((password == NULL)
17362  && (params_original_value (params, "password") == NULL))
17363  password = "";
17364 
17365  if (login && password)
17366  {
17367  ret = authenticate_gmp (login, password, &role, &timezone, &severity,
17368  &capabilities, &language, &pw_warning);
17369  if (ret)
17370  {
17371  switch (ret)
17372  {
17373  case 1: /* could not connect to manager */
17374  case 3: /* timeout */
17375  status = MHD_HTTP_SERVICE_UNAVAILABLE;
17376  auth_reason = GMP_SERVICE_DOWN;
17377  break;
17378  case 2: /* authentication failure */
17379  status = MHD_HTTP_UNAUTHORIZED;
17380  auth_reason = LOGIN_FAILED;
17381  break;
17382  default: /* unspecified error */
17383  status = MHD_HTTP_INTERNAL_SERVER_ERROR;
17384  auth_reason = LOGIN_ERROR;
17385  break;
17386  }
17387 
17388  g_warning ("Authentication failure for '%s' from %s. "
17389  "Status was %d.",
17390  login ?: "", client_address, ret);
17391  return handler_send_reauthentication (con, status, auth_reason);
17392  }
17393  else
17394  {
17395  user_t *user;
17396  user = user_add (login, password, timezone, severity, role,
17397  capabilities, language, pw_warning, client_address);
17398 
17399  g_message ("Authentication success for '%s' from %s", login ?: "",
17400  client_address);
17401 
17402  credentials = credentials_new (user, language);
17403 
17404  gchar *data =
17405  envelope_gmp (NULL, credentials, params, NULL, response_data);
17406 
17407  ret = handler_create_response (con, data, response_data,
17408  user_get_cookie (user));
17409 
17410  user_free (user);
17411 
17413 
17414  g_free (timezone);
17415  g_free (severity);
17416  g_free (capabilities);
17417  g_free (language);
17418  g_free (role);
17419  g_free (pw_warning);
17420 
17421  return ret;
17422  }
17423  }
17424  else
17425  {
17426  g_warning ("Authentication failure for '%s' from %s", login ?: "",
17427  client_address);
17428  return handler_send_reauthentication (con, MHD_HTTP_UNAUTHORIZED,
17429  LOGIN_FAILED);
17430  }
17431 }

References authenticate_gmp(), credentials_free(), credentials_new(), envelope_gmp(), GMP_SERVICE_DOWN, handler_create_response(), handler_send_reauthentication(), login(), LOGIN_ERROR, LOGIN_FAILED, params_original_value(), params_value(), user_add(), user_free(), and user_get_cookie().

Referenced by create_credential_gmp(), download_credential_gmp(), login(), save_credential_gmp(), and save_user_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ manager_connect()

int manager_connect ( credentials_t *  credentials,
gvm_connection_t *  connection,
cmd_response_data_t *  response_data 
)

Connect to Greenbone Vulnerability Manager daemon.

Parameters
[in]credentialsUsername and password for authentication.
[out]connectionConnection to Manager on success.
[out]response_dataExtra data return for the HTTP response.
Returns
0 success, 1 if manager closed connection, 2 if auth failed, 3 on timeout, 4 failed to connect, -1 on error

Definition at line 17444 of file gsad_gmp.c.

17446 {
17447  gmp_authenticate_info_opts_t auth_opts;
17448 
17450  {
17451  return 4;
17452  }
17453 
17455 
17456  auth_opts = gmp_authenticate_info_opts_defaults;
17457  auth_opts.username = user_get_username (user);
17458  auth_opts.password = user_get_password (user);
17459 
17460  int ret = gmp_authenticate_info_ext_c (connection, auth_opts);
17461 
17462  if (ret)
17463  {
17464  gvm_connection_close (connection);
17465  return ret;
17466  }
17467 
17468 #ifdef DEBUG
17469  /* Enable this if you need the CGI to sleep after launch. This can be useful
17470  * if you need to attach to manager process the CGI is talking to for
17471  * debugging purposes.
17472  *
17473  * An easier method is to run gsad under gdb and set a breakpoint here.
17474  */
17475  g_debug ("Sleeping!");
17476  sleep (10);
17477 #endif
17478  return 0;
17479 }

References credentials_get_user(), gvm_connection_open(), manager_address, manager_port, user_get_password(), and user_get_username().

Referenced by handle_system_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ member()

static int member ( params_t *  params,
const char *  string 
)
static

Look for a param with name equal to a given string.

Parameters
[in]paramsParams.
[in]stringString.
Returns
1 if param with name
  • string exists in
  • params, else 0.

Definition at line 390 of file gsad_gmp.c.

391 {
392  params_iterator_t iter;
393  param_t *param;
394  char *name;
395 
396  params_iterator_init (&iter, params);
397  while (params_iterator_next (&iter, &name, &param))
398  if (strcmp (name, string) == 0)
399  return 1;
400  return 0;
401 }

References params_iterator_init, params_iterator_next(), and params_iterator_t.

Referenced by save_config_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ member1()

int member1 ( params_t *  params,
const char *  string 
)

Look for param with value 1 and name equal to given string.

Parameters
[in]paramsParams.
[in]stringString.
Returns
1 if param with name
  • string exists in
  • params, else 0.

Definition at line 412 of file gsad_gmp.c.

413 {
414  params_iterator_t iter;
415  param_t *param;
416  char *name;
417 
418  params_iterator_init (&iter, params);
419  while (params_iterator_next (&iter, &name, &param))
420  if (param->value_size && param->value[0] == '1'
421  && strcmp (name, string) == 0)
422  return 1;
423  return 0;
424 }

References params_iterator_init, params_iterator_next(), params_iterator_t, param::value, and param::value_size.

Referenced by save_config_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ message_invalid()

gchar* message_invalid ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data,
const char *  message,
const char *  op_name 
)

Check a param using the direct response method.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]response_dataResponse data.
[in]messageMessage.
[in]op_nameOperation name.
Returns
Enveloped XML object.

Definition at line 764 of file gsad_gmp.c.

767 {
768  gchar *ret = action_result (connection, credentials, params, response_data,
769  op_name, message, NULL, NULL);
770 
771  cmd_response_data_set_status_code (response_data,
773 
774  return ret;
775 }

References action_result(), cmd_response_data_set_status_code(), and GSAD_STATUS_INVALID_REQUEST.

Referenced by create_report_gmp(), create_task_gmp(), delete_resource(), and save_auth_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_resource_to_trash()

char* move_resource_to_trash ( gvm_connection_t *  connection,
const char *  type,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Move a resource to the trashcan.

Parameters
[in]connectionConnection to manager.
[in]typeType of resource.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1703 of file gsad_gmp.c.

1706 {
1707  return delete_resource (connection, type, credentials, params, FALSE,
1708  response_data);
1709 }

References delete_resource().

Referenced by delete_agent_gmp(), delete_alert_gmp(), delete_config_gmp(), delete_credential_gmp(), delete_filter_gmp(), delete_group_gmp(), delete_note_gmp(), delete_override_gmp(), delete_permission_gmp(), delete_port_list_gmp(), delete_report_format_gmp(), delete_role_gmp(), delete_scanner_gmp(), delete_schedule_gmp(), delete_tag_gmp(), delete_target_gmp(), delete_task_gmp(), delete_ticket_gmp(), delete_tls_certificate_gmp(), and delete_user_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_task_gmp()

char* move_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Reassign a task to a new GMP slave.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2894 of file gsad_gmp.c.

2896 {
2897  gchar *command, *response, *html;
2898  const char *task_id, *slave_id;
2899  int ret;
2900  entity_t entity;
2901 
2902  slave_id = params_value (params, "slave_id");
2903  task_id = params_value (params, "task_id");
2904 
2905  command = g_strdup_printf ("<move_task task_id=\"%s\" slave_id=\"%s\"/>",
2906  task_id ? task_id : "", slave_id ? slave_id : "");
2907 
2908  response = NULL;
2909  entity = NULL;
2910  ret =
2911  gmp (connection, credentials, &response, &entity, response_data, command);
2912  g_free (command);
2913  switch (ret)
2914  {
2915  case 0:
2916  break;
2917  case -1:
2918  /* 'gmp' set response. */
2919  return response;
2920  case 1:
2921  cmd_response_data_set_status_code (response_data,
2922  MHD_HTTP_INTERNAL_SERVER_ERROR);
2923  return gsad_message (
2924  credentials, "Internal error", __FUNCTION__, __LINE__,
2925  "An internal error occurred while moving a task. "
2926  "The task was not moved. "
2927  "Diagnostics: Failure to send command to manager daemon.",
2928  response_data);
2929  case 2:
2930  cmd_response_data_set_status_code (response_data,
2931  MHD_HTTP_INTERNAL_SERVER_ERROR);
2932  return gsad_message (
2933  credentials, "Internal error", __FUNCTION__, __LINE__,
2934  "An internal error occurred while moving a task. "
2935  "It is unclear whether the task has been moved or not. "
2936  "Diagnostics: Failure to receive response from manager daemon.",
2937  response_data);
2938  default:
2939  cmd_response_data_set_status_code (response_data,
2940  MHD_HTTP_INTERNAL_SERVER_ERROR);
2941  return gsad_message (
2942  credentials, "Internal error", __FUNCTION__, __LINE__,
2943  "An internal error occurred while moving a task. "
2944  "It is unclear whether the task has been moved or not. "
2945  "Diagnostics: Internal Error.",
2946  response_data);
2947  }
2948 
2949  html = response_from_entity (connection, credentials, params, entity,
2950  "Move Task", response_data);
2951 
2952  free_entity (entity);
2953  g_free (response);
2954  return html;
2955 }

References cmd_response_data_set_status_code(), gmp(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ new_alert()

static char* new_alert ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Returns page to create a new alert.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4696 of file gsad_gmp.c.

4699 {
4700  GString *xml;
4701  int ret;
4702  entity_t entity;
4703  gchar *response;
4704 
4705  xml = g_string_new ("<new_alert>");
4706  if (extra_xml)
4707  g_string_append (xml, extra_xml);
4708 
4709  /* Get Report Formats. */
4710 
4711  response = NULL;
4712  entity = NULL;
4713  ret = gmp (connection, credentials, &response, &entity, response_data,
4714  "<get_report_formats filter=\"rows=-1\"/>");
4715  switch (ret)
4716  {
4717  case 0:
4718  case -1:
4719  break;
4720  case 1:
4721  cmd_response_data_set_status_code (response_data,
4722  MHD_HTTP_INTERNAL_SERVER_ERROR);
4723  return gsad_message (
4724  credentials, "Internal error", __FUNCTION__, __LINE__,
4725  "An internal error occurred while getting Report "
4726  "Formats for new alert. "
4727  "Diagnostics: Failure to send command to manager daemon.",
4728  response_data);
4729  case 2:
4730  cmd_response_data_set_status_code (response_data,
4731  MHD_HTTP_INTERNAL_SERVER_ERROR);
4732  return gsad_message (
4733  credentials, "Internal error", __FUNCTION__, __LINE__,
4734  "An internal error occurred while getting Report "
4735  "Formats for new alert. "
4736  "Diagnostics: Failure to receive response from manager daemon.",
4737  response_data);
4738  default:
4739  cmd_response_data_set_status_code (response_data,
4740  MHD_HTTP_INTERNAL_SERVER_ERROR);
4741  return gsad_message (credentials, "Internal error", __FUNCTION__,
4742  __LINE__,
4743  "An internal error occurred while getting Report "
4744  "Formats for new alert. It is unclear whether"
4745  " the alert has been saved or not. "
4746  "Diagnostics: Internal Error.",
4747  response_data);
4748  }
4749  g_string_append (xml, response);
4750  g_free (response);
4751  free_entity (entity);
4752 
4753  /* Get Report Filters. */
4754 
4755  ret = gmp (connection, credentials, &response, &entity, response_data,
4756  "<get_filters filter=\"rows=-1\"/>");
4757 
4758  switch (ret)
4759  {
4760  case 0:
4761  case -1:
4762  break;
4763  case 1:
4764  cmd_response_data_set_status_code (response_data,
4765  MHD_HTTP_INTERNAL_SERVER_ERROR);
4766  return gsad_message (
4767  credentials, "Internal error", __FUNCTION__, __LINE__,
4768  "An internal error occurred while getting Report "
4769  "Filters for new alert. "
4770  "The task was not saved. "
4771  "Diagnostics: Failure to send command to manager daemon.",
4772  response_data);
4773  case 2:
4774  cmd_response_data_set_status_code (response_data,
4775  MHD_HTTP_INTERNAL_SERVER_ERROR);
4776  return gsad_message (
4777  credentials, "Internal error", __FUNCTION__, __LINE__,
4778  "An internal error occurred while getting Report "
4779  "Filters for new alert. "
4780  "Diagnostics: Failure to receive response from manager daemon.",
4781  response_data);
4782  default:
4783  cmd_response_data_set_status_code (response_data,
4784  MHD_HTTP_INTERNAL_SERVER_ERROR);
4785  return gsad_message (credentials, "Internal error", __FUNCTION__,
4786  __LINE__,
4787  "An internal error occurred while getting Report "
4788  "Filters for new alert. "
4789  "Diagnostics: Internal Error.",
4790  response_data);
4791  }
4792  g_string_append (xml, response);
4793  g_free (response);
4794  free_entity (entity);
4795 
4796  /* Get Tasks. */
4797 
4798  ret = gmp (connection, credentials, &response, &entity, response_data,
4799  "<get_tasks"
4800  " schedules_only=\"1\""
4801  " filter=\"owner=any permission=start_task rows=-1\"/>");
4802 
4803  switch (ret)
4804  {
4805  case 0:
4806  case -1:
4807  break;
4808  case 1:
4809  cmd_response_data_set_status_code (response_data,
4810  MHD_HTTP_INTERNAL_SERVER_ERROR);
4811  return gsad_message (
4812  credentials, "Internal error", __FUNCTION__, __LINE__,
4813  "An internal error occurred while getting Tasks"
4814  " for new alert. "
4815  "The task was not saved. "
4816  "Diagnostics: Failure to send command to manager daemon.",
4817  response_data);
4818  case 2:
4819  cmd_response_data_set_status_code (response_data,
4820  MHD_HTTP_INTERNAL_SERVER_ERROR);
4821  return gsad_message (
4822  credentials, "Internal error", __FUNCTION__, __LINE__,
4823  "An internal error occurred while getting Tasks"
4824  " for new alert. "
4825  "Diagnostics: Failure to receive response from manager daemon.",
4826  response_data);
4827  default:
4828  cmd_response_data_set_status_code (response_data,
4829  MHD_HTTP_INTERNAL_SERVER_ERROR);
4830  return gsad_message (credentials, "Internal error", __FUNCTION__,
4831  __LINE__,
4832  "An internal error occurred while getting Tasks"
4833  " for new alert. "
4834  "Diagnostics: Internal Error.",
4835  response_data);
4836  }
4837  g_string_append (xml, response);
4838  g_free (response);
4839  free_entity (entity);
4840 
4841  /* Get Credentials. */
4842 
4843  ret = gmp (connection, credentials, &response, &entity, response_data,
4844  "<get_credentials"
4845  " filter=\"type=up or type=pw"
4846  " owner=any permission=any rows=-1\"/>");
4847 
4848  switch (ret)
4849  {
4850  case 0:
4851  case -1:
4852  break;
4853  case 1:
4854  cmd_response_data_set_status_code (response_data,
4855  MHD_HTTP_INTERNAL_SERVER_ERROR);
4856  return gsad_message (
4857  credentials, "Internal error", __FUNCTION__, __LINE__,
4858  "An internal error occurred while getting"
4859  " Credentials for new alert. "
4860  "The task was not saved. "
4861  "Diagnostics: Failure to send command to manager daemon.",
4862  response_data);
4863  case 2:
4864  cmd_response_data_set_status_code (response_data,
4865  MHD_HTTP_INTERNAL_SERVER_ERROR);
4866  return gsad_message (
4867  credentials, "Internal error", __FUNCTION__, __LINE__,
4868  "An internal error occurred while getting"
4869  " Credentials for new alert. "
4870  "Diagnostics: Failure to receive response from manager daemon.",
4871  response_data);
4872  default:
4873  cmd_response_data_set_status_code (response_data,
4874  MHD_HTTP_INTERNAL_SERVER_ERROR);
4875  return gsad_message (credentials, "Internal error", __FUNCTION__,
4876  __LINE__,
4877  "An internal error occurred while getting"
4878  " Credentials for new alert. "
4879  "Diagnostics: Internal Error.",
4880  response_data);
4881  }
4882 
4883  g_string_append (xml, response);
4884  g_free (response);
4885  free_entity (entity);
4886 
4887  g_string_append (xml, "</new_alert>");
4888  return envelope_gmp (connection, credentials, params,
4889  g_string_free (xml, FALSE), response_data);
4890 }

References cmd_response_data_set_status_code(), envelope_gmp(), gmp(), and gsad_message().

Referenced by new_alert_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_alert_gmp()

char* new_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Returns page to create a new alert.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4903 of file gsad_gmp.c.

4905 {
4906  return new_alert (connection, credentials, params, NULL, response_data);
4907 }

References new_alert().

Here is the call graph for this function:

◆ ping_gmp()

char* ping_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get assets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 17071 of file gsad_gmp.c.

17073 {
17074  return action_result (connection, credentials, params, response_data, "ping",
17075  "pong", NULL, NULL);
17076 }

References action_result().

Here is the call graph for this function:

◆ renew_session_gmp()

char* renew_session_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Definition at line 17042 of file gsad_gmp.c.

17044 {
17045  gchar *html;
17046  gchar *message;
17048 
17051 
17052  message = g_strdup_printf ("%ld", user_get_session_timeout (user));
17053 
17054  html = action_result (connection, credentials, params, response_data,
17055  "renew_session", message, NULL, NULL);
17056  g_free (message);
17057  return html;
17058 }

References action_result(), credentials_get_user(), session_add_user(), user_get_session_timeout(), user_get_token(), and user_renew_session().

Here is the call graph for this function:

◆ report_alert_gmp()

char* report_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Run alert for a report.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 8884 of file gsad_gmp.c.

8886 {
8887  entity_t entity;
8888  const char *alert_id, *report_id;
8889  const char *status, *filter;
8890  gchar *response, *html;
8891  int ret;
8892 
8893  alert_id = params_value (params, "alert_id");
8894  report_id = params_value (params, "report_id");
8895 
8896  if ((alert_id == NULL) || (report_id == NULL))
8897  {
8898  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
8899  return gsad_message (credentials, "Bad Request", __FUNCTION__, __LINE__,
8900  "Missing parameter alert_id or report_id. "
8901  "Diagnostics: Required parameter was NULL.",
8902  response_data);
8903  }
8904 
8905  filter = params_value (params, "filter");
8906 
8907  if (filter == NULL && !params_given (params, "filter"))
8908  filter = "first=1 rows=-1"
8909  " result_hosts_only=0"
8910  " apply_overrides=1"
8911  " notes=1 overrides=1"
8912  " sort-reverse=severity";
8913 
8914  ret = gvm_connection_sendf_xml (connection,
8915  "<get_reports"
8916  " report_id=\"%s\""
8917  " ignore_pagination=\"1\""
8918  " filter=\"%s\""
8919  " alert_id=\"%s\"/>",
8920  report_id, filter ? filter : "", alert_id);
8921  if (ret == -1)
8922  {
8923  cmd_response_data_set_status_code (response_data,
8924  MHD_HTTP_INTERNAL_SERVER_ERROR);
8925  return gsad_message (
8926  credentials, "Internal error", __FUNCTION__, __LINE__,
8927  "An internal error occurred while getting a report. "
8928  "The report could not be delivered. "
8929  "Diagnostics: Failure to send command to manager daemon.",
8930  response_data);
8931  }
8932 
8933  if (read_entity_and_text_c (connection, &entity, &response))
8934  {
8935  cmd_response_data_set_status_code (response_data,
8936  MHD_HTTP_INTERNAL_SERVER_ERROR);
8937  return gsad_message (credentials, "Internal error", __FUNCTION__,
8938  __LINE__,
8939  "An internal error occurred while getting a report. "
8940  "The report could not be delivered. "
8941  "Diagnostics: Failure to receive response from "
8942  "manager daemon.",
8943  response_data);
8944  }
8945 
8946  status = entity_attribute (entity, "status");
8947  if ((status == NULL) || (strlen (status) == 0))
8948  {
8949  free_entity (entity);
8950  g_free (response);
8951  cmd_response_data_set_status_code (response_data,
8952  MHD_HTTP_INTERNAL_SERVER_ERROR);
8953  return gsad_message (
8954  credentials, "Internal error", __FUNCTION__, __LINE__,
8955  "An internal error occurred while getting a report. "
8956  "The report could not be delivered. "
8957  "Diagnostics: Failure to parse response from manager daemon.",
8958  response_data);
8959  }
8960  if (strcmp (status, "200"))
8961  {
8962  free_entity (entity);
8963  g_free (response);
8964  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
8965  return gsad_message (credentials, "Failed", __FUNCTION__, __LINE__,
8966  "Running the report alert failed."
8967  "The report could not be delivered.",
8968  response_data);
8969  }
8970 
8971  html = response_from_entity (connection, credentials, params, entity,
8972  "Report Alert", response_data);
8973 
8974  free_entity (entity);
8975  g_free (response);
8976  return html;
8977 }

References cmd_response_data_set_status_code(), gsad_message(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ resource_action()

char* resource_action ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  type,
const char *  action,
cmd_response_data_t *  response_data 
)

Perform action on resource, get next page, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]typeType of resource.
[in]actionAction to perform.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 1749 of file gsad_gmp.c.

1752 {
1753  gchar *html, *response, *param_name;
1754  const char *resource_id;
1755  gchar *cap_action, *cap_type, *get_cmd, *prev_action;
1756 
1757  int ret;
1758  entity_t entity;
1759 
1760  assert (type);
1761 
1762  param_name = g_strdup_printf ("%s_id", type);
1763  resource_id = params_value (params, param_name);
1764 
1765  if (resource_id == NULL)
1766  {
1767  gchar *message;
1768  message = g_strdup_printf (
1769  "An internal error occurred while performing an action. "
1770  "The resource remains the same. "
1771  "Diagnostics: Required parameter %s was NULL.",
1772  param_name);
1773  g_free (param_name);
1774  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
1775  html = gsad_message (credentials, "Internal error", __FUNCTION__,
1776  __LINE__, message, response_data);
1777  g_free (message);
1778  return html;
1779  }
1780  g_free (param_name);
1781 
1782  response = NULL;
1783  entity = NULL;
1784  ret = gmpf (connection, credentials, &response, &entity, response_data,
1785  "<%s_%s %s_id=\"%s\"/>", action, type, type, resource_id);
1786  switch (ret)
1787  {
1788  case 0:
1789  case -1:
1790  break;
1791  case 1:
1792  cmd_response_data_set_status_code (response_data,
1793  MHD_HTTP_INTERNAL_SERVER_ERROR);
1794  return gsad_message (
1795  credentials, "Internal error", __FUNCTION__, __LINE__,
1796  "An internal error occurred while performing an action. "
1797  "The resource remains the same. "
1798  "Diagnostics: Failure to send command to manager daemon.",
1799  response_data);
1800  case 2:
1801  cmd_response_data_set_status_code (response_data,
1802  MHD_HTTP_INTERNAL_SERVER_ERROR);
1803  return gsad_message (
1804  credentials, "Internal error", __FUNCTION__, __LINE__,
1805  "An internal error occurred while performing an action. "
1806  "It is unclear whether the resource has been affected. "
1807  "Diagnostics: Failure to receive response from manager daemon.",
1808  response_data);
1809  default:
1810  cmd_response_data_set_status_code (response_data,
1811  MHD_HTTP_INTERNAL_SERVER_ERROR);
1812  return gsad_message (
1813  credentials, "Internal error", __FUNCTION__, __LINE__,
1814  "An internal error occurred while performing an action. "
1815  "It is unclear whether the resource has been affected. "
1816  "Diagnostics: Internal Error.",
1817  response_data);
1818  }
1819 
1820  if (!gmp_success (entity))
1821  set_http_status_from_entity (entity, response_data);
1822 
1823  cap_action = capitalize (action);
1824  cap_type = capitalize (type);
1825  get_cmd = g_strdup_printf ("get_%ss", type);
1826  prev_action = g_strdup_printf ("%s %s", cap_action, cap_type);
1827  html = response_from_entity (connection, credentials, params, entity,
1828  prev_action, response_data);
1829 
1830  g_free (response);
1831  free_entity (entity);
1832  g_free (cap_action);
1833  g_free (cap_type);
1834  g_free (get_cmd);
1835  g_free (prev_action);
1836 
1837  return html;
1838 }

References capitalize(), cmd_response_data_set_status_code(), gmp_success(), gmpf(), gsad_message(), params_value(), response_from_entity(), and set_http_status_from_entity().

Referenced by resume_task_gmp(), start_task_gmp(), and stop_task_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ response_from_entity()

static gchar * response_from_entity ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
entity_t  entity,
const char *  action,
cmd_response_data_t *  response_data 
)
static

Set redirect or return a basic action_result page based on entity.

Parameters
[in]connectionConnection to manager

Definition at line 783 of file gsad_gmp.c.

786 {
787  gchar *res;
788  entity_t status_details_entity;
789  int success;
790  success = gmp_success (entity);
791 
792  if (!success)
793  {
794  set_http_status_from_entity (entity, response_data);
795  }
796 
797  status_details_entity = entity_child (entity, "status_details");
798 
799  res = action_result (connection, credentials, params, response_data, action,
800  entity_attribute (entity, "status_text"),
801  entity_text (status_details_entity),
802  entity_attribute (entity, "id"));
803  return res;
804 }

References action_result(), gmp_success(), and set_http_status_from_entity().

Referenced by bulk_delete_gmp(), check_modify_config(), clone_gmp(), create_agent_gmp(), create_alert_gmp(), create_asset_gmp(), create_config_gmp(), create_container_task_gmp(), create_credential_gmp(), create_filter_gmp(), create_group_gmp(), create_host_gmp(), create_note_gmp(), create_override_gmp(), create_permission_gmp(), create_port_list_gmp(), create_port_range_gmp(), create_report_gmp(), create_role_gmp(), create_scanner_gmp(), create_schedule_gmp(), create_tag_gmp(), create_target_gmp(), create_task_gmp(), create_ticket_gmp(), create_tls_certificate_gmp(), create_user_gmp(), delete_asset_gmp(), delete_resource(), empty_trashcan_gmp(), import_config_gmp(), import_port_list_gmp(), import_report_format_gmp(), move_task_gmp(), report_alert_gmp(), resource_action(), restore_gmp(), run_wizard_gmp(), save_agent_gmp(), save_alert_gmp(), save_asset_gmp(), save_auth_gmp(), save_container_task_gmp(), save_credential_gmp(), save_filter_gmp(), save_group_gmp(), save_note_gmp(), save_override_gmp(), save_permission_gmp(), save_port_list_gmp(), save_report_format_gmp(), save_role_gmp(), save_scanner_gmp(), save_schedule_gmp(), save_setting_gmp(), save_tag_gmp(), save_target_gmp(), save_task_gmp(), save_ticket_gmp(), save_tls_certificate_gmp(), save_user_gmp(), sync_feed(), test_alert_gmp(), toggle_tag_gmp(), verify_agent_gmp(), and verify_scanner_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restore_gmp()

char* restore_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Restore a resource, get all trash, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6184 of file gsad_gmp.c.

6186 {
6187  GString *xml;
6188  gchar *ret;
6189  entity_t entity;
6190  const char *target_id;
6191 
6192  target_id = params_value (params, "target_id");
6193 
6194  CHECK_VARIABLE_INVALID (target_id, "Restore")
6195 
6196  xml = g_string_new ("");
6197 
6198  /* Restore the resource. */
6199 
6200  if (gvm_connection_sendf (connection,
6201  "<restore"
6202  " id=\"%s\"/>",
6203  target_id)
6204  == -1)
6205  {
6206  g_string_free (xml, TRUE);
6207  cmd_response_data_set_status_code (response_data,
6208  MHD_HTTP_INTERNAL_SERVER_ERROR);
6209  return gsad_message (
6210  credentials, "Internal error", __FUNCTION__, __LINE__,
6211  "An internal error occurred while restoring a resource. "
6212  "The resource was not deleted. "
6213  "Diagnostics: Failure to send command to manager daemon.",
6214  response_data);
6215  }
6216 
6217  if (read_entity_and_string_c (connection, &entity, &xml))
6218  {
6219  g_string_free (xml, TRUE);
6220  cmd_response_data_set_status_code (response_data,
6221  MHD_HTTP_INTERNAL_SERVER_ERROR);
6222  return gsad_message (
6223  credentials, "Internal error", __FUNCTION__, __LINE__,
6224  "An internal error occurred while restoring a resource. "
6225  "It is unclear whether the resource has been restored or not. "
6226  "Diagnostics: Failure to read response from manager daemon.",
6227  response_data);
6228  }
6229 
6230  /* Cleanup, and return trash page. */
6231 
6232  ret = response_from_entity (connection, credentials, params, entity,
6233  "Restore", response_data);
6234  free_entity (entity);
6235  g_string_free (xml, FALSE);
6236  return ret;
6237 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ resume_task_gmp()

char* resume_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Resume a task, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2858 of file gsad_gmp.c.

2860 {
2861  return resource_action (connection, credentials, params, "task", "resume",
2862  response_data);
2863 }

References resource_action().

Here is the call graph for this function:

◆ run_wizard_gmp()

char* run_wizard_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Run a wizard and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 11291 of file gsad_gmp.c.

11293 {
11294  const char *name;
11295  int ret;
11296  GString *run;
11297  param_t *param;
11298  gchar *param_name, *html, *response;
11299  params_iterator_t iter;
11300  params_t *wizard_params;
11301  entity_t entity;
11302 
11303  /* The naming is a bit subtle here, because the HTTP request
11304  * parameters are called "param"s and so are the GMP wizard
11305  * parameters. */
11306 
11307  name = params_value (params, "name");
11308  if (name == NULL)
11309  {
11310  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
11311  return gsad_message (
11312  credentials, "Internal error", __FUNCTION__, __LINE__,
11313  "An internal error occurred while trying to start a wizard. "
11314  "Diagnostics: Required parameter 'name' was NULL.",
11315  response_data);
11316  }
11317  run = g_string_new ("<run_wizard>");
11318 
11319  g_string_append_printf (run,
11320  "<name>%s</name>"
11321  "<params>",
11322  name);
11323 
11324  wizard_params = params_values (params, "event_data:");
11325  if (wizard_params)
11326  {
11327  params_iterator_init (&iter, wizard_params);
11328  while (params_iterator_next (&iter, &param_name, &param))
11329  xml_string_append (run,
11330  "<param>"
11331  "<name>%s</name>"
11332  "<value>%s</value>"
11333  "</param>",
11334  param_name, param->value);
11335  }
11336 
11337  g_string_append (run, "</params></run_wizard>");
11338 
11339  response = NULL;
11340  entity = NULL;
11341  ret =
11342  gmp (connection, credentials, &response, &entity, response_data, run->str);
11343  g_string_free (run, TRUE);
11344  switch (ret)
11345  {
11346  case 0:
11347  case -1:
11348  break;
11349  case 1:
11350  cmd_response_data_set_status_code (response_data,
11351  MHD_HTTP_INTERNAL_SERVER_ERROR);
11352  return gsad_message (
11353  credentials, "Internal error", __FUNCTION__, __LINE__,
11354  "An internal error occurred while running a wizard. "
11355  "The wizard did not start. "
11356  "Diagnostics: Failure to send command to manager daemon.",
11357  response_data);
11358  case 2:
11359  cmd_response_data_set_status_code (response_data,
11360  MHD_HTTP_INTERNAL_SERVER_ERROR);
11361  return gsad_message (
11362  credentials, "Internal error", __FUNCTION__, __LINE__,
11363  "An internal error occurred while running a wizard. "
11364  "It is unclear whether the wizard started or not. "
11365  "Diagnostics: Failure to receive response from manager daemon.",
11366  response_data);
11367  default:
11368  cmd_response_data_set_status_code (response_data,
11369  MHD_HTTP_INTERNAL_SERVER_ERROR);
11370  return gsad_message (credentials, "Internal error", __FUNCTION__,
11371  __LINE__,
11372  "An internal error occurred while running a wizard. "
11373  "It is unclear whether the wizard started or not. "
11374  "Diagnostics: Internal Error.",
11375  response_data);
11376  }
11377 
11378  html = response_from_entity (connection, credentials, params, entity,
11379  "Run Wizard", response_data);
11380  free_entity (entity);
11381  g_free (response);
11382  return html;
11383 }

References cmd_response_data_set_status_code(), gmp(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), and param::value.

Here is the call graph for this function:

◆ save_agent_gmp()

char* save_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a agent, get all agents, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4243 of file gsad_gmp.c.

4245 {
4246  int ret;
4247  gchar *html, *response;
4248  const char *agent_id, *name, *comment;
4249  entity_t entity;
4250 
4251  agent_id = params_value (params, "agent_id");
4252  name = params_value (params, "name");
4253  comment = params_value (params, "comment");
4254 
4255  CHECK_VARIABLE_INVALID (agent_id, "Save Agent");
4256  CHECK_VARIABLE_INVALID (name, "Save Agent");
4257  CHECK_VARIABLE_INVALID (comment, "Save Agent");
4258 
4259  /* Modify the agent. */
4260 
4261  response = NULL;
4262  entity = NULL;
4263  ret = gmpf (connection, credentials, &response, &entity, response_data,
4264  "<modify_agent agent_id=\"%s\">"
4265  "<name>%s</name>"
4266  "<comment>%s</comment>"
4267  "</modify_agent>",
4268  agent_id, name, comment);
4269 
4270  switch (ret)
4271  {
4272  case 0:
4273  case -1:
4274  break;
4275  case 1:
4276  cmd_response_data_set_status_code (response_data,
4277  MHD_HTTP_INTERNAL_SERVER_ERROR);
4278  return gsad_message (
4279  credentials, "Internal error", __FUNCTION__, __LINE__,
4280  "An internal error occurred while saving a agent. "
4281  "The agent was not saved. "
4282  "Diagnostics: Failure to send command to manager daemon.",
4283  response_data);
4284  case 2:
4285  cmd_response_data_set_status_code (response_data,
4286  MHD_HTTP_INTERNAL_SERVER_ERROR);
4287  return gsad_message (
4288  credentials, "Internal error", __FUNCTION__, __LINE__,
4289  "An internal error occurred while saving a agent. "
4290  "It is unclear whether the agent has been saved or not. "
4291  "Diagnostics: Failure to receive response from manager daemon.",
4292  response_data);
4293  default:
4294  cmd_response_data_set_status_code (response_data,
4295  MHD_HTTP_INTERNAL_SERVER_ERROR);
4296  return gsad_message (
4297  credentials, "Internal error", __FUNCTION__, __LINE__,
4298  "An internal error occurred while saving a agent. "
4299  "It is unclear whether the agent has been saved or not. "
4300  "Diagnostics: Internal Error.",
4301  response_data);
4302  }
4303 
4304  html = response_from_entity (connection, credentials, params, entity,
4305  "Save Agent", response_data);
4306  free_entity (entity);
4307  g_free (response);
4308  return html;
4309 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_alert_gmp()

char* save_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify an alert, get all alerts, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5633 of file gsad_gmp.c.

5635 {
5636  GString *xml;
5637  int ret;
5638  gchar *html, *response;
5639  const char *name, *comment, *alert_id;
5640  const char *event, *condition, *method;
5641  const char *filter_id, *active;
5642  params_t *event_data, *condition_data, *method_data, *report_formats;
5643  entity_t entity;
5644 
5645  name = params_value (params, "name");
5646  comment = params_value (params, "comment");
5647  condition = params_value (params, "condition");
5648  event = params_value (params, "event");
5649  method = params_value (params, "method");
5650  alert_id = params_value (params, "alert_id");
5651  filter_id = params_value (params, "filter_id");
5652  active = params_value (params, "active");
5653 
5654  if (filter_id == NULL || str_equal (filter_id, ""))
5655  {
5656  filter_id = FILT_ID_NONE;
5657  }
5658 
5659  CHECK_VARIABLE_INVALID (name, "Save Alert");
5660  CHECK_VARIABLE_INVALID (comment, "Save Alert");
5661  CHECK_VARIABLE_INVALID (alert_id, "Save Alert");
5662  CHECK_VARIABLE_INVALID (condition, "Save Alert");
5663  CHECK_VARIABLE_INVALID (event, "Save Alert");
5664  CHECK_VARIABLE_INVALID (method, "Save Alert");
5665  CHECK_VARIABLE_INVALID (active, "Save Alert");
5666 
5667  xml = g_string_new ("");
5668 
5669  /* Modify the alert. */
5670 
5671  event_data = params_values (params, "event_data:");
5672  condition_data = params_values (params, "condition_data:");
5673  method_data = params_values (params, "method_data:");
5674  report_formats = params_values (params, "report_format_ids:");
5675 
5676  if (str_equal (event, EVENT_TYPE_NEW_SECINFO) && event_data)
5677  {
5678  params_iterator_t iter;
5679  char *name;
5680  param_t *param;
5681 
5682  params_iterator_init (&iter, event_data);
5683  while (params_iterator_next (&iter, &name, &param))
5684  if (str_equal (name, "feed_event") && param->value
5685  && str_equal (param->value, "updated"))
5686  {
5688  break;
5689  }
5690  }
5691 
5692  xml_string_append (xml,
5693  "<modify_alert alert_id=\"%s\">"
5694  "<name>%s</name>"
5695  "<filter id=\"%s\"/>"
5696  "<active>%s</active>"
5697  "<comment>%s</comment>"
5698  "<event>%s",
5699  alert_id, name, filter_id, active, comment ? comment : "",
5700  event);
5701 
5702  append_alert_event_data (xml, event_data, event);
5703 
5704  xml_string_append (xml,
5705  "</event>"
5706  "<method>%s",
5707  method);
5708 
5709  append_alert_method_data (xml, method_data, method, report_formats);
5710 
5711  xml_string_append (xml,
5712  "</method>"
5713  "<condition>%s",
5714  condition);
5715 
5716  append_alert_condition_data (xml, condition_data, condition);
5717 
5718  xml_string_append (xml, "</condition>"
5719  "</modify_alert>");
5720 
5721  ret =
5722  gmp (connection, credentials, &response, &entity, response_data, xml->str);
5723  g_string_free (xml, TRUE);
5724  switch (ret)
5725  {
5726  case 0:
5727  case -1:
5728  break;
5729  case 1:
5730  cmd_response_data_set_status_code (response_data,
5731  MHD_HTTP_INTERNAL_SERVER_ERROR);
5732  return gsad_message (
5733  credentials, "Internal error", __FUNCTION__, __LINE__,
5734  "An internal error occurred while saving a new alert. "
5735  "No new alert was created. "
5736  "Diagnostics: Failure to send command to manager daemon.",
5737  response_data);
5738  case 2:
5739  cmd_response_data_set_status_code (response_data,
5740  MHD_HTTP_INTERNAL_SERVER_ERROR);
5741  return gsad_message (
5742  credentials, "Internal error", __FUNCTION__, __LINE__,
5743  "An internal error occurred while saving a new alert. "
5744  "It is unclear whether the alert has been created or not. "
5745  "Diagnostics: Failure to receive response from manager daemon.",
5746  response_data);
5747  default:
5748  cmd_response_data_set_status_code (response_data,
5749  MHD_HTTP_INTERNAL_SERVER_ERROR);
5750  return gsad_message (
5751  credentials, "Internal error", __FUNCTION__, __LINE__,
5752  "An internal error occurred while saving a new alert. "
5753  "It is unclear whether the alert has been created or not. "
5754  "Diagnostics: Internal Error.",
5755  response_data);
5756  }
5757 
5758  html = response_from_entity (connection, credentials, params, entity,
5759  "Save Alert", response_data);
5760  free_entity (entity);
5761  g_free (response);
5762  return html;
5763 }

References append_alert_condition_data(), append_alert_event_data(), append_alert_method_data(), CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), EVENT_TYPE_NEW_SECINFO, EVENT_TYPE_UPDATED_SECINFO, FILT_ID_NONE, gmp(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), str_equal(), and param::value.

Here is the call graph for this function:

◆ save_asset_gmp()

char* save_asset_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify an asset, get all assets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16508 of file gsad_gmp.c.

16510 {
16511  int ret;
16512  gchar *html, *response;
16513  const char *asset_id, *comment;
16514  entity_t entity;
16515 
16516  asset_id = params_value (params, "asset_id");
16517  comment = params_value (params, "comment");
16518 
16519  CHECK_VARIABLE_INVALID (asset_id, "Save Asset");
16520  CHECK_VARIABLE_INVALID (comment, "Save Asset");
16521 
16522  /* Modify the asset. */
16523 
16524  response = NULL;
16525  entity = NULL;
16526  ret = gmpf (connection, credentials, &response, &entity, response_data,
16527  "<modify_asset asset_id=\"%s\">"
16528  "<comment>%s</comment>"
16529  "</modify_asset>",
16530  asset_id, comment);
16531 
16532  switch (ret)
16533  {
16534  case 0:
16535  case -1:
16536  break;
16537  case 1:
16538  cmd_response_data_set_status_code (response_data,
16539  MHD_HTTP_INTERNAL_SERVER_ERROR);
16540  return gsad_message (
16541  credentials, "Internal error", __FUNCTION__, __LINE__,
16542  "An internal error occurred while saving an asset. "
16543  "The asset was not saved. "
16544  "Diagnostics: Failure to send command to manager daemon.",
16545  response_data);
16546  case 2:
16547  cmd_response_data_set_status_code (response_data,
16548  MHD_HTTP_INTERNAL_SERVER_ERROR);
16549  return gsad_message (
16550  credentials, "Internal error", __FUNCTION__, __LINE__,
16551  "An internal error occurred while saving an asset. "
16552  "It is unclear whether the asset has been saved or not. "
16553  "Diagnostics: Failure to receive response from manager daemon.",
16554  response_data);
16555  default:
16556  cmd_response_data_set_status_code (response_data,
16557  MHD_HTTP_INTERNAL_SERVER_ERROR);
16558  return gsad_message (
16559  credentials, "Internal error", __FUNCTION__, __LINE__,
16560  "An internal error occurred while saving an asset. "
16561  "It is unclear whether the asset has been saved or not. "
16562  "Diagnostics: Internal Error.",
16563  response_data);
16564  }
16565 
16566  html = response_from_entity (connection, credentials, params, entity,
16567  "Save Asset", response_data);
16568  free_entity (entity);
16569  g_free (response);
16570  return html;
16571 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_auth_gmp()

char* save_auth_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save authentication settings.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
XML enveloped list of users and configuration.
Warning
authdn shall contain a single s, handle with care.
authdn shall contain a single s, handle with care.
authdn shall contain a single s, handle with care.

Definition at line 15379 of file gsad_gmp.c.

15381 {
15382  int ret;
15383  entity_t entity = NULL;
15384  char *html, *response = NULL, *truefalse;
15385  const char *method;
15386 
15387  if (params_value (params, "enable")
15388  && (strcmp (params_value (params, "enable"), "1") == 0))
15389  truefalse = "true";
15390  else
15391  truefalse = "false";
15392 
15393  method = params_value (params, "group");
15394  CHECK_VARIABLE_INVALID (method, "Save Authentication");
15395  if (!strcmp (method, "method:ldap_connect"))
15396  {
15397  const char *ldaphost, *authdn, *certificate;
15398  ldaphost = params_value (params, "ldaphost");
15399  authdn = params_value (params, "authdn");
15400  certificate = params_value (params, "certificate");
15401 
15402  CHECK_VARIABLE_INVALID (ldaphost, "Save Authentication");
15403  CHECK_VARIABLE_INVALID (authdn, "Save Authentication");
15404  if (params_given (params, "certificate") && strcmp (certificate, ""))
15405  {
15406  CHECK_VARIABLE_INVALID (certificate, "Save Authentication");
15408  ret =
15409  gmpf (connection, credentials, &response, &entity, response_data,
15410  "<modify_auth>"
15411  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
15412  AUTH_CONF_SETTING ("ldaphost", "%s")
15413  AUTH_CONF_SETTING ("authdn", "%s")
15414  AUTH_CONF_SETTING ("cacert", "%s") "</group>"
15415  "</modify_auth>",
15416  method, truefalse, ldaphost, authdn, certificate);
15417  }
15418  else
15420  ret = gmpf (connection, credentials, &response, &entity, response_data,
15421  "<modify_auth>"
15422  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
15423  AUTH_CONF_SETTING ("ldaphost", "%s")
15424  AUTH_CONF_SETTING ("authdn", "%s") "</group>"
15425  "</modify_auth>",
15426  method, truefalse, ldaphost, authdn);
15427  }
15428  else if (!strcmp (method, "method:radius_connect"))
15429  {
15430  const char *radiushost, *radiuskey;
15431  radiushost = params_value (params, "radiushost");
15432  radiuskey = params_value (params, "radiuskey");
15433 
15434  CHECK_VARIABLE_INVALID (radiushost, "Save Authentication");
15435  CHECK_VARIABLE_INVALID (radiuskey, "Save Authentication");
15437  ret = gmpf (connection, credentials, &response, &entity, response_data,
15438  "<modify_auth>"
15439  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
15440  AUTH_CONF_SETTING ("radiushost", "%s")
15441  AUTH_CONF_SETTING ("radiuskey", "%s") "</group>"
15442  "</modify_auth>",
15443  method, truefalse, radiushost, radiuskey);
15444  }
15445  else
15446  {
15447  return message_invalid (connection, credentials, params, response_data,
15448  "Given method was invalid", "Save auth");
15449  }
15450 
15451  switch (ret)
15452  {
15453  case 0:
15454  case -1:
15455  break;
15456  case 1:
15457  cmd_response_data_set_status_code (response_data,
15458  MHD_HTTP_INTERNAL_SERVER_ERROR);
15459  return gsad_message (
15460  credentials, "Internal error", __FUNCTION__, __LINE__,
15461  "An internal error occurred while saving the auth settings. "
15462  "The settings were not saved. "
15463  "Diagnostics: Failure to send command to manager daemon.",
15464  response_data);
15465  case 2:
15466  cmd_response_data_set_status_code (response_data,
15467  MHD_HTTP_INTERNAL_SERVER_ERROR);
15468  return gsad_message (
15469  credentials, "Internal error", __FUNCTION__, __LINE__,
15470  "An internal error occurred while saving the auth settings. "
15471  "It is unclear whether the settings have been saved or not. "
15472  "Diagnostics: Failure to receive response from manager daemon.",
15473  response_data);
15474  default:
15475  cmd_response_data_set_status_code (response_data,
15476  MHD_HTTP_INTERNAL_SERVER_ERROR);
15477  return gsad_message (
15478  credentials, "Internal error", __FUNCTION__, __LINE__,
15479  "An internal error occurred while saving the auth settings. "
15480  "It is unclear whether the settings have been saved or not. "
15481  "Diagnostics: Internal Error.",
15482  response_data);
15483  }
15484 
15485  html =
15486  response_from_entity (connection, credentials, params, entity,
15487  "Save Authentication Configuration", response_data);
15488  free_entity (entity);
15489  g_free (response);
15490  return html;
15491 }

References AUTH_CONF_SETTING, CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), message_invalid(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_config_family_gmp()

char* save_config_family_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Get details of an NVT for a config, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7757 of file gsad_gmp.c.

7760 {
7761  char *ret;
7762  const char *config_id, *family;
7763  params_t *nvts;
7764 
7765  config_id = params_value (params, "config_id");
7766  family = params_value (params, "family");
7767 
7768  CHECK_VARIABLE_INVALID (config_id, "Save Config Family")
7769  CHECK_VARIABLE_INVALID (family, "Save Config Family")
7770 
7771  /* Set the NVT selection. */
7772 
7773  if (gvm_connection_sendf (connection,
7774  "<modify_config config_id=\"%s\">"
7775  "<nvt_selection>"
7776  "<family>%s</family>",
7777  config_id, family)
7778  == -1)
7779  {
7780  cmd_response_data_set_status_code (response_data,
7781  MHD_HTTP_INTERNAL_SERVER_ERROR);
7782  return gsad_message (
7783  credentials, "Internal error", __FUNCTION__, __LINE__,
7784  "An internal error occurred while saving a config. "
7785  "It is unclear whether the entire config has been saved. "
7786  "Diagnostics: Failure to send command to manager daemon.",
7787  response_data);
7788  }
7789 
7790  nvts = params_values (params, "nvt:");
7791  if (nvts)
7792  {
7793  params_iterator_t iter;
7794  char *name;
7795  param_t *param;
7796 
7797  params_iterator_init (&iter, nvts);
7798  while (params_iterator_next (&iter, &name, &param))
7799  if (gvm_connection_sendf (connection, "<nvt oid=\"%s\"/>", name) == -1)
7800  {
7801  cmd_response_data_set_status_code (response_data,
7802  MHD_HTTP_INTERNAL_SERVER_ERROR);
7803  return gsad_message (
7804  credentials, "Internal error", __FUNCTION__, __LINE__,
7805  "An internal error occurred while saving a config. "
7806  "It is unclear whether the entire config has been saved. "
7807  "Diagnostics: Failure to send command to manager daemon.",
7808  response_data);
7809  }
7810  }
7811 
7812  if (gvm_connection_sendf (connection, "</nvt_selection>"
7813  "</modify_config>")
7814  == -1)
7815  {
7816  cmd_response_data_set_status_code (response_data,
7817  MHD_HTTP_INTERNAL_SERVER_ERROR);
7818  return gsad_message (
7819  credentials, "Internal error", __FUNCTION__, __LINE__,
7820  "An internal error occurred while saving a config. "
7821  "It is unclear whether the entire config has been saved. "
7822  "Diagnostics: Failure to send command to manager daemon.",
7823  response_data);
7824  }
7825 
7826  ret =
7827  check_modify_config (connection, credentials, params, "get_config_family",
7828  "edit_config_family", NULL, response_data);
7829 
7830  return ret;
7831 }

References check_modify_config(), CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), and params_values().

Here is the call graph for this function:

◆ save_config_gmp()

char* save_config_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save details of an NVT for a config and return the next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Following page.

Definition at line 7346 of file gsad_gmp.c.

7348 {
7349  int gmp_ret;
7350  char *ret, *osp_ret;
7351  params_t *preferences, *selects, *trends;
7352  const char *config_id, *name, *comment, *scanner_id;
7353  int success;
7354 
7355  config_id = params_value (params, "config_id");
7356  name = params_value (params, "name");
7357  comment = params_value (params, "comment");
7358  scanner_id = params_value (params, "scanner_id");
7359 
7360  CHECK_VARIABLE_INVALID (config_id, "Save Config");
7361  CHECK_VARIABLE_INVALID (name, "Save Config");
7362  CHECK_VARIABLE_INVALID (comment, "Save Config");
7363 
7364  /* Save name and comment. */
7365 
7366  if (scanner_id)
7367  gmp_ret = gvm_connection_sendf_xml (connection,
7368  "<modify_config config_id=\"%s\">"
7369  "<name>%s</name>"
7370  "<comment>%s</comment>"
7371  "<scanner>%s</scanner>"
7372  "</modify_config>",
7373  params_value (params, "config_id"),
7374  name, comment, scanner_id);
7375  else
7376  gmp_ret = gvm_connection_sendf_xml (connection,
7377  "<modify_config config_id=\"%s\">"
7378  "<name>%s</name>"
7379  "<comment>%s</comment>"
7380  "</modify_config>",
7381  params_value (params, "config_id"),
7382  name, comment);
7383 
7384  if (gmp_ret == -1)
7385  {
7386  cmd_response_data_set_status_code (response_data,
7387  MHD_HTTP_INTERNAL_SERVER_ERROR);
7388  return gsad_message (
7389  credentials, "Internal error", __FUNCTION__, __LINE__,
7390  "An internal error occurred while saving a config. "
7391  "It is unclear whether the entire config has been saved. "
7392  "Diagnostics: Failure to send command to manager daemon.",
7393  response_data);
7394  }
7395 
7396  ret = check_modify_config (connection, credentials, params, "get_config",
7397  "edit_config", &success, response_data);
7398  if (success == 0)
7399  {
7400  return ret;
7401  }
7402 
7403  /* Save preferences. */
7404 
7405  preferences = params_values (params, "preference:");
7406  if (preferences)
7407  {
7408  params_iterator_t iter;
7409  char *param_name;
7410  param_t *param;
7411 
7412  params_iterator_init (&iter, preferences);
7413  while (params_iterator_next (&iter, &param_name, &param))
7414  {
7415  gchar *value;
7416 
7417  value = param->value_size ? g_base64_encode ((guchar *) param->value,
7418  param->value_size)
7419  : g_strdup ("");
7420 
7421  if (gvm_connection_sendf (connection,
7422  "<modify_config config_id=\"%s\">"
7423  "<preference>"
7424  "<name>%s</name>"
7425  "<value>%s</value>"
7426  "</preference>"
7427  "</modify_config>",
7428  params_value (params, "config_id"),
7429  param_name, value)
7430  == -1)
7431  {
7432  g_free (value);
7434  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
7435  return gsad_message (
7436  credentials, "Internal error", __FUNCTION__, __LINE__,
7437  "An internal error occurred while saving a config. "
7438  "It is unclear whether the entire config has been saved. "
7439  "Diagnostics: Failure to send command to manager daemon.",
7440  response_data);
7441  }
7442  g_free (value);
7443  g_free (ret);
7444 
7445  ret =
7446  check_modify_config (connection, credentials, params, "get_config",
7447  "edit_config", &success, response_data);
7448  if (success == 0)
7449  {
7450  return ret;
7451  }
7452  }
7453  }
7454 
7455  /* OSP config file preference. */
7456  osp_ret = save_osp_prefs (connection, credentials, params, "get_config",
7457  "edit_config", &success, response_data);
7458  if (osp_ret)
7459  {
7460  g_free (ret);
7461  ret = osp_ret;
7462  }
7463 
7464  if (success == 0)
7465  {
7466  if (osp_ret == NULL)
7467  {
7468  cmd_response_data_set_status_code (response_data,
7469  MHD_HTTP_INTERNAL_SERVER_ERROR);
7470  return gsad_message (
7471  credentials, "Internal error", __FUNCTION__, __LINE__,
7472  "An internal error occurred while saving a config. "
7473  "It is unclear whether the entire config has been saved. "
7474  "Diagnostics: save_osp_prefs returned NULL unexpectedly.",
7475  response_data);
7476  }
7477  return ret;
7478  }
7479 
7480  /* Update the config. */
7481 
7482  trends = params_values (params, "trend:");
7483  selects = params_values (params, "select:");
7484 
7485  if (trends || selects || params_value (params, "trend"))
7486  {
7487  if (gvm_connection_sendf (
7488  connection,
7489  "<modify_config config_id=\"%s\">"
7490  "<family_selection>"
7491  "<growing>%i</growing>",
7492  params_value (params, "config_id"),
7493  trends && params_value (params, "trend")
7494  && strcmp (params_value (params, "trend"), "0"))
7495  == -1)
7496  {
7497  cmd_response_data_set_status_code (response_data,
7498  MHD_HTTP_INTERNAL_SERVER_ERROR);
7499  return gsad_message (
7500  credentials, "Internal error", __FUNCTION__, __LINE__,
7501  "An internal error occurred while saving a config. "
7502  "It is unclear whether the entire config has been saved. "
7503  "Diagnostics: Failure to send command to manager daemon.",
7504  response_data);
7505  }
7506 
7507  if (selects)
7508  {
7509  gchar *family;
7510  params_iterator_t iter;
7511  param_t *param;
7512 
7513  params_iterator_init (&iter, selects);
7514  while (params_iterator_next (&iter, &family, &param))
7515  if (gvm_connection_sendf (connection,
7516  "<family>"
7517  "<name>%s</name>"
7518  "<all>1</all>"
7519  "<growing>%i</growing>"
7520  "</family>",
7521  family,
7522  trends && member1 (trends, family))
7523  == -1)
7524  {
7526  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
7527  return gsad_message (
7528  credentials, "Internal error", __FUNCTION__, __LINE__,
7529  "An internal error occurred while saving a config. "
7530  "It is unclear whether the entire config has been saved. "
7531  "Diagnostics: Failure to send command to manager daemon.",
7532  response_data);
7533  }
7534  }
7535 
7536  if (trends)
7537  {
7538  gchar *family;
7539  params_iterator_t iter;
7540  param_t *param;
7541 
7542  params_iterator_init (&iter, trends);
7543  while (params_iterator_next (&iter, &family, &param))
7544  {
7545  if (param->value_size == 0)
7546  continue;
7547  if (param->value[0] == '0')
7548  continue;
7549  if (selects && member (selects, family))
7550  continue;
7551  if (gvm_connection_sendf (connection,
7552  "<family>"
7553  "<name>%s</name>"
7554  "<all>0</all>"
7555  "<growing>1</growing>"
7556  "</family>",
7557  family)
7558  == -1)
7559  {
7561  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
7562  return gsad_message (
7563  credentials, "Internal error", __FUNCTION__, __LINE__,
7564  "An internal error occurred while saving a config. "
7565  "It is unclear whether the entire config has been saved. "
7566  "Diagnostics: Failure to send command to manager daemon.",
7567  response_data);
7568  }
7569  }
7570  }
7571 
7572  if (gvm_connection_sendf (connection, "</family_selection>"
7573  "</modify_config>")
7574  == -1)
7575  {
7576  cmd_response_data_set_status_code (response_data,
7577  MHD_HTTP_INTERNAL_SERVER_ERROR);
7578  return gsad_message (
7579  credentials, "Internal error", __FUNCTION__, __LINE__,
7580  "An internal error occurred while saving a config. "
7581  "It is unclear whether the entire config has been saved. "
7582  "Diagnostics: Failure to send command to manager daemon.",
7583  response_data);
7584  }
7585 
7586  g_free (ret);
7587  ret = check_modify_config (connection, credentials, params, "get_config",
7588  "edit_config", NULL, response_data);
7589  }
7590  return ret;
7591 }

References check_modify_config(), CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), member(), member1(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), save_osp_prefs(), param::value, and param::value_size.

Here is the call graph for this function:

◆ save_config_nvt_gmp()

char* save_config_nvt_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save NVT prefs for a config, get NVT details, envelope result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7929 of file gsad_gmp.c.

7931 {
7932  params_t *preferences;
7933  const char *config_id;
7934  int success;
7935  char *modify_config_ret;
7936 
7937  modify_config_ret = NULL;
7938  config_id = params_value (params, "config_id");
7939 
7940  preferences = params_values (params, "preference:");
7941  if (preferences)
7942  {
7943  param_t *preference;
7944  gchar *preference_name;
7945  params_iterator_t iter;
7946 
7947  /* Save preferences. */
7948 
7949  params_iterator_init (&iter, preferences);
7950  while (params_iterator_next (&iter, &preference_name, &preference))
7951  {
7952  int ret, is_timeout = 0;
7953  gchar *value, **splits;
7954 
7955  g_free (modify_config_ret);
7956  modify_config_ret = NULL;
7957 
7958  /* Passwords and files have checkboxes to control whether they
7959  * must be reset. This works around the need for the Manager to
7960  * send the actual password or show the actual file. */
7961 
7962  /* OID:PrefID:PrefType:PrefName value */
7963  splits = g_strsplit (preference_name, ":", 4);
7964  if (splits && splits[0] && splits[1] && splits[2] && splits[3])
7965  {
7966  if (!strcmp (splits[2], "password"))
7967  {
7968  int found = 0;
7969  params_t *passwords;
7970 
7971  passwords = params_values (params, "password:");
7972  if (passwords)
7973  {
7974  param_t *password;
7975  gchar *password_name;
7976  params_iterator_t password_params;
7977 
7978  params_iterator_init (&password_params, passwords);
7979  while (params_iterator_next (&password_params,
7980  &password_name, &password))
7981  if (strcmp (password_name, preference_name) == 0)
7982  {
7983  found = 1;
7984  break;
7985  }
7986  }
7987  if (found == 0)
7988  {
7989  /* Skip modifying the password preference. */
7990  g_strfreev (splits);
7991  continue;
7992  }
7993  }
7994  else if (!strcmp (splits[2], "file"))
7995  {
7996  int found = 0;
7997  params_t *files;
7998 
7999  files = params_values (params, "file:");
8000  if (files)
8001  {
8002  param_t *file;
8003  gchar *file_name;
8004  params_iterator_t file_params;
8005 
8006  params_iterator_init (&file_params, files);
8007  while (
8008  params_iterator_next (&file_params, &file_name, &file))
8009  if (strcmp (file_name, preference_name) == 0)
8010  {
8011  found = 1;
8012  break;
8013  }
8014  }
8015  if (found == 0)
8016  {
8017  /* Skip modifying the file preference. */
8018  g_strfreev (splits);
8019  continue;
8020  }
8021  }
8022  else if (!strcmp (splits[2], "scanner"))
8023  {
8024  /* Presume it's the timeout. */
8025  is_timeout = 1;
8026  }
8027  }
8028  g_strfreev (splits);
8029 
8030  value = preference->value_size
8031  ? g_base64_encode ((guchar *) preference->value,
8032  preference->value_size)
8033  : g_strdup ("");
8034 
8035  if (is_timeout)
8036  {
8037  const char *timeout;
8038  gchar *preference_name_escaped;
8039 
8040  timeout = params_value (params, "timeout");
8041 
8042  if (timeout == NULL)
8043  {
8044  g_free (value);
8045  cmd_response_data_set_status_code (response_data,
8046  MHD_HTTP_BAD_REQUEST);
8047  return gsad_message (
8048  credentials, "Internal error", __FUNCTION__, __LINE__,
8049  "An internal error occurred while saving a config. "
8050  "It is unclear whether the entire config has been saved. "
8051  "Diagnostics: Required parameter was NULL.",
8052  response_data);
8053  }
8054 
8055  preference_name_escaped =
8056  g_markup_escape_text (preference_name, -1);
8057 
8058  if (strcmp (timeout, "0") == 0)
8059  /* Leave out the value to clear the preference. */
8060  ret = gvm_connection_sendf (connection,
8061  "<modify_config"
8062  " config_id=\"%s\">"
8063  "<preference>"
8064  "<name>%s</name>"
8065  "</preference>"
8066  "</modify_config>",
8067  config_id, preference_name_escaped);
8068  else
8069  ret = gvm_connection_sendf (connection,
8070  "<modify_config"
8071  " config_id=\"%s\">"
8072  "<preference>"
8073  "<name>%s</name>"
8074  "<value>%s</value>"
8075  "</preference>"
8076  "</modify_config>",
8077  config_id, preference_name_escaped,
8078  value);
8079 
8080  g_free (preference_name_escaped);
8081  }
8082  else
8083  {
8084  gchar *preference_name_escaped;
8085  preference_name_escaped =
8086  g_markup_escape_text (preference_name, -1);
8087  ret =
8088  gvm_connection_sendf (connection,
8089  "<modify_config"
8090  " config_id=\"%s\">"
8091  "<preference>"
8092  "<nvt oid=\"%s\"/>"
8093  "<name>%s</name>"
8094  "<value>%s</value>"
8095  "</preference>"
8096  "</modify_config>",
8097  config_id, params_value (params, "oid"),
8098  preference_name_escaped, value);
8099  g_free (preference_name_escaped);
8100  }
8101 
8102  if (ret == -1)
8103  {
8104  g_free (value);
8106  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8107  return gsad_message (
8108  credentials, "Internal error", __FUNCTION__, __LINE__,
8109  "An internal error occurred while saving a config. "
8110  "It is unclear whether the entire config has been saved. "
8111  "Diagnostics: Failure to send command to manager daemon.",
8112  response_data);
8113  }
8114  g_free (value);
8115 
8116  modify_config_ret = check_modify_config (
8117  connection, credentials, params, "get_config_nvt",
8118  "save_config_nvt", &success, response_data);
8119  if (success == 0)
8120  {
8121  return modify_config_ret;
8122  }
8123  }
8124  }
8125 
8126  /* Create a generic success message in case modify_config_ret is NULL,
8127  * which could happen if the last preference is a password and skipped.
8128  * This assumes that messages are returned earlier in case of errors. */
8129  modify_config_ret = action_result (
8130  connection, credentials, params, response_data, "Modify Config",
8131  "All NVT preferences modified successfully", NULL, NULL);
8132 
8133  return modify_config_ret;
8134 }

References action_result(), check_modify_config(), cmd_response_data_set_status_code(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::value, and param::value_size.

Here is the call graph for this function:

◆ save_container_task_gmp()

char* save_container_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save container task, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2703 of file gsad_gmp.c.

2706 {
2707  gchar *format, *response, *html;
2708  const char *comment, *name, *task_id;
2709  const char *in_assets, *auto_delete, *auto_delete_data;
2710  int ret;
2711  entity_t entity;
2712 
2713  comment = params_value (params, "comment");
2714  in_assets = params_value (params, "in_assets");
2715  name = params_value (params, "name");
2716  task_id = params_value (params, "task_id");
2717  auto_delete = params_value (params, "auto_delete");
2718  auto_delete_data = params_value (params, "auto_delete_data");
2719  CHECK_VARIABLE_INVALID (name, "Save Task")
2720  CHECK_VARIABLE_INVALID (comment, "Save Task")
2721  CHECK_VARIABLE_INVALID (task_id, "Save Task")
2722  CHECK_VARIABLE_INVALID (in_assets, "Save Task")
2723  CHECK_VARIABLE_INVALID (auto_delete, "Save Task");
2724  CHECK_VARIABLE_INVALID (auto_delete_data, "Save Task");
2725 
2726  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
2727  "<name>%%s</name>"
2728  "<comment>%%s</comment>"
2729  "<preferences>"
2730  "<preference>"
2731  "<scanner_name>in_assets</scanner_name>"
2732  "<value>%%s</value>"
2733  "</preference>"
2734  "<preference>"
2735  "<scanner_name>auto_delete</scanner_name>"
2736  "<value>%%s</value>"
2737  "</preference>"
2738  "<preference>"
2739  "<scanner_name>auto_delete_data</scanner_name>"
2740  "<value>%%s</value>"
2741  "</preference>"
2742  "</preferences>"
2743  "</modify_task>");
2744 
2745  response = NULL;
2746  entity = NULL;
2747  ret =
2748  gmpf (connection, credentials, &response, &entity, response_data, format,
2749  task_id, name, comment, strcmp (in_assets, "0") ? "yes" : "no",
2750  auto_delete, auto_delete_data);
2751  g_free (format);
2752  switch (ret)
2753  {
2754  case 0:
2755  case -1:
2756  break;
2757  case 1:
2758  cmd_response_data_set_status_code (response_data,
2759  MHD_HTTP_INTERNAL_SERVER_ERROR);
2760  return gsad_message (
2761  credentials, "Internal error", __FUNCTION__, __LINE__,
2762  "An internal error occurred while saving a task. "
2763  "No new task was created. "
2764  "Diagnostics: Failure to send command to manager daemon.",
2765  response_data);
2766  case 2:
2767  cmd_response_data_set_status_code (response_data,
2768  MHD_HTTP_INTERNAL_SERVER_ERROR);
2769  return gsad_message (
2770  credentials, "Internal error", __FUNCTION__, __LINE__,
2771  "An internal error occurred while saving a task. "
2772  "It is unclear whether the task has been created or not. "
2773  "Diagnostics: Failure to receive response from manager daemon.",
2774  response_data);
2775  default:
2776  cmd_response_data_set_status_code (response_data,
2777  MHD_HTTP_INTERNAL_SERVER_ERROR);
2778  return gsad_message (
2779  credentials, "Internal error", __FUNCTION__, __LINE__,
2780  "An internal error occurred while saving a task. "
2781  "It is unclear whether the task has been created or not. "
2782  "Diagnostics: Internal Error.",
2783  response_data);
2784  }
2785 
2786  html = response_from_entity (connection, credentials, params, entity,
2787  "Save Container Task", response_data);
2788  free_entity (entity);
2789  g_free (response);
2790  return html;
2791 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_credential_gmp()

char* save_credential_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save credential, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 3680 of file gsad_gmp.c.

3682 {
3683  int ret, change_password, change_ssh_passphrase, change_passphrase;
3684  int change_community, change_privacy_password;
3685  gchar *html, *response;
3686  const char *credential_id, *public_key;
3687  const char *name, *comment, *login, *password, *passphrase, *type;
3688  const char *private_key, *certificate, *community, *privacy_password;
3689  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
3690  GString *command;
3691  entity_t entity;
3692 
3693  credential_id = params_value (params, "credential_id");
3694  type = params_value (params, "credential_type");
3695  name = params_value (params, "name");
3696  comment = params_value (params, "comment");
3697  login = params_value (params, "credential_login");
3698  password = params_value (params, "password");
3699  passphrase = params_value (params, "passphrase");
3700  private_key = params_value (params, "private_key");
3701  certificate = params_value (params, "certificate");
3702  community = params_value (params, "community");
3703  privacy_password = params_value (params, "privacy_password");
3704  auth_algorithm = params_value (params, "auth_algorithm");
3705  privacy_algorithm = params_value (params, "privacy_algorithm");
3706  allow_insecure = params_value (params, "allow_insecure");
3707  public_key = params_value (params, "public_key");
3708 
3709  CHECK_VARIABLE_INVALID (credential_id, "Save Credential");
3710  CHECK_VARIABLE_INVALID (name, "Save Credential");
3711  CHECK_VARIABLE_INVALID (comment, "Save Credential");
3712  CHECK_VARIABLE_INVALID (allow_insecure, "Save Credential");
3713  CHECK_VARIABLE_INVALID (type, "Save Credential");
3714 
3715  if (str_equal (type, "cc"))
3716  {
3717  if (params_given (params, "certificate"))
3718  CHECK_VARIABLE_INVALID (certificate, "Save Credential");
3719 
3720  if (params_given (params, "private_key"))
3721  CHECK_VARIABLE_INVALID (private_key, "Save Credential");
3722 
3723  if (params_given (params, "change_passphrase"))
3724  CHECK_VARIABLE_INVALID (passphrase, "Save Credential");
3725  }
3726  else if (str_equal (type, "snmp"))
3727  {
3728  if (params_given (params, "auth_algorithm"))
3729  CHECK_VARIABLE_INVALID (auth_algorithm, "Save Credential");
3730 
3731  if (params_given (params, "privacy_algorithm"))
3732  CHECK_VARIABLE_INVALID (privacy_algorithm, "Save Credential");
3733 
3734  if (params_given (params, "change_privacy_password"))
3735  CHECK_VARIABLE_INVALID (privacy_password, "Save Credential");
3736 
3737  if (params_given (params, "change_community"))
3738  CHECK_VARIABLE_INVALID (community, "Save Credential");
3739  }
3740  else if (str_equal (type, "up") | str_equal (type, "pw"))
3741  {
3742  if (params_given (params, "change_password"))
3743  CHECK_VARIABLE_INVALID (password, "Save Credential");
3744  }
3745  else if (str_equal (type, "smime"))
3746  {
3747  if (params_given (params, "certificate"))
3748  CHECK_VARIABLE_INVALID (certificate, "Save Credential");
3749  }
3750  else if (str_equal (type, "smime"))
3751  {
3752  if (params_given (params, "public_key"))
3753  CHECK_VARIABLE_INVALID (public_key, "Save Credential");
3754  }
3755 
3756  if (params_given (params, "login"))
3757  CHECK_VARIABLE_INVALID (login, "Save Credential");
3758 
3759  change_password = params_value_bool (params, "change_password");
3760 
3761  /* Prepare command */
3762  command = g_string_new ("");
3763 
3764  xml_string_append (command,
3765  "<modify_credential credential_id=\"%s\">"
3766  "<name>%s</name>"
3767  "<comment>%s</comment>"
3768  "<allow_insecure>%s</allow_insecure>",
3769  credential_id, name, comment, allow_insecure);
3770 
3771  if (str_equal (type, "snmp"))
3772  {
3773  change_community = params_value_bool (params, "change_community");
3774  change_privacy_password =
3775  params_value_bool (params, "change_privacy_password");
3776 
3777  if (auth_algorithm)
3778  xml_string_append (command, "<auth_algorithm>%s</auth_algorithm>",
3779  auth_algorithm);
3780 
3781  if (change_community)
3782  xml_string_append (command, "<community>%s</community>", community);
3783 
3784  if (privacy_algorithm || change_privacy_password)
3785  {
3786  xml_string_append (command, "<privacy>");
3787  if (privacy_algorithm)
3788  {
3789  xml_string_append (command, "<algorithm>%s</algorithm>",
3790  privacy_algorithm);
3791  }
3792  if (change_privacy_password && privacy_password)
3793  {
3794  xml_string_append (command, "<password>%s</password>",
3795  privacy_password);
3796  }
3797 
3798  xml_string_append (command, "</privacy>");
3799  }
3800  }
3801  else if (str_equal (type, "cc"))
3802  {
3803  change_passphrase = params_value_bool (params, "change_passphrase");
3804 
3805  if ((certificate && strcmp (certificate, "")))
3806  {
3807  xml_string_append (command, "<certificate>%s</certificate>",
3808  certificate);
3809  }
3810 
3811  if ((private_key && strcmp (private_key, "")) || change_passphrase)
3812  {
3813  xml_string_append (command, "<key>");
3814  if (change_passphrase)
3815  xml_string_append (command, "<phrase>%s</phrase>", passphrase);
3816  if (private_key)
3817  xml_string_append (command, "<private>%s</private>", private_key);
3818  xml_string_append (command, "</key>");
3819  }
3820 
3821 
3822  }
3823  else if (str_equal (type, "usk"))
3824  {
3825  change_ssh_passphrase = params_value_bool (params, "change_passphrase");
3826 
3827  if ((private_key && strcmp (private_key, "")) || change_ssh_passphrase)
3828  {
3829  xml_string_append (command, "<key>");
3830  if (change_ssh_passphrase)
3831  xml_string_append (command, "<phrase>%s</phrase>", passphrase);
3832  if (private_key)
3833  xml_string_append (command, "<private>%s</private>", private_key);
3834  xml_string_append (command, "</key>");
3835  }
3836  }
3837  else if (str_equal (type, "up") | str_equal (type, "pw"))
3838  {
3839  if (change_password)
3840  xml_string_append (command, "<password>%s</password>", password);
3841  }
3842  else if (str_equal (type, "smime"))
3843  {
3844  if ((certificate && strcmp (certificate, "")))
3845  {
3846  xml_string_append (command, "<certificate>%s</certificate>",
3847  certificate);
3848  }
3849  }
3850  else if (str_equal (type, "pgp"))
3851  {
3852  if ((public_key && strcmp (public_key, "")))
3853  {
3854  xml_string_append (command, "<key>");
3855  xml_string_append (command, "<public>%s</public>", public_key);
3856  xml_string_append (command, "</key>");
3857  }
3858  }
3859 
3860  if (login && strcmp (login, ""))
3861  xml_string_append (command, "<login>%s</login>", login);
3862 
3863  xml_string_append (command, "</modify_credential>");
3864 
3865  /* Modify the credential. */
3866  response = NULL;
3867  entity = NULL;
3868  ret = gmp (connection, credentials, &response, &entity, response_data,
3869  command->str);
3870  g_string_free (command, TRUE);
3871 
3872  switch (ret)
3873  {
3874  case 0:
3875  break;
3876  case -1:
3877  /* 'gmp' set response. */
3878  return response;
3879  case 1:
3880  cmd_response_data_set_status_code (response_data,
3881  MHD_HTTP_INTERNAL_SERVER_ERROR);
3882  return gsad_message (
3883  credentials, "Internal error", __FUNCTION__, __LINE__,
3884  "An internal error occurred while saving a Credential. "
3885  "The Credential was not saved. "
3886  "Diagnostics: Failure to send command to manager daemon.",
3887  response_data);
3888  case 2:
3889  cmd_response_data_set_status_code (response_data,
3890  MHD_HTTP_INTERNAL_SERVER_ERROR);
3891  return gsad_message (
3892  credentials, "Internal error", __FUNCTION__, __LINE__,
3893  "An internal error occurred while saving a Credential. "
3894  "It is unclear whether the Credential has been saved or not. "
3895  "Diagnostics: Failure to receive response from manager daemon.",
3896  response_data);
3897  default:
3898  cmd_response_data_set_status_code (response_data,
3899  MHD_HTTP_INTERNAL_SERVER_ERROR);
3900  return gsad_message (
3901  credentials, "Internal error", __FUNCTION__, __LINE__,
3902  "An internal error occurred while saving a Credential. "
3903  "It is unclear whether the Credential has been saved or not. "
3904  "Diagnostics: Internal Error.",
3905  response_data);
3906  }
3907 
3908  html = response_from_entity (connection, credentials, params, entity,
3909  "Save Credential", response_data);
3910  free_entity (entity);
3911  g_free (response);
3912  return html;
3913 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), login(), params_given(), params_value(), params_value_bool(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ save_filter_gmp()

char* save_filter_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a filter, get all filters, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14436 of file gsad_gmp.c.

14438 {
14439  entity_t entity;
14440  gchar *html, *response;
14441  const char *filter_id, *name, *comment, *term, *type;
14442 
14443  filter_id = params_value (params, "filter_id");
14444  name = params_value (params, "name");
14445  comment = params_value (params, "comment");
14446  term = params_value (params, "term");
14447  type = params_value (params, "resource_type");
14448 
14449  CHECK_VARIABLE_INVALID (filter_id, "Save Filter");
14450  CHECK_VARIABLE_INVALID (name, "Save Filter");
14451  CHECK_VARIABLE_INVALID (comment, "Save Filter");
14452  CHECK_VARIABLE_INVALID (term, "Save Filter");
14453  CHECK_VARIABLE_INVALID (type, "Save Filter");
14454 
14455  {
14456  int ret;
14457 
14458  /* Modify the filter. */
14459 
14460  ret = gvm_connection_sendf_xml (connection,
14461  "<modify_filter filter_id=\"%s\">"
14462  "<name>%s</name>"
14463  "<comment>%s</comment>"
14464  "<term>%s</term>"
14465  "<type>%s</type>"
14466  "</modify_filter>",
14467  filter_id, name, comment, term, type);
14468 
14469  if (ret == -1)
14470  {
14471  cmd_response_data_set_status_code (response_data,
14472  MHD_HTTP_INTERNAL_SERVER_ERROR);
14473  return gsad_message (
14474  credentials, "Internal error", __FUNCTION__, __LINE__,
14475  "An internal error occurred while modifying a filter. "
14476  "The filter was not modified. "
14477  "Diagnostics: Failure to send command to manager daemon.",
14478  response_data);
14479  }
14480 
14481  entity = NULL;
14482  if (read_entity_and_text_c (connection, &entity, &response))
14483  {
14484  cmd_response_data_set_status_code (response_data,
14485  MHD_HTTP_INTERNAL_SERVER_ERROR);
14486  return gsad_message (
14487  credentials, "Internal error", __FUNCTION__, __LINE__,
14488  "An internal error occurred while modifying a filter. "
14489  "It is unclear whether the filter has been modified or not. "
14490  "Diagnostics: Failure to receive response from manager daemon.",
14491  response_data);
14492  }
14493  }
14494 
14495  /* Pass response to handler of following page. */
14496 
14497  html = response_from_entity (connection, credentials, params, entity,
14498  "Save Filter", response_data);
14499 
14500  free_entity (entity);
14501  g_free (response);
14502  return html;
14503 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_group_gmp()

char* save_group_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a group, return the next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 12543 of file gsad_gmp.c.

12545 {
12546  int ret;
12547  gchar *html, *response;
12548  const char *group_id, *name, *comment, *users;
12549  entity_t entity;
12550 
12551  group_id = params_value (params, "group_id");
12552  name = params_value (params, "name");
12553  comment = params_value (params, "comment");
12554  users = params_value (params, "users");
12555 
12556  CHECK_VARIABLE_INVALID (group_id, "Save Group");
12557  CHECK_VARIABLE_INVALID (name, "Save Group");
12558  CHECK_VARIABLE_INVALID (comment, "Save Group");
12559  CHECK_VARIABLE_INVALID (users, "Save Group");
12560 
12561  /* Modify the Group. */
12562 
12563  response = NULL;
12564  entity = NULL;
12565  ret = gmpf (connection, credentials, &response, &entity, response_data,
12566  "<modify_group group_id=\"%s\">"
12567  "<name>%s</name>"
12568  "<comment>%s</comment>"
12569  "<users>%s</users>"
12570  "</modify_group>",
12571  group_id, name, comment, users);
12572 
12573  switch (ret)
12574  {
12575  case 0:
12576  case -1:
12577  break;
12578  case 1:
12579  cmd_response_data_set_status_code (response_data,
12580  MHD_HTTP_INTERNAL_SERVER_ERROR);
12581  return gsad_message (
12582  credentials, "Internal error", __FUNCTION__, __LINE__,
12583  "An internal error occurred while saving a group. "
12584  "The group was not saved. "
12585  "Diagnostics: Failure to send command to manager daemon.",
12586  response_data);
12587  case 2:
12588  cmd_response_data_set_status_code (response_data,
12589  MHD_HTTP_INTERNAL_SERVER_ERROR);
12590  return gsad_message (
12591  credentials, "Internal error", __FUNCTION__, __LINE__,
12592  "An internal error occurred while saving a group. "
12593  "It is unclear whether the group has been saved or not. "
12594  "Diagnostics: Failure to receive response from manager daemon.",
12595  response_data);
12596  default:
12597  cmd_response_data_set_status_code (response_data,
12598  MHD_HTTP_INTERNAL_SERVER_ERROR);
12599  return gsad_message (
12600  credentials, "Internal error", __FUNCTION__, __LINE__,
12601  "An internal error occurred while saving a group. "
12602  "It is unclear whether the group has been saved or not. "
12603  "Diagnostics: Internal Error.",
12604  response_data);
12605  }
12606 
12607  html = response_from_entity (connection, credentials, params, entity,
12608  "Save Group", response_data);
12609  free_entity (entity);
12610  g_free (response);
12611  return html;
12612 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), response_from_entity(), and users.

Here is the call graph for this function:

◆ save_my_settings_gmp()

char* save_my_settings_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const gchar *  accept_language,
cmd_response_data_t *  response_data 
)

Returns page with user's settings, for editing.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]accept_languageAccept-Language, from browser.
[out]timezoneTimezone. Caller must free.
[out]passwordPassword. Caller must free.
[out]severitySeverity. Caller must free.
[out]languageLanguage. Caller must free.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 11589 of file gsad_gmp.c.

11592 {
11593  const char *lang, *text, *old_passwd, *passwd, *max;
11594  const char *details_fname, *list_fname, *report_fname;
11595  gchar *lang_64, *text_64, *max_64, *fname_64;
11596  GString *xml;
11597  entity_t entity;
11598  params_t *changed, *defaults, *filters;
11599  int modify_failed = 0;
11600  const char *changed_value;
11601  gboolean user_changed = 0;
11602 
11604 
11605  changed = params_values (params, "settings_changed:");
11606 
11607  text = params_value (params, "text");
11608  old_passwd = params_value (params, "old_password");
11609  passwd = params_value (params, "password");
11610  max = params_value (params, "max");
11611  lang = params_value (params, "lang");
11612  details_fname = params_value (params, "details_fname");
11613  list_fname = params_value (params, "list_fname");
11614  report_fname = params_value (params, "report_fname");
11615 
11616  CHECK_VARIABLE_INVALID (text, "Save Settings")
11617  CHECK_VARIABLE_INVALID (text, "Save Settings")
11618  CHECK_VARIABLE_INVALID (old_passwd, "Save Settings")
11619  CHECK_VARIABLE_INVALID (max, "Save Settings")
11620  CHECK_VARIABLE_INVALID (lang, "Save Settings")
11621  CHECK_VARIABLE_INVALID (details_fname, "Save Settings")
11622  CHECK_VARIABLE_INVALID (list_fname, "Save Settings")
11623  CHECK_VARIABLE_INVALID (report_fname, "Save Settings")
11624 
11625  xml = g_string_new ("");
11626 
11627  changed_value = params_value (changed, "password");
11628  if ((strlen (passwd) || strlen (old_passwd))
11629  && (changed_value == NULL
11630  || (strcmp (changed_value, "") && strcmp (changed_value, "0"))))
11631  {
11632  gchar *passwd_64;
11633  gmp_authenticate_info_opts_t auth_opts;
11634 
11635  /* Send Password setting */
11636 
11637  auth_opts = gmp_authenticate_info_opts_defaults;
11638  auth_opts.username = user_get_username (user);
11639  auth_opts.password = old_passwd;
11640  switch (gmp_authenticate_info_ext_c (connection, auth_opts))
11641  {
11642  case 0:
11643  break;
11644  case 1:
11645  cmd_response_data_set_status_code (response_data,
11646  MHD_HTTP_INTERNAL_SERVER_ERROR);
11647  return gsad_message (
11648  credentials, "Internal error", __FUNCTION__, __LINE__,
11649  "An internal error occurred while saving settings. "
11650  "The settings remains the same. "
11651  "Diagnostics: Manager closed connection during authenticate.",
11652  response_data);
11653  case 2:
11654  cmd_response_data_set_status_code (response_data,
11655  MHD_HTTP_INTERNAL_SERVER_ERROR);
11656  return gsad_message (
11657  credentials, "Invalid Password", __FUNCTION__, __LINE__,
11658  "You tried to change your password, but the old"
11659  " password was not provided or was incorrect. "
11660  " Please enter the correct old password or remove"
11661  " old and new passwords to apply any other changes"
11662  " of your settings.",
11663  response_data);
11664  default:
11665  cmd_response_data_set_status_code (response_data,
11666  MHD_HTTP_INTERNAL_SERVER_ERROR);
11667  return gsad_message (
11668  credentials, "Internal error", __FUNCTION__, __LINE__,
11669  "An internal error occurred while saving settings. "
11670  "The settings remains the same. "
11671  "Diagnostics: Internal Error.",
11672  response_data);
11673  }
11674 
11675  passwd_64 = g_base64_encode ((guchar *) passwd, strlen (passwd));
11676 
11677  if (gvm_connection_sendf (connection,
11678  "<modify_setting>"
11679  "<name>Password</name>"
11680  "<value>%s</value>"
11681  "</modify_setting>",
11682  passwd_64 ? passwd_64 : "")
11683  == -1)
11684  {
11685  g_free (passwd_64);
11686  cmd_response_data_set_status_code (response_data,
11687  MHD_HTTP_INTERNAL_SERVER_ERROR);
11688  return gsad_message (
11689  credentials, "Internal error", __FUNCTION__, __LINE__,
11690  "An internal error occurred while saving settings. "
11691  "It is unclear whether all the settings were saved. "
11692  "Diagnostics: Failure to send command to manager daemon.",
11693  response_data);
11694  }
11695  g_free (passwd_64);
11696 
11697  entity = NULL;
11698  xml_string_append (xml, "<save_setting name=\"Password\">");
11699  if (read_entity_and_string_c (connection, &entity, &xml))
11700  {
11701  g_string_free (xml, TRUE);
11702  cmd_response_data_set_status_code (response_data,
11703  MHD_HTTP_INTERNAL_SERVER_ERROR);
11704  return gsad_message (
11705  credentials, "Internal error", __FUNCTION__, __LINE__,
11706  "An internal error occurred while saving settings. "
11707  "Diagnostics: Failure to receive response from manager daemon.",
11708  response_data);
11709  }
11710  xml_string_append (xml, "</save_setting>");
11711 
11712  if (gmp_success (entity) == 1)
11713  {
11714  user_set_password (user, passwd);
11716  user_changed = 1;
11717  }
11718  else
11719  {
11720  set_http_status_from_entity (entity, response_data);
11721  modify_failed = 1;
11722  }
11723  }
11724 
11725  /* Send Timezone */
11726  changed_value = params_value (changed, "timezone");
11727  if (changed_value == NULL
11728  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11729  {
11730  text_64 = g_base64_encode ((guchar *) text, strlen (text));
11731 
11732  if (gvm_connection_sendf (connection,
11733  "<modify_setting>"
11734  "<name>Timezone</name>"
11735  "<value>%s</value>"
11736  "</modify_setting>",
11737  text_64 ? text_64 : "")
11738  == -1)
11739  {
11740  g_free (text_64);
11741  cmd_response_data_set_status_code (response_data,
11742  MHD_HTTP_INTERNAL_SERVER_ERROR);
11743  return gsad_message (
11744  credentials, "Internal error", __FUNCTION__, __LINE__,
11745  "An internal error occurred while saving settings. "
11746  "It is unclear whether all the settings were saved. "
11747  "Diagnostics: Failure to send command to manager daemon.",
11748  response_data);
11749  }
11750  g_free (text_64);
11751 
11752  entity = NULL;
11753  xml_string_append (xml, "<save_setting name=\"Timezone\">");
11754  if (read_entity_and_string_c (connection, &entity, &xml))
11755  {
11756  g_string_free (xml, TRUE);
11757  cmd_response_data_set_status_code (response_data,
11758  MHD_HTTP_INTERNAL_SERVER_ERROR);
11759  return gsad_message (
11760  credentials, "Internal error", __FUNCTION__, __LINE__,
11761  "An internal error occurred while saving settings. "
11762  "Diagnostics: Failure to receive response from manager daemon.",
11763  response_data);
11764  }
11765  xml_string_append (xml, "</save_setting>");
11766 
11767  if (gmp_success (entity) == 1)
11768  {
11769  const gchar *timezone = strlen (text) ? text : "UTC";
11770 
11771  user_set_timezone (user, timezone);
11772  user_changed = 1;
11773 
11774  /* Set the timezone, so that the ENVELOPE/TIME
11775  * uses the right timezone. */
11776 
11777  if (setenv ("TZ", timezone, 1) == -1)
11778  {
11779  g_critical ("%s: failed to set TZ\n", __FUNCTION__);
11780  exit (EXIT_FAILURE);
11781  }
11782  tzset ();
11783  }
11784  else
11785  {
11786  set_http_status_from_entity (entity, response_data);
11787  modify_failed = 1;
11788  }
11789  }
11790 
11791  /* Send Rows Per Page */
11792  changed_value = params_value (changed, "max");
11793  if (changed_value == NULL
11794  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11795  {
11796  max_64 = g_base64_encode ((guchar *) max, strlen (max));
11797 
11798  if (gvm_connection_sendf (connection,
11799  "<modify_setting"
11800  " setting_id"
11801  "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">"
11802  "<value>%s</value>"
11803  "</modify_setting>",
11804  max_64 ? max_64 : "")
11805  == -1)
11806  {
11807  g_free (max_64);
11808  cmd_response_data_set_status_code (response_data,
11809  MHD_HTTP_INTERNAL_SERVER_ERROR);
11810  return gsad_message (
11811  credentials, "Internal error", __FUNCTION__, __LINE__,
11812  "An internal error occurred while saving settings. "
11813  "It is unclear whether all the settings were saved. "
11814  "Diagnostics: Failure to send command to manager daemon.",
11815  response_data);
11816  }
11817  g_free (max_64);
11818 
11819  entity = NULL;
11820  xml_string_append (xml, "<save_setting id=\"%s\">",
11821  "5f5a8712-8017-11e1-8556-406186ea4fc5");
11822  if (read_entity_and_string_c (connection, &entity, &xml))
11823  {
11824  g_string_free (xml, TRUE);
11825  cmd_response_data_set_status_code (response_data,
11826  MHD_HTTP_INTERNAL_SERVER_ERROR);
11827  return gsad_message (
11828  credentials, "Internal error", __FUNCTION__, __LINE__,
11829  "An internal error occurred while saving settings. "
11830  "It is unclear whether all the settings were saved. "
11831  "Diagnostics: Failure to receive response from manager daemon.",
11832  response_data);
11833  }
11834  xml_string_append (xml, "</save_setting>");
11835  if (gmp_success (entity) != 1)
11836  {
11837  set_http_status_from_entity (entity, response_data);
11838  modify_failed = 1;
11839  }
11840  }
11841 
11842  /* Send resource details export file name format. */
11843  changed_value = params_value (changed, "details_fname");
11844  if (changed_value == NULL
11845  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11846  {
11847  fname_64 =
11848  g_base64_encode ((guchar *) details_fname, strlen (details_fname));
11849 
11850  if (gvm_connection_sendf (connection,
11851  "<modify_setting"
11852  " setting_id"
11853  "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">"
11854  "<value>%s</value>"
11855  "</modify_setting>",
11856  fname_64 ? fname_64 : "")
11857  == -1)
11858  {
11859  g_free (fname_64);
11860  cmd_response_data_set_status_code (response_data,
11861  MHD_HTTP_INTERNAL_SERVER_ERROR);
11862  return gsad_message (
11863  credentials, "Internal error", __FUNCTION__, __LINE__,
11864  "An internal error occurred while saving settings. "
11865  "It is unclear whether all the settings were saved. "
11866  "Diagnostics: Failure to send command to manager daemon.",
11867  response_data);
11868  }
11869  g_free (fname_64);
11870 
11871  entity = NULL;
11872  xml_string_append (xml, "<save_setting id=\"%s\">",
11873  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
11874  if (read_entity_and_string_c (connection, &entity, &xml))
11875  {
11876  g_string_free (xml, TRUE);
11877  cmd_response_data_set_status_code (response_data,
11878  MHD_HTTP_INTERNAL_SERVER_ERROR);
11879  return gsad_message (
11880  credentials, "Internal error", __FUNCTION__, __LINE__,
11881  "An internal error occurred while saving settings. "
11882  "It is unclear whether all the settings were saved. "
11883  "Diagnostics: Failure to receive response from manager daemon.",
11884  response_data);
11885  }
11886  xml_string_append (xml, "</save_setting>");
11887  if (gmp_success (entity) != 1)
11888  {
11889  set_http_status_from_entity (entity, response_data);
11890  modify_failed = 1;
11891  }
11892  }
11893 
11894  /* Send resource list export file name format. */
11895  changed_value = params_value (changed, "list_fname");
11896  if (changed_value == NULL
11897  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11898  {
11899  fname_64 = g_base64_encode ((guchar *) list_fname, strlen (list_fname));
11900 
11901  if (gvm_connection_sendf (connection,
11902  "<modify_setting"
11903  " setting_id"
11904  "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">"
11905  "<value>%s</value>"
11906  "</modify_setting>",
11907  fname_64 ? fname_64 : "")
11908  == -1)
11909  {
11910  g_free (fname_64);
11911  cmd_response_data_set_status_code (response_data,
11912  MHD_HTTP_INTERNAL_SERVER_ERROR);
11913  return gsad_message (
11914  credentials, "Internal error", __FUNCTION__, __LINE__,
11915  "An internal error occurred while saving settings. "
11916  "It is unclear whether all the settings were saved. "
11917  "Diagnostics: Failure to send command to manager daemon.",
11918  response_data);
11919  }
11920  g_free (fname_64);
11921 
11922  entity = NULL;
11923  xml_string_append (xml, "<save_setting id=\"%s\">",
11924  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
11925  if (read_entity_and_string_c (connection, &entity, &xml))
11926  {
11927  g_string_free (xml, TRUE);
11928  cmd_response_data_set_status_code (response_data,
11929  MHD_HTTP_INTERNAL_SERVER_ERROR);
11930  return gsad_message (
11931  credentials, "Internal error", __FUNCTION__, __LINE__,
11932  "An internal error occurred while saving settings. "
11933  "It is unclear whether all the settings were saved. "
11934  "Diagnostics: Failure to receive response from manager daemon.",
11935  response_data);
11936  }
11937  xml_string_append (xml, "</save_setting>");
11938  if (gmp_success (entity) != 1)
11939  {
11940  set_http_status_from_entity (entity, response_data);
11941  modify_failed = 1;
11942  }
11943  }
11944 
11945  /* Send report export file name format. */
11946  changed_value = params_value (changed, "report_fname");
11947  if (changed_value == NULL
11948  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11949  {
11950  fname_64 =
11951  g_base64_encode ((guchar *) report_fname, strlen (report_fname));
11952 
11953  if (gvm_connection_sendf (connection,
11954  "<modify_setting"
11955  " setting_id"
11956  "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">"
11957  "<value>%s</value>"
11958  "</modify_setting>",
11959  fname_64 ? fname_64 : "")
11960  == -1)
11961  {
11962  g_free (fname_64);
11963  cmd_response_data_set_status_code (response_data,
11964  MHD_HTTP_INTERNAL_SERVER_ERROR);
11965  return gsad_message (
11966  credentials, "Internal error", __FUNCTION__, __LINE__,
11967  "An internal error occurred while saving settings. "
11968  "It is unclear whether all the settings were saved. "
11969  "Diagnostics: Failure to send command to manager daemon.",
11970  response_data);
11971  }
11972  g_free (fname_64);
11973 
11974  entity = NULL;
11975  xml_string_append (xml, "<save_setting id=\"%s\">",
11976  "e1a2ae0b-736e-4484-b029-330c9e15b900");
11977  if (read_entity_and_string_c (connection, &entity, &xml))
11978  {
11979  g_string_free (xml, TRUE);
11980  cmd_response_data_set_status_code (response_data,
11981  MHD_HTTP_INTERNAL_SERVER_ERROR);
11982  return gsad_message (
11983  credentials, "Internal error", __FUNCTION__, __LINE__,
11984  "An internal error occurred while saving settings. "
11985  "It is unclear whether all the settings were saved. "
11986  "Diagnostics: Failure to receive response from manager daemon.",
11987  response_data);
11988  }
11989  xml_string_append (xml, "</save_setting>");
11990  if (gmp_success (entity) != 1)
11991  {
11992  set_http_status_from_entity (entity, response_data);
11993  modify_failed = 1;
11994  }
11995  }
11996 
11997  /* Send User Interface Language. */
11998  changed_value = params_value (changed, "lang");
11999  if (changed_value == NULL
12000  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
12001  {
12002  lang_64 = g_base64_encode ((guchar *) lang, strlen (lang));
12003 
12004  if (gvm_connection_sendf (connection,
12005  "<modify_setting"
12006  " setting_id"
12007  "=\"6765549a-934e-11e3-b358-406186ea4fc5\">"
12008  "<value>%s</value>"
12009  "</modify_setting>",
12010  lang_64 ? lang_64 : "")
12011  == -1)
12012  {
12013  g_free (lang_64);
12014  cmd_response_data_set_status_code (response_data,
12015  MHD_HTTP_INTERNAL_SERVER_ERROR);
12016  return gsad_message (
12017  credentials, "Internal error", __FUNCTION__, __LINE__,
12018  "An internal error occurred while saving settings. "
12019  "It is unclear whether all the settings were saved. "
12020  "Diagnostics: Failure to send command to manager daemon.",
12021  response_data);
12022  }
12023  g_free (lang_64);
12024 
12025  entity = NULL;
12026  xml_string_append (xml, "<save_setting id=\"%s\">",
12027  "6765549a-934e-11e3-b358-406186ea4fc5");
12028  if (read_entity_and_string_c (connection, &entity, &xml))
12029  {
12030  g_string_free (xml, TRUE);
12031  cmd_response_data_set_status_code (response_data,
12032  MHD_HTTP_INTERNAL_SERVER_ERROR);
12033  return gsad_message (
12034  credentials, "Internal error", __FUNCTION__, __LINE__,
12035  "An internal error occurred while saving settings. "
12036  "It is unclear whether all the settings were saved. "
12037  "Diagnostics: Failure to receive response from manager daemon.",
12038  response_data);
12039  }
12040  xml_string_append (xml, "</save_setting>");
12041  if (gmp_success (entity) == 1)
12042  {
12043  user_set_language (user, lang);
12044  user_changed = 1;
12045  }
12046  else
12047  {
12048  set_http_status_from_entity (entity, response_data);
12049  modify_failed = 1;
12050  }
12051  }
12052 
12053  /* Send default resources */
12054 
12055  defaults = params_values (params, "settings_default:");
12056  if (send_settings_filters (connection, defaults, changed, xml, &modify_failed,
12057  response_data))
12058  {
12059  cmd_response_data_set_status_code (response_data,
12060  MHD_HTTP_INTERNAL_SERVER_ERROR);
12061  return gsad_message (
12062  credentials, "Internal error", __FUNCTION__, __LINE__,
12063  "An internal error occurred while saving settings. "
12064  "It is unclear whether all the settings were saved. "
12065  "Diagnostics: Failure to send command to manager daemon.",
12066  response_data);
12067  }
12068 
12069  /* Send resources filters */
12070 
12071  filters = params_values (params, "settings_filter:");
12072  if (send_settings_filters (connection, filters, changed, xml, &modify_failed,
12073  response_data))
12074  {
12075  cmd_response_data_set_status_code (response_data,
12076  MHD_HTTP_INTERNAL_SERVER_ERROR);
12077  return gsad_message (
12078  credentials, "Internal error", __FUNCTION__, __LINE__,
12079  "An internal error occurred while saving settings. "
12080  "It is unclear whether all the settings were saved. "
12081  "Diagnostics: Failure to send command to manager daemon.",
12082  response_data);
12083  }
12084 
12085  /* Send Severity Class. */
12086 
12087  changed_value = params_value (changed, "severity_class");
12088  if (changed_value == NULL
12089  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
12090  {
12091  text = params_value (params, "severity_class");
12092  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
12093  : g_strdup (""));
12094 
12095  if (gvm_connection_sendf (connection,
12096  "<modify_setting"
12097  " setting_id"
12098  "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">"
12099  "<value>%s</value>"
12100  "</modify_setting>",
12101  text_64 ? text_64 : "")
12102  == -1)
12103  {
12104  g_free (text_64);
12105  cmd_response_data_set_status_code (response_data,
12106  MHD_HTTP_INTERNAL_SERVER_ERROR);
12107  return gsad_message (
12108  credentials, "Internal error", __FUNCTION__, __LINE__,
12109  "An internal error occurred while saving settings. "
12110  "It is unclear whether all the settings were saved. "
12111  "Diagnostics: Failure to send command to manager daemon.",
12112  response_data);
12113  }
12114  g_free (text_64);
12115 
12116  entity = NULL;
12117  xml_string_append (xml, "<save_setting id=\"%s\">",
12118  "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
12119  if (read_entity_and_string_c (connection, &entity, &xml))
12120  {
12121  g_string_free (xml, TRUE);
12122  cmd_response_data_set_status_code (response_data,
12123  MHD_HTTP_INTERNAL_SERVER_ERROR);
12124  return gsad_message (
12125  credentials, "Internal error", __FUNCTION__, __LINE__,
12126  "An internal error occurred while saving settings. "
12127  "It is unclear whether all the settings were saved. "
12128  "Diagnostics: Failure to receive response from manager daemon.",
12129  response_data);
12130  }
12131  xml_string_append (xml, "</save_setting>");
12132 
12133  if (gmp_success (entity) == 1)
12134  {
12135  if ((text != NULL) && (strlen (text) > 0))
12136  {
12137  user_set_severity (user, text);
12138  user_changed = 1;
12139  }
12140  }
12141  else
12142  {
12143  set_http_status_from_entity (entity, response_data);
12144  modify_failed = 1;
12145  }
12146  }
12147 
12148  /* Send Dynamic Severity setting. */
12149 
12150  changed_value = params_value (changed, "dynamic_severity");
12151  if (changed_value == NULL
12152  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
12153  {
12154  text = params_value (params, "dynamic_severity");
12155  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
12156  : g_strdup (""));
12157 
12158  if (gvm_connection_sendf (connection,
12159  "<modify_setting"
12160  " setting_id"
12161  "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">"
12162  "<value>%s</value>"
12163  "</modify_setting>",
12164  text_64 ? text_64 : "")
12165  == -1)
12166  {
12167  g_free (text_64);
12168  cmd_response_data_set_status_code (response_data,
12169  MHD_HTTP_INTERNAL_SERVER_ERROR);
12170  return gsad_message (
12171  credentials, "Internal error", __FUNCTION__, __LINE__,
12172  "An internal error occurred while saving settings. "
12173  "It is unclear whether all the settings were saved. "
12174  "Diagnostics: Failure to send command to manager daemon.",
12175  response_data);
12176  }
12177  g_free (text_64);
12178 
12179  entity = NULL;
12180  xml_string_append (xml, "<save_setting id=\"%s\">",
12181  "77ec2444-e7f2-4a80-a59b-f4237782d93f");
12182  if (read_entity_and_string_c (connection, &entity, &xml))
12183  {
12184  g_string_free (xml, TRUE);
12185  cmd_response_data_set_status_code (response_data,
12186  MHD_HTTP_INTERNAL_SERVER_ERROR);
12187  return gsad_message (
12188  credentials, "Internal error", __FUNCTION__, __LINE__,
12189  "An internal error occurred while saving settings. "
12190  "It is unclear whether all the settings were saved. "
12191  "Diagnostics: Failure to receive response from manager daemon.",
12192  response_data);
12193  }
12194  xml_string_append (xml, "</save_setting>");
12195  if (gmp_success (entity) != 1)
12196  {
12197  set_http_status_from_entity (entity, response_data);
12198  modify_failed = 1;
12199  }
12200  }
12201 
12202  /* Send Default Severity setting. */
12203  changed_value = params_value (changed, "default_severity");
12204  if (changed_value == NULL
12205  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
12206  {
12207  text = params_value (params, "default_severity");
12208  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
12209  : g_strdup (""));
12210 
12211  if (gvm_connection_sendf (connection,
12212  "<modify_setting"
12213  " setting_id"
12214  "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">"
12215  "<value>%s</value>"
12216  "</modify_setting>",
12217  text_64 ? text_64 : "")
12218  == -1)
12219  {
12220  g_free (text_64);
12221  cmd_response_data_set_status_code (response_data,
12222  MHD_HTTP_INTERNAL_SERVER_ERROR);
12223  return gsad_message (
12224  credentials, "Internal error", __FUNCTION__, __LINE__,
12225  "An internal error occurred while saving settings. "
12226  "It is unclear whether all the settings were saved. "
12227  "Diagnostics: Failure to send command to manager daemon.",
12228  response_data);
12229  }
12230  g_free (text_64);
12231 
12232  entity = NULL;
12233  xml_string_append (xml, "<save_setting id=\"%s\">",
12234  "7eda49c5-096c-4bef-b1ab-d080d87300df");
12235  if (read_entity_and_string_c (connection, &entity, &xml))
12236  {
12237  g_string_free (xml, TRUE);
12238  cmd_response_data_set_status_code (response_data,
12239  MHD_HTTP_INTERNAL_SERVER_ERROR);
12240  return gsad_message (
12241  credentials, "Internal error", __FUNCTION__, __LINE__,
12242  "An internal error occurred while saving settings. "
12243  "It is unclear whether all the settings were saved. "
12244  "Diagnostics: Failure to receive response from manager daemon.",
12245  response_data);
12246  }
12247  xml_string_append (xml, "</save_setting>");
12248  if (gmp_success (entity) != 1)
12249  {
12250  set_http_status_from_entity (entity, response_data);
12251  modify_failed = 1;
12252  }
12253  }
12254 
12255  /* Send Auto Cache Rebuild setting. */
12256 
12257  changed_value = params_value (changed, "auto_cache_rebuild");
12258  if (changed_value == NULL
12259  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
12260  {
12261  text = params_value (params, "auto_cache_rebuild");
12262  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
12263  : g_strdup (""));
12264 
12265  if (gvm_connection_sendf (connection,
12266  "<modify_setting"
12267  " setting_id"
12268  "=\"a09285b0-2d47-49b6-a4ef-946ee71f1d5c\">"
12269  "<value>%s</value>"
12270  "</modify_setting>",
12271  text_64 ? text_64 : "")
12272  == -1)
12273  {
12274  g_free (text_64);
12275  gvm_connection_close (connection);
12276  cmd_response_data_set_status_code (response_data,
12277  MHD_HTTP_INTERNAL_SERVER_ERROR);
12278  return gsad_message (
12279  credentials, "Internal error", __FUNCTION__, __LINE__,
12280  "An internal error occurred while saving settings. "
12281  "It is unclear whether all the settings were saved. "
12282  "Diagnostics: Failure to send command to manager daemon.",
12283  response_data);
12284  }
12285  g_free (text_64);
12286 
12287  entity = NULL;
12288  xml_string_append (xml, "<save_setting id=\"%s\">",
12289  "a09285b0-2d47-49b6-a4ef-946ee71f1d5c");
12290  if (read_entity_and_string_c (connection, &entity, &xml))
12291  {
12292  g_string_free (xml, TRUE);
12293  gvm_connection_close (connection);
12294  cmd_response_data_set_status_code (response_data,
12295  MHD_HTTP_INTERNAL_SERVER_ERROR);
12296  return gsad_message (
12297  credentials, "Internal error", __FUNCTION__, __LINE__,
12298  "An internal error occurred while saving settings. "
12299  "It is unclear whether all the settings were saved. "
12300  "Diagnostics: Failure to receive response from manager daemon.",
12301  response_data);
12302  }
12303  xml_string_append (xml, "</save_setting>");
12304  if (gmp_success (entity) != 1)
12305  {
12306  set_http_status_from_entity (entity, response_data);
12307  modify_failed = 1;
12308  }
12309  }
12310 
12311  if (user_changed)
12312  {
12314  }
12315 
12316  return envelope_gmp (connection, credentials, params,
12317  g_string_free (xml, FALSE), response_data);
12318 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), credentials_get_user(), envelope_gmp(), gmp_success(), gsad_message(), params_t, params_value(), params_values(), send_settings_filters(), session_add_user(), session_remove_other_sessions(), set_http_status_from_entity(), user_get_token(), user_get_username(), user_set_language(), user_set_password(), user_set_severity(), and user_set_timezone().

Here is the call graph for this function:

◆ save_note_gmp()

char* save_note_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save note, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9543 of file gsad_gmp.c.

9545 {
9546  gchar *response;
9547  entity_t entity;
9548  const char *note_id, *text, *hosts, *port, *severity, *task_id;
9549  const char *result_id, *active, *days, *oid;
9550  char *ret;
9551 
9552  note_id = params_value (params, "note_id");
9553 
9554  oid = params_value (params, "oid");
9555 
9556  text = params_value (params, "text");
9557  if (text == NULL)
9558  params_given (params, "text") || (text = "");
9559 
9560  port = get_port_from_params (params);
9561  hosts = get_hosts_from_params (params);
9562  task_id = get_task_id_from_params (params);
9563  severity = get_severity_from_params (params);
9564  result_id = get_result_id_from_params (params);
9565 
9566  active = params_value (params, "active");
9567  days = params_value (params, "days");
9568 
9569  CHECK_VARIABLE_INVALID (oid, "Save Note");
9570  CHECK_VARIABLE_INVALID (active, "Save Note");
9571  CHECK_VARIABLE_INVALID (note_id, "Save Note");
9572  CHECK_VARIABLE_INVALID (days, "Save Note");
9573 
9574  response = NULL;
9575  entity = NULL;
9576  switch (gmpf (connection, credentials, &response, &entity, response_data,
9577  "<modify_note note_id=\"%s\">"
9578  "<active>%s</active>"
9579  "<hosts>%s</hosts>"
9580  "<port>%s</port>"
9581  "<severity>%s</severity>"
9582  "<text>%s</text>"
9583  "<task id=\"%s\"/>"
9584  "<result id=\"%s\"/>"
9585  "<nvt oid=\"%s\"/>"
9586  "</modify_note>",
9587  note_id, strcmp (active, "1") ? active : (days ? days : "-1"),
9588  hosts ? hosts : "", port ? port : "", severity ? severity : "",
9589  text ? text : "", task_id ? task_id : "",
9590  result_id ? result_id : "", oid))
9591  {
9592  case 0:
9593  case -1:
9594  break;
9595  case 1:
9596  cmd_response_data_set_status_code (response_data,
9597  MHD_HTTP_INTERNAL_SERVER_ERROR);
9598  return gsad_message (
9599  credentials, "Internal error", __FUNCTION__, __LINE__,
9600  "An internal error occurred while saving a note. "
9601  "The note remains the same. "
9602  "Diagnostics: Failure to send command to manager daemon.",
9603  response_data);
9604  case 2:
9605  cmd_response_data_set_status_code (response_data,
9606  MHD_HTTP_INTERNAL_SERVER_ERROR);
9607  return gsad_message (
9608  credentials, "Internal error", __FUNCTION__, __LINE__,
9609  "An internal error occurred while saving a note. "
9610  "It is unclear whether the note has been saved or not. "
9611  "Diagnostics: Failure to receive response from manager daemon.",
9612  response_data);
9613  default:
9614  cmd_response_data_set_status_code (response_data,
9615  MHD_HTTP_INTERNAL_SERVER_ERROR);
9616  return gsad_message (
9617  credentials, "Internal error", __FUNCTION__, __LINE__,
9618  "An internal error occurred while saving a note. "
9619  "It is unclear whether the note has been saved or not. "
9620  "Diagnostics: Internal Error.",
9621  response_data);
9622  }
9623 
9624  ret = response_from_entity (connection, credentials, params, entity,
9625  "Save Note", response_data);
9626 
9627  free_entity (entity);
9628  g_free (response);
9629  return ret;
9630 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_hosts_from_params(), get_port_from_params(), get_result_id_from_params(), get_severity_from_params(), get_task_id_from_params(), gmpf(), gsad_message(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_osp_prefs()

static char* save_osp_prefs ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  next,
const char *  fail_next,
int *  success,
cmd_response_data_t *  response_data 
)
static

Save OSP file preferences.

Parameters
[in]connectionConnection.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]nextThe next command on success.
[in]fail_nextThe next command on failure.
[out]successWhether the last command was successful.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 7279 of file gsad_gmp.c.

7282 {
7283  GHashTableIter iter;
7284  gpointer param_name, val;
7285  char *ret;
7286  const char *config_id;
7287 
7288  config_id = params_value (params, "config_id");
7289  g_hash_table_iter_init (&iter, params);
7290  ret = NULL;
7291  while (g_hash_table_iter_next (&iter, &param_name, &val))
7292  {
7293  gchar *value;
7294  param_t *param = val;
7295 
7296  g_free (ret);
7297  ret = NULL;
7298 
7299  if (!g_str_has_prefix (param_name, "osp_pref_"))
7300  continue;
7301  value = param->value_size
7302  ? g_base64_encode ((guchar *) param->value, param->value_size)
7303  : g_strdup ("");
7304 
7305  /* Send the name without the osp_pref_ prefix. */
7306  param_name = ((char *) param_name) + 9;
7307  if (gvm_connection_sendf (connection,
7308  "<modify_config config_id=\"%s\">"
7309  "<preference><name>%s</name>"
7310  "<value>%s</value></preference>"
7311  "</modify_config>",
7312  config_id, (char *) param_name, value)
7313  == -1)
7314  {
7315  g_free (value);
7316  cmd_response_data_set_status_code (response_data,
7317  MHD_HTTP_INTERNAL_SERVER_ERROR);
7318  return gsad_message (
7319  credentials, "Internal error", __FUNCTION__, __LINE__,
7320  "An internal error occurred while saving a config. It is"
7321  " unclear whether the entire config has been saved. "
7322  "Diagnostics: Failure to send command to manager daemon.",
7323  response_data);
7324  }
7325  g_free (value);
7326 
7327  ret = check_modify_config (connection, credentials, params, next,
7328  fail_next, success, response_data);
7329  if (*success == 0)
7330  return ret;
7331  }
7332  return ret;
7333 }

References check_modify_config(), cmd_response_data_set_status_code(), gsad_message(), params_value(), param::value, and param::value_size.

Referenced by save_config_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_override_gmp()

char* save_override_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save override, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 9846 of file gsad_gmp.c.

9848 {
9849  gchar *response;
9850  entity_t entity;
9851  const char *override_id, *text, *hosts, *port;
9852  const char *severity, *custom_severity, *new_severity;
9853  const char *task_id, *result_id, *active, *days, *oid;
9854  char *ret;
9855 
9856  override_id = params_value (params, "override_id");
9857 
9858  port = get_port_from_params (params);
9859  hosts = get_hosts_from_params (params);
9860  task_id = get_task_id_from_params (params);
9861  severity = get_severity_from_params (params);
9862  result_id = get_result_id_from_params (params);
9863 
9864  text = params_value (params, "text");
9865  if (text == NULL)
9866  params_given (params, "text") || (text = "");
9867 
9868  custom_severity = params_value (params, "custom_severity");
9869  if (custom_severity && strcmp (custom_severity, "0") != 0)
9870  new_severity = params_value (params, "new_severity");
9871  else
9872  new_severity = params_value (params, "new_severity_from_list");
9873 
9874  active = params_value (params, "active");
9875  days = params_value (params, "days");
9876  oid = params_value (params, "oid");
9877 
9878  CHECK_VARIABLE_INVALID (active, "Save Override");
9879  CHECK_VARIABLE_INVALID (override_id, "Save Override");
9880  CHECK_VARIABLE_INVALID (new_severity, "Save Override");
9881  CHECK_VARIABLE_INVALID (days, "Save Override");
9882  CHECK_VARIABLE_INVALID (oid, "Save Override");
9883 
9884  response = NULL;
9885  entity = NULL;
9886  switch (gmpf (connection, credentials, &response, &entity, response_data,
9887  "<modify_override override_id=\"%s\">"
9888  "<active>%s</active>"
9889  "<nvt oid=\"%s\"/>"
9890  "<hosts>%s</hosts>"
9891  "<port>%s</port>"
9892  "<severity>%s</severity>"
9893  "<new_severity>%s</new_severity>"
9894  "<text>%s</text>"
9895  "<task id=\"%s\"/>"
9896  "<result id=\"%s\"/>"
9897  "</modify_override>",
9898  override_id,
9899  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
9900  hosts ? hosts : "", port ? port : "", severity ? severity : "",
9901  new_severity, text ? text : "", task_id ? task_id : "",
9902  result_id ? result_id : ""))
9903  {
9904  case 0:
9905  case -1:
9906  break;
9907  case 1:
9908  cmd_response_data_set_status_code (response_data,
9909  MHD_HTTP_INTERNAL_SERVER_ERROR);
9910  return gsad_message (
9911  credentials, "Internal error", __FUNCTION__, __LINE__,
9912  "An internal error occurred while saving a override. "
9913  "The override remains the same. "
9914  "Diagnostics: Failure to send command to manager daemon.",
9915  response_data);
9916  case 2:
9917  cmd_response_data_set_status_code (response_data,
9918  MHD_HTTP_INTERNAL_SERVER_ERROR);
9919  return gsad_message (
9920  credentials, "Internal error", __FUNCTION__, __LINE__,
9921  "An internal error occurred while saving a override. "
9922  "It is unclear whether the override has been saved or not. "
9923  "Diagnostics: Failure to receive response from manager daemon.",
9924  response_data);
9925  default:
9926  cmd_response_data_set_status_code (response_data,
9927  MHD_HTTP_INTERNAL_SERVER_ERROR);
9928  return gsad_message (
9929  credentials, "Internal error", __FUNCTION__, __LINE__,
9930  "An internal error occurred while saving a override. "
9931  "It is unclear whether the override has been saved or not. "
9932  "Diagnostics: Internal Error.",
9933  response_data);
9934  }
9935 
9936  ret = response_from_entity (connection, credentials, params, entity,
9937  "Save Override", response_data);
9938 
9939  free_entity (entity);
9940  g_free (response);
9941  return ret;
9942 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_hosts_from_params(), get_port_from_params(), get_result_id_from_params(), get_severity_from_params(), get_task_id_from_params(), gmpf(), gsad_message(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_permission_gmp()

char* save_permission_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a permission, get all permissions, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13274 of file gsad_gmp.c.

13276 {
13277  gchar *html, *response;
13278  const char *permission_id, *name, *comment, *resource_id, *resource_type;
13279  const char *subject_id, *subject_type;
13280  entity_t entity;
13281  int ret;
13282 
13283  permission_id = params_value (params, "permission_id");
13284  name = params_value (params, "permission");
13285  comment = params_value (params, "comment");
13286  subject_type = params_value (params, "subject_type");
13287  resource_id = params_value (params, "id_or_empty");
13288  resource_type = params_value (params, "optional_resource_type");
13289 
13290  CHECK_VARIABLE_INVALID (permission_id, "Save Permission");
13291  CHECK_VARIABLE_INVALID (name, "Save Permission");
13292  CHECK_VARIABLE_INVALID (comment, "Save Permission");
13293  CHECK_VARIABLE_INVALID (resource_id, "Save Permission");
13294  CHECK_VARIABLE_INVALID (subject_type, "Save Permission");
13295  if (params_given (params, "optional_resource_type"))
13296  CHECK_VARIABLE_INVALID (resource_type, "Save Permission");
13297 
13298  if (strcmp (subject_type, "user") == 0)
13299  subject_id = params_value (params, "user_id");
13300  else if (strcmp (subject_type, "group") == 0)
13301  subject_id = params_value (params, "group_id");
13302  else if (strcmp (subject_type, "role") == 0)
13303  subject_id = params_value (params, "role_id");
13304  else
13305  subject_id = NULL;
13306  CHECK_VARIABLE_INVALID (subject_id, "Save Permission");
13307 
13308  /* Modify the permission. */
13309 
13310  response = NULL;
13311  entity = NULL;
13312  ret = gmpf (connection, credentials, &response, &entity, response_data,
13313  "<modify_permission permission_id=\"%s\">"
13314  "<name>%s</name>"
13315  "<comment>%s</comment>"
13316  "<subject id=\"%s\">"
13317  "<type>%s</type>"
13318  "</subject>"
13319  "<resource id=\"%s\">"
13320  "<type>%s</type>"
13321  "</resource>"
13322  "</modify_permission>",
13323  permission_id, name, comment, subject_id, subject_type,
13324  (resource_id && strlen (resource_id)) ? resource_id : "0",
13325  resource_type ? resource_type : "");
13326  switch (ret)
13327  {
13328  case 0:
13329  case -1:
13330  break;
13331  case 1:
13332  cmd_response_data_set_status_code (response_data,
13333  MHD_HTTP_INTERNAL_SERVER_ERROR);
13334  return gsad_message (
13335  credentials, "Internal error", __FUNCTION__, __LINE__,
13336  "An internal error occurred while modifying a permission. "
13337  "The permission was not modified. "
13338  "Diagnostics: Failure to send command to manager daemon.",
13339  response_data);
13340  case 2:
13341  cmd_response_data_set_status_code (response_data,
13342  MHD_HTTP_INTERNAL_SERVER_ERROR);
13343  return gsad_message (
13344  credentials, "Internal error", __FUNCTION__, __LINE__,
13345  "An internal error occurred while modifying a permission. "
13346  "It is unclear whether the permission has been modified or not. "
13347  "Diagnostics: Failure to receive response from manager daemon.",
13348  response_data);
13349  default:
13350  cmd_response_data_set_status_code (response_data,
13351  MHD_HTTP_INTERNAL_SERVER_ERROR);
13352  return gsad_message (
13353  credentials, "Internal error", __FUNCTION__, __LINE__,
13354  "An internal error occurred while modifying a permission. "
13355  "It is unclear whether the permission has been modified or not. "
13356  "Diagnostics: Internal Error.",
13357  response_data);
13358  }
13359 
13360  html = response_from_entity (connection, credentials, params, entity,
13361  "Save Permission", response_data);
13362  free_entity (entity);
13363  g_free (response);
13364  return html;
13365 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_port_list_gmp()

char* save_port_list_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a port list, get all port list, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13605 of file gsad_gmp.c.

13607 {
13608  int ret;
13609  gchar *html, *response;
13610  const char *port_list_id, *name, *comment;
13611  entity_t entity;
13612 
13613  port_list_id = params_value (params, "port_list_id");
13614  name = params_value (params, "name");
13615  comment = params_value (params, "comment");
13616 
13617  CHECK_VARIABLE_INVALID (port_list_id, "Save Port List");
13618  CHECK_VARIABLE_INVALID (name, "Save Port List");
13619  CHECK_VARIABLE_INVALID (comment, "Save Port List");
13620 
13621  /* Modify the Port List. */
13622 
13623  response = NULL;
13624  entity = NULL;
13625  ret = gmpf (connection, credentials, &response, &entity, response_data,
13626  "<modify_port_list port_list_id=\"%s\">"
13627  "<name>%s</name>"
13628  "<comment>%s</comment>"
13629  "</modify_port_list>",
13630  port_list_id, name, comment);
13631 
13632  switch (ret)
13633  {
13634  case 0:
13635  case -1:
13636  break;
13637  case 1:
13638  cmd_response_data_set_status_code (response_data,
13639  MHD_HTTP_INTERNAL_SERVER_ERROR);
13640  return gsad_message (
13641  credentials, "Internal error", __FUNCTION__, __LINE__,
13642  "An internal error occurred while saving a Port List. "
13643  "The Port List was not saved. "
13644  "Diagnostics: Failure to send command to manager daemon.",
13645  response_data);
13646  case 2:
13647  cmd_response_data_set_status_code (response_data,
13648  MHD_HTTP_INTERNAL_SERVER_ERROR);
13649  return gsad_message (
13650  credentials, "Internal error", __FUNCTION__, __LINE__,
13651  "An internal error occurred while saving a Port List. "
13652  "It is unclear whether the Port List has been saved or not. "
13653  "Diagnostics: Failure to receive response from manager daemon.",
13654  response_data);
13655  default:
13656  cmd_response_data_set_status_code (response_data,
13657  MHD_HTTP_INTERNAL_SERVER_ERROR);
13658  return gsad_message (
13659  credentials, "Internal error", __FUNCTION__, __LINE__,
13660  "An internal error occurred while saving a Port List. "
13661  "It is unclear whether the Port List has been saved or not. "
13662  "Diagnostics: Internal Error.",
13663  response_data);
13664  }
13665 
13666  html = response_from_entity (connection, credentials, params, entity,
13667  "Save Port List", response_data);
13668  free_entity (entity);
13669  g_free (response);
13670  return html;
13671 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_report_format_gmp()

char* save_report_format_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save report_format, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 11010 of file gsad_gmp.c.

11013 {
11014  int ret;
11015  gchar *html, *response;
11016  params_t *preferences, *id_list_params, *include_id_lists;
11017  const char *report_format_id, *name, *summary, *enable;
11018  entity_t entity;
11019 
11020  report_format_id = params_value (params, "report_format_id");
11021  name = params_value (params, "name");
11022  summary = params_value (params, "summary");
11023  enable = params_value (params, "enable");
11024 
11025  CHECK_VARIABLE_INVALID (report_format_id, "Save Report Format");
11026  CHECK_VARIABLE_INVALID (name, "Save Report Format");
11027  CHECK_VARIABLE_INVALID (summary, "Save Report Format");
11028  CHECK_VARIABLE_INVALID (enable, "Save Report Format");
11029 
11030  id_list_params = params_values (params, "id_list:");
11031  include_id_lists = params_values (params, "include_id_list:");
11032  if (include_id_lists)
11033  {
11034  GHashTable *id_lists;
11035  param_t *param;
11036  gchar *param_name, *pref_name, *value, *old_values, *new_values;
11037  params_iterator_t iter;
11038  GHashTableIter hash_table_iter;
11039 
11040  id_lists =
11041  g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
11042 
11043  params_iterator_init (&iter, include_id_lists);
11044  while (params_iterator_next (&iter, &param_name, &param))
11045  {
11046  if (param->value == NULL)
11047  continue;
11048 
11049  g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (""));
11050  }
11051 
11052  params_iterator_init (&iter, id_list_params);
11053  while (params_iterator_next (&iter, &param_name, &param))
11054  {
11055  if (param->value == NULL)
11056  continue;
11057 
11058  gchar *colon_pos = strchr (param->value, ':');
11059 
11060  pref_name = g_strndup (param->value, colon_pos - param->value);
11061  value = g_strdup (colon_pos + 1);
11062 
11063  old_values = g_hash_table_lookup (id_lists, pref_name);
11064 
11065  if (old_values && strcmp (old_values, ""))
11066  {
11067  new_values = g_strdup_printf ("%s,%s", old_values, value);
11068  g_hash_table_insert (id_lists, pref_name, new_values);
11069  g_free (value);
11070  }
11071  else if (old_values)
11072  {
11073  g_hash_table_insert (id_lists, pref_name, value);
11074  }
11075  }
11076 
11077  g_hash_table_iter_init (&hash_table_iter, id_lists);
11078  while (g_hash_table_iter_next (&hash_table_iter, (void **) &pref_name,
11079  (void **) &value))
11080  {
11081  gchar *value_64;
11082 
11083  value_64 = strlen (value)
11084  ? g_base64_encode ((guchar *) value, strlen (value))
11085  : g_strdup ("");
11086 
11087  response = NULL;
11088  entity = NULL;
11089  ret =
11090  gmpf (connection, credentials, &response, &entity, response_data,
11091  "<modify_report_format"
11092  " report_format_id=\"%s\">"
11093  "<param>"
11094  "<name>%s</name>"
11095  "<value>%s</value>"
11096  "</param>"
11097  "</modify_report_format>",
11098  report_format_id, pref_name, value_64);
11099  g_free (value_64);
11100  switch (ret)
11101  {
11102  case 0:
11103  break;
11104  case 1:
11106  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11107  return gsad_message (
11108  credentials, "Internal error", __FUNCTION__, __LINE__,
11109  "An internal error occurred while saving a Report Format. "
11110  "The Report Format was not saved. "
11111  "Diagnostics: Failure to send command to manager daemon.",
11112  response_data);
11113  case 2:
11115  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11116  return gsad_message (
11117  credentials, "Internal error", __FUNCTION__, __LINE__,
11118  "An internal error occurred while saving a Report Format. "
11119  "It is unclear whether the Report Format has been saved or "
11120  "not. "
11121  "Diagnostics: Failure to receive response from manager daemon.",
11122  response_data);
11123  case -1:
11124  default:
11126  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11127  return gsad_message (
11128  credentials, "Internal error", __FUNCTION__, __LINE__,
11129  "An internal error occurred while saving a Report Format. "
11130  "It is unclear whether the Report Format has been saved or "
11131  "not. "
11132  "Diagnostics: Internal Error.",
11133  response_data);
11134  }
11135 
11136  /* TODO Check if succeeded. response_from_entity_if_failed? */
11137  }
11138  }
11139 
11140  /* Modify the Report Format. */
11141 
11142  preferences = params_values (params, "preference:");
11143  if (preferences)
11144  {
11145  param_t *param;
11146  gchar *param_name;
11147  params_iterator_t iter;
11148 
11149  /* The naming is a bit subtle here, because the HTTP request
11150  * parameters are called "param"s and so are the GMP report format
11151  * parameters. */
11152 
11153  params_iterator_init (&iter, preferences);
11154  while (params_iterator_next (&iter, &param_name, &param))
11155  {
11156  char **splits;
11157  /* OID:PrefID:PrefType:PrefName value */
11158  splits = g_strsplit (param_name, ":", 4);
11159  if (splits && splits[0] && splits[1] && splits[2] && splits[3])
11160  {
11161  gchar *value;
11162 
11163  value =
11164  param->value_size
11165  ? g_base64_encode ((guchar *) param->value, param->value_size)
11166  : g_strdup ("");
11167 
11168  response = NULL;
11169  entity = NULL;
11170  ret = gmpf (connection, credentials, &response, &entity,
11171  response_data,
11172  "<modify_report_format"
11173  " report_format_id=\"%s\">"
11174  "<param>"
11175  "<name>%s</name>"
11176  "<value>%s</value>"
11177  "</param>"
11178  "</modify_report_format>",
11179  report_format_id, splits[3], value);
11180  g_free (value);
11181  switch (ret)
11182  {
11183  case 0:
11184  break;
11185  case 1:
11187  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11188  g_strfreev (splits);
11189  return gsad_message (
11190  credentials, "Internal error", __FUNCTION__, __LINE__,
11191  "An internal error occurred while saving a Report Format. "
11192  "The Report Format was not saved. "
11193  "Diagnostics: Failure to send command to manager daemon.",
11194  response_data);
11195  case 2:
11197  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11198  g_strfreev (splits);
11199  return gsad_message (
11200  credentials, "Internal error", __FUNCTION__, __LINE__,
11201  "An internal error occurred while saving a Report Format. "
11202  "It is unclear whether the Report Format has been saved or "
11203  "not. "
11204  "Diagnostics: Failure to receive response from manager "
11205  "daemon.",
11206  response_data);
11207  case -1:
11208  default:
11210  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
11211  g_strfreev (splits);
11212  return gsad_message (
11213  credentials, "Internal error", __FUNCTION__, __LINE__,
11214  "An internal error occurred while saving a Report Format. "
11215  "It is unclear whether the Report Format has been saved or "
11216  "not. "
11217  "Diagnostics: Internal Error.",
11218  response_data);
11219  }
11220 
11221  /* TODO Check if succeeded. response_from_entity_if_failed? */
11222  }
11223  g_strfreev (splits);
11224  }
11225  }
11226 
11227  response = NULL;
11228  entity = NULL;
11229  ret = gmpf (connection, credentials, &response, &entity, response_data,
11230  "<modify_report_format"
11231  " report_format_id=\"%s\">"
11232  "<name>%s</name>"
11233  "<summary>%s</summary>"
11234  "<active>%s</active>"
11235  "</modify_report_format>",
11236  report_format_id, name, summary, enable);
11237 
11238  switch (ret)
11239  {
11240  case 0:
11241  break;
11242  case -1:
11243  return response;
11244  case 1:
11245  cmd_response_data_set_status_code (response_data,
11246  MHD_HTTP_INTERNAL_SERVER_ERROR);
11247  return gsad_message (
11248  credentials, "Internal error", __FUNCTION__, __LINE__,
11249  "An internal error occurred while saving a Report Format. "
11250  "The Report Format was not saved. "
11251  "Diagnostics: Failure to send command to manager daemon.",
11252  response_data);
11253  case 2:
11254  cmd_response_data_set_status_code (response_data,
11255  MHD_HTTP_INTERNAL_SERVER_ERROR);
11256  return gsad_message (
11257  credentials, "Internal error", __FUNCTION__, __LINE__,
11258  "An internal error occurred while saving a Report Format. "
11259  "It is unclear whether the Report Format has been saved or not. "
11260  "Diagnostics: Failure to receive response from manager daemon.",
11261  response_data);
11262  default:
11263  cmd_response_data_set_status_code (response_data,
11264  MHD_HTTP_INTERNAL_SERVER_ERROR);
11265  return gsad_message (
11266  credentials, "Internal error", __FUNCTION__, __LINE__,
11267  "An internal error occurred while saving a Report Format. "
11268  "It is unclear whether the Report Format has been saved or not. "
11269  "Diagnostics: Internal Error.",
11270  response_data);
11271  }
11272 
11273  html = response_from_entity (connection, credentials, params, entity,
11274  "Save Report Format", response_data);
11275  free_entity (entity);
11276  g_free (response);
11277  return html;
11278 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), param::value, and param::value_size.

Here is the call graph for this function:

◆ save_role_gmp()

char* save_role_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a role, return the next page.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13981 of file gsad_gmp.c.

13983 {
13984  int ret;
13985  gchar *html, *response;
13986  const char *role_id, *name, *comment, *users;
13987  entity_t entity;
13988 
13989  role_id = params_value (params, "role_id");
13990  name = params_value (params, "name");
13991  comment = params_value (params, "comment");
13992  users = params_value (params, "users");
13993 
13994  CHECK_VARIABLE_INVALID (role_id, "Save Role");
13995  CHECK_VARIABLE_INVALID (name, "Save Role");
13996  CHECK_VARIABLE_INVALID (comment, "Save Role");
13997  CHECK_VARIABLE_INVALID (users, "Save Role");
13998 
13999  /* Modify the Role. */
14000 
14001  response = NULL;
14002  entity = NULL;
14003  ret = gmpf (connection, credentials, &response, &entity, response_data,
14004  "<modify_role role_id=\"%s\">"
14005  "<name>%s</name>"
14006  "<comment>%s</comment>"
14007  "<users>%s</users>"
14008  "</modify_role>",
14009  role_id, name, comment, users);
14010 
14011  switch (ret)
14012  {
14013  case 0:
14014  case -1:
14015  break;
14016  case 1:
14017  cmd_response_data_set_status_code (response_data,
14018  MHD_HTTP_INTERNAL_SERVER_ERROR);
14019  return gsad_message (
14020  credentials, "Internal error", __FUNCTION__, __LINE__,
14021  "An internal error occurred while saving a role. "
14022  "The role was not saved. "
14023  "Diagnostics: Failure to send command to manager daemon.",
14024  response_data);
14025  case 2:
14026  cmd_response_data_set_status_code (response_data,
14027  MHD_HTTP_INTERNAL_SERVER_ERROR);
14028  return gsad_message (
14029  credentials, "Internal error", __FUNCTION__, __LINE__,
14030  "An internal error occurred while saving a role. "
14031  "It is unclear whether the role has been saved or not. "
14032  "Diagnostics: Failure to receive response from manager daemon.",
14033  response_data);
14034  default:
14035  cmd_response_data_set_status_code (response_data,
14036  MHD_HTTP_INTERNAL_SERVER_ERROR);
14037  return gsad_message (
14038  credentials, "Internal error", __FUNCTION__, __LINE__,
14039  "An internal error occurred while saving a role. "
14040  "It is unclear whether the role has been saved or not. "
14041  "Diagnostics: Internal Error.",
14042  response_data);
14043  }
14044 
14045  html = response_from_entity (connection, credentials, params, entity,
14046  "Save Role", response_data);
14047  free_entity (entity);
14048  g_free (response);
14049  return html;
14050 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), response_from_entity(), and users.

Here is the call graph for this function:

◆ save_scanner_gmp()

char* save_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save scanner, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10229 of file gsad_gmp.c.

10231 {
10232  gchar *response = NULL;
10233  entity_t entity = NULL;
10234  const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
10235  const char *credential_id, *which_cert;
10236  char *html;
10237  int ret, is_unix_socket, in_use;
10238 
10239  scanner_id = params_value (params, "scanner_id");
10240  name = params_value (params, "name");
10241  comment = params_value (params, "comment");
10242  host = params_value (params, "scanner_host");
10243  is_unix_socket = (host && *host == '/') ? 1 : 0;
10244  port = params_value (params, "port");
10245  type = params_value (params, "scanner_type");
10246  which_cert = params_value (params, "which_cert");
10247  ca_pub = params_value (params, "ca_pub");
10248  credential_id = params_value (params, "credential_id");
10249  CHECK_VARIABLE_INVALID (scanner_id, "Edit Scanner");
10250  CHECK_VARIABLE_INVALID (name, "Edit Scanner");
10251  if (params_given (params, "scanner_host") == 0)
10252  in_use = 1;
10253  else
10254  {
10255  in_use = 0;
10256  CHECK_VARIABLE_INVALID (host, "Edit Scanner");
10257  CHECK_VARIABLE_INVALID (port, "Edit Scanner");
10258  CHECK_VARIABLE_INVALID (type, "Edit Scanner");
10259  }
10260  if (is_unix_socket == 0)
10261  {
10262  CHECK_VARIABLE_INVALID (ca_pub, "Edit Scanner");
10263  CHECK_VARIABLE_INVALID (which_cert, "Edit Scanner");
10264  }
10265 
10266  if (is_unix_socket)
10267  {
10268  ret = gmpf (connection, credentials, &response, &entity, response_data,
10269  "<modify_scanner scanner_id=\"%s\">"
10270  "<name>%s</name>"
10271  "<comment>%s</comment>"
10272  "</modify_scanner>",
10273  scanner_id, name, comment ?: "");
10274  }
10275  else if (strcmp (which_cert, "new") == 0
10276  || strcmp (which_cert, "default") == 0)
10277  {
10278  if (ca_pub == NULL)
10279  ca_pub = "";
10280  if (in_use)
10281  ret = gmpf (connection, credentials, &response, &entity, response_data,
10282  "<modify_scanner scanner_id=\"%s\">"
10283  "<name>%s</name>"
10284  "<comment>%s</comment>"
10285  "<ca_pub>%s</ca_pub>"
10286  "<credential id=\"%s\"/>"
10287  "</modify_scanner>",
10288  scanner_id, name, comment ?: "",
10289  strcmp (which_cert, "new") == 0 ? ca_pub : "",
10290  credential_id ? credential_id : "");
10291  else
10292  ret = gmpf (connection, credentials, &response, &entity, response_data,
10293  "<modify_scanner scanner_id=\"%s\">"
10294  "<name>%s</name>"
10295  "<comment>%s</comment>"
10296  "<host>%s</host>"
10297  "<port>%s</port>"
10298  "<type>%s</type>"
10299  "<ca_pub>%s</ca_pub>"
10300  "<credential id=\"%s\"/>"
10301  "</modify_scanner>",
10302  scanner_id, name, comment ?: "", host, port, type,
10303  strcmp (which_cert, "new") == 0 ? ca_pub : "",
10304  credential_id ? credential_id : "");
10305  }
10306  else
10307  {
10308  /* Using existing CA cert. */
10309  if (in_use)
10310  ret = gmpf (connection, credentials, &response, &entity, response_data,
10311  "<modify_scanner scanner_id=\"%s\">"
10312  "<name>%s</name>"
10313  "<comment>%s</comment>"
10314  "<credential id=\"%s\"/>"
10315  "</modify_scanner>",
10316  scanner_id, name, comment ?: "", credential_id);
10317  else
10318  ret = gmpf (connection, credentials, &response, &entity, response_data,
10319  "<modify_scanner scanner_id=\"%s\">"
10320  "<name>%s</name>"
10321  "<comment>%s</comment>"
10322  "<host>%s</host>"
10323  "<port>%s</port>"
10324  "<type>%s</type>"
10325  "<credential id=\"%s\"/>"
10326  "</modify_scanner>",
10327  scanner_id, name, comment ?: "", host, port, type,
10328  credential_id);
10329  }
10330 
10331  switch (ret)
10332  {
10333  case 0:
10334  case -1:
10335  break;
10336  case 1:
10337  cmd_response_data_set_status_code (response_data,
10338  MHD_HTTP_INTERNAL_SERVER_ERROR);
10339  return gsad_message (
10340  credentials, "Internal error", __FUNCTION__, __LINE__,
10341  "An internal error occurred while saving a scanner. "
10342  "The scanner remains the same. "
10343  "Diagnostics: Failure to send command to manager daemon.",
10344  response_data);
10345  case 2:
10346  cmd_response_data_set_status_code (response_data,
10347  MHD_HTTP_INTERNAL_SERVER_ERROR);
10348  return gsad_message (
10349  credentials, "Internal error", __FUNCTION__, __LINE__,
10350  "An internal error occurred while saving a scanner. "
10351  "It is unclear whether the scanner has been saved or not. "
10352  "Diagnostics: Failure to receive response from manager daemon.",
10353  response_data);
10354  default:
10355  cmd_response_data_set_status_code (response_data,
10356  MHD_HTTP_INTERNAL_SERVER_ERROR);
10357  return gsad_message (
10358  credentials, "Internal error", __FUNCTION__, __LINE__,
10359  "An internal error occurred while saving a scanner. "
10360  "It is unclear whether the scanner has been saved or not. "
10361  "Diagnostics: Internal Error.",
10362  response_data);
10363  }
10364 
10365  html = response_from_entity (connection, credentials, params, entity,
10366  "Save Scanner", response_data);
10367 
10368  free_entity (entity);
10369  g_free (response);
10370  return html;
10371 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), is_unix_socket(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_schedule_gmp()

char* save_schedule_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save schedule, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14554 of file gsad_gmp.c.

14556 {
14557  gchar *response;
14558  entity_t entity;
14559  const char *schedule_id, *name, *comment, *timezone, *icalendar;
14560  char *ret;
14561 
14562  schedule_id = params_value (params, "schedule_id");
14563  name = params_value (params, "name");
14564  comment = params_value (params, "comment");
14565  icalendar = params_value (params, "icalendar");
14566  timezone = params_value (params, "timezone");
14567 
14568  CHECK_VARIABLE_INVALID (schedule_id, "Save Schedule");
14569  CHECK_VARIABLE_INVALID (name, "Save Schedule");
14570  CHECK_VARIABLE_INVALID (comment, "Save Schedule");
14571  CHECK_VARIABLE_INVALID (icalendar, "Save Schedule");
14572  CHECK_VARIABLE_INVALID (timezone, "Save Schedule");
14573 
14574  response = NULL;
14575  entity = NULL;
14576  switch (gmpf (connection, credentials, &response, &entity, response_data,
14577  "<modify_schedule schedule_id=\"%s\">"
14578  "<name>%s</name>"
14579  "<comment>%s</comment>"
14580  "<timezone>%s</timezone>"
14581  "<icalendar>%s</icalendar>"
14582  "</modify_schedule>",
14583  schedule_id, name ? name : "", comment ? comment : "", timezone,
14584  icalendar))
14585  {
14586  case 0:
14587  case -1:
14588  break;
14589  case 1:
14590  cmd_response_data_set_status_code (response_data,
14591  MHD_HTTP_INTERNAL_SERVER_ERROR);
14592  return gsad_message (
14593  credentials, "Internal error", __FUNCTION__, __LINE__,
14594  "An internal error occurred while saving a schedule. "
14595  "The schedule remains the same. "
14596  "Diagnostics: Failure to send command to manager daemon.",
14597  response_data);
14598  case 2:
14599  cmd_response_data_set_status_code (response_data,
14600  MHD_HTTP_INTERNAL_SERVER_ERROR);
14601  return gsad_message (
14602  credentials, "Internal error", __FUNCTION__, __LINE__,
14603  "An internal error occurred while saving a schedule. "
14604  "It is unclear whether the schedule has been saved or not. "
14605  "Diagnostics: Failure to receive response from manager daemon.",
14606  response_data);
14607  default:
14608  cmd_response_data_set_status_code (response_data,
14609  MHD_HTTP_INTERNAL_SERVER_ERROR);
14610  return gsad_message (
14611  credentials, "Internal error", __FUNCTION__, __LINE__,
14612  "An internal error occurred while saving a schedule. "
14613  "It is unclear whether the schedule has been saved or not. "
14614  "Diagnostics: Internal Error.",
14615  response_data);
14616  }
14617 
14618  ret = response_from_entity (connection, credentials, params, entity,
14619  "Save Schedule", response_data);
14620  free_entity (entity);
14621  g_free (response);
14622  return ret;
14623 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_setting_gmp()

char* save_setting_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save user setting.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
An action response.

Definition at line 15577 of file gsad_gmp.c.

15579 {
15580  const gchar *setting_id = params_value (params, "setting_id");
15581  const gchar *setting_value = params_value (params, "setting_value");
15582  const gchar *setting_name = NULL;
15583 
15584  CHECK_VARIABLE_INVALID (setting_id, "Save Setting");
15585  CHECK_VARIABLE_INVALID (setting_value, "Save Setting");
15586 
15587  if (params_given (params, "setting_name"))
15588  {
15589  setting_name = params_value (params, "setting_name");
15590  CHECK_VARIABLE_INVALID (setting_name, "Save Settings")
15591  }
15592 
15593  gchar *value_64 =
15594  g_base64_encode ((guchar *) setting_value, strlen (setting_value));
15595  gchar *html;
15596  gchar *response = NULL;
15597  entity_t entity = NULL;
15598  int ret;
15599  GString *xml = g_string_new ("");
15600 
15601  xml_string_append (xml,
15602  "<modify_setting setting_id=\"%s\">"
15603  "<value>%s</value>",
15604  setting_id, value_64);
15605 
15606  if (setting_name)
15607  {
15608  xml_string_append (xml, "<name>%s</name>", setting_name);
15609  }
15610 
15611  xml_string_append (xml, "</modify_setting>");
15612 
15614 
15615  ret =
15616  gmp (connection, credentials, &response, &entity, response_data, xml->str);
15617 
15618  g_free (value_64);
15619  g_string_free (xml, TRUE);
15620 
15621  switch (ret)
15622  {
15623  case 0:
15624  case -1:
15625  break;
15626  case 1:
15627  cmd_response_data_set_status_code (response_data,
15628  MHD_HTTP_INTERNAL_SERVER_ERROR);
15629  return gsad_message (
15630  credentials, "Internal error", __FUNCTION__, __LINE__,
15631  "An internal error occurred while saving settings. "
15632  "It is unclear whether all the settings were saved. "
15633  "Diagnostics: Failure to send command to manager daemon.",
15634  response_data);
15635  case 2:
15636 
15637  cmd_response_data_set_status_code (response_data,
15638  MHD_HTTP_INTERNAL_SERVER_ERROR);
15639  return gsad_message (
15640  credentials, "Internal error", __FUNCTION__, __LINE__,
15641  "An internal error occurred while saving settings. "
15642  "It is unclear whether all the settings were saved. "
15643  "Diagnostics: Failure to receive response from manager daemon.",
15644  response_data);
15645  default:
15646 
15647  cmd_response_data_set_status_code (response_data,
15648  MHD_HTTP_INTERNAL_SERVER_ERROR);
15649  return gsad_message (credentials, "Internal error", __FUNCTION__,
15650  __LINE__,
15651  "An internal error occurred while saving settings. "
15652  "It is unclear whether all the settings were saved. "
15653  "Diagnostics: Internal Error.",
15654  response_data);
15655  }
15656  html = response_from_entity (connection, credentials, params, entity,
15657  "Save Setting", response_data);
15658  free_entity (entity);
15659  g_free (response);
15660  return html;
15661 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_content_type(), cmd_response_data_set_status_code(), gmp(), GSAD_CONTENT_TYPE_APP_XML, gsad_message(), params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_tag_gmp()

char* save_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a tag, get all tags, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6438 of file gsad_gmp.c.

6440 {
6441  gchar *response;
6442  const char *name, *comment, *filter, *value, *resource_type, *active;
6443  const char *resources_action;
6444  params_t *resource_ids;
6445  const char *tag_id;
6446  GString *command;
6447  entity_t entity;
6448  char *ret;
6449 
6450  tag_id = params_value (params, "tag_id");
6451  name = params_value (params, "tag_name");
6452  comment = params_value (params, "comment");
6453  filter = params_value (params, "filter");
6454  value = params_value (params, "tag_value");
6455  resource_type = params_value (params, "resource_type");
6456  resource_ids = params_values (params, "resource_ids:");
6457  resources_action = params_value (params, "resources_action");
6458  active = params_value (params, "active");
6459 
6460  CHECK_VARIABLE_INVALID (tag_id, "Save Tag")
6461  CHECK_VARIABLE_INVALID (name, "Save Tag")
6462  CHECK_VARIABLE_INVALID (comment, "Save Tag")
6463  if (params_given (params, "filter"))
6464  CHECK_VARIABLE_INVALID (filter, "Save Tag")
6465  CHECK_VARIABLE_INVALID (value, "Save Tag")
6466  if (params_given (params, "resources_action"))
6467  CHECK_VARIABLE_INVALID (resources_action, "Save Tag")
6468  CHECK_VARIABLE_INVALID (resource_type, "Save Tag")
6469  CHECK_VARIABLE_INVALID (active, "Save Tag")
6470 
6471  command = g_string_new ("");
6472 
6473  xml_string_append (command,
6474  "<modify_tag tag_id=\"%s\">"
6475  "<name>%s</name>"
6476  "<comment>%s</comment>"
6477  "<value>%s</value>"
6478  "<active>%s</active>"
6479  "<resources action=\"%s\" filter=\"%s\">"
6480  "<type>%s</type>",
6481  tag_id, name, comment, value, active,
6482  resources_action ? resources_action : "",
6483  filter ? filter : "", resource_type);
6484 
6485  if (resource_ids)
6486  {
6487  params_iterator_t iter;
6488  char *name;
6489  param_t *param;
6490 
6491  params_iterator_init (&iter, resource_ids);
6492  while (params_iterator_next (&iter, &name, &param))
6493  if (param->value && strcmp (param->value, "0"))
6494  g_string_append_printf (command, "<resource id=\"%s\"/>",
6495  param->value ? param->value : "");
6496  }
6497 
6498  xml_string_append (command, "</resources>"
6499  "</modify_tag>");
6500 
6501  response = NULL;
6502  entity = NULL;
6503  switch (gmp (connection, credentials, &response, &entity, response_data,
6504  command->str))
6505  {
6506  case 0:
6507  case -1:
6508  break;
6509  case 1:
6510  cmd_response_data_set_status_code (response_data,
6511  MHD_HTTP_INTERNAL_SERVER_ERROR);
6512  g_string_free (command, TRUE);
6513  return gsad_message (credentials, "Internal error", __FUNCTION__,
6514  __LINE__,
6515  "An internal error occurred while saving a tag. "
6516  "The tag remains the same. "
6517  "Diagnostics: Failure to send command to "
6518  "manager daemon.",
6519  response_data);
6520  case 2:
6521  cmd_response_data_set_status_code (response_data,
6522  MHD_HTTP_INTERNAL_SERVER_ERROR);
6523  g_string_free (command, TRUE);
6524  return gsad_message (credentials, "Internal error", __FUNCTION__,
6525  __LINE__,
6526  "An internal error occurred while saving a tag. "
6527  "It is unclear whether the tag has been saved "
6528  "or not. "
6529  "Diagnostics: Failure to receive response from "
6530  "manager daemon.",
6531  response_data);
6532  default:
6533  cmd_response_data_set_status_code (response_data,
6534  MHD_HTTP_INTERNAL_SERVER_ERROR);
6535  g_string_free (command, TRUE);
6536  return gsad_message (credentials, "Internal error", __FUNCTION__,
6537  __LINE__,
6538  "An internal error occurred while saving a tag. "
6539  "It is unclear whether the tag has been saved "
6540  "or not. "
6541  "Diagnostics: Internal Error.",
6542  response_data);
6543  }
6544 
6545  g_string_free (command, TRUE);
6546  ret = response_from_entity (connection, credentials, params, entity,
6547  "Save Tag", response_data);
6548 
6549  free_entity (entity);
6550  g_free (response);
6551  return ret;
6552 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), and param::value.

Here is the call graph for this function:

◆ save_target_gmp()

char* save_target_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a target, get all targets, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6785 of file gsad_gmp.c.

6787 {
6788  gchar *html, *response;
6789  const char *name, *hosts, *exclude_hosts, *comment;
6790  const char *target_ssh_credential, *port, *target_smb_credential;
6791  const char *target_esxi_credential, *target_snmp_credential;
6792  const char *target_source, *target_exclude_source;
6793  const char *target_id, *port_list_id, *reverse_lookup_only;
6794  const char *reverse_lookup_unify, *alive_tests, *in_use;
6795  GString *command;
6796 
6797  alive_tests = params_value (params, "alive_tests");
6798  name = params_value (params, "name");
6799  comment = params_value (params, "comment");
6800  in_use = params_value (params, "in_use");
6801  target_id = params_value (params, "target_id");
6802 
6803  CHECK_VARIABLE_INVALID (name, "Save Target");
6804  CHECK_VARIABLE_INVALID (target_id, "Save Target");
6805  CHECK_VARIABLE_INVALID (comment, "Save Target");
6806  CHECK_VARIABLE_INVALID (alive_tests, "Save Target");
6807  CHECK_VARIABLE_INVALID (in_use, "Save Target");
6808 
6809  if (str_equal (in_use, "1"))
6810  {
6811  entity_t entity;
6812  int ret;
6813 
6814  /* Target is in use. Modify fewer fields. */
6815 
6816  command = g_string_new ("");
6817  xml_string_append (command,
6818  "<modify_target target_id=\"%s\">"
6819  "<name>%s</name>"
6820  "<comment>%s</comment>"
6821  "<alive_tests>%s</alive_tests>"
6822  "</modify_target>",
6823  target_id, name ? name : "", comment ? comment : "",
6824  alive_tests);
6825 
6826  response = NULL;
6827  entity = NULL;
6828  ret = gmp (connection, credentials, &response, &entity, response_data,
6829  command->str);
6830  g_string_free (command, TRUE);
6831  switch (ret)
6832  {
6833  case 0:
6834  case -1:
6835  break;
6836  case 1:
6837  cmd_response_data_set_status_code (response_data,
6838  MHD_HTTP_INTERNAL_SERVER_ERROR);
6839  return gsad_message (
6840  credentials, "Internal error", __FUNCTION__, __LINE__,
6841  "An internal error occurred while saving a target. "
6842  "The target remains the same. "
6843  "Diagnostics: Failure to send command to manager daemon.",
6844  response_data);
6845  case 2:
6846  cmd_response_data_set_status_code (response_data,
6847  MHD_HTTP_INTERNAL_SERVER_ERROR);
6848  return gsad_message (
6849  credentials, "Internal error", __FUNCTION__, __LINE__,
6850  "An internal error occurred while saving a target. "
6851  "It is unclear whether the target has been saved or not. "
6852  "Diagnostics: Failure to receive response from manager daemon.",
6853  response_data);
6854  default:
6855  cmd_response_data_set_status_code (response_data,
6856  MHD_HTTP_INTERNAL_SERVER_ERROR);
6857  return gsad_message (
6858  credentials, "Internal error", __FUNCTION__, __LINE__,
6859  "An internal error occurred while saving a target. "
6860  "It is unclear whether the target has been saved or not. "
6861  "Diagnostics: Internal Error.",
6862  response_data);
6863  }
6864 
6865  html = response_from_entity (connection, credentials, params, entity,
6866  "Save Target", response_data);
6867 
6868  free_entity (entity);
6869  g_free (response);
6870  return html;
6871  }
6872 
6873  hosts = params_value (params, "hosts");
6874  exclude_hosts = params_value (params, "exclude_hosts");
6875  reverse_lookup_only = params_value (params, "reverse_lookup_only");
6876  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
6877  target_source = params_value (params, "target_source");
6878  target_exclude_source = params_value (params, "target_exclude_source");
6879  port_list_id = params_value (params, "port_list_id");
6880  target_ssh_credential = params_value (params, "ssh_credential_id");
6881  port = params_value (params, "port");
6882  target_smb_credential = params_value (params, "smb_credential_id");
6883  target_esxi_credential = params_value (params, "esxi_credential_id");
6884  target_snmp_credential = params_value (params, "snmp_credential_id");
6885 
6886  CHECK_VARIABLE_INVALID (target_source, "Save Target");
6887  CHECK_VARIABLE_INVALID (target_exclude_source, "Save Target");
6888  CHECK_VARIABLE_INVALID (port_list_id, "Save Target");
6889  CHECK_VARIABLE_INVALID (target_ssh_credential, "Save Target");
6890  CHECK_VARIABLE_INVALID (target_smb_credential, "Save Target");
6891  CHECK_VARIABLE_INVALID (target_esxi_credential, "Save Target");
6892  CHECK_VARIABLE_INVALID (target_snmp_credential, "Save Target");
6893 
6894  if (strcmp (target_ssh_credential, "--")
6895  && strcmp (target_ssh_credential, "0"))
6896  CHECK_VARIABLE_INVALID (port, "Save Target");
6897 
6898  if (str_equal (target_source, "manual"))
6899  {
6900  CHECK_VARIABLE_INVALID (hosts, "Save Target")
6901  }
6902 
6903  {
6904  int ret;
6905  gchar *ssh_credentials_element, *smb_credentials_element;
6906  gchar *esxi_credentials_element, *snmp_credentials_element;
6907  gchar *comment_element;
6908  entity_t entity;
6909 
6910  if (comment)
6911  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
6912  else
6913  comment_element = g_strdup ("");
6914 
6915  if (str_equal (target_ssh_credential, "--"))
6916  ssh_credentials_element = g_strdup ("");
6917  else
6918  ssh_credentials_element = g_strdup_printf ("<ssh_credential id=\"%s\">"
6919  "<port>%s</port>"
6920  "</ssh_credential>",
6921  target_ssh_credential, port);
6922 
6923  if (str_equal (target_smb_credential, "--"))
6924  smb_credentials_element = g_strdup ("");
6925  else
6926  smb_credentials_element =
6927  g_strdup_printf ("<smb_credential id=\"%s\"/>", target_smb_credential);
6928 
6929  if (str_equal (target_esxi_credential, "--"))
6930  esxi_credentials_element = g_strdup ("");
6931  else
6932  esxi_credentials_element = g_strdup_printf (
6933  "<esxi_credential id=\"%s\"/>", target_esxi_credential);
6934 
6935  if (str_equal (target_snmp_credential, "--"))
6936  snmp_credentials_element = g_strdup ("");
6937  else
6938  snmp_credentials_element = g_strdup_printf (
6939  "<snmp_credential id=\"%s\"/>", target_snmp_credential);
6940 
6941  command = g_string_new ("");
6942  xml_string_append (
6943  command,
6944  "<modify_target target_id=\"%s\">"
6945  "<name>%s</name>"
6946  "<hosts>%s</hosts>"
6947  "<exclude_hosts>%s</exclude_hosts>"
6948  "<reverse_lookup_only>%s</reverse_lookup_only>"
6949  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
6950  "<port_list id=\"%s\"/>"
6951  "<alive_tests>%s</alive_tests>",
6952  target_id, name,
6953  str_equal (target_source, "file") ? params_value (params, "file") : hosts,
6954  str_equal (target_exclude_source, "file")
6955  ? params_value (params, "exclude_file")
6956  : exclude_hosts,
6957  reverse_lookup_only ? reverse_lookup_only : "0",
6958  reverse_lookup_unify ? reverse_lookup_unify : "0", port_list_id,
6959  alive_tests);
6960 
6961  g_string_append_printf (command,
6962  "%s%s%s%s%s"
6963  "</modify_target>",
6964  comment_element, ssh_credentials_element,
6965  smb_credentials_element, esxi_credentials_element,
6966  snmp_credentials_element);
6967 
6968  g_free (comment_element);
6969  g_free (ssh_credentials_element);
6970  g_free (smb_credentials_element);
6971  g_free (esxi_credentials_element);
6972  g_free (snmp_credentials_element);
6973 
6974  /* Modify the target. */
6975 
6976  ret = gvm_connection_sendf (connection, "%s", command->str);
6977  g_string_free (command, TRUE);
6978 
6979  if (ret == -1)
6980  {
6981  cmd_response_data_set_status_code (response_data,
6982  MHD_HTTP_INTERNAL_SERVER_ERROR);
6983  return gsad_message (
6984  credentials, "Internal error", __FUNCTION__, __LINE__,
6985  "An internal error occurred while modifying target. "
6986  "No target was modified. "
6987  "Diagnostics: Failure to send command to manager daemon.",
6988  response_data);
6989  }
6990 
6991  entity = NULL;
6992  if (read_entity_and_text_c (connection, &entity, &response))
6993  {
6994  cmd_response_data_set_status_code (response_data,
6995  MHD_HTTP_INTERNAL_SERVER_ERROR);
6996  return gsad_message (
6997  credentials, "Internal error", __FUNCTION__, __LINE__,
6998  "An internal error occurred while modifying a target. "
6999  "It is unclear whether the target has been modified or not. "
7000  "Diagnostics: Failure to receive response from manager daemon.",
7001  response_data);
7002  }
7003 
7004  html = response_from_entity (connection, credentials, params, entity,
7005  "Save Target", response_data);
7006  }
7007 
7008  /* Pass response to handler of following page. */
7009 
7010  return html;
7011 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), params_value(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ save_task_gmp()

char* save_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Save task, get next page, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2472 of file gsad_gmp.c.

2474 {
2475  gchar *html, *response, *format;
2476  const char *comment, *name, *schedule_id, *in_assets;
2477  const char *scanner_id, *task_id, *max_checks, *max_hosts;
2478  const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
2479  const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
2480  const char *apply_overrides, *min_qod;
2481  int ret;
2482  params_t *alerts;
2483  GString *alert_element;
2484  entity_t entity;
2485 
2486  alterable = params_value (params, "alterable");
2487  apply_overrides = params_value (params, "apply_overrides");
2488  auto_delete = params_value (params, "auto_delete");
2489  auto_delete_data = params_value (params, "auto_delete_data");
2490  comment = params_value (params, "comment");
2491  config_id = params_value (params, "config_id");
2492  hosts_ordering = params_value (params, "hosts_ordering");
2493  in_assets = params_value (params, "in_assets");
2494  max_checks = params_value (params, "max_checks");
2495  max_hosts = params_value (params, "max_hosts");
2496  min_qod = params_value (params, "min_qod");
2497  name = params_value (params, "name");
2498  scanner_id = params_value (params, "scanner_id");
2499  scanner_type = params_value (params, "scanner_type");
2500  schedule_id = params_value (params, "schedule_id");
2501  schedule_periods = params_value (params, "schedule_periods");
2502  source_iface = params_value (params, "source_iface");
2503  target_id = params_value (params, "target_id");
2504  task_id = params_value (params, "task_id");
2505 
2506  if (scanner_type != NULL)
2507  {
2508  CHECK_VARIABLE_INVALID (scanner_type, "Save Task");
2509  if (!strcmp (scanner_type, "1"))
2510  {
2511  hosts_ordering = "";
2512  max_checks = "";
2513  source_iface = "";
2514  max_hosts = "";
2515  }
2516  else if (!strcmp (scanner_type, "3"))
2517  {
2518  config_id = "0";
2519  hosts_ordering = "";
2520  max_checks = "";
2521  source_iface = "";
2522  max_hosts = "";
2523  }
2524  }
2525 
2526  CHECK_VARIABLE_INVALID (name, "Save Task");
2527  CHECK_VARIABLE_INVALID (comment, "Save Task");
2528  CHECK_VARIABLE_INVALID (target_id, "Save Task");
2529  CHECK_VARIABLE_INVALID (hosts_ordering, "Save Task");
2530  CHECK_VARIABLE_INVALID (config_id, "Save Task");
2531  CHECK_VARIABLE_INVALID (schedule_id, "Save Task");
2532  if (params_given (params, "schedule_periods"))
2533  {
2534  CHECK_VARIABLE_INVALID (schedule_periods, "Save Task");
2535  }
2536  else
2537  schedule_periods = "0";
2538  CHECK_VARIABLE_INVALID (scanner_id, "Save Task");
2539  CHECK_VARIABLE_INVALID (task_id, "Save Task");
2540  CHECK_VARIABLE_INVALID (max_checks, "Save Task");
2541  CHECK_VARIABLE_INVALID (source_iface, "Save Task");
2542  CHECK_VARIABLE_INVALID (auto_delete, "Save Task");
2543  CHECK_VARIABLE_INVALID (auto_delete_data, "Save Task");
2544  CHECK_VARIABLE_INVALID (max_hosts, "Save Task");
2545  CHECK_VARIABLE_INVALID (in_assets, "Save Task");
2546 
2547  if (!strcmp (in_assets, "1"))
2548  {
2549  CHECK_VARIABLE_INVALID (apply_overrides, "Save Task");
2550  CHECK_VARIABLE_INVALID (min_qod, "Save Task");
2551  }
2552  else
2553  {
2554  if (!params_given (params, "apply_overrides")
2555  || !params_valid (params, "apply_overrides"))
2556  apply_overrides = "";
2557 
2558  if (!params_given (params, "min_qod")
2559  || !params_valid (params, "min_qod"))
2560  min_qod = "";
2561  }
2562 
2563  alert_element = g_string_new ("");
2564  if (params_given (params, "alert_id_optional:"))
2565  alerts = params_values (params, "alert_id_optional:");
2566  else
2567  alerts = params_values (params, "alert_ids:");
2568 
2569  if (alerts)
2570  {
2571  params_iterator_t iter;
2572  char *name;
2573  param_t *param;
2574 
2575  params_iterator_init (&iter, alerts);
2576  while (params_iterator_next (&iter, &name, &param))
2577  {
2578  if (param->value && strcmp (param->value, "0"))
2579  g_string_append_printf (alert_element, "<alert id=\"%s\"/>",
2580  param->value ? param->value : "");
2581  }
2582  }
2583 
2584  // Remove Alerts from Task if none are given.
2585  if (strcmp (alert_element->str, "") == 0)
2586  g_string_append_printf (alert_element, "<alert id=\"0\"/>");
2587 
2588  format = g_strdup_printf (
2589  "<modify_task task_id=\"%%s\">"
2590  "<name>%%s</name>"
2591  "<comment>%%s</comment>"
2592  "<hosts_ordering>%s</hosts_ordering>"
2593  "%s"
2594  "<target id=\"%%s\"/>"
2595  "<config id=\"%%s\"/>"
2596  "<schedule id=\"%%s\"/>"
2597  "<schedule_periods>%%s</schedule_periods>"
2598  "<scanner id=\"%%s\"/>"
2599  "<preferences>"
2600  "<preference>"
2601  "<scanner_name>max_checks</scanner_name>"
2602  "<value>%%s</value>"
2603  "</preference>"
2604  "<preference>"
2605  "<scanner_name>max_hosts</scanner_name>"
2606  "<value>%%s</value>"
2607  "</preference>"
2608  "<preference>"
2609  "<scanner_name>in_assets</scanner_name>"
2610  "<value>%%s</value>"
2611  "</preference>"
2612  "<preference>"
2613  "<scanner_name>assets_apply_overrides</scanner_name>"
2614  "<value>%%s</value>"
2615  "</preference>"
2616  "<preference>"
2617  "<scanner_name>assets_min_qod</scanner_name>"
2618  "<value>%%s</value>"
2619  "</preference>"
2620  "<preference>"
2621  "<scanner_name>source_iface</scanner_name>"
2622  "<value>%%s</value>"
2623  "</preference>"
2624  "<preference>"
2625  "<scanner_name>auto_delete</scanner_name>"
2626  "<value>%%s</value>"
2627  "</preference>"
2628  "<preference>"
2629  "<scanner_name>auto_delete_data</scanner_name>"
2630  "<value>%%s</value>"
2631  "</preference>"
2632  "</preferences>"
2633  "%s%i%s"
2634  "</modify_task>",
2635  hosts_ordering, alert_element->str, alterable ? "<alterable>" : "",
2636  alterable ? strcmp (alterable, "0") : 0, alterable ? "</alterable>" : "");
2637  response = NULL;
2638  entity = NULL;
2639  ret = gmpf (connection, credentials, &response, &entity, response_data,
2640  format, task_id, name, comment, target_id, config_id, schedule_id,
2641  schedule_periods, scanner_id, max_checks, max_hosts,
2642  strcmp (in_assets, "0") ? "yes" : "no",
2643  strcmp (apply_overrides, "0") ? "yes" : "no", min_qod,
2644  source_iface, auto_delete, auto_delete_data);
2645  g_free (format);
2646 
2647  g_string_free (alert_element, TRUE);
2648 
2649  switch (ret)
2650  {
2651  case 0:
2652  case -1:
2653  break;
2654  case 1:
2655  cmd_response_data_set_status_code (response_data,
2656  MHD_HTTP_INTERNAL_SERVER_ERROR);
2657  return gsad_message (
2658  credentials, "Internal error", __FUNCTION__, __LINE__,
2659  "An internal error occurred while saving a task. "
2660  "The task was not saved. "
2661  "Diagnostics: Failure to send command to manager daemon.",
2662  response_data);
2663  case 2:
2664  cmd_response_data_set_status_code (response_data,
2665  MHD_HTTP_INTERNAL_SERVER_ERROR);
2666  return gsad_message (
2667  credentials, "Internal error", __FUNCTION__, __LINE__,
2668  "An internal error occurred while saving a task. "
2669  "It is unclear whether the task has been saved or not. "
2670  "Diagnostics: Failure to receive response from manager daemon.",
2671  response_data);
2672  default:
2673  cmd_response_data_set_status_code (response_data,
2674  MHD_HTTP_INTERNAL_SERVER_ERROR);
2675  return gsad_message (
2676  credentials, "Internal error", __FUNCTION__, __LINE__,
2677  "An internal error occurred while saving a task. "
2678  "It is unclear whether the task has been saved or not. "
2679  "Diagnostics: Internal Error.",
2680  response_data);
2681  }
2682 
2683  html = response_from_entity (connection, credentials, params, entity,
2684  "Save Task", response_data);
2685  free_entity (entity);
2686  g_free (response);
2687  return html;
2688 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_valid(), params_value(), params_values(), response_from_entity(), and param::value.

Here is the call graph for this function:

◆ save_ticket_gmp()

char* save_ticket_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a ticket.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16696 of file gsad_gmp.c.

16698 {
16699  gchar *response = NULL;
16700  entity_t entity = NULL;
16701  const gchar *ticket_id, *status, *open_note, *fixed_note, *closed_note;
16702  const gchar *user_id;
16703  gchar *ret;
16704 
16705  ticket_id = params_value (params, "ticket_id");
16706  status = params_value (params, "ticket_status");
16707  open_note = params_value (params, "open_note");
16708  fixed_note = params_value (params, "fixed_note");
16709  closed_note = params_value (params, "closed_note");
16710  user_id = params_value (params, "user_id");
16711 
16712  CHECK_VARIABLE_INVALID (ticket_id, "Save Ticket");
16713  CHECK_VARIABLE_INVALID (status, "Save Ticket");
16714  CHECK_VARIABLE_INVALID (user_id, "Save Ticket");
16715  CHECK_VARIABLE_INVALID (open_note, "Save Ticket");
16716  CHECK_VARIABLE_INVALID (fixed_note, "Save Ticket");
16717  CHECK_VARIABLE_INVALID (closed_note, "Save Ticket");
16718 
16719  switch (gmpf (connection, credentials, &response, &entity, response_data,
16720  "<modify_ticket ticket_id=\"%s\">"
16721  "<assigned_to><user id=\"%s\"/></assigned_to>"
16722  "<status>%s</status>"
16723  "<open_note>%s</open_note>"
16724  "<fixed_note>%s</fixed_note>"
16725  "<closed_note>%s</closed_note>"
16726  "</modify_ticket>",
16727  ticket_id, user_id, status, open_note, fixed_note, closed_note))
16728  {
16729  case 0:
16730  case -1:
16731  break;
16732  case 1:
16733  cmd_response_data_set_status_code (response_data,
16734  MHD_HTTP_INTERNAL_SERVER_ERROR);
16735  return gsad_message (
16736  credentials, "Internal error", __FUNCTION__, __LINE__,
16737  "An internal error occurred while saving a ticket. "
16738  "Diagnostics: Failure to send command to manager daemon.",
16739  response_data);
16740  case 2:
16741  cmd_response_data_set_status_code (response_data,
16742  MHD_HTTP_INTERNAL_SERVER_ERROR);
16743  return gsad_message (
16744  credentials, "Internal error", __FUNCTION__, __LINE__,
16745  "An internal error occurred while saving a ticket. "
16746  "It is unclear whether the ticket has been saved or not. "
16747  "Diagnostics: Failure to receive response from manager daemon.",
16748  response_data);
16749  default:
16750  cmd_response_data_set_status_code (response_data,
16751  MHD_HTTP_INTERNAL_SERVER_ERROR);
16752  return gsad_message (
16753  credentials, "Internal error", __FUNCTION__, __LINE__,
16754  "An internal error occurred while saving a ticket. "
16755  "It is unclear whether the ticket has been saved or not. "
16756  "Diagnostics: Internal Error.",
16757  response_data);
16758  }
16759 
16760  ret = response_from_entity (connection, credentials, params, entity,
16761  "Save Ticket", response_data);
16762 
16763  free_entity (entity);
16764  g_free (response);
16765  return ret;
16766 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_tls_certificate_gmp()

char* save_tls_certificate_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a TLS certificate.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 16945 of file gsad_gmp.c.

16948 {
16949  gchar *response = NULL;
16950  entity_t entity = NULL;
16951  const gchar *tls_certificate_id, *name, *comment, *trust, *certificate_bin;
16952  size_t certificate_size;
16953  gchar *certificate_b64;
16954  gchar *ret;
16955 
16956  tls_certificate_id = params_value (params, "tls_certificate_id");
16957  name = params_value (params, "name");
16958  comment = params_value (params, "comment");
16959  trust = params_value (params, "trust");
16960  certificate_bin = params_value (params, "certificate_bin");
16961  certificate_size = params_value_size (params, "certificate_bin");
16962 
16963  certificate_b64 =
16964  (certificate_size > 0)
16965  ? g_base64_encode ((guchar *) certificate_bin, certificate_size)
16966  : g_strdup ("");
16967 
16968  CHECK_VARIABLE_INVALID (tls_certificate_id, "Save TLS Certificate");
16969  CHECK_VARIABLE_INVALID (name, "Save TLS Certificate");
16970  CHECK_VARIABLE_INVALID (comment, "Save TLS Certificate");
16971  CHECK_VARIABLE_INVALID (trust, "Save TLS Certificate");
16972 
16973  switch (gmpf (connection, credentials, &response, &entity, response_data,
16974  "<modify_tls_certificate tls_certificate_id=\"%s\">"
16975  "<name>%s</name>"
16976  "<comment>%s</comment>"
16977  "<trust>%s</trust>"
16978  "<certificate>%s</certificate>"
16979  "</modify_tls_certificate>",
16980  tls_certificate_id, name, comment, trust, certificate_b64))
16981  {
16982  case 0:
16983  case -1:
16984  break;
16985  case 1:
16986  cmd_response_data_set_status_code (response_data,
16987  MHD_HTTP_INTERNAL_SERVER_ERROR);
16988  return gsad_message (
16989  credentials, "Internal error", __FUNCTION__, __LINE__,
16990  "An internal error occurred while saving a TLS certificate. "
16991  "Diagnostics: Failure to send command to manager daemon.",
16992  response_data);
16993  case 2:
16994  cmd_response_data_set_status_code (response_data,
16995  MHD_HTTP_INTERNAL_SERVER_ERROR);
16996  return gsad_message (
16997  credentials, "Internal error", __FUNCTION__, __LINE__,
16998  "An internal error occurred while saving a TLS certificate. "
16999  "It is unclear whether the TLS certificate has been saved or not. "
17000  "Diagnostics: Failure to receive response from manager daemon.",
17001  response_data);
17002  default:
17003  cmd_response_data_set_status_code (response_data,
17004  MHD_HTTP_INTERNAL_SERVER_ERROR);
17005  return gsad_message (
17006  credentials, "Internal error", __FUNCTION__, __LINE__,
17007  "An internal error occurred while saving a TLS certificate. "
17008  "It is unclear whether the TLS certificate has been saved or not. "
17009  "Diagnostics: Internal Error.",
17010  response_data);
17011  }
17012 
17013  ret = response_from_entity (connection, credentials, params, entity,
17014  "Save TLS Certificate", response_data);
17015 
17016  free_entity (entity);
17017  g_free (response);
17018  g_free (certificate_b64);
17019  return ret;
17020 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), params_value_size(), and response_from_entity().

Here is the call graph for this function:

◆ save_user_gmp()

char* save_user_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Modify a user, get all users, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15018 of file gsad_gmp.c.

15020 {
15021  int ret;
15022  gchar *html, *response, *buf;
15023  const char *user_id, *login, *old_login, *modify_password, *password;
15024  const char *hosts, *hosts_allow, *ifaces, *ifaces_allow, *comment;
15025  entity_t entity;
15026  GString *command, *group_elements, *role_elements;
15027  params_t *groups, *roles;
15028 
15029  /* List of hosts user has/lacks access rights. */
15030  hosts = params_value (params, "access_hosts");
15031  /* Whether hosts grants ("1") or forbids ("0") access. "2" for all
15032  * access. */
15033  hosts_allow = params_value (params, "hosts_allow");
15034  ifaces = params_value (params, "access_ifaces");
15035  ifaces_allow = params_value (params, "ifaces_allow");
15036  login = params_value (params, "login");
15037  old_login = params_value (params, "old_login");
15038  modify_password = params_value (params, "modify_password");
15039  password = params_value (params, "password");
15040  user_id = params_value (params, "user_id");
15041  comment = params_value (params, "comment");
15042 
15043  CHECK_VARIABLE_INVALID (user_id, "Save User");
15044  CHECK_VARIABLE_INVALID (modify_password, "Save User");
15045  CHECK_VARIABLE_INVALID (hosts, "Save User");
15046  CHECK_VARIABLE_INVALID (hosts_allow, "Save User");
15047  CHECK_VARIABLE_INVALID (ifaces, "Save User");
15048  CHECK_VARIABLE_INVALID (ifaces_allow, "Save User");
15049  CHECK_VARIABLE_INVALID (login, "Save User");
15050  CHECK_VARIABLE_INVALID (old_login, "Save User");
15051 
15052  if (modify_password && str_equal (modify_password, "1"))
15053  {
15054  // require password if modify_password is 1 (== set new password)
15055  CHECK_VARIABLE_INVALID (password, "Save User");
15056  }
15057 
15058  if (params_given (params, "comment"))
15059  {
15060  CHECK_VARIABLE_INVALID (comment, "Save User");
15061  }
15062 
15063  /* Modify the user. */
15064 
15065  command = g_string_new ("");
15066  buf = g_markup_printf_escaped ("<modify_user user_id=\"%s\">"
15067  "<password modify=\"%s\">"
15068  "%s</password>",
15069  user_id, modify_password,
15070  password ? password : "");
15071  g_string_append (command, buf);
15072  g_free (buf);
15073 
15074  if (login)
15075  {
15076  buf = g_markup_printf_escaped ("<new_name>%s</new_name>", login);
15077  g_string_append (command, buf);
15078  g_free (buf);
15079  }
15080 
15081  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
15082  "<ifaces allow=\"%s\">%s</ifaces>",
15083  hosts_allow, hosts, ifaces_allow, ifaces);
15084  g_string_append (command, buf);
15085  g_free (buf);
15086 
15087  if (modify_password && !strcmp (modify_password, "2"))
15088  g_string_append (command,
15089  "<sources><source>ldap_connect</source></sources>");
15090  else if (modify_password && !strcmp (modify_password, "3"))
15091  g_string_append (command,
15092  "<sources><source>radius_connect</source></sources>");
15093  else
15094  g_string_append (command, "<sources><source>file</source></sources>");
15095 
15096  group_elements = g_string_new ("<groups>");
15097  if (params_given (params, "group_id_optional:"))
15098  groups = params_values (params, "group_id_optional:");
15099  else
15100  groups = params_values (params, "group_ids:");
15101 
15102  if (groups)
15103  {
15104  params_iterator_t iter;
15105  char *name;
15106  param_t *param;
15107 
15108  params_iterator_init (&iter, groups);
15109  while (params_iterator_next (&iter, &name, &param))
15110  {
15111  if (param->value && strcmp (param->value, "--"))
15112  g_string_append_printf (group_elements, "<group id=\"%s\"/>",
15113  param->value ? param->value : "");
15114  }
15115  }
15116  g_string_append (command, group_elements->str);
15117  g_string_free (group_elements, TRUE);
15118  g_string_append (command, "</groups>");
15119 
15120  role_elements = g_string_new ("");
15121  if (params_given (params, "role_id_optional:"))
15122  roles = params_values (params, "role_id_optional:");
15123  else
15124  roles = params_values (params, "role_ids:");
15125 
15126  if (roles)
15127  {
15128  params_iterator_t iter;
15129  char *name;
15130  param_t *param;
15131 
15132  params_iterator_init (&iter, roles);
15133  while (params_iterator_next (&iter, &name, &param))
15134  {
15135  if (param->value && strcmp (param->value, "--"))
15136  g_string_append_printf (role_elements, "<role id=\"%s\"/>",
15137  param->value ? param->value : "");
15138  }
15139  }
15140  else
15141  g_string_append_printf (role_elements, "<role id=\"0\"/>");
15142 
15143  g_string_append (command, role_elements->str);
15144  g_string_free (role_elements, TRUE);
15145 
15146  if (comment)
15147  {
15148  xml_string_append (command, "<comment>%s</comment>", comment);
15149  }
15150 
15151  g_string_append (command, "</modify_user>");
15152 
15153  response = NULL;
15154  entity = NULL;
15155  ret = gmp (connection, credentials, &response, &entity, response_data,
15156  command->str);
15157  g_string_free (command, TRUE);
15158 
15159  user_t *current_user = credentials_get_user (credentials);
15160 
15161  switch (ret)
15162  {
15163  case 0:
15164  if (gmp_success (entity) == 1)
15165  {
15166  user_t *user = session_get_user_by_username (old_login);
15167 
15168  if (user
15169  && (!str_equal (modify_password, "0")
15170  || !str_equal (old_login, login)))
15171  {
15172  /* logout all other user sessions if new password was set,
15173  authentication type has changed or username has changed */
15175  user);
15176  }
15177 
15178  if (str_equal (old_login, user_get_username (current_user)))
15179  {
15180  /* update username of current user */
15181  user_set_username (current_user, login);
15182 
15183  if (str_equal (modify_password, "1"))
15184  {
15185  /* update password of current user */
15186  user_set_password (current_user, password);
15187  }
15188  }
15189  }
15190  break;
15191  case -1:
15192  break;
15193  case 1:
15194  cmd_response_data_set_status_code (response_data,
15195  MHD_HTTP_INTERNAL_SERVER_ERROR);
15196  return gsad_message (
15197  credentials, "Internal error", __FUNCTION__, __LINE__,
15198  "An internal error occurred while saving a user. "
15199  "The user was not saved. "
15200  "Diagnostics: Failure to send command to manager daemon.",
15201  response_data);
15202  case 2:
15203  cmd_response_data_set_status_code (response_data,
15204  MHD_HTTP_INTERNAL_SERVER_ERROR);
15205  return gsad_message (
15206  credentials, "Internal error", __FUNCTION__, __LINE__,
15207  "An internal error occurred while saving a user. "
15208  "It is unclear whether the user has been saved or not. "
15209  "Diagnostics: Failure to receive response from manager daemon.",
15210  response_data);
15211  default:
15212  cmd_response_data_set_status_code (response_data,
15213  MHD_HTTP_INTERNAL_SERVER_ERROR);
15214  return gsad_message (
15215  credentials, "Internal error", __FUNCTION__, __LINE__,
15216  "An internal error occurred while saving a user. "
15217  "It is unclear whether the user has been saved or not. "
15218  "Diagnostics: Internal Error.",
15219  response_data);
15220  }
15221 
15222  if (gmp_success (entity)
15223  && (str_equal (modify_password, "2") || !str_equal (modify_password, "3"))
15224  && str_equal (old_login, user_get_username (current_user)))
15225  {
15226  free_entity (entity);
15227  g_free (response);
15228 
15229  cmd_response_data_set_status_code (response_data, MHD_HTTP_UNAUTHORIZED);
15230  return gsad_message (
15231  credentials, "Authentication Required", __FUNCTION__, __LINE__,
15232  "Authentication method changed. Please login with ", response_data);
15233  }
15234  else
15235  html = response_from_entity (connection, credentials, params, entity,
15236  "Save User", response_data);
15237  free_entity (entity);
15238  g_free (response);
15239  return html;
15240 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), credentials_get_user(), gmp(), gmp_success(), gsad_message(), login(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), session_get_user_by_username(), session_remove_other_sessions(), str_equal(), user_get_token(), user_get_username(), user_set_password(), user_set_username(), and param::value.

Here is the call graph for this function:

◆ send_settings_filters()

static int send_settings_filters ( gvm_connection_t *  connection,
params_t *  data,
params_t *  changed,
GString *  xml,
int *  modify_failed_flag,
cmd_response_data_t *  response_data 
)
static

Send settings resource filters.

Parameters
[in]connectionConnection to Manager.
[in]dataData.
[in]changedParams indicating which settings changed.
[out]xmlGString to write responses to.
[out]modify_failed_flagPointer to an int to set to 1 on failure to modify one of the settings.
Returns
0 on success, -1 on error.

Definition at line 11516 of file gsad_gmp.c.

11519 {
11520  if (data)
11521  {
11522  params_iterator_t iter;
11523  char *uuid;
11524  param_t *param;
11525  entity_t entity;
11526 
11527  params_iterator_init (&iter, data);
11528  while (params_iterator_next (&iter, &uuid, &param))
11529  {
11530  const char *changed_value = params_value (changed, uuid);
11531  if (changed_value == NULL
11532  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
11533  {
11534  gchar *base64;
11535  if (param->value)
11536  base64 = g_base64_encode ((guchar *) param->value,
11537  strlen (param->value));
11538  else
11539  base64 = g_strdup ("");
11540  if (gvm_connection_sendf_xml (connection,
11541  "<modify_setting setting_id=\"%s\">"
11542  "<value>%s</value>"
11543  "</modify_setting>",
11544  uuid, base64))
11545  {
11546  g_free (base64);
11547  return -1;
11548  }
11549 
11550  g_free (base64);
11551 
11552  entity = NULL;
11553  xml_string_append (xml, "<save_setting id=\"%s\">", uuid);
11554  if (read_entity_and_string_c (connection, &entity, &xml))
11555  {
11556  free_entity (entity);
11557  return -1;
11558  }
11559  xml_string_append (xml, "</save_setting>");
11560  if (!gmp_success (entity))
11561  {
11562  set_http_status_from_entity (entity, response_data);
11563  if (modify_failed_flag)
11564  *modify_failed_flag = 1;
11565  }
11566  free_entity (entity);
11567  }
11568  }
11569  }
11570  return 0;
11571 }

References gmp_success(), params_iterator_init, params_iterator_next(), params_iterator_t, params_value(), set_http_status_from_entity(), and param::value.

Referenced by save_my_settings_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_http_status_from_entity()

void set_http_status_from_entity ( entity_t  entity,
cmd_response_data_t *  response_data 
)

Set the HTTP status according to GMP response entity.

Parameters
[in]entityThe GMP response entity.
[in]response_dataResponse data.

Definition at line 547 of file gsad_gmp.c.

549 {
550  if (entity == NULL)
551  cmd_response_data_set_status_code (response_data,
552  MHD_HTTP_INTERNAL_SERVER_ERROR);
553  else if (str_equal (entity_attribute (entity, "status_text"),
554  "Permission denied"))
555  cmd_response_data_set_status_code (response_data, MHD_HTTP_FORBIDDEN);
556  else if (str_equal (entity_attribute (entity, "status"), "404"))
557  cmd_response_data_set_status_code (response_data, MHD_HTTP_NOT_FOUND);
558  else
559  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
560 }

References cmd_response_data_set_status_code(), and str_equal().

Referenced by delete_resource(), export_many(), export_resource(), get_aggregate_gmp(), get_capabilities_gmp(), get_entities(), get_entity(), get_report(), resource_action(), response_from_entity(), save_my_settings_gmp(), send_settings_filters(), and setting_get_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setting_get_value()

static int setting_get_value ( gvm_connection_t *  connection,
const char *  setting_id,
gchar **  value,
cmd_response_data_t *  response_data 
)
static

Get a setting by UUID for the current user of an GMP connection.

Parameters
[in]connectionConnection.
[in]setting_idUUID of the setting to get.
[out]valueValue of the setting.
[out]response_dataExtra data return for the HTTP response.
Returns
-1 internal error, 0 success, 1 send error, 2 read error.

Definition at line 648 of file gsad_gmp.c.

650 {
651  int ret;
652  entity_t entity;
653  const char *status;
654  gchar *response;
655 
656  *value = NULL;
657 
658  ret = gvm_connection_sendf (connection, "<get_settings setting_id=\"%s\"/>",
659  setting_id);
660  if (ret)
661  return 1;
662 
663  entity = NULL;
664  if (read_entity_and_text_c (connection, &entity, &response))
665  return 2;
666 
667  status = entity_attribute (entity, "status");
668  if (status == NULL || strlen (status) == 0)
669  {
670  g_free (response);
671  free_entity (entity);
672  return -1;
673  }
674 
675  if (status[0] == '2')
676  {
677  entity_t setting;
678  setting = entity_child (entity, "setting");
679  if (setting == NULL)
680  {
681  free_entity (entity);
682  g_free (response);
683  return 0;
684  }
685  setting = entity_child (setting, "value");
686  if (setting == NULL)
687  {
688  free_entity (entity);
689  g_free (response);
690  return -1;
691  }
692  *value = g_strdup (entity_text (setting));
693  g_free (response);
694  free_entity (entity);
695  }
696  else
697  {
698  if (response_data)
699  set_http_status_from_entity (entity, response_data);
700  free_entity (entity);
701  g_free (response);
702  return -1;
703  }
704 
705  return 0;
706 }

References set_http_status_from_entity().

Referenced by authenticate_gmp(), export_many(), export_resource(), and get_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_task_gmp()

char* start_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Start a task, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2876 of file gsad_gmp.c.

2878 {
2879  return resource_action (connection, credentials, params, "task", "start",
2880  response_data);
2881 }

References resource_action().

Here is the call graph for this function:

◆ stop_task_gmp()

char* stop_task_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Stop a task, get all tasks, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2840 of file gsad_gmp.c.

2842 {
2843  return resource_action (connection, credentials, params, "task", "stop",
2844  response_data);
2845 }

References resource_action().

Here is the call graph for this function:

◆ sync_cert_gmp()

char* sync_cert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Synchronize with a CERT feed and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14226 of file gsad_gmp.c.

14228 {
14229  return sync_feed (connection, credentials, params, "sync_cert",
14230  "Synchronize CERT Feed", "the CERT feed", response_data);
14231 }

References sync_feed().

Here is the call graph for this function:

◆ sync_feed()

static char* sync_feed ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  sync_cmd,
const char *  action,
const char *  feed_name,
cmd_response_data_t *  response_data 
)
static

Synchronize with a feed and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[in]sync_cmdName of the GMP command used to sync the feed.
[in]actionAction shown in gsad status messages.
[in]feed_nameName of the feed shown in error messages.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14133 of file gsad_gmp.c.

14136 {
14137  entity_t entity;
14138  char *text = NULL;
14139  gchar *html, *msg;
14140 
14141  if (gvm_connection_sendf (connection, "<%s/>", sync_cmd) == -1)
14142  {
14143  cmd_response_data_set_status_code (response_data,
14144  MHD_HTTP_INTERNAL_SERVER_ERROR);
14145 
14146  msg = g_strdup_printf (
14147  "An internal error occurred while synchronizing with %s. "
14148  "Feed synchronization is currently not available. "
14149  "Diagnostics: Failure to send command to manager daemon.",
14150  feed_name);
14151  html = gsad_message (credentials, "Internal error", __FUNCTION__,
14152  __LINE__, msg, response_data);
14153  g_free (msg);
14154  return html;
14155  }
14156 
14157  if (read_entity_and_text_c (connection, &entity, &text))
14158  {
14159  cmd_response_data_set_status_code (response_data,
14160  MHD_HTTP_INTERNAL_SERVER_ERROR);
14161 
14162  msg = g_strdup_printf (
14163  "An internal error occurred while synchronizing with %s. "
14164  "Feed synchronization is currently not available. "
14165  "Diagnostics: Failure to receive response from manager daemon.",
14166  feed_name);
14167  html = gsad_message (credentials, "Internal error", __FUNCTION__,
14168  __LINE__, msg, response_data);
14169  g_free (msg);
14170  return html;
14171  }
14172 
14173  html = response_from_entity (connection, credentials, params, entity, action,
14174  response_data);
14175 
14176  return html;
14177 }

References cmd_response_data_set_status_code(), gsad_message(), and response_from_entity().

Referenced by sync_cert_gmp(), sync_feed_gmp(), and sync_scap_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_feed_gmp()

char* sync_feed_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Synchronize with an NVT feed and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14190 of file gsad_gmp.c.

14192 {
14193  return sync_feed (connection, credentials, params, "sync_feed",
14194  "Synchronize Feed", "the NVT feed", response_data);
14195 }

References sync_feed().

Here is the call graph for this function:

◆ sync_scap_gmp()

char* sync_scap_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Synchronize with a SCAP feed and envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 14208 of file gsad_gmp.c.

14210 {
14211  return sync_feed (connection, credentials, params, "sync_scap",
14212  "Synchronize Feed", "the SCAP feed", response_data);
14213 }

References sync_feed().

Here is the call graph for this function:

◆ test_alert_gmp()

char* test_alert_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Test an alert, get all alerts envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 5776 of file gsad_gmp.c.

5778 {
5779  gchar *html, *response;
5780  const char *alert_id;
5781  entity_t entity;
5782 
5783  alert_id = params_value (params, "alert_id");
5784 
5785  if (alert_id == NULL)
5786  {
5787  cmd_response_data_set_status_code (response_data,
5789  return gsad_message (credentials, "Invalid request", __FUNCTION__,
5790  __LINE__,
5791  "Missing parameter alert_id."
5792  "Diagnostics: Required parameter was NULL.",
5793  response_data);
5794  }
5795 
5796  /* Test the alert. */
5797 
5798  if (gvm_connection_sendf (connection, "<test_alert alert_id=\"%s\"/>",
5799  alert_id)
5800  == -1)
5801  {
5802  cmd_response_data_set_status_code (response_data,
5803  MHD_HTTP_INTERNAL_SERVER_ERROR);
5804  return gsad_message (
5805  credentials, "Internal error", __FUNCTION__, __LINE__,
5806  "An internal error occurred while testing an alert. "
5807  "Diagnostics: Failure to send command to manager daemon.",
5808  response_data);
5809  }
5810 
5811  entity = NULL;
5812  if (read_entity_and_text_c (connection, &entity, &response))
5813  {
5814  cmd_response_data_set_status_code (response_data,
5815  MHD_HTTP_INTERNAL_SERVER_ERROR);
5816  return gsad_message (
5817  credentials, "Internal error", __FUNCTION__, __LINE__,
5818  "An internal error occurred while testing an alert. "
5819  "Diagnostics: Failure to receive response from manager daemon.",
5820  response_data);
5821  }
5822 
5823  html = response_from_entity (connection, credentials, params, entity,
5824  "Test Alert", response_data);
5825 
5826  free_entity (entity);
5827  g_free (response);
5828  return html;
5829 }

References cmd_response_data_set_status_code(), gsad_message(), GSAD_STATUS_INVALID_REQUEST, params_value(), and response_from_entity().

Here is the call graph for this function:

◆ toggle_tag_gmp()

char* toggle_tag_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Set tag enabled status.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 6657 of file gsad_gmp.c.

6659 {
6660  gchar *html, *response;
6661  const char *tag_id, *enable;
6662  entity_t entity;
6663 
6664  tag_id = params_value (params, "tag_id");
6665  enable = params_value (params, "enable");
6666 
6667  CHECK_VARIABLE_INVALID (tag_id, "Toggle Tag")
6668  CHECK_VARIABLE_INVALID (enable, "Toggle Tag")
6669 
6670  /* Delete the resource and get all resources. */
6671 
6672  if (gvm_connection_sendf (connection,
6673  "<modify_tag tag_id=\"%s\">"
6674  "<active>%s</active>"
6675  "</modify_tag>",
6676  tag_id, enable)
6677  == -1)
6678  {
6679  cmd_response_data_set_status_code (response_data,
6680  MHD_HTTP_INTERNAL_SERVER_ERROR);
6681  return gsad_message (credentials, "Internal error", __FUNCTION__,
6682  __LINE__,
6683  "An internal error occurred while modifying a tag. "
6684  "The tag is not modified. "
6685  "Diagnostics: Failure to send command to"
6686  " manager daemon.",
6687  response_data);
6688  }
6689 
6690  entity = NULL;
6691  if (read_entity_and_text_c (connection, &entity, &response))
6692  {
6693  cmd_response_data_set_status_code (response_data,
6694  MHD_HTTP_INTERNAL_SERVER_ERROR);
6695  return gsad_message (credentials, "Internal error", __FUNCTION__,
6696  __LINE__,
6697  "An internal error occurred while modifying a tag. "
6698  "It is unclear whether the tag has been modified"
6699  " or not. "
6700  "Diagnostics: Failure to read response from"
6701  " manager daemon.",
6702  response_data);
6703  }
6704 
6705  html = response_from_entity (connection, credentials, params, entity,
6706  "Toggle Tag", response_data);
6707 
6708  free_entity (entity);
6709  g_free (response);
6710 
6711  return html;
6712 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ verify_agent_gmp()

char* verify_agent_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Verify agent, get agents, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 4377 of file gsad_gmp.c.

4379 {
4380  gchar *html, *response;
4381  const char *agent_id;
4382  int ret;
4383  entity_t entity;
4384 
4385  agent_id = params_value (params, "agent_id");
4386  if (agent_id == NULL)
4387  {
4388  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
4389  return gsad_message (
4390  credentials, "Internal error", __FUNCTION__, __LINE__,
4391  "An internal error occurred while verifying an agent. "
4392  "Diagnostics: Required parameter was NULL.",
4393  response_data);
4394  }
4395  response = NULL;
4396  entity = NULL;
4397  ret = gmpf (connection, credentials, &response, &entity, response_data,
4398  "<verify_agent agent_id=\"%s\" />", agent_id);
4399 
4400  switch (ret)
4401  {
4402  case 0:
4403  case -1:
4404  break;
4405  case 1:
4406  cmd_response_data_set_status_code (response_data,
4407  MHD_HTTP_INTERNAL_SERVER_ERROR);
4408  return gsad_message (
4409  credentials, "Internal error", __FUNCTION__, __LINE__,
4410  "An internal error occurred while verifying a agent. "
4411  "The agent was not verified. "
4412  "Diagnostics: Failure to send command to manager daemon.",
4413  response_data);
4414  case 2:
4415  cmd_response_data_set_status_code (response_data,
4416  MHD_HTTP_INTERNAL_SERVER_ERROR);
4417  return gsad_message (
4418  credentials, "Internal error", __FUNCTION__, __LINE__,
4419  "An internal error occurred while verifying a agent. "
4420  "It is unclear whether the agent was verified or not. "
4421  "Diagnostics: Failure to send command to manager daemon.",
4422  response_data);
4423  default:
4424  cmd_response_data_set_status_code (response_data,
4425  MHD_HTTP_INTERNAL_SERVER_ERROR);
4426  return gsad_message (
4427  credentials, "Internal error", __FUNCTION__, __LINE__,
4428  "An internal error occurred while verifying a agent. "
4429  "It is unclear whether the agent was verified or not. "
4430  "Diagnostics: Failure to send command to manager daemon.",
4431  response_data);
4432  }
4433 
4434  html = response_from_entity (connection, credentials, params, entity,
4435  "Verify Agent", response_data);
4436  free_entity (entity);
4437  g_free (response);
4438  return html;
4439 }

References cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ verify_scanner_gmp()

char* verify_scanner_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Verify scanner, get scanners, envelope the result.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 10048 of file gsad_gmp.c.

10050 {
10051  gchar *html, *response;
10052  const char *scanner_id;
10053  int ret;
10054  entity_t entity;
10055 
10056  scanner_id = params_value (params, "scanner_id");
10057  CHECK_VARIABLE_INVALID (scanner_id, "Verify Scanner");
10058 
10059  ret = gmpf (connection, credentials, &response, &entity, response_data,
10060  "<verify_scanner scanner_id=\"%s\"/>", scanner_id);
10061 
10062  switch (ret)
10063  {
10064  case 0:
10065  case -1:
10066  break;
10067  case 1:
10068  cmd_response_data_set_status_code (response_data,
10069  MHD_HTTP_INTERNAL_SERVER_ERROR);
10070  return gsad_message (
10071  credentials, "Internal error", __FUNCTION__, __LINE__,
10072  "An internal error occurred while verifying a scanner. "
10073  "The scanner was not verified. "
10074  "Diagnostics: Failure to send command to manager daemon.",
10075  response_data);
10076  case 2:
10077  cmd_response_data_set_status_code (response_data,
10078  MHD_HTTP_INTERNAL_SERVER_ERROR);
10079  return gsad_message (
10080  credentials, "Internal error", __FUNCTION__, __LINE__,
10081  "An internal error occurred while verifying a scanner. "
10082  "It is unclear whether the scanner was verified or not. "
10083  "Diagnostics: Failure to send command to manager daemon.",
10084  response_data);
10085  default:
10086  cmd_response_data_set_status_code (response_data,
10087  MHD_HTTP_INTERNAL_SERVER_ERROR);
10088  return gsad_message (
10089  credentials, "Internal error", __FUNCTION__, __LINE__,
10090  "An internal error occurred while verifying a scanner. "
10091  "It is unclear whether the scanner was verified or not. "
10092  "Diagnostics: Failure to send command to manager daemon.",
10093  response_data);
10094  }
10095 
10096  html = response_from_entity (connection, credentials, params, entity,
10097  "Verify Scanner", response_data);
10098  free_entity (entity);
10099  g_free (response);
10100  return html;
10101 }

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmpf(), gsad_message(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ wizard()

char * wizard ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Returns a wizard page.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15721 of file gsad_gmp.c.

15724 {
15725  GString *xml;
15726  const char *name = params_value (params, "name");
15727 
15728  if (name == NULL)
15729  {
15730  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
15731  return gsad_message (
15732  credentials, "Internal error", __FUNCTION__, __LINE__,
15733  "An internal error occurred while getting the wizard. "
15734  "Given name was invalid",
15735  response_data);
15736  }
15737 
15738  xml = g_string_new ("");
15739  g_string_append_printf (xml, "<wizard>%s<%s/>", extra_xml ? extra_xml : "",
15740  name);
15741 
15742  /* Try to run init mode of the wizard */
15743  if (gvm_connection_sendf_xml (connection,
15744  "<run_wizard read_only=\"1\">"
15745  "<name>%s</name>"
15746  "<mode>init</mode>"
15747  "</run_wizard>",
15748  name)
15749  == -1)
15750  {
15751  g_string_free (xml, TRUE);
15752  cmd_response_data_set_status_code (response_data,
15753  MHD_HTTP_INTERNAL_SERVER_ERROR);
15754  return gsad_message (
15755  credentials, "Internal error", __FUNCTION__, __LINE__,
15756  "An internal error occurred while getting the wizard. "
15757  "Diagnostics: Failure to send command to manager daemon.",
15758  response_data);
15759  }
15760 
15761  if (read_string_c (connection, &xml))
15762  {
15763  g_string_free (xml, TRUE);
15764  cmd_response_data_set_status_code (response_data,
15765  MHD_HTTP_INTERNAL_SERVER_ERROR);
15766  return gsad_message (credentials, "Internal error", __FUNCTION__,
15767  __LINE__,
15768  "An internal error occurred while getting the"
15769  " wizard."
15770  "Diagnostics: Failure to receive response from"
15771  " manager daemon.",
15772  response_data);
15773  }
15774 
15775  /* Get the setting. */
15776 
15777  if (gvm_connection_sendf_xml (
15778  connection, "<get_settings"
15779  " setting_id=\"20f3034c-e709-11e1-87e7-406186ea4fc5\"/>")
15780  == -1)
15781  {
15782  g_string_free (xml, TRUE);
15783  cmd_response_data_set_status_code (response_data,
15784  MHD_HTTP_INTERNAL_SERVER_ERROR);
15785  return gsad_message (
15786  credentials, "Internal error", __FUNCTION__, __LINE__,
15787  "An internal error occurred while getting the wizard. "
15788  "Diagnostics: Failure to send command to manager daemon.",
15789  response_data);
15790  }
15791 
15792  if (read_string_c (connection, &xml))
15793  {
15794  g_string_free (xml, TRUE);
15795  cmd_response_data_set_status_code (response_data,
15796  MHD_HTTP_INTERNAL_SERVER_ERROR);
15797  return gsad_message (
15798  credentials, "Internal error", __FUNCTION__, __LINE__,
15799  "An internal error occurred while the wizard. "
15800  "Diagnostics: Failure to receive response from manager daemon.",
15801  response_data);
15802  }
15803 
15804  /* Cleanup, and return transformed XML. */
15805 
15806  g_string_append_printf (xml, "</wizard>");
15807  return envelope_gmp (connection, credentials, params,
15808  g_string_free (xml, FALSE), response_data);
15809 }

References cmd_response_data_set_status_code(), envelope_gmp(), gsad_message(), and params_value().

Referenced by wizard_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wizard_get()

char * wizard_get ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const char *  extra_xml,
cmd_response_data_t *  response_data 
)
static

Returns a wizard_get page.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15840 of file gsad_gmp.c.

15843 {
15844  const char *name;
15845  int ret;
15846  GString *run;
15847  param_t *param;
15848  gchar *param_name, *response;
15849  params_iterator_t iter;
15850  params_t *wizard_params;
15851  entity_t entity;
15852  gchar *wizard_xml;
15853 
15854  /* The naming is a bit subtle here, because the HTTP request
15855  * parameters are called "param"s and so are the GMP wizard
15856  * parameters. */
15857 
15858  name = params_value (params, "get_name");
15859  if (name == NULL)
15860  {
15861  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
15862  return gsad_message (
15863  credentials, "Internal error", __FUNCTION__, __LINE__,
15864  "An internal error occurred while trying to start a wizard. "
15865  "Diagnostics: Required parameter 'get_name' was NULL.",
15866  response_data);
15867  }
15868 
15869  run = g_string_new ("<run_wizard read_only=\"1\">");
15870 
15871  g_string_append_printf (run,
15872  "<name>%s</name>"
15873  "<params>",
15874  name);
15875 
15876  wizard_params = params_values (params, "event_data:");
15877  if (wizard_params)
15878  {
15879  params_iterator_init (&iter, wizard_params);
15880  while (params_iterator_next (&iter, &param_name, &param))
15881  xml_string_append (run,
15882  "<param>"
15883  "<name>%s</name>"
15884  "<value>%s</value>"
15885  "</param>",
15886  param_name, param->value);
15887  }
15888 
15889  g_string_append (run, "</params></run_wizard>");
15890 
15891  response = NULL;
15892  entity = NULL;
15893  ret =
15894  gmp (connection, credentials, &response, &entity, response_data, run->str);
15895  g_string_free (run, TRUE);
15896  switch (ret)
15897  {
15898  case 0:
15899  case -1:
15900  break;
15901  case 1:
15902  cmd_response_data_set_status_code (response_data,
15903  MHD_HTTP_INTERNAL_SERVER_ERROR);
15904  return gsad_message (
15905  credentials, "Internal error", __FUNCTION__, __LINE__,
15906  "An internal error occurred while running a wizard. "
15907  "The wizard did not start. "
15908  "Diagnostics: Failure to send command to manager daemon.",
15909  response_data);
15910  case 2:
15911  cmd_response_data_set_status_code (response_data,
15912  MHD_HTTP_INTERNAL_SERVER_ERROR);
15913  return gsad_message (
15914  credentials, "Internal error", __FUNCTION__, __LINE__,
15915  "An internal error occurred while running a wizard. "
15916  "It is unclear whether the wizard started or not. "
15917  "Diagnostics: Failure to receive response from manager daemon.",
15918  response_data);
15919  default:
15920  cmd_response_data_set_status_code (response_data,
15921  MHD_HTTP_INTERNAL_SERVER_ERROR);
15922  return gsad_message (credentials, "Internal error", __FUNCTION__,
15923  __LINE__,
15924  "An internal error occurred while running a wizard. "
15925  "It is unclear whether the wizard started or not. "
15926  "Diagnostics: Internal Error.",
15927  response_data);
15928  }
15929 
15930  wizard_xml = g_strdup_printf ("<wizard><%s/>%s%s</wizard>", name,
15931  extra_xml ? extra_xml : "", response);
15932 
15933  return envelope_gmp (connection, credentials, params, wizard_xml,
15934  response_data);
15935 }

References cmd_response_data_set_status_code(), envelope_gmp(), gmp(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

Referenced by wizard_get_gmp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wizard_get_gmp()

char* wizard_get_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Returns a wizard_get page.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15948 of file gsad_gmp.c.

15950 {
15951  return wizard_get (connection, credentials, params, NULL, response_data);
15952 }

References wizard_get().

Here is the call graph for this function:

◆ wizard_gmp()

char* wizard_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
cmd_response_data_t *  response_data 
)

Returns a wizard page.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 15822 of file gsad_gmp.c.

15824 {
15825  return wizard (connection, credentials, params, NULL, response_data);
15826 }

References wizard().

Here is the call graph for this function:

Variable Documentation

◆ manager_address

gchar* manager_address = NULL

The address the manager is on.

Definition at line 137 of file gsad_gmp.c.

Referenced by authenticate_gmp(), gmp_init(), and manager_connect().

◆ manager_port

int manager_port = 9390

The port the manager is on.

Definition at line 142 of file gsad_gmp.c.

Referenced by authenticate_gmp(), gmp_init(), and manager_connect().

◆ manager_use_tls

int manager_use_tls = 0

Whether to use TLS for Manager connections.

Definition at line 132 of file gsad_gmp.c.

Referenced by gmp_init(), and gvm_connection_open().

gmpf
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:619
is_unix_socket
gboolean is_unix_socket()
Definition: gsad_settings.c:276
handler_send_reauthentication
int handler_send_reauthentication(http_connection_t *connection, int http_status_code, authentication_reason_t reason)
Allow for reauthentication of a user.
Definition: gsad_http.c:435
get_note
static char * get_note(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a note, envelope the result.
Definition: gsad_gmp.c:9259
params_value_size
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
Definition: gsad_base.c:237
edit_alert
char * edit_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, envelope the result.
Definition: gsad_gmp.c:5388
get_scanner
static char * get_scanner(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one scanner, envelope the result.
Definition: gsad_gmp.c:9976
param::value
gchar * value
Definition: gsad_params.h:40
params_t
#define params_t
Definition: gsad_params.h:31
manager_use_tls
int manager_use_tls
Whether to use TLS for Manager connections.
Definition: gsad_gmp.c:132
user_get_username
const gchar * user_get_username(user_t *user)
Definition: gsad_user.c:154
save_osp_prefs
static char * save_osp_prefs(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Save OSP file preferences.
Definition: gsad_gmp.c:7279
params_values
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
ctime_r_strip_newline
char * ctime_r_strip_newline(time_t *time, char *string)
Return string from ctime_r with newline replaces with terminator.
Definition: gsad_base.c:111
user_get_cookie
const gchar * user_get_cookie(user_t *user)
Definition: gsad_user.c:166
new_alert
static char * new_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Returns page to create a new alert.
Definition: gsad_gmp.c:4696
user_get_client_address
const gchar * user_get_client_address(user_t *user)
Definition: gsad_user.c:196
user
User information structure, for sessions.
Definition: gsad_user.c:42
GET_TRASH_RESOURCE
#define GET_TRASH_RESOURCE(capability, command, name)
Definition: gsad_gmp.c:11385
cmd_response_data_set_content_type
void cmd_response_data_set_content_type(cmd_response_data_t *data, content_type_t content_type)
Set content type of cmd_response_data_t struct.
Definition: gsad_cmd.c:134
cmd_response_data_set_content_disposition
void cmd_response_data_set_content_disposition(cmd_response_data_t *data, gchar *content_disposition)
Set content disposition of cmd_response_data_t struct.
Definition: gsad_cmd.c:212
cmd_response_data_set_status_code
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
get_result_id_from_params
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
Definition: gsad_gmp.c:9401
manager_address
gchar * manager_address
The address the manager is on.
Definition: gsad_gmp.c:137
user_set_language
void user_set_language(user_t *user, const gchar *language)
Set language of user.
Definition: gsad_user.c:280
wizard_get
static char * wizard_get(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard_get page.
Definition: gsad_gmp.c:15840
credentials_get_language
const gchar * credentials_get_language(credentials_t *cred)
Definition: gsad_credentials.c:73
command_enabled
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA GMP library.
Definition: gsad_gmp.c:261
get_trash
static char * get_trash(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Setup trash page XML, envelope the result.
Definition: gsad_gmp.c:11431
params_valid
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:303
gmp_arguments_add
void gmp_arguments_add(gmp_arguments_t *arguments, const gchar *key, const gchar *value)
Definition: gsad_gmp_arguments.c:44
export_resource
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1267
get_agent
static char * get_agent(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one agent, envelope the result.
Definition: gsad_gmp.c:4323
credentials
Structure of credential related information.
Definition: gsad_credentials.c:34
credentials_get_cmd_duration
double credentials_get_cmd_duration(credentials_t *cred)
Definition: gsad_credentials.c:85
XML_REPORT_FORMAT_ID
#define XML_REPORT_FORMAT_ID
Definition: gsad_gmp.c:144
GMP_SERVICE_DOWN
@ GMP_SERVICE_DOWN
Definition: gsad_http.h:162
cmd_response_data_set_content_length
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
params_get
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:173
wizard
static char * wizard(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard page.
Definition: gsad_gmp.c:15721
message_invalid
gchar * message_invalid(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *op_name)
Check a param using the direct response method.
Definition: gsad_gmp.c:764
connect_unix
int connect_unix(const gchar *path)
Connect to Greenbone Vulnerability Manager daemon.
Definition: gsad_gmp.c:17146
params_original_value
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:255
get_user
static char * get_user(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one user, envelope the result.
Definition: gsad_gmp.c:14657
EVENT_TYPE_NEW_SECINFO
#define EVENT_TYPE_NEW_SECINFO
Definition: gsad_gmp.c:4913
get_config_family
static char * get_config_family(gvm_connection_t *, credentials_t *, params_t *, int, cmd_response_data_t *)
Get details of a family for a config, envelope the result.
Definition: gsad_gmp.c:7605
params_filename
const char * params_filename(params_t *params, const char *name)
Get filename of param.
Definition: gsad_base.c:271
params_add
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318
resource_action
char * resource_action(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, envelope result.
Definition: gsad_gmp.c:1749
param::valid
int valid
Definition: gsad_params.h:44
gsad_message
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:957
gmp
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:576
user_renew_session
void user_renew_session(user_t *user)
Definition: gsad_user.c:59
session_get_user_by_username
user_t * session_get_user_by_username(const gchar *username)
Definition: gsad_session.c:116
params_iterator_init
#define params_iterator_init
Definition: gsad_params.h:99
EVENT_TYPE_UPDATED_SECINFO
#define EVENT_TYPE_UPDATED_SECINFO
Definition: gsad_gmp.c:4914
INCLUDE_RELATED_CURRENT_RESOURCE_ONLY
#define INCLUDE_RELATED_CURRENT_RESOURCE_ONLY
Definition: gsad_gmp.c:12849
format_file_name
gchar * format_file_name(gchar *fname_format, credentials_t *credentials, const char *type, const char *uuid, entity_t resource_entity)
Generates a file name for exporting.
Definition: gsad_gmp.c:1182
append_alert_method_data
static void append_alert_method_data(GString *xml, params_t *data, const char *method, params_t *report_formats)
Send method data for an alert.
Definition: gsad_gmp.c:5007
get_report_format
static char * get_report_format(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one report format, envelope the result.
Definition: gsad_gmp.c:10853
get_severity_from_params
const char * get_severity_from_params(params_t *params)
Get severity from request params.
Definition: gsad_gmp.c:9378
get_credential
static char * get_credential(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one credential, envelope the result.
Definition: gsad_gmp.c:3378
user_get_session_timeout
const time_t user_get_session_timeout(user_t *user)
Definition: gsad_user.c:220
CHECK_VARIABLE_INVALID
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:121
gvm_connection_open
int gvm_connection_open(gvm_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_gmp.c:17185
get_permission
static char * get_permission(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one permission, envelope the result.
Definition: gsad_gmp.c:12628
get_target
static char * get_target(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one target, envelope the result.
Definition: gsad_gmp.c:6726
get_one
char * get_one(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
Get one resource, envelope the result.
Definition: gsad_gmp.c:913
get_asset
static char * get_asset(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Request an asset.
Definition: gsad_gmp.c:16212
get_role
static char * get_role(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one role, envelope the result.
Definition: gsad_gmp.c:13891
get_many
static char * get_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
Get all of a particular type of resource, envelope the result.
Definition: gsad_gmp.c:1048
params_iterator_t
#define params_iterator_t
Definition: gsad_params.h:97
get_alert
static char * get_alert(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one alert, envelope the result.
Definition: gsad_gmp.c:5328
get_port_list
static char * get_port_list(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one port_list, envelope the result.
Definition: gsad_gmp.c:13545
params_value
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
member1
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
Definition: gsad_gmp.c:412
user_set_username
void user_set_username(user_t *user, const gchar *username)
Set username of user.
Definition: gsad_user.c:302
GSAD_CONTENT_TYPE_APP_XML
@ GSAD_CONTENT_TYPE_APP_XML
Definition: gsad_content_type.h:40
session_add_user
void session_add_user(const gchar *id, user_t *user)
Add user to the session "database".
Definition: gsad_session.c:147
send_settings_filters
static int send_settings_filters(gvm_connection_t *connection, params_t *data, params_t *changed, GString *xml, int *modify_failed_flag, cmd_response_data_t *response_data)
Send settings resource filters.
Definition: gsad_gmp.c:11516
gmp_success
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:526
authentication_reason_t
enum authentication_reason authentication_reason_t
Definition: gsad_http.h:169
user_get_capabilities
const gchar * user_get_capabilities(user_t *user)
Definition: gsad_user.c:178
credentials_new
credentials_t * credentials_new(user_t *user, const gchar *language)
Definition: gsad_credentials.c:42
gmp_request
int gmp_request(gvm_connection_t *connection, const char *cmd, gmp_arguments_t *arguments)
Definition: gsad_gmp_request.c:25
user_set_severity
void user_set_severity(user_t *user, const gchar *severity)
Set severity class of user.
Definition: gsad_user.c:265
param::value_size
int value_size
Definition: gsad_params.h:46
user_get_password
const gchar * user_get_password(user_t *user)
Definition: gsad_user.c:214
get_report
char * get_report(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Get a report and return the result.
Definition: gsad_gmp.c:8469
users
GPtrArray * users
User session data.
Definition: gsad_session.c:39
session_remove_other_sessions
void session_remove_other_sessions(const gchar *id, user_t *user)
Removes all session of the user, except the one with the passed id.
Definition: gsad_session.c:181
credentials_free
void credentials_free(credentials_t *creds)
Definition: gsad_credentials.c:54
user_free
void user_free(user_t *user)
Definition: gsad_user.c:100
envelope_gmp
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:319
str_equal
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
FILT_ID_USER_SETTING
#define FILT_ID_USER_SETTING
filt_id value to use the filter in the user setting if possible.
Definition: gsad_gmp.c:113
setting_get_value
static int setting_get_value(gvm_connection_t *connection, const char *setting_id, gchar **value, cmd_response_data_t *response_data)
Get a setting by UUID for the current user of an GMP connection.
Definition: gsad_gmp.c:648
ANONXML_REPORT_FORMAT_ID
#define ANONXML_REPORT_FORMAT_ID
Definition: gsad_gmp.c:145
param
Request parameter.
Definition: gsad_params.h:38
authenticate_gmp
int authenticate_gmp(const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning)
Check authentication credentials.
Definition: gsad_gmp.c:17223
get_port_from_params
const char * get_port_from_params(params_t *params)
Get a port from request params.
Definition: gsad_gmp.c:9297
create_report_gmp
char * create_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new container task.
Definition: gsad_gmp.c:1926
response_from_entity
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:783
set_http_status_from_entity
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to GMP response entity.
Definition: gsad_gmp.c:547
manager_port
int manager_port
The port the manager is on.
Definition: gsad_gmp.c:142
GSAD_MESSAGE_INVALID_PARAM
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_gmp.c:85
get_task_id_from_params
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
Definition: gsad_gmp.c:9358
get_entities
static char * get_entities(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
Get all entities of a particular type, envelope the result.
Definition: gsad_gmp.c:964
GSAD_CONTENT_TYPE_IMAGE_PNG
@ GSAD_CONTENT_TYPE_IMAGE_PNG
Definition: gsad_content_type.h:43
user_set_password
void user_set_password(user_t *user, const gchar *password)
Set password of user.
Definition: gsad_user.c:248
gmp_arguments_t
GHashTable gmp_arguments_t
Definition: gsad_gmp_arguments.h:24
user_get_timezone
const gchar * user_get_timezone(user_t *user)
Definition: gsad_user.c:190
gmp_arguments_free
void gmp_arguments_free(gmp_arguments_t *arguments)
Definition: gsad_gmp_arguments.c:35
AUTH_CONF_SETTING
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_gmp.
Definition: gsad_gmp.c:15362
get_override
static char * get_override(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a override, envelope the result.
Definition: gsad_gmp.c:9662
login
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:17345
params_iterator_next
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:400
gmp_arguments_new
gmp_arguments_t * gmp_arguments_new()
Definition: gsad_gmp_arguments.c:23
user_add
user_t * user_add(const gchar *username, const gchar *password, const gchar *timezone, const gchar *severity, const gchar *role, const gchar *capabilities, const gchar *language, const gchar *pw_warning, const char *address)
Add a user.
Definition: gsad_user.c:350
user_get_password_warning
const gchar * user_get_password_warning(user_t *user)
Definition: gsad_user.c:184
LOGIN_ERROR
@ LOGIN_ERROR
Definition: gsad_http.h:159
export_many
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1419
INCLUDE_RELATED_RESOURCES_ONLY
#define INCLUDE_RELATED_RESOURCES_ONLY
Definition: gsad_gmp.c:12851
append_alert_condition_data
static void append_alert_condition_data(GString *xml, params_t *data, const char *condition)
Send condition data for an alert.
Definition: gsad_gmp.c:4957
move_resource_to_trash
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:1703
user_get_severity
const gchar * user_get_severity(user_t *user)
Definition: gsad_user.c:202
params_given
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
get_entity
char * get_entity(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gmp_arguments_t *arguments, cmd_response_data_t *response_data)
Get a single entity, envelope the result.
Definition: gsad_gmp.c:820
check_modify_config
static char * check_modify_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Check a modify_config response.
Definition: gsad_gmp.c:440
user_get_role
const gchar * user_get_role(user_t *user)
Definition: gsad_user.c:208
credentials_get_user
user_t * credentials_get_user(credentials_t *cred)
Definition: gsad_credentials.c:67
get_hosts_from_params
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
Definition: gsad_gmp.c:9323
user_set_timezone
void user_set_timezone(user_t *user, const gchar *timezone)
Set timezone of user.
Definition: gsad_user.c:233
handler_create_response
int handler_create_response(http_connection_t *connection, gchar *data, cmd_response_data_t *response_data, const gchar *sid)
Create and send a response.
Definition: gsad_http.c:368
cmd_response_data_set_content_type_string
void cmd_response_data_set_content_type_string(cmd_response_data_t *data, gchar *content_type_string)
Set a content type as string.
Definition: gsad_cmd.c:241
get_tag
static char * get_tag(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one tag, envelope the result.
Definition: gsad_gmp.c:6603
EVENT_TYPE_TASK_RUN_STATUS_CHANGED
#define EVENT_TYPE_TASK_RUN_STATUS_CHANGED
Definition: gsad_gmp.c:4915
append_alert_event_data
static void append_alert_event_data(GString *xml, params_t *data, const char *event)
Send event data for an alert.
Definition: gsad_gmp.c:4929
member
static int member(params_t *params, const char *string)
Look for a param with name equal to a given string.
Definition: gsad_gmp.c:390
get_group
static char * get_group(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one group, envelope the result.
Definition: gsad_gmp.c:12334
action_result
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
Definition: gsad_gmp.c:725
capitalize
gchar * capitalize(const char *input)
Capitalize a type or command name and replace underscores.
Definition: utils.c:48
FILT_ID_NONE
#define FILT_ID_NONE
filt_id value to use term or built-in default filter.
Definition: gsad_gmp.c:108
LOGIN_FAILED
@ LOGIN_FAILED
Definition: gsad_http.h:158
params_value_bool
gboolean params_value_bool(params_t *params, const char *name)
Get boolean value of param.
Definition: gsad_base.c:221
get_schedule
static char * get_schedule(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one schedule, envelope the result.
Definition: gsad_gmp.c:10387
params_remove
void params_remove(params_t *params, const char *name)
Definition: gsad_base.c:338
CHECK_GMPF_RET
#define CHECK_GMPF_RET
Definition: gsad_gmp.c:12800
GSAD_CONTENT_TYPE_OCTET_STREAM
@ GSAD_CONTENT_TYPE_OCTET_STREAM
Definition: gsad_content_type.h:48
delete_resource
char * delete_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
Delete a resource, get all resources, envelope the result.
Definition: gsad_gmp.c:1596
get_filter
static char * get_filter(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one filter, envelope the result.
Definition: gsad_gmp.c:14247
vendor_version_get
const gchar * vendor_version_get()
Get the vendor version.
Definition: gsad_settings.c:117
GSAD_STATUS_INVALID_REQUEST
#define GSAD_STATUS_INVALID_REQUEST
HTTP status code for expected failure of gmp requests e.g. if some parameter was missing or invalid.
Definition: gsad_gmp.c:98
sync_feed
static char * sync_feed(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
Synchronize with a feed and envelope the result.
Definition: gsad_gmp.c:14133
user_get_token
const gchar * user_get_token(user_t *user)
Definition: gsad_user.c:172