Greenbone Security Assistant  7.0.3~git
gsad_omp.c File Reference

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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <time.h>
#include <microhttpd.h>
#include "gsad_base.h"
#include "gsad_omp.h"
#include "xslt_i18n.h"
#include <openvas/misc/openvas_server.h>
#include <openvas/base/openvas_file.h>
#include <openvas/base/cvss.h>
#include <openvas/omp/omp.h>
#include <openvas/omp/xml.h>
#include <libxml2/libxml/xmlmemory.h>
#include <libxml2/libxml/HTMLtree.h>
#include <libxml2/libxml/xmlIO.h>
#include <libxml2/libxml/xinclude.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
Include dependency graph for gsad_omp.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 omp"
 GLib log domain. More...
 
#define OPENVASMD_ADDRESS   "127.0.0.1"
 Manager (openvasmd) address. More...
 
#define CHECK_PARAM(name, op_name, ret_func)
 Check a param. More...
 
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
 Check a param using the direct response method. More...
 
#define PARAM_OR_SETTING(value, param, setting_id, cleanup)
 Get a value from a param or fall back to a setting. More...
 
#define CHECK(name)    CHECK_PARAM_INVALID (name, "Create Task", "new_task")
 Check a param. More...
 
#define CHECK(name)
 Check a param. More...
 
#define GET_TRASH_RESOURCE(capability, command, name)
 
#define CHECK_OMPF_RET
 
#define AUTH_CONF_SETTING(key, value)
 Generate AUTH_CONF_SETTING element for save_auth_omp. More...
 

Functions

int token_user_remove (const char *)
 Remove a user from the session "database", releasing the user_t too. More...
 
int command_enabled (credentials_t *credentials, const gchar *name)
 Init the GSA OMP library. More...
 
void omp_init (const gchar *manager_address_unix, const gchar *manager_address_tls, int port_manager)
 Init the GSA OMP library. More...
 
void cmd_response_data_init (cmd_response_data_t *data)
 Initializes a cmd_response_data_t struct. More...
 
void cmd_response_data_reset (cmd_response_data_t *data)
 Clears a cmd_response_data_t struct. More...
 
void init_find_by_value (find_by_value_t *find, gchar *value)
 
void free_find_by_value (find_by_value_t *find)
 
int member1 (params_t *params, const char *string)
 Look for param with value 1 and name equal to given string. More...
 
void set_http_status_from_entity (entity_t entity, cmd_response_data_t *response_data)
 Set the HTTP status according to OMP response entity. More...
 
gchar * message_invalid (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
 Check a param using the direct response method. More...
 
char * get_one (openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, const char *extra_xml, const char *extra_attribs, cmd_response_data_t *response_data)
 Get one resource, XSL transform the result. More...
 
char * edit_resource (openvas_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, XSL transform 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 (openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a resource. More...
 
char * delete_resource (openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
 Delete a resource, get all resources, XSL transform the result. More...
 
char * resource_action (openvas_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, XSL transform result. More...
 
char * new_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new task. More...
 
char * new_container_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new task. More...
 
char * upload_report_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload report page. More...
 
char * create_report_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a report, get all tasks, XSL transform the result. More...
 
char * import_report_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report, get all reports, XSL transform the result. More...
 
char * create_container_task_omp (openvas_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_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a task, get all tasks, XSL transform the result. More...
 
char * delete_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a task, get all tasks, XSL transform the result. More...
 
char * edit_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_task XML, XSL transform the result. More...
 
char * save_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save task, get next page, XSL transform the result. More...
 
char * save_container_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save container task, get next page, XSL transform the result. More...
 
char * export_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a task. More...
 
char * export_tasks_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of tasks. More...
 
char * stop_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Stop a task, get all tasks, XSL transform the result. More...
 
char * resume_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Resume a task, get all tasks, XSL transform the result. More...
 
char * start_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Start a task, get all tasks, XSL transform the result. More...
 
char * move_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Reassign a task to a new OMP slave. More...
 
char * get_info (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Requests SecInfo. More...
 
char * get_info_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get info, XSL transform the result. More...
 
char * get_nvts_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Requests NVT details, accepting extra commands. More...
 
char * get_tasks_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tasks, XSL transform the result. More...
 
char * get_tasks_chart_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a tasks chart, XSL transform the result. More...
 
char * get_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a task, XSL transform the result. More...
 
char * create_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a credential, get all credentials, XSL transform result. More...
 
char * get_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one credential, XSL transform the result. More...
 
int download_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **login, cmd_response_data_t *response_data)
 Export a Credential in a defined format. More...
 
char * export_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a Credential. More...
 
char * export_credentials_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Credentials. More...
 
char * get_credentials_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one or all credentials, XSL transform the result. More...
 
char * delete_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete credential, get all credentials, XSL transform result. More...
 
char * new_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new Credential. More...
 
char * edit_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_credential XML, XSL transform the result. More...
 
char * save_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save credential, get next page, XSL transform the result. More...
 
char * new_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new agent page. More...
 
char * create_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an agent, get all agents, XSL transform result. More...
 
char * delete_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete agent, get all agents, XSL transform result. More...
 
int download_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *result_len, char **html, char **filename, cmd_response_data_t *response_data)
 Get an agent, XSL transform the result. More...
 
char * edit_agent (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_agent XML, XSL transform the result. More...
 
char * edit_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_agent XML, XSL transform the result. More...
 
char * save_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a agent, get all agents, XSL transform the result. More...
 
char * get_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one agent, XSL transform the result. More...
 
char * get_agents_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all agents, XSL transform the result. More...
 
char * verify_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify agent, get agents, XSL transform the result. More...
 
char * export_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a agent. More...
 
char * export_agents_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of agents. More...
 
char * get_aggregate_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an aggregate of resources. More...
 
char * new_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new alert. More...
 
char * create_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an alert, get all alerts, XSL transform the result. More...
 
char * delete_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete an alert, get all alerts, XSL transform the result. More...
 
char * get_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one alert, XSL transform the result. More...
 
char * get_alerts_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all alerts, XSL transform the result. More...
 
char * edit_alert (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_alert XML, XSL transform the result. More...
 
char * edit_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_alert XML, XSL transform the result. More...
 
char * save_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an alert, get all alerts, XSL transform the result. More...
 
char * test_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Test an alert, get all alerts XSL transform the result. More...
 
char * export_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an alert. More...
 
char * export_alerts_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of alerts. More...
 
char * new_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new target. More...
 
char * create_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a target, get all targets, XSL transform the result. More...
 
char * clone_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Clone a resource, XSL transform the result. More...
 
char * delete_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a target, get all targets, XSL transform the result. More...
 
char * delete_trash_agent_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash agent, get all agents, XSL transform the result. More...
 
char * delete_trash_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash config, get all trash, XSL transform the result. More...
 
char * delete_trash_alert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash alert, get all trash, XSL transform the result. More...
 
char * delete_trash_credential_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash credential, get all trash, XSL transform the result. More...
 
char * delete_trash_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash report format, get all trash, XSL transform the result. More...
 
char * delete_trash_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash schedule, get all trash, XSL transform the result. More...
 
char * delete_trash_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash target, get all trash, XSL transform the result. More...
 
char * delete_trash_task_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash task, get all trash, XSL transform the result. More...
 
char * restore_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Restore a resource, get all trash, XSL transform the result. More...
 
char * empty_trashcan_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Empty the trashcan, get all trash, XSL transform the result. More...
 
char * new_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new target. More...
 
char * create_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a tag, get report, XSL transform the result. More...
 
char * delete_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, XSL transform the result. More...
 
char * delete_trash_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a note, get all notes, XSL transform the result. More...
 
char * edit_tag (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_tag XML, XSL transform the result. More...
 
char * edit_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_tag XML, XSL transform the result. More...
 
char * save_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a tag, get all tags, XSL transform the result. More...
 
char * export_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a tag. More...
 
char * export_tags_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of tags. More...
 
char * get_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one tag, XSL transform the result. More...
 
char * get_tags_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all tags, XSL transform the result. More...
 
char * toggle_tag_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Set tag enabled status. More...
 
char * edit_target (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_target XML, XSL transform the result. More...
 
char * edit_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_target XML, XSL transform the result. More...
 
char * get_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one target, XSL transform the result. More...
 
char * get_targets_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all targets, XSL transform the result. More...
 
char * save_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a target, get all targets, XSL transform the result. More...
 
char * export_target_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a target. More...
 
char * export_targets_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of targets. More...
 
char * new_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new scan config page. More...
 
char * upload_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload scan config page. More...
 
char * create_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create config, get all configs, XSL transform the result. More...
 
char * import_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import config, get all configs, XSL transform the result. More...
 
char * get_configs_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scan configs, XSL transform the result. More...
 
char * get_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a config, XSL transform the result. More...
 
char * edit_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a config, XSL transform the result. More...
 
char * sync_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Sync config, get configs, XSL transform the result. More...
 
char * save_config_omp (openvas_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_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for a config, XSL transform the result. More...
 
char * edit_config_family_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of a family for editing a config, XSL transform result. More...
 
char * save_config_family_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, XSL transform the result. More...
 
char * get_config_nvt_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get details of an NVT for a config, XSL transform the result. More...
 
char * edit_config_nvt_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit details of an NVT for a config, XSL transform the result. More...
 
char * save_config_nvt_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save NVT prefs for a config, get NVT details, XSL transform result. More...
 
char * delete_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete config, get all configs, XSL transform the result. More...
 
char * export_config_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a config. More...
 
char * export_configs_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of scan configs. More...
 
char * export_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a note. More...
 
char * export_notes_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of notes. More...
 
char * export_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an override. More...
 
char * export_overrides_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of overrides. More...
 
char * export_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a Port List. More...
 
char * export_port_lists_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Port Lists. More...
 
char * export_preference_file_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a file preference. More...
 
char * export_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a report format. More...
 
char * export_report_formats_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of Report Formats. More...
 
char * delete_report_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report, get task status, XSL transform the result. More...
 
char * get_report_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *report_len, gchar **content_type, char **content_disposition, cmd_response_data_t *response_data)
 Get a report and XSL transform the result. More...
 
char * get_reports_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all reports, XSL transform the result. More...
 
char * get_report_section_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a report section, XSL transform the result. More...
 
char * download_ssl_cert (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get an SSL Certificate. More...
 
char * download_ca_pub (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get a Scanner's CA Certificate. More...
 
char * download_key_pub (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gsize *response_size, cmd_response_data_t *response_data)
 Get a Scanner's Certificate. More...
 
char * export_result_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a result. More...
 
char * export_results_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of results. More...
 
char * get_results_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all results, XSL transform the result. More...
 
char * get_result_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one result, XSL transform the result. More...
 
char * get_notes_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all notes, XSL transform the result. More...
 
char * get_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get a note, XSL transform the result. More...
 
char * new_note (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Return the new notes page. More...
 
char * new_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new notes page. More...
 
char * create_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a note, get report, XSL transform the result. More...
 
char * delete_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete note, get next page, XSL transform the result. More...
 
char * delete_trash_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a note, get all notes, XSL transform the result. More...
 
char * edit_note (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Edit note, get next page, XSL transform the result. More...
 
char * edit_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit note, get next page, XSL transform the result. More...
 
char * save_note_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save note, get next page, XSL transform the result. More...
 
char * get_overrides_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all overrides, XSL transform the result. More...
 
char * get_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an override, XSL transform the result. More...
 
char * new_override (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Return the new overrides page. More...
 
char * new_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new overrides page. More...
 
char * create_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an override, get report, XSL transform the result. More...
 
char * delete_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete override, get next page, XSL transform the result. More...
 
char * delete_trash_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a override, get all overrides, XSL transform the result. More...
 
char * edit_override (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Edit override, get next page, XSL transform the result. More...
 
char * edit_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Edit override, get next page, XSL transform the result. More...
 
char * save_override_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save override, get next page, XSL transform the result. More...
 
char * get_scanners_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all scanners, XSL transform the result. More...
 
char * get_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one scanner, XSL transform the result. More...
 
char * export_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a scanner. More...
 
char * export_scanners_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of scanners. More...
 
char * new_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new scanner page. More...
 
char * verify_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify scanner, get scanners, XSL transform the result. More...
 
char * create_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a scanner, get all scanners, XSL transform the result. More...
 
char * delete_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a scanner, get all scanners, XSL transform the result. More...
 
char * delete_trash_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash scanner, get all scanners, XSL transform the result. More...
 
char * edit_scanner (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_scanner XML, XSL transform the result. More...
 
char * edit_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_scanner XML, XSL transform the result. More...
 
char * save_scanner_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save scanner, get next page, XSL transform the result. More...
 
char * get_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one schedule, XSL transform the result. More...
 
char * get_schedules_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all schedules, XSL transform the result. More...
 
char * new_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new schedule page. More...
 
char * create_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a schedule, get all schedules, XSL transform the result. More...
 
char * delete_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a schedule, get all schedules, XSL transform the result. More...
 
char * get_system_reports_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all system reports, XSL transform the result. More...
 
char * get_system_report_omp (openvas_connection_t *connection, credentials_t *credentials, const char *url, params_t *params, enum content_type *content_type, gsize *content_length, cmd_response_data_t *response_data)
 Return system report image. More...
 
char * get_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one report format, XSL transform the result. More...
 
char * get_report_formats_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all Report Formats, XSL transform the result. More...
 
char * new_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new report format page. More...
 
char * delete_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete report format, get report formats, XSL transform the result. More...
 
char * edit_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_report_format XML, XSL transform the result. More...
 
char * import_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import report format, get all report formats, XSL transform result. More...
 
char * save_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save report_format, get next page, XSL transform the result. More...
 
char * verify_report_format_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Verify report format, get report formats, XSL transform the result. More...
 
char * run_wizard_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Run a wizard and XSL transform the result. More...
 
char * get_trash_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all trash, XSL transform the result. More...
 
char * get_my_settings_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page with user's settings. More...
 
char * edit_my_settings_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page with user's settings, for editing. More...
 
char * save_my_settings_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *accept_language, char **timezone, char **password, char **severity, char **language, cmd_response_data_t *response_data)
 Returns page with user's settings, for editing. More...
 
char * get_protocol_doc_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get OMP doc. More...
 
char * export_omp_doc_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Download the OMP doc. More...
 
char * get_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one group, XSL transform the result. More...
 
char * get_groups_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all groups, XSL transform the result. More...
 
char * new_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new group. More...
 
char * delete_trash_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a group from trash, get all groups, XSL transform the result. More...
 
char * delete_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a group, get all groups, XSL transform the result. More...
 
char * create_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a group, get all groups, XSL transform the result. More...
 
char * edit_group (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_group XML, XSL transform the result. More...
 
char * edit_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_group XML, XSL transform the result. More...
 
char * export_group_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a group. More...
 
char * export_groups_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of groups. More...
 
char * save_group_omp (openvas_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_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one permission, XSL transform the result. More...
 
char * get_permissions_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all permissions, XSL transform the result. More...
 
char * delete_trash_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a permission, get all permissions, XSL transform the result. More...
 
char * delete_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a permission, get all permissions, XSL transform the result. More...
 
char * new_permission (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * new_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * create_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a permission, get all permissions, XSL transform the result. More...
 
char * new_permissions (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup new_permissions XML, XSL transform the result. More...
 
char * new_permissions_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup new_permission XML, XSL transform the result. More...
 
char * create_permissions_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create multiple permission, get next page, XSL transform the result. More...
 
char * edit_permission (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_permission XML, XSL transform the result. More...
 
char * edit_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_permission XML, XSL transform the result. More...
 
char * export_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a permission. More...
 
char * export_permissions_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of permissions. More...
 
char * save_permission_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a permission, get all permissions, XSL transform the result. More...
 
char * upload_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the upload port list page. More...
 
char * create_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a port list, get all port lists, XSL transform the result. More...
 
char * new_port_range_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new Port Range page. More...
 
char * create_port_range_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Add a range to a port list, XSL transform the result. More...
 
char * get_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one port_list, XSL transform the result. More...
 
char * get_port_lists_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all port_lists, XSL transform the result. More...
 
char * new_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new Port List page. More...
 
char * edit_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_port_list XML, XSL transform the result. More...
 
char * save_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a port list, get all port list, XSL transform the result. More...
 
char * delete_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port list, get all port lists, XSL transform the result. More...
 
char * delete_trash_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a trash port list, get all trash, XSL transform the result. More...
 
char * delete_port_range_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a port range, get the port list, XSL transform the result. More...
 
char * import_port_list_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Import port list, get all port_lists, XSL transform the result. More...
 
char * new_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new role. More...
 
char * delete_trash_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a role from trash, get all roles, XSL transform the result. More...
 
char * delete_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a role, get all roles, XSL transform the result. More...
 
char * create_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a role, get all roles, XSL transform the result. More...
 
char * edit_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_role XML, XSL transform the result. More...
 
char * get_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one role, XSL transform the result. More...
 
char * get_roles_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all roles, XSL transform the result. More...
 
char * export_role_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a role. More...
 
char * export_roles_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of roles. More...
 
char * save_role_omp (openvas_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_omp (openvas_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...
 
char * sync_feed_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with an NVT feed and XSL transform the result. More...
 
char * sync_scap_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a SCAP feed and XSL transform the result. More...
 
char * sync_cert_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Synchronize with a CERT feed and XSL transform the result. More...
 
char * get_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one filter, XSL transform the result. More...
 
char * get_filters_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all filters, XSL transform the result. More...
 
char * create_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a filter, get all filters, XSL transform the result. More...
 
char * delete_trash_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a filter, get all filters, XSL transform the result. More...
 
char * delete_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a filter, get all filters, XSL transform the result. More...
 
char * edit_filter (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_filter XML, XSL transform the result. More...
 
char * edit_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_filter XML, XSL transform the result. More...
 
char * export_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a filter. More...
 
char * export_filters_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of filters. More...
 
char * new_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new filter. More...
 
char * save_filter_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify a filter, get all filters, XSL transform the result. More...
 
char * edit_schedule (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_schedule XML, XSL transform the result. More...
 
char * edit_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_schedule XML, XSL transform the result. More...
 
char * export_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a schedule. More...
 
char * export_schedules_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of schedules. More...
 
char * save_schedule_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save schedule, get next page, XSL transform the result. More...
 
char * new_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns page to create a new user. More...
 
char * delete_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete a user, get all users, XSL transform the result. More...
 
char * delete_user_confirm_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Show confirmation deleting a user, XSL transform the result. More...
 
char * get_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get one user, XSL transform the result. More...
 
char * get_users_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get all users, XSL transform the result. More...
 
char * create_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create a user, get all users, XSL transform the result. More...
 
char * edit_user (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit_user XML, XSL transform the result. More...
 
char * edit_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_user XML, XSL transform the result. More...
 
char * auth_settings_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * logout (credentials_t *credentials, const gchar *message, cmd_response_data_t *response_data)
 Setup edit_user XML, XSL transform the result. More...
 
char * save_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, char **password_return, char **modified_user, int *logout_user, cmd_response_data_t *response_data)
 Modify a user, get all users, XSL transform the result. More...
 
char * export_user_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a user. More...
 
char * export_users_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of users. More...
 
char * cvss_calculator (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 
char * dashboard (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Show a dashboard. More...
 
char * save_auth_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Save authentication settings. More...
 
char * save_chart_preference_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, gchar **pref_id, gchar **pref_value, cmd_response_data_t *response_data)
 Save chart preferences. More...
 
char * wizard_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard page. More...
 
char * wizard_get_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Returns a wizard_get page. More...
 
char * process_bulk_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Returns a process_bulk page. More...
 
char * bulk_delete_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Delete multiple resources, get next page, XSL transform the result. More...
 
char * new_host_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Return the new host page. More...
 
char * create_host_omp (openvas_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_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get asset, XSL transform the result. More...
 
char * get_assets_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get assets, XSL transform the result. More...
 
char * create_asset_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Create an asset, get report, XSL transform the result. More...
 
char * delete_asset_omp (openvas_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_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export an asset. More...
 
char * export_assets_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
 Export a list of assets. More...
 
char * edit_asset (openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
 Setup edit XML, XSL transform the result. More...
 
char * edit_asset_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Setup edit_asset XML, XSL transform the result. More...
 
char * save_asset_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Modify an asset, get all assets, XSL transform the result. More...
 
char * get_assets_chart_omp (openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
 Get an assets chart, XSL transform the result. More...
 
int connect_unix (const gchar *path)
 Connect to OpenVAS Manager daemon. More...
 
int openvas_connection_open (openvas_connection_t *connection, const gchar *address, int port)
 Connect to an address. More...
 
int authenticate_omp (const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning, GTree **chart_prefs, gchar **autorefresh)
 Check authentication credentials. More...
 
int manager_connect (credentials_t *credentials, openvas_connection_t *connection, cmd_response_data_t *response_data)
 Connect to OpenVAS 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

OMP communication module of Greenbone Security Assistant daemon.

This file implements an API for OMP. The functions call the OpenVAS Manager via OMP properly, and apply XSL-Transforms to deliver HTML results.

Definition in file gsad_omp.c.

Macro Definition Documentation

#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_omp.

Definition at line 25851 of file gsad_omp.c.

Referenced by save_auth_omp().

#define CHECK (   name)    CHECK_PARAM_INVALID (name, "Create Task", "new_task")

Check a param.

Parameters
[in]nameParam name.

Definition at line 9605 of file gsad_omp.c.

Referenced by clone_omp(), create_task_omp(), and save_task_omp().

#define CHECK (   name)
Value:
if (name == NULL) \
{ \
response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
return gsad_message (credentials, \
"Internal error", __FUNCTION__, __LINE__, \
"An internal error occurred while cloning a resource. " \
"The resource was not cloned. " \
"Diagnostics: Required parameter '" G_STRINGIFY (name) \
"' was NULL.", \
"/omp?cmd=get_tasks", response_data); \
}
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467

Check a param.

Parameters
[in]nameParam name.

Definition at line 9605 of file gsad_omp.c.

#define CHECK_OMPF_RET

Definition at line 21140 of file gsad_omp.c.

Referenced by create_permissions_omp().

#define CHECK_PARAM (   name,
  op_name,
  ret_func 
)
Value:
if (name == NULL) \
{ \
gchar *msg, *ret_html; \
msg = g_strdup_printf (GSAD_MESSAGE_INVALID, \
"Given " G_STRINGIFY (name) " was invalid", \
op_name); \
ret_html = ret_func (connection, credentials, params, msg, \
response_data); \
g_free (msg); \
response_data->http_status_code = MHD_HTTP_BAD_REQUEST; \
return ret_html; \
}
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
Definition: gsad_base.h:44

Check a param.

Parameters
[in]nameParam name.
[in]op_nameOperation name.
[in]ret_funcFunction to return message.

Definition at line 1174 of file gsad_omp.c.

Referenced by create_permissions_omp(), sync_config_omp(), and verify_scanner_omp().

#define CHECK_PARAM_INVALID (   name,
  op_name,
  next_cmd 
)
Value:
if (name == NULL) \
{ \
return message_invalid (connection, credentials, params, response_data, \
"Given " G_STRINGIFY (name) " was invalid", \
G_STRINGIFY (MHD_HTTP_BAD_REQUEST), \
op_name, next_cmd); \
}
gchar * message_invalid(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472

Check a param using the direct response method.

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

Definition at line 1195 of file gsad_omp.c.

Referenced by auth_settings_omp(), create_agent_omp(), create_alert_omp(), create_asset_omp(), create_config_omp(), create_container_task_omp(), create_credential_omp(), create_filter_omp(), create_group_omp(), create_host_omp(), create_note_omp(), create_override_omp(), create_permission_omp(), create_port_list_omp(), create_port_range_omp(), create_report_omp(), create_role_omp(), create_scanner_omp(), create_schedule_omp(), create_tag_omp(), create_target_omp(), create_user_omp(), save_agent_omp(), save_alert_omp(), save_asset_omp(), save_auth_omp(), save_config_omp(), save_container_task_omp(), save_credential_omp(), save_filter_omp(), save_group_omp(), save_note_omp(), save_override_omp(), save_permission_omp(), save_port_list_omp(), save_report_format_omp(), save_role_omp(), save_scanner_omp(), save_schedule_omp(), save_tag_omp(), save_target_omp(), save_task_omp(), and save_user_omp().

#define G_LOG_DOMAIN   "gsad omp"

GLib log domain.

Definition at line 81 of file gsad_omp.c.

#define GET_TRASH_RESOURCE (   capability,
  command,
  name 
)

Definition at line 18726 of file gsad_omp.c.

#define OPENVASMD_ADDRESS   "127.0.0.1"

Manager (openvasmd) address.

Definition at line 86 of file gsad_omp.c.

#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 (credentials, connection, setting_id, \
&value, response_data); \
if (message) \
{ \
cleanup; \
return message; \
} \
}
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793

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

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 3330 of file gsad_omp.c.

Referenced by export_alerts_omp().

Function Documentation

char* auth_settings_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Definition at line 25207 of file gsad_omp.c.

References CHECK_PARAM_INVALID, command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_value().

25210 {
25211  GString * xml;
25212  gchar * buf;
25213  const char *name;
25214 
25215  name = params_value (params, "name");
25216 
25217  CHECK_PARAM_INVALID (name, "Auth settings", "auth_settings");
25218 
25219  xml = g_string_new ("");
25220  buf = g_markup_printf_escaped ("<auth_settings name=\"%s\">", name);
25221  g_string_append (xml, buf);
25222  g_free (buf);
25223 
25224  if (command_enabled (credentials, "DESCRIBE_AUTH"))
25225  {
25226  gchar * response = NULL;
25227  entity_t entity = NULL;
25228 
25229  switch (omp (connection, credentials, &response, &entity, response_data,
25230  "<describe_auth/>"))
25231  {
25232  case 0:
25233  case -1:
25234  break;
25235  case 1:
25236  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25237  return gsad_message (credentials,
25238  "Internal error", __FUNCTION__, __LINE__,
25239  "An internal error occurred getting the auth list. "
25240  "Diagnostics: Failure to send command to manager daemon.",
25241  "/omp?cmd=get_users", response_data);
25242  case 2:
25243  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25244  return gsad_message (credentials,
25245  "Internal error", __FUNCTION__, __LINE__,
25246  "An internal error occurred getting the auth list. "
25247  "Diagnostics: Failure to receive response from manager daemon.",
25248  "/omp?cmd=get_users", response_data);
25249  default:
25250  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25251  return gsad_message (credentials,
25252  "Internal error", __FUNCTION__, __LINE__,
25253  "An internal error occurred getting the auth list. "
25254  "Diagnostics: Internal Error.",
25255  "/omp?cmd=get_users", response_data);
25256  }
25257 
25258 
25259  g_string_append (xml, response);
25260  free_entity (entity);
25261  g_free (response);
25262  }
25263 
25264  g_string_append (xml, "</auth_settings>");
25265 
25266  return xsl_transform_omp (connection, credentials, params,
25267  g_string_free (xml, FALSE), response_data);
25268 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

int authenticate_omp ( const gchar *  username,
const gchar *  password,
gchar **  role,
gchar **  timezone,
gchar **  severity,
gchar **  capabilities,
gchar **  language,
gchar **  pw_warning,
GTree **  chart_prefs,
gchar **  autorefresh 
)

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.
[out]chart_prefsChart preferences.
[out]autorefreshAutorefresh preference.
Returns
0 if valid, 1 failed, 2 manager down, -1 error.

Definition at line 27622 of file gsad_omp.c.

References manager_address, manager_port, and openvas_connection_open().

Referenced by exec_omp_post(), and user_find().

27626 {
27627  openvas_connection_t connection;
27628  int auth;
27629  omp_authenticate_info_opts_t auth_opts;
27630 
27631  if (openvas_connection_open (&connection,
27633  manager_port))
27634  {
27635  g_debug ("%s failed to acquire socket!\n", __FUNCTION__);
27636  return 2;
27637  }
27638 
27639 #ifdef DEBUG_AUTH
27640  /* Enable this if you need the CGI to sleep after launch. This can be useful
27641  * if you need to attach to manager process the CGI is talking to for
27642  * debugging purposes.
27643  *
27644  * It's probably easier to run gsad in the foreground under gdb and
27645  * set a break point here.
27646  */
27647  g_debug ("Sleeping!");
27648  sleep (20);
27649 #endif
27650 
27651  auth_opts = omp_authenticate_info_opts_defaults;
27652  auth_opts.username = username;
27653  auth_opts.password = password;
27654  auth_opts.role = role;
27655  auth_opts.severity = severity;
27656  auth_opts.timezone = timezone;
27657  auth_opts.pw_warning = pw_warning;
27658 
27659  auth = omp_authenticate_info_ext_c (&connection, auth_opts);
27660  if (auth == 0)
27661  {
27662  entity_t entity;
27663  const char* status;
27664  char first;
27665  gchar *response;
27666  int ret;
27667 
27668  /* Get language setting. */
27669 
27670  ret = setting_get_value (&connection,
27671  "6765549a-934e-11e3-b358-406186ea4fc5",
27672  language,
27673  NULL);
27674 
27675  switch (ret)
27676  {
27677  case 0:
27678  break;
27679  case 1:
27680  case 2:
27681  openvas_connection_close (&connection);
27682  return 2;
27683  default:
27684  openvas_connection_close (&connection);
27685  return -1;
27686  }
27687 
27688  /* Request help. */
27689 
27690  ret = openvas_connection_sendf (&connection,
27691  "<help format=\"XML\" type=\"brief\"/>");
27692  if (ret)
27693  {
27694  openvas_connection_close (&connection);
27695  return 2;
27696  }
27697 
27698  /* Read the response. */
27699 
27700  entity = NULL;
27701  if (read_entity_and_text_c (&connection, &entity, &response))
27702  {
27703  openvas_connection_close (&connection);
27704  return 2;
27705  }
27706 
27707  /* Check the response. */
27708 
27709  status = entity_attribute (entity, "status");
27710  if (status == NULL
27711  || strlen (status) == 0)
27712  {
27713  g_free (response);
27714  free_entity (entity);
27715  return -1;
27716  }
27717  first = status[0];
27718  free_entity (entity);
27719  if (first == '2')
27720  {
27721  *capabilities = response;
27722  }
27723  else
27724  {
27725  openvas_connection_close (&connection);
27726  g_free (response);
27727  return -1;
27728  }
27729 
27730  /* Get the chart preferences */
27731 
27732  ret = openvas_connection_sendf (&connection,
27733  "<get_settings"
27734  " filter='name~\"Dashboard\"'/>");
27735  if (ret)
27736  {
27737  openvas_connection_close (&connection);
27738  return 2;
27739  }
27740 
27741  /* Read the response */
27742  entity = NULL;
27743  if (read_entity_and_text_c (&connection, &entity, &response))
27744  {
27745  openvas_connection_close (&connection);
27746  return 2;
27747  }
27748 
27749  /* Check the response. */
27750  status = entity_attribute (entity, "status");
27751  if (status == NULL
27752  || strlen (status) == 0)
27753  {
27754  g_free (response);
27755  free_entity (entity);
27756  return -1;
27757  }
27758  first = status[0];
27759  if (first == '2')
27760  {
27761  entities_t entities = entity->entities;
27762  entity_t child_entity;
27763  *chart_prefs = g_tree_new_full ((GCompareDataFunc) g_strcmp0,
27764  NULL, g_free, g_free);
27765 
27766  while ((child_entity = first_entity (entities)))
27767  {
27768  if (strcmp (entity_name (child_entity), "setting") == 0)
27769  {
27770  const char *setting_id
27771  = entity_attribute (child_entity, "id");
27772  const char *setting_value
27773  = entity_text (entity_child (child_entity, "value"));
27774 
27775  if (setting_id && setting_value)
27776  g_tree_insert (*chart_prefs,
27777  g_strdup (setting_id),
27778  g_strdup (setting_value));
27779  }
27780  entities = next_entities (entities);
27781  }
27782  free_entity (entity);
27783  g_free (response);
27784  }
27785  else
27786  {
27787  free_entity (entity);
27788  g_free (response);
27789  openvas_connection_close (&connection);
27790  return -1;
27791  }
27792 
27793  /* Get autorefresh setting. */
27794 
27795  ret = setting_get_value (&connection,
27796  "578a1c14-e2dc-45ef-a591-89d31391d007",
27797  autorefresh,
27798  NULL);
27799 
27800  switch (ret)
27801  {
27802  case 0:
27803  break;
27804  case 1:
27805  case 2:
27806  openvas_connection_close (&connection);
27807  return 2;
27808  default:
27809  openvas_connection_close (&connection);
27810  return -1;
27811  }
27812 
27813  openvas_connection_close (&connection);
27814  return 0;
27815  }
27816  else
27817  {
27818  openvas_connection_close (&connection);
27819  return 1;
27820  }
27821 }
gchar * manager_address
The address the manager is on.
Definition: gsad_omp.c:96
int manager_port
The port the manager is on.
Definition: gsad_omp.c:101
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_omp.c:27580

Here is the call graph for this function:

Here is the caller graph for this function:

char* bulk_delete_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete multiple resources, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 26639 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), and params_values().

26641 {
26642  const char *no_redirect, *type;
26643  GString *commands_xml;
26644  params_t *selected_ids;
26645  params_iterator_t iter;
26646  param_t *param;
26647  gchar *param_name;
26648  gchar *html, *response;
26649  entity_t entity;
26650  gchar *extra_attribs;
26651 
26652  no_redirect = params_value (params, "no_redirect");
26653  type = params_value (params, "resource_type");
26654  if (type == NULL)
26655  {
26656  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26657  return gsad_message (credentials,
26658  "Internal error", __FUNCTION__, __LINE__,
26659  "An internal error occurred while deleting resources. "
26660  "The resources were not deleted. "
26661  "Diagnostics: Required parameter 'resource_type' was NULL.",
26662  "/omp?cmd=get_tasks", response_data);
26663  }
26664 
26665  /* Extra attributes */
26666  extra_attribs = NULL;
26667 
26668  /* Inheritor of user's resource */
26669  if (strcmp (type, "user") == 0)
26670  {
26671  const char* inheritor_id;
26672  inheritor_id = params_value (params, "inheritor_id");
26673  if (inheritor_id)
26674  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
26675  }
26676 
26677  commands_xml = g_string_new ("<commands>");
26678 
26679  selected_ids = params_values (params, "bulk_selected:");
26680  if (selected_ids)
26681  {
26682  params_iterator_init (&iter, selected_ids);
26683  while (params_iterator_next (&iter, &param_name, &param))
26684  {
26685  xml_string_append (commands_xml,
26686  "<delete_%s %s_id=\"%s\" ultimate=\"0\"",
26687  type,
26688  type,
26689  param_name);
26690  if (extra_attribs)
26691  g_string_append_printf (commands_xml, " %s/>", extra_attribs);
26692  else
26693  g_string_append (commands_xml, "/>");
26694  }
26695  }
26696 
26697  g_string_append (commands_xml, "</commands>");
26698 
26699  /* Delete the resources and get all resources. */
26700 
26701  if (openvas_connection_sendf_xml (connection,
26702  commands_xml->str)
26703  == -1)
26704  {
26705  g_string_free (commands_xml, TRUE);
26706  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26707  return gsad_message (credentials,
26708  "Internal error", __FUNCTION__, __LINE__,
26709  "An internal error occurred while deleting resources. "
26710  "The resources were not deleted. "
26711  "Diagnostics: Failure to send command to manager daemon.",
26712  "/omp?cmd=get_tasks", response_data);
26713  }
26714  g_string_free (commands_xml, TRUE);
26715 
26716  entity = NULL;
26717  if (read_entity_and_text_c (connection, &entity, &response))
26718  {
26719  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26720  return gsad_message (credentials,
26721  "Internal error", __FUNCTION__, __LINE__,
26722  "An internal error occurred while deleting resources. "
26723  "It is unclear whether the resources have been deleted or not. "
26724  "Diagnostics: Failure to read response from manager daemon.",
26725  "/omp?cmd=get_tasks", response_data);
26726  }
26727 
26728  /* Cleanup, and return transformed XML. */
26729 
26730  if (params_given (params, "next") == 0)
26731  {
26732  gchar *next;
26733  next = g_strdup_printf ("get_%ss", type);
26734  params_add (params, "next", next);
26735  g_free (next);
26736  }
26737  html = response_from_entity (connection, credentials, params, entity,
26738  (no_redirect && strcmp (no_redirect, "0")),
26739  NULL, NULL,
26740  NULL, NULL,
26741  "Bulk Delete", response_data);
26742  g_free (response);
26743  free_entity (entity);
26744 
26745  return html;
26746 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808

Here is the call graph for this function:

char* clone_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Clone a resource, XSL transform 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
Result of XSL transformation.

Definition at line 9629 of file gsad_omp.c.

References CHECK, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_value(), and set_http_status_from_entity().

9631 {
9632  gchar *html, *response;
9633  const char *id, *type, *alterable, *no_redirect, *next_id;
9634  gchar *next_id_name, *cap_type, *prev_action;
9635  entity_t entity;
9636 
9637  id = params_value (params, "id");
9638  type = params_value (params, "resource_type");
9639  alterable = params_value (params, "alterable");
9640  no_redirect = params_value (params, "no_redirect");
9641 
9642  CHECK (id);
9643  CHECK (type);
9644 
9645  /* Clone the resource. */
9646 
9647  if (alterable && strcmp (alterable, "0"))
9648  {
9649  if (openvas_connection_sendf (connection,
9650  "<create_%s>"
9651  "<copy>%s</copy>"
9652  "<alterable>1</alterable>"
9653  "</create_%s>",
9654  type,
9655  id,
9656  type)
9657  == -1)
9658  {
9659  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9660  return gsad_message (credentials,
9661  "Internal error", __FUNCTION__, __LINE__,
9662  "An internal error occurred while cloning a resource. "
9663  "The resource was not cloned. "
9664  "Diagnostics: Failure to send command to manager daemon.",
9665  "/omp?cmd=get_tasks", response_data);
9666  }
9667  }
9668  else if (openvas_connection_sendf (connection,
9669  "<create_%s>"
9670  "<copy>%s</copy>"
9671  "</create_%s>",
9672  type,
9673  id,
9674  type)
9675  == -1)
9676  {
9677  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9678  return gsad_message (credentials,
9679  "Internal error", __FUNCTION__, __LINE__,
9680  "An internal error occurred while cloning a resource. "
9681  "The resource was not cloned. "
9682  "Diagnostics: Failure to send command to manager daemon.",
9683  "/omp?cmd=get_tasks", response_data);
9684  }
9685 
9686  entity = NULL;
9687  if (read_entity_and_text_c (connection, &entity, &response))
9688  {
9689  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9690  return gsad_message (credentials,
9691  "Internal error", __FUNCTION__, __LINE__,
9692  "An internal error occurred while cloning a resource. "
9693  "It is unclear whether the resource has been cloned or not. "
9694  "Diagnostics: Failure to read response from manager daemon.",
9695  "/omp?cmd=get_tasks", response_data);
9696  }
9697 
9698  /* Cleanup, and return next page. */
9699 
9700  if (omp_success (entity) == 0 || params_given (params, "next") == 0)
9701  {
9702  gchar *next;
9703  next = g_strdup_printf ("get_%ss", type);
9704  params_add (params, "next", next);
9705  g_free (next);
9706  }
9707 
9708  if (omp_success (entity))
9709  {
9710  next_id = entity_attribute (entity, "id");
9711  if (next_id == NULL)
9712  {
9713  free_entity (entity);
9714  g_free (response);
9715  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9716  return gsad_message (credentials,
9717  "Internal error", __FUNCTION__, __LINE__,
9718  "An internal error occurred while cloning a resource. "
9719  "The resource remains the same. "
9720  "Diagnostics: Error getting new resource.",
9721  "/omp?cmd=get_tasks", response_data);
9722  }
9723  next_id_name = g_strdup_printf ("%s_id", type);
9724  params_add (params, next_id_name, next_id);
9725  g_free (next_id_name);
9726  }
9727  else
9728  {
9729  set_http_status_from_entity (entity, response_data);
9730  next_id_name = NULL;
9731  next_id = NULL;
9732  }
9733 
9734  cap_type = capitalize (type);
9735  prev_action = g_strdup_printf ("Clone %s", cap_type);
9736  html = response_from_entity (connection, credentials, params, entity,
9737  (no_redirect && strcmp (no_redirect, "0")),
9738  NULL, NULL,
9739  NULL, NULL,
9740  prev_action, response_data);
9741 
9742  free_entity (entity);
9743  g_free (cap_type);
9744  g_free (prev_action);
9745  g_free (response);
9746 
9747  return html;
9748 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9605
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808

Here is the call graph for this function:

void cmd_response_data_init ( cmd_response_data_t data)

Initializes a cmd_response_data_t struct.

Parameters
[in]dataThe cmd_response_data_t struct to initialize

Definition at line 348 of file gsad_omp.c.

References cmd_response_data_t::http_status_code, and cmd_response_data_t::redirect.

Referenced by exec_omp_post(), and handle_request().

349 {
350  data->http_status_code = MHD_HTTP_OK;
351  data->redirect = NULL;
352 }
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94

Here is the caller graph for this function:

void cmd_response_data_reset ( cmd_response_data_t data)

Clears a cmd_response_data_t struct.

Parameters
[in]dataStruct to reset.

Definition at line 360 of file gsad_omp.c.

References param::value.

Referenced by exec_omp_post(), and handle_request().

361 {
362  memset (data, 0, sizeof (cmd_response_data_t));
363 }
Response information for commands.
Definition: gsad_base.h:92

Here is the caller graph for this function:

int command_enabled ( credentials_t credentials,
const gchar *  name 
)

Init the GSA OMP library.

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

Definition at line 305 of file gsad_omp.c.

References credentials_t::capabilities.

Referenced by auth_settings_omp(), create_role_omp(), dashboard(), delete_alert_omp(), delete_report_omp(), delete_task_omp(), delete_user_confirm_omp(), delete_user_omp(), edit_alert(), edit_permission(), edit_target(), edit_user(), export_alerts_omp(), get_alert_omp(), get_info(), get_my_settings_omp(), get_one(), get_system_reports_omp(), get_tasks_chart_omp(), get_user_omp(), new_container_task_omp(), new_permission(), new_permissions(), and save_schedule_omp().

306 {
307  /* TODO Hack. Fails if command named in summary of another command. */
308  return strstr (credentials->capabilities, name) ? 1 : 0;
309 }
char * capabilities
Capabilites of manager.
Definition: gsad_base.h:76

Here is the caller graph for this function:

int connect_unix ( const gchar *  path)

Connect to OpenVAS Manager daemon.

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

Definition at line 27542 of file gsad_omp.c.

Referenced by openvas_connection_open().

27543 {
27544  struct sockaddr_un address;
27545  int sock;
27546 
27547  /* Make socket. */
27548 
27549  sock = socket (AF_UNIX, SOCK_STREAM, 0);
27550  if (sock == -1)
27551  {
27552  g_warning ("Failed to create server socket");
27553  return -1;
27554  }
27555 
27556  /* Connect to server. */
27557 
27558  address.sun_family = AF_UNIX;
27559  strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
27560  if (connect (sock, (struct sockaddr *) &address, sizeof (address)) == -1)
27561  {
27562  g_warning ("Failed to connect to server: %s", strerror (errno));
27563  close (sock);
27564  return -1;
27565  }
27566 
27567  return sock;
27568 }

Here is the caller graph for this function:

char* create_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an agent, get all agents, XSL transform 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 of XSL transformation.

Definition at line 6928 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_filename(), params_value(), and params_value_size().

6930 {
6931  entity_t entity;
6932  gchar *response, *html;
6933  const char *no_redirect;
6934  const char *name, *comment, *installer, *installer_filename, *installer_sig;
6935  const char *howto_install, *howto_use;
6936  int installer_size, installer_sig_size, howto_install_size, howto_use_size;
6937  int ret;
6938  gchar *name_escaped, *comment_escaped;
6939  gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
6940  gchar *command;
6941 
6942  no_redirect = params_value (params, "no_redirect");
6943  name = params_value (params, "name");
6944  comment = params_value (params, "comment");
6945  installer = params_value (params, "installer");
6946  installer_filename = params_filename (params, "installer");
6947  installer_size = params_value_size (params, "installer");
6948  installer_sig = params_value (params, "installer_sig");
6949  installer_sig_size = params_value_size (params, "installer_sig");
6950  howto_install = params_value (params, "howto_install");
6951  howto_install_size = params_value_size (params, "howto_install");
6952  howto_use = params_value (params, "howto_use");
6953  howto_use_size = params_value_size (params, "howto_use");
6954 
6955  CHECK_PARAM_INVALID (name, "Create Agent", "new_agent");
6956  CHECK_PARAM_INVALID (comment, "Create Agent", "new_agent");
6957 
6958  /* Create the agent. */
6959 
6960  installer_64 = (installer_size > 0)
6961  ? g_base64_encode ((guchar *) installer,
6962  installer_size)
6963  : g_strdup ("");
6964 
6965  installer_sig_64 = (installer_sig_size > 0)
6966  ? g_base64_encode ((guchar *) installer_sig,
6967  installer_sig_size)
6968  : g_strdup ("");
6969 
6970  howto_install_64 = (howto_install_size > 0)
6971  ? g_base64_encode ((guchar *) howto_install,
6972  howto_install_size)
6973  : g_strdup ("");
6974 
6975  howto_use_64 = (howto_use_size > 0)
6976  ? g_base64_encode ((guchar *) howto_use,
6977  howto_use_size)
6978  : g_strdup ("");
6979 
6980  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
6981  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
6982 
6983  command = g_strdup_printf ("<create_agent>"
6984  "<name>%s</name>"
6985  "%s%s%s"
6986  "<installer>"
6987  "%s"
6988  "<signature>%s</signature>"
6989  "<filename>%s</filename>"
6990  "</installer>"
6991  "<howto_install>%s</howto_install>"
6992  "<howto_use>%s</howto_use>"
6993  "</create_agent>",
6994  name_escaped,
6995  comment_escaped ? "<comment>" : "",
6996  comment_escaped ? comment_escaped : "",
6997  comment_escaped ? "</comment>" : "",
6998  installer_64,
6999  installer_sig_64,
7000  installer_filename ? installer_filename : "",
7001  howto_install_64,
7002  howto_use_64);
7003 
7004  ret = omp (connection, credentials,
7005  &response,
7006  &entity,
7007  response_data,
7008  command);
7009  g_free (command);
7010 
7011  g_free (installer_64);
7012  g_free (howto_install_64);
7013  g_free (howto_use_64);
7014  g_free (name_escaped);
7015  g_free (comment_escaped);
7016 
7017  switch (ret)
7018  {
7019  case 0:
7020  break;
7021  case -1:
7022  /* 'omp' set response. */
7023  return response;
7024  case 1:
7025  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7026  return gsad_message (credentials,
7027  "Internal error", __FUNCTION__, __LINE__,
7028  "An internal error occurred while creating a new agent. "
7029  "No new agent was created. "
7030  "Diagnostics: Failure to send command to manager daemon.",
7031  "/omp?cmd=get_agents", response_data);
7032  case 2:
7033  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7034  return gsad_message (credentials,
7035  "Internal error", __FUNCTION__, __LINE__,
7036  "An internal error occurred while creating a new agent. "
7037  "It is unclear whether the agent has been created or not. "
7038  "Diagnostics: Failure to receive response from manager daemon.",
7039  "/omp?cmd=get_agents", response_data);
7040  default:
7041  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7042  return gsad_message (credentials,
7043  "Internal error", __FUNCTION__, __LINE__,
7044  "An internal error occurred while creating a new agent. "
7045  "It is unclear whether the agent has been created or not. "
7046  "Diagnostics: Internal Error.",
7047  "/omp?cmd=get_agents", response_data);
7048  }
7049 
7050  if (entity_attribute (entity, "id"))
7051  params_add (params, "agent_id", entity_attribute (entity, "id"));
7052  html = response_from_entity (connection, credentials, params, entity,
7053  (no_redirect && strcmp (no_redirect, "0")),
7054  NULL, "get_agents",
7055  NULL, "new_agent",
7056  "Create Agent", response_data);
7057  free_entity (entity);
7058  g_free (response);
7059  return html;
7060 }
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
Definition: gsad_base.c:727
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_filename(params_t *params, const char *name)
Get filename of param.
Definition: gsad_base.c:761
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an alert, get all alerts, XSL transform 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
Result of XSL transformation.

Definition at line 8228 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

8230 {
8231  int ret;
8232  gchar *html, *response;
8233  const char *no_redirect;
8234  const char *name, *comment, *condition, *event, *method, *filter_id;
8235  params_t *method_data, *event_data, *condition_data;
8236  entity_t entity;
8237  GString *xml;
8238 
8239  no_redirect = params_value (params, "no_redirect");
8240  name = params_value (params, "name");
8241  comment = params_value (params, "comment");
8242  if (params_given (params, "condition"))
8243  condition = params_value (params, "condition");
8244  else
8245  condition = "Always";
8246  event = params_value (params, "event");
8247  method = params_value (params, "method");
8248  filter_id = params_value (params, "filter_id");
8249 
8250  CHECK_PARAM_INVALID (name, "Create Alert", "new_alert");
8251  CHECK_PARAM_INVALID (comment, "Create Alert", "new_alert");
8252  CHECK_PARAM_INVALID (condition, "Create Alert", "new_alert");
8253  CHECK_PARAM_INVALID (event, "Create Alert", "new_alert");
8254  CHECK_PARAM_INVALID (method, "Create Alert", "new_alert");
8255  if (strcmp (event, "Task run status changed") == 0)
8256  {
8257  CHECK_PARAM_INVALID (filter_id, "Save Alert", "new_alert");
8258  }
8259 
8260  /* Create the alert. */
8261 
8262  method_data = params_values (params, "method_data:");
8263  event_data = params_values (params, "event_data:");
8264  condition_data = params_values (params, "condition_data:");
8265 
8266  xml = g_string_new ("");
8267 
8268  if ((strcmp (event, "New SecInfo arrived") == 0) && event_data)
8269  {
8270  params_iterator_t iter;
8271  char *name;
8272  param_t *param;
8273 
8274  params_iterator_init (&iter, event_data);
8275  while (params_iterator_next (&iter, &name, &param))
8276  if ((strcmp (name, "feed_event") == 0)
8277  && param->value
8278  && (strcmp (param->value, "updated") == 0))
8279  {
8280  event = "Updated SecInfo arrived";
8281  break;
8282  }
8283  }
8284 
8285  xml_string_append (xml,
8286  "<create_alert>"
8287  "<name>%s</name>"
8288  "<filter id=\"%s\"/>"
8289  "<comment>%s</comment>"
8290  "<event>%s",
8291  name,
8292  filter_id,
8293  comment ? comment : "",
8294  event);
8295 
8296  append_alert_event_data (xml, event_data, event);
8297 
8298  xml_string_append (xml,
8299  "</event>"
8300  "<method>%s",
8301  method);
8302 
8303  append_alert_method_data (xml, method_data, method);
8304 
8305  xml_string_append (xml,
8306  "</method>"
8307  "<condition>%s",
8308  condition);
8309 
8310  append_alert_condition_data (xml, condition_data, condition);
8311 
8312  xml_string_append (xml,
8313  "</condition>"
8314  "</create_alert>");
8315 
8316  ret = omp (connection, credentials,
8317  &response,
8318  &entity,
8319  response_data,
8320  xml->str);
8321  g_string_free (xml, TRUE);
8322  switch (ret)
8323  {
8324  case 0:
8325  case -1:
8326  break;
8327  case 1:
8328  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8329  return gsad_message (credentials,
8330  "Internal error", __FUNCTION__, __LINE__,
8331  "An internal error occurred while creating a new alert. "
8332  "No new alert was created. "
8333  "Diagnostics: Failure to send command to manager daemon.",
8334  "/omp?cmd=get_alerts", response_data);
8335  case 2:
8336  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8337  return gsad_message (credentials,
8338  "Internal error", __FUNCTION__, __LINE__,
8339  "An internal error occurred while creating a new alert. "
8340  "It is unclear whether the alert has been created or not. "
8341  "Diagnostics: Failure to receive response from manager daemon.",
8342  "/omp?cmd=get_alerts", response_data);
8343  default:
8344  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8345  return gsad_message (credentials,
8346  "Internal error", __FUNCTION__, __LINE__,
8347  "An internal error occurred while creating a new alert. "
8348  "It is unclear whether the alert has been created or not. "
8349  "Diagnostics: Internal Error.",
8350  "/omp?cmd=get_alerts", response_data);
8351  }
8352 
8353  if (entity_attribute (entity, "id"))
8354  params_add (params, "alert_id", entity_attribute (entity, "id"));
8355  html = response_from_entity (connection, credentials, params, entity,
8356  (no_redirect && strcmp (no_redirect, "0")),
8357  NULL, "get_alerts",
8358  NULL, "new_alert",
8359  "Create Alert", response_data);
8360  free_entity (entity);
8361  g_free (response);
8362  return html;
8363 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_asset_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an asset, get report, XSL transform 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
Result of XSL transformation.

Definition at line 27071 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

27073 {
27074  char *ret;
27075  gchar *response;
27076  const char *no_redirect, *report_id, *filter;
27077  entity_t entity;
27078 
27079  no_redirect = params_value (params, "no_redirect");
27080  report_id = params_value (params, "report_id");
27081  filter = params_value (params, "filter");
27082 
27083  CHECK_PARAM_INVALID (report_id, "Create Asset", "get_report_section");
27084  CHECK_PARAM_INVALID (filter, "Create Asset", "get_report_section");
27085 
27086  response = NULL;
27087  entity = NULL;
27088  switch (ompf (connection, credentials,
27089  &response,
27090  &entity,
27091  response_data,
27092  "<create_asset>"
27093  "<report id=\"%s\">"
27094  "<filter><term>%s</term></filter>"
27095  "</report>"
27096  "</create_asset>",
27097  report_id,
27098  filter))
27099  {
27100  case 0:
27101  case -1:
27102  break;
27103  case 1:
27104  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27105  return gsad_message (credentials,
27106  "Internal error", __FUNCTION__, __LINE__,
27107  "An internal error occurred while creating an asset. "
27108  "No new asset was created. "
27109  "Diagnostics: Failure to send command to manager daemon.",
27110  "/omp?cmd=get_tasks", response_data);
27111  case 2:
27112  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27113  return gsad_message (credentials,
27114  "Internal error", __FUNCTION__, __LINE__,
27115  "An internal error occurred while creating an asset. "
27116  "It is unclear whether the asset has been created or not. "
27117  "Diagnostics: Failure to receive response from manager daemon.",
27118  "/omp?cmd=get_tasks", response_data);
27119  default:
27120  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27121  return gsad_message (credentials,
27122  "Internal error", __FUNCTION__, __LINE__,
27123  "An internal error occurred while creating an asset. "
27124  "It is unclear whether the asset has been created or not. "
27125  "Diagnostics: Internal Error.",
27126  "/omp?cmd=get_tasks", response_data);
27127  }
27128 
27129  ret = response_from_entity (connection, credentials, params, entity,
27130  (no_redirect && strcmp (no_redirect, "0")),
27131  NULL, "get_report_section",
27132  NULL, "get_report_section",
27133  "Create Asset", response_data);
27134  free_entity (entity);
27135  g_free (response);
27136  return ret;
27137 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create config, get all configs, XSL transform 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
Result of XSL transformation.

Definition at line 11379 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

11382 {
11383  gchar *html, *response;
11384  const char *no_redirect, *name, *comment, *base, *scanner = NULL;
11385  entity_t entity;
11386 
11387  no_redirect = params_value (params, "no_redirect");
11388  name = params_value (params, "name");
11389  comment = params_value (params, "comment");
11390  base = params_value (params, "base");
11391 
11392  CHECK_PARAM_INVALID (name, "New Config", "new_config");
11393  CHECK_PARAM_INVALID (comment, "New Config", "new_config");
11394  CHECK_PARAM_INVALID (base, "New Config", "new_config");
11395  if (!strcmp (base, "0"))
11396  {
11397  scanner = params_value (params, "scanner_id");
11398  CHECK_PARAM_INVALID (scanner, "New Config", "new_config");
11399  }
11400 
11401  /* Create the config. */
11402  switch (ompf (connection, credentials,
11403  &response,
11404  &entity,
11405  response_data,
11406  "<create_config>"
11407  "<name>%s</name>"
11408  "<copy>%s</copy>"
11409  "<comment>%s</comment>"
11410  "<scanner>%s</scanner>"
11411  "</create_config>",
11412  name, base, comment,
11413  scanner ?: ""))
11414  {
11415  case 0:
11416  case -1:
11417  break;
11418  case 1:
11419  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11420  return gsad_message (credentials,
11421  "Internal error", __FUNCTION__, __LINE__,
11422  "An internal error occurred while creating a new config. "
11423  "No new config was created. "
11424  "Diagnostics: Failure to send command to manager daemon.",
11425  "/omp?cmd=get_configs", response_data);
11426  case 2:
11427  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11428  return gsad_message (credentials,
11429  "Internal error", __FUNCTION__, __LINE__,
11430  "An internal error occurred while creating a new config. "
11431  "It is unclear whether the config has been created or not. "
11432  "Diagnostics: Failure to receive response from manager daemon.",
11433  "/omp?cmd=get_configs", response_data);
11434  default:
11435  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11436  return gsad_message (credentials,
11437  "Internal error", __FUNCTION__, __LINE__,
11438  "An internal error occurred while creating a new config. "
11439  "It is unclear whether the config has been created or not. "
11440  "Diagnostics: Internal Error.",
11441  "/omp?cmd=get_configs", response_data);
11442  }
11443 
11444  if (entity_attribute (entity, "id"))
11445  params_add (params, "config_id", entity_attribute (entity, "id"));
11446  html = response_from_entity (connection, credentials, params, entity,
11447  (no_redirect && strcmp (no_redirect, "0")),
11448  NULL, "get_configs",
11449  NULL, "new_config",
11450  "Create Config", response_data);
11451 
11452  free_entity (entity);
11453  g_free (response);
11454  return html;
11455 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_container_task_omp ( openvas_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
Result of XSL transformation.

Definition at line 4029 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

4032 {
4033  entity_t entity;
4034  int ret;
4035  gchar *command, *html, *response;
4036  const char *no_redirect, *name, *comment;
4037 
4038  no_redirect = params_value (params, "no_redirect");
4039  name = params_value (params, "name");
4040  comment = params_value (params, "comment");
4041  CHECK_PARAM_INVALID (name, "Create Container Task", "new_container_task");
4042  CHECK_PARAM_INVALID (comment, "Create Container Task", "new_container_task");
4043 
4044  command = g_markup_printf_escaped ("<create_task>"
4045  "<target id=\"0\"/>"
4046  "<name>%s</name>"
4047  "<comment>%s</comment>"
4048  "</create_task>",
4049  name,
4050  comment);
4051  ret = omp (connection, credentials,
4052  &response,
4053  &entity,
4054  response_data,
4055  command);
4056  g_free (command);
4057 
4058  switch (ret)
4059  {
4060  case 0:
4061  break;
4062  case -1:
4063  /* 'omp' set response. */
4064  return response;
4065  case 1:
4066  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4067  return gsad_message (credentials,
4068  "Internal error", __FUNCTION__, __LINE__,
4069  "An internal error occurred while creating a container task. "
4070  "No task was created. "
4071  "Diagnostics: Failure to send command to manager daemon.",
4072  "/omp?cmd=get_tasks", response_data);
4073  case 2:
4074  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4075  return gsad_message (credentials,
4076  "Internal error", __FUNCTION__, __LINE__,
4077  "An internal error occurred while creating a container task. "
4078  "It is unclear whether the task has been created or not. "
4079  "Diagnostics: Failure to receive response from manager daemon.",
4080  "/omp?cmd=get_tasks", response_data);
4081  default:
4082  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4083  return gsad_message (credentials,
4084  "Internal error", __FUNCTION__, __LINE__,
4085  "An internal error occurred while creating a container task. "
4086  "It is unclear whether the task has been created or not. "
4087  "Diagnostics: Internal Error.",
4088  "/omp?cmd=get_tasks", response_data);
4089  }
4090 
4091  if (entity_attribute (entity, "id"))
4092  params_add (params, "task_id", entity_attribute (entity, "id"));
4093  html = response_from_entity (connection, credentials, params, entity,
4094  (no_redirect && strcmp (no_redirect, "0")),
4095  NULL, "get_tasks",
4096  NULL, "new_container_task",
4097  "Create Container Task", response_data);
4098  free_entity (entity);
4099  g_free (response);
4100  return html;
4101 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a credential, get all credentials, XSL transform 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 of XSL transformation.

Definition at line 5974 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, message_invalid(), params_add(), params_given(), params_t, and params_value().

5977 {
5978  int ret;
5979  gchar *html, *response;
5980  const char *no_redirect;
5981  const char *name, *comment, *login, *type, *password, *passphrase;
5982  const char *private_key, *certificate, *community, *privacy_password;
5983  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
5984  int autogenerate;
5985  entity_t entity;
5986 
5987  no_redirect = params_value (params, "no_redirect");
5988  name = params_value (params, "name");
5989  comment = params_value (params, "comment");
5990  login = params_value (params, "credential_login");
5991  type = params_value (params, "base");
5992  password = params_value (params, "lsc_password");
5993  passphrase = params_value (params, "passphrase");
5994  private_key = params_value (params, "private_key");
5995  certificate = params_value (params, "certificate");
5996  community = params_value (params, "community");
5997  privacy_password = params_value (params, "privacy_password");
5998  auth_algorithm = params_value (params, "auth_algorithm");
5999  privacy_algorithm = params_value (params, "privacy_algorithm");
6000  allow_insecure = params_value (params, "allow_insecure");
6001 
6002  if (params_value (params, "autogenerate"))
6003  autogenerate = strcmp (params_value (params, "autogenerate"), "0");
6004  else if (params_given (params, "autogenerate"))
6005  return message_invalid (connection, credentials, params, response_data,
6006  "Given autogenerate was invalid",
6007  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
6008  "Create Credential", "new_credential");
6009  else
6010  autogenerate = 0;
6011 
6012  CHECK_PARAM_INVALID (name, "Create Credential", "new_credential");
6013  CHECK_PARAM_INVALID (comment, "Create Credential", "new_credential");
6014  CHECK_PARAM_INVALID (type, "Create Credential", "new_credential");
6015  CHECK_PARAM_INVALID (allow_insecure, "Create Credential", "new_credential");
6016 
6017  if (autogenerate)
6018  {
6019  if (type && (strcmp (type, "cc") == 0))
6020  {
6021  // Auto-generate types without username
6022  ret = ompf (connection,
6023  credentials,
6024  &response,
6025  &entity,
6026  response_data,
6027  "<create_credential>"
6028  "<name>%s</name>"
6029  "<comment>%s</comment>"
6030  "<type>%s</type>"
6031  "<allow_insecure>%s</allow_insecure>"
6032  "</create_credential>",
6033  name,
6034  comment ? comment : "",
6035  type,
6036  allow_insecure);
6037  }
6038  else
6039  {
6040  // Auto-generate types with username
6041  CHECK_PARAM_INVALID (login, "Create Credential", "new_credential");
6042 
6043  ret = ompf (connection, credentials,
6044  &response,
6045  &entity,
6046  response_data,
6047  "<create_credential>"
6048  "<name>%s</name>"
6049  "<comment>%s</comment>"
6050  "<type>%s</type>"
6051  "<login>%s</login>"
6052  "<allow_insecure>%s</allow_insecure>"
6053  "</create_credential>",
6054  name,
6055  comment ? comment : "",
6056  type,
6057  login,
6058  allow_insecure);
6059  }
6060  }
6061  else
6062  {
6063  if (type && (strcmp (type, "up") == 0))
6064  {
6065  CHECK_PARAM_INVALID (login,
6066  "Create Credential", "new_credential");
6067  CHECK_PARAM_INVALID (password,
6068  "Create Credential", "new_credential");
6069 
6070  ret = ompf (connection, credentials,
6071  &response,
6072  &entity,
6073  response_data,
6074  "<create_credential>"
6075  "<name>%s</name>"
6076  "<comment>%s</comment>"
6077  "<type>%s</type>"
6078  "<login>%s</login>"
6079  "<password>%s</password>"
6080  "<allow_insecure>%s</allow_insecure>"
6081  "</create_credential>",
6082  name,
6083  comment ? comment : "",
6084  type,
6085  login ? login : "",
6086  password ? password : "",
6087  allow_insecure);
6088  }
6089  else if (type && (strcmp (type, "usk") == 0))
6090  {
6091  CHECK_PARAM_INVALID (login,
6092  "Create Credential", "new_credential");
6093  CHECK_PARAM_INVALID (passphrase,
6094  "Create Credential", "new_credential");
6095  CHECK_PARAM_INVALID (private_key,
6096  "Create Credential", "new_credential");
6097 
6098  ret = ompf (connection, credentials,
6099  &response,
6100  &entity,
6101  response_data,
6102  "<create_credential>"
6103  "<name>%s</name>"
6104  "<comment>%s</comment>"
6105  "<type>%s</type>"
6106  "<login>%s</login>"
6107  "<key>"
6108  "<private>%s</private>"
6109  "<phrase>%s</phrase>"
6110  "</key>"
6111  "<allow_insecure>%s</allow_insecure>"
6112  "</create_credential>",
6113  name,
6114  comment ? comment : "",
6115  type,
6116  login ? login : "",
6117  private_key ? private_key : "",
6118  passphrase ? passphrase : "",
6119  allow_insecure);
6120  }
6121  else if (type && (strcmp (type, "cc") == 0))
6122  {
6123  CHECK_PARAM_INVALID (certificate,
6124  "Create Credential", "new_credential");
6125  CHECK_PARAM_INVALID (private_key,
6126  "Create Credential", "new_credential");
6127 
6128  ret = ompf (connection, credentials,
6129  &response,
6130  &entity,
6131  response_data,
6132  "<create_credential>"
6133  "<name>%s</name>"
6134  "<comment>%s</comment>"
6135  "<type>%s</type>"
6136  "<certificate>%s</certificate>"
6137  "<key>"
6138  "<private>%s</private>"
6139  "</key>"
6140  "<allow_insecure>%s</allow_insecure>"
6141  "</create_credential>",
6142  name,
6143  comment ? comment : "",
6144  type,
6145  certificate ? certificate : "",
6146  private_key ? private_key : "",
6147  allow_insecure);
6148 
6149  }
6150  else if (type && (strcmp (type, "snmp") == 0))
6151  {
6152  CHECK_PARAM_INVALID (community,
6153  "Create Credential", "new_credential");
6154  CHECK_PARAM_INVALID (login,
6155  "Create Credential", "new_credential");
6156  CHECK_PARAM_INVALID (password,
6157  "Create Credential", "new_credential");
6158  CHECK_PARAM_INVALID (privacy_password,
6159  "Create Credential", "new_credential");
6160  CHECK_PARAM_INVALID (auth_algorithm,
6161  "Create Credential", "new_credential");
6162  CHECK_PARAM_INVALID (privacy_algorithm,
6163  "Create Credential", "new_credential");
6164 
6165  if (privacy_password && strcmp (privacy_password, ""))
6166  ret = ompf (connection, credentials,
6167  &response,
6168  &entity,
6169  response_data,
6170  "<create_credential>"
6171  "<name>%s</name>"
6172  "<comment>%s</comment>"
6173  "<type>%s</type>"
6174  "<community>%s</community>"
6175  "<login>%s</login>"
6176  "<password>%s</password>"
6177  "<privacy>"
6178  "<password>%s</password>"
6179  "<algorithm>%s</algorithm>"
6180  "</privacy>"
6181  "<auth_algorithm>%s</auth_algorithm>"
6182  "<allow_insecure>%s</allow_insecure>"
6183  "</create_credential>",
6184  name,
6185  comment ? comment : "",
6186  type,
6187  community ? community : "",
6188  login ? login : "",
6189  password ? password : "",
6190  privacy_password ? privacy_password : "",
6191  privacy_algorithm ? privacy_algorithm : "",
6192  auth_algorithm ? auth_algorithm : "",
6193  allow_insecure);
6194  else
6195  ret = ompf (connection, credentials,
6196  &response,
6197  &entity,
6198  response_data,
6199  "<create_credential>"
6200  "<name>%s</name>"
6201  "<comment>%s</comment>"
6202  "<type>%s</type>"
6203  "<community>%s</community>"
6204  "<login>%s</login>"
6205  "<password>%s</password>"
6206  "<auth_algorithm>%s</auth_algorithm>"
6207  "<allow_insecure>%s</allow_insecure>"
6208  "</create_credential>",
6209  name,
6210  comment ? comment : "",
6211  type,
6212  community ? community : "",
6213  login ? login : "",
6214  password ? password : "",
6215  auth_algorithm ? auth_algorithm : "",
6216  allow_insecure);
6217  }
6218  else
6219  {
6220  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6221  return gsad_message (credentials,
6222  "Internal error", __FUNCTION__, __LINE__,
6223  "An internal error occurred while creating a new credential. "
6224  "The credential could not be created. "
6225  "Diagnostics: Unrecognized credential type.",
6226  "/omp?cmd=get_credentials", response_data);
6227  }
6228  }
6229 
6230  /* Create the credential. */
6231  switch (ret)
6232  {
6233  case 0:
6234  case -1:
6235  break;
6236  case 1:
6237  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6238  return gsad_message (credentials,
6239  "Internal error", __FUNCTION__, __LINE__,
6240  "An internal error occurred while creating a new credential. "
6241  "It is unclear whether the credential has been created or not. "
6242  "Diagnostics: Failure to send command to manager daemon.",
6243  "/omp?cmd=get_credentials", response_data);
6244  case 2:
6245  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6246  return gsad_message (credentials,
6247  "Internal error", __FUNCTION__, __LINE__,
6248  "An internal error occurred while creating a new credential. "
6249  "It is unclear whether the credential has been created or not. "
6250  "Diagnostics: Failure to receive response from manager daemon.",
6251  "/omp?cmd=get_credentials", response_data);
6252  default:
6253  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6254  return gsad_message (credentials,
6255  "Internal error", __FUNCTION__, __LINE__,
6256  "An internal error occurred while creating a new credential. "
6257  "It is unclear whether the credential has been created or not. "
6258  "Diagnostics: Internal Error.",
6259  "/omp?cmd=get_credentials", response_data);
6260  }
6261 
6262  if (entity_attribute (entity, "id"))
6263  params_add (params, "credential_id", entity_attribute (entity, "id"));
6264  html = response_from_entity (connection, credentials, params, entity,
6265  (no_redirect && strcmp (no_redirect, "0")),
6266  NULL, "get_credentials",
6267  NULL, "new_credential",
6268  "Create Credential",
6269  response_data);
6270  free_entity (entity);
6271  g_free (response);
6272  return html;
6273 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
gchar * message_invalid(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a filter, get all filters, XSL transform 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
Result of XSL transformation.

Definition at line 23837 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), param::valid, param::valid_utf8, and param::value.

23839 {
23840  gchar *html, *response;
23841  const char *no_redirect, *name, *comment, *term, *type;
23842  entity_t entity;
23843 
23844  no_redirect = params_value (params, "no_redirect");
23845  name = params_value (params, "name");
23846  comment = params_value (params, "comment");
23847  term = params_value (params, "term");
23848  type = params_value (params, "optional_resource_type");
23849 
23850  CHECK_PARAM_INVALID (name, "Create Filter", "new_filter");
23851  CHECK_PARAM_INVALID (comment, "Create Filter", "new_filter");
23852  CHECK_PARAM_INVALID (term, "Create Filter", "new_filter");
23853  CHECK_PARAM_INVALID (type, "Create Filter", "new_filter");
23854 
23855  switch (ompf (connection, credentials,
23856  &response,
23857  &entity,
23858  response_data,
23859  "<create_filter>"
23860  "<name>%s</name>"
23861  "<comment>%s</comment>"
23862  "<term>%s</term>"
23863  "<type>%s</type>"
23864  "</create_filter>",
23865  name,
23866  comment,
23867  term,
23868  type))
23869  {
23870  case 0:
23871  case -1:
23872  break;
23873  case 1:
23874  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23875  return gsad_message (credentials,
23876  "Internal error", __FUNCTION__, __LINE__,
23877  "An internal error occurred while creating a new alert. "
23878  "No new alert was created. "
23879  "Diagnostics: Failure to send command to manager daemon.",
23880  "/omp?cmd=get_alerts", response_data);
23881  case 2:
23882  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23883  return gsad_message (credentials,
23884  "Internal error", __FUNCTION__, __LINE__,
23885  "An internal error occurred while creating a new alert. "
23886  "It is unclear whether the alert has been created or not. "
23887  "Diagnostics: Failure to receive response from manager daemon.",
23888  "/omp?cmd=get_alerts", response_data);
23889  default:
23890  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23891  return gsad_message (credentials,
23892  "Internal error", __FUNCTION__, __LINE__,
23893  "An internal error occurred while creating a new alert. "
23894  "It is unclear whether the alert has been created or not. "
23895  "Diagnostics: Internal Error.",
23896  "/omp?cmd=get_alerts", response_data);
23897  }
23898 
23899  if (omp_success (entity))
23900  {
23901  const char *filter_id;
23902 
23903  filter_id = entity_attribute (entity, "id");
23904  if (filter_id && strlen (filter_id))
23905  {
23906  param_t *param;
23907  param = params_add (params, "filt_id", filter_id);
23908  param->valid = 1;
23909  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
23910  }
23911  }
23912 
23913  if (entity_attribute (entity, "id"))
23914  params_add (params, "filter_id", entity_attribute (entity, "id"));
23915  html = response_from_entity (connection, credentials, params, entity,
23916  (no_redirect && strcmp (no_redirect, "0")),
23917  NULL, "get_filters",
23918  NULL, "new_filter",
23919  "Create Filter", response_data);
23920  free_entity (entity);
23921  g_free (response);
23922  return html;
23923 }
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int valid_utf8
Definition: gsad_base.h:153
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int valid
Definition: gsad_base.h:152
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a group, get all groups, XSL transform 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
Result of XSL transformation.

Definition at line 20278 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), and users.

20280 {
20281  gchar *html, *response, *command, *specials_element;
20282  const char *no_redirect, *name, *comment, *users, *grant_full;
20283  entity_t entity;
20284  GString *xml;
20285  int ret;
20286 
20287  no_redirect = params_value (params, "no_redirect");
20288  name = params_value (params, "name");
20289  comment = params_value (params, "comment");
20290  grant_full = params_value (params, "grant_full");
20291  users = params_value (params, "users");
20292 
20293  CHECK_PARAM_INVALID (name, "Create Group", "new_group");
20294  CHECK_PARAM_INVALID (comment, "Create Group", "new_group");
20295  CHECK_PARAM_INVALID (users, "Create Group", "new_group");
20296 
20297  /* Create the group. */
20298 
20299  xml = g_string_new ("");
20300 
20301  xml_string_append (xml,
20302  "<name>%s</name>"
20303  "<comment>%s</comment>"
20304  "<users>%s</users>",
20305  name,
20306  comment,
20307  users);
20308 
20309  if (grant_full)
20310  specials_element = g_strdup_printf ("<full/>");
20311  else
20312  specials_element = NULL;
20313 
20314  command = g_strdup_printf ("<create_group>"
20315  "%s"
20316  "<specials>"
20317  "%s"
20318  "</specials>"
20319  "</create_group>",
20320  xml->str,
20321  specials_element);
20322 
20323  g_string_free (xml, TRUE);
20324  g_free (specials_element);
20325 
20326  ret = omp (connection, credentials, &response, &entity, response_data,
20327  command);
20328  g_free (command);
20329  switch (ret)
20330  {
20331  case 0:
20332  case -1:
20333  break;
20334  case 1:
20335  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20336  return gsad_message (credentials,
20337  "Internal error", __FUNCTION__, __LINE__,
20338  "An internal error occurred while creating a new group. "
20339  "No new group was created. "
20340  "Diagnostics: Failure to send command to manager daemon.",
20341  "/omp?cmd=get_groups", response_data);
20342  case 2:
20343  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20344  return gsad_message (credentials,
20345  "Internal error", __FUNCTION__, __LINE__,
20346  "An internal error occurred while creating a new group. "
20347  "It is unclear whether the group has been created or not. "
20348  "Diagnostics: Failure to receive response from manager daemon.",
20349  "/omp?cmd=get_groups", response_data);
20350  default:
20351  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20352  return gsad_message (credentials,
20353  "Internal error", __FUNCTION__, __LINE__,
20354  "An internal error occurred while creating a new group. "
20355  "It is unclear whether the group has been created or not. "
20356  "Diagnostics: Internal Error.",
20357  "/omp?cmd=get_groups", response_data);
20358  }
20359 
20360  if (entity_attribute (entity, "id"))
20361  params_add (params, "group_id", entity_attribute (entity, "id"));
20362  html = response_from_entity (connection, credentials, params, entity,
20363  (no_redirect && strcmp (no_redirect, "0")),
20364  NULL, "get_groups",
20365  NULL, "new_group",
20366  "Create Group", response_data);
20367  free_entity (entity);
20368  g_free (response);
20369  return html;
20370 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
GPtrArray * users
User session data.
Definition: gsad.c:340
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_host_omp ( openvas_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
Result of XSL transformation.

Definition at line 26804 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_t, params_value(), param::valid, param::valid_utf8, and param::value.

26806 {
26807  int ret;
26808  gchar *html, *response;
26809  const char *no_redirect, *name, *comment;
26810  entity_t entity;
26811  GString *xml;
26812 
26813  no_redirect = params_value (params, "no_redirect");
26814 
26815  name = params_value (params, "name");
26816  CHECK_PARAM_INVALID (name, "Create Host", "new_host");
26817 
26818  comment = params_value (params, "comment");
26819  CHECK_PARAM_INVALID (comment, "Create Host", "new_host");
26820 
26821  /* Create the host. */
26822 
26823  xml = g_string_new ("");
26824 
26825  xml_string_append (xml,
26826  "<create_asset>"
26827  "<asset>"
26828  "<type>host</type>"
26829  "<name>%s</name>"
26830  "<comment>%s</comment>"
26831  "</asset>"
26832  "</create_asset>",
26833  name,
26834  comment);
26835 
26836  ret = omp (connection, credentials,
26837  &response,
26838  &entity,
26839  response_data,
26840  xml->str);
26841  g_string_free (xml, TRUE);
26842  switch (ret)
26843  {
26844  case 0:
26845  case -1:
26846  break;
26847  case 1:
26848  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26849  return gsad_message (credentials,
26850  "Internal error", __FUNCTION__, __LINE__,
26851  "An internal error occurred while creating a new host. "
26852  "No new host was created. "
26853  "Diagnostics: Failure to send command to manager daemon.",
26854  "/omp?cmd=get_assets", response_data);
26855  case 2:
26856  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26857  return gsad_message (credentials,
26858  "Internal error", __FUNCTION__, __LINE__,
26859  "An internal error occurred while creating a new host. "
26860  "It is unclear whether the host has been created or not. "
26861  "Diagnostics: Failure to receive response from manager daemon.",
26862  "/omp?cmd=get_assets", response_data);
26863  default:
26864  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26865  return gsad_message (credentials,
26866  "Internal error", __FUNCTION__, __LINE__,
26867  "An internal error occurred while creating a new host. "
26868  "It is unclear whether the host has been created or not. "
26869  "Diagnostics: Internal Error.",
26870  "/omp?cmd=get_assets", response_data);
26871  }
26872 
26873  if (entity_attribute (entity, "id"))
26874  params_add (params, "asset_id", entity_attribute (entity, "id"));
26875  html = response_from_entity (connection, credentials, params, entity,
26876  (no_redirect && strcmp (no_redirect, "0")),
26877  NULL, "get_assets",
26878  NULL, "new_host",
26879  "Create Host", response_data);
26880  free_entity (entity);
26881  g_free (response);
26882  return html;
26883 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a note, get report, XSL transform 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
Result of XSL transformation.

Definition at line 15465 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_original_value(), params_valid(), and params_value().

15467 {
15468  char *ret;
15469  gchar *response;
15470  const char *no_redirect, *oid, *severity, *port, *hosts;
15471  const char *text, *task_id, *note_result_id;
15472  /* For get_report. */
15473  const char *active, *days;
15474  entity_t entity;
15475 
15476  no_redirect = params_value (params, "no_redirect");
15477  oid = params_value (params, "oid");
15478  CHECK_PARAM_INVALID (oid, "Create Note", "new_note");
15479 
15480  if (params_valid (params, "severity"))
15481  severity = params_value (params, "severity");
15482  else if (params_given (params, "severity")
15483  && strcmp (params_original_value (params, "severity"), ""))
15484  severity = NULL;
15485  else
15486  severity = "";
15487  CHECK_PARAM_INVALID (severity, "Create Note", "new_note");
15488 
15489  port = params_value (params, "port");
15490  if (port == NULL)
15491  port = "";
15492  if (strcmp (port, "--") == 0)
15493  {
15494  int num = -1;
15495 
15496  port = params_value (params, "port_manual");
15497  if (port)
15498  num = atoi (port);
15499  if (num < 0 || num > 65535)
15500  port = NULL;
15501  }
15502  CHECK_PARAM_INVALID (port, "Create Note", "new_note");
15503 
15504  if (params_valid (params, "hosts"))
15505  {
15506  hosts = params_value (params, "hosts");
15507  if (strcmp (hosts, "--") == 0)
15508  {
15509  if (params_valid (params, "hosts_manual"))
15510  hosts = params_value (params, "hosts_manual");
15511  else if (params_given (params, "hosts_manual")
15512  && strcmp (params_original_value (params, "hosts_manual"),
15513  ""))
15514  hosts = NULL;
15515  else
15516  hosts = "";
15517  }
15518  }
15519  else if (strcmp (params_original_value (params, "hosts"), ""))
15520  hosts = NULL;
15521  else
15522  hosts = "";
15523  CHECK_PARAM_INVALID (hosts, "Create Note", "new_note");
15524 
15525  if (params_valid (params, "note_task_id"))
15526  {
15527  task_id = params_value (params, "note_task_id");
15528  if (task_id && (strcmp (task_id, "0") == 0))
15529  task_id = params_value (params, "note_task_uuid");
15530  }
15531  else if (params_given (params, "note_task_id")
15532  && strcmp (params_original_value (params, "note_task_id"), ""))
15533  task_id = NULL;
15534  else
15535  task_id = "";
15536 
15537  active = params_value (params, "active");
15538  CHECK_PARAM_INVALID (active, "Create Note", "new_note");
15539 
15540  text = params_value (params, "text");
15541  days = params_value (params, "days");
15542 
15543  note_result_id = params_value (params, "note_result_id");
15544  if (note_result_id && (strcmp (note_result_id, "0") == 0))
15545  note_result_id = params_value (params, "note_result_uuid");
15546 
15547  response = NULL;
15548  entity = NULL;
15549  switch (ompf (connection, credentials,
15550  &response,
15551  &entity,
15552  response_data,
15553  "<create_note>"
15554  "<active>%s</active>"
15555  "<nvt oid=\"%s\"/>"
15556  "<hosts>%s</hosts>"
15557  "<port>%s</port>"
15558  "<severity>%s</severity>"
15559  "<text>%s</text>"
15560  "<task id=\"%s\"/>"
15561  "<result id=\"%s\"/>"
15562  "</create_note>",
15563  strcmp (active, "1")
15564  ? active
15565  : (days ? days : "-1"),
15566  oid,
15567  hosts,
15568  port,
15569  severity,
15570  text ? text : "",
15571  task_id,
15572  note_result_id))
15573  {
15574  case 0:
15575  case -1:
15576  break;
15577  case 1:
15578  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15579  return gsad_message (credentials,
15580  "Internal error", __FUNCTION__, __LINE__,
15581  "An internal error occurred while creating a new note. "
15582  "No new note was created. "
15583  "Diagnostics: Failure to send command to manager daemon.",
15584  "/omp?cmd=get_notes", response_data);
15585  case 2:
15586  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15587  return gsad_message (credentials,
15588  "Internal error", __FUNCTION__, __LINE__,
15589  "An internal error occurred while creating a new note. "
15590  "It is unclear whether the note has been created or not. "
15591  "Diagnostics: Failure to receive response from manager daemon.",
15592  "/omp?cmd=get_notes", response_data);
15593  default:
15594  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15595  return gsad_message (credentials,
15596  "Internal error", __FUNCTION__, __LINE__,
15597  "An internal error occurred while creating a new note. "
15598  "It is unclear whether the note has been created or not. "
15599  "Diagnostics: Internal Error.",
15600  "/omp?cmd=get_notes", response_data);
15601  }
15602 
15603  if (entity_attribute (entity, "id"))
15604  params_add (params, "note_id", entity_attribute (entity, "id"));
15605  ret = response_from_entity (connection, credentials, params, entity,
15606  (no_redirect && strcmp (no_redirect, "0")),
15607  NULL, "get_notes",
15608  NULL, "new_note",
15609  "Create Note", response_data);
15610  free_entity (entity);
15611  g_free (response);
15612  return ret;
15613 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:745
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create an override, get report, XSL transform 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
Result of XSL transformation.

Definition at line 16148 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_original_value(), params_valid(), and params_value().

16151 {
16152  char *ret;
16153  gchar *response;
16154  const char *no_redirect;
16155  const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
16156  const char *text, *task_id, *override_result_id;
16157  /* For get_report. */
16158  const char *active, *days;
16159  entity_t entity;
16160 
16161  no_redirect = params_value (params, "no_redirect");
16162  oid = params_value (params, "oid");
16163  CHECK_PARAM_INVALID (oid, "Create Override", "new_override");
16164 
16165  if (params_valid (params, "severity"))
16166  severity = params_value (params, "severity");
16167  else if (params_given (params, "severity")
16168  && strcmp (params_original_value (params, "severity"), ""))
16169  severity = NULL;
16170  else
16171  severity = "";
16172  CHECK_PARAM_INVALID (severity, "Create Override", "new_override");
16173 
16174  custom_severity = params_value (params, "custom_severity");
16175  CHECK_PARAM_INVALID (custom_severity, "Create Override", "new_override");
16176 
16177  if (custom_severity != NULL && strcmp (custom_severity, "0"))
16178  {
16179  if (params_valid (params, "new_severity"))
16180  new_severity = params_value (params, "new_severity");
16181  else if (params_original_value (params, "new_severity") == NULL
16182  || strcmp (params_original_value (params, "new_severity"), ""))
16183  new_severity = NULL;
16184  else
16185  new_severity = "";
16186  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16187  }
16188  else
16189  {
16190  if (params_valid (params, "new_severity_from_list"))
16191  new_severity = params_value (params, "new_severity_from_list");
16192  else if (params_original_value (params, "new_severity_from_list") == NULL
16193  || strcmp (params_original_value (params,
16194  "new_severity_from_list"),
16195  ""))
16196  new_severity = NULL;
16197  else
16198  new_severity = "";
16199  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16200  }
16201 
16202  port = params_value (params, "port");
16203  if (port == NULL)
16204  port = "";
16205  if (strcmp (port, "--") == 0)
16206  {
16207  int num = -1;
16208 
16209  port = params_value (params, "port_manual");
16210  if (port)
16211  num = atoi (port);
16212  if (num < 0 || num > 65535)
16213  port = NULL;
16214  }
16215  CHECK_PARAM_INVALID (port, "Create Override", "new_override");
16216 
16217  if (params_valid (params, "hosts"))
16218  {
16219  hosts = params_value (params, "hosts");
16220  if (strcmp (hosts, "--") == 0)
16221  {
16222  if (params_valid (params, "hosts_manual"))
16223  hosts = params_value (params, "hosts_manual");
16224  else if (params_given (params, "hosts_manual")
16225  && strcmp (params_original_value (params, "hosts_manual"),
16226  ""))
16227  hosts = NULL;
16228  else
16229  hosts = "";
16230  }
16231  }
16232  else if (strcmp (params_original_value (params, "hosts"), ""))
16233  hosts = NULL;
16234  else
16235  hosts = "";
16236  CHECK_PARAM_INVALID (hosts, "Create Override", "new_override");
16237 
16238  if (params_valid (params, "override_task_id"))
16239  {
16240  task_id = params_value (params, "override_task_id");
16241  if (task_id && (strcmp (task_id, "0") == 0))
16242  task_id = params_value (params, "override_task_uuid");
16243  }
16244  else
16245  task_id = "";
16246 
16247  active = params_value (params, "active");
16248  CHECK_PARAM_INVALID (active, "Create Override", "new_override");
16249 
16250  text = params_value (params, "text");
16251  days = params_value (params, "days");
16252 
16253  override_result_id = params_value (params, "override_result_id");
16254  if (override_result_id && (strcmp (override_result_id, "0") == 0))
16255  override_result_id = params_value (params, "override_result_uuid");
16256 
16257  response = NULL;
16258  entity = NULL;
16259  switch (ompf (connection, credentials,
16260  &response,
16261  &entity,
16262  response_data,
16263  "<create_override>"
16264  "<active>%s</active>"
16265  "<nvt oid=\"%s\"/>"
16266  "<hosts>%s</hosts>"
16267  "<port>%s</port>"
16268  "<severity>%s</severity>"
16269  "<new_severity>%s</new_severity>"
16270  "<text>%s</text>"
16271  "<task id=\"%s\"/>"
16272  "<result id=\"%s\"/>"
16273  "</create_override>",
16274  strcmp (active, "1")
16275  ? active
16276  : (days ? days : "-1"),
16277  oid,
16278  hosts,
16279  port,
16280  severity,
16281  new_severity,
16282  text ? text : "",
16283  task_id,
16284  override_result_id))
16285  {
16286  case 0:
16287  case -1:
16288  break;
16289  case 1:
16290  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16291  return gsad_message (credentials,
16292  "Internal error", __FUNCTION__, __LINE__,
16293  "An internal error occurred while creating a new override. "
16294  "No new override was created. "
16295  "Diagnostics: Failure to send command to manager daemon.",
16296  "/omp?cmd=get_overrides", response_data);
16297  case 2:
16298  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16299  return gsad_message (credentials,
16300  "Internal error", __FUNCTION__, __LINE__,
16301  "An internal error occurred while creating a new override. "
16302  "It is unclear whether the override has been created or not. "
16303  "Diagnostics: Failure to receive response from manager daemon.",
16304  "/omp?cmd=get_overrides", response_data);
16305  default:
16306  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16307  return gsad_message (credentials,
16308  "Internal error", __FUNCTION__, __LINE__,
16309  "An internal error occurred while creating a new override. "
16310  "It is unclear whether the override has been created or not. "
16311  "Diagnostics: Internal Error.",
16312  "/omp?cmd=get_overrides", response_data);
16313  }
16314 
16315  if (entity_attribute (entity, "id"))
16316  params_add (params, "override_id", entity_attribute (entity, "id"));
16317  ret = response_from_entity (connection, credentials, params, entity,
16318  (no_redirect && strcmp (no_redirect, "0")),
16319  NULL, "get_overrides",
16320  NULL, "new_override",
16321  "Create Override", response_data);
16322  free_entity (entity);
16323  g_free (response);
16324  return ret;
16325 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:745
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a permission, get all permissions, XSL transform 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
Result of XSL transformation.

Definition at line 20856 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), and params_value().

20859 {
20860  int ret;
20861  gchar *html, *response;
20862  const char *no_redirect, *name, *comment, *resource_id, *resource_type;
20863  const char *subject_id, *subject_type, *subject_name;
20864  entity_t entity;
20865 
20866  gchar *subject_response;
20867  entity_t get_subject_entity = NULL;
20868  entity_t subject_entity;
20869 
20870  no_redirect = params_value (params, "no_redirect");
20871  name = params_value (params, "permission");
20872  comment = params_value (params, "comment");
20873  resource_id = params_value (params, "id_or_empty");
20874  resource_type = params_value (params, "optional_resource_type");
20875  subject_type = params_value (params, "subject_type");
20876  subject_name = params_value (params, "subject_name");
20877 
20878  CHECK_PARAM_INVALID (name, "Create Permission", "new_permission");
20879  CHECK_PARAM_INVALID (comment, "Create Permission", "new_permission");
20880  if (params_given (params, "id_or_empty"))
20881  CHECK_PARAM_INVALID (resource_id, "Create Permission", "new_permission");
20882  CHECK_PARAM_INVALID (subject_type, "Create Permission", "new_permission");
20883  if (params_given (params, "optional_resource_type"))
20884  CHECK_PARAM_INVALID (resource_type, "Create Permission", "new_permission");
20885 
20886  if (params_given (params, "subject_name"))
20887  {
20888  CHECK_PARAM_INVALID (subject_name,
20889  "Create Permission", "new_permission");
20890  subject_id = NULL;
20891  ret = ompf (connection, credentials,
20892  &subject_response,
20893  &get_subject_entity,
20894  response_data,
20895  "<get_%ss filter=\"rows=1 name=%s\">"
20896  "</get_%ss>",
20897  subject_type,
20898  subject_name,
20899  subject_type);
20900 
20901  switch (ret)
20902  {
20903  case 0:
20904  case -1:
20905  break;
20906  case 1:
20907  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20908  return gsad_message (credentials,
20909  "Internal error", __FUNCTION__, __LINE__,
20910  "An internal error occurred while getting"
20911  " the subject for a permission. "
20912  "The permission was not created. "
20913  "Diagnostics: Failure to send command"
20914  " to manager daemon.",
20915  "/omp?cmd=get_permissions", response_data);
20916  case 2:
20917  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20918  return gsad_message (credentials,
20919  "Internal error", __FUNCTION__, __LINE__,
20920  "An internal error occurred while getting"
20921  " the subject for a permission. "
20922  "The permission was not created. "
20923  "Diagnostics: Failure to receive response"
20924  " from manager daemon.",
20925  "/omp?cmd=get_permissions", response_data);
20926  default:
20927  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20928  return gsad_message (credentials,
20929  "Internal error", __FUNCTION__, __LINE__,
20930  "An internal error occurred while getting"
20931  " the subject for a permission. "
20932  "The permission was not created. "
20933  "Diagnostics: Internal Error.",
20934  "/omp?cmd=get_permissions", response_data);
20935  }
20936 
20937  subject_entity = entity_child (get_subject_entity, subject_type);
20938 
20939  if (subject_entity)
20940  subject_id = entity_attribute (subject_entity, "id");
20941 
20942  if (subject_id == NULL)
20943  {
20944  gchar *msg;
20945  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
20946  " operation=\"create_permission\">"
20947  "Could not find a %s with name '%s'."
20948  "</gsad_msg>",
20949  subject_type,
20950  subject_name ? subject_name : "");
20951  return next_page (connection, credentials, params, msg,
20952  response_data);
20953  }
20954  }
20955  else if (strcmp (subject_type, "user") == 0)
20956  subject_id = params_value (params, "permission_user_id");
20957  else if (strcmp (subject_type, "group") == 0)
20958  subject_id = params_value (params, "permission_group_id");
20959  else if (strcmp (subject_type, "role") == 0)
20960  subject_id = params_value (params, "permission_role_id");
20961  else
20962  subject_id = NULL;
20963  CHECK_PARAM_INVALID (subject_id, "Create Permission", "new_permission");
20964 
20965  /* Create the permission(s). */
20966 
20967  if (strcmp (name, "task_proxy") == 0)
20968  {
20969  response = NULL;
20970  entity = NULL;
20971  ret = ompf (connection, credentials,
20972  &response,
20973  &entity,
20974  response_data,
20975  "<commands>"
20976  "<create_permission>"
20977  "<name>get_tasks</name>"
20978  "<comment>%s</comment>"
20979  "<resource id=\"%s\"/>"
20980  "<subject id=\"%s\"><type>%s</type></subject>"
20981  "</create_permission>"
20982  "<create_permission>"
20983  "<name>modify_task</name>"
20984  "<comment>%s</comment>"
20985  "<resource id=\"%s\"/>"
20986  "<subject id=\"%s\"><type>%s</type></subject>"
20987  "</create_permission>"
20988  "<create_permission>"
20989  "<name>start_task</name>"
20990  "<comment>%s</comment>"
20991  "<resource id=\"%s\"/>"
20992  "<subject id=\"%s\"><type>%s</type></subject>"
20993  "</create_permission>"
20994  "<create_permission>"
20995  "<name>stop_task</name>"
20996  "<comment>%s</comment>"
20997  "<resource id=\"%s\"/>"
20998  "<subject id=\"%s\"><type>%s</type></subject>"
20999  "</create_permission>"
21000  "<create_permission>"
21001  "<name>resume_task</name>"
21002  "<comment>%s</comment>"
21003  "<resource id=\"%s\"/>"
21004  "<subject id=\"%s\"><type>%s</type></subject>"
21005  "</create_permission>"
21006  "</commands>",
21007  comment ? comment : "",
21008  resource_id ? resource_id : "",
21009  subject_id,
21010  subject_type,
21011  comment ? comment : "",
21012  resource_id ? resource_id : "",
21013  subject_id,
21014  subject_type,
21015  comment ? comment : "",
21016  resource_id ? resource_id : "",
21017  subject_id,
21018  subject_type,
21019  comment ? comment : "",
21020  resource_id ? resource_id : "",
21021  subject_id,
21022  subject_type,
21023  comment ? comment : "",
21024  resource_id ? resource_id : "",
21025  subject_id,
21026  subject_type);
21027 
21028  if (get_subject_entity)
21029  free_entity (get_subject_entity);
21030 
21031  switch (ret)
21032  {
21033  case 0:
21034  case -1:
21035  break;
21036  case 1:
21037  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21038  return gsad_message (credentials,
21039  "Internal error", __FUNCTION__, __LINE__,
21040  "An internal error occurred while creating a permission. "
21041  "The permission was not created. "
21042  "Diagnostics: Failure to send command to manager daemon.",
21043  "/omp?cmd=get_permissions", response_data);
21044  case 2:
21045  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21046  return gsad_message (credentials,
21047  "Internal error", __FUNCTION__, __LINE__,
21048  "An internal error occurred while creating a permission. "
21049  "It is unclear whether the permission has been created or not. "
21050  "Diagnostics: Failure to receive response from manager daemon.",
21051  "/omp?cmd=get_permissions", response_data);
21052  default:
21053  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21054  return gsad_message (credentials,
21055  "Internal error", __FUNCTION__, __LINE__,
21056  "An internal error occurred while creating a permission. "
21057  "It is unclear whether the permission has been created or not. "
21058  "Diagnostics: Internal Error.",
21059  "/omp?cmd=get_permissions", response_data);
21060  }
21061 
21062  if (entity_attribute (entity, "id"))
21063  params_add (params, "permission_id", entity_attribute (entity, "id"));
21064  html = response_from_entity (connection, credentials, params, entity,
21065  (no_redirect && strcmp (no_redirect, "0")),
21066  NULL, "get_permissions",
21067  NULL, "new_permission",
21068  "Create Permission", response_data);
21069  }
21070  else
21071  {
21072  response = NULL;
21073  entity = NULL;
21074  ret = ompf (connection, credentials,
21075  &response,
21076  &entity,
21077  response_data,
21078  "<create_permission>"
21079  "<name>%s</name>"
21080  "<comment>%s</comment>"
21081  "<resource id=\"%s\">"
21082  "<type>%s</type>"
21083  "</resource>"
21084  "<subject id=\"%s\"><type>%s</type></subject>"
21085  "</create_permission>",
21086  name,
21087  comment ? comment : "",
21088  resource_id ? resource_id : "",
21089  resource_type ? resource_type : "",
21090  subject_id,
21091  subject_type);
21092 
21093  if (get_subject_entity)
21094  free_entity (get_subject_entity);
21095 
21096  switch (ret)
21097  {
21098  case 0:
21099  case -1:
21100  break;
21101  case 1:
21102  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21103  return gsad_message (credentials,
21104  "Internal error", __FUNCTION__, __LINE__,
21105  "An internal error occurred while creating a permission. "
21106  "The permission was not created. "
21107  "Diagnostics: Failure to send command to manager daemon.",
21108  "/omp?cmd=get_permissions", response_data);
21109  case 2:
21110  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21111  return gsad_message (credentials,
21112  "Internal error", __FUNCTION__, __LINE__,
21113  "An internal error occurred while creating a permission. "
21114  "It is unclear whether the permission has been created or not. "
21115  "Diagnostics: Failure to receive response from manager daemon.",
21116  "/omp?cmd=get_permissions", response_data);
21117  default:
21118  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21119  return gsad_message (credentials,
21120  "Internal error", __FUNCTION__, __LINE__,
21121  "An internal error occurred while creating a permission. "
21122  "It is unclear whether the permission has been created or not. "
21123  "Diagnostics: Internal Error.",
21124  "/omp?cmd=get_permissions", response_data);
21125  }
21126 
21127  if (entity_attribute (entity, "id"))
21128  params_add (params, "permission_id", entity_attribute (entity, "id"));
21129  html = response_from_entity (connection, credentials, params, entity,
21130  (no_redirect && strcmp (no_redirect, "0")),
21131  NULL, "get_permissions",
21132  NULL, "new_permission",
21133  "Create Permission", response_data);
21134  }
21135  free_entity (entity);
21136  g_free (response);
21137  return html;
21138 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_permissions_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create multiple permission, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 21507 of file gsad_omp.c.

References CHECK_OMPF_RET, CHECK_PARAM, gsad_message(), cmd_response_data_t::http_status_code, new_permission(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), cmd_response_data_t::redirect, and param::value.

21510 {
21511  int ret;
21512  gchar *html, *response, *summary_response, *next_url;
21513  int successes;
21514  const char *no_redirect, *permission, *comment, *resource_id, *resource_type;
21515  const char *subject_id, *subject_type, *subject_name;
21516  int include_related;
21517 
21518  entity_t entity;
21519 
21520  gchar *subject_response;
21521  entity_t get_subject_entity = NULL;
21522  entity_t subject_entity;
21523 
21524  no_redirect = params_value (params, "no_redirect");
21525  permission = params_value (params, "permission");
21526  comment = params_value (params, "comment");
21527  resource_id = params_value (params, "resource_id");
21528  resource_type = params_value (params, "resource_type");
21529  subject_type = params_value (params, "subject_type");
21530  subject_name = params_value (params, "subject_name");
21531 
21532  include_related = atoi (params_value (params, "include_related"));
21533  CHECK_PARAM (params_value (params, "include_related"),
21534  "Create Permission", new_permission);
21535 
21536  CHECK_PARAM (permission, "Create Permission", new_permission);
21537  CHECK_PARAM (comment, "Create Permission", new_permission);
21538  CHECK_PARAM (resource_id, "Create Permission", new_permission);
21539  CHECK_PARAM (subject_type, "Create Permission", new_permission);
21540  CHECK_PARAM (resource_type, "Create Permission", new_permission);
21541 
21542  if (params_given (params, "subject_name"))
21543  {
21544  CHECK_PARAM (subject_name, "Create Permission", new_permission);
21545  subject_id = NULL;
21546  ret = ompf (connection, credentials,
21547  &subject_response,
21548  &get_subject_entity,
21549  response_data,
21550  "<get_%ss filter=\"rows=1 name=%s\">"
21551  "</get_%ss>",
21552  subject_type,
21553  subject_name,
21554  subject_type);
21555 
21556  switch (ret)
21557  {
21558  case 0:
21559  case -1:
21560  break;
21561  case 1:
21562  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21563  return gsad_message (credentials,
21564  "Internal error", __FUNCTION__, __LINE__,
21565  "An internal error occurred while getting"
21566  " the subject for a permission. "
21567  "The permission was not created. "
21568  "Diagnostics: Failure to send command"
21569  " to manager daemon.",
21570  "/omp?cmd=get_permissions", response_data);
21571  case 2:
21572  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21573  return gsad_message (credentials,
21574  "Internal error", __FUNCTION__, __LINE__,
21575  "An internal error occurred while getting"
21576  " the subject for a permission. "
21577  "The permission was not created. "
21578  "Diagnostics: Failure to receive response"
21579  " from manager daemon.",
21580  "/omp?cmd=get_permissions", response_data);
21581  default:
21582  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21583  return gsad_message (credentials,
21584  "Internal error", __FUNCTION__, __LINE__,
21585  "An internal error occurred while getting"
21586  " the subject for a permission. "
21587  "The permission was not created. "
21588  "Diagnostics: Internal Error.",
21589  "/omp?cmd=get_permissions", response_data);
21590  }
21591 
21592  subject_entity = entity_child (get_subject_entity, subject_type);
21593 
21594  if (subject_entity)
21595  subject_id = entity_attribute (subject_entity, "id");
21596 
21597  if (subject_id == NULL)
21598  {
21599  gchar *msg;
21600  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
21601  " operation=\"create_permission\">"
21602  "Could not find a %s with name '%s'."
21603  "</gsad_msg>",
21604  subject_type,
21605  subject_name ? subject_name : "");
21606  return next_page (connection, credentials, params, msg,
21607  response_data);
21608  }
21609  }
21610  else if (strcmp (subject_type, "user") == 0)
21611  subject_id = params_value (params, "permission_user_id");
21612  else if (strcmp (subject_type, "group") == 0)
21613  subject_id = params_value (params, "permission_group_id");
21614  else if (strcmp (subject_type, "role") == 0)
21615  subject_id = params_value (params, "permission_role_id");
21616  else
21617  subject_id = NULL;
21618  CHECK_PARAM (subject_id, "Create Permission", new_permission);
21619 
21620  successes = 0;
21621 
21622  /* Create the permission(s). */
21623 
21624  // Main resource permissions
21625  if (include_related != 2)
21626  {
21627  if (strcmp (permission, "read") == 0
21628  || strcmp (permission, "proxy") == 0)
21629  {
21630  response = NULL;
21631  entity = NULL;
21632  ret = ompf (connection, credentials,
21633  &response,
21634  &entity,
21635  response_data,
21636  "<create_permission>"
21637  "<name>get_%ss</name>"
21638  "<comment>%s</comment>"
21639  "<resource id=\"%s\">"
21640  "</resource>"
21641  "<subject id=\"%s\"><type>%s</type></subject>"
21642  "</create_permission>",
21643  resource_type,
21644  comment ? comment : "",
21645  resource_id,
21646  subject_id,
21647  subject_type);
21648 
21650  }
21651 
21652  if ((strcmp (permission, "proxy") == 0)
21653  && strcmp (resource_type, "result")
21654  && strcmp (resource_type, "report"))
21655  {
21656  response = NULL;
21657  entity = NULL;
21658  ret = ompf (connection, credentials,
21659  &response,
21660  &entity,
21661  response_data,
21662  "<create_permission>"
21663  "<name>modify_%s</name>"
21664  "<comment>%s</comment>"
21665  "<resource id=\"%s\">"
21666  "</resource>"
21667  "<subject id=\"%s\"><type>%s</type></subject>"
21668  "</create_permission>",
21669  resource_type,
21670  comment ? comment : "",
21671  resource_id,
21672  subject_id,
21673  subject_type);
21674 
21676 
21677  if (strcmp (resource_type, "task") == 0)
21678  {
21679  response = NULL;
21680  entity = NULL;
21681  ret = ompf (connection, credentials,
21682  &response,
21683  &entity,
21684  response_data,
21685  "<create_permission>"
21686  "<name>start_%s</name>"
21687  "<comment>%s</comment>"
21688  "<resource id=\"%s\">"
21689  "</resource>"
21690  "<subject id=\"%s\"><type>%s</type></subject>"
21691  "</create_permission>",
21692  resource_type,
21693  comment ? comment : "",
21694  resource_id,
21695  subject_id,
21696  subject_type);
21697 
21699 
21700  response = NULL;
21701  entity = NULL;
21702  ret = ompf (connection, credentials,
21703  &response,
21704  &entity,
21705  response_data,
21706  "<create_permission>"
21707  "<name>stop_%s</name>"
21708  "<comment>%s</comment>"
21709  "<resource id=\"%s\">"
21710  "</resource>"
21711  "<subject id=\"%s\"><type>%s</type></subject>"
21712  "</create_permission>",
21713  resource_type,
21714  comment ? comment : "",
21715  resource_id,
21716  subject_id,
21717  subject_type);
21718 
21720 
21721  response = NULL;
21722  entity = NULL;
21723  ret = ompf (connection, credentials,
21724  &response,
21725  &entity,
21726  response_data,
21727  "<create_permission>"
21728  "<name>resume_%s</name>"
21729  "<comment>%s</comment>"
21730  "<resource id=\"%s\">"
21731  "</resource>"
21732  "<subject id=\"%s\"><type>%s</type></subject>"
21733  "</create_permission>",
21734  resource_type,
21735  comment ? comment : "",
21736  resource_id,
21737  subject_id,
21738  subject_type);
21739 
21741  }
21742 
21743  if (strcmp (resource_type, "alert") == 0)
21744  {
21745  response = NULL;
21746  entity = NULL;
21747  ret = ompf (connection, credentials,
21748  &response,
21749  &entity,
21750  response_data,
21751  "<create_permission>"
21752  "<name>test_%s</name>"
21753  "<comment>%s</comment>"
21754  "<resource id=\"%s\">"
21755  "</resource>"
21756  "<subject id=\"%s\"><type>%s</type></subject>"
21757  "</create_permission>",
21758  resource_type,
21759  comment ? comment : "",
21760  resource_id,
21761  subject_id,
21762  subject_type);
21763 
21765  }
21766 
21767  if (strcmp (resource_type, "agent") == 0
21768  || strcmp (resource_type, "report_format") == 0
21769  || strcmp (resource_type, "scanner") == 0)
21770  {
21771  response = NULL;
21772  entity = NULL;
21773  ret = ompf (connection, credentials,
21774  &response,
21775  &entity,
21776  response_data,
21777  "<create_permission>"
21778  "<name>verify_%s</name>"
21779  "<comment>%s</comment>"
21780  "<resource id=\"%s\">"
21781  "</resource>"
21782  "<subject id=\"%s\"><type>%s</type></subject>"
21783  "</create_permission>",
21784  resource_type,
21785  comment ? comment : "",
21786  resource_id,
21787  subject_id,
21788  subject_type);
21789 
21791  }
21792  }
21793  }
21794 
21795  // Related permissions
21796  if (include_related)
21797  {
21798  params_t *related;
21799  related = params_values (params, "related:");
21800  if (related)
21801  {
21802  params_iterator_t iter;
21803  char *name;
21804  param_t *param;
21805 
21806  params_iterator_init (&iter, related);
21807  while (params_iterator_next (&iter, &name, &param))
21808  {
21809  char *related_id = name;
21810  char *related_type = param->value;
21811 
21812  if (strcmp (permission, "read") == 0
21813  || strcmp (permission, "proxy") == 0)
21814  {
21815  response = NULL;
21816  entity = NULL;
21817  ret = ompf (connection, credentials,
21818  &response,
21819  &entity,
21820  response_data,
21821  "<create_permission>"
21822  "<name>get_%ss</name>"
21823  "<comment>%s</comment>"
21824  "<resource id=\"%s\">"
21825  "</resource>"
21826  "<subject id=\"%s\"><type>%s</type></subject>"
21827  "</create_permission>",
21828  related_type,
21829  comment ? comment : "",
21830  related_id,
21831  subject_id,
21832  subject_type);
21833 
21835  }
21836 
21837  if ((strcmp (permission, "proxy") == 0)
21838  && strcmp (related_type, "result")
21839  && strcmp (related_type, "report"))
21840  {
21841  response = NULL;
21842  entity = NULL;
21843  ret = ompf (connection, credentials,
21844  &response,
21845  &entity,
21846  response_data,
21847  "<create_permission>"
21848  "<name>modify_%s</name>"
21849  "<comment>%s</comment>"
21850  "<resource id=\"%s\">"
21851  "</resource>"
21852  "<subject id=\"%s\"><type>%s</type></subject>"
21853  "</create_permission>",
21854  related_type,
21855  comment ? comment : "",
21856  related_id,
21857  subject_id,
21858  subject_type);
21859 
21861 
21862  if (strcmp (related_type, "task") == 0)
21863  {
21864  response = NULL;
21865  entity = NULL;
21866  ret = ompf (connection, credentials,
21867  &response,
21868  &entity,
21869  response_data,
21870  "<create_permission>"
21871  "<name>start_%s</name>"
21872  "<comment>%s</comment>"
21873  "<resource id=\"%s\">"
21874  "</resource>"
21875  "<subject id=\"%s\"><type>%s</type></subject>"
21876  "</create_permission>",
21877  related_type,
21878  comment ? comment : "",
21879  related_id,
21880  subject_id,
21881  subject_type);
21882 
21884 
21885  response = NULL;
21886  entity = NULL;
21887  ret = ompf (connection, credentials,
21888  &response,
21889  &entity,
21890  response_data,
21891  "<create_permission>"
21892  "<name>stop_%s</name>"
21893  "<comment>%s</comment>"
21894  "<resource id=\"%s\">"
21895  "</resource>"
21896  "<subject id=\"%s\"><type>%s</type></subject>"
21897  "</create_permission>",
21898  related_type,
21899  comment ? comment : "",
21900  related_id,
21901  subject_id,
21902  subject_type);
21903 
21905 
21906  response = NULL;
21907  entity = NULL;
21908  ret = ompf (connection, credentials,
21909  &response,
21910  &entity,
21911  response_data,
21912  "<create_permission>"
21913  "<name>resume_%s</name>"
21914  "<comment>%s</comment>"
21915  "<resource id=\"%s\">"
21916  "</resource>"
21917  "<subject id=\"%s\"><type>%s</type></subject>"
21918  "</create_permission>",
21919  related_type,
21920  comment ? comment : "",
21921  related_id,
21922  subject_id,
21923  subject_type);
21924 
21926  }
21927 
21928  if (strcmp (related_type, "alert") == 0)
21929  {
21930  response = NULL;
21931  entity = NULL;
21932  ret = ompf (connection, credentials,
21933  &response,
21934  &entity,
21935  response_data,
21936  "<create_permission>"
21937  "<name>test_%s</name>"
21938  "<comment>%s</comment>"
21939  "<resource id=\"%s\">"
21940  "</resource>"
21941  "<subject id=\"%s\"><type>%s</type></subject>"
21942  "</create_permission>",
21943  related_type,
21944  comment ? comment : "",
21945  related_id,
21946  subject_id,
21947  subject_type);
21948 
21950  }
21951 
21952  if (strcmp (related_type, "agent") == 0
21953  || strcmp (related_type, "report_format") == 0
21954  || strcmp (related_type, "scanner") == 0)
21955  {
21956  response = NULL;
21957  entity = NULL;
21958  ret = ompf (connection, credentials,
21959  &response,
21960  &entity,
21961  response_data,
21962  "<create_permission>"
21963  "<name>verify_%s</name>"
21964  "<comment>%s</comment>"
21965  "<resource id=\"%s\">"
21966  "</resource>"
21967  "<subject id=\"%s\"><type>%s</type></subject>"
21968  "</create_permission>",
21969  related_type,
21970  comment ? comment : "",
21971  related_id,
21972  subject_id,
21973  subject_type);
21974 
21976  }
21977  }
21978  }
21979  }
21980  }
21981 
21982  if (get_subject_entity)
21983  free_entity (get_subject_entity);
21984 
21985  summary_response = g_strdup_printf("Successfully created %i permissions",
21986  successes);
21987 
21988  next_url = next_page_url (credentials, params,
21989  NULL, "new_permissions",
21990  "Create Permissions",
21991  G_STRINGIFY (MHD_HTTP_CREATED),
21992  summary_response);
21993 
21994  if (no_redirect)
21995  {
21996  html = action_result_page (connection, credentials, params, response_data,
21997  "Create Permissions",
21998  G_STRINGIFY (MHD_HTTP_CREATED),
21999  summary_response,
22000  NULL,
22001  next_url);
22002  g_free (next_url);
22003  }
22004  else
22005  {
22006  html = NULL;
22007  response_data->redirect = next_url;
22008  }
22009  return html;
22010 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define CHECK_OMPF_RET
Definition: gsad_omp.c:21140
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
#define params_iterator_init
Definition: gsad_base.h:189
char * new_permission(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
Definition: gsad_omp.c:20675
#define params_iterator_t
Definition: gsad_base.h:187
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1174

Here is the call graph for this function:

char* create_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a port list, get all port lists, XSL transform 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
Result of XSL transformation.

Definition at line 22447 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_t, and params_value().

22450 {
22451  gchar *html, *response;
22452  const char *no_redirect, *name, *comment, *port_range, *from_file;
22453  entity_t entity;
22454 
22455  no_redirect = params_value (params, "no_redirect");
22456  name = params_value (params, "name");
22457  comment = params_value (params, "comment");
22458  port_range = params_value (params, "port_range");
22459  from_file = params_value (params, "from_file");
22460 
22461  CHECK_PARAM_INVALID (name, "Create Port List", "new_port_list");
22462  CHECK_PARAM_INVALID (comment, "Create Port List", "new_port_list");
22463  CHECK_PARAM_INVALID (port_range, "Create Port List", "new_port_list");
22464  CHECK_PARAM_INVALID (from_file, "Create Port List", "new_port_list");
22465 
22466  /* Create the port_list. */
22467 
22468  switch (ompf (connection, credentials,
22469  &response,
22470  &entity,
22471  response_data,
22472  "<create_port_list>"
22473  "<name>%s</name>"
22474  "<port_range>%s</port_range>"
22475  "<comment>%s</comment>"
22476  "</create_port_list>",
22477  name,
22478  strcmp (from_file, "0")
22479  ? params_value (params, "file")
22480  : port_range,
22481  comment ? comment : ""))
22482  {
22483  case 0:
22484  case -1:
22485  break;
22486  case 1:
22487  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22488  return gsad_message (credentials,
22489  "Internal error", __FUNCTION__, __LINE__,
22490  "An internal error occurred while creating a new port list. "
22491  "No new port list was created. "
22492  "Diagnostics: Failure to send command to manager daemon.",
22493  "/omp?cmd=get_port_lists", response_data);
22494  case 2:
22495  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22496  return gsad_message (credentials,
22497  "Internal error", __FUNCTION__, __LINE__,
22498  "An internal error occurred while creating a new port list. "
22499  "It is unclear whether the port list has been created or not. "
22500  "Diagnostics: Failure to receive response from manager daemon.",
22501  "/omp?cmd=get_port_lists", response_data);
22502  default:
22503  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22504  return gsad_message (credentials,
22505  "Internal error", __FUNCTION__, __LINE__,
22506  "An internal error occurred while creating a new port list. "
22507  "It is unclear whether the port list has been created or not. "
22508  "Diagnostics: Internal Error.",
22509  "/omp?cmd=get_port_lists", response_data);
22510  }
22511 
22512  if (entity_attribute (entity, "id"))
22513  params_add (params, "port_list_id", entity_attribute (entity, "id"));
22514  html = response_from_entity (connection, credentials, params, entity,
22515  (no_redirect && strcmp (no_redirect, "0")),
22516  NULL, "get_port_lists",
22517  NULL, "new_port_list",
22518  "Create Port List", response_data);
22519  free_entity (entity);
22520  g_free (response);
22521  return html;
22522 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_port_range_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Add a range to a port list, XSL transform 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
Result of XSL transformation.

Definition at line 22578 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

22581 {
22582  int ret;
22583  gchar *html, *response;
22584  const char *no_redirect, *port_list_id, *start, *end, *type;
22585  entity_t entity;
22586 
22587  no_redirect = params_value (params, "no_redirect");
22588  port_list_id = params_value (params, "port_list_id");
22589  start = params_value (params, "port_range_start");
22590  end = params_value (params, "port_range_end");
22591  type = params_value (params, "port_type");
22592 
22593  CHECK_PARAM_INVALID (port_list_id, "Create Port Range", "edit_port_list");
22594  CHECK_PARAM_INVALID (start, "Create Port Range", "edit_port_list");
22595  CHECK_PARAM_INVALID (end, "Create Port Range", "edit_port_list");
22596  CHECK_PARAM_INVALID (type, "Create Port Range", "edit_port_list");
22597 
22598  /* Create the port range. */
22599 
22600  response = NULL;
22601  entity = NULL;
22602  ret = ompf (connection, credentials,
22603  &response,
22604  &entity,
22605  response_data,
22606  "<create_port_range>"
22607  "<port_list id=\"%s\"/>"
22608  "<start>%s</start>"
22609  "<end>%s</end>"
22610  "<type>%s</type>"
22611  "</create_port_range>",
22612  port_list_id,
22613  start,
22614  end,
22615  type);
22616 
22617  switch (ret)
22618  {
22619  case 0:
22620  case -1:
22621  break;
22622  case 1:
22623  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22624  return gsad_message (credentials,
22625  "Internal error", __FUNCTION__, __LINE__,
22626  "An internal error occurred while creating a Port Range. "
22627  "The Port Range was not created. "
22628  "Diagnostics: Failure to send command to manager daemon.",
22629  "/omp?cmd=get_port_lists", response_data);
22630  case 2:
22631  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22632  return gsad_message (credentials,
22633  "Internal error", __FUNCTION__, __LINE__,
22634  "An internal error occurred while creating a Port Range. "
22635  "It is unclear whether the Port Range has been created or not. "
22636  "Diagnostics: Failure to receive response from manager daemon.",
22637  "/omp?cmd=get_port_lists", response_data);
22638  default:
22639  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22640  return gsad_message (credentials,
22641  "Internal error", __FUNCTION__, __LINE__,
22642  "An internal error occurred while creating a Port Range. "
22643  "It is unclear whether the Port Range has been created or not. "
22644  "Diagnostics: Internal Error.",
22645  "/omp?cmd=get_port_lists", response_data);
22646  }
22647 
22648  html = response_from_entity (connection, credentials, params, entity,
22649  (no_redirect && strcmp (no_redirect, "0")),
22650  NULL, "edit_port_list",
22651  NULL, "edit_port_list",
22652  "Create Port Range", response_data);
22653  free_entity (entity);
22654  g_free (response);
22655  return html;
22656 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a report, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 3854 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, message_invalid(), params_given(), and params_value().

Referenced by import_report_omp().

3857 {
3858  entity_t entity;
3859  int ret;
3860  gchar *command, *html, *response;
3861  const char *no_redirect, *cmd, *task_id, *name, *comment, *xml_file;
3862  const char *in_assets;
3863 
3864  no_redirect = params_value (params, "no_redirect");
3865  task_id = params_value (params, "task_id");
3866  xml_file = params_value (params, "xml_file");
3867  name = params_value (params, "name");
3868  comment = params_value (params, "comment");
3869  in_assets = params_value (params, "in_assets");
3870 
3871  if (task_id == NULL)
3872  {
3873  CHECK_PARAM_INVALID (name, "Create Report", "new_container_task");
3874  CHECK_PARAM_INVALID (comment, "Create Report", "new_container_task");
3875  }
3876  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3877 
3878  if (params_given (params, "in_assets"))
3879  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3880 
3881  if (strlen (xml_file) == 0)
3882  {
3883  if (task_id)
3884  return message_invalid (connection, credentials, params, response_data,
3885  "Report required",
3886  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
3887  "Create Report", "new_container_task");
3888 
3889  /* Create only the container task. */
3890 
3891  command = g_markup_printf_escaped ("<create_task>"
3892  "<target id=\"0\"/>"
3893  "<name>%s</name>"
3894  "<comment>%s</comment>"
3895  "</create_task>",
3896  name,
3897  comment);
3898  }
3899  else
3900  {
3901  gchar **xml_file_array, *xml_file_escaped;
3902 
3903  xml_file_array = g_strsplit (xml_file, "%", -1);
3904  if (xml_file_array != NULL && xml_file_array[0] != NULL)
3905  xml_file_escaped = g_strjoinv ("%%", xml_file_array);
3906  else
3907  xml_file_escaped = g_strdup (xml_file);
3908  g_strfreev (xml_file_array);
3909 
3910  if (task_id)
3911  command = g_strdup_printf ("<create_report>"
3912  "<in_assets>%s</in_assets>"
3913  "<task id=\"%s\"/>"
3914  "%s"
3915  "</create_report>",
3916  in_assets ? in_assets : "0",
3917  task_id ? task_id : "0",
3918  xml_file_escaped ? xml_file_escaped : "");
3919  else
3920  {
3921  gchar *name_escaped, *comment_escaped;
3922  name_escaped = name ? g_markup_escape_text (name, -1)
3923  : NULL;
3924  comment_escaped = comment ? g_markup_escape_text (comment, -1)
3925  : NULL;
3926  command = g_strdup_printf ("<create_report>"
3927  "<in_assets>%s</in_assets>"
3928  "<task>"
3929  "<name>%s</name>"
3930  "<comment>%s</comment>"
3931  "</task>"
3932  "%s"
3933  "</create_report>",
3934  in_assets ? in_assets : "",
3935  name_escaped,
3936  comment_escaped,
3937  xml_file_escaped);
3938  g_free (name_escaped);
3939  g_free (comment_escaped);
3940  }
3941  g_free (xml_file_escaped);
3942  }
3943 
3944  ret = omp (connection, credentials,
3945  &response,
3946  &entity,
3947  response_data,
3948  command);
3949  g_free (command);
3950 
3951  switch (ret)
3952  {
3953  case 0:
3954  break;
3955  case -1:
3956  /* 'omp' set response. */
3957  return response;
3958  case 1:
3959  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3960  return gsad_message (credentials,
3961  "Internal error", __FUNCTION__, __LINE__,
3962  "An internal error occurred while creating a new report. "
3963  "No new report was created. "
3964  "Diagnostics: Failure to send command to manager daemon.",
3965  "/omp?cmd=get_tasks", response_data);
3966  case 2:
3967  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3968  return gsad_message (credentials,
3969  "Internal error", __FUNCTION__, __LINE__,
3970  "An internal error occurred while creating a new report. "
3971  "It is unclear whether the report has been created or not. "
3972  "Diagnostics: Failure to receive response from manager daemon.",
3973  "/omp?cmd=get_tasks", response_data);
3974  default:
3975  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3976  return gsad_message (credentials,
3977  "Internal error", __FUNCTION__, __LINE__,
3978  "An internal error occurred while creating a new report. "
3979  "It is unclear whether the report has been created or not. "
3980  "Diagnostics: Internal Error.",
3981  "/omp?cmd=get_tasks", response_data);
3982  }
3983 
3984  cmd = params_value (params, "cmd");
3985  html = response_from_entity (connection, credentials, params, entity,
3986  (no_redirect && strcmp (no_redirect, "0")),
3987  NULL, "get_tasks",
3988  NULL,
3989  (cmd && strcmp (cmd, "import_report"))
3990  ? "new_container_task" : "upload_report",
3991  "Import Report", response_data);
3992  free_entity (entity);
3993  g_free (response);
3994  return html;
3995 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
gchar * message_invalid(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

Here is the caller graph for this function:

char* create_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a role, get all roles, XSL transform 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
Result of XSL transformation.

Definition at line 23104 of file gsad_omp.c.

References CHECK_PARAM_INVALID, command_enabled(), edit_resource(), gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_t, params_value(), credentials_t::username, and users.

23106 {
23107  char *ret;
23108  gchar *response;
23109  const char *no_redirect, *name, *comment, *users;
23110  entity_t entity;
23111 
23112  no_redirect = params_value (params, "no_redirect");
23113  name = params_value (params, "name");
23114  comment = params_value (params, "comment");
23115  users = params_value (params, "users");
23116 
23117  CHECK_PARAM_INVALID (name, "Create Role", "new_role");
23118  CHECK_PARAM_INVALID (comment, "Create Role", "new_role");
23119  CHECK_PARAM_INVALID (users, "Create Role", "new_role");
23120 
23121  response = NULL;
23122  entity = NULL;
23123  switch (ompf (connection, credentials,
23124  &response,
23125  &entity,
23126  response_data,
23127  "<create_role>"
23128  "<name>%s</name>"
23129  "<comment>%s</comment>"
23130  "<users>%s</users>"
23131  "</create_role>",
23132  name,
23133  comment,
23134  users))
23135  {
23136  case 0:
23137  case -1:
23138  break;
23139  case 1:
23140  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23141  return gsad_message (credentials,
23142  "Internal error", __FUNCTION__, __LINE__,
23143  "An internal error occurred while creating a new role. "
23144  "No new role was created. "
23145  "Diagnostics: Failure to send command to manager daemon.",
23146  "/omp?cmd=get_targets", response_data);
23147  case 2:
23148  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23149  return gsad_message (credentials,
23150  "Internal error", __FUNCTION__, __LINE__,
23151  "An internal error occurred while creating a new role. "
23152  "It is unclear whether the role has been created or not. "
23153  "Diagnostics: Failure to receive response from manager daemon.",
23154  "/omp?cmd=get_roles", response_data);
23155  default:
23156  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23157  return gsad_message (credentials,
23158  "Internal error", __FUNCTION__, __LINE__,
23159  "An internal error occurred while creating a new role. "
23160  "It is unclear whether the role has been created or not. "
23161  "Diagnostics: Internal Error.",
23162  "/omp?cmd=get_roles", response_data);
23163  }
23164 
23165  if (entity_attribute (entity, "id"))
23166  params_add (params, "role_id", entity_attribute (entity, "id"));
23167  ret = response_from_entity (connection, credentials, params, entity,
23168  (no_redirect && strcmp (no_redirect, "0")),
23169  NULL, "get_roles",
23170  NULL, "new_role",
23171  "Create Role", response_data);
23172  free_entity (entity);
23173  g_free (response);
23174  return ret;
23175 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
GPtrArray * users
User session data.
Definition: gsad.c:340
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a scanner, get all scanners, XSL transform 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
Result of XSL transformation.

Definition at line 16888 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), and params_value().

16891 {
16892  int ret;
16893  char *html;
16894  gchar *response = NULL;
16895  const char *no_redirect;
16896  const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
16897  entity_t entity = NULL;
16898 
16899  no_redirect = params_value (params, "no_redirect");
16900  name = params_value (params, "name");
16901  comment = params_value (params, "comment");
16902  host = params_value (params, "scanner_host");
16903  port = params_value (params, "port");
16904  type = params_value (params, "scanner_type");
16905  ca_pub = params_value (params, "ca_pub");
16906  credential_id = params_value (params, "credential_id");
16907  CHECK_PARAM_INVALID (name, "Create Scanner", "new_scanner");
16908  CHECK_PARAM_INVALID (comment, "Create Scanner", "new_scanner");
16909  CHECK_PARAM_INVALID (host, "Create Scanner", "new_scanner");
16910  CHECK_PARAM_INVALID (port, "Create Scanner", "new_scanner");
16911  CHECK_PARAM_INVALID (type, "Create Scanner", "new_scanner");
16912  if (params_given (params, "ca_pub"))
16913  CHECK_PARAM_INVALID (ca_pub, "Create Scanner", "new_scanner");
16914  CHECK_PARAM_INVALID (credential_id, "Create Scanner", "new_scanner");
16915 
16916  if (ca_pub)
16917  ret = ompf (connection, credentials, &response, &entity, response_data,
16918  "<create_scanner>"
16919  "<name>%s</name><comment>%s</comment>"
16920  "<host>%s</host><port>%s</port><type>%s</type>"
16921  "<ca_pub>%s</ca_pub>"
16922  "<credential id=\"%s\"/>"
16923  "</create_scanner>",
16924  name, comment, host, port, type, ca_pub, credential_id);
16925  else
16926  ret = ompf (connection, credentials, &response, &entity, response_data,
16927  "<create_scanner>"
16928  "<name>%s</name><comment>%s</comment>"
16929  "<host>%s</host><port>%s</port><type>%s</type>"
16930  "<credential id=\"%s\"/>"
16931  "</create_scanner>",
16932  name, comment, host, port, type, credential_id);
16933  switch (ret)
16934  {
16935  case 0:
16936  case -1:
16937  break;
16938  case 1:
16939  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16940  return gsad_message
16941  (credentials, "Internal error", __FUNCTION__, __LINE__,
16942  "An internal error occurred while creating a new scanner. "
16943  "No new scanner was created. "
16944  "Diagnostics: Failure to send command to manager daemon.",
16945  "/omp?cmd=get_scanners", response_data);
16946  case 2:
16947  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16948  return gsad_message
16949  (credentials, "Internal error", __FUNCTION__, __LINE__,
16950  "An internal error occurred while creating a new scanner. "
16951  "It is unclear whether the scanner has been created or not. "
16952  "Diagnostics: Failure to receive response from manager daemon.",
16953  "/omp?cmd=get_scanners", response_data);
16954  default:
16955  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16956  return gsad_message
16957  (credentials, "Internal error", __FUNCTION__, __LINE__,
16958  "An internal error occurred while creating a new scanner. "
16959  "It is unclear whether the scanner has been created or not. "
16960  "Diagnostics: Internal Error.",
16961  "/omp?cmd=get_scanners", response_data);
16962  }
16963 
16964  if (entity_attribute (entity, "id"))
16965  params_add (params, "scanner_id", entity_attribute (entity, "id"));
16966  html = response_from_entity (connection, credentials, params, entity,
16967  (no_redirect && strcmp (no_redirect, "0")),
16968  NULL, "get_scanners",
16969  NULL, "new_scanner",
16970  "Create Scanner", response_data);
16971  free_entity (entity);
16972  g_free (response);
16973  return html;
16974 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a schedule, get all schedules, XSL transform 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
Result of XSL transformation.

Definition at line 17425 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

17428 {
17429  char *ret;
17430  gchar *response;
17431  const char *no_redirect;
17432  const char *name, *comment, *hour, *minute, *day_of_month, *month, *year;
17433  const char *period, *period_unit, *duration, *duration_unit, *timezone;
17434  entity_t entity;
17435 
17436  no_redirect = params_value (params, "no_redirect");
17437  name = params_value (params, "name");
17438  comment = params_value (params, "comment");
17439  hour = params_value (params, "hour");
17440  minute = params_value (params, "minute");
17441  day_of_month = params_value (params, "day_of_month");
17442  duration = params_value (params, "duration");
17443  duration_unit = params_value (params, "duration_unit");
17444  month = params_value (params, "month");
17445  period = params_value (params, "period");
17446  period_unit = params_value (params, "period_unit");
17447  year = params_value (params, "year");
17448  timezone = params_value (params, "timezone");
17449 
17450  CHECK_PARAM_INVALID (name, "Create Schedule", "new_schedule");
17451  CHECK_PARAM_INVALID (comment, "Create Schedule", "new_schedule");
17452  CHECK_PARAM_INVALID (hour, "Create Schedule", "new_schedule");
17453  CHECK_PARAM_INVALID (minute, "Create Schedule", "new_schedule");
17454  CHECK_PARAM_INVALID (day_of_month, "Create Schedule", "new_schedule");
17455  CHECK_PARAM_INVALID (duration, "Create Schedule", "new_schedule");
17456  CHECK_PARAM_INVALID (duration_unit, "Create Schedule", "new_schedule");
17457  CHECK_PARAM_INVALID (month, "Create Schedule", "new_schedule");
17458  CHECK_PARAM_INVALID (period, "Create Schedule", "new_schedule");
17459  CHECK_PARAM_INVALID (period_unit, "period_unit", "new_schedule");
17460  CHECK_PARAM_INVALID (year, "Create Schedule", "new_schedule");
17461  CHECK_PARAM_INVALID (timezone, "Create Schedule", "new_schedule");
17462 
17463  response = NULL;
17464  entity = NULL;
17465  switch (ompf (connection, credentials,
17466  &response,
17467  &entity,
17468  response_data,
17469  "<create_schedule>"
17470  "<name>%s</name>"
17471  "<comment>%s</comment>"
17472  "<first_time>"
17473  "<hour>%s</hour>"
17474  "<minute>%s</minute>"
17475  "<day_of_month>%s</day_of_month>"
17476  "<month>%s</month>"
17477  "<year>%s</year>"
17478  "</first_time>"
17479  "<period>"
17480  "<unit>%s</unit>"
17481  "%s"
17482  "</period>"
17483  "<duration>"
17484  "<unit>%s</unit>"
17485  "%s"
17486  "</duration>"
17487  "<timezone>%s</timezone>"
17488  "</create_schedule>",
17489  name,
17490  comment,
17491  hour,
17492  minute,
17493  day_of_month,
17494  month,
17495  year,
17496  (strcmp (period_unit, "")
17497  ? period_unit
17498  : "second"),
17499  period,
17500  (strcmp (duration_unit, "")
17501  ? duration_unit
17502  : "second"),
17503  duration,
17504  timezone))
17505  {
17506  case 0:
17507  case -1:
17508  break;
17509  case 1:
17510  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17511  return gsad_message (credentials,
17512  "Internal error", __FUNCTION__, __LINE__,
17513  "An internal error occurred while creating a new schedule. "
17514  "No new schedule was created. "
17515  "Diagnostics: Failure to send command to manager daemon.",
17516  "/omp?cmd=get_schedules", response_data);
17517  case 2:
17518  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17519  return gsad_message (credentials,
17520  "Internal error", __FUNCTION__, __LINE__,
17521  "An internal error occurred while creating a new schedule. "
17522  "It is unclear whether the schedule has been created or not. "
17523  "Diagnostics: Failure to receive response from manager daemon.",
17524  "/omp?cmd=get_schedules", response_data);
17525  default:
17526  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17527  return gsad_message (credentials,
17528  "Internal error", __FUNCTION__, __LINE__,
17529  "An internal error occurred while creating a new schedule. "
17530  "It is unclear whether the schedule has been created or not. "
17531  "Diagnostics: Internal Error.",
17532  "/omp?cmd=get_schedules", response_data);
17533  }
17534 
17535  if (entity_attribute (entity, "id"))
17536  params_add (params, "schedule_id", entity_attribute (entity, "id"));
17537  ret = response_from_entity (connection, credentials, params, entity,
17538  (no_redirect && strcmp (no_redirect, "0")),
17539  NULL, "get_schedules",
17540  NULL, "new_schedule",
17541  "Create Schedule", response_data);
17542  free_entity (entity);
17543  g_free (response);
17544  return ret;
17545 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a tag, get report, XSL transform 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
Result of XSL transformation.

Definition at line 10143 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

10145 {
10146  char *ret;
10147  const char* no_redirect;
10148  gchar *response;
10149  const char *name, *comment, *value, *resource_type, *resource_id, *active;
10150  entity_t entity;
10151 
10152  no_redirect = params_value (params, "no_redirect");
10153  name = params_value (params, "tag_name");
10154  comment = params_value (params, "comment");
10155  value = params_value (params, "tag_value");
10156  resource_type = params_value (params, "resource_type");
10157  resource_id = params_value (params, "resource_id");
10158  active = params_value (params, "active");
10159 
10160  CHECK_PARAM_INVALID (name, "Create Tag", "new_tag")
10161  CHECK_PARAM_INVALID (comment, "Create Tag", "new_tag")
10162  CHECK_PARAM_INVALID (value, "Create Tag", "new_tag")
10163  CHECK_PARAM_INVALID (resource_type, "Create Tag", "new_tag")
10164  CHECK_PARAM_INVALID (resource_id, "Create Tag", "new_tag")
10165  CHECK_PARAM_INVALID (active, "Create Tag", "new_tag")
10166 
10167  response = NULL;
10168  entity = NULL;
10169  switch (ompf (connection, credentials,
10170  &response,
10171  &entity,
10172  response_data,
10173  "<create_tag>"
10174  "<name>%s</name>"
10175  "<comment>%s</comment>"
10176  "<value>%s</value>"
10177  "<resource id=\"%s\">"
10178  "<type>%s</type>"
10179  "</resource>"
10180  "<active>%s</active>"
10181  "</create_tag>",
10182  name,
10183  comment,
10184  value,
10185  resource_id,
10186  resource_type,
10187  active))
10188  {
10189  case 0:
10190  case -1:
10191  break;
10192  case 1:
10193  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10194  return gsad_message (credentials,
10195  "Internal error", __FUNCTION__, __LINE__,
10196  "An internal error occurred while creating a new tag. "
10197  "No new tag was created. "
10198  "Diagnostics: Failure to send command to manager daemon.",
10199  "/omp?cmd=get_targets", response_data);
10200  case 2:
10201  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10202  return gsad_message (credentials,
10203  "Internal error", __FUNCTION__, __LINE__,
10204  "An internal error occurred while creating a new tag. "
10205  "It is unclear whether the tag has been created or not. "
10206  "Diagnostics: Failure to receive response from manager daemon.",
10207  "/omp?cmd=get_tags", response_data);
10208  default:
10209  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10210  return gsad_message (credentials,
10211  "Internal error", __FUNCTION__, __LINE__,
10212  "An internal error occurred while creating a new tag. "
10213  "It is unclear whether the tag has been created or not. "
10214  "Diagnostics: Internal Error.",
10215  "/omp?cmd=get_tags", response_data);
10216  }
10217 
10218  if (entity_attribute (entity, "id"))
10219  params_add (params, "tag_id", entity_attribute (entity, "id"));
10220  ret = response_from_entity (connection, credentials, params, entity,
10221  (no_redirect && strcmp (no_redirect, "0")),
10222  NULL, "get_tags",
10223  NULL, "new_tag",
10224  "Create Tag", response_data);
10225 
10226  free_entity (entity);
10227  g_free (response);
10228  return ret;
10229 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a target, get all targets, XSL transform 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
Result of XSL transformation.

Definition at line 9407 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, message_invalid(), params_add(), and params_value().

9410 {
9411  int ret;
9412  gchar *html, *response, *command;
9413  const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
9414  const char *target_ssh_credential, *port, *target_smb_credential;
9415  const char *target_esxi_credential, *target_snmp_credential, *target_source;
9416  const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
9417  const char *alive_tests, *hosts_filter, *file;
9418  gchar *ssh_credentials_element, *smb_credentials_element;
9419  gchar *esxi_credentials_element, *snmp_credentials_element;
9420  gchar *asset_hosts_element;
9421  gchar* comment_element = NULL;
9422  entity_t entity;
9423  GString *xml;
9424 
9425  no_redirect = params_value (params, "no_redirect");
9426  name = params_value (params, "name");
9427  hosts = params_value (params, "hosts");
9428  exclude_hosts = params_value (params, "exclude_hosts");
9429  reverse_lookup_only = params_value (params, "reverse_lookup_only");
9430  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
9431  target_source = params_value (params, "target_source");
9432  comment = params_value (params, "comment");
9433  port_list_id = params_value (params, "port_list_id");
9434  target_ssh_credential = params_value (params, "ssh_credential_id");
9435  port = params_value (params, "port");
9436  target_smb_credential = params_value (params, "smb_credential_id");
9437  target_esxi_credential = params_value (params, "esxi_credential_id");
9438  target_snmp_credential = params_value (params, "snmp_credential_id");
9439  alive_tests = params_value (params, "alive_tests");
9440  hosts_filter = params_value (params, "hosts_filter");
9441  file = params_value (params, "file");
9442 
9443  CHECK_PARAM_INVALID (name, "Create Target", "new_target");
9444  CHECK_PARAM_INVALID (target_source, "Create Target", "new_target")
9445  if (hosts == NULL && strcmp (target_source, "manual") == 0)
9446  return message_invalid (connection, credentials, params, response_data,
9447  "Missing manual list of hosts",
9448  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9449  "Create Target", "new_target");
9450  if (strcmp (target_source, "file") == 0 && file == NULL)
9451  return message_invalid (connection, credentials, params, response_data,
9452  "Missing hosts file",
9453  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9454  "Create Target", "new_target");
9455 
9456  /* require hosts_filter if target_source is "asset_hosts" */
9457  if (strcmp (target_source, "asset_hosts") == 0)
9458  CHECK_PARAM_INVALID (hosts_filter, "Create Target", "new_target");
9459 
9460  CHECK_PARAM_INVALID (comment, "Create Target", "new_target");
9461  CHECK_PARAM_INVALID (port_list_id, "Create Target", "new_target");
9462  CHECK_PARAM_INVALID (target_ssh_credential, "Create Target", "new_target");
9463  if (strcmp (target_ssh_credential, "--"))
9464  CHECK_PARAM_INVALID (port, "Create Target", "new_target");
9465  CHECK_PARAM_INVALID (target_smb_credential, "Create Target", "new_target");
9466  CHECK_PARAM_INVALID (target_esxi_credential, "Create Target", "new_target");
9467  CHECK_PARAM_INVALID (target_snmp_credential, "Create Target", "new_target");
9468  CHECK_PARAM_INVALID (alive_tests, "Create Target", "new_target");
9469 
9470  if (comment != NULL)
9471  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
9472  else
9473  comment_element = g_strdup ("");
9474 
9475  if (strcmp (target_ssh_credential, "0") == 0)
9476  ssh_credentials_element = g_strdup ("");
9477  else
9478  ssh_credentials_element =
9479  g_strdup_printf ("<ssh_credential id=\"%s\">"
9480  "<port>%s</port>"
9481  "</ssh_credential>",
9482  target_ssh_credential,
9483  port);
9484 
9485  if (strcmp (target_smb_credential, "0") == 0)
9486  smb_credentials_element = g_strdup ("");
9487  else
9488  smb_credentials_element =
9489  g_strdup_printf ("<smb_credential id=\"%s\"/>",
9490  target_smb_credential);
9491 
9492  if (strcmp (target_esxi_credential, "0") == 0)
9493  esxi_credentials_element = g_strdup ("");
9494  else
9495  esxi_credentials_element =
9496  g_strdup_printf ("<esxi_credential id=\"%s\"/>",
9497  target_esxi_credential);
9498 
9499  if (strcmp (target_snmp_credential, "0") == 0)
9500  snmp_credentials_element = g_strdup ("");
9501  else
9502  snmp_credentials_element =
9503  g_strdup_printf ("<snmp_credential id=\"%s\"/>",
9504  target_snmp_credential);
9505 
9506  if (strcmp (target_source, "asset_hosts") == 0)
9507  asset_hosts_element = g_strdup_printf ("<asset_hosts filter=\"%s\"/>",
9508  hosts_filter);
9509  else
9510  asset_hosts_element = g_strdup ("");
9511 
9512  /* Create the target. */
9513 
9514  xml = g_string_new ("");
9515 
9516  xml_string_append (xml,
9517  "<name>%s</name>"
9518  "<hosts>%s</hosts>"
9519  "<exclude_hosts>%s</exclude_hosts>"
9520  "<reverse_lookup_only>%s</reverse_lookup_only>"
9521  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
9522  "<port_list id=\"%s\"/>"
9523  "<alive_tests>%s</alive_tests>",
9524  name,
9525  strcmp (target_source, "file") == 0 ? file : hosts,
9526  exclude_hosts ? exclude_hosts : "",
9527  reverse_lookup_only ? reverse_lookup_only : "0",
9528  reverse_lookup_unify ? reverse_lookup_unify : "0",
9529  port_list_id,
9530  alive_tests);
9531 
9532  command = g_strdup_printf ("<create_target>"
9533  "%s%s%s%s%s%s%s"
9534  "</create_target>",
9535  xml->str,
9536  comment_element,
9537  ssh_credentials_element,
9538  smb_credentials_element,
9539  esxi_credentials_element,
9540  snmp_credentials_element,
9541  asset_hosts_element);
9542 
9543  g_string_free (xml, TRUE);
9544  g_free (comment_element);
9545  g_free (ssh_credentials_element);
9546  g_free (smb_credentials_element);
9547  g_free (esxi_credentials_element);
9548 
9549  ret = omp (connection, credentials,
9550  &response,
9551  &entity,
9552  response_data,
9553  command);
9554  g_free (command);
9555  switch (ret)
9556  {
9557  case 0:
9558  break;
9559  case -1:
9560  /* 'omp' set response. */
9561  return response;
9562  case 1:
9563  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9564  return gsad_message (credentials,
9565  "Internal error", __FUNCTION__, __LINE__,
9566  "An internal error occurred while creating a new target. "
9567  "No new target was created. "
9568  "Diagnostics: Failure to send command to manager daemon.",
9569  "/omp?cmd=get_targets", response_data);
9570  case 2:
9571  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9572  return gsad_message (credentials,
9573  "Internal error", __FUNCTION__, __LINE__,
9574  "An internal error occurred while creating a new target. "
9575  "It is unclear whether the target has been created or not. "
9576  "Diagnostics: Failure to receive response from manager daemon.",
9577  "/omp?cmd=get_targets", response_data);
9578  default:
9579  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9580  return gsad_message (credentials,
9581  "Internal error", __FUNCTION__, __LINE__,
9582  "An internal error occurred while creating a new target. "
9583  "It is unclear whether the target has been created or not. "
9584  "Diagnostics: Internal Error.",
9585  "/omp?cmd=get_targets", response_data);
9586  }
9587 
9588  if (entity_attribute (entity, "id"))
9589  params_add (params, "target_id", entity_attribute (entity, "id"));
9590  html = response_from_entity (connection, credentials, params, entity,
9591  (no_redirect && strcmp (no_redirect, "0")),
9592  NULL, "get_targets",
9593  NULL, "new_target",
9594  "Create Target", response_data);
9595  free_entity (entity);
9596  g_free (response);
9597  return html;
9598 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
gchar * message_invalid(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* create_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a task, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 4114 of file gsad_omp.c.

References CHECK, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_valid(), params_value(), params_values(), and param::value.

4116 {
4117  entity_t entity;
4118  int ret;
4119  gchar *schedule_element, *command;
4120  gchar *response, *html;
4121  const char *no_redirect;
4122  const char *name, *comment, *config_id, *target_id, *scanner_type;
4123  const char *scanner_id, *schedule_id, *schedule_periods;
4124  const char *max_checks, *max_hosts;
4125  const char *in_assets, *hosts_ordering, *alterable, *source_iface;
4126  const char *add_tag, *tag_name, *tag_value, *auto_delete, *auto_delete_data;
4127  const char *apply_overrides, *min_qod;
4128  gchar *name_escaped, *comment_escaped;
4129  params_t *alerts;
4130  GString *alert_element;
4131 
4132  no_redirect = params_value (params, "no_redirect");
4133  name = params_value (params, "name");
4134  comment = params_value (params, "comment");
4135  target_id = params_value (params, "target_id");
4136  scanner_type = params_value (params, "scanner_type");
4137  hosts_ordering = params_value (params, "hosts_ordering");
4138  schedule_id = params_value (params, "schedule_id");
4139  schedule_periods = params_value (params, "schedule_periods");
4140  scanner_id = params_value (params, "scanner_id");
4141  config_id = params_value (params, "config_id");
4142  in_assets = params_value (params, "in_assets");
4143  apply_overrides = params_value (params, "apply_overrides");
4144  min_qod = params_value (params, "min_qod");
4145  max_checks = params_value (params, "max_checks");
4146  source_iface = params_value (params, "source_iface");
4147  auto_delete = params_value (params, "auto_delete");
4148  auto_delete_data = params_value (params, "auto_delete_data");
4149  max_hosts = params_value (params, "max_hosts");
4150  alterable = params_value (params, "alterable");
4151  add_tag = params_value (params, "add_tag");
4152  tag_name = params_value (params, "tag_name");
4153  tag_value = params_value (params, "tag_value");
4154  CHECK (scanner_type);
4155  if (!strcmp (scanner_type, "1"))
4156  {
4157  hosts_ordering = "";
4158  max_checks = "";
4159  source_iface = "";
4160  max_hosts = "";
4161  }
4162  else if (!strcmp (scanner_type, "3"))
4163  {
4164  config_id = "";
4165  hosts_ordering = "";
4166  max_checks = "";
4167  source_iface = "";
4168  max_hosts = "";
4169  }
4170 
4171  CHECK (name);
4172  CHECK (comment);
4173  CHECK (config_id);
4174  CHECK (target_id);
4175  CHECK (hosts_ordering);
4176  CHECK (scanner_id);
4177  CHECK (schedule_id);
4178  if (params_given (params, "schedule_periods"))
4179  {
4180  CHECK (schedule_periods);
4181  }
4182  else
4183  schedule_periods = "0";
4184  CHECK (in_assets);
4185  if (!strcmp (in_assets, "1"))
4186  {
4187  CHECK (apply_overrides);
4188  CHECK (min_qod);
4189  }
4190  else
4191  {
4192  if (!params_given (params, "apply_overrides")
4193  || !params_valid (params, "apply_overrides"))
4194  apply_overrides = "";
4195 
4196  if (!params_given (params, "min_qod")
4197  || !params_valid (params, "min_qod"))
4198  min_qod = "";
4199  }
4200  CHECK (max_checks);
4201  CHECK (source_iface);
4202  CHECK (auto_delete);
4203  CHECK (auto_delete_data);
4204  CHECK (max_hosts);
4205  CHECK (alterable);
4206  if (add_tag)
4207  {
4208  CHECK (add_tag);
4209  CHECK (tag_name);
4210  CHECK (tag_value);
4211  }
4212 
4213  if (schedule_id == NULL || strcmp (schedule_id, "0") == 0)
4214  schedule_element = g_strdup ("");
4215  else
4216  schedule_element = g_strdup_printf ("<schedule id=\"%s\"/>", schedule_id);
4217 
4218  alert_element = g_string_new ("");
4219  if (params_given (params, "alert_id_optional:"))
4220  alerts = params_values (params, "alert_id_optional:");
4221  else
4222  alerts = params_values (params, "alert_ids:");
4223 
4224  if (alerts)
4225  {
4226  params_iterator_t iter;
4227  char *name;
4228  param_t *param;
4229 
4230  params_iterator_init (&iter, alerts);
4231  while (params_iterator_next (&iter, &name, &param))
4232  if (param->value && strcmp (param->value, "0"))
4233  g_string_append_printf (alert_element,
4234  "<alert id=\"%s\"/>",
4235  param->value ? param->value : "");
4236  }
4237 
4238  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
4239  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
4240 
4241  command = g_strdup_printf ("<create_task>"
4242  "<config id=\"%s\"/>"
4243  "<schedule_periods>%s</schedule_periods>"
4244  "%s%s"
4245  "<target id=\"%s\"/>"
4246  "<scanner id=\"%s\"/>"
4247  "<hosts_ordering>%s</hosts_ordering>"
4248  "<name>%s</name>"
4249  "<comment>%s</comment>"
4250  "<preferences>"
4251  "<preference>"
4252  "<scanner_name>max_checks</scanner_name>"
4253  "<value>%s</value>"
4254  "</preference>"
4255  "<preference>"
4256  "<scanner_name>max_hosts</scanner_name>"
4257  "<value>%s</value>"
4258  "</preference>"
4259  "<preference>"
4260  "<scanner_name>in_assets</scanner_name>"
4261  "<value>%s</value>"
4262  "</preference>"
4263  "<preference>"
4264  "<scanner_name>"
4265  "assets_apply_overrides"
4266  "</scanner_name>"
4267  "<value>%s</value>"
4268  "</preference>"
4269  "<preference>"
4270  "<scanner_name>assets_min_qod</scanner_name>"
4271  "<value>%s</value>"
4272  "</preference>"
4273  "<preference>"
4274  "<scanner_name>source_iface</scanner_name>"
4275  "<value>%s</value>"
4276  "</preference>"
4277  "<preference>"
4278  "<scanner_name>auto_delete</scanner_name>"
4279  "<value>%s</value>"
4280  "</preference>"
4281  "<preference>"
4282  "<scanner_name>auto_delete_data</scanner_name>"
4283  "<value>%s</value>"
4284  "</preference>"
4285  "</preferences>"
4286  "<alterable>%i</alterable>"
4287  "</create_task>",
4288  config_id,
4289  schedule_periods,
4290  schedule_element,
4291  alert_element->str,
4292  target_id,
4293  scanner_id,
4294  hosts_ordering,
4295  name_escaped,
4296  comment_escaped,
4297  max_checks,
4298  max_hosts,
4299  strcmp (in_assets, "0") ? "yes" : "no",
4300  strcmp (apply_overrides, "0") ? "yes" : "no",
4301  min_qod,
4302  source_iface,
4303  auto_delete,
4304  auto_delete_data,
4305  alterable ? strcmp (alterable, "0") : 0);
4306 
4307  g_free (name_escaped);
4308  g_free (comment_escaped);
4309 
4310  ret = omp (connection, credentials,
4311  &response,
4312  &entity,
4313  response_data,
4314  command);
4315  g_free (command);
4316 
4317  g_free (schedule_element);
4318  g_string_free (alert_element, TRUE);
4319 
4320  switch (ret)
4321  {
4322  case 0:
4323  break;
4324  case -1:
4325  /* 'omp' set response. */
4326  return response;
4327  case 1:
4328  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4329  return gsad_message (credentials,
4330  "Internal error", __FUNCTION__, __LINE__,
4331  "An internal error occurred while creating a new task. "
4332  "No new task was created. "
4333  "Diagnostics: Failure to send command to manager daemon.",
4334  "/omp?cmd=get_tasks", response_data);
4335  case 2:
4336  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4337  return gsad_message (credentials,
4338  "Internal error", __FUNCTION__, __LINE__,
4339  "An internal error occurred while creating a new task. "
4340  "It is unclear whether the task has been created or not. "
4341  "Diagnostics: Failure to receive response from manager daemon.",
4342  "/omp?cmd=get_tasks", response_data);
4343  default:
4344  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4345  return gsad_message (credentials,
4346  "Internal error", __FUNCTION__, __LINE__,
4347  "An internal error occurred while creating a new task. "
4348  "It is unclear whether the task has been created or not. "
4349  "Diagnostics: Internal Error.",
4350  "/omp?cmd=get_tasks", response_data);
4351  }
4352 
4353  if (omp_success (entity))
4354  {
4355  if (add_tag && strcmp (add_tag, "0"))
4356  {
4357  const char *new_task_id = entity_attribute (entity, "id");
4358  gchar *tag_command, *tag_response;
4359  entity_t tag_entity;
4360 
4361  if (tag_value && strcmp (tag_value, ""))
4362  tag_command
4363  = g_markup_printf_escaped ("<create_tag>"
4364  "<name>%s</name>"
4365  "<resource id=\"%s\">"
4366  "<type>task</type>"
4367  "</resource>"
4368  "<value>%s</value>"
4369  "</create_tag>",
4370  tag_name,
4371  new_task_id,
4372  tag_value);
4373  else
4374  tag_command
4375  = g_markup_printf_escaped ("<create_tag>"
4376  "<name>%s</name>"
4377  "<resource id=\"%s\">"
4378  "<type>task</type>"
4379  "</resource>"
4380  "</create_tag>",
4381  tag_name,
4382  new_task_id);
4383 
4384  ret = omp (connection, credentials,
4385  &tag_response,
4386  &tag_entity,
4387  response_data,
4388  tag_command);
4389 
4390  switch (ret)
4391  {
4392  case 0:
4393  case -1:
4394  break;
4395  case 1:
4396  free_entity (entity);
4397  g_free (response);
4398  response_data->http_status_code
4399  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4400  return gsad_message (credentials,
4401  "Internal error", __FUNCTION__, __LINE__,
4402  "An internal error occurred while creating a new tag. "
4403  "No new tag was created. "
4404  "Diagnostics: Failure to send command to manager daemon.",
4405  "/omp?cmd=get_tasks", response_data);
4406  case 2:
4407  free_entity (entity);
4408  g_free (response);
4409  response_data->http_status_code
4410  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4411  return gsad_message (credentials,
4412  "Internal error", __FUNCTION__, __LINE__,
4413  "An internal error occurred while creating a new tag. "
4414  "It is unclear whether the tag has been created or not. "
4415  "Diagnostics: Failure to receive response from manager daemon.",
4416  "/omp?cmd=get_tasks", response_data);
4417  default:
4418  free_entity (entity);
4419  g_free (response);
4420  response_data->http_status_code
4421  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4422  return gsad_message (credentials,
4423  "Internal error", __FUNCTION__, __LINE__,
4424  "An internal error occurred while creating a new task. "
4425  "It is unclear whether the tag has been created or not. "
4426  "Diagnostics: Internal Error.",
4427  "/omp?cmd=get_tasks", response_data);
4428  }
4429 
4430  if (entity_attribute (entity, "id"))
4431  params_add (params, "task_id", entity_attribute (entity, "id"));
4432  html
4433  = response_from_entity (connection, credentials, params, tag_entity,
4434  (no_redirect && strcmp (no_redirect, "0")),
4435  NULL, "get_tasks",
4436  NULL, "new_tasks",
4437  "Create Task and Tag", response_data);
4438  free_entity (tag_entity);
4439  g_free (tag_response);
4440  }
4441  else
4442  {
4443  if (entity_attribute (entity, "id"))
4444  params_add (params, "task_id", entity_attribute (entity, "id"));
4445  html
4446  = response_from_entity (connection, credentials, params, entity,
4447  (no_redirect && strcmp (no_redirect, "0")),
4448  NULL, "get_tasks",
4449  NULL, "new_task",
4450  "Create Task", response_data);
4451  }
4452  }
4453  else
4454  {
4455  html = response_from_entity (connection, credentials, params, entity,
4456  (no_redirect && strcmp (no_redirect, "0")),
4457  NULL, "get_tasks",
4458  NULL, "new_task",
4459  "Create Task", response_data);
4460  }
4461  free_entity (entity);
4462  g_free (response);
4463  return html;
4464 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9605
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793

Here is the call graph for this function:

char* create_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a user, get all users, XSL transform 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
Result of XSL transformation.

Definition at line 24882 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

24884 {
24885  const char *no_redirect;
24886  const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
24887  const char *auth_method;
24888  int ret;
24889  params_t *groups, *roles;
24890  GString *group_elements, *role_elements, *string;
24891  gchar *buf, *response, *html;
24892  entity_t entity;
24893 
24894  no_redirect = params_value (params, "no_redirect");
24895  name = params_value (params, "login");
24896  password = params_value (params, "password");
24897  hosts = params_value (params, "access_hosts");
24898  hosts_allow = params_value (params, "hosts_allow");
24899  ifaces = params_value (params, "access_ifaces");
24900  ifaces_allow = params_value (params, "ifaces_allow");
24901  auth_method = params_value (params, "auth_method");
24902 
24903  CHECK_PARAM_INVALID (name, "Create User", "new_user");
24904  CHECK_PARAM_INVALID (password, "Create User", "new_user");
24905  CHECK_PARAM_INVALID (hosts, "Create User", "new_user");
24906  CHECK_PARAM_INVALID (hosts_allow, "Create User", "new_user");
24907  CHECK_PARAM_INVALID (ifaces, "Create User", "new_user");
24908  CHECK_PARAM_INVALID (ifaces_allow, "Create User", "new_user");
24909 
24910  /* Create the user. */
24911 
24912  string = g_string_new ("<create_user>");
24913  buf = g_markup_printf_escaped ("<name>%s</name>"
24914  "<password>%s</password>",
24915  name,
24916  password);
24917 
24918  g_string_append (string, buf);
24919  g_free (buf);
24920 
24921  group_elements = g_string_new ("<groups>");
24922  if (params_given (params, "group_id_optional:"))
24923  groups = params_values (params, "group_id_optional:");
24924  else
24925  groups = params_values (params, "group_ids:");
24926 
24927  if (groups)
24928  {
24929  params_iterator_t iter;
24930  char *name;
24931  param_t *param;
24932 
24933  params_iterator_init (&iter, groups);
24934  while (params_iterator_next (&iter, &name, &param))
24935  {
24936  if (param->value && strcmp (param->value, "--"))
24937  g_string_append_printf (group_elements,
24938  "<group id=\"%s\"/>",
24939  param->value ? param->value : "");
24940  }
24941  }
24942  g_string_append (string, group_elements->str);
24943  g_string_free (group_elements, TRUE);
24944  g_string_append (string, "</groups>");
24945 
24946  role_elements = g_string_new ("");
24947  if (params_given (params, "role_id_optional:"))
24948  roles = params_values (params, "role_id_optional:");
24949  else
24950  roles = params_values (params, "role_ids:");
24951 
24952  if (roles)
24953  {
24954  params_iterator_t iter;
24955  char *name;
24956  param_t *param;
24957 
24958  params_iterator_init (&iter, roles);
24959  while (params_iterator_next (&iter, &name, &param))
24960  {
24961  if (param->value && strcmp (param->value, "--"))
24962  g_string_append_printf (role_elements,
24963  "<role id=\"%s\"/>",
24964  param->value ? param->value : "");
24965  }
24966  }
24967  g_string_append (string, role_elements->str);
24968  g_string_free (role_elements, TRUE);
24969 
24970  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
24971  "<ifaces allow=\"%s\">%s</ifaces>",
24972  hosts_allow, hosts, ifaces_allow, ifaces);
24973  g_string_append (string, buf);
24974  g_free (buf);
24975  if (auth_method && !strcmp (auth_method, "1"))
24976  g_string_append
24977  (string, "<sources><source>ldap_connect</source></sources>");
24978  else if (auth_method && !strcmp (auth_method, "2"))
24979  g_string_append
24980  (string, "<sources><source>radius_connect</source></sources>");
24981  g_string_append (string, "</create_user>");
24982 
24983  buf = g_string_free (string, FALSE);
24984 
24985  response = NULL;
24986  entity = NULL;
24987  ret = omp (connection, credentials, &response, &entity, response_data, buf);
24988  g_free (buf);
24989  switch (ret)
24990  {
24991  case 0:
24992  case -1:
24993  break;
24994  case 1:
24995  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24996  return gsad_message (credentials,
24997  "Internal error", __FUNCTION__, __LINE__,
24998  "An internal error occurred while creating a new user. "
24999  "No new user was created. "
25000  "Diagnostics: Failure to send command to manager daemon.",
25001  "/omp?cmd=get_users", response_data);
25002  case 2:
25003  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25004  return gsad_message (credentials,
25005  "Internal error", __FUNCTION__, __LINE__,
25006  "An internal error occurred while creating a new user. "
25007  "It is unclear whether the user has been created or not. "
25008  "Diagnostics: Failure to receive response from manager daemon.",
25009  "/omp?cmd=get_users", response_data);
25010  default:
25011  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25012  return gsad_message (credentials,
25013  "Internal error", __FUNCTION__, __LINE__,
25014  "An internal error occurred while creating a new user. "
25015  "It is unclear whether the user has been created or not. "
25016  "Diagnostics: Internal Error.",
25017  "/omp?cmd=get_users", response_data);
25018  }
25019 
25020  if (entity_attribute (entity, "id"))
25021  params_add (params, "user_id", entity_attribute (entity, "id"));
25022  html = response_from_entity (connection, credentials, params, entity,
25023  (no_redirect && strcmp (no_redirect, "0")),
25024  NULL, "get_users",
25025  NULL, "new_user",
25026  "Create User", response_data);
25027  free_entity (entity);
25028  g_free (response);
25029  return html;
25030 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

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

Definition at line 25590 of file gsad_omp.c.

References params_value().

Referenced by exec_omp_get().

25592 {
25593  GString *xml;
25594  const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
25595  const char *cvss_vector, *name;
25596 
25597  cvss_av = params_value (params, "cvss_av");
25598  cvss_au = params_value (params, "cvss_au");
25599  cvss_ac = params_value (params, "cvss_ac");
25600  cvss_c = params_value (params, "cvss_c");
25601  cvss_i = params_value (params, "cvss_i");
25602  cvss_a = params_value (params, "cvss_a");
25603  cvss_vector = params_value (params, "cvss_vector");
25604  name = params_value (params, "name");
25605 
25606  xml = g_string_new ("<cvss_calculator>");
25607 
25608  /* Calculate base score */
25609  if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
25610  {
25611  char *vector = g_strdup_printf
25612  ("AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c",
25613  *cvss_av, *cvss_ac, *cvss_au, *cvss_c, *cvss_i, *cvss_a);
25614 
25615  g_string_append_printf (xml,
25616  "<cvss_vector>%s</cvss_vector>"
25617  "<cvss_score>%.1f</cvss_score>",
25618  vector,
25619  get_cvss_score_from_base_metrics (vector));
25620 
25621  g_string_append_printf
25622  (xml,
25623  "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>"
25624  "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>"
25625  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
25626  *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a);
25627 
25628  g_free (vector);
25629  }
25630  else if (cvss_vector)
25631  {
25632  double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
25633 
25634  g_string_append_printf (xml,
25635  "<cvss_vector>%s</cvss_vector>"
25636  "<cvss_score>%.1f</cvss_score>",
25637  cvss_vector,
25638  cvss_score);
25639 
25640  if (cvss_score != -1.0)
25641  {
25642  cvss_av = strstr (cvss_vector, "AV:");
25643  cvss_ac = strstr (cvss_vector, "/AC:");
25644  cvss_au = strstr (cvss_vector, "/Au:");
25645  if (cvss_au == NULL)
25646  cvss_au = strstr (cvss_vector, "/AU:");
25647  cvss_c = strstr (cvss_vector, "/C:");
25648  cvss_i = strstr (cvss_vector, "/I:");
25649  cvss_a = strstr (cvss_vector, "/A:");
25650 
25651  if (cvss_av && cvss_ac && cvss_au && cvss_c
25652  && cvss_i && cvss_a)
25653  g_string_append_printf
25654  (xml,
25655  "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>"
25656  "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>"
25657  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
25658  *(cvss_av + 3), *(cvss_ac + 4), *(cvss_au + 4),
25659  *(cvss_c + 3), *(cvss_i + 3), *(cvss_a + 3));
25660  }
25661  }
25662  else if (name && !strcmp ("vector", name))
25663  {
25664  g_string_append_printf (xml,
25665  "<cvss_score>%.1f</cvss_score>",
25666  -1.0);
25667  }
25668 
25669  g_string_append (xml, "</cvss_calculator>");
25670  return xsl_transform_omp (connection, credentials, params,
25671  g_string_free (xml, FALSE), response_data);
25672 }
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* dashboard ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Show a dashboard.

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

Definition at line 25685 of file gsad_omp.c.

References command_enabled(), gsad_message(), credentials_t::guest, cmd_response_data_t::http_status_code, params_value(), cmd_response_data_t::redirect, and credentials_t::token.

Referenced by exec_omp_get().

25687 {
25688  GString *xml;
25689  const char *name;
25690  gchar* response;
25691  entity_t entity;
25692  int ret;
25693  int may_get_aggregates, may_get_info, may_get_tasks;
25694 
25695  may_get_aggregates = command_enabled (credentials, "GET_AGGREGATES");
25696  may_get_info = command_enabled (credentials, "GET_INFO");
25697  may_get_tasks = command_enabled (credentials, "GET_TASKS");
25698  name = params_value (params, "dashboard_name");
25699  if (name == NULL)
25700  {
25701  if (credentials->guest
25702  && may_get_aggregates && may_get_info)
25703  name = "secinfo";
25704  else if (may_get_aggregates && may_get_info && may_get_tasks)
25705  name = "main";
25706  else if (may_get_aggregates && may_get_tasks)
25707  name = "scans";
25708  else if (may_get_aggregates && may_get_info)
25709  name = "secinfo";
25710  else if (command_enabled (credentials, "GET_SYSTEM_REPORTS"))
25711  {
25712  gchar *redirect_url;
25713  redirect_url = g_strdup_printf ("/omp?cmd=get_system_reports&token=%s",
25714  credentials->token);
25715  response_data->redirect = redirect_url;
25716  return g_strdup_printf ("redirecting to %s", redirect_url);
25717  }
25718  else
25719  {
25720  gchar *redirect_url;
25721  redirect_url = g_strdup_printf ("/help/about.html?token=%s",
25722  credentials->token);
25723  response_data->redirect = redirect_url;
25724  return g_strdup_printf ("redirecting to %s", redirect_url);
25725  }
25726  }
25727 
25728  xml = g_string_new ("<dashboard>");
25729  g_string_append_printf (xml, "<name>%s</name>", name);
25730 
25731  response = NULL;
25732  entity = NULL;
25733 
25734  // Test if SCAP and CERT databases are available
25735  if (strcasecmp (name, "") == 0
25736  || strcasecmp (name, "Main") == 0
25737  || strcasecmp (name, "SecInfo") == 0)
25738  {
25739  ret = ompf (connection,
25740  credentials,
25741  &response,
25742  &entity,
25743  response_data,
25744  "<get_info type=\"cve\" info_id=\"--\"/>");
25745 
25746  switch (ret)
25747  {
25748  case 0:
25749  case -1:
25750  break;
25751  case 1:
25752  g_string_free (xml, TRUE);
25753  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25754  return gsad_message (credentials,
25755  "Internal error", __FUNCTION__, __LINE__,
25756  "An internal error occurred while "
25757  "testing SecInfo database availability. "
25758  "Diagnostics: Failure to send command to "
25759  "manager daemon.",
25760  "/omp?cmd=dashboard", response_data);
25761  case 2:
25762  g_string_free (xml, TRUE);
25763  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25764  return gsad_message (credentials,
25765  "Internal error", __FUNCTION__, __LINE__,
25766  "An internal error occurred while "
25767  "testing SecInfo database availability. "
25768  "Diagnostics: Failure to receive response from "
25769  "manager daemon.",
25770  "/omp?cmd=dashboard", response_data);
25771  default:
25772  g_string_free (xml, TRUE);
25773  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25774  return gsad_message (credentials,
25775  "Internal error", __FUNCTION__, __LINE__,
25776  "An internal error occurred while "
25777  "testing SecInfo database availability. "
25778  "Diagnostics: Internal Error.",
25779  "/omp?cmd=dashboard", response_data);
25780  }
25781  g_string_append_printf (xml,
25782  "<secinfo_test>%s</secinfo_test>",
25783  response);
25784  g_free (response);
25785  free_entity (entity);
25786  }
25787 
25788  if (strcasecmp (name, "SecInfo") == 0)
25789  ret = ompf (connection,
25790  credentials,
25791  &response,
25792  &entity,
25793  response_data,
25794  "<get_filters filter=\"type=info or type= first=1 rows=-1\"/>");
25795  else
25796  ret = ompf (connection,
25797  credentials,
25798  &response,
25799  &entity,
25800  response_data,
25801  "<get_filters filter=\"first=1 rows=-1\"/>");
25802 
25803  switch (ret)
25804  {
25805  case 0:
25806  case -1:
25807  break;
25808  case 1:
25809  g_string_free (xml, TRUE);
25810  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25811  return gsad_message (credentials,
25812  "Internal error", __FUNCTION__, __LINE__,
25813  "An internal error occurred while getting the "
25814  "filters list. "
25815  "Diagnostics: Failure to send command to "
25816  "manager daemon.",
25817  "/omp?cmd=dashboard", response_data);
25818  case 2:
25819  g_string_free (xml, TRUE);
25820  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25821  return gsad_message (credentials,
25822  "Internal error", __FUNCTION__, __LINE__,
25823  "An internal error occurred while getting the "
25824  "filters list. "
25825  "Diagnostics: Failure to receive response from "
25826  "manager daemon.",
25827  "/omp?cmd=dashboard", response_data);
25828  default:
25829  g_string_free (xml, TRUE);
25830  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25831  return gsad_message (credentials,
25832  "Internal error", __FUNCTION__, __LINE__,
25833  "An internal error occurred while getting the "
25834  "filters list. "
25835  "Diagnostics: Internal Error.",
25836  "/omp?cmd=dashboard", response_data);
25837  }
25838 
25839  g_string_append (xml, response);
25840  g_free (response);
25841  free_entity (entity);
25842 
25843  g_string_append (xml, "</dashboard>");
25844  return xsl_transform_omp (connection, credentials, params,
25845  g_string_free (xml, FALSE), response_data);
25846 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int guest
Whether the user is a guest user.
Definition: gsad_base.h:86
char * token
Session token.
Definition: gsad_base.h:73
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* delete_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete agent, get all agents, XSL transform 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 of XSL transformation.

Definition at line 7073 of file gsad_omp.c.

References delete_resource().

7075 {
7076  return delete_resource (connection, "agent", credentials, params, 0,
7077  "get_agents", response_data);
7078 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete an alert, get all alerts, XSL transform 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
Result of XSL transformation.

Definition at line 8376 of file gsad_omp.c.

References command_enabled(), delete_resource(), get_one(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

8378 {
8379  return delete_resource (connection, "alert", credentials, params, 0,
8380  "get_alerts", response_data);
8381 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_asset_omp ( openvas_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
Result of XSL transformation.

Definition at line 27150 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_get(), params_given(), params_value(), cmd_response_data_t::redirect, param::value, and param::value_size.

27152 {
27153  gchar *html, *response, *resource_id;
27154  const char *next_id, *no_redirect;
27155  entity_t entity;
27156  gchar *next_url;
27157 
27158  if (params_value (params, "asset_id"))
27159  resource_id = g_strdup (params_value (params, "asset_id"));
27160  else if (params_value (params, "report_id"))
27161  resource_id = g_strdup (params_value (params, "report_id"));
27162  else
27163  {
27164  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27165  return gsad_message (credentials,
27166  "Internal error", __FUNCTION__, __LINE__,
27167  "An internal error occurred while deleting an asset. "
27168  "The asset was not deleted. "
27169  "Diagnostics: Required parameter was NULL.",
27170  "/omp?cmd=get_tasks", response_data);
27171  }
27172 
27173  /* This is a hack, needed because asset_id is the param name used for
27174  * both the asset being deleted and the asset on the next page. */
27175  next_id = params_value (params, "next_id");
27176  if (next_id
27177  && params_value (params, "asset_id"))
27178  {
27179  param_t *param;
27180  param = params_get (params, "asset_id");
27181  g_free (param->value);
27182  param->value = g_strdup (next_id);
27183  param->value_size = strlen (param->value);
27184  }
27185 
27186  /* Delete the resource and get all resources. */
27187 
27188  if (openvas_connection_sendf (connection,
27189  "<delete_asset %s_id=\"%s\"/>",
27190  params_value (params, "asset_id")
27191  ? "asset" : "report",
27192  resource_id)
27193  == -1)
27194  {
27195  g_free (resource_id);
27196  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27197  return gsad_message (credentials,
27198  "Internal error", __FUNCTION__, __LINE__,
27199  "An internal error occurred while deleting an asset. "
27200  "The asset is not deleted. "
27201  "Diagnostics: Failure to send command to manager daemon.",
27202  "/omp?cmd=get_tasks", response_data);
27203  }
27204 
27205  g_free (resource_id);
27206 
27207  entity = NULL;
27208  if (read_entity_and_text_c (connection, &entity, &response))
27209  {
27210  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27211  return gsad_message (credentials,
27212  "Internal error", __FUNCTION__, __LINE__,
27213  "An internal error occurred while deleting an asset. "
27214  "It is unclear whether the asset has been deleted or not. "
27215  "Diagnostics: Failure to read response from manager daemon.",
27216  "/omp?cmd=get_tasks", response_data);
27217  }
27218 
27219  /* Cleanup, and return transformed XML. */
27220 
27221  if (params_given (params, "next") == 0)
27222  params_add (params, "next", "get_asset");
27223 
27224  no_redirect = params_value (params, "no_redirect");
27225  if (no_redirect && strcmp (no_redirect, "0"))
27226  {
27227  html = next_page (connection, credentials, params, response,
27228  response_data);
27229  if (html == NULL)
27230  {
27231  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27232  html = gsad_message (credentials,
27233  "Internal error", __FUNCTION__, __LINE__,
27234  "An internal error occurred while deleting an "
27235  "asset. Diagnostics: Error in parameter next.",
27236  "/omp?cmd=get_tasks", response_data);
27237  }
27238  }
27239  else
27240  {
27241  next_url = next_page_url (credentials, params,
27242  NULL, "get_asset", "delete_asset",
27243  entity_attribute (entity, "status"),
27244  entity_attribute (entity, "status_text"));
27245  response_data->redirect = next_url;
27246 
27247  html = NULL;
27248  }
27249 
27250  g_free (response);
27251  free_entity (entity);
27252  return html;
27253 }
gchar * value
Definition: gsad_base.h:148
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:679
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
int value_size
Definition: gsad_base.h:154
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808

Here is the call graph for this function:

char* delete_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete config, get all configs, XSL transform 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
Result of XSL transformation.

Definition at line 12878 of file gsad_omp.c.

References delete_resource().

12881 {
12882  return delete_resource (connection, "config", credentials, params, 0,
12883  "get_configs", response_data);
12884 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete credential, get all credentials, XSL transform 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 of XSL transformation.

Definition at line 6604 of file gsad_omp.c.

References delete_resource().

6607 {
6608  return delete_resource (connection, "credential", credentials, params, 0,
6609  "get_credentials", response_data);
6610 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a filter, get all filters, XSL transform 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
Result of XSL transformation.

Definition at line 23955 of file gsad_omp.c.

References delete_resource(), free_find_by_value(), init_find_by_value(), find_by_value_t::keys, credentials_t::last_filt_ids, params_get(), and param::value.

23958 {
23959  param_t *filt_id, *id;
23960  GList *list;
23961 
23962  filt_id = params_get (params, "filt_id");
23963  id = params_get (params, "filter_id");
23964  if (id && id->value && filt_id && filt_id->value
23965  && (strcmp (id->value, filt_id->value) == 0))
23966  // TODO: Add params_remove.
23967  filt_id->value = NULL;
23968 
23969  /* remove to be deleted key from the user credentials */
23970  if (id && id->value)
23971  {
23972  find_by_value_t find;
23973 
23974  init_find_by_value (&find, id->value);
23975 
23976  g_tree_foreach (credentials->last_filt_ids, (GTraverseFunc)find_by_value,
23977  &find);
23978  if (find.keys != NULL)
23979  {
23980  list = g_list_first (find.keys);
23981 
23982  while (list != NULL)
23983  {
23984  g_debug ("%s removing filter from last filter ids for %s\n",
23985  __FUNCTION__, (char *)list->data);
23986  g_tree_remove (credentials->last_filt_ids, list->data);
23987  list = g_list_next (find.keys);
23988  }
23989  }
23990 
23991  free_find_by_value(&find);
23992  }
23993 
23994  return delete_resource (connection, "filter", credentials, params, 0,
23995  "get_filters", response_data);
23996 }
gchar * value
Definition: gsad_base.h:148
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:679
GTree * last_filt_ids
Last filter ids.
Definition: gsad_base.h:83
void init_find_by_value(find_by_value_t *find, gchar *value)
Definition: gsad_omp.c:396
Structure to search a key by value.
Definition: gsad_omp.c:389
Request parameter.
Definition: gsad_base.h:146
GList * keys
Definition: gsad_omp.c:392
void free_find_by_value(find_by_value_t *find)
Definition: gsad_omp.c:403
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a group, get all groups, XSL transform 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
Result of XSL transformation.

Definition at line 20260 of file gsad_omp.c.

References delete_resource().

20262 {
20263  return delete_resource (connection, "group", credentials, params, 0,
20264  "get_groups", response_data);
20265 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete note, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 15626 of file gsad_omp.c.

References delete_resource().

15628 {
15629  return delete_resource (connection, "note", credentials, params, 0, NULL,
15630  response_data);
15631 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete override, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 16338 of file gsad_omp.c.

References delete_resource().

16341 {
16342  return delete_resource (connection, "override", credentials, params, 0, NULL,
16343  response_data);
16344 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a permission, get all permissions, XSL transform 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
Result of XSL transformation.

Definition at line 20655 of file gsad_omp.c.

References delete_resource().

20658 {
20659  return delete_resource (connection, "permission", credentials, params, 0,
20660  NULL, response_data);
20661 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a port list, get all port lists, XSL transform 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
Result of XSL transformation.

Definition at line 22886 of file gsad_omp.c.

References delete_resource().

22889 {
22890  return delete_resource (connection, "port_list", credentials, params, 0,
22891  "get_port_lists", response_data);
22892 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_port_range_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a port range, get the port list, XSL transform 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
Result of XSL transformation.

Definition at line 22924 of file gsad_omp.c.

References delete_resource().

22927 {
22928  return delete_resource (connection, "port_range", credentials, params, 1,
22929  "edit_port_list", response_data);
22930 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete report format, get report formats, XSL transform 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
Result of XSL transformation.

Definition at line 18077 of file gsad_omp.c.

References delete_resource(), edit_resource(), and params_t.

18080 {
18081  return delete_resource (connection, "report_format", credentials, params, 0,
18082  "get_report_formats", response_data);
18083 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete report, get task status, XSL transform 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
Result of XSL transformation.

Definition at line 13246 of file gsad_omp.c.

References command_enabled(), delete_resource(), format_file_name(), gsad_message(), GSAD_MESSAGE_INVALID, cmd_response_data_t::http_status_code, credentials_t::last_filt_ids, params_add(), params_given(), params_t, params_valid(), params_value(), RESULTS_PER_PAGE, param::valid, param::valid_utf8, and param::value.

13249 {
13250  return delete_resource (connection, "report", credentials, params, 0, NULL,
13251  response_data);
13252 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_resource ( openvas_connection_t *  connection,
const char *  type,
credentials_t credentials,
params_t params,
int  ultimate,
const char *  get,
cmd_response_data_t response_data 
)

Delete a resource, get all resources, XSL transform 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.
[in]getNext page get command.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 3011 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_get(), params_value(), set_http_status_from_entity(), param::value, and param::value_size.

Referenced by delete_agent_omp(), delete_alert_omp(), delete_config_omp(), delete_credential_omp(), delete_filter_omp(), delete_group_omp(), delete_note_omp(), delete_override_omp(), delete_permission_omp(), delete_port_list_omp(), delete_port_range_omp(), delete_report_format_omp(), delete_report_omp(), delete_role_omp(), delete_scanner_omp(), delete_schedule_omp(), delete_tag_omp(), delete_target_omp(), delete_task_omp(), delete_trash_agent_omp(), delete_trash_alert_omp(), delete_trash_config_omp(), delete_trash_credential_omp(), delete_trash_filter_omp(), delete_trash_group_omp(), delete_trash_note_omp(), delete_trash_override_omp(), delete_trash_permission_omp(), delete_trash_port_list_omp(), delete_trash_report_format_omp(), delete_trash_role_omp(), delete_trash_scanner_omp(), delete_trash_schedule_omp(), delete_trash_tag_omp(), delete_trash_target_omp(), delete_trash_task_omp(), and delete_user_omp().

3014 {
3015  gchar *html, *response, *id_name, *resource_id, *extra_attribs;
3016  const char *no_redirect, *next_id;
3017  entity_t entity;
3018  gchar *cap_type, *default_next, *prev_action;
3019 
3020  no_redirect = params_value (params, "no_redirect");
3021  id_name = g_strdup_printf ("%s_id", type);
3022  if (params_value (params, id_name))
3023  resource_id = g_strdup (params_value (params, id_name));
3024  else
3025  {
3026  g_free (id_name);
3027  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
3028  return gsad_message (credentials,
3029  "Internal error", __FUNCTION__, __LINE__,
3030  "An internal error occurred while deleting a resource. "
3031  "The resource was not deleted. "
3032  "Diagnostics: Required parameter resource_id was NULL.",
3033  "/omp?cmd=get_tasks", response_data);
3034  }
3035 
3036  /* This is a hack for assets, because asset_id is the param name used for
3037  * both the asset being deleted and the asset on the next page. */
3038  next_id = params_value (params, "next_id");
3039  if (next_id)
3040  {
3041  param_t *param;
3042  param = params_get (params, id_name);
3043  g_free (param->value);
3044  param->value = g_strdup (next_id);
3045  param->value_size = strlen (param->value);
3046  }
3047 
3048  g_free (id_name);
3049 
3050  /* Extra attributes */
3051  extra_attribs = NULL;
3052 
3053  /* Inheritor of user's resource */
3054  if (strcmp (type, "user") == 0)
3055  {
3056  const char* inheritor_id;
3057  inheritor_id = params_value (params, "inheritor_id");
3058  if (inheritor_id)
3059  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
3060  }
3061 
3062  /* Delete the resource and get all resources. */
3063 
3064  if (openvas_connection_sendf (connection,
3065  "<delete_%s %s_id=\"%s\" ultimate=\"%i\"%s%s/>",
3066  type,
3067  type,
3068  resource_id,
3069  !!ultimate,
3070  extra_attribs ? " " : "",
3071  extra_attribs ? extra_attribs : "")
3072  == -1)
3073  {
3074  g_free (resource_id);
3075  g_free (extra_attribs);
3076  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3077  return gsad_message (credentials,
3078  "Internal error", __FUNCTION__, __LINE__,
3079  "An internal error occurred while deleting a resource. "
3080  "The resource is not deleted. "
3081  "Diagnostics: Failure to send command to manager daemon.",
3082  "/omp?cmd=get_tasks", response_data);
3083  }
3084 
3085  g_free (resource_id);
3086  g_free (extra_attribs);
3087 
3088  entity = NULL;
3089  if (read_entity_and_text_c (connection, &entity, &response))
3090  {
3091  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3092  return gsad_message (credentials,
3093  "Internal error", __FUNCTION__, __LINE__,
3094  "An internal error occurred while deleting a resource. "
3095  "It is unclear whether the resource has been deleted or not. "
3096  "Diagnostics: Failure to read response from manager daemon.",
3097  "/omp?cmd=get_tasks", response_data);
3098  }
3099 
3100  if (!omp_success (entity))
3101  set_http_status_from_entity (entity, response_data);
3102 
3103  cap_type = capitalize (type);
3104  default_next = g_strdup_printf ("get_%ss", type);
3105  prev_action = g_strdup_printf ("Delete %s", cap_type);
3106 
3107  html = response_from_entity (connection, credentials, params, entity,
3108  (no_redirect && strcmp (no_redirect, "0")),
3109  NULL, default_next,
3110  NULL, default_next,
3111  prev_action, response_data);
3112 
3113  g_free (response);
3114  free_entity (entity);
3115  g_free (cap_type);
3116  g_free (default_next);
3117  g_free (prev_action);
3118 
3119  return html;
3120 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
gchar * value
Definition: gsad_base.h:148
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:679
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int value_size
Definition: gsad_base.h:154
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* delete_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a role, get all roles, XSL transform 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
Result of XSL transformation.

Definition at line 23086 of file gsad_omp.c.

References delete_resource().

23088 {
23089  return delete_resource (connection, "role", credentials, params, 0,
23090  "get_roles", response_data);
23091 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a scanner, get all scanners, XSL transform 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
Result of XSL transformation.

Definition at line 16987 of file gsad_omp.c.

References delete_resource().

16990 {
16991  return delete_resource (connection, "scanner", credentials, params, 0,
16992  "get_scanners", response_data);
16993 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a schedule, get all schedules, XSL transform 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
Result of XSL transformation.

Definition at line 17558 of file gsad_omp.c.

References delete_resource().

17561 {
17562  return delete_resource (connection, "schedule", credentials, params, 0,
17563  "get_schedules", response_data);
17564 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete note, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 10242 of file gsad_omp.c.

References delete_resource().

10244 {
10245  return delete_resource (connection, "tag", credentials, params, 0, NULL,
10246  response_data);
10247 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a target, get all targets, XSL transform 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
Result of XSL transformation.

Definition at line 9763 of file gsad_omp.c.

References delete_resource().

9766 {
9767  return delete_resource (connection, "target", credentials, params, 0,
9768  "get_targets", response_data);
9769 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a task, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 4478 of file gsad_omp.c.

References command_enabled(), delete_resource(), gsad_message(), cmd_response_data_t::http_status_code, params_t, params_value(), and credentials_t::username.

4480 {
4481  return delete_resource (connection, "task", credentials, params, 0, NULL, response_data);
4482 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash agent, get all agents, XSL transform 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
Result of XSL transformation.

Definition at line 9782 of file gsad_omp.c.

References delete_resource().

9785 {
9786  return delete_resource (connection, "agent", credentials, params, 1,
9787  "get_trash", response_data);
9788 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash alert, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9820 of file gsad_omp.c.

References delete_resource().

9823 {
9824  return delete_resource (connection, "alert", credentials, params, 1,
9825  "get_trash", response_data);
9826 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash config, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9801 of file gsad_omp.c.

References delete_resource().

9804 {
9805  return delete_resource (connection, "config", credentials, params, 1,
9806  "get_trash", response_data);
9807 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash credential, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9839 of file gsad_omp.c.

References delete_resource().

9842 {
9843  return delete_resource (connection, "credential", credentials, params, 1,
9844  "get_trash", response_data);
9845 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a filter, get all filters, XSL transform 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
Result of XSL transformation.

Definition at line 23936 of file gsad_omp.c.

References delete_resource().

23939 {
23940  return delete_resource (connection, "filter", credentials, params, 1,
23941  "get_trash", response_data);
23942 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a group from trash, get all groups, XSL transform 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
Result of XSL transformation.

Definition at line 20241 of file gsad_omp.c.

References delete_resource().

20244 {
20245  return delete_resource (connection, "group", credentials, params, 1,
20246  "get_trash", response_data);
20247 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a note, get all notes, XSL transform 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
Result of XSL transformation.

Definition at line 15644 of file gsad_omp.c.

References delete_resource().

15647 {
15648  return delete_resource (connection, "note", credentials, params, 1,
15649  "get_trash", response_data);
15650 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a override, get all overrides, XSL transform 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
Result of XSL transformation.

Definition at line 16357 of file gsad_omp.c.

References delete_resource().

16360 {
16361  return delete_resource (connection, "override", credentials, params, 1,
16362  "get_trash", response_data);
16363 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a permission, get all permissions, XSL transform 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
Result of XSL transformation.

Definition at line 20636 of file gsad_omp.c.

References delete_resource().

20639 {
20640  return delete_resource (connection, "permission", credentials, params, 1,
20641  "get_trash", response_data);
20642 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash port list, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 22905 of file gsad_omp.c.

References delete_resource().

22908 {
22909  return delete_resource (connection, "port_list", credentials, params, 1,
22910  "get_trash", response_data);
22911 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash report format, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9858 of file gsad_omp.c.

References delete_resource().

9861 {
9862  return delete_resource (connection, "report_format", credentials, params, 1,
9863  "get_trash", response_data);
9864 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a role from trash, get all roles, XSL transform 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
Result of XSL transformation.

Definition at line 23067 of file gsad_omp.c.

References delete_resource().

23070 {
23071  return delete_resource (connection, "role", credentials, params, 1,
23072  "get_trash", response_data);
23073 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash scanner, get all scanners, XSL transform 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
Result of XSL transformation.

Definition at line 17006 of file gsad_omp.c.

References delete_resource().

17009 {
17010  return delete_resource (connection, "scanner", credentials, params, 1,
17011  "get_trash", response_data);
17012 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash schedule, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9877 of file gsad_omp.c.

References delete_resource().

9880 {
9881  return delete_resource (connection, "schedule", credentials, params, 1,
9882  "get_trash", response_data);
9883 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a note, get all notes, XSL transform 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
Result of XSL transformation.

Definition at line 10260 of file gsad_omp.c.

References delete_resource().

10263 {
10264  return delete_resource (connection, "tag", credentials, params, 1,
10265  "get_trash", response_data);
10266 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash target, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9896 of file gsad_omp.c.

References delete_resource().

9899 {
9900  return delete_resource (connection, "target", credentials, params, 1,
9901  "get_trash", response_data);
9902 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_trash_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a trash task, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9915 of file gsad_omp.c.

References delete_resource().

9918 {
9919  return delete_resource (connection, "task", credentials, params, 1,
9920  "get_trash", response_data);
9921 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

char* delete_user_confirm_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Show confirmation deleting a user, XSL transform 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
Result of XSL transformation.

Definition at line 24691 of file gsad_omp.c.

References command_enabled(), get_one(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

24694 {
24695  return delete_user_confirm (connection, credentials, params, NULL,
24696  response_data);
24697 }

Here is the call graph for this function:

char* delete_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a user, get all users, XSL transform 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
Result of XSL transformation.

Definition at line 24604 of file gsad_omp.c.

References command_enabled(), delete_resource(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

24606 {
24607  return delete_resource (connection, "user", credentials, params, 0,
24608  "get_users", response_data);
24609 }
char * delete_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3011

Here is the call graph for this function:

int download_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  result_len,
char **  html,
char **  filename,
cmd_response_data_t response_data 
)

Get an agent, XSL transform the result.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]result_lenLength of result.
[out]htmlResult of XSL transformation. 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 7095 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

7102 {
7103  entity_t entity;
7104  const char *agent_id, *format;
7105 
7106  agent_id = params_value (params, "agent_id");
7107  format = params_value (params, "agent_format");
7108 
7109  if ((agent_id == NULL) || (format == NULL))
7110  {
7111  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
7112  *html = gsad_message (credentials,
7113  "Internal error", __FUNCTION__, __LINE__,
7114  "An internal error occurred while downloading "
7115  "an agent. "
7116  "Diagnostics: Required parameter was NULL.",
7117  "/omp?cmd=get_agents", response_data);
7118  return 1;
7119  }
7120 
7121  *result_len = 0;
7122 
7123  /* Send the request. */
7124 
7125  if (openvas_connection_sendf (connection,
7126  "<get_agents agent_id=\"%s\" format=\"%s\"/>",
7127  agent_id,
7128  format)
7129  == -1)
7130  {
7131  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7132  *html = gsad_message (credentials,
7133  "Internal error", __FUNCTION__, __LINE__,
7134  "An internal error occurred while getting agent list. "
7135  "The current list of agents is not available. "
7136  "Diagnostics: Failure to send command to manager daemon.",
7137  "/omp?cmd=get_agents", response_data);
7138  return 1;
7139  }
7140 
7141  /* Read and handle the response. */
7142 
7143  if (strcmp (format, "installer") == 0
7144  || strcmp (format, "howto_install") == 0
7145  || strcmp (format, "howto_use") == 0)
7146  {
7147  gchar *package_decoded = NULL;
7148  entity_t package_entity = NULL, agent_entity;
7149 
7150  /* A base64 encoded package. */
7151 
7152  entity = NULL;
7153  if (read_entity_c (connection, &entity))
7154  {
7155  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7156  *html = gsad_message (credentials,
7157  "Internal error", __FUNCTION__, __LINE__,
7158  "An internal error occurred while getting a agent. "
7159  "The agent is not available. "
7160  "Diagnostics: Failure to receive response from manager daemon.",
7161  "/omp?cmd=get_agents", response_data);
7162  return 1;
7163  }
7164 
7165  agent_entity = entity_child (entity, "agent");
7166  if (agent_entity)
7167  package_entity = entity_child (agent_entity, "package");
7168  if (package_entity != NULL)
7169  {
7170  char *package_encoded = entity_text (package_entity);
7171  if (strlen (package_encoded))
7172  {
7173  package_decoded = (gchar *) g_base64_decode (package_encoded,
7174  result_len);
7175  if (package_decoded == NULL)
7176  {
7177  package_decoded = (gchar *) g_strdup ("");
7178  *result_len = 0;
7179  }
7180  }
7181  else
7182  {
7183  package_decoded = (gchar *) g_strdup ("");
7184  *result_len = 0;
7185  }
7186  *html = package_decoded;
7187  if (filename)
7188  {
7189  entity_t filename_entity;
7190  filename_entity = entity_child (package_entity,
7191  "filename");
7192  if (filename_entity)
7193  *filename = g_strdup (entity_text (filename_entity));
7194  else
7195  *filename = NULL;
7196  if (!(*filename && strlen (*filename)))
7197  {
7198  g_free(*filename);
7199  *filename = g_strdup_printf ("agent-%s-%s", agent_id, format);
7200  }
7201  }
7202  free_entity (entity);
7203  return 0;
7204  }
7205  else
7206  {
7207  free_entity (entity);
7208  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7209  *html = gsad_message (credentials,
7210  "Internal error", __FUNCTION__, __LINE__,
7211  "An internal error occurred while getting a agent. "
7212  "The agent could not be delivered. "
7213  "Diagnostics: Failure to receive agent from manager daemon.",
7214  "/omp?cmd=get_tasks", response_data);
7215  return 1;
7216  }
7217  }
7218  else
7219  {
7220  /* An error. */
7221 
7222  entity = NULL;
7223  if (read_entity_c (connection, &entity))
7224  {
7225  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7226  *html = gsad_message (credentials,
7227  "Internal error", __FUNCTION__, __LINE__,
7228  "An internal error occurred while getting a agent. "
7229  "The agent could not be delivered. "
7230  "Diagnostics: Failure to receive agent from manager daemon.",
7231  "/omp?cmd=get_tasks", response_data);
7232  return 1;
7233  }
7234 
7235  free_entity (entity);
7236  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7237  *html = gsad_message (credentials,
7238  "Internal error", __FUNCTION__, __LINE__,
7239  "An internal error occurred while getting a agent. "
7240  "The agent could not be delivered. "
7241  "Diagnostics: Failure to parse agent from manager daemon.",
7242  "/omp?cmd=get_tasks", response_data);
7243  return 1;
7244  }
7245 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* download_ca_pub ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  response_size,
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.
[in]response_sizeSize of cert.
[out]response_dataExtra data return for the HTTP response.
Returns
CA Certificate.

Definition at line 14841 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

14844 {
14845  const char *ca_pub;
14846  char *unescaped;
14847 
14848  ca_pub = params_value (params, "ca_pub");
14849  if (ca_pub == NULL)
14850  {
14851  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
14852  return gsad_message (credentials,
14853  "Internal error", __FUNCTION__, __LINE__,
14854  "An internal error occurred."
14855  " Diagnostics: ca_pub was NULL.",
14856  "/omp?cmd=get_reports", response_data);
14857  }
14858  /* The Base64 comes URI escaped as it may contain special characters. */
14859  unescaped = g_uri_unescape_string (ca_pub, NULL);
14860  *response_size = strlen (unescaped);
14861  return unescaped;
14862 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

int download_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  result_len,
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]result_lenLength of result.
[out]htmlResult of XSL transformation. 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 6328 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

6335 {
6336  entity_t entity;
6337  const char *credential_id, *format;
6338 
6339  assert (html);
6340 
6341  if (result_len) *result_len = 0;
6342 
6343  /* Send the request. */
6344 
6345  credential_id = params_value (params, "credential_id");
6346  format = params_value (params, "package_format");
6347 
6348  if ((credential_id == NULL) || (format == NULL))
6349  {
6350  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
6351  *html = gsad_message (credentials,
6352  "Internal error", __FUNCTION__, __LINE__,
6353  "An internal error occurred while getting a credential. "
6354  "Diagnostics: Required parameter was NULL.",
6355  "/omp?cmd=get_credentials", response_data);
6356  return 1;
6357  }
6358 
6359  if (openvas_connection_sendf (connection,
6360  "<get_credentials"
6361  " credential_id=\"%s\""
6362  " format=\"%s\"/>",
6363  credential_id,
6364  format)
6365  == -1)
6366  {
6367  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6368  *html = gsad_message (credentials,
6369  "Internal error", __FUNCTION__, __LINE__,
6370  "An internal error occurred while getting a credential. "
6371  "Diagnostics: Failure to send command to manager daemon.",
6372  "/omp?cmd=get_credentials", response_data);
6373  return 1;
6374  }
6375 
6376  /* Read and handle the response. */
6377 
6378  if (strcmp (format, "rpm") == 0
6379  || strcmp (format, "deb") == 0
6380  || strcmp (format, "exe") == 0)
6381  {
6382  gchar *package_decoded = NULL;
6383  entity_t package_entity = NULL, credential_entity;
6384 
6385  /* A base64 encoded package. */
6386 
6387  entity = NULL;
6388  if (read_entity_c (connection, &entity))
6389  {
6390  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6391  *html = gsad_message (credentials,
6392  "Internal error", __FUNCTION__, __LINE__,
6393  "An internal error occurred while getting a credential. "
6394  "The credential is not available. "
6395  "Diagnostics: Failure to receive response from manager daemon.",
6396  "/omp?cmd=get_credentials", response_data);
6397  return 1;
6398  }
6399 
6400  credential_entity = entity_child (entity, "credential");
6401  if (credential_entity)
6402  package_entity = entity_child (credential_entity, "package");
6403  if (package_entity != NULL)
6404  {
6405  gsize len;
6406  char *package_encoded = entity_text (package_entity);
6407  if (strlen (package_encoded))
6408  {
6409  package_decoded = (gchar *) g_base64_decode (package_encoded,
6410  &len);
6411  if (package_decoded == NULL)
6412  {
6413  package_decoded = (gchar *) g_strdup ("");
6414  len = 0;
6415  }
6416  }
6417  else
6418  {
6419  package_decoded = (gchar *) g_strdup ("");
6420  len = 0;
6421  }
6422  if (result_len) *result_len = len;
6423  *html = package_decoded;
6424  if (login)
6425  {
6426  entity_t login_entity;
6427  login_entity = entity_child (credential_entity, "login");
6428  if (login_entity)
6429  *login = g_strdup (entity_text (login_entity));
6430  else
6431  *login = NULL;
6432  }
6433  free_entity (entity);
6434  return 0;
6435  }
6436  else
6437  {
6438  free_entity (entity);
6439  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6440  *html = gsad_message (credentials,
6441  "Internal error", __FUNCTION__, __LINE__,
6442  "An internal error occurred while getting a credential. "
6443  "The credential could not be delivered. "
6444  "Diagnostics: Failure to receive credential from manager daemon.",
6445  "/omp?cmd=get_credentials", response_data);
6446  return 1;
6447  }
6448  }
6449  else
6450  {
6451  entity_t credential_entity, key_entity = NULL;
6452 
6453  /* A key or certificate. */
6454 
6455  entity = NULL;
6456  if (read_entity_c (connection, &entity))
6457  {
6458  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6459  *html = gsad_message (credentials,
6460  "Internal error", __FUNCTION__, __LINE__,
6461  "An internal error occurred while getting a credential. "
6462  "The credential could not be delivered. "
6463  "Diagnostics: Failure to receive credential from manager daemon.",
6464  "/omp?cmd=get_credentials", response_data);
6465  return 1;
6466  }
6467 
6468  credential_entity = entity_child (entity, "credential");
6469  if (credential_entity)
6470  {
6471  if (strcmp (format, "pem") == 0)
6472  key_entity = entity_child (credential_entity, "certificate");
6473  else
6474  key_entity = entity_child (credential_entity, "public_key");
6475  }
6476  if (key_entity != NULL)
6477  {
6478  *html = g_strdup (entity_text (key_entity));
6479  if (login)
6480  {
6481  entity_t login_entity = entity_child (credential_entity, "login");
6482  if (login_entity)
6483  *login = g_strdup (entity_text (login_entity));
6484  else
6485  *login = NULL;
6486  }
6487  free_entity (entity);
6488  return 0;
6489  }
6490  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6491  *html = gsad_message (credentials,
6492  "Internal error", __FUNCTION__, __LINE__,
6493  "An internal error occurred while getting a credential. "
6494  "The credential could not be delivered. "
6495  "Diagnostics: Failure to parse credential from manager daemon.",
6496  "/omp?cmd=get_credentials", response_data);
6497  free_entity (entity);
6498  return 1;
6499  }
6500 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* download_key_pub ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  response_size,
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.
[in]response_sizeSize of cert.
[out]response_dataExtra data return for the HTTP response.
Returns
Certificate.

Definition at line 14876 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

14879 {
14880  const char *key_pub;
14881  char *unescaped;
14882 
14883  key_pub = params_value (params, "key_pub");
14884  if (key_pub == NULL)
14885  {
14886  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
14887  return gsad_message (credentials,
14888  "Internal error", __FUNCTION__, __LINE__,
14889  "An internal error occurred."
14890  " Diagnostics: key_pub was NULL.",
14891  "/omp?cmd=get_reports", response_data);
14892  }
14893 
14894  /* The Base64 comes URI escaped as it may contain special characters. */
14895  unescaped = g_uri_unescape_string (key_pub, NULL);
14896  *response_size = strlen (unescaped);
14897  return unescaped;
14898 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* download_ssl_cert ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  response_size,
cmd_response_data_t response_data 
)

Get an SSL Certificate.

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

Definition at line 14798 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

14801 {
14802  const char *ssl_cert;
14803  gchar *cert;
14804  char *unescaped;
14805 
14806  ssl_cert = params_value (params, "ssl_cert");
14807  if (ssl_cert == NULL)
14808  {
14809  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
14810  return gsad_message (credentials,
14811  "Internal error", __FUNCTION__, __LINE__,
14812  "An internal error occurred."
14813  " Diagnostics: ssl_cert was NULL.",
14814  "/omp?cmd=get_reports", response_data);
14815  }
14816  /* The Base64 comes URI escaped as it may contain special characters. */
14817  unescaped = g_uri_unescape_string (ssl_cert, NULL);
14818 
14819  cert = g_strdup_printf ("-----BEGIN CERTIFICATE-----\n"
14820  "%s\n-----END CERTIFICATE-----\n",
14821  unescaped);
14822 
14823  *response_size = strlen (cert);
14824 
14825  g_free (unescaped);
14826  return cert;
14827 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_agent ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_agent XML, XSL transform 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
Result of XSL transformation.

Definition at line 7259 of file gsad_omp.c.

References edit_resource().

Referenced by edit_agent_omp(), and exec_omp_get().

7262 {
7263  return edit_resource (connection, "agent", credentials, params, NULL,
7264  extra_xml, response_data);
7265 }
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_agent XML, XSL transform 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
Result of XSL transformation.

Definition at line 7278 of file gsad_omp.c.

References edit_agent().

7280 {
7281  return edit_agent (connection, credentials, params, NULL, response_data);
7282 }
char * edit_agent(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_agent XML, XSL transform the result.
Definition: gsad_omp.c:7259

Here is the call graph for this function:

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

Setup edit_alert XML, XSL transform 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
Result of XSL transformation.

Definition at line 8723 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_alert_omp(), and exec_omp_get().

8726 {
8727  GString *xml;
8728  gchar *edit;
8729  const char *alert_id, *next, *filter;
8730 
8731  alert_id = params_value (params, "alert_id");
8732  next = params_value (params, "next");
8733  filter = params_value (params, "filter");
8734 
8735  if (alert_id == NULL)
8736  {
8737  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
8738  return gsad_message (credentials,
8739  "Internal error", __FUNCTION__, __LINE__,
8740  "An internal error occurred while editing an alert. "
8741  "The alert remains as it was. "
8742  "Diagnostics: Required parameter alert_id was NULL.",
8743  "/omp?cmd=get_alerts", response_data);
8744  }
8745 
8746  if (next == NULL)
8747  next = "get_alerts";
8748 
8749  if (openvas_connection_sendf (connection,
8750  "<get_alerts"
8751  " alert_id=\"%s\""
8752  " details=\"1\"/>",
8753  alert_id)
8754  == -1)
8755  {
8756  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8757  return gsad_message (credentials,
8758  "Internal error", __FUNCTION__, __LINE__,
8759  "An internal error occurred while getting alert info. "
8760  "Diagnostics: Failure to send command to manager daemon.",
8761  "/omp?cmd=get_alerts", response_data);
8762  }
8763 
8764  xml = g_string_new ("<edit_alert>");
8765 
8766  if (extra_xml)
8767  g_string_append (xml, extra_xml);
8768 
8769  edit = g_markup_printf_escaped ("<alert id=\"%s\"/>"
8770  /* Page that follows. */
8771  "<next>%s</next>"
8772  /* Passthroughs. */
8773  "<filters><term>%s</term></filters>",
8774  alert_id,
8775  next,
8776  filter);
8777  g_string_append (xml, edit);
8778  g_free (edit);
8779 
8780  if (read_string_c (connection, &xml))
8781  {
8782  g_string_free (xml, TRUE);
8783  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8784  return gsad_message (credentials,
8785  "Internal error", __FUNCTION__, __LINE__,
8786  "An internal error occurred while getting alert info. "
8787  "Diagnostics: Failure to receive response from manager daemon.",
8788  "/omp?cmd=get_alerts", response_data);
8789  }
8790 
8791  if (command_enabled (credentials, "GET_REPORT_FORMATS"))
8792  {
8793  /* Get the report formats. */
8794 
8795  if (openvas_connection_sendf (connection,
8796  "<get_report_formats"
8797  " filter=\"rows=-1\"/>")
8798  == -1)
8799  {
8800  g_string_free (xml, TRUE);
8801  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8802  return gsad_message (credentials,
8803  "Internal error", __FUNCTION__, __LINE__,
8804  "An internal error occurred while getting report formats. "
8805  "The current list of report formats is not available. "
8806  "Diagnostics: Failure to send command to manager daemon.",
8807  "/omp?cmd=get_alerts", response_data);
8808  }
8809 
8810  if (read_string_c (connection, &xml))
8811  {
8812  g_string_free (xml, TRUE);
8813  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8814  return gsad_message (credentials,
8815  "Internal error", __FUNCTION__, __LINE__,
8816  "An internal error occurred while getting report formats. "
8817  "The current list of report formats is not available. "
8818  "Diagnostics: Failure to receive response from manager daemon.",
8819  "/omp?cmd=get_alerts", response_data);
8820  }
8821  }
8822 
8823  if (command_enabled (credentials, "GET_FILTERS"))
8824  {
8825  /* Get filters. */
8826 
8827  if (openvas_connection_sendf (connection,
8828  "<get_filters filter=\"rows=-1\"/>")
8829  == -1)
8830  {
8831  g_string_free (xml, TRUE);
8832  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8833  return gsad_message (credentials,
8834  "Internal error", __FUNCTION__, __LINE__,
8835  "An internal error occurred while getting the list "
8836  "of filters. "
8837  "The current list of filters is not available. "
8838  "Diagnostics: Failure to send command to manager daemon.",
8839  "/omp?cmd=get_alerts", response_data);
8840  }
8841 
8842  if (read_string_c (connection, &xml))
8843  {
8844  g_string_free (xml, TRUE);
8845  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8846  return gsad_message (credentials,
8847  "Internal error", __FUNCTION__, __LINE__,
8848  "An internal error occurred while getting the list "
8849  "of filters. "
8850  "The current list of filters is not available. "
8851  "Diagnostics: Failure to receive response from manager daemon.",
8852  "/omp?cmd=get_filters", response_data);
8853  }
8854  }
8855 
8856  if (command_enabled (credentials, "GET_TASKS"))
8857  {
8858  /* Get tasks. */
8859 
8860  if (openvas_connection_sendf (connection,
8861  "<get_tasks"
8862  " schedules_only=\"1\""
8863  " filter=\"owner=any permission=start_task"
8864  " rows=-1\"/>")
8865  == -1)
8866  {
8867  g_string_free (xml, TRUE);
8868  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8869  return gsad_message (credentials,
8870  "Internal error", __FUNCTION__, __LINE__,
8871  "An internal error occurred while getting the list "
8872  "of tasks. "
8873  "The current list of tasks is not available. "
8874  "Diagnostics: Failure to send command to manager daemon.",
8875  "/omp?cmd=get_alerts", response_data);
8876  }
8877 
8878  if (read_string_c (connection, &xml))
8879  {
8880  g_string_free (xml, TRUE);
8881  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8882  return gsad_message (credentials,
8883  "Internal error", __FUNCTION__, __LINE__,
8884  "An internal error occurred while getting the list "
8885  "of tasks. "
8886  "The current list of tasks is not available. "
8887  "Diagnostics: Failure to receive response from manager daemon.",
8888  "/omp?cmd=get_tasks", response_data);
8889  }
8890  }
8891 
8892  /* Get Credentials. */
8893 
8894  if (command_enabled (credentials, "GET_CREDENTIALS"))
8895  {
8896  if (openvas_connection_sendf (connection,
8897  "<get_credentials"
8898  " filter=\"type=up owner=any permission=any"
8899  " rows=-1\"/>")
8900  == -1)
8901  {
8902  g_string_free (xml, TRUE);
8903  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8904  return gsad_message (credentials,
8905  "Internal error", __FUNCTION__, __LINE__,
8906  "An internal error occurred while getting the list "
8907  "of credentials. "
8908  "The current list of tasks is not available. "
8909  "Diagnostics: Failure to send command to manager daemon.",
8910  "/omp?cmd=get_alerts", response_data);
8911  }
8912 
8913  if (read_string_c (connection, &xml))
8914  {
8915  g_string_free (xml, TRUE);
8916  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8917  return gsad_message (credentials,
8918  "Internal error", __FUNCTION__, __LINE__,
8919  "An internal error occurred while getting the list "
8920  "of credentials. "
8921  "The current list of tasks is not available. "
8922  "Diagnostics: Failure to receive response from manager daemon.",
8923  "/omp?cmd=get_tasks", response_data);
8924  }
8925  }
8926 
8927  /* Cleanup, and return transformed XML. */
8928 
8929  g_string_append (xml, "</edit_alert>");
8930  return xsl_transform_omp (connection, credentials, params,
8931  g_string_free (xml, FALSE), response_data);
8932 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_alert XML, XSL transform 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
Result of XSL transformation.

Definition at line 8945 of file gsad_omp.c.

References edit_alert().

8947 {
8948  return edit_alert (connection, credentials, params, NULL, response_data);
8949 }
char * edit_alert(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, XSL transform the result.
Definition: gsad_omp.c:8723

Here is the call graph for this function:

char* edit_asset ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit XML, XSL transform 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
Result of XSL transformation.

Definition at line 27315 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_asset_omp(), and exec_omp_get().

27318 {
27319  GString *xml;
27320  const char *asset_id;
27321  gchar *response;
27322  entity_t entity;
27323 
27324  asset_id = params_value (params, "asset_id");
27325  if (asset_id == NULL)
27326  {
27327  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27328  return gsad_message (credentials,
27329  "Internal error", __FUNCTION__, __LINE__,
27330  "An internal error occurred while editing a asset. "
27331  "The asset remains as it was. "
27332  "Diagnostics: Required ID parameter was NULL.",
27333  "/omp?cmd=get_tasks", response_data);
27334  }
27335 
27336  xml = g_string_new ("");
27337 
27338  g_string_append_printf (xml, "<edit_asset>");
27339 
27340  if (extra_xml)
27341  g_string_append (xml, extra_xml);
27342 
27343  response = NULL;
27344  entity = NULL;
27345  switch (ompf (connection, credentials,
27346  &response,
27347  &entity,
27348  response_data,
27349  "<get_assets"
27350  " type=\"host\""
27351  " asset_id=\"%s\""
27352  " details=\"1\"/>",
27353  asset_id))
27354  {
27355  case 0:
27356  case -1:
27357  break;
27358  case 1:
27359  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27360  g_string_free (xml, TRUE);
27361  return gsad_message (credentials,
27362  "Internal error", __FUNCTION__, __LINE__,
27363  "An internal error occurred while getting the asset. "
27364  "Diagnostics: Failure to send command to manager daemon.",
27365  "/omp?cmd=get_assets", response_data);
27366  case 2:
27367  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27368  g_string_free (xml, TRUE);
27369  return gsad_message (credentials,
27370  "Internal error", __FUNCTION__, __LINE__,
27371  "An internal error occurred while getting the asset. "
27372  "Diagnostics: Failure to receive response from manager daemon.",
27373  "/omp?cmd=get_assets", response_data);
27374  default:
27375  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27376  g_string_free (xml, TRUE);
27377  return gsad_message (credentials,
27378  "Internal error", __FUNCTION__, __LINE__,
27379  "An internal error occurred while getting the asset. "
27380  "Diagnostics: Internal Error.",
27381  "/omp?cmd=get_assets", response_data);
27382  }
27383 
27384  g_string_append (xml, response);
27385  g_string_append_printf (xml, "</edit_asset>");
27386  free_entity (entity);
27387  g_free (response);
27388  return xsl_transform_omp (connection, credentials, params,
27389  g_string_free (xml, FALSE), response_data);
27390 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_asset_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_asset XML, XSL transform 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
Result of XSL transformation.

Definition at line 27403 of file gsad_omp.c.

References edit_asset().

27406 {
27407  return edit_asset (connection, credentials, params, NULL, response_data);
27408 }
char * edit_asset(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, XSL transform the result.
Definition: gsad_omp.c:27315

Here is the call graph for this function:

char* edit_config_family_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get details of a family for editing a config, XSL transform 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 of XSL transformation.

Definition at line 12361 of file gsad_omp.c.

12364 {
12365  return get_config_family (connection, credentials, params, 1, response_data);
12366 }
char* edit_config_nvt_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Edit details of an NVT for a config, XSL transform 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
Result of XSL transformation.

Definition at line 12638 of file gsad_omp.c.

12641 {
12642  return get_config_nvt (connection, credentials, params, 1, response_data);
12643 }
char* edit_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a config, XSL transform 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
Result of XSL transformation.

Definition at line 11804 of file gsad_omp.c.

11806 {
11807  return edit_config (connection, credentials, params, NULL, response_data);
11808 }
char* edit_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_credential XML, XSL transform 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
Result of XSL transformation.

Definition at line 6661 of file gsad_omp.c.

6664 {
6665  return edit_credential (connection, credentials, params, NULL, response_data);
6666 }
char* edit_filter ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_filter XML, XSL transform 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
Result of XSL transformation.

Definition at line 24010 of file gsad_omp.c.

References edit_resource().

Referenced by edit_filter_omp(), and exec_omp_get().

24013 {
24014  return edit_resource (connection, "filter", credentials, params, NULL,
24015  extra_xml, response_data);
24016 }
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_filter XML, XSL transform 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
Result of XSL transformation.

Definition at line 24029 of file gsad_omp.c.

References edit_filter().

24031 {
24032  return edit_filter (connection, credentials, params, NULL, response_data);
24033 }
char * edit_filter(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_filter XML, XSL transform the result.
Definition: gsad_omp.c:24010

Here is the call graph for this function:

char* edit_group ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_group XML, XSL transform 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
Result of XSL transformation.

Definition at line 20384 of file gsad_omp.c.

References edit_resource().

Referenced by edit_group_omp(), and exec_omp_get().

20387 {
20388  return edit_resource (connection, "group", credentials, params, NULL,
20389  extra_xml, response_data);
20390 }
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_group XML, XSL transform 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
Result of XSL transformation.

Definition at line 20403 of file gsad_omp.c.

References edit_group().

20405 {
20406  return edit_group (connection, credentials, params, NULL, response_data);
20407 }
char * edit_group(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_group XML, XSL transform the result.
Definition: gsad_omp.c:20384

Here is the call graph for this function:

char* edit_my_settings_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
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.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 19125 of file gsad_omp.c.

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

19128 {
19129  return edit_my_settings (connection, credentials, params, NULL,
19130  response_data);
19131 }

Here is the call graph for this function:

char* edit_note ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Edit note, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 15664 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_note_omp(), and exec_omp_get().

15667 {
15668  GString *xml;
15669  const char *note_id;
15670 
15671  note_id = params_value (params, "note_id");
15672 
15673  if (openvas_connection_sendf (connection,
15674  "<get_notes"
15675  " note_id=\"%s\""
15676  " details=\"1\""
15677  " result=\"1\"/>",
15678  note_id)
15679  == -1)
15680  {
15681  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15682  return gsad_message (credentials,
15683  "Internal error", __FUNCTION__, __LINE__,
15684  "An internal error occurred while editing a note. "
15685  "The note remains as it was. "
15686  "Diagnostics: Failure to send command to manager daemon.",
15687  "/omp?cmd=get_notes", response_data);
15688  }
15689 
15690  xml = g_string_new ("");
15691 
15692  xml_string_append (xml, "<edit_note>");
15693 
15694  if (extra_xml)
15695  g_string_append (xml, extra_xml);
15696 
15697  if (read_string_c (connection, &xml))
15698  {
15699  g_string_free (xml, TRUE);
15700  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15701  return gsad_message (credentials,
15702  "Internal error", __FUNCTION__, __LINE__,
15703  "An internal error occurred while editing a note. "
15704  "The note remains as it was. "
15705  "Diagnostics: Failure to receive response from manager daemon.",
15706  "/omp?cmd=get_notes", response_data);
15707  }
15708 
15709  /* Cleanup, and return transformed XML. */
15710 
15711  g_string_append (xml, "</edit_note>");
15712  return xsl_transform_omp (connection, credentials, params,
15713  g_string_free (xml, FALSE), response_data);
15714 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Edit note, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 15727 of file gsad_omp.c.

References edit_note().

15729 {
15730  return edit_note (connection, credentials, params, NULL, response_data);
15731 }
char * edit_note(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit note, get next page, XSL transform the result.
Definition: gsad_omp.c:15664

Here is the call graph for this function:

char* edit_override ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Edit override, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 16377 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_override_omp(), and exec_omp_get().

16380 {
16381  GString *xml;
16382  const char *override_id;
16383 
16384  override_id = params_value (params, "override_id");
16385 
16386  if (openvas_connection_sendf (connection,
16387  "<get_overrides"
16388  " override_id=\"%s\""
16389  " details=\"1\""
16390  " result=\"1\"/>",
16391  override_id)
16392  == -1)
16393  {
16394  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16395  return gsad_message (credentials,
16396  "Internal error", __FUNCTION__, __LINE__,
16397  "An internal error occurred while editing an override. "
16398  "The override remains as it was. "
16399  "Diagnostics: Failure to send command to manager daemon.",
16400  "/omp?cmd=get_overrides", response_data);
16401  }
16402 
16403  xml = g_string_new ("");
16404 
16405  xml_string_append (xml, "<edit_override>");
16406 
16407  if (extra_xml)
16408  g_string_append (xml, extra_xml);
16409 
16410  if (read_string_c (connection, &xml))
16411  {
16412  g_string_free (xml, TRUE);
16413  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16414  return gsad_message (credentials,
16415  "Internal error", __FUNCTION__, __LINE__,
16416  "An internal error occurred while editing an override. "
16417  "The override remains as it was. "
16418  "Diagnostics: Failure to receive response from manager daemon.",
16419  "/omp?cmd=get_overrides", response_data);
16420  }
16421 
16422  /* Cleanup, and return transformed XML. */
16423 
16424  g_string_append (xml, "</edit_override>");
16425  return xsl_transform_omp (connection, credentials, params,
16426  g_string_free (xml, FALSE), response_data);
16427 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Edit override, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 16440 of file gsad_omp.c.

References edit_override().

16442 {
16443  return edit_override (connection, credentials, params, NULL, response_data);
16444 }
char * edit_override(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit override, get next page, XSL transform the result.
Definition: gsad_omp.c:16377

Here is the call graph for this function:

char* edit_permission ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_permission XML, XSL transform 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
Result of XSL transformation.

Definition at line 22026 of file gsad_omp.c.

References command_enabled(), edit_resource(), gsad_message(), and cmd_response_data_t::http_status_code.

Referenced by edit_permission_omp(), and exec_omp_get().

22029 {
22030  gchar *html;
22031  GString *extra;
22032 
22033  extra = g_string_new ("");
22034 
22035  if (command_enabled (credentials, "GET_USERS"))
22036  {
22037  gchar *response;
22038  entity_t entity;
22039 
22040  response = NULL;
22041  entity = NULL;
22042  switch (omp (connection, credentials, &response, &entity, response_data,
22043  "<get_users filter=\"rows=-1\"/>"))
22044  {
22045  case 0:
22046  case -1:
22047  break;
22048  case 1:
22049  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22050  return gsad_message (credentials,
22051  "Internal error", __FUNCTION__, __LINE__,
22052  "An internal error occurred getting the user list. "
22053  "No new user was created. "
22054  "Diagnostics: Failure to send command to manager daemon.",
22055  "/omp?cmd=get_users", response_data);
22056  case 2:
22057  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22058  return gsad_message (credentials,
22059  "Internal error", __FUNCTION__, __LINE__,
22060  "An internal error occurred getting the user list. "
22061  "No new user was created. "
22062  "Diagnostics: Failure to receive response from manager daemon.",
22063  "/omp?cmd=get_users", response_data);
22064  default:
22065  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22066  return gsad_message (credentials,
22067  "Internal error", __FUNCTION__, __LINE__,
22068  "An internal error occurred getting the user list. "
22069  "No new user was created. "
22070  "Diagnostics: Internal Error.",
22071  "/omp?cmd=get_users", response_data);
22072  }
22073 
22074  g_string_append (extra, response);
22075 
22076  free_entity (entity);
22077  g_free (response);
22078  }
22079 
22080  if (command_enabled (credentials, "GET_GROUPS"))
22081  {
22082  gchar *response;
22083  entity_t entity;
22084 
22085  response = NULL;
22086  entity = NULL;
22087  switch (omp (connection, credentials, &response, &entity, response_data,
22088  "<get_groups filter=\"rows=-1\"/>"))
22089  {
22090  case 0:
22091  case -1:
22092  break;
22093  case 1:
22094  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22095  return gsad_message (credentials,
22096  "Internal error", __FUNCTION__, __LINE__,
22097  "An internal error occurred getting the group list. "
22098  "No new user was created. "
22099  "Diagnostics: Failure to send command to manager daemon.",
22100  "/omp?cmd=get_users", response_data);
22101  case 2:
22102  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22103  return gsad_message (credentials,
22104  "Internal error", __FUNCTION__, __LINE__,
22105  "An internal error occurred getting the group list. "
22106  "No new user was created. "
22107  "Diagnostics: Failure to receive response from manager daemon.",
22108  "/omp?cmd=get_users", response_data);
22109  default:
22110  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22111  return gsad_message (credentials,
22112  "Internal error", __FUNCTION__, __LINE__,
22113  "An internal error occurred getting the group list. "
22114  "No new user was created. "
22115  "Diagnostics: Internal Error.",
22116  "/omp?cmd=get_users", response_data);
22117  }
22118 
22119  g_string_append (extra, response);
22120 
22121  free_entity (entity);
22122  g_free (response);
22123  }
22124 
22125  if (command_enabled (credentials, "GET_ROLES"))
22126  {
22127  gchar *response;
22128  entity_t entity;
22129 
22130  response = NULL;
22131  entity = NULL;
22132  switch (omp (connection, credentials, &response, &entity, response_data,
22133  "<get_roles filter=\"rows=-1\"/>"))
22134  {
22135  case 0:
22136  case -1:
22137  break;
22138  case 1:
22139  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22140  return gsad_message (credentials,
22141  "Internal error", __FUNCTION__, __LINE__,
22142  "An internal error occurred getting the role list. "
22143  "No new user was created. "
22144  "Diagnostics: Failure to send command to manager daemon.",
22145  "/omp?cmd=get_users", response_data);
22146  case 2:
22147  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22148  return gsad_message (credentials,
22149  "Internal error", __FUNCTION__, __LINE__,
22150  "An internal error occurred getting the role list. "
22151  "No new user was created. "
22152  "Diagnostics: Failure to receive response from manager daemon.",
22153  "/omp?cmd=get_users", response_data);
22154  default:
22155  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22156  return gsad_message (credentials,
22157  "Internal error", __FUNCTION__, __LINE__,
22158  "An internal error occurred getting the role list. "
22159  "No new user was created. "
22160  "Diagnostics: Internal Error.",
22161  "/omp?cmd=get_users", response_data);
22162  }
22163 
22164  g_string_append (extra, response);
22165 
22166  free_entity (entity);
22167  g_free (response);
22168  }
22169 
22170  if (extra_xml)
22171  g_string_append (extra, extra_xml);
22172  html = edit_resource (connection, "permission", credentials, params, NULL,
22173  extra->str, response_data);
22174  g_string_free (extra, TRUE);
22175  return html;
22176 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_permission XML, XSL transform 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
Result of XSL transformation.

Definition at line 22189 of file gsad_omp.c.

References edit_permission().

22192 {
22193  return edit_permission (connection, credentials, params, NULL, response_data);
22194 }
char * edit_permission(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_permission XML, XSL transform the result.
Definition: gsad_omp.c:22026

Here is the call graph for this function:

char* edit_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_port_list XML, XSL transform 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
Result of XSL transformation.

Definition at line 22782 of file gsad_omp.c.

22785 {
22786  return edit_port_list (connection, credentials, params, NULL, response_data);
22787 }
char* edit_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_report_format XML, XSL transform 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
Result of XSL transformation.

Definition at line 18134 of file gsad_omp.c.

18137 {
18138  return edit_report_format (connection, credentials, params, NULL,
18139  response_data);
18140 }
char* edit_resource ( openvas_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, XSL transform 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
Result of XSL transformation.

Definition at line 2498 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by create_role_omp(), delete_report_format_omp(), edit_agent(), edit_filter(), edit_group(), edit_permission(), edit_schedule(), edit_user(), new_credential_omp(), and new_port_list_omp().

2502 {
2503  GString *xml;
2504  gchar *id_name;
2505  const char *resource_id;
2506 
2507  id_name = g_strdup_printf ("%s_id", type);
2508  resource_id = params_value (params, id_name);
2509  g_free (id_name);
2510 
2511  if (resource_id == NULL)
2512  {
2513  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
2514  return gsad_message (credentials,
2515  "Internal error", __FUNCTION__, __LINE__,
2516  "An internal error occurred while editing a resource. "
2517  "The resource remains as it was. "
2518  "Diagnostics: Required ID parameter was NULL.",
2519  "/omp?cmd=get_tasks", response_data);
2520  }
2521 
2522  if (openvas_connection_sendf (connection,
2523  /* TODO: Remove redundant COMMANDS. */
2524  "<commands>"
2525  "<get_%ss"
2526  " %s"
2527  " %s_id=\"%s\""
2528  " details=\"1\"/>"
2529  "</commands>",
2530  type,
2531  extra_get_attribs ? extra_get_attribs : "",
2532  type,
2533  resource_id)
2534  == -1)
2535  {
2536  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2537  return gsad_message (credentials,
2538  "Internal error", __FUNCTION__, __LINE__,
2539  "An internal error occurred while getting a resource. "
2540  "Diagnostics: Failure to send command to manager daemon.",
2541  "/omp?cmd=get_tasks", response_data);
2542  }
2543 
2544  xml = g_string_new ("");
2545 
2546  g_string_append_printf (xml, "<edit_%s>", type);
2547 
2548  if (extra_xml)
2549  g_string_append (xml, extra_xml);
2550 
2551  if (read_string_c (connection, &xml))
2552  {
2553  g_string_free (xml, TRUE);
2554  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2555  return gsad_message (credentials,
2556  "Internal error", __FUNCTION__, __LINE__,
2557  "An internal error occurred while getting a resource. "
2558  "Diagnostics: Failure to receive response from manager daemon.",
2559  "/omp?cmd=get_tasks", response_data);
2560  }
2561 
2562  /* Cleanup, and return transformed XML. */
2563 
2564  g_string_append_printf (xml, "</edit_%s>", type);
2565  return xsl_transform_omp (connection, credentials, params,
2566  g_string_free (xml, FALSE), response_data);
2567 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_role XML, XSL transform 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
Result of XSL transformation.

Definition at line 23305 of file gsad_omp.c.

References get_one(), and params_t.

23308 {
23309  return edit_role (connection, credentials, params, NULL, response_data);
23310 }

Here is the call graph for this function:

char* edit_scanner ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_scanner XML, XSL transform 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
Result of XSL transformation.

Definition at line 17026 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_scanner_omp(), and exec_omp_get().

17029 {
17030  GString *xml;
17031  const char *scanner_id, *next;
17032 
17033  scanner_id = params_value (params, "scanner_id");
17034  next = params_value (params, "next");
17035 
17036  if (scanner_id == NULL)
17037  {
17038  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
17039  return gsad_message (credentials,
17040  "Internal error", __FUNCTION__, __LINE__,
17041  "An internal error occurred while editing a scanner. "
17042  "The scanner remains as it was. "
17043  "Diagnostics: Required parameter was NULL.",
17044  "/omp?cmd=get_tasks", response_data);
17045  }
17046 
17047  if (next == NULL)
17048  next = "get_scanner";
17049 
17050  if (openvas_connection_sendf (connection,
17051  "<commands>"
17052  "<get_scanners scanner_id=\"%s\" details=\"1\" />"
17053  "<get_credentials filter=\"first=1 rows=-1\" />"
17054  "</commands>",
17055  scanner_id)
17056  == -1)
17057  {
17058  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17059  return gsad_message (credentials,
17060  "Internal error", __FUNCTION__, __LINE__,
17061  "An internal error occurred while getting scanner info. "
17062  "Diagnostics: Failure to send command to manager daemon.",
17063  "/omp?cmd=get_tasks", response_data);
17064  }
17065 
17066  xml = g_string_new ("");
17067 
17068  if (extra_xml)
17069  g_string_append (xml, extra_xml);
17070 
17071  g_string_append_printf (xml,
17072  "<edit_scanner>"
17073  "<scanner id=\"%s\"/>"
17074  /* Page that follows. */
17075  "<next>%s</next>",
17076  scanner_id,
17077  next);
17078 
17079  if (read_string_c (connection, &xml))
17080  {
17081  g_string_free (xml, TRUE);
17082  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17083  return gsad_message (credentials,
17084  "Internal error", __FUNCTION__, __LINE__,
17085  "An internal error occurred while getting scanner info. "
17086  "Diagnostics: Failure to receive response from manager daemon.",
17087  "/omp?cmd=get_tasks", response_data);
17088  }
17089 
17090  /* Cleanup, and return transformed XML. */
17091 
17092  g_string_append (xml, "</edit_scanner>");
17093  return xsl_transform_omp (connection, credentials, params,
17094  g_string_free (xml, FALSE), response_data);
17095 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_scanner XML, XSL transform 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
Result of XSL transformation.

Definition at line 17108 of file gsad_omp.c.

References edit_scanner().

17110 {
17111  return edit_scanner (connection, credentials, params, NULL, response_data);
17112 }
char * edit_scanner(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_scanner XML, XSL transform the result.
Definition: gsad_omp.c:17026

Here is the call graph for this function:

char* edit_schedule ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_schedule XML, XSL transform 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
Result of XSL transformation.

Definition at line 24202 of file gsad_omp.c.

References edit_resource().

Referenced by edit_schedule_omp(), and exec_omp_get().

24205 {
24206  return edit_resource (connection, "schedule", credentials, params,
24207  "tasks=\"1\"", extra_xml, response_data);
24208 }
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_schedule XML, XSL transform 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
Result of XSL transformation.

Definition at line 24221 of file gsad_omp.c.

References edit_schedule().

24224 {
24225  return edit_schedule (connection, credentials, params, NULL, response_data);
24226 }
char * edit_schedule(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_schedule XML, XSL transform the result.
Definition: gsad_omp.c:24202

Here is the call graph for this function:

char* edit_tag ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_tag XML, XSL transform 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
Result of XSL transformation.

Definition at line 10280 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_tag_omp(), and exec_omp_get().

10283 {
10284  GString *xml;
10285  gchar *edit;
10286  const char *tag_id;
10287 
10288  tag_id = params_value (params, "tag_id");
10289  if (tag_id == NULL)
10290  {
10291  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10292  return gsad_message (credentials,
10293  "Internal error", __FUNCTION__, __LINE__,
10294  "An internal error occurred while editing a tag. "
10295  "The tag remains as it was. "
10296  "Diagnostics: Required parameter was NULL.",
10297  "/omp?cmd=get_tags", response_data);
10298  }
10299 
10300  if (openvas_connection_sendf (connection,
10301  "<get_tags"
10302  " tag_id=\"%s\""
10303  "/>",
10304  tag_id)
10305  == -1)
10306  {
10307  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10308  return gsad_message (credentials,
10309  "Internal error", __FUNCTION__, __LINE__,
10310  "An internal error occurred while getting tag info. "
10311  "Diagnostics: Failure to send command to manager daemon.",
10312  "/omp?cmd=get_tags", response_data);
10313  }
10314 
10315  xml = g_string_new ("");
10316 
10317  edit = g_markup_printf_escaped ("<edit_tag>"
10318  "<tag id=\"%s\"/>",
10319  tag_id);
10320 
10321  g_string_append (xml, edit);
10322  g_free (edit);
10323 
10324  if (extra_xml)
10325  g_string_append (xml, extra_xml);
10326 
10327  if (read_string_c (connection, &xml))
10328  {
10329  g_string_free (xml, TRUE);
10330  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10331  return gsad_message (credentials,
10332  "Internal error", __FUNCTION__, __LINE__,
10333  "An internal error occurred while getting target info. "
10334  "Diagnostics: Failure to receive response from manager daemon.",
10335  "/omp?cmd=get_tags", response_data);
10336  }
10337 
10338  /* Cleanup, and return transformed XML. */
10339 
10340  g_string_append (xml, "</edit_tag>");
10341  return xsl_transform_omp (connection, credentials, params,
10342  g_string_free (xml, FALSE), response_data);
10343 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_tag XML, XSL transform 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
Result of XSL transformation.

Definition at line 10356 of file gsad_omp.c.

References edit_tag().

10358 {
10359  return edit_tag (connection, credentials, params, NULL, response_data);
10360 }
char * edit_tag(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
Definition: gsad_omp.c:10280

Here is the call graph for this function:

char* edit_target ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_target XML, XSL transform 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
Result of XSL transformation.

Definition at line 10692 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by edit_target_omp(), and exec_omp_get().

10695 {
10696  GString *xml;
10697  gchar *edit;
10698  const char *target_id, *next, *filter, *first, *max;
10699 
10700  target_id = params_value (params, "target_id");
10701  filter = params_value (params, "filter");
10702  first = params_value (params, "first");
10703  max = params_value (params, "max");
10704  next = params_value (params, "next");
10705 
10706  if (target_id == NULL)
10707  {
10708  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10709  return gsad_message (credentials,
10710  "Internal error", __FUNCTION__, __LINE__,
10711  "An internal error occurred while editing a target. "
10712  "The target remains as it was. "
10713  "Diagnostics: Required parameter was NULL.",
10714  "/omp?cmd=get_targets", response_data);
10715  }
10716 
10717  if (next == NULL)
10718  next = "get_target";
10719 
10720  if (openvas_connection_sendf (connection,
10721  "<get_targets"
10722  " target_id=\"%s\""
10723  " details=\"1\"/>",
10724  target_id)
10725  == -1)
10726  {
10727  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10728  return gsad_message (credentials,
10729  "Internal error", __FUNCTION__, __LINE__,
10730  "An internal error occurred while getting target info. "
10731  "Diagnostics: Failure to send command to manager daemon.",
10732  "/omp?cmd=get_targets", response_data);
10733  }
10734 
10735  xml = g_string_new ("");
10736 
10737  if (extra_xml)
10738  g_string_append (xml, extra_xml);
10739 
10740 
10741  edit = g_markup_printf_escaped ("<edit_target>"
10742  "<target id=\"%s\"/>"
10743  /* Page that follows. */
10744  "<next>%s</next>"
10745  /* Passthroughs. */
10746  "<filters><term>%s</term></filters>"
10747  "<targets start=\"%s\" max=\"%s\"/>",
10748  target_id,
10749  next,
10750  filter,
10751  first,
10752  max);
10753  g_string_append (xml, edit);
10754  g_free (edit);
10755 
10756  if (read_string_c (connection, &xml))
10757  {
10758  g_string_free (xml, TRUE);
10759  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10760  return gsad_message (credentials,
10761  "Internal error", __FUNCTION__, __LINE__,
10762  "An internal error occurred while getting target info. "
10763  "Diagnostics: Failure to receive response from manager daemon.",
10764  "/omp?cmd=get_targets", response_data);
10765  }
10766 
10767  if (command_enabled (credentials, "GET_CREDENTIALS"))
10768  {
10769  /* Get the credentials. */
10770 
10771  if (openvas_connection_sendf (connection,
10772  "<get_credentials"
10773  " filter=\"rows=-1 sort=name\"/>")
10774  == -1)
10775  {
10776  g_string_free (xml, TRUE);
10777  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10778  return gsad_message (credentials,
10779  "Internal error", __FUNCTION__, __LINE__,
10780  "An internal error occurred while getting targets list. "
10781  "The current list of targets is not available. "
10782  "Diagnostics: Failure to send command to manager daemon.",
10783  "/omp?cmd=get_targets", response_data);
10784  }
10785 
10786  if (read_string_c (connection, &xml))
10787  {
10788  g_string_free (xml, TRUE);
10789  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10790  return gsad_message (credentials,
10791  "Internal error", __FUNCTION__, __LINE__,
10792  "An internal error occurred while getting targets list. "
10793  "The current list of targets is not available. "
10794  "Diagnostics: Failure to receive response from manager daemon.",
10795  "/omp?cmd=get_targets", response_data);
10796  }
10797  }
10798 
10799  if (command_enabled (credentials, "GET_PORT_LISTS"))
10800  {
10801  /* Get the port lists. */
10802 
10803  if (openvas_connection_sendf (connection,
10804  "<get_port_lists"
10805  " filter=\"rows=-1 sort=name\"/>")
10806  == -1)
10807  {
10808  g_string_free (xml, TRUE);
10809  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10810  return gsad_message (credentials,
10811  "Internal error", __FUNCTION__, __LINE__,
10812  "An internal error occurred while getting targets list. "
10813  "The current list of targets is not available. "
10814  "Diagnostics: Failure to send command to manager daemon.",
10815  "/omp?cmd=get_tasks", response_data);
10816  }
10817 
10818  if (read_string_c (connection, &xml))
10819  {
10820  g_string_free (xml, TRUE);
10821  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10822  return gsad_message (credentials,
10823  "Internal error", __FUNCTION__, __LINE__,
10824  "An internal error occurred while getting targets list. "
10825  "The current list of targets is not available. "
10826  "Diagnostics: Failure to receive response from manager daemon.",
10827  "/omp?cmd=get_tasks", response_data);
10828  }
10829  }
10830 
10831  /* Cleanup, and return transformed XML. */
10832 
10833  g_string_append (xml, "</edit_target>");
10834  return xsl_transform_omp (connection, credentials, params,
10835  g_string_free (xml, FALSE), response_data);
10836 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_target XML, XSL transform 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
Result of XSL transformation.

Definition at line 10849 of file gsad_omp.c.

References edit_target(), get_one(), and params_t.

10851 {
10852  return edit_target (connection, credentials, params, NULL, response_data);
10853 }
char * edit_target(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_target XML, XSL transform the result.
Definition: gsad_omp.c:10692

Here is the call graph for this function:

char* edit_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_task XML, XSL transform 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
Result of XSL transformation.

Definition at line 4622 of file gsad_omp.c.

4624 {
4625  return edit_task (connection, credentials, params, NULL, response_data);
4626 }
char* edit_user ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup edit_user XML, XSL transform 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
Result of XSL transformation.

Definition at line 25044 of file gsad_omp.c.

References command_enabled(), edit_resource(), gsad_message(), and cmd_response_data_t::http_status_code.

Referenced by edit_user_omp(), and exec_omp_get().

25047 {
25048  gchar *html;
25049  GString *extra;
25050 
25051  extra = g_string_new ("");
25052  if (command_enabled (credentials, "DESCRIBE_AUTH"))
25053  {
25054  gchar *response;
25055  entity_t entity;
25056 
25057  response = NULL;
25058  entity = NULL;
25059  switch (omp (connection, credentials, &response, &entity, response_data,
25060  "<describe_auth/>"))
25061  {
25062  case 0:
25063  case -1:
25064  break;
25065  case 1:
25066  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25067  return gsad_message (credentials,
25068  "Internal error", __FUNCTION__, __LINE__,
25069  "An internal error occurred getting the auth list. "
25070  "Diagnostics: Failure to send command to manager daemon.",
25071  "/omp?cmd=get_users", response_data);
25072  case 2:
25073  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25074  return gsad_message (credentials,
25075  "Internal error", __FUNCTION__, __LINE__,
25076  "An internal error occurred getting the auth list. "
25077  "Diagnostics: Failure to receive response from manager daemon.",
25078  "/omp?cmd=get_users", response_data);
25079  default:
25080  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25081  return gsad_message (credentials,
25082  "Internal error", __FUNCTION__, __LINE__,
25083  "An internal error occurred getting the auth list. "
25084  "Diagnostics: Internal Error.",
25085  "/omp?cmd=get_users", response_data);
25086  }
25087 
25088  g_string_append (extra, response);
25089 
25090  free_entity (entity);
25091  g_free (response);
25092  }
25093 
25094  if (command_enabled (credentials, "GET_GROUPS"))
25095  {
25096  gchar *response;
25097  entity_t entity;
25098 
25099  response = NULL;
25100  entity = NULL;
25101  switch (omp (connection, credentials, &response, &entity, response_data,
25102  "<get_groups filter=\"permission=modify_group\"/>"))
25103  {
25104  case 0:
25105  case -1:
25106  break;
25107  case 1:
25108  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25109  return gsad_message (credentials,
25110  "Internal error", __FUNCTION__, __LINE__,
25111  "An internal error occurred getting the group list. "
25112  "Diagnostics: Failure to send command to manager daemon.",
25113  "/omp?cmd=get_users", response_data);
25114  case 2:
25115  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25116  return gsad_message (credentials,
25117  "Internal error", __FUNCTION__, __LINE__,
25118  "An internal error occurred getting the group list. "
25119  "Diagnostics: Failure to receive response from manager daemon.",
25120  "/omp?cmd=get_users", response_data);
25121  default:
25122  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25123  return gsad_message (credentials,
25124  "Internal error", __FUNCTION__, __LINE__,
25125  "An internal error occurred getting the group list. "
25126  "Diagnostics: Internal Error.",
25127  "/omp?cmd=get_users", response_data);
25128  }
25129 
25130  g_string_append (extra, response);
25131 
25132  free_entity (entity);
25133  g_free (response);
25134  }
25135 
25136  if (command_enabled (credentials, "GET_ROLES"))
25137  {
25138  gchar *response;
25139  entity_t entity;
25140 
25141  response = NULL;
25142  entity = NULL;
25143  switch (omp (connection, credentials, &response, &entity, response_data,
25144  "<get_roles/>"))
25145  {
25146  case 0:
25147  case -1:
25148  break;
25149  case 1:
25150  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25151  return gsad_message (credentials,
25152  "Internal error", __FUNCTION__, __LINE__,
25153  "An internal error occurred getting the role list. "
25154  "No new user was created. "
25155  "Diagnostics: Failure to send command to manager daemon.",
25156  "/omp?cmd=get_users", response_data);
25157  case 2:
25158  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25159  return gsad_message (credentials,
25160  "Internal error", __FUNCTION__, __LINE__,
25161  "An internal error occurred getting the role list. "
25162  "No new user was created. "
25163  "Diagnostics: Failure to receive response from manager daemon.",
25164  "/omp?cmd=get_users", response_data);
25165  default:
25166  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25167  return gsad_message (credentials,
25168  "Internal error", __FUNCTION__, __LINE__,
25169  "An internal error occurred getting the role list. "
25170  "No new user was created. "
25171  "Diagnostics: Internal Error.",
25172  "/omp?cmd=get_users", response_data);
25173  }
25174 
25175  g_string_append (extra, response);
25176 
25177  free_entity (entity);
25178  g_free (response);
25179  }
25180 
25181  if (extra_xml)
25182  g_string_append (extra, extra_xml);
25183  html = edit_resource (connection, "user", credentials, params, NULL,
25184  extra->str, response_data);
25185  g_string_free (extra, TRUE);
25186  return html;
25187 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
char * edit_resource(openvas_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, XSL transform the result.
Definition: gsad_omp.c:2498
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* edit_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_user XML, XSL transform 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
Result of XSL transformation.

Definition at line 25200 of file gsad_omp.c.

References edit_user().

25202 {
25203  return edit_user (connection, credentials, params, NULL, response_data);
25204 }
char * edit_user(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
Definition: gsad_omp.c:25044

Here is the call graph for this function:

char* empty_trashcan_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Empty the trashcan, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 10011 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

10014 {
10015  GString *xml;
10016  const char* no_redirect;
10017  gchar *ret;
10018  entity_t entity;
10019 
10020  no_redirect = params_value (params, "no_redirect");
10021 
10022  xml = g_string_new ("");
10023 
10024  /* Empty the trash. */
10025 
10026  if (openvas_connection_sendf (connection,
10027  "<empty_trashcan/>")
10028  == -1)
10029  {
10030  g_string_free (xml, TRUE);
10031  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10032  return gsad_message (credentials,
10033  "Internal error", __FUNCTION__, __LINE__,
10034  "An internal error occurred while emptying the trashcan. "
10035  "Diagnostics: Failure to send command to manager daemon.",
10036  "/omp?cmd=get_trash", response_data);
10037  }
10038 
10039  if (read_entity_and_string_c (connection, &entity, &xml))
10040  {
10041  g_string_free (xml, TRUE);
10042  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10043  return gsad_message (credentials,
10044  "Internal error", __FUNCTION__, __LINE__,
10045  "An internal error occurred while emptying the trashcan. "
10046  "Diagnostics: Failure to read response from manager daemon.",
10047  "/omp?cmd=get_trash", response_data);
10048  }
10049 
10050  /* Cleanup, and return trash page. */
10051 
10052  ret = response_from_entity (connection, credentials, params, entity,
10053  (no_redirect && strcmp (no_redirect, "0")),
10054  NULL, "get_trash",
10055  NULL, "get_trash",
10056  "Empty Trashcan", response_data);
10057  free_entity (entity);
10058  g_string_free (xml, FALSE);
10059  return ret;
10060 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* export_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a agent.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Agent XML on success. HTML result of XSL transformation on error.

Definition at line 7554 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

7558 {
7559  return export_resource (connection, "agent", credentials, params,
7560  content_type, content_disposition, content_length,
7561  response_data);
7562 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_agents_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Agents XML on success. HTML result of XSL transformation on error.

Definition at line 7579 of file gsad_omp.c.

Referenced by exec_omp_get().

7583 {
7584  return export_many (connection, "agent", credentials, params, content_type,
7585  content_disposition, content_length, response_data);
7586 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export an alert.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Alert XML on success. HTML result of XSL transformation on error.

Definition at line 9185 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

9189 {
9190  return export_resource (connection, "alert", credentials, params,
9191  content_type, content_disposition, content_length,
9192  response_data);
9193 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_alerts_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Alerts XML on success. HTML result of XSL transformation on error.

Definition at line 9210 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, PARAM_OR_SETTING, params_t, and params_value().

Referenced by exec_omp_get().

9214 {
9215  return export_many (connection, "alert", credentials, params, content_type,
9216  content_disposition, content_length, response_data);
9217 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_asset_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export an asset.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Asset XML on success. HTML result of XSL transformation on error.

Definition at line 27269 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

27273 {
27274  return export_resource (connection, "asset", credentials, params,
27275  content_type, content_disposition, content_length,
27276  response_data);
27277 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_assets_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Assets XML on success. HTML result of XSL transformation on error.

Definition at line 27294 of file gsad_omp.c.

Referenced by exec_omp_get().

27298 {
27299  return export_many (connection, "asset", credentials, params, content_type,
27300  content_disposition, content_length, response_data);
27301 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a config.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent dispositions return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Config XML on success. HTML result of XSL transformation on error.

Definition at line 12900 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

12904 {
12905  return export_resource (connection, "config", credentials, params,
12906  content_type, content_disposition, content_length,
12907  response_data);
12908 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_configs_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Scan configs XML on success. HTML result of XSL transformation on error.

Definition at line 12925 of file gsad_omp.c.

Referenced by exec_omp_get().

12929 {
12930  return export_many (connection, "config", credentials, params, content_type,
12931  content_disposition, content_length, response_data);
12932 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a Credential.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Credential XML on success. HTML result of XSL transformation on error.

Definition at line 6517 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

6522 {
6523  return export_resource (connection, "credential", credentials, params,
6524  content_type, content_disposition, content_length,
6525  response_data);
6526 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_credentials_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Credentials XML on success. HTML result of XSL transformation on error.

Definition at line 6543 of file gsad_omp.c.

References params_t.

Referenced by exec_omp_get().

6548 {
6549  return export_many (connection, "credential", credentials, params,
6550  content_type, content_disposition, content_length,
6551  response_data);
6552 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a filter.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Filter XML on success. HTML result of XSL transformation on error.

Definition at line 24049 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

24053 {
24054  return export_resource (connection, "filter", credentials, params,
24055  content_type, content_disposition, content_length,
24056  response_data);
24057 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_filters_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Filters XML on success. HTML result of XSL transformation on error.

Definition at line 24074 of file gsad_omp.c.

Referenced by exec_omp_get().

24078 {
24079  return export_many (connection, "filter", credentials, params, content_type,
24080  content_disposition, content_length, response_data);
24081 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a group.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Group XML on success. HTML result of XSL transformation on error.

Definition at line 20423 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

20427 {
20428  return export_resource (connection, "group", credentials, params,
20429  content_type, content_disposition, content_length,
20430  response_data);
20431 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_groups_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Groups XML on success. HTML result of XSL transformation on error.

Definition at line 20448 of file gsad_omp.c.

Referenced by exec_omp_get().

20452 {
20453  return export_many (connection, "group", credentials, params, content_type,
20454  content_disposition, content_length, response_data);
20455 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a note.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. HTML result of XSL transformation on error.

Definition at line 12948 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

12952 {
12953  return export_resource (connection, "note", credentials, params, content_type,
12954  content_disposition, content_length, response_data);
12955 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_notes_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Notes XML on success. HTML result of XSL transformation on error.

Definition at line 12972 of file gsad_omp.c.

Referenced by exec_omp_get().

12976 {
12977  return export_many (connection, "note", credentials, params, content_type,
12978  content_disposition, content_length, response_data);
12979 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_omp_doc_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Download the OMP doc.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
XML on success. HTML result of XSL transformation on error.

Definition at line 20023 of file gsad_omp.c.

References get_one(), GSAD_CONTENT_TYPE_APP_XML, gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

Referenced by exec_omp_get().

20028 {
20029  entity_t entity, response;
20030  char *content = NULL;
20031  const char *format;
20032  time_t now;
20033  struct tm *tm;
20034 
20035  *content_length = 0;
20036 
20037  format = params_value (params, "protocol_format")
20038  ? params_value (params, "protocol_format")
20039  : "xml";
20040 
20041  if (openvas_connection_sendf (connection,
20042  "<help format=\"%s\"/>",
20043  format)
20044  == -1)
20045  {
20046  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20047  return gsad_message (credentials,
20048  "Internal error", __FUNCTION__, __LINE__,
20049  "An internal error occurred while getting a list. "
20050  "The list could not be delivered. "
20051  "Diagnostics: Failure to send command to manager daemon.",
20052  "/omp?cmd=get_protocol_doc", response_data);
20053  }
20054 
20055  response = NULL;
20056  if (read_entity_and_text_c (connection, &response, &content))
20057  {
20058  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20059  return gsad_message (credentials,
20060  "Internal error", __FUNCTION__, __LINE__,
20061  "An internal error occurred while getting OMP doc. "
20062  "Diagnostics: Failure to receive response from manager daemon.",
20063  "/omp?cmd=get_protocol_doc", response_data);
20064  }
20065 
20066  if (strcmp (format, "xml") == 0)
20067  *content_length = strlen (content);
20068  else
20069  {
20070  char *content_64;
20071  entity = entity_child (response, "schema");
20072  if (entity == NULL)
20073  {
20074  free_entity (response);
20075  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20076  return gsad_message (credentials,
20077  "Internal error", __FUNCTION__, __LINE__,
20078  "An internal error occurred while getting OMP doc. "
20079  "Diagnostics: Schema element missing.",
20080  "/omp?cmd=get_protocol_doc", response_data);
20081  }
20082 
20083  content_64 = entity_text (entity);
20084  if (strlen (content_64) == 0)
20085  {
20086  free_entity (response);
20087  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20088  return gsad_message (credentials,
20089  "Internal error", __FUNCTION__, __LINE__,
20090  "An internal error occurred while getting OMP doc. "
20091  "Diagnostics: Schema empty.",
20092  "/omp?cmd=get_protocol_doc", response_data);
20093  }
20094 
20095  content = (char *) g_base64_decode (content_64, content_length);
20096  }
20097 
20098  now = time (NULL);
20099  tm = localtime (&now);
20101  *content_disposition = g_strdup_printf ("attachment;"
20102  " filename=\"omp-%d-%d-%d.%s\"",
20103  tm->tm_mday,
20104  tm->tm_mon + 1,
20105  tm->tm_year +1900,
20106  format);
20107  free_entity (response);
20108  return content;
20109 }
content_type
Content types.
Definition: gsad_base.h:120
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export an override.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Override XML on success. HTML result of XSL transformation on error.

Definition at line 12995 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13000 {
13001  return export_resource (connection, "override", credentials, params,
13002  content_type, content_disposition, content_length,
13003  response_data);
13004 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_overrides_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Overrides XML on success. HTML result of XSL transformation on error.

Definition at line 13021 of file gsad_omp.c.

Referenced by exec_omp_get().

13026 {
13027  return export_many (connection, "override", credentials, params, content_type,
13028  content_disposition, content_length, response_data);
13029 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a permission.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Permission XML on success. HTML result of XSL transformation on error.

Definition at line 22210 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

22215 {
22216  return export_resource (connection, "permission", credentials, params,
22217  content_type, content_disposition, content_length,
22218  response_data);
22219 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_permissions_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Permissions XML on success. HTML result of XSL transformation on error.

Definition at line 22236 of file gsad_omp.c.

Referenced by exec_omp_get().

22241 {
22242  return export_many (connection, "permission", credentials, params,
22243  content_type, content_disposition, content_length,
22244  response_data);
22245 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Port List XML on success. HTML result of XSL transformation on error.

Definition at line 13046 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13051 {
13052  return export_resource (connection, "port_list", credentials, params,
13053  content_type, content_disposition, content_length,
13054  response_data);
13055 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_port_lists_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Port Lists XML on success. HTML result of XSL transformation on error.

Definition at line 13072 of file gsad_omp.c.

Referenced by exec_omp_get().

13077 {
13078  return export_many (connection, "port_list", credentials, params,
13079  content_type, content_disposition, content_length,
13080  response_data);
13081 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_preference_file_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent dispositions return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Config XML on success. HTML result of XSL transformation on error.

Definition at line 13097 of file gsad_omp.c.

References GSAD_CONTENT_TYPE_OCTET_STREAM, gsad_message(), GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get().

13102 {
13103  GString *xml;
13104  entity_t entity, preference_entity, value_entity;
13105  const char *config_id, *oid, *preference_name;
13106 
13107  *content_length = 0;
13108 
13109  config_id = params_value (params, "config_id");
13110  oid = params_value (params, "oid");
13111  preference_name = params_value (params, "preference_name");
13112 
13113  xml = g_string_new ("<get_preferences_response>");
13114 
13115  if (config_id == NULL || oid == NULL || preference_name == NULL)
13116  g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Export Preference File"));
13117  else
13118  {
13119  if (openvas_connection_sendf (connection,
13120  "<get_preferences"
13121  " config_id=\"%s\""
13122  " nvt_oid=\"%s\""
13123  " preference=\"%s\"/>",
13124  config_id,
13125  oid,
13126  preference_name)
13127  == -1)
13128  {
13129  g_string_free (xml, TRUE);
13130  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13131  return gsad_message (credentials,
13132  "Internal error", __FUNCTION__, __LINE__,
13133  "An internal error occurred while getting a preference file. "
13134  "The file could not be delivered. "
13135  "Diagnostics: Failure to send command to manager daemon.",
13136  "/omp?cmd=get_tasks", response_data);
13137  }
13138 
13139  entity = NULL;
13140  if (read_entity_c (connection, &entity))
13141  {
13142  g_string_free (xml, TRUE);
13143  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13144  return gsad_message (credentials,
13145  "Internal error", __FUNCTION__, __LINE__,
13146  "An internal error occurred while getting a preference file. "
13147  "The file could not be delivered. "
13148  "Diagnostics: Failure to receive response from manager daemon.",
13149  "/omp?cmd=get_tasks", response_data);
13150  }
13151 
13152  preference_entity = entity_child (entity, "preference");
13153  if (preference_entity != NULL
13154  && (value_entity = entity_child (preference_entity, "value")))
13155  {
13156  char *content = strdup (entity_text (value_entity));
13158  *content_disposition = g_strdup_printf ("attachment; filename=\"pref_file.bin\"");
13159  *content_length = strlen (content);
13160  free_entity (entity);
13161  g_string_free (xml, TRUE);
13162  return content;
13163  }
13164  else
13165  {
13166  free_entity (entity);
13167  g_string_free (xml, TRUE);
13168  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13169  return gsad_message (credentials,
13170  "Internal error", __FUNCTION__, __LINE__,
13171  "An internal error occurred while getting a preference file. "
13172  "The file could not be delivered. "
13173  "Diagnostics: Failure to receive file from manager daemon.",
13174  "/omp?cmd=get_tasks", response_data);
13175  }
13176  }
13177 
13178  g_string_append (xml, "</get_preferences_response>");
13179  return xsl_transform_omp (connection, credentials, params,
13180  g_string_free (xml, FALSE), response_data);
13181 }
content_type
Content types.
Definition: gsad_base.h:120
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Report format XML on success. HTML result of XSL transformation on error.

Definition at line 13198 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13203 {
13204  return export_resource (connection, "report_format", credentials, params,
13205  content_type, content_disposition, content_length,
13206  response_data);
13207 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_report_formats_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Report Formats XML on success. HTML result of XSL transformation on error.

Definition at line 13224 of file gsad_omp.c.

Referenced by exec_omp_get().

13229 {
13230  return export_many (connection, "report_format", credentials, params,
13231  content_type, content_disposition, content_length,
13232  response_data);
13233 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_resource ( openvas_connection_t *  connection,
const char *  type,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Resource XML on success. HTML result of XSL transformation on error.

Definition at line 2671 of file gsad_omp.c.

References format_file_name(), GSAD_CONTENT_TYPE_APP_XML, gsad_message(), GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, params_t, params_value(), and set_http_status_from_entity().

Referenced by export_agent_omp(), export_alert_omp(), export_asset_omp(), export_config_omp(), export_credential_omp(), export_filter_omp(), export_group_omp(), export_note_omp(), export_override_omp(), export_permission_omp(), export_port_list_omp(), export_report_format_omp(), export_result_omp(), export_role_omp(), export_scanner_omp(), export_schedule_omp(), export_tag_omp(), export_target_omp(), export_task_omp(), and export_user_omp().

2676 {
2677  GString *xml;
2678  entity_t entity;
2679  entity_t resource_entity;
2680  char *content = NULL;
2681  gchar *id_name;
2682  gchar *fname_format, *file_name;
2683  int ret;
2684  const char *resource_id, *subtype;
2685 
2686  *content_length = 0;
2687 
2688  xml = g_string_new ("");
2689 
2690  id_name = g_strdup_printf ("%s_id", type);
2691  resource_id = params_value (params, id_name);
2692  g_free (id_name);
2693 
2694  if (resource_id == NULL)
2695  {
2696  g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Export Resource"));
2697  return xsl_transform_omp (connection, credentials, params,
2698  g_string_free (xml, FALSE), response_data);
2699  }
2700 
2701  subtype = params_value (params, "subtype");
2702 
2703  if (openvas_connection_sendf (connection,
2704  "<get_%ss"
2705  " %s_id=\"%s\""
2706  "%s%s%s"
2707  " export=\"1\""
2708  " details=\"1\"/>",
2709  type,
2710  type,
2711  resource_id,
2712  subtype ? " type=\"" : "",
2713  subtype ? subtype : "",
2714  subtype ? "\"" : "")
2715  == -1)
2716  {
2717  g_string_free (xml, TRUE);
2718  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2719  return gsad_message (credentials,
2720  "Internal error", __FUNCTION__, __LINE__,
2721  "An internal error occurred while getting a resource. "
2722  "The resource could not be delivered. "
2723  "Diagnostics: Failure to send command to manager daemon.",
2724  "/omp?cmd=get_tasks", response_data);
2725  }
2726 
2727  entity = NULL;
2728  if (read_entity_and_text_c (connection, &entity, &content))
2729  {
2730  g_string_free (xml, TRUE);
2731  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2732  return gsad_message (credentials,
2733  "Internal error", __FUNCTION__, __LINE__,
2734  "An internal error occurred while getting a resource. "
2735  "The resource could not be delivered. "
2736  "Diagnostics: Failure to receive response from manager daemon.",
2737  "/omp?cmd=get_tasks", response_data);
2738  }
2739 
2740  if (!omp_success (entity))
2741  set_http_status_from_entity (entity, response_data);
2742 
2743  resource_entity = entity_child (entity, type);
2744 
2745  if (resource_entity == NULL)
2746  {
2747  g_free (content);
2748  free_entity (entity);
2749  g_string_free (xml, TRUE);
2750  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2751  return gsad_message (credentials,
2752  "Internal error", __FUNCTION__, __LINE__,
2753  "An internal error occurred while getting a resource. "
2754  "The resource could not be delivered. "
2755  "Diagnostics: Failure to receive resource from manager daemon.",
2756  "/omp?cmd=get_tasks", response_data);
2757  }
2758 
2759  ret = setting_get_value (connection,
2760  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2",
2761  &fname_format,
2762  response_data);
2763  if (ret)
2764  {
2765  g_free (content);
2766  free_entity (entity);
2767  g_string_free (xml, TRUE);
2768  switch (ret)
2769  {
2770  case 1:
2771  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2772  return gsad_message (credentials,
2773  "Internal error", __FUNCTION__, __LINE__,
2774  "An internal error occurred while getting a setting. "
2775  "The setting could not be delivered. "
2776  "Diagnostics: Failure to send command to manager daemon.",
2777  "/omp?cmd=get_tasks", response_data);
2778  case 2:
2779  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2780  return gsad_message (credentials,
2781  "Internal error", __FUNCTION__, __LINE__,
2782  "An internal error occurred while getting a setting. "
2783  "The setting could not be delivered. "
2784  "Diagnostics: Failure to receive response from manager daemon.",
2785  "/omp?cmd=get_tasks", response_data);
2786  default:
2787  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2788  return gsad_message (credentials,
2789  "Internal error", __FUNCTION__, __LINE__,
2790  "An internal error occurred while getting a setting. "
2791  "The setting could not be delivered. "
2792  "Diagnostics: Internal error.",
2793  "/omp?cmd=get_tasks", response_data);
2794  }
2795  }
2796 
2797  if (fname_format == NULL)
2798  {
2799  g_warning ("%s : File name format setting not found.", __FUNCTION__);
2800  fname_format = "%T-%U";
2801  }
2802 
2803  file_name = format_file_name (fname_format, credentials, type, resource_id,
2804  resource_entity);
2805  if (file_name == NULL)
2806  file_name = g_strdup_printf ("%s-%s", type, resource_id);
2807 
2809  *content_disposition = g_strdup_printf ("attachment; filename=\"%s.xml\"",
2810  file_name);
2811  *content_length = strlen (content);
2812  free_entity (entity);
2813  g_free (file_name);
2814  g_string_free (xml, TRUE);
2815  return content;
2816 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
content_type
Content types.
Definition: gsad_base.h:120
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
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_omp.c:2581
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_result_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a result.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Result XML on success. HTML result of XSL transformation on error.

Definition at line 14915 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

14919 {
14920  return export_resource (connection, "result", credentials, params,
14921  content_type, content_disposition, content_length,
14922  response_data);
14923 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_results_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Results XML on success. HTML result of XSL transformation on error.

Definition at line 14940 of file gsad_omp.c.

References params_t, and params_value().

Referenced by exec_omp_get().

14945 {
14946  return export_many (connection, "result", credentials, params, content_type,
14947  content_disposition, content_length, response_data);
14948 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a role.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Role XML on success. HTML result of XSL transformation on error.

Definition at line 23400 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

23404 {
23405  return export_resource (connection, "role", credentials, params, content_type,
23406  content_disposition, content_length, response_data);
23407 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_roles_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Roles XML on success. HTML result of XSL transformation on error.

Definition at line 23424 of file gsad_omp.c.

Referenced by exec_omp_get().

23428 {
23429  return export_many (connection, "role", credentials, params, content_type,
23430  content_disposition, content_length, response_data);
23431 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a scanner.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Scanner XML on success. HTML result of XSL transformation on error.

Definition at line 16678 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

16683 {
16684  return export_resource (connection, "scanner", credentials, params,
16685  content_type, content_disposition, content_length,
16686  response_data);
16687 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_scanners_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Scanners XML on success. HTML result of XSL transformation on error.

Definition at line 16703 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_t.

Referenced by exec_omp_get().

16708 {
16709  return export_many (connection, "scanner", credentials, params, content_type,
16710  content_disposition, content_length, response_data);
16711 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a schedule.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Schedule XML on success. HTML result of XSL transformation on error.

Definition at line 24242 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

24247 {
24248  return export_resource (connection, "schedule", credentials, params,
24249  content_type, content_disposition, content_length,
24250  response_data);
24251 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_schedules_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Schedules XML on success. HTML result of XSL transformation on error.

Definition at line 24267 of file gsad_omp.c.

Referenced by exec_omp_get().

24272 {
24273  return export_many (connection, "schedule", credentials, params, content_type,
24274  content_disposition, content_length, response_data);
24275 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a tag.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Target XML on success. HTML result of XSL transformation on error.

Definition at line 10482 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

10486 {
10487  return export_resource (connection, "tag", credentials, params, content_type,
10488  content_disposition, content_length, response_data);
10489 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_tags_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Targets XML on success. HTML result of XSL transformation on error.

Definition at line 10506 of file gsad_omp.c.

References get_one(), and params_t.

Referenced by exec_omp_get().

10510 {
10511  return export_many (connection, "tag", credentials, params, content_type,
10512  content_disposition, content_length, response_data);
10513 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a target.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Target XML on success. HTML result of XSL transformation on error.

Definition at line 11205 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

11209 {
11210  return export_resource (connection, "target", credentials, params,
11211  content_type, content_disposition, content_length,
11212  response_data);
11213 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_targets_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Targets XML on success. HTML result of XSL transformation on error.

Definition at line 11230 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_t.

Referenced by exec_omp_get().

11234 {
11235  return export_many (connection, "target", credentials, params, content_type,
11236  content_disposition, content_length, response_data);
11237 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a task.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. HTML result of XSL transformation on error.

Definition at line 4993 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

4997 {
4998  return export_resource (connection, "task", credentials, params, content_type,
4999  content_disposition, content_length, response_data);
5000 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_tasks_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Tasks XML on success. HTML result of XSL transformation on error.

Definition at line 5017 of file gsad_omp.c.

Referenced by exec_omp_get().

5021 {
5022  return export_many (connection, "task", credentials, params, content_type,
5023  content_disposition, content_length, response_data);
5024 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

char* export_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Export a user.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Note XML on success. HTML result of XSL transformation on error.

Definition at line 25556 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

25560 {
25561  return export_resource (connection, "user", credentials, params, content_type,
25562  content_disposition, content_length, response_data);
25563 }
content_type
Content types.
Definition: gsad_base.h:120
char * export_resource(openvas_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2671

Here is the call graph for this function:

Here is the caller graph for this function:

char* export_users_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
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]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Users XML on success. HTML result of XSL transformation on error.

Definition at line 25580 of file gsad_omp.c.

Referenced by exec_omp_get().

25584 {
25585  return export_many (connection, "user", credentials, params, content_type,
25586  content_disposition, content_length, response_data);
25587 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the caller graph for this function:

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 2581 of file gsad_omp.c.

References credentials_t::username.

Referenced by delete_report_omp(), and export_resource().

2584 {
2585  gchar *creation_time, *modification_time, *name, *format_name;
2586  gchar *ret;
2587 
2588  if (resource_entity)
2589  {
2590  entity_t creation_time_entity, modification_time_entity;
2591  entity_t task_entity, format_entity, format_name_entity, name_entity;
2592 
2593  creation_time_entity = entity_child (resource_entity,
2594  "creation_time");
2595 
2596  if (creation_time_entity)
2597  creation_time = entity_text (creation_time_entity);
2598  else
2599  creation_time = NULL;
2600 
2601  modification_time_entity = entity_child (resource_entity,
2602  "modification_time");
2603 
2604  if (modification_time_entity)
2605  modification_time = entity_text (modification_time_entity);
2606  else
2607  modification_time = NULL;
2608 
2609  if (strcasecmp (type, "report") == 0)
2610  {
2611  task_entity = entity_child (resource_entity, "task");
2612  if (task_entity)
2613  name_entity = entity_child (task_entity, "name");
2614  else
2615  name_entity = NULL;
2616 
2617  format_entity = entity_child (resource_entity, "report_format");
2618  if (format_entity)
2619  {
2620  format_name_entity = entity_child (format_entity, "name");
2621  }
2622  else
2623  format_name_entity = NULL;
2624 
2625  if (format_name_entity && strlen (entity_text (format_name_entity)))
2626  format_name = entity_text (format_name_entity);
2627  else
2628  format_name = NULL;
2629  }
2630  else
2631  {
2632  name_entity = entity_child (resource_entity, "name");
2633  format_name = NULL;
2634  }
2635 
2636  if (name_entity)
2637  name = entity_text (name_entity);
2638  else
2639  name = NULL;
2640  }
2641  else
2642  {
2643  creation_time = NULL;
2644  modification_time = NULL;
2645  name = NULL;
2646  format_name = NULL;
2647  }
2648 
2649  ret = openvas_export_file_name (fname_format, credentials->username,
2650  type, uuid, creation_time, modification_time,
2651  name, format_name);
2652  return ret;
2653 }
char * username
Name of user.
Definition: gsad_base.h:69

Here is the caller graph for this function:

char* get_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one agent, XSL transform 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
Result of XSL transformation.

Definition at line 7400 of file gsad_omp.c.

References params_t.

7402 {
7403  return get_agent (connection, credentials, params, NULL, response_data);
7404 }
char* get_agents_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all agents, XSL transform 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
Result of XSL transformation.

Definition at line 7437 of file gsad_omp.c.

7439 {
7440  return get_agents (connection, credentials, params, NULL, response_data);
7441 }
char* get_aggregate_omp ( openvas_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 7599 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::valid, and param::value.

7602 {
7603  params_t *data_columns, *text_columns;
7604  params_t *sort_fields, *sort_stats, *sort_orders;
7605  params_iterator_t data_columns_iterator, text_columns_iterator;
7606  params_iterator_t sort_fields_iterator, sort_stats_iterator;
7607  params_iterator_t sort_orders_iterator;
7608  char *param_name;
7609  param_t *param;
7610 
7611  const char *data_column, *group_column, *subgroup_column, *type;
7612  const char *filter, *filt_id, *xml_param;
7613  const char *first_group, *max_groups;
7614  const char *mode;
7615  gchar *filter_escaped, *command_escaped, *response;
7616  entity_t entity;
7617  GString *xml, *command;
7618  int ret;
7619 
7620  data_columns = params_values (params, "data_columns:");
7621  data_column = params_value (params, "data_column");
7622  text_columns = params_values (params, "text_columns:");
7623  group_column = params_value (params, "group_column");
7624  subgroup_column = params_value (params, "subgroup_column");
7625  type = params_value (params, "aggregate_type");
7626  filter = params_value (params, "filter");
7627  filt_id = params_value (params, "filt_id");
7628  sort_fields = params_values (params, "sort_fields:");
7629  sort_stats = params_values (params, "sort_stats:");
7630  sort_orders = params_values (params, "sort_orders:");
7631  first_group = params_value (params, "first_group");
7632  max_groups = params_value (params, "max_groups");
7633  mode = params_value (params, "aggregate_mode");
7634  if (filter && strcmp (filter, ""))
7635  filter_escaped = g_markup_escape_text (filter, -1);
7636  else
7637  {
7638  if (filt_id == NULL
7639  || strcmp (filt_id, "") == 0
7640  || strcmp (filt_id, "0") == 0)
7641  filter_escaped = g_strdup ("rows=-2");
7642  else
7643  filter_escaped = NULL;
7644  }
7645  xml_param = params_value (params, "xml");
7646 
7647  if (xml_param == NULL || atoi (xml_param) == 0)
7648  {
7649  return xsl_transform_omp (connection, credentials, params,
7650  g_strdup ("<get_aggregate/>"), response_data);
7651  }
7652  xml = g_string_new ("<get_aggregate>");
7653 
7654  command = g_string_new ("<get_aggregates");
7655  g_string_append_printf (command, " type=\"%s\"", type);
7656  if (data_column)
7657  g_string_append_printf (command, " data_column=\"%s\"", data_column);
7658  if (group_column)
7659  g_string_append_printf (command, " group_column=\"%s\"", group_column);
7660  if (subgroup_column)
7661  g_string_append_printf (command,
7662  " subgroup_column=\"%s\"", subgroup_column);
7663  if (filter_escaped && strcmp (filter_escaped, ""))
7664  g_string_append_printf (command, " filter=\"%s\"", filter_escaped);
7665  if (filt_id && strcmp (filt_id, ""))
7666  g_string_append_printf (command, " filt_id=\"%s\"", filt_id);
7667  if (first_group && strcmp (first_group, ""))
7668  g_string_append_printf (command, " first_group=\"%s\"", first_group);
7669  if (max_groups && strcmp (max_groups, ""))
7670  g_string_append_printf (command, " max_groups=\"%s\"", max_groups);
7671  if (mode && strcmp (mode, ""))
7672  g_string_append_printf (command, " mode=\"%s\"", mode);
7673  g_string_append (command, ">");
7674 
7675  if (sort_fields && sort_stats && sort_orders)
7676  {
7677  param_t *field_param, *stat_param, *order_param;
7678  gchar *field_i, *stat_i, *order_i;
7679 
7680  params_iterator_init (&sort_fields_iterator, sort_fields);
7681  params_iterator_init (&sort_stats_iterator, sort_stats);
7682  params_iterator_init (&sort_orders_iterator, sort_orders);
7683 
7684  while (params_iterator_next (&sort_fields_iterator,
7685  &field_i, &field_param)
7686  && params_iterator_next (&sort_stats_iterator,
7687  &stat_i, &stat_param)
7688  && params_iterator_next (&sort_orders_iterator,
7689  &order_i, &order_param))
7690  {
7691  if (field_param->valid && stat_param->valid && order_param->valid)
7692  {
7693  xml_string_append (command,
7694  "<sort field=\"%s\""
7695  " stat=\"%s\""
7696  " order=\"%s\"/>",
7697  field_param->value ? field_param->value : "",
7698  stat_param->value ? stat_param->value : "",
7699  order_param->value ? order_param->value : "");
7700  }
7701  }
7702  }
7703 
7704  if (data_columns)
7705  {
7706  params_iterator_init (&data_columns_iterator, data_columns);
7707  while (params_iterator_next (&data_columns_iterator, &param_name, &param))
7708  {
7709  if (param->valid)
7710  {
7711  xml_string_append (command,
7712  "<data_column>%s</data_column>",
7713  param->value);
7714  }
7715  }
7716  }
7717 
7718  if (text_columns)
7719  {
7720  params_iterator_init (&text_columns_iterator, text_columns);
7721  while (params_iterator_next (&text_columns_iterator, &param_name, &param))
7722  {
7723  if (param->valid)
7724  {
7725  xml_string_append (command,
7726  "<text_column>%s</text_column>",
7727  param->value);
7728  }
7729  }
7730  }
7731 
7732  g_string_append (command, "</get_aggregates>");
7733 
7734  g_free (filter_escaped);
7735 
7736  command_escaped = g_markup_escape_text (command->str, -1);
7737  g_string_append (xml, command_escaped);
7738  g_free (command_escaped);
7739 
7740  ret = omp (connection, credentials, &response, &entity, response_data,
7741  command->str);
7742  g_string_free (command, TRUE);
7743  switch (ret)
7744  {
7745  case 0:
7746  break;
7747  case -1:
7748  /* 'omp' set response. */
7749  return response;
7750  case 1:
7751  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7752  return gsad_message (credentials,
7753  "Internal error", __FUNCTION__, __LINE__,
7754  "An internal error occurred while getting aggregates. "
7755  "Diagnostics: Failure to send command to manager daemon.",
7756  "/omp?cmd=get_tasks", response_data);
7757  case 2:
7758  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7759  return gsad_message (credentials,
7760  "Internal error", __FUNCTION__, __LINE__,
7761  "An internal error occurred while getting aggregates. "
7762  "Diagnostics: Failure to receive response from manager daemon.",
7763  "/omp?cmd=get_tasks", response_data);
7764  default:
7765  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7766  return gsad_message (credentials,
7767  "Internal error", __FUNCTION__, __LINE__,
7768  "An internal error occurred while getting aggregates. "
7769  "Diagnostics: Internal Error.",
7770  "/omp?cmd=get_tasks", response_data);
7771  }
7772 
7773  g_string_append (xml, response);
7774 
7775  g_string_append (xml, "</get_aggregate>");
7776 
7777  return xsl_transform_omp (connection, credentials, params,
7778  g_string_free (xml, FALSE), response_data);
7779 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
int valid
Definition: gsad_base.h:152
#define params_iterator_t
Definition: gsad_base.h:187

Here is the call graph for this function:

char* get_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one alert, XSL transform 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
Result of XSL transformation.

Definition at line 8564 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

8566 {
8567  return get_alert (connection, credentials, params, NULL, response_data);
8568 }

Here is the call graph for this function:

char* get_alerts_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all alerts, XSL transform 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
Result of XSL transformation.

Definition at line 8705 of file gsad_omp.c.

8707 {
8708  return get_alerts (connection, credentials, params, NULL, response_data);
8709 }
char* get_asset_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get asset, XSL transform 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
Result of XSL transformation.

Definition at line 26975 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_t, params_value(), param::valid, param::valid_utf8, and param::value.

26977 {
26978  return get_asset (connection, credentials, params, NULL, response_data);
26979 }

Here is the call graph for this function:

char* get_assets_chart_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get an assets chart, XSL transform 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
Result of XSL transformation.

Definition at line 27523 of file gsad_omp.c.

27526 {
27527  return get_assets_chart (connection, credentials, params, NULL,
27528  response_data);
27529 }
char* get_assets_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get assets, XSL transform 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
Result of XSL transformation.

Definition at line 27054 of file gsad_omp.c.

27056 {
27057  return get_assets (connection, credentials, params, NULL, response_data);
27058 }
char* get_config_family_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get details of a family for a config, XSL transform 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
Result of XSL transformation.

Definition at line 12343 of file gsad_omp.c.

12346 {
12347  return get_config_family (connection, credentials, params, 0, response_data);
12348 }
char* get_config_nvt_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get details of an NVT for a config, XSL transform 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
Result of XSL transformation.

Definition at line 12620 of file gsad_omp.c.

12623 {
12624  return get_config_nvt (connection, credentials, params, 0, response_data);
12625 }
char* get_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a config, XSL transform 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
Result of XSL transformation.

Definition at line 11768 of file gsad_omp.c.

References params_t.

11770 {
11771  return get_config (connection, credentials, params, NULL, 0, response_data);
11772 }
char* get_configs_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all scan configs, XSL transform 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
Result of XSL transformation.

Definition at line 11564 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

11566 {
11567  return get_configs (connection, credentials, params, NULL, response_data);
11568 }

Here is the call graph for this function:

char* get_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one credential, XSL transform 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
Result of XSL transformation.

Definition at line 6306 of file gsad_omp.c.

6309 {
6310  return get_credential (connection, credentials, params, NULL, response_data);
6311 }
char* get_credentials_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one or all credentials, XSL transform 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 6586 of file gsad_omp.c.

6589 {
6590  return get_credentials (connection, credentials, params, NULL, response_data);
6591 }
char* get_feeds_omp ( openvas_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
Result of XSL transformation.

Definition at line 23536 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

23538 {
23539  entity_t entity;
23540  char *text = NULL;
23541  gchar *response;
23542  time_t now;
23543  struct tm *tm;
23544  gchar current_timestamp[30];
23545 
23546  if (openvas_connection_sendf (connection,
23547  "<commands>"
23548  "<get_feeds/>"
23549  "</commands>")
23550  == -1)
23551  {
23552  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23553  return gsad_message (credentials,
23554  "Internal error", __FUNCTION__, __LINE__,
23555  "An internal error occurred while getting the feed list. "
23556  "The current list of feeds is not available. "
23557  "Diagnostics: Failure to send command to manager daemon.",
23558  "/omp?cmd=get_tasks", response_data);
23559  }
23560 
23561  if (read_entity_and_text_c (connection, &entity, &text))
23562  {
23563  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23564  return gsad_message (credentials,
23565  "Internal error", __FUNCTION__, __LINE__,
23566  "An internal error occurred while getting the feed. "
23567  "The current list of feeds is not available. "
23568  "Diagnostics: Failure to receive response from manager daemon.",
23569  "/omp?cmd=get_tasks", response_data);
23570  }
23571 
23572  time (&now);
23573  tm = gmtime (&now);
23574  if (tm == NULL
23575  || (strftime (current_timestamp,
23576  29,
23577  "%Y-%m-%dT%H:%M:%S",
23578  tm)
23579  == 0))
23580  {
23581  current_timestamp[0] = '\0';
23582  }
23583 
23584  response = g_strdup_printf ("<get_feeds>"
23585  "%s"
23586  "<current_time_utc>%s</current_time_utc>"
23587  "</get_feeds>",
23588  text,
23589  current_timestamp);
23590 
23591  g_free (text);
23592 
23593  return xsl_transform_omp (connection, credentials, params, response,
23594  response_data);
23595 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467

Here is the call graph for this function:

char* get_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one filter, XSL transform 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
Result of XSL transformation.

Definition at line 23758 of file gsad_omp.c.

References params_t.

23760 {
23761  return get_filter (connection, credentials, params, NULL, response_data);
23762 }
char* get_filters_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all filters, XSL transform 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
Result of XSL transformation.

Definition at line 23795 of file gsad_omp.c.

References params_t.

23797 {
23798  return get_filters (connection, credentials, params, NULL, response_data);
23799 }
char* get_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one group, XSL transform 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
Result of XSL transformation.

Definition at line 20145 of file gsad_omp.c.

References params_t.

20147 {
20148  return get_group (connection, credentials, params, NULL, response_data);
20149 }
char* get_groups_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all groups, XSL transform 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
Result of XSL transformation.

Definition at line 20182 of file gsad_omp.c.

References params_t.

20184 {
20185  return get_groups (connection, credentials, params, NULL, response_data);
20186 }
char* get_info ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Requests SecInfo.

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
XSL transformed SecInfo response or error message.

Definition at line 5282 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_value(), param::valid, param::valid_utf8, and param::value.

Referenced by exec_omp_get(), get_info_omp(), and message_invalid().

5285 {
5286  char *ret;
5287  GString *extra_attribs, *extra_response;
5288  const char *info_type;
5289 
5290  info_type = params_value (params, "info_type");
5291  if (info_type == NULL)
5292  {
5293  param_t *param;
5294  param = params_add (params, "info_type", "nvt");
5295  param->valid = 1;
5296  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
5297  info_type = params_value (params, "info_type");
5298  }
5299 
5300  if (strcmp (info_type, "nvt")
5301  && strcmp (info_type, "cve")
5302  && strcmp (info_type, "cpe")
5303  && strcmp (info_type, "ovaldef")
5304  && strcmp (info_type, "cert_bund_adv")
5305  && strcmp (info_type, "dfn_cert_adv")
5306  && strcmp (info_type, "allinfo")
5307  && strcmp (info_type, "NVT")
5308  && strcmp (info_type, "CVE")
5309  && strcmp (info_type, "CPE")
5310  && strcmp (info_type, "OVALDEF")
5311  && strcmp (info_type, "CERT_BUND_ADV")
5312  && strcmp (info_type, "DFN_CERT_ADV")
5313  && strcmp (info_type, "ALLINFO"))
5314  {
5315  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
5316  return gsad_message (credentials,
5317  "Internal error", __FUNCTION__, __LINE__,
5318  "An internal error occurred while getting SecInfo. "
5319  "Diagnostics: Invalid info_type parameter value",
5320  "/omp?cmd=get_info", response_data);
5321  }
5322 
5323  if (params_value (params, "info_name")
5324  && params_value (params, "info_id"))
5325  {
5326  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
5327  return gsad_message (credentials,
5328  "Internal error", __FUNCTION__, __LINE__,
5329  "An internal error occurred while getting SecInfo. "
5330  "Diagnostics: Both ID and Name set.",
5331  "/omp?cmd=get_info", response_data);
5332  }
5333  extra_response = g_string_new (extra_xml ? extra_xml : "");
5334 
5335  if (command_enabled (credentials, "GET_NOTES")
5336  && (strcasecmp (info_type, "NVT") == 0)
5337  && params_value (params, "info_id"))
5338  {
5339  gchar *response;
5340 
5341  if (simple_ompf (connection, "getting SecInfo", credentials, &response,
5342  response_data,
5343  "<get_notes"
5344  " nvt_oid=\"%s\""
5345  " sort_field=\"notes.text\"/>",
5346  params_value (params, "info_id")))
5347  {
5348  g_string_free (extra_response, TRUE);
5349  return response;
5350  }
5351 
5352  g_string_append (extra_response, response);
5353  }
5354 
5355  if (command_enabled (credentials, "GET_OVERRIDES")
5356  && (strcasecmp (info_type, "NVT") == 0)
5357  && params_value (params, "info_id"))
5358  {
5359  gchar *response;
5360 
5361  if (simple_ompf (connection, "getting SecInfo", credentials, &response,
5362  response_data,
5363  "<get_overrides"
5364  " nvt_oid=\"%s\""
5365  " sort_field=\"overrides.text\"/>",
5366  params_value (params, "info_id")))
5367  {
5368  g_string_free (extra_response, TRUE);
5369  return response;
5370  }
5371 
5372  g_string_append (extra_response, response);
5373  }
5374 
5375  extra_attribs = g_string_new("");
5376  g_string_append_printf (extra_attribs, "type=\"%s\"",
5377  params_value (params, "info_type"));
5378  if (params_value (params, "info_name"))
5379  g_string_append_printf (extra_attribs,
5380  " name=\"%s\"",
5381  params_value (params, "info_name"));
5382  else if (params_value (params, "info_id"))
5383  g_string_append_printf (extra_attribs,
5384  " info_id=\"%s\"",
5385  params_value (params, "info_id"));
5386  if (params_value (params, "details"))
5387  g_string_append_printf (extra_attribs,
5388  " details=\"%s\"",
5389  params_value (params, "details"));
5390  ret = get_many (connection, "info", credentials, params, extra_response->str,
5391  extra_attribs->str, response_data);
5392 
5393  g_string_free (extra_response, TRUE);
5394  g_string_free (extra_attribs, TRUE);
5395 
5396  return ret;
5397 }
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int valid_utf8
Definition: gsad_base.h:153
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int valid
Definition: gsad_base.h:152
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808

Here is the call graph for this function:

Here is the caller graph for this function:

char* get_info_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get info, XSL transform 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
Result of XSL transformation.

Definition at line 5410 of file gsad_omp.c.

References get_info().

5413 {
5414  return get_info (connection, credentials, params, NULL, response_data);
5415 }
char * get_info(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
Definition: gsad_omp.c:5282

Here is the call graph for this function:

char* get_my_settings_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page with user's 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
Result of XSL transformation.

Definition at line 18916 of file gsad_omp.c.

References buffer_languages_xml(), command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

18919 {
18920  GString *commands;
18921  int ret;
18922  entity_t entity;
18923  gchar *response;
18924 
18925  commands = g_string_new ("<commands>");
18926  if (command_enabled (credentials, "GET_ALERTS"))
18927  g_string_append (commands, "<get_alerts/>");
18928  if (command_enabled (credentials, "GET_CONFIGS"))
18929  g_string_append (commands, "<get_configs/>");
18930  if (command_enabled (credentials, "GET_FILTERS"))
18931  g_string_append (commands, "<get_filters/>");
18932  if (command_enabled (credentials, "GET_CREDENTIALS"))
18933  g_string_append (commands, "<get_credentials/>");
18934  if (command_enabled (credentials, "GET_PORT_LISTS"))
18935  g_string_append (commands, "<get_port_lists/>");
18936  if (command_enabled (credentials, "GET_REPORT_FORMATS"))
18937  g_string_append (commands, "<get_report_formats/>");
18938  if (command_enabled (credentials, "GET_SCANNERS"))
18939  g_string_append (commands, "<get_scanners/>");
18940  if (command_enabled (credentials, "GET_SCHEDULES"))
18941  g_string_append (commands, "<get_schedules/>");
18942  if (command_enabled (credentials, "GET_TARGETS"))
18943  g_string_append (commands, "<get_targets/>");
18944  g_string_append (commands, "</commands>");
18945 
18946  /* Get Filters and other resource lists. */
18947  response = NULL;
18948  entity = NULL;
18949  ret = omp (connection, credentials, &response, &entity, response_data,
18950  commands->str);
18951  g_string_free (commands, TRUE);
18952  switch (ret)
18953  {
18954  case 0:
18955  case -1:
18956  break;
18957  case 1:
18958  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18959  return gsad_message (credentials,
18960  "Internal error", __FUNCTION__, __LINE__,
18961  "An internal error occurred while getting resources "
18962  "for the settings. "
18963  "Diagnostics: Failure to send command to manager daemon.",
18964  "/omp?cmd=get_my_settings", response_data);
18965  case 2:
18966  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18967  return gsad_message (credentials,
18968  "Internal error", __FUNCTION__, __LINE__,
18969  "An internal error occurred while getting resources "
18970  "for the settings. "
18971  "Diagnostics: Failure to receive response from manager daemon.",
18972  "/omp?cmd=get_alerts", response_data);
18973  default:
18974  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18975  return gsad_message (credentials,
18976  "Internal error", __FUNCTION__, __LINE__,
18977  "An internal error occurred while getting resources "
18978  "for the settings. "
18979  "It is unclear whether the task has been saved or not. "
18980  "Diagnostics: Internal Error.",
18981  "/omp?cmd=get_alerts", response_data);
18982  }
18983  free_entity (entity);
18984 
18985  return get_my_settings (connection, credentials, params, response,
18986  response_data);
18987 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

char* get_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a note, XSL transform 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
Result of XSL transformation.

Definition at line 15251 of file gsad_omp.c.

15253 {
15254  return get_note (connection, credentials, params, NULL, response_data);
15255 }
char* get_notes_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all notes, XSL transform 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
Result of XSL transformation.

Definition at line 15214 of file gsad_omp.c.

References get_one(), and params_t.

15216 {
15217  return get_notes (connection, credentials, params, NULL, response_data);
15218 }

Here is the call graph for this function:

char* get_nvts_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Requests NVT details, accepting extra commands.

Parameters
[in]connectionConnection to manager
[in]credentialsCredentials for the manager connection.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
XSL transformed NVT details response or error message.

Definition at line 5428 of file gsad_omp.c.

References params_add(), params_get(), params_t, params_value(), param::valid, param::valid_utf8, param::value, and param::value_size.

5430 {
5431  return get_nvts (connection, credentials, params, NULL, NULL, response_data);
5432 }

Here is the call graph for this function:

char* get_one ( openvas_connection_t *  connection,
const char *  type,
credentials_t credentials,
params_t params,
const char *  extra_xml,
const char *  extra_attribs,
cmd_response_data_t response_data 
)

Get one resource, XSL transform 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]extra_attribsExtra attributes for OMP GET command.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 1823 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, credentials_t::last_filt_ids, params_t, params_value(), and set_http_status_from_entity().

Referenced by create_credential_omp(), create_host_omp(), create_port_range_omp(), delete_alert_omp(), delete_user_confirm_omp(), edit_role_omp(), edit_target_omp(), export_omp_doc_omp(), export_tags_omp(), get_notes_omp(), get_overrides_omp(), get_scanners_omp(), get_system_report_omp(), save_agent_omp(), save_group_omp(), save_scanner_omp(), and sync_cert_omp().

1827 {
1828  GString *xml;
1829  int ret;
1830  gchar *end, *id_name;
1831  const char *id, *sort_field, *sort_order, *filter, *first, *max;
1832 
1833  id_name = g_strdup_printf ("%s_id", type);
1834  id = params_value (params, id_name);
1835  g_free (id_name);
1836  sort_field = params_value (params, "sort_field");
1837  sort_order = params_value (params, "sort_order");
1838 
1839  if (id == NULL)
1840  {
1841  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1842  return gsad_message (credentials,
1843  "Internal error", __FUNCTION__, __LINE__,
1844  "An internal error occurred while getting a resource. "
1845  "Diagnostics: missing ID.",
1846  "/omp?cmd=get_tasks", response_data);
1847  }
1848 
1849  xml = g_string_new ("");
1850  g_string_append_printf (xml, "<get_%s>", type);
1851 
1852  if (strcmp (type, "role") == 0
1853  && command_enabled (credentials, "GET_PERMISSIONS")
1854  && params_value (params, "role_id"))
1855  {
1856  gchar *response;
1857  entity_t entity;
1858 
1859  response = NULL;
1860  entity = NULL;
1861  switch (ompf (connection, credentials, &response, &entity, response_data,
1862  "<get_permissions"
1863  " filter=\"rows=-1 subject_type=role and subject_uuid=%s\"/>",
1864  params_value (params, "role_id")))
1865  {
1866  case 0:
1867  case -1:
1868  break;
1869  case 1:
1870  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1871  return gsad_message (credentials,
1872  "Internal error", __FUNCTION__, __LINE__,
1873  "An internal error occurred getting permissions. "
1874  "Diagnostics: Failure to send command to manager daemon.",
1875  "/omp?cmd=get_roles", response_data);
1876  case 2:
1877  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1878  return gsad_message (credentials,
1879  "Internal error", __FUNCTION__, __LINE__,
1880  "An internal error occurred getting permissions. "
1881  "Diagnostics: Failure to receive response from manager daemon.",
1882  "/omp?cmd=get_roles", response_data);
1883  default:
1884  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1885  return gsad_message (credentials,
1886  "Internal error", __FUNCTION__, __LINE__,
1887  "An internal error occurred getting permissins. "
1888  "Diagnostics: Internal Error.",
1889  "/omp?cmd=get_roles", response_data);
1890  }
1891 
1892  g_string_append (xml, response);
1893 
1894  if (!omp_success (entity))
1895  set_http_status_from_entity (entity, response_data);
1896 
1897  free_entity (entity);
1898  g_free (response);
1899  }
1900 
1901  /* Pass through params for get_resources. */
1902  filter = params_value (params, "filter");
1903  first = params_value (params, "first");
1904  max = params_value (params, "max");
1905  end = g_markup_printf_escaped ("<filters><term>%s</term></filters>"
1906  "<%ss start=\"%s\" max=\"%s\"/>",
1907  filter ? filter : "",
1908  type,
1909  first ? first : "",
1910  max ? max : "");
1911  g_string_append (xml, end);
1912  g_free (end);
1913 
1914  if (extra_xml)
1915  g_string_append (xml, extra_xml);
1916 
1917  /* Get the resource. */
1918 
1919  if (openvas_connection_sendf (connection,
1920  "<get_%ss"
1921  " %s_id=\"%s\""
1922  " sort_field=\"%s\""
1923  " sort_order=\"%s\""
1924  " details=\"1\""
1925  " %s/>",
1926  type,
1927  type,
1928  id,
1929  sort_field ? sort_field : "name",
1930  sort_order ? sort_order : "ascending",
1931  extra_attribs ? extra_attribs : "")
1932  == -1)
1933  {
1934  g_string_free (xml, TRUE);
1935  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1936  return gsad_message (credentials,
1937  "Internal error", __FUNCTION__, __LINE__,
1938  "An internal error occurred while getting resources list. "
1939  "The current list of resources is not available. "
1940  "Diagnostics: Failure to send command to manager daemon.",
1941  "/omp?cmd=get_resources", response_data);
1942  }
1943 
1944  if (read_string_c (connection, &xml))
1945  {
1946  g_string_free (xml, TRUE);
1947  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1948  return gsad_message (credentials,
1949  "Internal error", __FUNCTION__, __LINE__,
1950  "An internal error occurred while getting resources list. "
1951  "The current list of resources is not available. "
1952  "Diagnostics: Failure to receive response from manager daemon.",
1953  "/omp?cmd=get_resources", response_data);
1954  }
1955 
1956  /* Get tag names */
1957 
1958  if (openvas_connection_sendf (connection,
1959  "<get_tags"
1960  " filter=\"resource_type=%s"
1961  " first=1"
1962  " rows=-1\""
1963  " names_only=\"1\""
1964  "/>",
1965  type)
1966  == -1)
1967  {
1968  g_string_free (xml, TRUE);
1969  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1970  return gsad_message (credentials,
1971  "Internal error", __FUNCTION__, __LINE__,
1972  "An internal error occurred while getting tag names list. "
1973  "The current list of resources is not available. "
1974  "Diagnostics: Failure to send command to manager daemon.",
1975  "/omp?cmd=get_resources", response_data);
1976  }
1977 
1978  if (read_string_c (connection, &xml))
1979  {
1980  g_string_free (xml, TRUE);
1981  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
1982  return gsad_message (credentials,
1983  "Internal error", __FUNCTION__, __LINE__,
1984  "An internal error occurred while getting tag names list. "
1985  "The current list of resources is not available. "
1986  "Diagnostics: Failure to receive response from manager daemon.",
1987  "/omp?cmd=get_resources", response_data);
1988  }
1989 
1990  /* Get permissions */
1991 
1992  g_string_append (xml, "<permissions>");
1993 
1994  if ((strcmp (type, "user") == 0)
1995  || (strcmp (type, "group") == 0)
1996  || (strcmp (type, "role") == 0))
1997  ret = openvas_connection_sendf (connection,
1998  "<get_permissions"
1999  " filter=\"subject_uuid=%s"
2000  " and not resource_uuid=&quot;&quot;"
2001  " or resource_uuid=%s"
2002  " first=1 rows=-1\"/>",
2003  id,
2004  id);
2005  else
2006  ret = openvas_connection_sendf (connection,
2007  "<get_permissions"
2008  " filter=\"resource_uuid=%s"
2009  " first=1 rows=-1\"/>",
2010  id);
2011  if (ret == -1)
2012  {
2013  g_string_free (xml, TRUE);
2014  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2015  return gsad_message (credentials,
2016  "Internal error", __FUNCTION__, __LINE__,
2017  "An internal error occurred while getting permissions list. "
2018  "The current list of resources is not available. "
2019  "Diagnostics: Failure to send command to manager daemon.",
2020  "/omp?cmd=get_resources", response_data);
2021  }
2022 
2023  if (read_string_c (connection, &xml))
2024  {
2025  g_string_free (xml, TRUE);
2026  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2027  return gsad_message (credentials,
2028  "Internal error", __FUNCTION__, __LINE__,
2029  "An internal error occurred while getting permissions list. "
2030  "The current list of resources is not available. "
2031  "Diagnostics: Failure to receive response from manager daemon.",
2032  "/omp?cmd=get_resources", response_data);
2033  }
2034 
2035  g_string_append (xml, "</permissions>");
2036 
2037  /* Cleanup, and return transformed XML. */
2038 
2039  g_string_append_printf (xml, "</get_%s>", type);
2040  return xsl_transform_omp (connection, credentials, params,
2041  g_string_free (xml, FALSE), response_data);
2042 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* get_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get an override, XSL transform 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
Result of XSL transformation.

Definition at line 15932 of file gsad_omp.c.

15934 {
15935  return get_override (connection, credentials, params, NULL, response_data);
15936 }
char* get_overrides_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all overrides, XSL transform 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
Result of XSL transformation.

Definition at line 15895 of file gsad_omp.c.

References get_one(), and params_t.

15897 {
15898  return get_overrides (connection, credentials, params, NULL, response_data);
15899 }

Here is the call graph for this function:

char* get_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one permission, XSL transform 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
Result of XSL transformation.

Definition at line 20580 of file gsad_omp.c.

References params_t.

20583 {
20584  return get_permission (connection, credentials, params, NULL, response_data);
20585 }
char* get_permissions_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all permissions, XSL transform 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
Result of XSL transformation.

Definition at line 20618 of file gsad_omp.c.

20621 {
20622  return get_permissions (connection, credentials, params, NULL, response_data);
20623 }
char* get_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one port_list, XSL transform 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
Result of XSL transformation.

Definition at line 22689 of file gsad_omp.c.

References params_t.

22692 {
22693  return get_port_list (connection, credentials, params, NULL, response_data);
22694 }
char* get_port_lists_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all port_lists, XSL transform 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
Result of XSL transformation.

Definition at line 22727 of file gsad_omp.c.

22730 {
22731  return get_port_lists (connection, credentials, params, NULL, response_data);
22732 }
char* get_protocol_doc_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get OMP doc.

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 of XSL transformation.

Definition at line 19965 of file gsad_omp.c.

References gsad_message(), and cmd_response_data_t::http_status_code.

19968 {
19969  GString *xml;
19970  entity_t help_response;
19971 
19972  xml = g_string_new ("");
19973  g_string_append_printf (xml, "<get_protocol_doc>");
19974 
19975  /* Get the resource. */
19976 
19977  if (openvas_connection_sendf (connection, "<help format=\"XML\"/>")
19978  == -1)
19979  {
19980  g_string_free (xml, TRUE);
19981  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19982  return gsad_message (credentials,
19983  "Internal error", __FUNCTION__, __LINE__,
19984  "An internal error occurred while getting the OMP doc. "
19985  "Diagnostics: Failure to send command to manager daemon.",
19986  "/omp?cmd=get_tasks", response_data);
19987  }
19988 
19989  help_response = NULL;
19990  if (read_entity_and_string_c (connection, &help_response, &xml))
19991  {
19992  g_string_free (xml, TRUE);
19993  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19994  return gsad_message (credentials,
19995  "Internal error", __FUNCTION__, __LINE__,
19996  "An internal error occurred while getting the OMP doc. "
19997  "Diagnostics: Failure to receive response from manager daemon.",
19998  "/omp?cmd=get_tasks", response_data);
19999  }
20000  free_entity (help_response);
20001 
20002  /* Cleanup, and return transformed XML. */
20003 
20004  g_string_append_printf (xml, "</get_protocol_doc>");
20005  return xsl_transform_omp (connection, credentials, params,
20006  g_string_free (xml, FALSE), response_data);
20007 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467

Here is the call graph for this function:

char* get_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one report format, XSL transform 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
Result of XSL transformation.

Definition at line 17975 of file gsad_omp.c.

References params_t.

17978 {
17979  return get_report_format (connection, credentials, params, NULL,
17980  response_data);
17981 }
char* get_report_formats_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all Report Formats, XSL transform 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
Result of XSL transformation.

Definition at line 18014 of file gsad_omp.c.

References params_t.

18017 {
18018  return get_report_formats (connection, credentials, params, NULL,
18019  response_data);
18020 }
char* get_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gsize *  report_len,
gchar **  content_type,
char **  content_disposition,
cmd_response_data_t response_data 
)

Get a report and XSL transform the result.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]report_lenLength of report.
[out]content_typeContent type if known, else NULL.
[out]content_dispositionContent disposition, if content_type set.
[out]response_dataExtra data return for the HTTP response.
Returns
Report.

Definition at line 14595 of file gsad_omp.c.

References params_t, and params_value().

Referenced by exec_omp_get().

14598 {
14599  char *result;
14600  int error = 0;
14601 
14602  result = get_report (connection, credentials, params, NULL, report_len,
14603  content_type, content_disposition, NULL, &error,
14604  response_data);
14605 
14606  return error ? result : xsl_transform_omp (connection, credentials, params,
14607  result, response_data);
14608 }
content_type
Content types.
Definition: gsad_base.h:120

Here is the call graph for this function:

Here is the caller graph for this function:

char* get_report_section_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a report section, XSL transform 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
Result of XSL transformation.

Definition at line 14779 of file gsad_omp.c.

Referenced by exec_omp_post().

14782 {
14783  return get_report_section (connection, credentials, params, NULL, response_data);
14784 }

Here is the caller graph for this function:

char* get_reports_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all reports, XSL transform 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
Result of XSL transformation.

Definition at line 14648 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

14650 {
14651  return get_reports (connection, credentials, params, NULL, response_data);
14652 }

Here is the call graph for this function:

char* get_result_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one result, XSL transform 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
Result of XSL transformation.

Definition at line 15139 of file gsad_omp.c.

References params_t, and params_value().

15141 {
15142  return get_result (connection, credentials, params,
15143  params_value (params, "result_id"),
15144  params_value (params, "task_id"),
15145  params_value (params, "name"),
15146  params_value (params, "apply_overrides"),
15147  NULL,
15148  params_value (params, "report_id"),
15149  params_value (params, "autofp"),
15150  NULL,
15151  response_data);
15152 }
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* get_results_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all results, XSL transform 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
Result of XSL transformation.

Definition at line 14988 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_t.

14990 {
14991  return get_results (connection, credentials,
14992  params,
14993  NULL,
14994  response_data);
14995 }

Here is the call graph for this function:

char* get_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one role, XSL transform 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
Result of XSL transformation.

Definition at line 23343 of file gsad_omp.c.

References params_t.

23345 {
23346  return get_role (connection, credentials, params, NULL, response_data);
23347 }
char* get_roles_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all roles, XSL transform 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
Result of XSL transformation.

Definition at line 23380 of file gsad_omp.c.

23382 {
23383  return get_roles (connection, credentials, params, NULL, response_data);
23384 }
char* get_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one scanner, XSL transform 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
Result of XSL transformation.

Definition at line 16658 of file gsad_omp.c.

16660 {
16661  return get_scanner (connection, credentials, params, NULL, response_data);
16662 }
char* get_scanners_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all scanners, XSL transform 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
Result of XSL transformation.

Definition at line 16621 of file gsad_omp.c.

References get_one(), and params_t.

16623 {
16624  return get_scanners (connection, credentials, params, NULL, response_data);
16625 }

Here is the call graph for this function:

char* get_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one schedule, XSL transform 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
Result of XSL transformation.

Definition at line 17306 of file gsad_omp.c.

References params_t.

17308 {
17309  return get_schedule (connection, credentials, params, NULL, response_data);
17310 }
char* get_schedules_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all schedules, XSL transform 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
Result of XSL transformation.

Definition at line 17343 of file gsad_omp.c.

References params_t.

17346 {
17347  return get_schedules (connection, credentials, params, NULL, response_data);
17348 }
char* get_system_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
const char *  url,
params_t params,
enum content_type content_type,
gsize *  content_length,
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]content_typeContent type return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Image, or NULL.

Definition at line 17777 of file gsad_omp.c.

References get_one(), GSAD_CONTENT_TYPE_IMAGE_PNG, params_t, and params_value().

Referenced by handle_request().

17783 {
17784  entity_t entity;
17785  entity_t report_entity;
17786  char name[501];
17787  time_t now;
17788  struct tm *now_broken;
17789  const char *slave_id, *duration;
17790  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
17791  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
17792  struct tm start_time, end_time;
17793  gchar *start_time_str, *end_time_str;
17794  gchar *omp_command;
17795 
17796  *content_length = 0;
17797 
17798  if (url == NULL)
17799  return NULL;
17800 
17801  slave_id = params_value (params, "slave_id");
17802 
17803  /* fan/report.png */
17804  if (sscanf (url, "%500[^ /]./report.png", name) == 1)
17805  {
17806  duration = params_value (params, "duration");
17807 
17808  if (duration && strcmp (duration, ""))
17809  {
17810  omp_command = g_markup_printf_escaped ("<get_system_reports"
17811  " name=\"%s\""
17812  " duration=\"%s\""
17813  " slave_id=\"%s\"/>",
17814  name,
17815  duration,
17816  slave_id ? slave_id : "0");
17817  }
17818  else
17819  {
17820  now = time (NULL);
17821  now_broken = localtime (&now);
17822 
17823  start_year = params_value (params, "start_year");
17824  start_month = params_value (params, "start_month");
17825  start_day = params_value (params, "start_day");
17826  start_hour = params_value (params, "start_hour");
17827  start_minute = params_value (params, "start_minute");
17828 
17829  end_year = params_value (params, "end_year");
17830  end_month = params_value (params, "end_month");
17831  end_day = params_value (params, "end_day");
17832  end_hour = params_value (params, "end_hour");
17833  end_minute = params_value (params, "end_minute");
17834 
17835  start_time.tm_year = start_year ? atoi (start_year) - 1900
17836  : now_broken->tm_year;
17837  start_time.tm_mon = start_month ? atoi (start_month) - 1
17838  : now_broken->tm_mon;
17839  start_time.tm_mday = start_day ? atoi (start_day)
17840  : now_broken->tm_mday;
17841  start_time.tm_hour = start_hour ? atoi (start_hour)
17842  : now_broken->tm_hour;
17843  start_time.tm_min = start_minute ? atoi (start_minute)
17844  : now_broken->tm_min;
17845  start_time.tm_zone = now_broken->tm_zone;
17846 
17847  end_time.tm_year = end_year ? atoi (end_year) - 1900
17848  : now_broken->tm_year;
17849  end_time.tm_mon = end_month ? atoi (end_month) - 1
17850  : now_broken->tm_mon;
17851  end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
17852  end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
17853  end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
17854  end_time.tm_zone = now_broken->tm_zone;
17855 
17856 
17857 
17858  start_time_str
17859  = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:00",
17860  start_time.tm_year + 1900,
17861  start_time.tm_mon + 1,
17862  start_time.tm_mday,
17863  start_time.tm_hour,
17864  start_time.tm_min);
17865 
17866  end_time_str
17867  = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:00",
17868  end_time.tm_year + 1900,
17869  end_time.tm_mon + 1,
17870  end_time.tm_mday,
17871  end_time.tm_hour,
17872  end_time.tm_min);
17873 
17874  omp_command
17875  = g_markup_printf_escaped ("<get_system_reports"
17876  " name=\"%s\""
17877  " start_time=\"%s\""
17878  " end_time=\"%s\""
17879  " slave_id=\"%s\"/>",
17880  name,
17881  start_time_str,
17882  end_time_str,
17883  slave_id ? slave_id : "0");
17884  g_free (start_time_str);
17885  g_free (end_time_str);
17886  }
17887 
17888  if (openvas_connection_sendf (connection,
17889  "%s",
17890  omp_command)
17891  == -1)
17892  {
17893  g_free (omp_command);
17894  return NULL;
17895  }
17896  g_free (omp_command);
17897 
17898  entity = NULL;
17899  if (read_entity_c (connection, &entity))
17900  {
17901  return NULL;
17902  }
17903 
17904  report_entity = entity_child (entity, "system_report");
17905  if (report_entity == NULL)
17906  {
17907  free_entity (entity);
17908  return NULL;
17909  }
17910 
17911  report_entity = entity_child (report_entity, "report");
17912  if (report_entity == NULL)
17913  {
17914  free_entity (entity);
17915  return NULL;
17916  }
17917  else
17918  {
17919  char *content_64 = entity_text (report_entity);
17920  char *content = NULL;
17921 
17922  if (content_64 && strlen (content_64))
17923  {
17924  content = (char *) g_base64_decode (content_64,
17925  content_length);
17926 
17927 #if 1
17929  //*content_disposition = g_strdup_printf ("attachment; filename=\"xxx.png\"");
17930 #else
17931  g_free (content);
17932  content = g_strdup ("helo");
17933 #endif
17934  }
17935 
17936  free_entity (entity);
17937  return content;
17938  }
17939  }
17940 
17941  return NULL;
17942 }
content_type
Content types.
Definition: gsad_base.h:120
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* get_system_reports_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all system reports, XSL transform 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
Result of XSL transformation.

Definition at line 17577 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_value().

17580 {
17581  GString *xml;
17582  time_t now, duration, duration_start;
17583  struct tm start_time, end_time;
17584 
17585  const char *slave_id, *given_duration, *range_type;
17586  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
17587  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
17588 
17589  slave_id = params_value (params, "slave_id");
17590 
17591  now = time (NULL);
17592 
17593  given_duration = params_value (params, "duration");
17594  range_type = params_value (params, "range_type");
17595  if (!range_type)
17596  range_type = "duration";
17597 
17598  duration = given_duration ? atoi (given_duration) : 86400;
17599  duration_start = now - duration;
17600 
17601  xml = g_string_new ("<get_system_reports>");
17602 
17603  g_string_append_printf (xml,
17604  "<slave id=\"%s\"/>",
17605  slave_id ? slave_id : "0");
17606  if (strcmp (range_type, "duration") == 0)
17607  {
17608  struct tm *time_broken;
17609  time_broken = localtime (&now);
17610  end_time.tm_year = time_broken->tm_year;
17611  end_time.tm_mon = time_broken->tm_mon;
17612  end_time.tm_mday = time_broken->tm_mday;
17613  end_time.tm_hour = time_broken->tm_hour;
17614  end_time.tm_min = time_broken->tm_min;
17615 
17616  time_broken = localtime (&duration_start);
17617  start_time.tm_year = time_broken->tm_year;
17618  start_time.tm_mon = time_broken->tm_mon;
17619  start_time.tm_mday = time_broken->tm_mday;
17620  start_time.tm_hour = time_broken->tm_hour;
17621  start_time.tm_min = time_broken->tm_min;
17622 
17623  g_string_append_printf (xml,
17624  "<duration>%ld</duration>",
17625  duration);
17626  }
17627  else
17628  {
17629  struct tm *time_broken;
17630  time_broken = localtime (&now);
17631 
17632  start_year = params_value (params, "start_year");
17633  start_month = params_value (params, "start_month");
17634  start_day = params_value (params, "start_day");
17635  start_hour = params_value (params, "start_hour");
17636  start_minute = params_value (params, "start_minute");
17637 
17638  end_year = params_value (params, "end_year");
17639  end_month = params_value (params, "end_month");
17640  end_day = params_value (params, "end_day");
17641  end_hour = params_value (params, "end_hour");
17642  end_minute = params_value (params, "end_minute");
17643 
17644  start_time.tm_year = start_year ? atoi (start_year) - 1900
17645  : time_broken->tm_year;
17646  start_time.tm_mon = start_month ? atoi (start_month) - 1
17647  : time_broken->tm_mon;
17648  start_time.tm_mday = start_day ? atoi (start_day)
17649  : time_broken->tm_mday;
17650  start_time.tm_hour = start_hour ? atoi (start_hour)
17651  : time_broken->tm_hour;
17652  start_time.tm_min = start_minute ? atoi (start_minute)
17653  : time_broken->tm_min;
17654 
17655  end_time.tm_year = end_year ? atoi (end_year) - 1900
17656  : time_broken->tm_year;
17657  end_time.tm_mon = end_month ? atoi (end_month) - 1
17658  : time_broken->tm_mon;
17659  end_time.tm_mday = end_day ? atoi (end_day)
17660  : time_broken->tm_mday;
17661  end_time.tm_hour = end_hour ? atoi (end_hour)
17662  : time_broken->tm_hour;
17663  end_time.tm_min = end_minute ? atoi (end_minute)
17664  : time_broken->tm_min;
17665  }
17666 
17667  g_string_append_printf (xml,
17668  "<start_time>"
17669  "<minute>%i</minute>"
17670  "<hour>%i</hour>"
17671  "<day_of_month>%i</day_of_month>"
17672  "<month>%i</month>"
17673  "<year>%i</year>"
17674  "</start_time>",
17675  start_time.tm_min,
17676  start_time.tm_hour,
17677  start_time.tm_mday,
17678  start_time.tm_mon + 1,
17679  start_time.tm_year + 1900);
17680 
17681  g_string_append_printf (xml,
17682  "<end_time>"
17683  "<minute>%i</minute>"
17684  "<hour>%i</hour>"
17685  "<day_of_month>%i</day_of_month>"
17686  "<month>%i</month>"
17687  "<year>%i</year>"
17688  "</end_time>",
17689  end_time.tm_min,
17690  end_time.tm_hour,
17691  end_time.tm_mday,
17692  end_time.tm_mon + 1,
17693  end_time.tm_year + 1900);
17694 
17695  /* Get the system reports. */
17696 
17697  if (openvas_connection_sendf (connection,
17698  "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
17699  slave_id ? slave_id : "0")
17700  == -1)
17701  {
17702  g_string_free (xml, TRUE);
17703  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17704  return gsad_message (credentials,
17705  "Internal error", __FUNCTION__, __LINE__,
17706  "An internal error occurred while getting the system reports. "
17707  "The current list of system reports is not available. "
17708  "Diagnostics: Failure to send command to manager daemon.",
17709  "/omp?cmd=get_tasks", response_data);
17710  }
17711 
17712  if (read_string_c (connection, &xml))
17713  {
17714  g_string_free (xml, TRUE);
17715  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17716  return gsad_message (credentials,
17717  "Internal error", __FUNCTION__, __LINE__,
17718  "An internal error occurred while getting the system reports. "
17719  "The current list of system reports is not available. "
17720  "Diagnostics: Failure to receive response from manager daemon.",
17721  "/omp?cmd=get_tasks", response_data);
17722  }
17723 
17724  if (command_enabled (credentials, "GET_SCANNERS"))
17725  {
17726  /* Get the OMP scanners. */
17727 
17728  if (openvas_connection_sendf (connection,
17729  "<get_scanners"
17730  " filter=\"sort=name rows=-1 type=4\"/>")
17731  == -1)
17732  {
17733  g_string_free (xml, TRUE);
17734  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17735  return gsad_message (credentials,
17736  "Internal error", __FUNCTION__, __LINE__,
17737  "An internal error occurred while getting the system reports. "
17738  "The current list of system reports is not available. "
17739  "Diagnostics: Failure to send command to manager daemon.",
17740  "/omp?cmd=get_tasks", response_data);
17741  }
17742 
17743  if (read_string_c (connection, &xml))
17744  {
17745  g_string_free (xml, TRUE);
17746  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17747  return gsad_message (credentials,
17748  "Internal error", __FUNCTION__, __LINE__,
17749  "An internal error occurred while getting the system reports. "
17750  "The current list of system reports is not available. "
17751  "Diagnostics: Failure to receive response from manager daemon.",
17752  "/omp?cmd=get_tasks", response_data);
17753  }
17754  }
17755 
17756  /* Cleanup, and return transformed XML. */
17757 
17758  g_string_append (xml, "</get_system_reports>");
17759  return xsl_transform_omp (connection, credentials, params,
17760  g_string_free (xml, FALSE), response_data);
17761 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

char* get_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one tag, XSL transform 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
Result of XSL transformation.

Definition at line 10546 of file gsad_omp.c.

References params_t.

10548 {
10549  return get_tag (connection, credentials, params, NULL, response_data);
10550 }
char* get_tags_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all tags, XSL transform 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
Result of XSL transformation.

Definition at line 10583 of file gsad_omp.c.

10585 {
10586  return get_tags (connection, credentials, params, NULL, response_data);
10587 }
char* get_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one target, XSL transform 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
Result of XSL transformation.

Definition at line 10886 of file gsad_omp.c.

References params_t.

10888 {
10889  return get_target (connection, credentials, params, NULL, response_data);
10890 }
char* get_targets_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all targets, XSL transform 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
Result of XSL transformation.

Definition at line 10923 of file gsad_omp.c.

10925 {
10926  return get_targets (connection, credentials, params, NULL, response_data);
10927 }
char* get_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a task, XSL transform 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
Result of XSL transformation.

Definition at line 5932 of file gsad_omp.c.

References params_t.

5934 {
5935  return get_task (connection, credentials, params, NULL, response_data);
5936 }
char* get_tasks_chart_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a tasks chart, XSL transform 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
Result of XSL transformation.

Definition at line 5578 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

5581 {
5582  return get_tasks_chart (connection, credentials, params, NULL, response_data);
5583 }

Here is the call graph for this function:

char* get_tasks_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 5541 of file gsad_omp.c.

References params_t.

5543 {
5544  return get_tasks (connection, credentials, params, NULL, response_data);
5545 }
char* get_trash_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 18839 of file gsad_omp.c.

References buffer_languages_xml(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

18841 {
18842  return get_trash (connection, credentials, params, NULL, response_data);
18843 }

Here is the call graph for this function:

char* get_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one user, XSL transform 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
Result of XSL transformation.

Definition at line 24779 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, and params_t.

24781 {
24782  return get_user (connection, credentials, params, NULL, response_data);
24783 }

Here is the call graph for this function:

char* get_users_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all users, XSL transform 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
Result of XSL transformation.

Definition at line 24865 of file gsad_omp.c.

24867 {
24868  return get_users (connection, credentials, params, NULL, response_data);
24869 }
char* import_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Import config, get all configs, XSL transform 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
Result of XSL transformation.

Definition at line 11468 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

11471 {
11472  const char *no_redirect;
11473  gchar *command, *html, *response;
11474  entity_t entity;
11475  int ret;
11476 
11477  no_redirect = params_value (params, "no_redirect");
11478 
11479  /* Create the config. */
11480 
11481  response = NULL;
11482  entity = NULL;
11483  command = g_strdup_printf ("<create_config>"
11484  "%s"
11485  "</create_config>",
11486  params_value (params, "xml_file"));
11487  ret = omp (connection, credentials, &response, &entity, response_data,
11488  command);
11489  g_free (command);
11490  switch (ret)
11491  {
11492  case 0:
11493  case -1:
11494  break;
11495  case 1:
11496  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11497  return gsad_message (credentials,
11498  "Internal error", __FUNCTION__, __LINE__,
11499  "An internal error occurred while importing a config. "
11500  "The schedule remains the same. "
11501  "Diagnostics: Failure to send command to manager daemon.",
11502  "/omp?cmd=get_configs", response_data);
11503  case 2:
11504  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11505  return gsad_message (credentials,
11506  "Internal error", __FUNCTION__, __LINE__,
11507  "An internal error occurred while importing a config. "
11508  "It is unclear whether the schedule has been saved or not. "
11509  "Diagnostics: Failure to receive response from manager daemon.",
11510  "/omp?cmd=get_configs", response_data);
11511  default:
11512  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11513  return gsad_message (credentials,
11514  "Internal error", __FUNCTION__, __LINE__,
11515  "An internal error occurred while importing a config. "
11516  "It is unclear whether the schedule has been saved or not. "
11517  "Diagnostics: Internal Error.",
11518  "/omp?cmd=get_configs", response_data);
11519  }
11520 
11521  /* Cleanup, and return transformed XML. */
11522 
11523  html = response_from_entity (connection, credentials, params, entity,
11524  (no_redirect && strcmp (no_redirect, "0")),
11525  NULL, "get_configs",
11526  NULL, "new_config",
11527  "Import Config", response_data);
11528  free_entity (entity);
11529  g_free (response);
11530  return html;
11531 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* import_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Import port list, get all port_lists, XSL transform 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
Result of XSL transformation.

Definition at line 22943 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

22946 {
22947  const char *no_redirect;
22948  gchar *command, *html, *response;
22949  entity_t entity;
22950  int ret;
22951 
22952  no_redirect = params_value (params, "no_redirect");
22953 
22954  /* Create the port list. */
22955 
22956  response = NULL;
22957  entity = NULL;
22958  command = g_strdup_printf ("<create_port_list>"
22959  "%s"
22960  "</create_port_list>",
22961  params_value (params, "xml_file"));
22962  ret = omp (connection, credentials, &response, &entity, response_data,
22963  command);
22964  g_free (command);
22965  switch (ret)
22966  {
22967  case 0:
22968  case -1:
22969  break;
22970  case 1:
22971  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22972  return gsad_message (credentials,
22973  "Internal error", __FUNCTION__, __LINE__,
22974  "An internal error occurred while importing a port_list. "
22975  "The schedule remains the same. "
22976  "Diagnostics: Failure to send command to manager daemon.",
22977  "/omp?cmd=get_port_lists",
22978  response_data);
22979  case 2:
22980  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22981  return gsad_message (credentials,
22982  "Internal error", __FUNCTION__, __LINE__,
22983  "An internal error occurred while importing a port_list. "
22984  "It is unclear whether the schedule has been saved or not. "
22985  "Diagnostics: Failure to receive response from manager daemon.",
22986  "/omp?cmd=get_port_lists",
22987  response_data);
22988  default:
22989  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22990  return gsad_message (credentials,
22991  "Internal error", __FUNCTION__, __LINE__,
22992  "An internal error occurred while importing a port_list. "
22993  "It is unclear whether the schedule has been saved or not. "
22994  "Diagnostics: Internal Error.",
22995  "/omp?cmd=get_port_lists",
22996  response_data);
22997  }
22998 
22999  /* Cleanup, and return transformed XML. */
23000 
23001  html = response_from_entity (connection, credentials, params, entity,
23002  (no_redirect && strcmp (no_redirect, "0")),
23003  NULL, "get_port_lists",
23004  NULL, "new_port_list",
23005  "Import Port List", response_data);
23006  free_entity (entity);
23007  g_free (response);
23008  return html;
23009 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* import_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Import report format, get all report formats, XSL transform 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 of XSL transformation.

Definition at line 18153 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_add(), and params_value().

18156 {
18157  const char* no_redirect;
18158  gchar *command, *html, *response;
18159  entity_t entity;
18160  int ret;
18161 
18162  no_redirect = params_value (params, "no_redirect");
18163 
18164  /* Create the report format. */
18165 
18166  response = NULL;
18167  entity = NULL;
18168  command = g_strdup_printf ("<create_report_format>"
18169  "%s"
18170  "</create_report_format>",
18171  params_value (params, "xml_file"));
18172  ret = omp (connection, credentials, &response, &entity, response_data,
18173  command);
18174  g_free (command);
18175  switch (ret)
18176  {
18177  case 0:
18178  case -1:
18179  break;
18180  case 1:
18181  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18182  return gsad_message (credentials,
18183  "Internal error", __FUNCTION__, __LINE__,
18184  "An internal error occurred while importing a report format. "
18185  "The schedule remains the same. "
18186  "Diagnostics: Failure to send command to manager daemon.",
18187  "/omp?cmd=get_report_formats", response_data);
18188  case 2:
18189  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18190  return gsad_message (credentials,
18191  "Internal error", __FUNCTION__, __LINE__,
18192  "An internal error occurred while importing a report format. "
18193  "It is unclear whether the schedule has been saved or not. "
18194  "Diagnostics: Failure to receive response from manager daemon.",
18195  "/omp?cmd=get_report_formats", response_data);
18196  default:
18197  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18198  return gsad_message (credentials,
18199  "Internal error", __FUNCTION__, __LINE__,
18200  "An internal error occurred while importing a report format. "
18201  "It is unclear whether the schedule has been saved or not. "
18202  "Diagnostics: Internal Error.",
18203  "/omp?cmd=get_report_formats", response_data);
18204  }
18205 
18206  /* Cleanup, and return transformed XML. */
18207 
18208  if (entity_attribute (entity, "id"))
18209  params_add (params, "report_format_id", entity_attribute (entity, "id"));
18210  html = response_from_entity (connection, credentials, params, entity,
18211  (no_redirect && strcmp (no_redirect, "0")),
18212  NULL, "get_report_formats",
18213  NULL, "new_report_format",
18214  "Create Report Format", response_data);
18215 
18216  free_entity (entity);
18217  g_free (response);
18218  return html;
18219 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808

Here is the call graph for this function:

char* import_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Import report, get all reports, XSL transform 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
Result of XSL transformation.

Definition at line 4008 of file gsad_omp.c.

References create_report_omp().

4011 {
4012  return create_report_omp (connection, credentials, params, response_data);
4013 }
char * create_report_omp(openvas_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a report, get all tasks, XSL transform the result.
Definition: gsad_omp.c:3854

Here is the call graph for this function:

void init_find_by_value ( find_by_value_t find,
gchar *  value 
)

Definition at line 396 of file gsad_omp.c.

References find_by_value_t::keys, param::value, and find_by_value_t::value.

Referenced by delete_filter_omp().

397 {
398  find->keys = NULL;
399  find->value = value;
400 }
gchar * value
Definition: gsad_omp.c:391
GList * keys
Definition: gsad_omp.c:392

Here is the caller graph for this function:

char* logout ( credentials_t credentials,
const gchar *  message,
cmd_response_data_t response_data 
)

Setup edit_user XML, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]messageLogin screen message.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 25280 of file gsad_omp.c.

References ctime_r_strip_newline(), login_xml(), credentials_t::params, params_value(), credentials_t::token, token_user_remove(), and xsl_transform().

Referenced by exec_omp_get(), exec_omp_post(), handle_request(), and save_user_omp().

25282 {
25283  time_t now;
25284  gchar *xml;
25285  char *res;
25286  char ctime_now[200];
25287  int ret;
25288  const char* xml_flag;
25289  xml_flag = params_value (credentials->params, "xml");
25290 
25291  if (credentials->token == NULL)
25292  return NULL;
25293 
25294  ret = token_user_remove (credentials->token);
25295  if (ret)
25296  return NULL;
25297 
25298  now = time (NULL);
25299  ctime_r_strip_newline (&now, ctime_now);
25300 
25301  xml = login_xml (message, NULL, ctime_now, NULL, NULL, NULL);
25302 
25303  if (xml_flag && strcmp (xml_flag, "0"))
25304  return xml;
25305 
25306  res = xsl_transform (xml, response_data);
25307  g_free (xml);
25308  return res;
25309 }
int token_user_remove(const char *)
Remove a user from the session "database", releasing the user_t too.
Definition: gsad.c:980
gchar * login_xml(const gchar *message, const gchar *token, const gchar *time, const gchar *url, const gchar *i18n, const gchar *guest)
Generate XML for login page.
Definition: gsad_base.c:584
char * token
Session token.
Definition: gsad_base.h:73
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
char * xsl_transform(const char *xml_text, cmd_response_data_t *response_data)
XSL Transformation.
Definition: gsad_base.c:445
params_t * params
Request parameters.
Definition: gsad_base.h:84
char * ctime_r_strip_newline(time_t *time, char *string)
Return string from ctime_r with newline replaces with terminator.
Definition: gsad_base.c:241

Here is the call graph for this function:

Here is the caller graph for this function:

int manager_connect ( credentials_t credentials,
openvas_connection_t *  connection,
cmd_response_data_t response_data 
)

Connect to OpenVAS Manager daemon.

If the Manager is down, logout and return the login HTML in html.

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 failed to connect, -2 authentication failed.

Definition at line 27835 of file gsad_omp.c.

References cmd_response_data_t::http_status_code, manager_address, manager_port, openvas_connection_open(), credentials_t::password, and credentials_t::username.

Referenced by exec_omp_get(), exec_omp_post(), and handle_request().

27837 {
27838  omp_authenticate_info_opts_t auth_opts;
27839 
27840  if (openvas_connection_open (connection,
27842  manager_port))
27843  {
27844  response_data->http_status_code = MHD_HTTP_SERVICE_UNAVAILABLE;
27845  return -1;
27846  }
27847 
27848 #if 0
27849  g_debug ("in manager_connect: Trying to authenticate with %s/%s\n",
27850  credentials->username,
27851  credentials->password);
27852 #endif
27853 
27854 
27855  auth_opts = omp_authenticate_info_opts_defaults;
27856  auth_opts.username = credentials->username;
27857  auth_opts.password = credentials->password;
27858  if (omp_authenticate_info_ext_c (connection, auth_opts))
27859  {
27860  g_debug ("authenticate failed!\n");
27861  openvas_connection_close (connection);
27862  return -2;
27863  }
27864 
27865 #ifdef DEBUG
27866  /* Enable this if you need the CGI to sleep after launch. This can be useful
27867  * if you need to attach to manager process the CGI is talking to for
27868  * debugging purposes.
27869  *
27870  * An easier method is to run gsad under gdb and set a breakpoint here.
27871  */
27872  g_debug ("Sleeping!");
27873  sleep (10);
27874 #endif
27875  return 0;
27876 }
gchar * manager_address
The address the manager is on.
Definition: gsad_omp.c:96
char * username
Name of user.
Definition: gsad_base.h:69
int manager_port
The port the manager is on.
Definition: gsad_omp.c:101
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_omp.c:27580
char * password
User&#39;s password.
Definition: gsad_base.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

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 725 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), param::value, and param::value_size.

Referenced by save_config_omp().

726 {
727  params_iterator_t iter;
728  param_t *param;
729  char *name;
730 
731  params_iterator_init (&iter, params);
732  while (params_iterator_next (&iter, &name, &param))
733  if (param->value_size
734  && param->value[0] == '1'
735  && strcmp (name, string) == 0)
736  return 1;
737  return 0;
738 }
gchar * value
Definition: gsad_base.h:148
int value_size
Definition: gsad_base.h:154
Request parameter.
Definition: gsad_base.h:146
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* message_invalid ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data,
const char *  message,
const char *  status,
const char *  op_name,
const char *  next_cmd 
)

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]statusStatus code.
[in]op_nameOperation name.
[in]next_cmdNext command.
Returns
Result of XSL transformation.

Definition at line 1472 of file gsad_omp.c.

References credentials_t::current_page, get_info(), cmd_response_data_t::http_status_code, params_t, params_value(), cmd_response_data_t::redirect, and set_http_status_from_entity().

Referenced by create_credential_omp(), create_report_omp(), and create_target_omp().

1476 {
1477  gchar *ret;
1478  gchar *next_url;
1479 
1480  next_url = next_page_url (credentials, params, next_cmd, NULL, op_name,
1481  status, message);
1482  ret = action_result_page (connection, credentials, params, response_data,
1483  op_name, G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
1484  message, NULL,
1485  next_url);
1486  g_free (next_url);
1487  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
1488  return ret;
1489 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* move_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Reassign a task to a new OMP 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
Result of XSL transformation.

Definition at line 5091 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

5093 {
5094  gchar *command, *response, *html;
5095  const char *no_redirect, *task_id, *slave_id;
5096  int ret;
5097  entity_t entity;
5098 
5099  no_redirect = params_value (params, "no_redirect");
5100  slave_id = params_value (params, "slave_id");
5101  task_id = params_value (params, "task_id");
5102 
5103  command = g_strdup_printf ("<move_task task_id=\"%s\" slave_id=\"%s\"/>",
5104  task_id ? task_id : "",
5105  slave_id ? slave_id : "");
5106 
5107  response = NULL;
5108  entity = NULL;
5109  ret = omp (connection, credentials, &response, &entity, response_data,
5110  command);
5111  g_free (command);
5112  switch (ret)
5113  {
5114  case 0:
5115  break;
5116  case -1:
5117  /* 'omp' set response. */
5118  return response;
5119  case 1:
5120  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5121  return gsad_message (credentials,
5122  "Internal error", __FUNCTION__, __LINE__,
5123  "An internal error occurred while moving a task. "
5124  "The task was not moved. "
5125  "Diagnostics: Failure to send command to manager daemon.",
5126  "/omp?cmd=get_tasks", response_data);
5127  case 2:
5128  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5129  return gsad_message (credentials,
5130  "Internal error", __FUNCTION__, __LINE__,
5131  "An internal error occurred while moving a task. "
5132  "It is unclear whether the task has been moved or not. "
5133  "Diagnostics: Failure to receive response from manager daemon.",
5134  "/omp?cmd=get_tasks", response_data);
5135  default:
5136  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5137  return gsad_message (credentials,
5138  "Internal error", __FUNCTION__, __LINE__,
5139  "An internal error occurred while moving a task. "
5140  "It is unclear whether the task has been moved or not. "
5141  "Diagnostics: Internal Error.",
5142  "/omp?cmd=get_tasks", response_data);
5143  }
5144 
5145  html = response_from_entity (connection, credentials, params, entity,
5146  (no_redirect && strcmp (no_redirect, "0")),
5147  NULL, "get_tasks",
5148  NULL, "get_tasks",
5149  "Move Task", response_data);
5150 
5151  free_entity (entity);
5152  g_free (response);
5153  return html;
5154 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* new_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new agent 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
Result of XSL transformation.

Definition at line 6911 of file gsad_omp.c.

6913 {
6914  return new_agent (connection, credentials, params, NULL, response_data);
6915 }
char* new_alert_omp ( openvas_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
Result of XSL transformation.

Definition at line 7993 of file gsad_omp.c.

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

7995 {
7996  return new_alert (connection, credentials, params, NULL, response_data);
7997 }

Here is the call graph for this function:

char* new_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new scan config 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
Result of XSL transformation.

Definition at line 11318 of file gsad_omp.c.

References params_t.

11320 {
11321  return new_config (connection, credentials, params, NULL, response_data);
11322 }
char* new_container_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new task.

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
Result of XSL transformation.

Definition at line 3773 of file gsad_omp.c.

References command_enabled(), and params_t.

3776 {
3777  return new_container_task (connection, credentials, NULL, params, NULL,
3778  response_data);
3779 }

Here is the call graph for this function:

char* new_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new Credential.

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
Result of XSL transformation.

Definition at line 6623 of file gsad_omp.c.

References edit_resource(), and params_t.

6626 {
6627  return new_credential (connection, credentials, params, NULL, response_data);
6628 }

Here is the call graph for this function:

char* new_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new filter.

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
Result of XSL transformation.

Definition at line 24094 of file gsad_omp.c.

Referenced by exec_omp_get().

24096 {
24097  return new_filter (connection, credentials, params, NULL, response_data);
24098 }

Here is the caller graph for this function:

char* new_group_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new group.

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
Result of XSL transformation.

Definition at line 20224 of file gsad_omp.c.

20226 {
20227  return new_group (connection, credentials, params, NULL, response_data);
20228 }
char* new_host_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new host 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
Result of XSL transformation.

Definition at line 26787 of file gsad_omp.c.

26789 {
26790  return new_host (connection, credentials, params, NULL, response_data);
26791 }
char* new_note ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Return the new notes page.

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
Result of XSL transformation.

Definition at line 15269 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get(), and new_note_omp().

15272 {
15273  GString *xml;
15274  const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
15275  const char *next;
15276  /* Passthroughs. */
15277  const char *report_id, *first_result, *max_results, *sort_field;
15278  const char *sort_order, *levels, *autofp, *notes;
15279  const char *overrides, *result_hosts_only, *search_phrase;
15280 
15281  result_id = params_value (params, "result_id");
15282  task_id = params_value (params, "task_id");
15283 
15284  next = params_value (params, "next");
15285  first_result = params_value (params, "first_result");
15286  max_results = params_value (params, "max_results");
15287  levels = params_value (params, "levels");
15288  autofp = params_value (params, "autofp");
15289  notes = params_value (params, "notes");
15290  report_id = params_value (params, "report_id");
15291  search_phrase = params_value (params, "search_phrase");
15292  sort_field = params_value (params, "sort_field");
15293  sort_order = params_value (params, "sort_order");
15294  task_name = params_value (params, "name");
15295  severity = params_value (params, "severity");
15296  result_hosts_only = params_value (params, "result_hosts_only");
15297 
15298  hosts = params_value (params, "hosts");
15299  oid = params_value (params, "oid");
15300  port = params_value (params, "port");
15301  overrides = params_value (params, "overrides");
15302 
15303  if (result_id == NULL || task_id == NULL)
15304  {
15305  xml = g_string_new ("");
15306 
15307  xml_string_append (xml,
15308  "<new_note>"
15309  "<nvt id=\"%s\"/>"
15310  "<next>%s</next>",
15311  oid ? oid : "0",
15312  next ? next : "");
15313 
15314  if (extra_xml)
15315  g_string_append (xml, extra_xml);
15316 
15317  if (openvas_connection_sendf (connection,
15318  "<get_tasks"
15319  " schedules_only=\"1\""
15320  " details=\"0\"/>")
15321  == -1)
15322  {
15323  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15324  return gsad_message (credentials,
15325  "Internal error", __FUNCTION__, __LINE__,
15326  "An internal error occurred while creating a new note. "
15327  "No new note was created. "
15328  "Diagnostics: Failure to send command to manager daemon.",
15329  "/omp?cmd=get_notes", response_data);
15330  }
15331 
15332  if (read_string_c (connection, &xml))
15333  {
15334  g_string_free (xml, TRUE);
15335  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15336  return gsad_message (credentials,
15337  "Internal error", __FUNCTION__, __LINE__,
15338  "An internal error occurred while creating a new note. "
15339  "No new note was created. "
15340  "Diagnostics: Failure to receive response from manager daemon.",
15341  "/omp?cmd=get_notes", response_data);
15342  }
15343 
15344  g_string_append (xml, "</new_note>");
15345  return xsl_transform_omp (connection, credentials, params,
15346  g_string_free (xml, FALSE), response_data);
15347  }
15348 
15349  if (openvas_connection_sendf (connection,
15350  "<get_results"
15351  " result_id=\"%s\""
15352  " task_id=\"%s\""
15353  " notes_details=\"1\""
15354  " notes=\"1\""
15355  " result_hosts_only=\"1\"/>",
15356  result_id,
15357  task_id)
15358  == -1)
15359  {
15360  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15361  return gsad_message (credentials,
15362  "Internal error", __FUNCTION__, __LINE__,
15363  "An internal error occurred while creating a new note. "
15364  "No new note was created. "
15365  "Diagnostics: Failure to send command to manager daemon.",
15366  "/omp?cmd=get_notes", response_data);
15367  }
15368 
15369  xml = g_string_new ("");
15370 
15371  xml_string_append (xml,
15372  "<new_note>"
15373  "<nvt id=\"%s\"/>"
15374  "<hosts>%s</hosts>"
15375  "<port>%s</port>"
15376  "<severity>%s</severity>"
15377  "<task id=\"%s\">"
15378  "<name>%s</name>"
15379  "</task>"
15380  "<result id=\"%s\"/>"
15381  "<next>%s</next>"
15382  /* Passthroughs. */
15383  "<report id=\"%s\"/>"
15384  "<first_result>%s</first_result>"
15385  "<max_results>%s</max_results>"
15386  "<sort_field>%s</sort_field>"
15387  "<sort_order>%s</sort_order>"
15388  "<levels>%s</levels>"
15389  "<autofp>%s</autofp>"
15390  "<notes>%s</notes>"
15391  "<overrides>%s</overrides>"
15392  "<result_hosts_only>%s</result_hosts_only>"
15393  "<search_phrase>%s</search_phrase>",
15394  oid,
15395  hosts,
15396  /* port is NULL for CVE scan results. */
15397  port ? port : "",
15398  severity,
15399  task_id,
15400  task_name,
15401  result_id,
15402  next ? next : "",
15403  report_id,
15404  first_result,
15405  max_results,
15406  sort_field,
15407  sort_order,
15408  levels,
15409  autofp,
15410  notes,
15411  overrides,
15412  result_hosts_only,
15413  search_phrase);
15414 
15415  if (extra_xml)
15416  g_string_append (xml, extra_xml);
15417 
15418  if (read_string_c (connection, &xml))
15419  {
15420  g_string_free (xml, TRUE);
15421  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15422  return gsad_message (credentials,
15423  "Internal error", __FUNCTION__, __LINE__,
15424  "An internal error occurred while creating a new note. "
15425  "It is unclear whether the note has been created or not. "
15426  "Diagnostics: Failure to receive response from manager daemon.",
15427  "/omp?cmd=get_notes", response_data);
15428  }
15429 
15430  /* Cleanup, and return transformed XML. */
15431 
15432  g_string_append (xml, "</new_note>");
15433  return xsl_transform_omp (connection, credentials, params,
15434  g_string_free (xml, FALSE), response_data);
15435 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* new_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new notes 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
Result of XSL transformation.

Definition at line 15448 of file gsad_omp.c.

References new_note().

15450 {
15451  return new_note (connection, credentials, params, NULL, response_data);
15452 }
char * new_note(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new notes page.
Definition: gsad_omp.c:15269

Here is the call graph for this function:

char* new_override ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Return the new overrides page.

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
Result of XSL transformation.

Definition at line 15950 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

Referenced by exec_omp_get(), and new_override_omp().

15953 {
15954  GString *xml;
15955  const char *oid, *hosts, *port, *severity, *task_id, *task_name, *result_id;
15956  const char *next;
15957  /* Passthroughs. */
15958  const char *report_id, *first_result, *max_results, *sort_field;
15959  const char *sort_order, *levels, *autofp, *notes;
15960  const char *overrides, *result_hosts_only, *search_phrase;
15961 
15962  result_id = params_value (params, "result_id");
15963  task_id = params_value (params, "task_id");
15964 
15965  next = params_value (params, "next");
15966  first_result = params_value (params, "first_result");
15967  max_results = params_value (params, "max_results");
15968  levels = params_value (params, "levels");
15969  autofp = params_value (params, "autofp");
15970  notes = params_value (params, "notes");
15971  report_id = params_value (params, "report_id");
15972  search_phrase = params_value (params, "search_phrase");
15973  sort_field = params_value (params, "sort_field");
15974  sort_order = params_value (params, "sort_order");
15975  task_name = params_value (params, "name");
15976  severity = params_value (params, "severity");
15977  result_hosts_only = params_value (params, "result_hosts_only");
15978 
15979  hosts = params_value (params, "hosts");
15980  oid = params_value (params, "oid");
15981  port = params_value (params, "port");
15982  overrides = params_value (params, "overrides");
15983 
15984  if (result_id == NULL || task_id == NULL)
15985  {
15986  xml = g_string_new ("");
15987 
15988  xml_string_append (xml,
15989  "<new_override>"
15990  "<nvt id=\"%s\"/>"
15991  "<next>%s</next>",
15992  oid ? oid : "0",
15993  next ? next : "");
15994 
15995  if (extra_xml)
15996  g_string_append (xml, extra_xml);
15997 
15998  if (openvas_connection_sendf (connection,
15999  "<get_tasks"
16000  " schedules_only=\"1\""
16001  " details=\"0\"/>")
16002  == -1)
16003  {
16004  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16005  return gsad_message (credentials,
16006  "Internal error", __FUNCTION__, __LINE__,
16007  "An internal error occurred while creating a new override. "
16008  "No new override was created. "
16009  "Diagnostics: Failure to send command to manager daemon.",
16010  "/omp?cmd=get_overrides", response_data);
16011  }
16012 
16013  if (read_string_c (connection, &xml))
16014  {
16015  g_string_free (xml, TRUE);
16016  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16017  return gsad_message (credentials,
16018  "Internal error", __FUNCTION__, __LINE__,
16019  "An internal error occurred while creating a new override. "
16020  "No new override was created. "
16021  "Diagnostics: Failure to receive response from manager daemon.",
16022  "/omp?cmd=get_overrides", response_data);
16023  }
16024 
16025  g_string_append (xml, "</new_override>");
16026  return xsl_transform_omp (connection, credentials, params,
16027  g_string_free (xml, FALSE), response_data);
16028  }
16029 
16030  if (openvas_connection_sendf (connection,
16031  "<get_results"
16032  " result_id=\"%s\""
16033  " task_id=\"%s\""
16034  " notes_details=\"1\""
16035  " notes=\"1\""
16036  " overrides_details=\"1\""
16037  " overrides=\"1\""
16038  " result_hosts_only=\"1\"/>",
16039  result_id,
16040  task_id)
16041  == -1)
16042  {
16043  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16044  return gsad_message (credentials,
16045  "Internal error", __FUNCTION__, __LINE__,
16046  "An internal error occurred while creating a new override. "
16047  "No new override was created. "
16048  "Diagnostics: Failure to send command to manager daemon.",
16049  "/omp?cmd=get_overrides", response_data);
16050  }
16051 
16052  xml = g_string_new ("");
16053 
16054  xml_string_append (xml,
16055  "<new_override>"
16056  "<nvt id=\"%s\"/>"
16057  "<hosts>%s</hosts>"
16058  "<port>%s</port>"
16059  "<severity>%s</severity>"
16060  "<task id=\"%s\">"
16061  "<name>%s</name>"
16062  "</task>"
16063  "<result id=\"%s\"/>"
16064  "<next>%s</next>"
16065  /* Passthroughs. */
16066  "<report id=\"%s\"/>"
16067  "<first_result>%s</first_result>"
16068  "<max_results>%s</max_results>"
16069  "<sort_field>%s</sort_field>"
16070  "<sort_order>%s</sort_order>"
16071  "<levels>%s</levels>"
16072  "<autofp>%s</autofp>"
16073  "<notes>%s</notes>"
16074  "<overrides>%s</overrides>"
16075  "<result_hosts_only>%s</result_hosts_only>"
16076  "<search_phrase>%s</search_phrase>",
16077  oid,
16078  hosts,
16079  /* port is NULL for CVE scan results. */
16080  port ? port : "",
16081  severity,
16082  task_id,
16083  task_name,
16084  result_id,
16085  next ? next : "",
16086  report_id,
16087  first_result,
16088  max_results,
16089  sort_field,
16090  sort_order,
16091  levels,
16092  autofp,
16093  notes,
16094  overrides,
16095  result_hosts_only,
16096  search_phrase);
16097 
16098  if (extra_xml)
16099  g_string_append (xml, extra_xml);
16100 
16101  if (read_string_c (connection, &xml))
16102  {
16103  g_string_free (xml, TRUE);
16104  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16105  return gsad_message (credentials,
16106  "Internal error", __FUNCTION__, __LINE__,
16107  "An internal error occurred while creating a new override. "
16108  "It is unclear whether the override has been created or not. "
16109  "Diagnostics: Failure to receive response from manager daemon.",
16110  "/omp?cmd=get_overrides", response_data);
16111  }
16112 
16113  /* Cleanup, and return transformed XML. */
16114 
16115  g_string_append (xml, "</new_override>");
16116  return xsl_transform_omp (connection, credentials, params,
16117  g_string_free (xml, FALSE), response_data);
16118 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* new_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new overrides 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
Result of XSL transformation.

Definition at line 16131 of file gsad_omp.c.

References new_override().

16133 {
16134  return new_override (connection, credentials, params, NULL, response_data);
16135 }
char * new_override(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new overrides page.
Definition: gsad_omp.c:15950

Here is the call graph for this function:

char* new_permission ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup new_permission XML, XSL transform 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
Result of XSL transformation.

Definition at line 20675 of file gsad_omp.c.

References command_enabled(), gsad_message(), and cmd_response_data_t::http_status_code.

Referenced by create_permissions_omp(), exec_omp_get(), and new_permission_omp().

20678 {
20679  GString *xml;
20680 
20681  xml = g_string_new ("<new_permission>");
20682 
20683  if (command_enabled (credentials, "GET_USERS"))
20684  {
20685  gchar *response;
20686  entity_t entity;
20687 
20688  response = NULL;
20689  entity = NULL;
20690  switch (omp (connection, credentials, &response, &entity, response_data,
20691  "<get_users filter=\"rows=-1 permission=get_users\"/>"))
20692  {
20693  case 0:
20694  case -1:
20695  break;
20696  case 1:
20697  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20698  return gsad_message (credentials,
20699  "Internal error", __FUNCTION__, __LINE__,
20700  "An internal error occurred getting the user list. "
20701  "No new user was created. "
20702  "Diagnostics: Failure to send command to manager daemon.",
20703  "/omp?cmd=get_users", response_data);
20704  case 2:
20705  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20706  return gsad_message (credentials,
20707  "Internal error", __FUNCTION__, __LINE__,
20708  "An internal error occurred getting the user list. "
20709  "No new user was created. "
20710  "Diagnostics: Failure to receive response from manager daemon.",
20711  "/omp?cmd=get_users", response_data);
20712  default:
20713  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20714  return gsad_message (credentials,
20715  "Internal error", __FUNCTION__, __LINE__,
20716  "An internal error occurred getting the user list. "
20717  "No new user was created. "
20718  "Diagnostics: Internal Error.",
20719  "/omp?cmd=get_users", response_data);
20720  }
20721 
20722  g_string_append (xml, response);
20723 
20724  free_entity (entity);
20725  g_free (response);
20726  }
20727 
20728  if (command_enabled (credentials, "GET_GROUPS"))
20729  {
20730  gchar *response;
20731  entity_t entity;
20732 
20733  response = NULL;
20734  entity = NULL;
20735  switch (omp (connection, credentials, &response, &entity, response_data,
20736  "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
20737  {
20738  case 0:
20739  case -1:
20740  break;
20741  case 1:
20742  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20743  return gsad_message (credentials,
20744  "Internal error", __FUNCTION__, __LINE__,
20745  "An internal error occurred getting the group list. "
20746  "No new user was created. "
20747  "Diagnostics: Failure to send command to manager daemon.",
20748  "/omp?cmd=get_users", response_data);
20749  case 2:
20750  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20751  return gsad_message (credentials,
20752  "Internal error", __FUNCTION__, __LINE__,
20753  "An internal error occurred getting the group list. "
20754  "No new user was created. "
20755  "Diagnostics: Failure to receive response from manager daemon.",
20756  "/omp?cmd=get_users", response_data);
20757  default:
20758  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20759  return gsad_message (credentials,
20760  "Internal error", __FUNCTION__, __LINE__,
20761  "An internal error occurred getting the group list. "
20762  "No new user was created. "
20763  "Diagnostics: Internal Error.",
20764  "/omp?cmd=get_users", response_data);
20765  }
20766 
20767  g_string_append (xml, response);
20768 
20769  free_entity (entity);
20770  g_free (response);
20771  }
20772 
20773  if (command_enabled (credentials, "GET_ROLES"))
20774  {
20775  gchar *response;
20776  entity_t entity;
20777 
20778  response = NULL;
20779  entity = NULL;
20780  switch (omp (connection, credentials, &response, &entity, response_data,
20781  "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
20782  {
20783  case 0:
20784  case -1:
20785  break;
20786  case 1:
20787  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20788  return gsad_message (credentials,
20789  "Internal error", __FUNCTION__, __LINE__,
20790  "An internal error occurred getting the role list. "
20791  "No new user was created. "
20792  "Diagnostics: Failure to send command to manager daemon.",
20793  "/omp?cmd=get_users", response_data);
20794  case 2:
20795  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20796  return gsad_message (credentials,
20797  "Internal error", __FUNCTION__, __LINE__,
20798  "An internal error occurred getting the role list. "
20799  "No new user was created. "
20800  "Diagnostics: Failure to receive response from manager daemon.",
20801  "/omp?cmd=get_users", response_data);
20802  default:
20803  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20804  return gsad_message (credentials,
20805  "Internal error", __FUNCTION__, __LINE__,
20806  "An internal error occurred getting the role list. "
20807  "No new user was created. "
20808  "Diagnostics: Internal Error.",
20809  "/omp?cmd=get_users", response_data);
20810  }
20811 
20812  g_string_append (xml, response);
20813 
20814  free_entity (entity);
20815  g_free (response);
20816  }
20817 
20818  if (extra_xml)
20819  g_string_append (xml, extra_xml);
20820 
20821  g_string_append (xml, "</new_permission>");
20822 
20823  return xsl_transform_omp (connection, credentials, params,
20824  g_string_free (xml, FALSE), response_data);
20825 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* new_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup new_permission XML, XSL transform 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
Result of XSL transformation.

Definition at line 20838 of file gsad_omp.c.

References new_permission().

20841 {
20842  return new_permission (connection, credentials, params, NULL, response_data);
20843 }
char * new_permission(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
Definition: gsad_omp.c:20675

Here is the call graph for this function:

char* new_permissions ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Setup new_permissions XML, XSL transform 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
Result of XSL transformation.

Definition at line 21202 of file gsad_omp.c.

References command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

Referenced by exec_omp_get(), and new_permissions_omp().

21205 {
21206  GString *xml;
21207  const char *resource_id, *restrict_type;
21208  params_t *related;
21209  params_iterator_t related_iterator;
21210  param_t *related_param;
21211  char *related_id;
21212 
21213  xml = g_string_new ("<new_permissions>");
21214 
21215  if (command_enabled (credentials, "GET_USERS"))
21216  {
21217  gchar *response;
21218  entity_t entity;
21219 
21220  response = NULL;
21221  entity = NULL;
21222  switch (omp (connection, credentials, &response, &entity, response_data,
21223  "<get_users filter=\"rows=-1 permission=get_users\"/>"))
21224  {
21225  case 0:
21226  case -1:
21227  break;
21228  case 1:
21229  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21230  return gsad_message (credentials,
21231  "Internal error", __FUNCTION__, __LINE__,
21232  "An internal error occurred getting the user list. "
21233  "No new user was created. "
21234  "Diagnostics: Failure to send command to manager daemon.",
21235  "/omp?cmd=get_users", response_data);
21236  case 2:
21237  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21238  return gsad_message (credentials,
21239  "Internal error", __FUNCTION__, __LINE__,
21240  "An internal error occurred getting the user list. "
21241  "No new user was created. "
21242  "Diagnostics: Failure to receive response from manager daemon.",
21243  "/omp?cmd=get_users", response_data);
21244  default:
21245  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21246  return gsad_message (credentials,
21247  "Internal error", __FUNCTION__, __LINE__,
21248  "An internal error occurred getting the user list. "
21249  "No new user was created. "
21250  "Diagnostics: Internal Error.",
21251  "/omp?cmd=get_users", response_data);
21252  }
21253 
21254  g_string_append (xml, response);
21255 
21256  free_entity (entity);
21257  g_free (response);
21258  }
21259 
21260  if (command_enabled (credentials, "GET_GROUPS"))
21261  {
21262  gchar *response;
21263  entity_t entity;
21264 
21265  response = NULL;
21266  entity = NULL;
21267  switch (omp (connection, credentials, &response, &entity, response_data,
21268  "<get_groups filter=\"rows=-1 permission=get_groups\"/>"))
21269  {
21270  case 0:
21271  case -1:
21272  break;
21273  case 1:
21274  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21275  return gsad_message (credentials,
21276  "Internal error", __FUNCTION__, __LINE__,
21277  "An internal error occurred getting the group list. "
21278  "No new user was created. "
21279  "Diagnostics: Failure to send command to manager daemon.",
21280  "/omp?cmd=get_users", response_data);
21281  case 2:
21282  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21283  return gsad_message (credentials,
21284  "Internal error", __FUNCTION__, __LINE__,
21285  "An internal error occurred getting the group list. "
21286  "No new user was created. "
21287  "Diagnostics: Failure to receive response from manager daemon.",
21288  "/omp?cmd=get_users", response_data);
21289  default:
21290  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21291  return gsad_message (credentials,
21292  "Internal error", __FUNCTION__, __LINE__,
21293  "An internal error occurred getting the group list. "
21294  "No new user was created. "
21295  "Diagnostics: Internal Error.",
21296  "/omp?cmd=get_users", response_data);
21297  }
21298 
21299  g_string_append (xml, response);
21300 
21301  free_entity (entity);
21302  g_free (response);
21303  }
21304 
21305  if (command_enabled (credentials, "GET_ROLES"))
21306  {
21307  gchar *response;
21308  entity_t entity;
21309 
21310  response = NULL;
21311  entity = NULL;
21312  switch (omp (connection, credentials, &response, &entity, response_data,
21313  "<get_roles filter=\"rows=-1 permission=get_roles\"/>"))
21314  {
21315  case 0:
21316  case -1:
21317  break;
21318  case 1:
21319  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21320  return gsad_message (credentials,
21321  "Internal error", __FUNCTION__, __LINE__,
21322  "An internal error occurred getting the role list. "
21323  "No new user was created. "
21324  "Diagnostics: Failure to send command to manager daemon.",
21325  "/omp?cmd=get_users", response_data);
21326  case 2:
21327  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21328  return gsad_message (credentials,
21329  "Internal error", __FUNCTION__, __LINE__,
21330  "An internal error occurred getting the role list. "
21331  "No new user was created. "
21332  "Diagnostics: Failure to receive response from manager daemon.",
21333  "/omp?cmd=get_users", response_data);
21334  default:
21335  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21336  return gsad_message (credentials,
21337  "Internal error", __FUNCTION__, __LINE__,
21338  "An internal error occurred getting the role list. "
21339  "No new user was created. "
21340  "Diagnostics: Internal Error.",
21341  "/omp?cmd=get_users", response_data);
21342  }
21343 
21344  g_string_append (xml, response);
21345 
21346  free_entity (entity);
21347  g_free (response);
21348  }
21349 
21350  resource_id = params_value (params, "resource_id");
21351  restrict_type = params_value (params, "restrict_type");
21352  if (resource_id && restrict_type)
21353  {
21354  gchar *get_command;
21355  gchar *response;
21356  entity_t entity;
21357 
21358  get_command = g_strdup_printf ("get_%ss", restrict_type);
21359  response = NULL;
21360  entity = NULL;
21361  switch (ompf (connection, credentials, &response, &entity, response_data,
21362  "<%s %s_id=\"%s\" details=\"0\"/>",
21363  get_command, restrict_type, resource_id))
21364  {
21365  case 0:
21366  case -1:
21367  break;
21368  case 1:
21369  g_free (get_command);
21370  response_data->http_status_code
21371  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21372  return gsad_message (credentials,
21373  "Internal error", __FUNCTION__, __LINE__,
21374  "An internal error occurred getting a resource. "
21375  "No new permission was created. "
21376  "Diagnostics: Failure to send command to manager daemon.",
21377  "/omp?cmd=get_users", response_data);
21378  case 2:
21379  g_free (get_command);
21380  response_data->http_status_code
21381  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21382  return gsad_message (credentials,
21383  "Internal error", __FUNCTION__, __LINE__,
21384  "An internal error occurred getting a resource. "
21385  "No new permission was created. "
21386  "Diagnostics: Failure to receive response from manager daemon.",
21387  "/omp?cmd=get_users", response_data);
21388  default:
21389  g_free (get_command);
21390  response_data->http_status_code
21391  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21392  return gsad_message (credentials,
21393  "Internal error", __FUNCTION__, __LINE__,
21394  "An internal error occurred getting a resource. "
21395  "No new permission was created. "
21396  "Diagnostics: Internal Error.",
21397  "/omp?cmd=get_users", response_data);
21398  }
21399  g_string_append (xml, response);
21400 
21401  free_entity (entity);
21402  g_free (response);
21403  }
21404 
21405  related = params_values (params, "related:");
21406  if (related)
21407  {
21408  params_iterator_init (&related_iterator, related);
21409  }
21410 
21411  while (related
21412  && params_iterator_next (&related_iterator,
21413  &related_id, &related_param))
21414  {
21415  const char* related_type;
21416  gchar *get_command;
21417  gchar *response;
21418  entity_t entity;
21419 
21420  related_type = related_param->value;
21421 
21422  get_command = g_strdup_printf ("get_%ss", related_type);
21423  response = NULL;
21424  entity = NULL;
21425  switch (ompf (connection, credentials, &response, &entity, response_data,
21426  "<%s %s_id=\"%s\" details=\"0\"/>",
21427  get_command, related_type, related_id))
21428  {
21429  case 0:
21430  case -1:
21431  break;
21432  case 1:
21433  g_free (get_command);
21434  response_data->http_status_code
21435  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21436  return gsad_message (credentials,
21437  "Internal error", __FUNCTION__, __LINE__,
21438  "An internal error occurred getting a resource. "
21439  "No new permission was created. "
21440  "Diagnostics: Failure to send command to manager daemon.",
21441  "/omp?cmd=get_users", response_data);
21442  case 2:
21443  g_free (get_command);
21444  response_data->http_status_code
21445  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21446  return gsad_message (credentials,
21447  "Internal error", __FUNCTION__, __LINE__,
21448  "An internal error occurred getting a resource. "
21449  "No new permission was created. "
21450  "Diagnostics: Failure to receive response from manager daemon.",
21451  "/omp?cmd=get_users", response_data);
21452  default:
21453  g_free (get_command);
21454  response_data->http_status_code
21455  = MHD_HTTP_INTERNAL_SERVER_ERROR;
21456  return gsad_message (credentials,
21457  "Internal error", __FUNCTION__, __LINE__,
21458  "An internal error occurred getting a resource. "
21459  "No new permission was created. "
21460  "Diagnostics: Internal Error.",
21461  "/omp?cmd=get_users", response_data);
21462  }
21463  g_string_append (xml, response);
21464 
21465  free_entity (entity);
21466  g_free (response);
21467  }
21468 
21469  if (extra_xml)
21470  g_string_append (xml, extra_xml);
21471 
21472  g_string_append (xml, "</new_permissions>");
21473 
21474  return xsl_transform_omp (connection, credentials, params,
21475  g_string_free (xml, FALSE), response_data);
21476 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:305

Here is the call graph for this function:

Here is the caller graph for this function:

char* new_permissions_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup new_permission XML, XSL transform 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
Result of XSL transformation.

Definition at line 21489 of file gsad_omp.c.

References new_permissions().

21492 {
21493  return new_permissions (connection, credentials, params, NULL, response_data);
21494 }
char * new_permissions(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permissions XML, XSL transform the result.
Definition: gsad_omp.c:21202

Here is the call graph for this function:

char* new_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new Port List 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
Result of XSL transformation.

Definition at line 22745 of file gsad_omp.c.

References edit_resource(), and params_t.

22747 {
22748  return new_port_list (connection, credentials, params, NULL, response_data);
22749 }

Here is the call graph for this function:

char* new_port_range_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new Port Range 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
Result of XSL transformation.

Definition at line 22560 of file gsad_omp.c.

22563 {
22564  return new_port_range (connection, credentials, params, NULL, response_data);
22565 }
char* new_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new report format 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
Result of XSL transformation.

Definition at line 18058 of file gsad_omp.c.

18061 {
18062  return new_report_format (connection, credentials, params, NULL,
18063  response_data);
18064 }
char* new_role_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new role.

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
Result of XSL transformation.

Definition at line 23050 of file gsad_omp.c.

23052 {
23053  return new_role (connection, credentials, params, NULL, response_data);
23054 }
char* new_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new scanner 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
Result of XSL transformation.

Definition at line 16775 of file gsad_omp.c.

16777 {
16778  return new_scanner (connection, credentials, params, NULL, response_data);
16779 }
char* new_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new schedule 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
Result of XSL transformation.

Definition at line 17408 of file gsad_omp.c.

17410 {
17411  return new_schedule (connection, credentials, params, NULL, response_data);
17412 }
char* new_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new target.

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
Result of XSL transformation.

Definition at line 10126 of file gsad_omp.c.

10128 {
10129  return new_tag (connection, credentials, params, NULL, response_data);
10130 }
char* new_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new target.

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
Result of XSL transformation.

Definition at line 9390 of file gsad_omp.c.

9392 {
9393  return new_target (connection, credentials, params, NULL, response_data);
9394 }
char* new_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new task.

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
Result of XSL transformation.

Definition at line 3722 of file gsad_omp.c.

References GSAD_MESSAGE_INVALID, and params_t.

3724 {
3725  return new_task (connection, credentials, NULL, params, NULL, response_data);
3726 }
char* new_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new user.

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
Result of XSL transformation.

Definition at line 24587 of file gsad_omp.c.

24589 {
24590  return new_user (connection, credentials, params, NULL, response_data);
24591 }
void omp_init ( const gchar *  manager_address_unix,
const gchar *  manager_address_tls,
int  port_manager 
)

Init the GSA OMP 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 319 of file gsad_omp.c.

References manager_address, manager_port, and manager_use_tls.

Referenced by main().

321 {
322  if (manager_address_unix)
323  {
324  manager_address = g_strdup (manager_address_unix);
325  manager_use_tls = 0;
326  }
327  else if (manager_address_tls)
328  {
329  manager_address = g_strdup (manager_address_tls);
330  manager_use_tls = 1;
331  }
332  else
333  {
334  manager_address = g_build_filename (OPENVAS_RUN_DIR,
335  "openvasmd.sock",
336  NULL);
337  manager_use_tls = 0;
338  }
339  manager_port = port_manager;
340 }
gchar * manager_address
The address the manager is on.
Definition: gsad_omp.c:96
int manager_use_tls
Whether to use TLS for Manager connections.
Definition: gsad_omp.c:91
int manager_port
The port the manager is on.
Definition: gsad_omp.c:101

Here is the caller graph for this function:

int openvas_connection_open ( openvas_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 27580 of file gsad_omp.c.

References connect_unix(), and manager_use_tls.

Referenced by authenticate_omp(), and manager_connect().

27583 {
27584  if (address == NULL)
27585  return -1;
27586 
27587  connection->tls = manager_use_tls;
27588 
27589  if (manager_use_tls)
27590  {
27591  connection->socket = openvas_server_open (&connection->session,
27592  address,
27593  port);
27594  connection->credentials = NULL;
27595  }
27596  else
27597  connection->socket = connect_unix (address);
27598 
27599  if (connection->socket == -1)
27600  return -1;
27601 
27602  return 0;
27603 }
int manager_use_tls
Whether to use TLS for Manager connections.
Definition: gsad_omp.c:91
int connect_unix(const gchar *path)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:27542

Here is the call graph for this function:

Here is the caller graph for this function:

char* process_bulk_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
enum content_type content_type,
char **  content_disposition,
gsize *  content_length,
cmd_response_data_t response_data 
)

Returns a process_bulk page.

Parameters
[in]connectionConnection to manager
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]content_typeContent type return.
[out]content_dispositionContent disposition return.
[out]content_lengthContent length return.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 26347 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_add(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_valid(), params_value(), params_values(), param::valid, param::valid_utf8, and param::value.

Referenced by exec_omp_post().

26351 {
26352  GString *bulk_string;
26353  const char *type, *subtype, *action;
26354  char *param_name;
26355  params_t *selected_ids;
26356  param_t *param;
26357  params_iterator_t iter;
26358 
26359  type = params_value (params, "resource_type");
26360  if (type == NULL)
26361  {
26362  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26363  return gsad_message (credentials,
26364  "Internal error", __FUNCTION__, __LINE__,
26365  "An internal error occurred while performing a bulk action. "
26366  "Diagnostics: Required parameter 'resource_type' was NULL.",
26367  "/omp?cmd=get_tasks", response_data);
26368  }
26369  if (strcmp (type, "info") == 0)
26370  {
26371  subtype = params_value (params, "info_type");
26372  if (subtype == NULL)
26373  {
26374  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26375  return gsad_message (credentials,
26376  "Internal error", __FUNCTION__, __LINE__,
26377  "An internal error occurred while performing a bulk action. "
26378  "Diagnostics: Required parameter 'info_type' was NULL.",
26379  "/omp?cmd=get_tasks", response_data);
26380  }
26381  }
26382  else
26383  subtype = NULL;
26384 
26385  if (params_valid (params, "bulk_create.x"))
26386  action = "create";
26387  else if (params_valid (params, "bulk_delete.x"))
26388  action = "delete";
26389  else if (params_valid (params, "bulk_export.x"))
26390  action = "export";
26391  else if (params_value (params, "bulk_trash.x"))
26392  action = "trash";
26393  else
26394  {
26395  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26396  return gsad_message (credentials,
26397  "Internal error", __FUNCTION__, __LINE__,
26398  "An internal error occurred while performing a bulk action. "
26399  "Diagnostics: Could not determine the action.",
26400  "/omp?cmd=get_tasks", response_data);
26401  }
26402 
26403  if (strcmp (action, "create") == 0)
26404  {
26405  if (params_value (params, "bulk_select")
26406  && strcmp (params_value (params, "bulk_select"), "1") == 0)
26407  {
26408  bulk_string = g_string_new ("first=1 rows=-1");
26409 
26410  selected_ids = params_values (params, "bulk_selected:");
26411  if (selected_ids)
26412  {
26413  params_iterator_init (&iter, selected_ids);
26414  while (params_iterator_next (&iter, &param_name, &param))
26415  xml_string_append (bulk_string,
26416  " uuid=%s",
26417  param_name);
26418  }
26419  }
26420  else if (params_value (params, "bulk_select")
26421  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26422  {
26423  bulk_string = g_string_new ("first=1 rows=-1 ");
26424  g_string_append (bulk_string, params_value (params, "filter") ? : "");
26425  }
26426  else
26427  {
26428  bulk_string = g_string_new (params_value (params, "filter") ? : "");
26429  }
26430  param = params_add (params, "hosts_filter", bulk_string->str);
26431  param->valid = 1;
26432  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
26433  g_string_free (bulk_string, TRUE);
26434 
26435  return new_target (connection, credentials, params, NULL, response_data);
26436  }
26437 
26438  if (strcmp (action, "export") == 0)
26439  {
26440  if (params_value (params, "bulk_select")
26441  && strcmp (params_value (params, "bulk_select"), "1") == 0)
26442  {
26443  bulk_string
26444  = g_string_new ("first=1 rows=-1 uuid=");
26445 
26446  selected_ids = params_values (params, "bulk_selected:");
26447  if (selected_ids)
26448  {
26449  params_iterator_init (&iter, selected_ids);
26450  while (params_iterator_next (&iter, &param_name, &param))
26451  xml_string_append (bulk_string,
26452  " uuid=%s",
26453  param_name);
26454  }
26455  }
26456  else if (params_value (params, "bulk_select")
26457  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26458  {
26459  bulk_string
26460  = g_string_new ("first=1 rows=-1 ");
26461  g_string_append (bulk_string, params_value (params, "filter") ? : "");
26462  }
26463  else
26464  {
26465  bulk_string
26466  = g_string_new (params_value (params, "filter") ? : "");
26467  }
26468  params_add (params, "filter", g_string_free (bulk_string, FALSE));
26469 
26470  return export_many (connection, type, credentials, params, content_type,
26471  content_disposition, content_length, response_data);
26472  }
26473 
26474  bulk_string = g_string_new ("<process_bulk>");
26475 
26476  g_string_append_printf (bulk_string,
26477  "<type>%s</type>"
26478  "<action>%s</action>",
26479  type,
26480  action);
26481 
26482  g_string_append (bulk_string, "<selections>");
26483 
26484  if (params_value (params, "bulk_select")
26485  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26486  {
26487  int ret;
26488  entity_t entity;
26489  gchar *response;
26490 
26491  ret = ompf (connection, credentials, &response, &entity, response_data,
26492  "<get_%ss filter=\"first=1 rows=-1 %s\"/>",
26493  type,
26494  params_value (params, "filter") ? : "");
26495 
26496  if (ret)
26497  {
26498  free_entity (entity);
26499  g_free (response);
26500  g_string_free (bulk_string, TRUE);
26501  }
26502  switch (ret)
26503  {
26504  case 0:
26505  case -1:
26506  break;
26507  case 1:
26508  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26509  return gsad_message (credentials,
26510  "Internal error", __FUNCTION__, __LINE__,
26511  "An internal error occurred while getting a"
26512  " resources list. "
26513  "Diagnostics: Failure to send command to"
26514  " manager daemon.",
26515  "/omp?cmd=get_my_settings", response_data);
26516  case 2:
26517  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26518  return gsad_message (credentials,
26519  "Internal error", __FUNCTION__, __LINE__,
26520  "An internal error occurred while getting a"
26521  " resources list. "
26522  "Diagnostics: Failure to receive response from"
26523  " manager daemon.",
26524  "/omp?cmd=get_my_settings", response_data);
26525  default:
26526  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26527  return gsad_message (credentials,
26528  "Internal error", __FUNCTION__, __LINE__,
26529  "An internal error occurred while getting a"
26530  " resources list. "
26531  "Diagnostics: Internal Error.",
26532  "/omp?cmd=get_my_settings", response_data);
26533  }
26534 
26535  entities_t entities = entity->entities;
26536  entity_t child_entity;
26537 
26538  while ((child_entity = first_entity (entities)))
26539  {
26540  if (strcmp (entity_name (child_entity), type) == 0)
26541  {
26542  const char *resource_id
26543  = entity_attribute (child_entity, "id");
26544 
26545  if (resource_id)
26546  xml_string_append (bulk_string,
26547  "<selection id=\"%s\" />",
26548  resource_id);
26549  }
26550  entities = next_entities (entities);
26551  }
26552  }
26553  else
26554  {
26555  selected_ids = params_values (params, "bulk_selected:");
26556  if (selected_ids)
26557  {
26558  params_iterator_init (&iter, selected_ids);
26559  while (params_iterator_next (&iter, &param_name, &param))
26560  xml_string_append (bulk_string,
26561  "<selection id=\"%s\" />",
26562  param_name);
26563  }
26564  }
26565  g_string_append (bulk_string, "</selections>");
26566 
26567  if (strcmp (action, "delete") == 0 && strcmp (type, "user") == 0)
26568  {
26569  int ret;
26570  entity_t entity;
26571  gchar *response;
26572 
26573  ret = ompf (connection, credentials, &response, &entity, response_data,
26574  "<get_users filter=\"first=1 rows=-1\"/>",
26575  type,
26576  params_value (params, "filter") ? : "");
26577 
26578  if (ret)
26579  {
26580  free_entity (entity);
26581  g_free (response);
26582  g_string_free (bulk_string, TRUE);
26583  }
26584  switch (ret)
26585  {
26586  case 0:
26587  case -1:
26588  break;
26589  case 1:
26590  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26591  return gsad_message (credentials,
26592  "Internal error", __FUNCTION__, __LINE__,
26593  "An internal error occurred while getting a"
26594  " resources list. "
26595  "Diagnostics: Failure to send command to"
26596  " manager daemon.",
26597  "/omp?cmd=get_my_settings", response_data);
26598  case 2:
26599  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26600  return gsad_message (credentials,
26601  "Internal error", __FUNCTION__, __LINE__,
26602  "An internal error occurred while getting a"
26603  " resources list. "
26604  "Diagnostics: Failure to receive response from"
26605  " manager daemon.",
26606  "/omp?cmd=get_my_settings", response_data);
26607  default:
26608  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26609  return gsad_message (credentials,
26610  "Internal error", __FUNCTION__, __LINE__,
26611  "An internal error occurred while getting a"
26612  " resources list. "
26613  "Diagnostics: Internal Error.",
26614  "/omp?cmd=get_my_settings", response_data);
26615  }
26616 
26617  g_string_append (bulk_string, response);
26618  free_entity (entity);
26619  g_free (response);
26620  }
26621 
26622  g_string_append (bulk_string, "</process_bulk>");
26623 
26624  return xsl_transform_omp (connection, credentials, params,
26625  g_string_free (bulk_string, FALSE), response_data);
26626 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
content_type
Content types.
Definition: gsad_base.h:120
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int valid_utf8
Definition: gsad_base.h:153
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
int valid
Definition: gsad_base.h:152
#define params_iterator_t
Definition: gsad_base.h:187
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:808
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793

Here is the call graph for this function:

Here is the caller graph for this function:

char* resource_action ( openvas_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, XSL transform 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
Result of XSL transformation.

Definition at line 3135 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_value(), and set_http_status_from_entity().

Referenced by resume_task_omp(), start_task_omp(), and stop_task_omp().

3138 {
3139  gchar *html, *response, *param_name;
3140  const char *no_redirect, *resource_id;
3141  gchar *cap_action, *cap_type, *get_cmd, *prev_action;
3142 
3143  int ret;
3144  entity_t entity;
3145 
3146  assert (type);
3147 
3148  param_name = g_strdup_printf ("%s_id", type);
3149  no_redirect = params_value (params, "no_redirect");
3150  resource_id = params_value (params, param_name);
3151 
3152  if (resource_id == NULL)
3153  {
3154  gchar *message;
3155  message = g_strdup_printf
3156  ("An internal error occurred while performing an action. "
3157  "The resource remains the same. "
3158  "Diagnostics: Required parameter %s was NULL.",
3159  param_name);
3160  g_free (param_name);
3161  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
3162  html = gsad_message (credentials,
3163  "Internal error", __FUNCTION__, __LINE__,
3164  message,
3165  "/omp?cmd=get_tasks", response_data);
3166  g_free (message);
3167  return html;
3168  }
3169  g_free (param_name);
3170 
3171  response = NULL;
3172  entity = NULL;
3173  ret = ompf (connection, credentials, &response, &entity, response_data,
3174  "<%s_%s %s_id=\"%s\"/>",
3175  action,
3176  type,
3177  type,
3178  resource_id);
3179  switch (ret)
3180  {
3181  case 0:
3182  case -1:
3183  break;
3184  case 1:
3185  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3186  return gsad_message (credentials,
3187  "Internal error", __FUNCTION__, __LINE__,
3188  "An internal error occurred while performing an action. "
3189  "The resource remains the same. "
3190  "Diagnostics: Failure to send command to manager daemon.",
3191  "/omp?cmd=get_tasks", response_data);
3192  case 2:
3193  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3194  return gsad_message (credentials,
3195  "Internal error", __FUNCTION__, __LINE__,
3196  "An internal error occurred while performing an action. "
3197  "It is unclear whether the resource has been affected. "
3198  "Diagnostics: Failure to receive response from manager daemon.",
3199  "/omp?cmd=get_tasks", response_data);
3200  default:
3201  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
3202  return gsad_message (credentials,
3203  "Internal error", __FUNCTION__, __LINE__,
3204  "An internal error occurred while performing an action. "
3205  "It is unclear whether the resource has been affected. "
3206  "Diagnostics: Internal Error.",
3207  "/omp?cmd=get_tasks", response_data);
3208  }
3209 
3210  if (!omp_success (entity))
3211  set_http_status_from_entity (entity, response_data);
3212 
3213  cap_action = capitalize (action);
3214  cap_type = capitalize (type);
3215  get_cmd = g_strdup_printf ("get_%ss", type);
3216  prev_action = g_strdup_printf ("%s %s", cap_action, cap_type);
3217  html = response_from_entity (connection, credentials, params, entity,
3218  (no_redirect && strcmp (no_redirect, "0")),
3219  NULL, get_cmd,
3220  NULL, get_cmd,
3221  prev_action, response_data);
3222 
3223  g_free (response);
3224  free_entity (entity);
3225  g_free (cap_action);
3226  g_free (cap_type);
3227  g_free (get_cmd);
3228  g_free (prev_action);
3229 
3230  return html;
3231 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* restore_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Restore a resource, get all trash, XSL transform 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
Result of XSL transformation.

Definition at line 9934 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

9936 {
9937  GString *xml;
9938  gchar *ret;
9939  entity_t entity;
9940  const char *target_id, *no_redirect;
9941 
9942  target_id = params_value (params, "target_id");
9943  no_redirect = params_value (params, "no_redirect");
9944 
9945  if (target_id == NULL)
9946  {
9947  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
9948  return gsad_message (credentials,
9949  "Internal error", __FUNCTION__, __LINE__,
9950  "An internal error occurred while restoring a resource. "
9951  "The resource was not restored. "
9952  "Diagnostics: Required parameter was NULL.",
9953  "/omp?cmd=get_tasks", response_data);
9954  }
9955 
9956  xml = g_string_new ("");
9957 
9958  /* Restore the resource. */
9959 
9960  if (openvas_connection_sendf (connection,
9961  "<restore"
9962  " id=\"%s\"/>",
9963  target_id)
9964  == -1)
9965  {
9966  g_string_free (xml, TRUE);
9967  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9968  return gsad_message (credentials,
9969  "Internal error", __FUNCTION__, __LINE__,
9970  "An internal error occurred while restoring a resource. "
9971  "The resource was not deleted. "
9972  "Diagnostics: Failure to send command to manager daemon.",
9973  "/omp?cmd=get_trash", response_data);
9974  }
9975 
9976  if (read_entity_and_string_c (connection, &entity, &xml))
9977  {
9978  g_string_free (xml, TRUE);
9979  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9980  return gsad_message (credentials,
9981  "Internal error", __FUNCTION__, __LINE__,
9982  "An internal error occurred while restoring a resource. "
9983  "It is unclear whether the resource has been restored or not. "
9984  "Diagnostics: Failure to read response from manager daemon.",
9985  "/omp?cmd=get_trash", response_data);
9986  }
9987 
9988  /* Cleanup, and return trash page. */
9989 
9990  ret = response_from_entity (connection, credentials, params, entity,
9991  (no_redirect && strcmp (no_redirect, "0")),
9992  NULL, "get_trash",
9993  NULL, "get_trash",
9994  "Restore", response_data);
9995  free_entity (entity);
9996  g_string_free (xml, FALSE);
9997  return ret;
9998 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* resume_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Resume a task, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 5055 of file gsad_omp.c.

References resource_action().

5057 {
5058  return resource_action (connection, credentials, params, "task", "resume",
5059  response_data);
5060 }
char * resource_action(openvas_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, XSL transform result.
Definition: gsad_omp.c:3135

Here is the call graph for this function:

char* run_wizard_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Run a wizard and XSL transform 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
Result of XSL transformation.

Definition at line 18630 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

18632 {
18633  const char *no_redirect, *name;
18634  int ret;
18635  GString *run;
18636  param_t *param;
18637  gchar *param_name, *html, *response;
18638  params_iterator_t iter;
18639  params_t *wizard_params;
18640  entity_t entity;
18641 
18642  /* The naming is a bit subtle here, because the HTTP request
18643  * parameters are called "param"s and so are the OMP wizard
18644  * parameters. */
18645 
18646  no_redirect = params_value (params, "no_redirect");
18647  name = params_value (params, "name");
18648  if (name == NULL)
18649  {
18650  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
18651  return gsad_message (credentials,
18652  "Internal error", __FUNCTION__, __LINE__,
18653  "An internal error occurred while trying to start a wizard. "
18654  "Diagnostics: Required parameter 'name' was NULL.",
18655  "/omp?cmd=get_tasks", response_data);
18656  }
18657  run = g_string_new ("<run_wizard>");
18658 
18659  g_string_append_printf (run,
18660  "<name>%s</name>"
18661  "<params>",
18662  name);
18663 
18664  wizard_params = params_values (params, "event_data:");
18665  if (wizard_params)
18666  {
18667  params_iterator_init (&iter, wizard_params);
18668  while (params_iterator_next (&iter, &param_name, &param))
18669  xml_string_append (run,
18670  "<param>"
18671  "<name>%s</name>"
18672  "<value>%s</value>"
18673  "</param>",
18674  param_name,
18675  param->value);
18676  }
18677 
18678  g_string_append (run, "</params></run_wizard>");
18679 
18680  response = NULL;
18681  entity = NULL;
18682  ret = omp (connection, credentials, &response, &entity, response_data,
18683  run->str);
18684  g_string_free (run, TRUE);
18685  switch (ret)
18686  {
18687  case 0:
18688  case -1:
18689  break;
18690  case 1:
18691  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18692  return gsad_message (credentials,
18693  "Internal error", __FUNCTION__, __LINE__,
18694  "An internal error occurred while running a wizard. "
18695  "The wizard did not start. "
18696  "Diagnostics: Failure to send command to manager daemon.",
18697  "/omp?cmd=get_tasks", response_data);
18698  case 2:
18699  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18700  return gsad_message (credentials,
18701  "Internal error", __FUNCTION__, __LINE__,
18702  "An internal error occurred while running a wizard. "
18703  "It is unclear whether the wizard started or not. "
18704  "Diagnostics: Failure to receive response from manager daemon.",
18705  "/omp?cmd=get_tasks", response_data);
18706  default:
18707  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18708  return gsad_message (credentials,
18709  "Internal error", __FUNCTION__, __LINE__,
18710  "An internal error occurred while running a wizard. "
18711  "It is unclear whether the wizard started or not. "
18712  "Diagnostics: Internal Error.",
18713  "/omp?cmd=get_tasks", response_data);
18714  }
18715 
18716  html = response_from_entity (connection, credentials, params, entity,
18717  (no_redirect && strcmp (no_redirect, "0")),
18718  NULL, "wizard",
18719  NULL, "wizard",
18720  "Run Wizard", response_data);
18721  free_entity (entity);
18722  g_free (response);
18723  return html;
18724 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187

Here is the call graph for this function:

char* save_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a agent, get all agents, XSL transform 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
Result of XSL transformation.

Definition at line 7295 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

7297 {
7298  int ret;
7299  gchar *html, *response;
7300  const char *no_redirect, *agent_id, *name, *comment;
7301  entity_t entity;
7302 
7303  no_redirect = params_value (params, "no_redirect");
7304  agent_id = params_value (params, "agent_id");
7305  name = params_value (params, "name");
7306  comment = params_value (params, "comment");
7307 
7308  CHECK_PARAM_INVALID (agent_id, "Save Agent", "edit_agent");
7309  CHECK_PARAM_INVALID (name, "Save Agent", "edit_agent");
7310  CHECK_PARAM_INVALID (comment, "Save Agent", "edit_agent");
7311 
7312  /* Modify the agent. */
7313 
7314  response = NULL;
7315  entity = NULL;
7316  ret = ompf (connection, credentials,
7317  &response,
7318  &entity,
7319  response_data,
7320  "<modify_agent agent_id=\"%s\">"
7321  "<name>%s</name>"
7322  "<comment>%s</comment>"
7323  "</modify_agent>",
7324  agent_id,
7325  name,
7326  comment);
7327 
7328  switch (ret)
7329  {
7330  case 0:
7331  case -1:
7332  break;
7333  case 1:
7334  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7335  return gsad_message (credentials,
7336  "Internal error", __FUNCTION__, __LINE__,
7337  "An internal error occurred while saving a agent. "
7338  "The agent was not saved. "
7339  "Diagnostics: Failure to send command to manager daemon.",
7340  "/omp?cmd=get_agents", response_data);
7341  case 2:
7342  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7343  return gsad_message (credentials,
7344  "Internal error", __FUNCTION__, __LINE__,
7345  "An internal error occurred while saving a agent. "
7346  "It is unclear whether the agent has been saved or not. "
7347  "Diagnostics: Failure to receive response from manager daemon.",
7348  "/omp?cmd=get_agents", response_data);
7349  default:
7350  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7351  return gsad_message (credentials,
7352  "Internal error", __FUNCTION__, __LINE__,
7353  "An internal error occurred while saving a agent. "
7354  "It is unclear whether the agent has been saved or not. "
7355  "Diagnostics: Internal Error.",
7356  "/omp?cmd=get_agents", response_data);
7357  }
7358 
7359  html = response_from_entity (connection, credentials, params, entity,
7360  (no_redirect && strcmp (no_redirect, "0")),
7361  NULL, "get_agents",
7362  NULL, "edit_agent",
7363  "Save Agent", response_data);
7364  free_entity (entity);
7365  g_free (response);
7366  return html;
7367 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify an alert, get all alerts, XSL transform 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
Result of XSL transformation.

Definition at line 8962 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

8964 {
8965  GString *xml;
8966  int ret;
8967  gchar *html, *response;
8968  const char *no_redirect, *name, *comment, *alert_id;
8969  const char *event, *condition, *method;
8970  const char *filter_id;
8971  params_t *event_data, *condition_data, *method_data;
8972  entity_t entity;
8973 
8974  no_redirect = params_value (params, "no_redirect");
8975  name = params_value (params, "name");
8976  comment = params_value (params, "comment");
8977  if (params_given (params, "condition"))
8978  condition = params_value (params, "condition");
8979  else
8980  condition = "Always";
8981  event = params_value (params, "event");
8982  method = params_value (params, "method");
8983  alert_id = params_value (params, "alert_id");
8984  filter_id = params_value (params, "filter_id");
8985 
8986  CHECK_PARAM_INVALID (name, "Save Alert", "edit_alert");
8987  CHECK_PARAM_INVALID (comment, "Save Alert", "edit_alert");
8988  CHECK_PARAM_INVALID (alert_id, "Save Alert", "edit_alert");
8989  CHECK_PARAM_INVALID (condition, "Save Alert", "edit_alert");
8990  CHECK_PARAM_INVALID (event, "Save Alert", "edit_alert");
8991  CHECK_PARAM_INVALID (method, "Save Alert", "edit_alert");
8992  if (strcmp (event, "Task run status changed") == 0)
8993  {
8994  CHECK_PARAM_INVALID (filter_id, "Save Alert", "edit_alert");
8995  }
8996 
8997  xml = g_string_new ("");
8998 
8999  /* Modify the alert. */
9000 
9001  event_data = params_values (params, "event_data:");
9002  condition_data = params_values (params, "condition_data:");
9003  method_data = params_values (params, "method_data:");
9004 
9005  if ((strcmp (event, "New SecInfo arrived") == 0) && event_data)
9006  {
9007  params_iterator_t iter;
9008  char *name;
9009  param_t *param;
9010 
9011  params_iterator_init (&iter, event_data);
9012  while (params_iterator_next (&iter, &name, &param))
9013  if ((strcmp (name, "feed_event") == 0)
9014  && param->value
9015  && (strcmp (param->value, "updated") == 0))
9016  {
9017  event = "Updated SecInfo arrived";
9018  break;
9019  }
9020  }
9021 
9022  xml_string_append (xml,
9023  "<modify_alert alert_id=\"%s\">"
9024  "<name>%s</name>"
9025  "<filter id=\"%s\"/>"
9026  "<comment>%s</comment>"
9027  "<event>%s",
9028  alert_id,
9029  name,
9030  filter_id,
9031  comment ? comment : "",
9032  event);
9033 
9034  append_alert_event_data (xml, event_data, event);
9035 
9036  xml_string_append (xml,
9037  "</event>"
9038  "<method>%s",
9039  method);
9040 
9041  append_alert_method_data (xml, method_data, method);
9042 
9043  xml_string_append (xml,
9044  "</method>"
9045  "<condition>%s",
9046  condition);
9047 
9048  append_alert_condition_data (xml, condition_data, condition);
9049 
9050  xml_string_append (xml,
9051  "</condition>"
9052  "</modify_alert>");
9053 
9054  ret = omp (connection, credentials,
9055  &response,
9056  &entity,
9057  response_data,
9058  xml->str);
9059  g_string_free (xml, TRUE);
9060  switch (ret)
9061  {
9062  case 0:
9063  case -1:
9064  break;
9065  case 1:
9066  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9067  return gsad_message (credentials,
9068  "Internal error", __FUNCTION__, __LINE__,
9069  "An internal error occurred while saving a new alert. "
9070  "No new alert was created. "
9071  "Diagnostics: Failure to send command to manager daemon.",
9072  "/omp?cmd=get_alerts", response_data);
9073  case 2:
9074  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9075  return gsad_message (credentials,
9076  "Internal error", __FUNCTION__, __LINE__,
9077  "An internal error occurred while saving a new alert. "
9078  "It is unclear whether the alert has been created or not. "
9079  "Diagnostics: Failure to receive response from manager daemon.",
9080  "/omp?cmd=get_alerts", response_data);
9081  default:
9082  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9083  return gsad_message (credentials,
9084  "Internal error", __FUNCTION__, __LINE__,
9085  "An internal error occurred while saving a new alert. "
9086  "It is unclear whether the alert has been created or not. "
9087  "Diagnostics: Internal Error.",
9088  "/omp?cmd=get_alerts", response_data);
9089  }
9090 
9091  html = response_from_entity (connection, credentials, params, entity,
9092  (no_redirect && strcmp (no_redirect, "0")),
9093  NULL, "get_alerts",
9094  NULL, "edit_alert",
9095  "Save Alert", response_data);
9096  free_entity (entity);
9097  g_free (response);
9098  return html;
9099 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_asset_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify an asset, get all assets, XSL transform 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
Result of XSL transformation.

Definition at line 27421 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

27424 {
27425  int ret;
27426  gchar *html, *response;
27427  const char *no_redirect, *asset_id, *comment;
27428  entity_t entity;
27429 
27430  no_redirect = params_value (params, "no_redirect");
27431  asset_id = params_value (params, "asset_id");
27432  comment = params_value (params, "comment");
27433 
27434  CHECK_PARAM_INVALID (asset_id, "Save Asset", "edit_asset");
27435  CHECK_PARAM_INVALID (comment, "Save Asset", "edit_asset");
27436 
27437  /* Modify the asset. */
27438 
27439  response = NULL;
27440  entity = NULL;
27441  ret = ompf (connection, credentials,
27442  &response,
27443  &entity,
27444  response_data,
27445  "<modify_asset asset_id=\"%s\">"
27446  "<comment>%s</comment>"
27447  "</modify_asset>",
27448  asset_id,
27449  comment);
27450 
27451  switch (ret)
27452  {
27453  case 0:
27454  case -1:
27455  break;
27456  case 1:
27457  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27458  return gsad_message (credentials,
27459  "Internal error", __FUNCTION__, __LINE__,
27460  "An internal error occurred while saving an asset. "
27461  "The asset was not saved. "
27462  "Diagnostics: Failure to send command to manager daemon.",
27463  "/omp?cmd=get_assets", response_data);
27464  case 2:
27465  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27466  return gsad_message (credentials,
27467  "Internal error", __FUNCTION__, __LINE__,
27468  "An internal error occurred while saving an asset. "
27469  "It is unclear whether the asset has been saved or not. "
27470  "Diagnostics: Failure to receive response from manager daemon.",
27471  "/omp?cmd=get_assets", response_data);
27472  default:
27473  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27474  return gsad_message (credentials,
27475  "Internal error", __FUNCTION__, __LINE__,
27476  "An internal error occurred while saving an asset. "
27477  "It is unclear whether the asset has been saved or not. "
27478  "Diagnostics: Internal Error.",
27479  "/omp?cmd=get_assets", response_data);
27480  }
27481 
27482  html = response_from_entity (connection, credentials, params, entity,
27483  (no_redirect && strcmp (no_redirect, "0")),
27484  NULL, "get_assets",
27485  NULL, "edit_asset",
27486  "Save Asset", response_data);
27487  free_entity (entity);
27488  g_free (response);
27489  return html;
27490 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_auth_omp ( openvas_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
XSL transformated 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 25868 of file gsad_omp.c.

References AUTH_CONF_SETTING, CHECK_PARAM_INVALID, gsad_message(), GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, params_given(), and params_value().

25870 {
25871  int ret;
25872  entity_t entity = NULL;
25873  char *html, *response = NULL, *truefalse;
25874  const char *no_redirect, *method;
25875 
25876  if (params_value (params, "enable")
25877  && (strcmp (params_value (params, "enable"), "1") == 0))
25878  truefalse = "true";
25879  else
25880  truefalse = "false";
25881 
25882  no_redirect = params_value (params, "no_redirect");
25883  method = params_value (params, "group");
25884  CHECK_PARAM_INVALID (method, "Save Authentication", "get_users");
25885  if (!strcmp (method, "method:ldap_connect"))
25886  {
25887  const char *ldaphost, *authdn, *certificate;
25888  ldaphost = params_value (params, "ldaphost");
25889  authdn = params_value (params, "authdn");
25890  certificate = params_value (params, "certificate");
25891 
25892  CHECK_PARAM_INVALID (ldaphost, "Save Authentication", "get_users");
25893  CHECK_PARAM_INVALID (authdn, "Save Authentication", "get_users");
25894  if (params_given (params, "certificate") && strcmp (certificate, ""))
25895  {
25896  CHECK_PARAM_INVALID (certificate, "Save Authentication", "get_users");
25898  ret = ompf (connection, credentials, &response, &entity,
25899  response_data,
25900  "<modify_auth>"
25901  "<group name=\"%s\">"
25902  AUTH_CONF_SETTING ("enable", "%s")
25903  AUTH_CONF_SETTING ("ldaphost", "%s")
25904  AUTH_CONF_SETTING ("authdn", "%s")
25905  AUTH_CONF_SETTING ("cacert", "%s")
25906  "</group>"
25907  "</modify_auth>", method, truefalse, ldaphost, authdn,
25908  certificate);
25909  }
25910  else
25912  ret = ompf (connection, credentials, &response, &entity, response_data,
25913  "<modify_auth>"
25914  "<group name=\"%s\">"
25915  AUTH_CONF_SETTING ("enable", "%s")
25916  AUTH_CONF_SETTING ("ldaphost", "%s")
25917  AUTH_CONF_SETTING ("authdn", "%s")
25918  "</group>"
25919  "</modify_auth>", method, truefalse, ldaphost, authdn);
25920  }
25921  else if (!strcmp (method, "method:radius_connect"))
25922  {
25923  const char *radiushost, *radiuskey;
25924  radiushost = params_value (params, "radiushost");
25925  radiuskey = params_value (params, "radiuskey");
25926 
25927  CHECK_PARAM_INVALID (radiushost, "Save Authentication", "get_users");
25928  CHECK_PARAM_INVALID (radiuskey, "Save Authentication", "get_users");
25930  ret = ompf (connection, credentials, &response, &entity, response_data,
25931  "<modify_auth>"
25932  "<group name=\"%s\">"
25933  AUTH_CONF_SETTING ("enable", "%s")
25934  AUTH_CONF_SETTING ("radiushost", "%s")
25935  AUTH_CONF_SETTING ("radiuskey", "%s")
25936  "</group>"
25937  "</modify_auth>", method, truefalse, radiushost, radiuskey);
25938  }
25939  else
25940  return get_users (connection, credentials, params,
25942  ("Save Authentication Configuration"),
25943  response_data);
25944 
25945  switch (ret)
25946  {
25947  case 0:
25948  case -1:
25949  break;
25950  case 1:
25951  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25952  return gsad_message (credentials,
25953  "Internal error", __FUNCTION__, __LINE__,
25954  "An internal error occurred while saving the auth settings. "
25955  "The settings were not saved. "
25956  "Diagnostics: Failure to send command to manager daemon.",
25957  "/omp?cmd=get_users", response_data);
25958  case 2:
25959  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25960  return gsad_message (credentials,
25961  "Internal error", __FUNCTION__, __LINE__,
25962  "An internal error occurred while saving the auth settings. "
25963  "It is unclear whether the settings have been saved or not. "
25964  "Diagnostics: Failure to receive response from manager daemon.",
25965  "/omp?cmd=get_users", response_data);
25966  default:
25967  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25968  return gsad_message (credentials,
25969  "Internal error", __FUNCTION__, __LINE__,
25970  "An internal error occurred while saving the auth settings. "
25971  "It is unclear whether the settings have been saved or not. "
25972  "Diagnostics: Internal Error.",
25973  "/omp?cmd=get_users", response_data);
25974  }
25975 
25976  html = response_from_entity (connection, credentials, params, entity,
25977  (no_redirect && strcmp (no_redirect, "0")),
25978  NULL, NULL,
25979  NULL, "modify_auth",
25980  "Save Authentication Configuration",
25981  response_data);
25982  free_entity (entity);
25983  g_free (response);
25984  return html;
25985 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_omp.
Definition: gsad_omp.c:25851
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_chart_preference_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
gchar **  pref_id,
gchar **  pref_value,
cmd_response_data_t response_data 
)

Save chart preferences.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]pref_idPreference ID.
[in]pref_valuePreference value.
[out]response_dataExtra data return for the HTTP response.
Returns
SAVE_CHART_PREFERENCE OMP response.

Definition at line 26000 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_t, params_value(), and set_http_status_from_entity().

Referenced by exec_omp_post().

26004 {
26005  *pref_id = g_strdup (params_value (params, "chart_preference_id"));
26006  *pref_value = g_strdup (params_value (params, "chart_preference_value"));
26007 
26008  gchar* value_64 = g_base64_encode ((guchar*)*pref_value,
26009  strlen (*pref_value));
26010  gchar* response;
26011  entity_t entity;
26012  int ret;
26013 
26014  if (*pref_id == NULL)
26015  {
26016  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26017  return ("<save_chart_preference_response"
26018  " status=\"400\" status_text=\"Invalid or missing name\"/>");
26019  }
26020  if (*pref_value == NULL)
26021  {
26022  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26023  return ("<save_chart_preference_response"
26024  " status=\"400\" status_text=\"Invalid or missing value\"/>");
26025  }
26026 
26027  response = NULL;
26028  entity = NULL;
26029  ret = ompf (connection, credentials, &response, &entity, response_data,
26030  "<modify_setting setting_id=\"%s\">"
26031  "<value>%s</value>"
26032  "</modify_setting>",
26033  *pref_id, value_64);
26034  g_free (value_64);
26035  switch (ret)
26036  {
26037  case 0:
26038  case -1:
26039  break;
26040  case 1:
26041  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26042  return gsad_message (credentials,
26043  "Internal error", __FUNCTION__, __LINE__,
26044  "An internal error occurred while saving settings. "
26045  "It is unclear whether all the settings were saved. "
26046  "Diagnostics: Failure to send command to manager daemon.",
26047  "/omp?cmd=get_my_settings", response_data);
26048  case 2:
26049  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26050  return gsad_message (credentials,
26051  "Internal error", __FUNCTION__, __LINE__,
26052  "An internal error occurred while saving settings. "
26053  "It is unclear whether all the settings were saved. "
26054  "Diagnostics: Failure to receive response from manager daemon.",
26055  "/omp?cmd=get_my_settings", response_data);
26056  default:
26057  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26058  return gsad_message (credentials,
26059  "Internal error", __FUNCTION__, __LINE__,
26060  "An internal error occurred while saving settings. "
26061  "It is unclear whether all the settings were saved. "
26062  "Diagnostics: Internal Error.",
26063  "/omp?cmd=get_my_settings", response_data);
26064  }
26065 
26066  if (omp_success (entity))
26067  {
26068  free_entity (entity);
26069  g_free (response);
26070  return ("<save_chart_preference_response"
26071  " status=\"200\" status_text=\"OK\"/>");
26072  }
26073  else
26074  {
26075  set_http_status_from_entity (entity, response_data);
26076  gchar* ret_response
26077  = g_strdup_printf("<save_chart_preference_response"
26078  " status=\"%s\" status_text=\"%s\"/>",
26079  entity_attribute (entity, "status"),
26080  entity_attribute (entity, "status_text"));
26081  free_entity (entity);
26082  g_free (response);
26083  return ret_response;
26084  }
26085 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

Here is the caller graph for this function:

char* save_config_family_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get details of an NVT for a config, XSL transform 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
Result of XSL transformation.

Definition at line 12379 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), and params_values().

12382 {
12383  char *ret;
12384  const char *config_id, *family;
12385  params_t *nvts;
12386 
12387  config_id = params_value (params, "config_id");
12388  family = params_value (params, "family");
12389 
12390  if ((config_id == NULL) || (family == NULL))
12391  {
12392  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
12393  return gsad_message (credentials,
12394  "Internal error", __FUNCTION__, __LINE__,
12395  "An internal error occurred while saving getting config family. "
12396  "The config has not been saved. "
12397  "Diagnostics: Required parameter was NULL.",
12398  "/omp?cmd=get_configs", response_data);
12399  }
12400 
12401  /* Set the NVT selection. */
12402 
12403  if (openvas_connection_sendf (connection,
12404  "<modify_config config_id=\"%s\">"
12405  "<nvt_selection>"
12406  "<family>%s</family>",
12407  config_id,
12408  family)
12409  == -1)
12410  {
12411  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12412  return gsad_message (credentials,
12413  "Internal error", __FUNCTION__, __LINE__,
12414  "An internal error occurred while saving a config. "
12415  "It is unclear whether the entire config has been saved. "
12416  "Diagnostics: Failure to send command to manager daemon.",
12417  "/omp?cmd=get_configs", response_data);
12418  }
12419 
12420  nvts = params_values (params, "nvt:");
12421  if (nvts)
12422  {
12423  params_iterator_t iter;
12424  char *name;
12425  param_t *param;
12426 
12427  params_iterator_init (&iter, nvts);
12428  while (params_iterator_next (&iter, &name, &param))
12429  if (openvas_connection_sendf (connection,
12430  "<nvt oid=\"%s\"/>",
12431  name)
12432  == -1)
12433  {
12434  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12435  return gsad_message (credentials,
12436  "Internal error", __FUNCTION__, __LINE__,
12437  "An internal error occurred while saving a config. "
12438  "It is unclear whether the entire config has been saved. "
12439  "Diagnostics: Failure to send command to manager daemon.",
12440  "/omp?cmd=get_configs", response_data);
12441  }
12442  }
12443 
12444  if (openvas_connection_sendf (connection,
12445  "</nvt_selection>"
12446  "</modify_config>")
12447  == -1)
12448  {
12449  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12450  return gsad_message (credentials,
12451  "Internal error", __FUNCTION__, __LINE__,
12452  "An internal error occurred while saving a config. "
12453  "It is unclear whether the entire config has been saved. "
12454  "Diagnostics: Failure to send command to manager daemon.",
12455  "/omp?cmd=get_configs", response_data);
12456  }
12457 
12458  ret = check_modify_config (credentials, connection, params,
12459  "get_config_family", "edit_config_family",
12460  NULL, response_data);
12461 
12462  return ret;
12463 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187

Here is the call graph for this function:

char* save_config_nvt_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save NVT prefs for a config, get NVT details, XSL transform 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 of XSL transformation.

Definition at line 12656 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::value, and param::value_size.

12659 {
12660  params_t *preferences;
12661  const char *config_id;
12662  int success;
12663  char *modify_config_ret;
12664 
12665  modify_config_ret = NULL;
12666  config_id = params_value (params, "config_id");
12667 
12668  preferences = params_values (params, "preference:");
12669  if (preferences)
12670  {
12671  param_t *preference;
12672  gchar *preference_name;
12673  params_iterator_t iter;
12674 
12675  /* Save preferences. */
12676 
12677  params_iterator_init (&iter, preferences);
12678  while (params_iterator_next (&iter, &preference_name, &preference))
12679  {
12680  int type_start, type_end, count, ret, is_timeout = 0;
12681  gchar *value;
12682 
12683  g_free (modify_config_ret);
12684  modify_config_ret = NULL;
12685 
12686  /* Passwords and files have checkboxes to control whether they
12687  * must be reset. This works around the need for the Manager to
12688  * send the actual password or show the actual file. */
12689 
12690  /* LDAPsearch[entry]:Timeout value */
12691  count = sscanf (preference_name,
12692  "%*[^[][%n%*[^]]%n]:",
12693  &type_start,
12694  &type_end);
12695  if (count == 0 && type_start > 0 && type_end > 0)
12696  {
12697  if (strncmp (preference_name + type_start,
12698  "password",
12699  type_end - type_start)
12700  == 0)
12701  {
12702  int found = 0;
12703  params_t *passwords;
12704 
12705  passwords = params_values (params, "password:");
12706  if (passwords)
12707  {
12708  param_t *password;
12709  gchar *password_name;
12710  params_iterator_t password_params;
12711 
12712  params_iterator_init (&password_params, passwords);
12713  while (params_iterator_next (&password_params,
12714  &password_name,
12715  &password))
12716  if (strcmp (password_name, preference_name) == 0)
12717  {
12718  found = 1;
12719  break;
12720  }
12721  }
12722  if (found == 0)
12723  /* Skip modifying the password preference. */
12724  continue;
12725  }
12726  else if (strncmp (preference_name + type_start,
12727  "file",
12728  type_end - type_start)
12729  == 0)
12730  {
12731  int found = 0;
12732  params_t *files;
12733 
12734  files = params_values (params, "file:");
12735  if (files)
12736  {
12737  param_t *file;
12738  gchar *file_name;
12739  params_iterator_t file_params;
12740 
12741  params_iterator_init (&file_params, files);
12742  while (params_iterator_next (&file_params,
12743  &file_name,
12744  &file))
12745  if (strcmp (file_name, preference_name) == 0)
12746  {
12747  found = 1;
12748  break;
12749  }
12750  }
12751  if (found == 0)
12752  /* Skip modifying the file preference. */
12753  continue;
12754  }
12755  else if (strncmp (preference_name + type_start,
12756  "scanner",
12757  type_end - type_start)
12758  == 0)
12759  {
12760  /* Presume it's the timeout. */
12761  is_timeout = 1;
12762  }
12763  }
12764 
12765  value = preference->value_size
12766  ? g_base64_encode ((guchar *) preference->value,
12767  preference->value_size)
12768  : g_strdup ("");
12769 
12770  if (is_timeout)
12771  {
12772  const char *timeout;
12773  gchar *preference_name_escaped;
12774 
12775  timeout = params_value (params, "timeout");
12776 
12777  if (timeout == NULL)
12778  {
12779  g_free (value);
12780  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
12781  return gsad_message (credentials,
12782  "Internal error", __FUNCTION__, __LINE__,
12783  "An internal error occurred while saving a config. "
12784  "It is unclear whether the entire config has been saved. "
12785  "Diagnostics: Required parameter was NULL.",
12786  "/omp?cmd=get_configs", response_data);
12787  }
12788 
12789  preference_name_escaped = g_markup_escape_text (preference_name,
12790  -1);
12791 
12792  if (strcmp (timeout, "0") == 0)
12793  /* Leave out the value to clear the preference. */
12794  ret = openvas_connection_sendf (connection,
12795  "<modify_config"
12796  " config_id=\"%s\">"
12797  "<preference>"
12798  "<name>%s</name>"
12799  "</preference>"
12800  "</modify_config>",
12801  config_id,
12802  preference_name_escaped);
12803  else
12804  ret = openvas_connection_sendf (connection,
12805  "<modify_config"
12806  " config_id=\"%s\">"
12807  "<preference>"
12808  "<name>%s</name>"
12809  "<value>%s</value>"
12810  "</preference>"
12811  "</modify_config>",
12812  config_id,
12813  preference_name_escaped,
12814  value);
12815 
12816  g_free (preference_name_escaped);
12817  }
12818  else
12819  {
12820  gchar *preference_name_escaped;
12821  preference_name_escaped = g_markup_escape_text (preference_name,
12822  -1);
12823  ret = openvas_connection_sendf (connection,
12824  "<modify_config"
12825  " config_id=\"%s\">"
12826  "<preference>"
12827  "<nvt oid=\"%s\"/>"
12828  "<name>%s</name>"
12829  "<value>%s</value>"
12830  "</preference>"
12831  "</modify_config>",
12832  config_id,
12833  params_value (params, "oid"),
12834  preference_name_escaped,
12835  value);
12836  g_free (preference_name_escaped);
12837  }
12838 
12839  if (ret == -1)
12840  {
12841  g_free (value);
12842  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12843  return gsad_message (credentials,
12844  "Internal error", __FUNCTION__, __LINE__,
12845  "An internal error occurred while saving a config. "
12846  "It is unclear whether the entire config has been saved. "
12847  "Diagnostics: Failure to send command to manager daemon.",
12848  "/omp?cmd=get_configs", response_data);
12849  }
12850  g_free (value);
12851 
12852  modify_config_ret = check_modify_config (credentials, connection,
12853  params,
12854  "get_config_nvt",
12855  "edit_config_nvt",
12856  &success, response_data);
12857  if (success == 0)
12858  {
12859  return modify_config_ret;
12860  }
12861  }
12862  }
12863 
12864  return modify_config_ret;
12865 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int value_size
Definition: gsad_base.h:154
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187

Here is the call graph for this function:

char* save_config_omp ( openvas_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 11952 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, member1(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::value, and param::value_size.

11954 {
11955  int omp_ret;
11956  char *ret, *osp_ret;
11957  params_t *preferences, *selects, *trends;
11958  const char *config_id, *name, *comment, *scanner_id;
11959  int success;
11960 
11961  config_id = params_value (params, "config_id");
11962  name = params_value (params, "name");
11963  comment = params_value (params, "comment");
11964  scanner_id = params_value (params, "scanner_id");
11965 
11966  CHECK_PARAM_INVALID (config_id, "Save Config", "edit_config");
11967  CHECK_PARAM_INVALID (name, "Save Config", "edit_config");
11968  CHECK_PARAM_INVALID (comment, "Save Config", "edit_config");
11969 
11970  /* Save name and comment. */
11971 
11972  if (scanner_id)
11973  omp_ret = openvas_connection_sendf_xml (connection,
11974  "<modify_config config_id=\"%s\">"
11975  "<name>%s</name>"
11976  "<comment>%s</comment>"
11977  "<scanner>%s</scanner>"
11978  "</modify_config>",
11979  params_value (params, "config_id"),
11980  name,
11981  comment,
11982  scanner_id);
11983  else
11984  omp_ret = openvas_connection_sendf_xml (connection,
11985  "<modify_config config_id=\"%s\">"
11986  "<name>%s</name>"
11987  "<comment>%s</comment>"
11988  "</modify_config>",
11989  params_value (params, "config_id"),
11990  name,
11991  comment);
11992 
11993  if (omp_ret == -1)
11994  {
11995  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11996  return gsad_message (credentials,
11997  "Internal error", __FUNCTION__, __LINE__,
11998  "An internal error occurred while saving a config. "
11999  "It is unclear whether the entire config has been saved. "
12000  "Diagnostics: Failure to send command to manager daemon.",
12001  "/omp?cmd=get_configs", response_data);
12002  }
12003 
12004  ret = check_modify_config (credentials, connection, params,
12005  "get_config", "edit_config",
12006  &success, response_data);
12007  if (success == 0)
12008  {
12009  return ret;
12010  }
12011 
12012  /* Save preferences. */
12013 
12014  preferences = params_values (params, "preference:");
12015  if (preferences)
12016  {
12017  params_iterator_t iter;
12018  char *param_name;
12019  param_t *param;
12020 
12021  params_iterator_init (&iter, preferences);
12022  while (params_iterator_next (&iter, &param_name, &param))
12023  {
12024  gchar *value;
12025 
12026  value = param->value_size
12027  ? g_base64_encode ((guchar *) param->value,
12028  param->value_size)
12029  : g_strdup ("");
12030 
12031  if (openvas_connection_sendf (connection,
12032  "<modify_config config_id=\"%s\">"
12033  "<preference>"
12034  "<name>%s</name>"
12035  "<value>%s</value>"
12036  "</preference>"
12037  "</modify_config>",
12038  params_value (params, "config_id"),
12039  param_name,
12040  value)
12041  == -1)
12042  {
12043  g_free (value);
12044  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12045  return gsad_message (credentials,
12046  "Internal error", __FUNCTION__, __LINE__,
12047  "An internal error occurred while saving a config. "
12048  "It is unclear whether the entire config has been saved. "
12049  "Diagnostics: Failure to send command to manager daemon.",
12050  "/omp?cmd=get_configs", response_data);
12051  }
12052  g_free (value);
12053  g_free (ret);
12054 
12055  ret = check_modify_config (credentials, connection, params,
12056  "get_config", "edit_config",
12057  &success, response_data);
12058  if (success == 0)
12059  {
12060  return ret;
12061  }
12062  }
12063  }
12064 
12065  /* OSP config file preference. */
12066  osp_ret = save_osp_prefs (credentials, connection, params,
12067  "get_config", "edit_config",
12068  &success, response_data);
12069 
12070  if (osp_ret)
12071  {
12072  g_free (ret);
12073  ret = osp_ret;
12074  }
12075 
12076  if (success == 0)
12077  {
12078  if (osp_ret == NULL)
12079  {
12080  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12081  return gsad_message (credentials,
12082  "Internal error", __FUNCTION__, __LINE__,
12083  "An internal error occurred while saving a config. "
12084  "It is unclear whether the entire config has been saved. "
12085  "Diagnostics: save_osp_prefs returned NULL unexpectedly.",
12086  "/omp?cmd=get_configs", response_data);
12087  }
12088  return ret;
12089  }
12090 
12091  /* Update the config. */
12092 
12093  trends = params_values (params, "trend:");
12094  selects = params_values (params, "select:");
12095 
12096  if (trends || selects || params_value (params, "trend"))
12097  {
12098  if (openvas_connection_sendf (connection,
12099  "<modify_config config_id=\"%s\">"
12100  "<family_selection>"
12101  "<growing>%i</growing>",
12102  params_value (params, "config_id"),
12103  trends
12104  && params_value (params, "trend")
12105  && strcmp (params_value (params, "trend"), "0"))
12106  == -1)
12107  {
12108  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12109  return gsad_message (credentials,
12110  "Internal error", __FUNCTION__, __LINE__,
12111  "An internal error occurred while saving a config. "
12112  "It is unclear whether the entire config has been saved. "
12113  "Diagnostics: Failure to send command to manager daemon.",
12114  "/omp?cmd=get_configs", response_data);
12115  }
12116 
12117  if (selects)
12118  {
12119  gchar *family;
12120  params_iterator_t iter;
12121  param_t *param;
12122 
12123  params_iterator_init (&iter, selects);
12124  while (params_iterator_next (&iter, &family, &param))
12125  if (openvas_connection_sendf (connection,
12126  "<family>"
12127  "<name>%s</name>"
12128  "<all>1</all>"
12129  "<growing>%i</growing>"
12130  "</family>",
12131  family,
12132  trends && member1 (trends, family))
12133  == -1)
12134  {
12135  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12136  return gsad_message (credentials,
12137  "Internal error", __FUNCTION__, __LINE__,
12138  "An internal error occurred while saving a config. "
12139  "It is unclear whether the entire config has been saved. "
12140  "Diagnostics: Failure to send command to manager daemon.",
12141  "/omp?cmd=get_configs", response_data);
12142  }
12143  }
12144 
12145  if (trends)
12146  {
12147  gchar *family;
12148  params_iterator_t iter;
12149  param_t *param;
12150 
12151  params_iterator_init (&iter, trends);
12152  while (params_iterator_next (&iter, &family, &param))
12153  {
12154  if (param->value_size == 0) continue;
12155  if (param->value[0] == '0') continue;
12156  if (selects && member (selects, family)) continue;
12157  if (openvas_connection_sendf (connection,
12158  "<family>"
12159  "<name>%s</name>"
12160  "<all>0</all>"
12161  "<growing>1</growing>"
12162  "</family>",
12163  family)
12164  == -1)
12165  {
12166  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12167  return gsad_message (credentials,
12168  "Internal error", __FUNCTION__, __LINE__,
12169  "An internal error occurred while saving a config. "
12170  "It is unclear whether the entire config has been saved. "
12171  "Diagnostics: Failure to send command to manager daemon.",
12172  "/omp?cmd=get_configs", response_data);
12173  }
12174  }
12175  }
12176 
12177  if (openvas_connection_sendf (connection,
12178  "</family_selection>"
12179  "</modify_config>")
12180  == -1)
12181  {
12182  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12183  return gsad_message (credentials,
12184  "Internal error", __FUNCTION__, __LINE__,
12185  "An internal error occurred while saving a config. "
12186  "It is unclear whether the entire config has been saved. "
12187  "Diagnostics: Failure to send command to manager daemon.",
12188  "/omp?cmd=get_configs", response_data);
12189  }
12190 
12191  g_free (ret);
12192  ret = check_modify_config (credentials, connection, params,
12193  "get_config", "edit_config",
12194  NULL, response_data);
12195  }
12196  return ret;
12197 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int value_size
Definition: gsad_base.h:154
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
Definition: gsad_omp.c:725
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_container_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save container task, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 4887 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

4890 {
4891  gchar *format, *response, *html;
4892  const char *no_redirect, *comment, *name, *task_id;
4893  const char *in_assets, *auto_delete, *auto_delete_data;
4894  int ret;
4895  entity_t entity;
4896 
4897  no_redirect = params_value (params, "no_redirect");
4898  comment = params_value (params, "comment");
4899  in_assets = params_value (params, "in_assets");
4900  name = params_value (params, "name");
4901  task_id = params_value (params, "task_id");
4902  auto_delete = params_value (params, "auto_delete");
4903  auto_delete_data = params_value (params, "auto_delete_data");
4904  CHECK_PARAM_INVALID (name, "Save Task", "edit_task")
4905  CHECK_PARAM_INVALID (comment, "Save Task", "edit_task")
4906  CHECK_PARAM_INVALID (task_id, "Save Task", "edit_task")
4907  CHECK_PARAM_INVALID (in_assets, "Save Task", "edit_task")
4908  CHECK_PARAM_INVALID (auto_delete, "Save Task", "edit_task");
4909  CHECK_PARAM_INVALID (auto_delete_data, "Save Task", "edit_task");
4910 
4911  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
4912  "<name>%%s</name>"
4913  "<comment>%%s</comment>"
4914  "<preferences>"
4915  "<preference>"
4916  "<scanner_name>in_assets</scanner_name>"
4917  "<value>%%s</value>"
4918  "</preference>"
4919  "<preference>"
4920  "<scanner_name>auto_delete</scanner_name>"
4921  "<value>%%s</value>"
4922  "</preference>"
4923  "<preference>"
4924  "<scanner_name>auto_delete_data</scanner_name>"
4925  "<value>%%s</value>"
4926  "</preference>"
4927  "</preferences>"
4928  "</modify_task>");
4929 
4930  response = NULL;
4931  entity = NULL;
4932  ret = ompf (connection, credentials, &response, &entity, response_data,
4933  format, task_id, name, comment,
4934  strcmp (in_assets, "0") ? "yes" : "no",
4935  auto_delete,
4936  auto_delete_data);
4937  g_free (format);
4938  switch (ret)
4939  {
4940  case 0:
4941  case -1:
4942  break;
4943  case 1:
4944  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4945  return gsad_message (credentials,
4946  "Internal error", __FUNCTION__, __LINE__,
4947  "An internal error occurred while saving a task. "
4948  "No new task was created. "
4949  "Diagnostics: Failure to send command to manager daemon.",
4950  "/omp?cmd=get_tasks", response_data);
4951  case 2:
4952  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4953  return gsad_message (credentials,
4954  "Internal error", __FUNCTION__, __LINE__,
4955  "An internal error occurred while saving a task. "
4956  "It is unclear whether the task has been created or not. "
4957  "Diagnostics: Failure to receive response from manager daemon.",
4958  "/omp?cmd=get_tasks", response_data);
4959  default:
4960  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4961  return gsad_message (credentials,
4962  "Internal error", __FUNCTION__, __LINE__,
4963  "An internal error occurred while saving a task. "
4964  "It is unclear whether the task has been created or not. "
4965  "Diagnostics: Internal Error.",
4966  "/omp?cmd=get_tasks", response_data);
4967  }
4968 
4969  html = response_from_entity (connection, credentials, params, entity,
4970  (no_redirect && strcmp (no_redirect, "0")),
4971  NULL, "get_tasks",
4972  NULL, "edit_task",
4973  "Save Container Task", response_data);
4974  free_entity (entity);
4975  g_free (response);
4976  return html;
4977 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_credential_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save credential, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 6679 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_t, and params_value().

6682 {
6683  int ret, change_password, change_passphrase;
6684  int change_community, change_privacy_password;
6685  gchar *html, *response;
6686  const char *no_redirect, *credential_id;
6687  const char *name, *comment, *login, *password, *passphrase;
6688  const char *private_key, *certificate, *community, *privacy_password;
6689  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6690  GString *command;
6691  entity_t entity;
6692 
6693  no_redirect = params_value (params, "no_redirect");
6694  credential_id = params_value (params, "credential_id");
6695  name = params_value (params, "name");
6696  comment = params_value (params, "comment");
6697  login = params_value (params, "credential_login");
6698  password = params_value (params, "password");
6699  passphrase = params_value (params, "passphrase");
6700  private_key = params_value (params, "private_key");
6701  certificate = params_value (params, "certificate");
6702  community = params_value (params, "community");
6703  privacy_password = params_value (params, "privacy_password");
6704  auth_algorithm = params_value (params, "auth_algorithm");
6705  privacy_algorithm = params_value (params, "privacy_algorithm");
6706  allow_insecure = params_value (params, "allow_insecure");
6707 
6708  CHECK_PARAM_INVALID (credential_id, "Save Credential", "edit_credential");
6709  CHECK_PARAM_INVALID (name, "Save Credential", "edit_credential");
6710  CHECK_PARAM_INVALID (comment, "Save Credential", "edit_credential");
6711  CHECK_PARAM_INVALID (allow_insecure, "Save Credential", "edit_credential");
6712  if (params_given (params, "certificate"))
6713  CHECK_PARAM_INVALID (certificate, "Save Credential", "edit_credential");
6714  if (params_given (params, "private_key"))
6715  CHECK_PARAM_INVALID (private_key, "Save Credential", "edit_credential");
6716  if (params_given (params, "login"))
6717  CHECK_PARAM_INVALID (login, "Save Credential", "edit_credential");
6718  if (params_given (params, "auth_algorithm"))
6719  CHECK_PARAM_INVALID (auth_algorithm, "Save Credential", "edit_credential");
6720  if (params_given (params, "privacy_algorithm"))
6721  CHECK_PARAM_INVALID (privacy_algorithm,
6722  "Save Credential", "edit_credential");
6723 
6724  change_community = (params_value (params, "change_community") ? 1 : 0);
6725  if (change_community)
6726  CHECK_PARAM_INVALID (community, "Save Credential", "edit_credential");
6727  change_passphrase = (params_value (params, "change_passphrase") ? 1 : 0);
6728  if (change_passphrase)
6729  CHECK_PARAM_INVALID (passphrase, "Save Credential", "edit_credential");
6730  change_password = (params_value (params, "change_password") ? 1 : 0);
6731  if (change_password)
6732  CHECK_PARAM_INVALID (password, "Save Credential", "edit_credential");
6733  change_privacy_password
6734  = (params_value (params, "change_privacy_password") ? 1 : 0);
6735  if (change_privacy_password)
6736  CHECK_PARAM_INVALID (privacy_password,
6737  "Save Credential", "edit_credential");
6738 
6739  /* Prepare command */
6740  command = g_string_new ("");
6741 
6742  xml_string_append (command,
6743  "<modify_credential credential_id=\"%s\">"
6744  "<name>%s</name>"
6745  "<comment>%s</comment>"
6746  "<allow_insecure>%s</allow_insecure>",
6747  credential_id,
6748  name,
6749  comment,
6750  allow_insecure);
6751 
6752  if (auth_algorithm)
6753  xml_string_append (command,
6754  "<auth_algorithm>%s</auth_algorithm>",
6755  auth_algorithm);
6756 
6757  if (certificate && strcmp (certificate, ""))
6758  xml_string_append (command,
6759  "<certificate>%s</certificate>",
6760  certificate);
6761 
6762  if (change_community)
6763  xml_string_append (command,
6764  "<community>%s</community>",
6765  community);
6766 
6767  if (login && strcmp (login, ""))
6768  xml_string_append (command,
6769  "<login>%s</login>",
6770  login);
6771 
6772  if (change_password)
6773  xml_string_append (command,
6774  "<password>%s</password>",
6775  password);
6776 
6777  if (privacy_algorithm || change_privacy_password)
6778  {
6779  xml_string_append (command,
6780  "<privacy>");
6781  if (privacy_algorithm && strcmp (privacy_algorithm, ""))
6782  {
6783  xml_string_append (command,
6784  "<algorithm>%s</algorithm>",
6785  privacy_algorithm);
6786  if (change_privacy_password)
6787  xml_string_append (command,
6788  "<password>%s</password>",
6789  privacy_password);
6790  }
6791  else if (privacy_algorithm)
6792  {
6793  xml_string_append (command,
6794  "<algorithm></algorithm>");
6795  xml_string_append (command,
6796  "<password></password>");
6797  }
6798 
6799  xml_string_append (command,
6800  "</privacy>");
6801  }
6802 
6803  if ((private_key && strcmp (private_key, "")) || change_passphrase)
6804  {
6805  xml_string_append (command,
6806  "<key>");
6807  if (change_passphrase)
6808  xml_string_append (command,
6809  "<phrase>%s</phrase>",
6810  passphrase);
6811  if (private_key)
6812  xml_string_append (command,
6813  "<private>%s</private>",
6814  private_key);
6815  xml_string_append (command,
6816  "</key>");
6817  }
6818 
6819  xml_string_append (command,
6820  "</modify_credential>");
6821 
6822  /* Modify the credential. */
6823  response = NULL;
6824  entity = NULL;
6825  ret = omp (connection, credentials,
6826  &response,
6827  &entity,
6828  response_data,
6829  command->str);
6830  g_string_free (command, TRUE);
6831 
6832  switch (ret)
6833  {
6834  case 0:
6835  break;
6836  case -1:
6837  /* 'omp' set response. */
6838  return response;
6839  case 1:
6840  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6841  return gsad_message (credentials,
6842  "Internal error", __FUNCTION__, __LINE__,
6843  "An internal error occurred while saving a Credential. "
6844  "The Credential was not saved. "
6845  "Diagnostics: Failure to send command to manager daemon.",
6846  "/omp?cmd=get_credentials", response_data);
6847  case 2:
6848  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6849  return gsad_message (credentials,
6850  "Internal error", __FUNCTION__, __LINE__,
6851  "An internal error occurred while saving a Credential. "
6852  "It is unclear whether the Credential has been saved or not. "
6853  "Diagnostics: Failure to receive response from manager daemon.",
6854  "/omp?cmd=get_credentials", response_data);
6855  default:
6856  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6857  return gsad_message (credentials,
6858  "Internal error", __FUNCTION__, __LINE__,
6859  "An internal error occurred while saving a Credential. "
6860  "It is unclear whether the Credential has been saved or not. "
6861  "Diagnostics: Internal Error.",
6862  "/omp?cmd=get_credentials", response_data);
6863  }
6864 
6865  html = response_from_entity (connection, credentials, params, entity,
6866  (no_redirect && strcmp (no_redirect, "0")),
6867  NULL, "get_credentials",
6868  NULL, "edit_credential",
6869  "Save Credential", response_data);
6870  free_entity (entity);
6871  g_free (response);
6872  return html;
6873 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_filter_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a filter, get all filters, XSL transform 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
Result of XSL transformation.

Definition at line 24111 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

24113 {
24114  entity_t entity;
24115  gchar *html, *response;
24116  const char *no_redirect, *filter_id, *name, *comment, *term, *type;
24117 
24118  no_redirect = params_value (params, "no_redirect");
24119  filter_id = params_value (params, "filter_id");
24120  name = params_value (params, "name");
24121  comment = params_value (params, "comment");
24122  term = params_value (params, "term");
24123  type = params_value (params, "optional_resource_type");
24124 
24125  CHECK_PARAM_INVALID (filter_id, "Save Filter", "edit_filter");
24126  CHECK_PARAM_INVALID (name, "Save Filter", "edit_filter");
24127  CHECK_PARAM_INVALID (comment, "Save Filter", "edit_filter");
24128  CHECK_PARAM_INVALID (term, "Save Filter", "edit_filter");
24129  CHECK_PARAM_INVALID (type, "Save Filter", "edit_filter");
24130 
24131  {
24132  int ret;
24133 
24134  /* Modify the filter. */
24135 
24136  ret = openvas_connection_sendf_xml (connection,
24137  "<modify_filter filter_id=\"%s\">"
24138  "<name>%s</name>"
24139  "<comment>%s</comment>"
24140  "<term>%s</term>"
24141  "<type>%s</type>"
24142  "</modify_filter>",
24143  filter_id,
24144  name,
24145  comment,
24146  term,
24147  type);
24148 
24149  if (ret == -1)
24150  {
24151  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24152  return gsad_message (credentials,
24153  "Internal error", __FUNCTION__, __LINE__,
24154  "An internal error occurred while modifying a filter. "
24155  "The filter was not modified. "
24156  "Diagnostics: Failure to send command to manager daemon.",
24157  "/omp?cmd=get_filters", response_data);
24158  }
24159 
24160  entity = NULL;
24161  if (read_entity_and_text_c (connection, &entity, &response))
24162  {
24163  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24164  return gsad_message (credentials,
24165  "Internal error", __FUNCTION__, __LINE__,
24166  "An internal error occurred while modifying a filter. "
24167  "It is unclear whether the filter has been modified or not. "
24168  "Diagnostics: Failure to receive response from manager daemon.",
24169  "/omp?cmd=get_filters", response_data);
24170  }
24171 
24172  }
24173 
24174  /* Pass response to handler of following page. */
24175 
24176  html = response_from_entity (connection, credentials, params, entity,
24177  (no_redirect && strcmp (no_redirect, "0")),
24178  NULL, "get_filters",
24179  NULL, "edit_filter",
24180  "Save Filter", response_data);
24181 
24182  free_entity (entity);
24183  g_free (response);
24184  return html;
24185 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_group_omp ( openvas_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
Result of XSL transformation.

Definition at line 20468 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, params_t, params_value(), and users.

20470 {
20471  int ret;
20472  gchar *html, *response;
20473  const char *no_redirect, *group_id, *name, *comment, *users;
20474  entity_t entity;
20475 
20476  no_redirect = params_value (params, "no_redirect");
20477  group_id = params_value (params, "group_id");
20478  name = params_value (params, "name");
20479  comment = params_value (params, "comment");
20480  users = params_value (params, "users");
20481 
20482  CHECK_PARAM_INVALID (group_id, "Save Group", "edit_group");
20483  CHECK_PARAM_INVALID (name, "Save Group", "edit_group");
20484  CHECK_PARAM_INVALID (comment, "Save Group", "edit_group");
20485  CHECK_PARAM_INVALID (users, "Save Group", "edit_group");
20486 
20487  /* Modify the Group. */
20488 
20489  response = NULL;
20490  entity = NULL;
20491  ret = ompf (connection, credentials,
20492  &response,
20493  &entity,
20494  response_data,
20495  "<modify_group group_id=\"%s\">"
20496  "<name>%s</name>"
20497  "<comment>%s</comment>"
20498  "<users>%s</users>"
20499  "</modify_group>",
20500  group_id,
20501  name,
20502  comment,
20503  users);
20504 
20505  switch (ret)
20506  {
20507  case 0:
20508  case -1:
20509  break;
20510  case 1:
20511  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20512  return gsad_message (credentials,
20513  "Internal error", __FUNCTION__, __LINE__,
20514  "An internal error occurred while saving a group. "
20515  "The group was not saved. "
20516  "Diagnostics: Failure to send command to manager daemon.",
20517  "/omp?cmd=get_groups", response_data);
20518  case 2:
20519  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20520  return gsad_message (credentials,
20521  "Internal error", __FUNCTION__, __LINE__,
20522  "An internal error occurred while saving a group. "
20523  "It is unclear whether the group has been saved or not. "
20524  "Diagnostics: Failure to receive response from manager daemon.",
20525  "/omp?cmd=get_groups", response_data);
20526  default:
20527  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20528  return gsad_message (credentials,
20529  "Internal error", __FUNCTION__, __LINE__,
20530  "An internal error occurred while saving a group. "
20531  "It is unclear whether the group has been saved or not. "
20532  "Diagnostics: Internal Error.",
20533  "/omp?cmd=get_groups", response_data);
20534  }
20535 
20536  html = response_from_entity (connection, credentials, params, entity,
20537  (no_redirect && strcmp (no_redirect, "0")),
20538  NULL, "get_groups",
20539  NULL, "edit_group",
20540  "Save Group", response_data);
20541  free_entity (entity);
20542  g_free (response);
20543  return html;
20544 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
GPtrArray * users
User session data.
Definition: gsad.c:340
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_my_settings_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
const char *  accept_language,
char **  timezone,
char **  password,
char **  severity,
char **  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
Result of XSL transformation.

Definition at line 19221 of file gsad_omp.c.

References accept_language_to_env_fmt(), gsad_message(), GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, credentials_t::language, params_t, params_value(), params_values(), credentials_t::password, set_http_status_from_entity(), set_language_code(), credentials_t::severity, credentials_t::timezone, and credentials_t::username.

Referenced by exec_omp_post().

19226 {
19227  const char *lang, *text, *old_passwd, *passwd, *status, *max;
19228  const char *details_fname, *list_fname, *report_fname;
19229  gchar *lang_64, *text_64, *max_64, *fname_64;
19230  GString *xml;
19231  entity_t entity;
19232  params_t *changed, *defaults, *filters;
19233  int modify_failed = 0;
19234  const char *changed_value;
19235 
19236  changed = params_values (params, "settings_changed:");
19237  *timezone = NULL;
19238  *password = NULL;
19239  *severity = NULL;
19240  *language = NULL;
19241 
19242  text = params_value (params, "text");
19243  old_passwd = params_value (params, "old_password");
19244  passwd = params_value (params, "password");
19245  max = params_value (params, "max");
19246  lang = params_value (params, "lang");
19247  details_fname = params_value (params, "details_fname");
19248  list_fname = params_value (params, "list_fname");
19249  report_fname = params_value (params, "report_fname");
19250  if ((text == NULL)
19251  || (passwd == NULL)
19252  || (old_passwd == NULL)
19253  || (max == NULL)
19254  || (lang == NULL)
19255  || (details_fname == NULL)
19256  || (list_fname == NULL)
19257  || (report_fname == NULL))
19258  return edit_my_settings (connection, credentials, params,
19260  ("Save My Settings"),
19261  response_data);
19262 
19263  xml = g_string_new ("");
19264 
19265  changed_value = params_value (changed, "password");
19266  if ((strlen (passwd) || strlen (old_passwd))
19267  && (changed_value == NULL
19268  || (strcmp (changed_value, "") && strcmp (changed_value, "0"))))
19269  {
19270  gchar *passwd_64;
19271  omp_authenticate_info_opts_t auth_opts;
19272 
19273  /* Send Password setting */
19274 
19275  auth_opts = omp_authenticate_info_opts_defaults;
19276  auth_opts.username = credentials->username;
19277  auth_opts.password = old_passwd;
19278  switch (omp_authenticate_info_ext_c (connection, auth_opts))
19279  {
19280  case 0:
19281  break;
19282  case 1:
19283  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19284  return gsad_message (credentials,
19285  "Internal error", __FUNCTION__, __LINE__,
19286  "An internal error occurred while saving settings. "
19287  "The settings remains the same. "
19288  "Diagnostics: Manager closed connection during authenticate.",
19289  "/omp?cmd=get_my_settings", response_data);
19290  case 2:
19291  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
19292  return gsad_message (credentials,
19293  "Invalid Password", __FUNCTION__, __LINE__,
19294  "You tried to change your password, but the old"
19295  " password was not provided or was incorrect. "
19296  " Please enter the correct old password or remove"
19297  " old and new passwords to apply any other changes"
19298  " of your settings.",
19299  "/omp?cmd=get_my_settings", response_data);
19300  default:
19301  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19302  return gsad_message (credentials,
19303  "Internal error", __FUNCTION__, __LINE__,
19304  "An internal error occurred while saving settings. "
19305  "The settings remains the same. "
19306  "Diagnostics: Internal Error.",
19307  "/omp?cmd=get_my_settings", response_data);
19308  }
19309 
19310  passwd_64 = g_base64_encode ((guchar*) passwd, strlen (passwd));
19311 
19312  if (openvas_connection_sendf (connection,
19313  "<modify_setting>"
19314  "<name>Password</name>"
19315  "<value>%s</value>"
19316  "</modify_setting>",
19317  passwd_64 ? passwd_64 : "")
19318  == -1)
19319  {
19320  g_free (passwd_64);
19321  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19322  return gsad_message (credentials,
19323  "Internal error", __FUNCTION__, __LINE__,
19324  "An internal error occurred while saving settings. "
19325  "It is unclear whether all the settings were saved. "
19326  "Diagnostics: Failure to send command to manager daemon.",
19327  "/omp?cmd=get_my_settings", response_data);
19328  }
19329  g_free (passwd_64);
19330 
19331  entity = NULL;
19332  xml_string_append (xml, "<save_setting name=\"Password\">");
19333  if (read_entity_and_string_c (connection, &entity, &xml))
19334  {
19335  g_string_free (xml, TRUE);
19336  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19337  return gsad_message (credentials,
19338  "Internal error", __FUNCTION__, __LINE__,
19339  "An internal error occurred while saving settings. "
19340  "Diagnostics: Failure to receive response from manager daemon.",
19341  "/omp?cmd=get_my_settings", response_data);
19342  }
19343  xml_string_append (xml, "</save_setting>");
19344 
19345  status = entity_attribute (entity, "status");
19346  if (status && (strlen (status) > 0) && (status[0] == '2'))
19347  {
19348  g_free (credentials->password);
19349  credentials->password = g_strdup (passwd);
19350  *password = g_strdup (passwd);
19351  }
19352  else
19353  {
19354  set_http_status_from_entity (entity, response_data);
19355  modify_failed = 1;
19356  }
19357  }
19358 
19359  /* Send Timezone */
19360  changed_value = params_value (changed, "timezone");
19361  if (changed_value == NULL
19362  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19363  {
19364  text_64 = g_base64_encode ((guchar*) text, strlen (text));
19365 
19366  if (openvas_connection_sendf (connection,
19367  "<modify_setting>"
19368  "<name>Timezone</name>"
19369  "<value>%s</value>"
19370  "</modify_setting>",
19371  text_64 ? text_64 : "")
19372  == -1)
19373  {
19374  g_free (text_64);
19375  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19376  return gsad_message (credentials,
19377  "Internal error", __FUNCTION__, __LINE__,
19378  "An internal error occurred while saving settings. "
19379  "It is unclear whether all the settings were saved. "
19380  "Diagnostics: Failure to send command to manager daemon.",
19381  "/omp?cmd=get_my_settings", response_data);
19382  }
19383  g_free (text_64);
19384 
19385  entity = NULL;
19386  xml_string_append (xml, "<save_setting name=\"Timezone\">");
19387  if (read_entity_and_string_c (connection, &entity, &xml))
19388  {
19389  g_string_free (xml, TRUE);
19390  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19391  return gsad_message (credentials,
19392  "Internal error", __FUNCTION__, __LINE__,
19393  "An internal error occurred while saving settings. "
19394  "Diagnostics: Failure to receive response from manager daemon.",
19395  "/omp?cmd=get_my_settings", response_data);
19396  }
19397  xml_string_append (xml, "</save_setting>");
19398 
19399  status = entity_attribute (entity, "status");
19400  if (status && (strlen (status) > 0) && (status[0] == '2'))
19401  {
19402  g_free (credentials->timezone);
19403  credentials->timezone = g_strdup (strlen (text) ? text : "UTC");
19404  *timezone = g_strdup (strlen (text) ? text : "UTC");
19405 
19406  /* Set the timezone, so that the ENVELOPE/TIME
19407  * uses the right timezone. */
19408 
19409  if (setenv ("TZ", credentials->timezone, 1) == -1)
19410  {
19411  g_critical ("%s: failed to set TZ\n", __FUNCTION__);
19412  exit (EXIT_FAILURE);
19413  }
19414  tzset ();
19415  }
19416  else
19417  {
19418  set_http_status_from_entity (entity, response_data);
19419  modify_failed = 1;
19420  }
19421  }
19422 
19423  /* Send Rows Per Page */
19424  changed_value = params_value (changed, "max");
19425  if (changed_value == NULL
19426  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19427  {
19428  max_64 = g_base64_encode ((guchar*) max, strlen (max));
19429 
19430  if (openvas_connection_sendf (connection,
19431  "<modify_setting"
19432  " setting_id"
19433  "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">"
19434  "<value>%s</value>"
19435  "</modify_setting>",
19436  max_64 ? max_64 : "")
19437  == -1)
19438  {
19439  g_free (max_64);
19440  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19441  return gsad_message (credentials,
19442  "Internal error", __FUNCTION__, __LINE__,
19443  "An internal error occurred while saving settings. "
19444  "It is unclear whether all the settings were saved. "
19445  "Diagnostics: Failure to send command to manager daemon.",
19446  "/omp?cmd=get_my_settings", response_data);
19447  }
19448  g_free (max_64);
19449 
19450  entity = NULL;
19451  xml_string_append (xml,
19452  "<save_setting id=\"%s\">",
19453  "5f5a8712-8017-11e1-8556-406186ea4fc5");
19454  if (read_entity_and_string_c (connection, &entity, &xml))
19455  {
19456  g_string_free (xml, TRUE);
19457  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19458  return gsad_message (credentials,
19459  "Internal error", __FUNCTION__, __LINE__,
19460  "An internal error occurred while saving settings. "
19461  "It is unclear whether all the settings were saved. "
19462  "Diagnostics: Failure to receive response from manager daemon.",
19463  "/omp?cmd=get_my_settings", response_data);
19464  }
19465  xml_string_append (xml, "</save_setting>");
19466  if (! omp_success (entity))
19467  {
19468  set_http_status_from_entity (entity, response_data);
19469  modify_failed = 1;
19470  }
19471  }
19472 
19473  /* Send resource details export file name format. */
19474  changed_value = params_value (changed, "details_fname");
19475  if (changed_value == NULL
19476  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19477  {
19478  fname_64 = g_base64_encode ((guchar*) details_fname, strlen (details_fname));
19479 
19480  if (openvas_connection_sendf (connection,
19481  "<modify_setting"
19482  " setting_id"
19483  "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">"
19484  "<value>%s</value>"
19485  "</modify_setting>",
19486  fname_64 ? fname_64 : "")
19487  == -1)
19488  {
19489  g_free (fname_64);
19490  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19491  return gsad_message (credentials,
19492  "Internal error", __FUNCTION__, __LINE__,
19493  "An internal error occurred while saving settings. "
19494  "It is unclear whether all the settings were saved. "
19495  "Diagnostics: Failure to send command to manager daemon.",
19496  "/omp?cmd=get_my_settings", response_data);
19497  }
19498  g_free (fname_64);
19499 
19500  entity = NULL;
19501  xml_string_append (xml,
19502  "<save_setting id=\"%s\">",
19503  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
19504  if (read_entity_and_string_c (connection, &entity, &xml))
19505  {
19506  g_string_free (xml, TRUE);
19507  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19508  return gsad_message (credentials,
19509  "Internal error", __FUNCTION__, __LINE__,
19510  "An internal error occurred while saving settings. "
19511  "It is unclear whether all the settings were saved. "
19512  "Diagnostics: Failure to receive response from manager daemon.",
19513  "/omp?cmd=get_my_settings", response_data);
19514  }
19515  xml_string_append (xml, "</save_setting>");
19516  if (omp_success (entity) != 1)
19517  {
19518  set_http_status_from_entity (entity, response_data);
19519  modify_failed = 1;
19520  }
19521  }
19522 
19523  /* Send resource list export file name format. */
19524  changed_value = params_value (changed, "list_fname");
19525  if (changed_value == NULL
19526  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19527  {
19528  fname_64 = g_base64_encode ((guchar*) list_fname, strlen (list_fname));
19529 
19530  if (openvas_connection_sendf (connection,
19531  "<modify_setting"
19532  " setting_id"
19533  "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">"
19534  "<value>%s</value>"
19535  "</modify_setting>",
19536  fname_64 ? fname_64 : "")
19537  == -1)
19538  {
19539  g_free (fname_64);
19540  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19541  return gsad_message (credentials,
19542  "Internal error", __FUNCTION__, __LINE__,
19543  "An internal error occurred while saving settings. "
19544  "It is unclear whether all the settings were saved. "
19545  "Diagnostics: Failure to send command to manager daemon.",
19546  "/omp?cmd=get_my_settings", response_data);
19547  }
19548  g_free (fname_64);
19549 
19550  entity = NULL;
19551  xml_string_append (xml,
19552  "<save_setting id=\"%s\">",
19553  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
19554  if (read_entity_and_string_c (connection, &entity, &xml))
19555  {
19556  g_string_free (xml, TRUE);
19557  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19558  return gsad_message (credentials,
19559  "Internal error", __FUNCTION__, __LINE__,
19560  "An internal error occurred while saving settings. "
19561  "It is unclear whether all the settings were saved. "
19562  "Diagnostics: Failure to receive response from manager daemon.",
19563  "/omp?cmd=get_my_settings", response_data);
19564  }
19565  xml_string_append (xml, "</save_setting>");
19566  if (omp_success (entity) != 1)
19567  {
19568  set_http_status_from_entity (entity, response_data);
19569  modify_failed = 1;
19570  }
19571  }
19572 
19573  /* Send report export file name format. */
19574  changed_value = params_value (changed, "report_fname");
19575  if (changed_value == NULL
19576  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19577  {
19578  fname_64 = g_base64_encode ((guchar*) report_fname, strlen (report_fname));
19579 
19580  if (openvas_connection_sendf (connection,
19581  "<modify_setting"
19582  " setting_id"
19583  "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">"
19584  "<value>%s</value>"
19585  "</modify_setting>",
19586  fname_64 ? fname_64 : "")
19587  == -1)
19588  {
19589  g_free (fname_64);
19590  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19591  return gsad_message (credentials,
19592  "Internal error", __FUNCTION__, __LINE__,
19593  "An internal error occurred while saving settings. "
19594  "It is unclear whether all the settings were saved. "
19595  "Diagnostics: Failure to send command to manager daemon.",
19596  "/omp?cmd=get_my_settings", response_data);
19597  }
19598  g_free (fname_64);
19599 
19600  entity = NULL;
19601  xml_string_append (xml,
19602  "<save_setting id=\"%s\">",
19603  "e1a2ae0b-736e-4484-b029-330c9e15b900");
19604  if (read_entity_and_string_c (connection, &entity, &xml))
19605  {
19606  g_string_free (xml, TRUE);
19607  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19608  return gsad_message (credentials,
19609  "Internal error", __FUNCTION__, __LINE__,
19610  "An internal error occurred while saving settings. "
19611  "It is unclear whether all the settings were saved. "
19612  "Diagnostics: Failure to receive response from manager daemon.",
19613  "/omp?cmd=get_my_settings", response_data);
19614  }
19615  xml_string_append (xml, "</save_setting>");
19616  if (omp_success (entity) != 1)
19617  {
19618  set_http_status_from_entity (entity, response_data);
19619  modify_failed = 1;
19620  }
19621  }
19622 
19623  /* Send User Interface Language. */
19624  changed_value = params_value (changed, "lang");
19625  if (changed_value == NULL
19626  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19627  {
19628  lang_64 = g_base64_encode ((guchar*) lang, strlen (lang));
19629 
19630  if (openvas_connection_sendf (connection,
19631  "<modify_setting"
19632  " setting_id"
19633  "=\"6765549a-934e-11e3-b358-406186ea4fc5\">"
19634  "<value>%s</value>"
19635  "</modify_setting>",
19636  lang_64 ? lang_64 : "")
19637  == -1)
19638  {
19639  g_free (lang_64);
19640  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19641  return gsad_message (credentials,
19642  "Internal error", __FUNCTION__, __LINE__,
19643  "An internal error occurred while saving settings. "
19644  "It is unclear whether all the settings were saved. "
19645  "Diagnostics: Failure to send command to manager daemon.",
19646  "/omp?cmd=get_my_settings", response_data);
19647  }
19648  g_free (lang_64);
19649 
19650  entity = NULL;
19651  xml_string_append (xml,
19652  "<save_setting id=\"%s\">",
19653  "6765549a-934e-11e3-b358-406186ea4fc5");
19654  if (read_entity_and_string_c (connection, &entity, &xml))
19655  {
19656  g_string_free (xml, TRUE);
19657  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19658  return gsad_message (credentials,
19659  "Internal error", __FUNCTION__, __LINE__,
19660  "An internal error occurred while saving settings. "
19661  "It is unclear whether all the settings were saved. "
19662  "Diagnostics: Failure to receive response from manager daemon.",
19663  "/omp?cmd=get_my_settings", response_data);
19664  }
19665  xml_string_append (xml, "</save_setting>");
19666  if (omp_success (entity))
19667  {
19668  gchar *language_code;
19669  set_language_code (&language_code, lang);
19670  if (language_code)
19671  {
19672  g_free (credentials->language);
19673  credentials->language = language_code;
19674  *language = g_strdup (lang);
19675  }
19676  else
19677  {
19678  g_free (credentials->language);
19679  credentials->language = accept_language_to_env_fmt (accept_language);
19680  *language = NULL;
19681  }
19682  }
19683  else
19684  {
19685  set_http_status_from_entity (entity, response_data);
19686  modify_failed = 1;
19687  }
19688  }
19689 
19690  /* Send default resources */
19691 
19692  defaults = params_values (params, "settings_default:");
19693  if (send_settings_filters (connection, defaults, changed, xml,
19694  &modify_failed, response_data))
19695  {
19696  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19697  return gsad_message (credentials,
19698  "Internal error", __FUNCTION__, __LINE__,
19699  "An internal error occurred while saving settings. "
19700  "It is unclear whether all the settings were saved. "
19701  "Diagnostics: Failure to send command to manager daemon.",
19702  "/omp?cmd=get_my_settings", response_data);
19703  }
19704 
19705  /* Send resources filters */
19706 
19707  filters = params_values (params, "settings_filter:");
19708  if (send_settings_filters (connection, filters, changed, xml, &modify_failed,
19709  response_data))
19710  {
19711  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19712  return gsad_message (credentials,
19713  "Internal error", __FUNCTION__, __LINE__,
19714  "An internal error occurred while saving settings. "
19715  "It is unclear whether all the settings were saved. "
19716  "Diagnostics: Failure to send command to manager daemon.",
19717  "/omp?cmd=get_my_settings", response_data);
19718  }
19719 
19720  /* Send Severity Class. */
19721 
19722  changed_value = params_value (changed, "severity_class");
19723  if (changed_value == NULL
19724  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19725  {
19726  text = params_value (params, "severity_class");
19727  text_64 = (text
19728  ? g_base64_encode ((guchar*) text, strlen (text))
19729  : g_strdup (""));
19730 
19731  if (openvas_connection_sendf (connection,
19732  "<modify_setting"
19733  " setting_id"
19734  "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">"
19735  "<value>%s</value>"
19736  "</modify_setting>",
19737  text_64 ? text_64 : "")
19738  == -1)
19739  {
19740  g_free (text_64);
19741  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19742  return gsad_message (credentials,
19743  "Internal error", __FUNCTION__, __LINE__,
19744  "An internal error occurred while saving settings. "
19745  "It is unclear whether all the settings were saved. "
19746  "Diagnostics: Failure to send command to manager daemon.",
19747  "/omp?cmd=get_my_settings", response_data);
19748  }
19749  g_free (text_64);
19750 
19751  entity = NULL;
19752  xml_string_append (xml,
19753  "<save_setting id=\"%s\">",
19754  "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
19755  if (read_entity_and_string_c (connection, &entity, &xml))
19756  {
19757  g_string_free (xml, TRUE);
19758  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19759  return gsad_message (credentials,
19760  "Internal error", __FUNCTION__, __LINE__,
19761  "An internal error occurred while saving settings. "
19762  "It is unclear whether all the settings were saved. "
19763  "Diagnostics: Failure to receive response from manager daemon.",
19764  "/omp?cmd=get_my_settings", response_data);
19765  }
19766  xml_string_append (xml, "</save_setting>");
19767 
19768  status = entity_attribute (entity, "status");
19769  if (status && (strlen (status) > 0) && (status[0] == '2'))
19770  {
19771  g_free (credentials->severity);
19772  if ((text != NULL) && (strlen (text) > 0))
19773  {
19774  credentials->severity = g_strdup (text);
19775  *severity = g_strdup (text);
19776  }
19777  }
19778  else
19779  {
19780  set_http_status_from_entity (entity, response_data);
19781  modify_failed = 1;
19782  }
19783  }
19784 
19785  /* Send Dynamic Severity setting. */
19786 
19787  changed_value = params_value (changed, "dynamic_severity");
19788  if (changed_value == NULL
19789  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19790  {
19791  text = params_value (params, "dynamic_severity");
19792  text_64 = (text
19793  ? g_base64_encode ((guchar*) text, strlen (text))
19794  : g_strdup (""));
19795 
19796  if (openvas_connection_sendf (connection,
19797  "<modify_setting"
19798  " setting_id"
19799  "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">"
19800  "<value>%s</value>"
19801  "</modify_setting>",
19802  text_64 ? text_64 : "")
19803  == -1)
19804  {
19805  g_free (text_64);
19806  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19807  return gsad_message (credentials,
19808  "Internal error", __FUNCTION__, __LINE__,
19809  "An internal error occurred while saving settings. "
19810  "It is unclear whether all the settings were saved. "
19811  "Diagnostics: Failure to send command to manager daemon.",
19812  "/omp?cmd=get_my_settings", response_data);
19813  }
19814  g_free (text_64);
19815 
19816  entity = NULL;
19817  xml_string_append (xml,
19818  "<save_setting id=\"%s\">",
19819  "77ec2444-e7f2-4a80-a59b-f4237782d93f");
19820  if (read_entity_and_string_c (connection, &entity, &xml))
19821  {
19822  g_string_free (xml, TRUE);
19823  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19824  return gsad_message (credentials,
19825  "Internal error", __FUNCTION__, __LINE__,
19826  "An internal error occurred while saving settings. "
19827  "It is unclear whether all the settings were saved. "
19828  "Diagnostics: Failure to receive response from manager daemon.",
19829  "/omp?cmd=get_my_settings", response_data);
19830  }
19831  xml_string_append (xml, "</save_setting>");
19832  if (! omp_success (entity))
19833  {
19834  set_http_status_from_entity (entity, response_data);
19835  modify_failed = 1;
19836  }
19837  }
19838 
19839  /* Send Default Severity setting. */
19840  changed_value = params_value (changed, "default_severity");
19841  if (changed_value == NULL
19842  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19843  {
19844  text = params_value (params, "default_severity");
19845  text_64 = (text
19846  ? g_base64_encode ((guchar*) text, strlen (text))
19847  : g_strdup (""));
19848 
19849  if (openvas_connection_sendf (connection,
19850  "<modify_setting"
19851  " setting_id"
19852  "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">"
19853  "<value>%s</value>"
19854  "</modify_setting>",
19855  text_64 ? text_64 : "")
19856  == -1)
19857  {
19858  g_free (text_64);
19859  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19860  return gsad_message (credentials,
19861  "Internal error", __FUNCTION__, __LINE__,
19862  "An internal error occurred while saving settings. "
19863  "It is unclear whether all the settings were saved. "
19864  "Diagnostics: Failure to send command to manager daemon.",
19865  "/omp?cmd=get_my_settings", response_data);
19866  }
19867  g_free (text_64);
19868 
19869  entity = NULL;
19870  xml_string_append (xml,
19871  "<save_setting id=\"%s\">",
19872  "7eda49c5-096c-4bef-b1ab-d080d87300df");
19873  if (read_entity_and_string_c (connection, &entity, &xml))
19874  {
19875  g_string_free (xml, TRUE);
19876  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19877  return gsad_message (credentials,
19878  "Internal error", __FUNCTION__, __LINE__,
19879  "An internal error occurred while saving settings. "
19880  "It is unclear whether all the settings were saved. "
19881  "Diagnostics: Failure to receive response from manager daemon.",
19882  "/omp?cmd=get_my_settings", response_data);
19883  }
19884  xml_string_append (xml, "</save_setting>");
19885  if (! omp_success (entity))
19886  {
19887  set_http_status_from_entity (entity, response_data);
19888  modify_failed = 1;
19889  }
19890  }
19891 
19892  /* Send Auto Cache Rebuild setting. */
19893 
19894  changed_value = params_value (changed, "auto_cache_rebuild");
19895  if (changed_value == NULL
19896  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19897  {
19898  text = params_value (params, "auto_cache_rebuild");
19899  text_64 = (text
19900  ? g_base64_encode ((guchar*) text, strlen (text))
19901  : g_strdup (""));
19902 
19903  if (openvas_connection_sendf (connection,
19904  "<modify_setting"
19905  " setting_id"
19906  "=\"a09285b0-2d47-49b6-a4ef-946ee71f1d5c\">"
19907  "<value>%s</value>"
19908  "</modify_setting>",
19909  text_64 ? text_64 : "")
19910  == -1)
19911  {
19912  g_free (text_64);
19913  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19914  return gsad_message (credentials,
19915  "Internal error", __FUNCTION__, __LINE__,
19916  "An internal error occurred while saving settings. "
19917  "It is unclear whether all the settings were saved. "
19918  "Diagnostics: Failure to send command to manager daemon.",
19919  "/omp?cmd=get_my_settings", response_data);
19920  }
19921  g_free (text_64);
19922 
19923  entity = NULL;
19924  xml_string_append (xml,
19925  "<save_setting id=\"%s\">",
19926  "a09285b0-2d47-49b6-a4ef-946ee71f1d5c");
19927  if (read_entity_and_string_c (connection, &entity, &xml))
19928  {
19929  g_string_free (xml, TRUE);
19930  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19931  return gsad_message (credentials,
19932  "Internal error", __FUNCTION__, __LINE__,
19933  "An internal error occurred while saving settings. "
19934  "It is unclear whether all the settings were saved. "
19935  "Diagnostics: Failure to receive response from manager daemon.",
19936  "/omp?cmd=get_my_settings", response_data);
19937  }
19938  xml_string_append (xml, "</save_setting>");
19939  if (! omp_success (entity))
19940  {
19941  set_http_status_from_entity (entity, response_data);
19942  modify_failed = 1;
19943  }
19944  }
19945 
19946  if (modify_failed)
19947  return edit_my_settings (connection, credentials, params,
19948  g_string_free (xml, FALSE), response_data);
19949  else
19950  return get_my_settings (connection, credentials, params,
19951  g_string_free (xml, FALSE), response_data);
19952 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
char * timezone
User&#39;s timezone.
Definition: gsad_base.h:72
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
void set_language_code(gchar **lang, const gchar *language)
Set language code of user.
Definition: gsad_base.c:218
gchar * accept_language_to_env_fmt(const char *accept_language)
Convert an Accept-Language string to the LANGUAGE env variable form.
Definition: xslt_i18n.c:769
char * username
Name of user.
Definition: gsad_base.h:69
#define params_t
Definition: gsad_base.h:61
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
char * severity
Severity class.
Definition: gsad_base.h:78
char * language
Accept-Language browser header.
Definition: gsad_base.h:77
char * password
User&#39;s password.
Definition: gsad_base.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

char* save_note_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save note, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 15744 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_original_value(), params_t, params_valid(), and params_value().

15746 {
15747  gchar *response;
15748  entity_t entity;
15749  const char *no_redirect;
15750  const char *note_id, *text, *hosts, *port, *severity, *note_task_id;
15751  const char *note_result_id, *active, *days;
15752  char *ret;
15753 
15754  no_redirect = params_value (params, "no_redirect");
15755  note_id = params_value (params, "note_id");
15756 
15757  text = params_value (params, "text");
15758  if (text == NULL)
15759  params_given (params, "text") || (text = "");
15760 
15761  if (params_valid (params, "hosts"))
15762  hosts = params_value (params, "hosts");
15763  else if (strcmp (params_original_value (params, "hosts"), ""))
15764  hosts = NULL;
15765  else
15766  hosts = "";
15767 
15768  if (params_valid (params, "port"))
15769  port = params_value (params, "port");
15770  else if (strcmp (params_original_value (params, "port"), ""))
15771  port = NULL;
15772  else
15773  port = "";
15774 
15775  if (params_valid (params, "severity"))
15776  severity = params_value (params, "severity");
15777  else if (strcmp (params_original_value (params, "severity"), ""))
15778  severity = NULL;
15779  else
15780  severity = "";
15781 
15782  note_task_id = params_value (params, "note_task_id");
15783  note_result_id = params_value (params, "note_result_id");
15784 
15785  active = params_value (params, "active");
15786  days = params_value (params, "days");
15787 
15788  CHECK_PARAM_INVALID (note_task_id, "Save Note", "edit_note");
15789  CHECK_PARAM_INVALID (note_result_id, "Save Note", "edit_note");
15790  CHECK_PARAM_INVALID (active, "Save Note", "edit_note");
15791  CHECK_PARAM_INVALID (note_id, "Save Note", "edit_note");
15792  CHECK_PARAM_INVALID (text, "Save Note", "edit_note");
15793  CHECK_PARAM_INVALID (hosts, "Save Note", "edit_note");
15794  CHECK_PARAM_INVALID (port, "Save Note", "edit_note");
15795  CHECK_PARAM_INVALID (severity, "Save Note", "edit_note");
15796  CHECK_PARAM_INVALID (days, "Save Note", "edit_note");
15797 
15798  response = NULL;
15799  entity = NULL;
15800  switch (ompf (connection, credentials,
15801  &response,
15802  &entity,
15803  response_data,
15804  "<modify_note note_id=\"%s\">"
15805  "<active>%s</active>"
15806  "<hosts>%s</hosts>"
15807  "<port>%s</port>"
15808  "<severity>%s</severity>"
15809  "<text>%s</text>"
15810  "<task id=\"%s\"/>"
15811  "<result id=\"%s\"/>"
15812  "</modify_note>",
15813  note_id,
15814  strcmp (active, "1")
15815  ? active
15816  : (days ? days : "-1"),
15817  hosts ? hosts : "",
15818  port ? port : "",
15819  severity ? severity : "",
15820  text ? text : "",
15821  note_task_id,
15822  note_result_id))
15823  {
15824  case 0:
15825  case -1:
15826  break;
15827  case 1:
15828  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15829  return gsad_message (credentials,
15830  "Internal error", __FUNCTION__, __LINE__,
15831  "An internal error occurred while saving a note. "
15832  "The note remains the same. "
15833  "Diagnostics: Failure to send command to manager daemon.",
15834  "/omp?cmd=get_notes", response_data);
15835  case 2:
15836  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15837  return gsad_message (credentials,
15838  "Internal error", __FUNCTION__, __LINE__,
15839  "An internal error occurred while saving a note. "
15840  "It is unclear whether the note has been saved or not. "
15841  "Diagnostics: Failure to receive response from manager daemon.",
15842  "/omp?cmd=get_notes", response_data);
15843  default:
15844  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
15845  return gsad_message (credentials,
15846  "Internal error", __FUNCTION__, __LINE__,
15847  "An internal error occurred while saving a note. "
15848  "It is unclear whether the note has been saved or not. "
15849  "Diagnostics: Internal Error.",
15850  "/omp?cmd=get_notes", response_data);
15851  }
15852 
15853  ret = response_from_entity (connection, credentials, params, entity,
15854  (no_redirect && strcmp (no_redirect, "0")),
15855  NULL, "get_notes",
15856  NULL, "edit_note",
15857  "Save Note", response_data);
15858 
15859  free_entity (entity);
15860  g_free (response);
15861  return ret;
15862 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:745
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_override_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save override, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 16457 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_original_value(), params_t, params_valid(), and params_value().

16460 {
16461  gchar *response;
16462  entity_t entity;
16463  const char *no_redirect, *override_id, *text, *hosts, *port;
16464  const char *severity, *custom_severity, *new_severity;
16465  const char *override_task_id, *override_result_id, *active, *days;
16466  char *ret;
16467 
16468  no_redirect = params_value (params, "no_redirect");
16469  override_id = params_value (params, "override_id");
16470 
16471  text = params_value (params, "text");
16472  if (text == NULL)
16473  params_given (params, "text") || (text = "");
16474 
16475  if (params_valid (params, "hosts"))
16476  hosts = params_value (params, "hosts");
16477  else if (strcmp (params_original_value (params, "hosts"), ""))
16478  hosts = NULL;
16479  else
16480  hosts = "";
16481 
16482  if (params_valid (params, "port"))
16483  port = params_value (params, "port");
16484  else if (strcmp (params_original_value (params, "port"), ""))
16485  port = NULL;
16486  else
16487  port = "";
16488 
16489  if (params_valid (params, "severity"))
16490  severity = params_value (params, "severity");
16491  else if (strcmp (params_original_value (params, "severity"), ""))
16492  severity = NULL;
16493  else
16494  severity = "";
16495 
16496  custom_severity = params_value (params, "custom_severity");
16497  if (custom_severity && strcmp (custom_severity, "0") != 0)
16498  new_severity = params_value (params, "new_severity");
16499  else
16500  new_severity = params_value (params, "new_severity_from_list");
16501 
16502  override_task_id = params_value (params, "override_task_id");
16503  override_result_id = params_value (params, "override_result_id");
16504 
16505  active = params_value (params, "active");
16506  days = params_value (params, "days");
16507 
16508  CHECK_PARAM_INVALID (override_task_id, "Save Override", "edit_override");
16509  CHECK_PARAM_INVALID (override_result_id, "Save Override", "edit_override");
16510  CHECK_PARAM_INVALID (active, "Save Override", "edit_override");
16511  CHECK_PARAM_INVALID (override_id, "Save Override", "edit_override");
16512  CHECK_PARAM_INVALID (text, "Save Override", "edit_override");
16513  CHECK_PARAM_INVALID (hosts, "Save Override", "edit_override");
16514  CHECK_PARAM_INVALID (port, "Save Override", "edit_override");
16515  CHECK_PARAM_INVALID (severity, "Save Override", "edit_override");
16516  CHECK_PARAM_INVALID (new_severity, "Save Override", "edit_override");
16517  CHECK_PARAM_INVALID (days, "Save Override", "edit_override");
16518 
16519  response = NULL;
16520  entity = NULL;
16521  switch (ompf (connection, credentials,
16522  &response,
16523  &entity,
16524  response_data,
16525  "<modify_override override_id=\"%s\">"
16526  "<active>%s</active>"
16527  "<hosts>%s</hosts>"
16528  "<port>%s</port>"
16529  "<severity>%s</severity>"
16530  "<new_severity>%s</new_severity>"
16531  "<text>%s</text>"
16532  "<task id=\"%s\"/>"
16533  "<result id=\"%s\"/>"
16534  "</modify_override>",
16535  override_id,
16536  strcmp (active, "1")
16537  ? active
16538  : (days ? days : "-1"),
16539  hosts ? hosts : "",
16540  port ? port : "",
16541  severity ? severity : "",
16542  new_severity,
16543  text ? text : "",
16544  override_task_id,
16545  override_result_id))
16546  {
16547  case 0:
16548  case -1:
16549  break;
16550  case 1:
16551  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16552  return gsad_message (credentials,
16553  "Internal error", __FUNCTION__, __LINE__,
16554  "An internal error occurred while saving a override. "
16555  "The override remains the same. "
16556  "Diagnostics: Failure to send command to manager daemon.",
16557  "/omp?cmd=get_overrides", response_data);
16558  case 2:
16559  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16560  return gsad_message (credentials,
16561  "Internal error", __FUNCTION__, __LINE__,
16562  "An internal error occurred while saving a override. "
16563  "It is unclear whether the override has been saved or not. "
16564  "Diagnostics: Failure to receive response from manager daemon.",
16565  "/omp?cmd=get_overrides", response_data);
16566  default:
16567  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16568  return gsad_message (credentials,
16569  "Internal error", __FUNCTION__, __LINE__,
16570  "An internal error occurred while saving a override. "
16571  "It is unclear whether the override has been saved or not. "
16572  "Diagnostics: Internal Error.",
16573  "/omp?cmd=get_overrides", response_data);
16574  }
16575 
16576  ret = response_from_entity (connection, credentials, params, entity,
16577  (no_redirect && strcmp (no_redirect, "0")),
16578  NULL, "get_overrides",
16579  NULL, "edit_override",
16580  "Save Override", response_data);
16581 
16582  free_entity (entity);
16583  g_free (response);
16584  return ret;
16585 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:745
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_permission_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a permission, get all permissions, XSL transform 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
Result of XSL transformation.

Definition at line 22258 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_t, and params_value().

22261 {
22262  gchar *html, *response;
22263  const char *no_redirect;
22264  const char *permission_id, *name, *comment, *resource_id, *resource_type;
22265  const char *subject_id, *subject_type;
22266  entity_t entity;
22267  int ret;
22268 
22269  no_redirect = params_value (params, "no_redirect");
22270  permission_id = params_value (params, "permission_id");
22271  name = params_value (params, "permission");
22272  comment = params_value (params, "comment");
22273  subject_type = params_value (params, "subject_type");
22274  resource_id = params_value (params, "id_or_empty");
22275  resource_type = params_value (params, "optional_resource_type");
22276 
22277  CHECK_PARAM_INVALID (permission_id, "Save Permission", "edit_permission");
22278  CHECK_PARAM_INVALID (name, "Save Permission", "edit_permission");
22279  CHECK_PARAM_INVALID (comment, "Save Permission", "edit_permission");
22280  if (params_given (params, "id_or_empty"))
22281  CHECK_PARAM_INVALID (resource_id, "Save Permission", "edit_permission");
22282  CHECK_PARAM_INVALID (subject_type, "Save Permission", "edit_permission");
22283  if (params_given (params, "optional_resource_type"))
22284  CHECK_PARAM_INVALID (resource_type, "Save Permission", "edit_permission");
22285 
22286  if (strcmp (subject_type, "user") == 0)
22287  subject_id = params_value (params, "user_id");
22288  else if (strcmp (subject_type, "group") == 0)
22289  subject_id = params_value (params, "group_id");
22290  else if (strcmp (subject_type, "role") == 0)
22291  subject_id = params_value (params, "role_id");
22292  else
22293  subject_id = NULL;
22294  CHECK_PARAM_INVALID (subject_id, "Save Permission", "edit_permission");
22295 
22296  /* Modify the permission. */
22297 
22298  response = NULL;
22299  entity = NULL;
22300  ret = ompf (connection, credentials,
22301  &response,
22302  &entity,
22303  response_data,
22304  "<modify_permission permission_id=\"%s\">"
22305  "<name>%s</name>"
22306  "<comment>%s</comment>"
22307  "<subject id=\"%s\">"
22308  "<type>%s</type>"
22309  "</subject>"
22310  "<resource id=\"%s\">"
22311  "<type>%s</type>"
22312  "</resource>"
22313  "</modify_permission>",
22314  permission_id,
22315  name,
22316  comment,
22317  subject_id,
22318  subject_type,
22319  (resource_id && strlen (resource_id)) ? resource_id : "0",
22320  resource_type ? resource_type : "");
22321  switch (ret)
22322  {
22323  case 0:
22324  case -1:
22325  break;
22326  case 1:
22327  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22328  return gsad_message (credentials,
22329  "Internal error", __FUNCTION__, __LINE__,
22330  "An internal error occurred while modifying a permission. "
22331  "The permission was not modified. "
22332  "Diagnostics: Failure to send command to manager daemon.",
22333  "/omp?cmd=get_permissions", response_data);
22334  case 2:
22335  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22336  return gsad_message (credentials,
22337  "Internal error", __FUNCTION__, __LINE__,
22338  "An internal error occurred while modifying a permission. "
22339  "It is unclear whether the permission has been modified or not. "
22340  "Diagnostics: Failure to receive response from manager daemon.",
22341  "/omp?cmd=get_permissions", response_data);
22342  default:
22343  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22344  return gsad_message (credentials,
22345  "Internal error", __FUNCTION__, __LINE__,
22346  "An internal error occurred while modifying a permission. "
22347  "It is unclear whether the permission has been modified or not. "
22348  "Diagnostics: Internal Error.",
22349  "/omp?cmd=get_permissions", response_data);
22350  }
22351 
22352  html = response_from_entity (connection, credentials, params, entity,
22353  (no_redirect && strcmp (no_redirect, "0")),
22354  NULL, "get_permissions",
22355  NULL, "edit_permission",
22356  "Save Permission", response_data);
22357  free_entity (entity);
22358  g_free (response);
22359  return html;
22360 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a port list, get all port list, XSL transform 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
Result of XSL transformation.

Definition at line 22800 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

22803 {
22804  int ret;
22805  gchar *html, *response;
22806  const char *no_redirect, *port_list_id, *name, *comment;
22807  entity_t entity;
22808 
22809  no_redirect = params_value (params, "no_redirect");
22810  port_list_id = params_value (params, "port_list_id");
22811  name = params_value (params, "name");
22812  comment = params_value (params, "comment");
22813 
22814  CHECK_PARAM_INVALID (port_list_id, "Save Port List", "edit_port_list");
22815  CHECK_PARAM_INVALID (name, "Save Port List", "edit_port_list");
22816  CHECK_PARAM_INVALID (comment, "Save Port List", "edit_port_list");
22817 
22818  /* Modify the Port List. */
22819 
22820  response = NULL;
22821  entity = NULL;
22822  ret = ompf (connection, credentials,
22823  &response,
22824  &entity,
22825  response_data,
22826  "<modify_port_list port_list_id=\"%s\">"
22827  "<name>%s</name>"
22828  "<comment>%s</comment>"
22829  "</modify_port_list>",
22830  port_list_id,
22831  name,
22832  comment);
22833 
22834  switch (ret)
22835  {
22836  case 0:
22837  case -1:
22838  break;
22839  case 1:
22840  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22841  return gsad_message (credentials,
22842  "Internal error", __FUNCTION__, __LINE__,
22843  "An internal error occurred while saving a Port List. "
22844  "The Port List was not saved. "
22845  "Diagnostics: Failure to send command to manager daemon.",
22846  "/omp?cmd=get_port_lists", response_data);
22847  case 2:
22848  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22849  return gsad_message (credentials,
22850  "Internal error", __FUNCTION__, __LINE__,
22851  "An internal error occurred while saving a Port List. "
22852  "It is unclear whether the Port List has been saved or not. "
22853  "Diagnostics: Failure to receive response from manager daemon.",
22854  "/omp?cmd=get_port_lists", response_data);
22855  default:
22856  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22857  return gsad_message (credentials,
22858  "Internal error", __FUNCTION__, __LINE__,
22859  "An internal error occurred while saving a Port List. "
22860  "It is unclear whether the Port List has been saved or not. "
22861  "Diagnostics: Internal Error.",
22862  "/omp?cmd=get_port_lists", response_data);
22863  }
22864 
22865  html = response_from_entity (connection, credentials, params, entity,
22866  (no_redirect && strcmp (no_redirect, "0")),
22867  NULL, "get_port_lists",
22868  NULL, "edit_port_list",
22869  "Save Port List", response_data);
22870  free_entity (entity);
22871  g_free (response);
22872  return html;
22873 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save report_format, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 18232 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::value, and param::value_size.

18235 {
18236  int ret;
18237  gchar *html, *response;
18238  params_t *preferences, *id_list_params, *include_id_lists;
18239  const char *no_redirect, *report_format_id, *name, *summary, *enable;
18240  entity_t entity;
18241 
18242  no_redirect = params_value (params, "no_redirect");
18243  report_format_id = params_value (params, "report_format_id");
18244  name = params_value (params, "name");
18245  summary = params_value (params, "summary");
18246  enable = params_value (params, "enable");
18247 
18248  CHECK_PARAM_INVALID (report_format_id, "Save Report Format",
18249  "edit_report_format");
18250  CHECK_PARAM_INVALID (name, "Save Report Format", "edit_report_format");
18251  CHECK_PARAM_INVALID (summary, "Save Report Format", "edit_report_format");
18252  CHECK_PARAM_INVALID (enable, "Save Report Format", "edit_report_format");
18253 
18254  id_list_params = params_values (params, "id_list:");
18255  include_id_lists = params_values (params, "include_id_list:");
18256  if (include_id_lists)
18257  {
18258  GHashTable *id_lists;
18259  param_t *param;
18260  gchar *param_name, *pref_name, *value, *old_values, *new_values;
18261  params_iterator_t iter;
18262  GHashTableIter hash_table_iter;
18263 
18264  id_lists = g_hash_table_new_full (g_str_hash, g_str_equal,
18265  g_free, g_free);
18266 
18267  params_iterator_init (&iter, include_id_lists);
18268  while (params_iterator_next (&iter, &param_name, &param))
18269  {
18270  if (param->value == NULL)
18271  continue;
18272 
18273  g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (""));
18274  }
18275 
18276  params_iterator_init (&iter, id_list_params);
18277  while (params_iterator_next (&iter, &param_name, &param))
18278  {
18279  if (param->value == NULL)
18280  continue;
18281 
18282  gchar *colon_pos = strchr (param->value, ':');
18283 
18284  pref_name = g_strndup (param->value, colon_pos - param->value);
18285  value = g_strdup (colon_pos + 1);
18286 
18287  old_values = g_hash_table_lookup (id_lists, pref_name);
18288 
18289  if (old_values && strcmp (old_values, ""))
18290  {
18291  new_values = g_strdup_printf ("%s,%s", old_values, value);
18292  g_hash_table_insert (id_lists, pref_name, new_values);
18293  g_free (value);
18294  }
18295  else if (old_values)
18296  {
18297  g_hash_table_insert (id_lists, pref_name, value);
18298  }
18299  }
18300 
18301  g_hash_table_iter_init (&hash_table_iter, id_lists);
18302  while (g_hash_table_iter_next (&hash_table_iter,
18303  (void**)&pref_name, (void**)&value))
18304  {
18305  gchar *value_64;
18306 
18307  value_64 = strlen (value)
18308  ? g_base64_encode ((guchar *) value, strlen (value))
18309  : g_strdup ("");
18310 
18311  response = NULL;
18312  entity = NULL;
18313  ret = ompf (connection, credentials,
18314  &response,
18315  &entity,
18316  response_data,
18317  "<modify_report_format"
18318  " report_format_id=\"%s\">"
18319  "<param>"
18320  "<name>%s</name>"
18321  "<value>%s</value>"
18322  "</param>"
18323  "</modify_report_format>",
18324  report_format_id,
18325  pref_name,
18326  value_64);
18327  g_free (value_64);
18328  switch (ret)
18329  {
18330  case 0:
18331  break;
18332  case 1:
18333  response_data->http_status_code
18334  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18335  return gsad_message (credentials,
18336  "Internal error", __FUNCTION__, __LINE__,
18337  "An internal error occurred while saving a Report Format. "
18338  "The Report Format was not saved. "
18339  "Diagnostics: Failure to send command to manager daemon.",
18340  "/omp?cmd=get_report_formats",
18341  response_data);
18342  case 2:
18343  response_data->http_status_code
18344  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18345  return gsad_message (credentials,
18346  "Internal error", __FUNCTION__, __LINE__,
18347  "An internal error occurred while saving a Report Format. "
18348  "It is unclear whether the Report Format has been saved or not. "
18349  "Diagnostics: Failure to receive response from manager daemon.",
18350  "/omp?cmd=get_report_formats",
18351  response_data);
18352  case -1:
18353  default:
18354  response_data->http_status_code
18355  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18356  return gsad_message (credentials,
18357  "Internal error", __FUNCTION__, __LINE__,
18358  "An internal error occurred while saving a Report Format. "
18359  "It is unclear whether the Report Format has been saved or not. "
18360  "Diagnostics: Internal Error.",
18361  "/omp?cmd=get_report_formats",
18362  response_data);
18363  }
18364 
18365  /* TODO Check if succeeded. response_from_entity_if_failed? */
18366  }
18367  }
18368 
18369  /* Modify the Report Format. */
18370 
18371  preferences = params_values (params, "preference:");
18372  if (preferences)
18373  {
18374  param_t *param;
18375  gchar *param_name;
18376  params_iterator_t iter;
18377 
18378  /* The naming is a bit subtle here, because the HTTP request
18379  * parameters are called "param"s and so are the OMP report format
18380  * parameters. */
18381 
18382  params_iterator_init (&iter, preferences);
18383  while (params_iterator_next (&iter, &param_name, &param))
18384  {
18385  int type_start, type_end, count;
18386  /* LDAPsearch[entry]:Timeout value */
18387  count = sscanf (param_name,
18388  "%*[^[][%n%*[^]]%n]:",
18389  &type_start,
18390  &type_end);
18391  if (count == 0 && type_start > 0 && type_end > 0)
18392  {
18393  gchar *value;
18394 
18395  value = param->value_size
18396  ? g_base64_encode ((guchar *) param->value,
18397  param->value_size)
18398  : g_strdup ("");
18399 
18400  response = NULL;
18401  entity = NULL;
18402  ret = ompf (connection, credentials,
18403  &response,
18404  &entity,
18405  response_data,
18406  "<modify_report_format"
18407  " report_format_id=\"%s\">"
18408  "<param>"
18409  "<name>%s</name>"
18410  "<value>%s</value>"
18411  "</param>"
18412  "</modify_report_format>",
18413  report_format_id,
18414  param_name + type_end + 2,
18415  value);
18416  g_free (value);
18417  switch (ret)
18418  {
18419  case 0:
18420  break;
18421  case 1:
18422  response_data->http_status_code
18423  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18424  return gsad_message (credentials,
18425  "Internal error", __FUNCTION__, __LINE__,
18426  "An internal error occurred while saving a Report Format. "
18427  "The Report Format was not saved. "
18428  "Diagnostics: Failure to send command to manager daemon.",
18429  "/omp?cmd=get_report_formats",
18430  response_data);
18431  case 2:
18432  response_data->http_status_code
18433  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18434  return gsad_message (credentials,
18435  "Internal error", __FUNCTION__, __LINE__,
18436  "An internal error occurred while saving a Report Format. "
18437  "It is unclear whether the Report Format has been saved or not. "
18438  "Diagnostics: Failure to receive response from manager daemon.",
18439  "/omp?cmd=get_report_formats",
18440  response_data);
18441  case -1:
18442  default:
18443  response_data->http_status_code
18444  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18445  return gsad_message (credentials,
18446  "Internal error", __FUNCTION__, __LINE__,
18447  "An internal error occurred while saving a Report Format. "
18448  "It is unclear whether the Report Format has been saved or not. "
18449  "Diagnostics: Internal Error.",
18450  "/omp?cmd=get_report_formats",
18451  response_data);
18452  }
18453 
18454  /* TODO Check if succeeded. response_from_entity_if_failed? */
18455  }
18456  }
18457  }
18458 
18459  response = NULL;
18460  entity = NULL;
18461  ret = ompf (connection, credentials,
18462  &response,
18463  &entity,
18464  response_data,
18465  "<modify_report_format"
18466  " report_format_id=\"%s\">"
18467  "<name>%s</name>"
18468  "<summary>%s</summary>"
18469  "<active>%s</active>"
18470  "</modify_report_format>",
18471  report_format_id,
18472  name,
18473  summary,
18474  enable);
18475 
18476  switch (ret)
18477  {
18478  case 0:
18479  break;
18480  case -1:
18481  return response;
18482  case 1:
18483  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18484  return gsad_message (credentials,
18485  "Internal error", __FUNCTION__, __LINE__,
18486  "An internal error occurred while saving a Report Format. "
18487  "The Report Format was not saved. "
18488  "Diagnostics: Failure to send command to manager daemon.",
18489  "/omp?cmd=get_report_formats", response_data);
18490  case 2:
18491  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18492  return gsad_message (credentials,
18493  "Internal error", __FUNCTION__, __LINE__,
18494  "An internal error occurred while saving a Report Format. "
18495  "It is unclear whether the Report Format has been saved or not. "
18496  "Diagnostics: Failure to receive response from manager daemon.",
18497  "/omp?cmd=get_report_formats", response_data);
18498  default:
18499  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18500  return gsad_message (credentials,
18501  "Internal error", __FUNCTION__, __LINE__,
18502  "An internal error occurred while saving a Report Format. "
18503  "It is unclear whether the Report Format has been saved or not. "
18504  "Diagnostics: Internal Error.",
18505  "/omp?cmd=get_report_formats", response_data);
18506  }
18507 
18508  html = response_from_entity (connection, credentials, params, entity,
18509  (no_redirect && strcmp (no_redirect, "0")),
18510  NULL, "get_report_formats",
18511  NULL, "edit_report_format",
18512  "Save Report Format", response_data);
18513  free_entity (entity);
18514  g_free (response);
18515  return html;
18516 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int value_size
Definition: gsad_base.h:154
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_role_omp ( openvas_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
Result of XSL transformation.

Definition at line 23444 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_value(), and users.

23446 {
23447  int ret;
23448  gchar *html, *response;
23449  const char *no_redirect, *role_id, *name, *comment, *users;
23450  entity_t entity;
23451 
23452  no_redirect = params_value (params, "no_redirect");
23453  role_id = params_value (params, "role_id");
23454  name = params_value (params, "name");
23455  comment = params_value (params, "comment");
23456  users = params_value (params, "users");
23457 
23458  CHECK_PARAM_INVALID (role_id, "Save Role", "edit_role");
23459  CHECK_PARAM_INVALID (name, "Save Role", "edit_role");
23460  CHECK_PARAM_INVALID (comment, "Save Role", "edit_role");
23461  CHECK_PARAM_INVALID (users, "Save Role", "edit_role");
23462 
23463  /* Modify the Role. */
23464 
23465  response = NULL;
23466  entity = NULL;
23467  ret = ompf (connection, credentials,
23468  &response,
23469  &entity,
23470  response_data,
23471  "<modify_role role_id=\"%s\">"
23472  "<name>%s</name>"
23473  "<comment>%s</comment>"
23474  "<users>%s</users>"
23475  "</modify_role>",
23476  role_id,
23477  name,
23478  comment,
23479  users);
23480 
23481  switch (ret)
23482  {
23483  case 0:
23484  case -1:
23485  break;
23486  case 1:
23487  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23488  return gsad_message (credentials,
23489  "Internal error", __FUNCTION__, __LINE__,
23490  "An internal error occurred while saving a role. "
23491  "The role was not saved. "
23492  "Diagnostics: Failure to send command to manager daemon.",
23493  "/omp?cmd=get_roles", response_data);
23494  case 2:
23495  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23496  return gsad_message (credentials,
23497  "Internal error", __FUNCTION__, __LINE__,
23498  "An internal error occurred while saving a role. "
23499  "It is unclear whether the role has been saved or not. "
23500  "Diagnostics: Failure to receive response from manager daemon.",
23501  "/omp?cmd=get_roles", response_data);
23502  default:
23503  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23504  return gsad_message (credentials,
23505  "Internal error", __FUNCTION__, __LINE__,
23506  "An internal error occurred while saving a role. "
23507  "It is unclear whether the role has been saved or not. "
23508  "Diagnostics: Internal Error.",
23509  "/omp?cmd=get_roles", response_data);
23510  }
23511 
23512  html = response_from_entity (connection, credentials, params, entity,
23513  (no_redirect && strcmp (no_redirect, "0")),
23514  NULL, "get_roles",
23515  NULL, "edit_role",
23516  "Save Role", response_data);
23517  free_entity (entity);
23518  g_free (response);
23519  return html;
23520 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
GPtrArray * users
User session data.
Definition: gsad.c:340
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save scanner, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 17125 of file gsad_omp.c.

References CHECK_PARAM_INVALID, get_one(), gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_t, and params_value().

17127 {
17128  gchar *response = NULL;
17129  entity_t entity = NULL;
17130  const char *no_redirect;
17131  const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
17132  const char *credential_id, *which_cert;
17133  char *html;
17134  int ret, is_unix_socket, in_use;
17135 
17136  no_redirect = params_value (params, "no_redirect");
17137  scanner_id = params_value (params, "scanner_id");
17138  name = params_value (params, "name");
17139  comment = params_value (params, "comment");
17140  host = params_value (params, "scanner_host");
17141  is_unix_socket = (host && *host == '/') ? 1 : 0;
17142  port = params_value (params, "port");
17143  type = params_value (params, "scanner_type");
17144  which_cert = params_value (params, "which_cert");
17145  ca_pub = params_value (params, "ca_pub");
17146  credential_id = params_value (params, "credential_id");
17147  CHECK_PARAM_INVALID (scanner_id, "Edit Scanner", "edit_scanner");
17148  CHECK_PARAM_INVALID (name, "Edit Scanner", "edit_scanner");
17149  if (params_given (params, "scanner_host") == 0)
17150  in_use = 1;
17151  else
17152  {
17153  in_use = 0;
17154  CHECK_PARAM_INVALID (host, "Edit Scanner", "edit_scanner");
17155  CHECK_PARAM_INVALID (port, "Edit Scanner", "edit_scanner");
17156  CHECK_PARAM_INVALID (type, "Edit Scanner", "edit_scanner");
17157  }
17158  if (is_unix_socket == 0)
17159  {
17160  CHECK_PARAM_INVALID (ca_pub, "Edit Scanner", "edit_scanner");
17161  CHECK_PARAM_INVALID (credential_id, "Edit Scanner", "edit_scanner");
17162  CHECK_PARAM_INVALID (which_cert, "Edit Scanner", "edit_scanner");
17163  }
17164 
17165  if (is_unix_socket)
17166  {
17167  ret = ompf (connection, credentials, &response, &entity, response_data,
17168  "<modify_scanner scanner_id=\"%s\">"
17169  "<name>%s</name>"
17170  "<comment>%s</comment>"
17171  "</modify_scanner>",
17172  scanner_id, name, comment ?: "");
17173  }
17174  else if (strcmp (which_cert, "new") == 0
17175  || strcmp (which_cert, "default") == 0)
17176  {
17177  if (ca_pub == NULL)
17178  ca_pub = "";
17179  if (in_use)
17180  ret = ompf (connection, credentials, &response, &entity, response_data,
17181  "<modify_scanner scanner_id=\"%s\">"
17182  "<name>%s</name>"
17183  "<comment>%s</comment>"
17184  "<ca_pub>%s</ca_pub>"
17185  "<credential id=\"%s\"/>"
17186  "</modify_scanner>",
17187  scanner_id, name, comment ?: "",
17188  strcmp (which_cert, "new") == 0 ? ca_pub : "",
17189  credential_id);
17190  else
17191  ret = ompf (connection, credentials, &response, &entity, response_data,
17192  "<modify_scanner scanner_id=\"%s\">"
17193  "<name>%s</name>"
17194  "<comment>%s</comment>"
17195  "<host>%s</host>"
17196  "<port>%s</port>"
17197  "<type>%s</type>"
17198  "<ca_pub>%s</ca_pub>"
17199  "<credential id=\"%s\"/>"
17200  "</modify_scanner>",
17201  scanner_id, name, comment ?: "", host, port, type,
17202  strcmp (which_cert, "new") == 0 ? ca_pub : "",
17203  credential_id);
17204  }
17205  else
17206  {
17207  /* Using existing CA cert. */
17208  if (in_use)
17209  ret = ompf (connection, credentials, &response, &entity, response_data,
17210  "<modify_scanner scanner_id=\"%s\">"
17211  "<name>%s</name>"
17212  "<comment>%s</comment>"
17213  "<credential id=\"%s\"/>"
17214  "</modify_scanner>",
17215  scanner_id, name, comment ?: "", credential_id);
17216  else
17217  ret = ompf (connection, credentials, &response, &entity, response_data,
17218  "<modify_scanner scanner_id=\"%s\">"
17219  "<name>%s</name>"
17220  "<comment>%s</comment>"
17221  "<host>%s</host>"
17222  "<port>%s</port>"
17223  "<type>%s</type>"
17224  "<credential id=\"%s\"/>"
17225  "</modify_scanner>",
17226  scanner_id, name, comment ?: "", host, port, type,
17227  credential_id);
17228  }
17229 
17230  switch (ret)
17231  {
17232  case 0:
17233  case -1:
17234  break;
17235  case 1:
17236  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17237  return gsad_message
17238  (credentials, "Internal error", __FUNCTION__, __LINE__,
17239  "An internal error occurred while saving a scanner. "
17240  "The scanner remains the same. "
17241  "Diagnostics: Failure to send command to manager daemon.",
17242  "/omp?cmd=get_scanners", response_data);
17243  case 2:
17244  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17245  return gsad_message
17246  (credentials, "Internal error", __FUNCTION__, __LINE__,
17247  "An internal error occurred while saving a scanner. "
17248  "It is unclear whether the scanner has been saved or not. "
17249  "Diagnostics: Failure to receive response from manager daemon.",
17250  "/omp?cmd=get_scanners", response_data);
17251  default:
17252  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17253  return gsad_message
17254  (credentials, "Internal error", __FUNCTION__, __LINE__,
17255  "An internal error occurred while saving a scanner. "
17256  "It is unclear whether the scanner has been saved or not. "
17257  "Diagnostics: Internal Error.",
17258  "/omp?cmd=get_scanners", response_data);
17259  }
17260 
17261  html = response_from_entity (connection, credentials, params, entity,
17262  (no_redirect && strcmp (no_redirect, "0")),
17263  NULL, "get_scanners",
17264  NULL, "edit_scanner",
17265  "Save Scanner", response_data);
17266 
17267  free_entity (entity);
17268  g_free (response);
17269  return html;
17270 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_schedule_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save schedule, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 24288 of file gsad_omp.c.

References CHECK_PARAM_INVALID, command_enabled(), gsad_message(), cmd_response_data_t::http_status_code, params_t, and params_value().

24291 {
24292  gchar *response;
24293  entity_t entity;
24294  const char *no_redirect, *schedule_id, *name, *comment;
24295  const char *hour, *minute, *day_of_month, *month, *year, *timezone;
24296  const char *period, *period_unit, *duration, *duration_unit;
24297  char *ret;
24298 
24299  no_redirect = params_value (params, "no_redirect");
24300  schedule_id = params_value (params, "schedule_id");
24301  name = params_value (params, "name");
24302  comment = params_value (params, "comment");
24303  hour = params_value (params, "hour");
24304  minute = params_value (params, "minute");
24305  day_of_month = params_value (params, "day_of_month");
24306  duration = params_value (params, "duration");
24307  duration_unit = params_value (params, "duration_unit");
24308  month = params_value (params, "month");
24309  period = params_value (params, "period");
24310  period_unit = params_value (params, "period_unit");
24311  year = params_value (params, "year");
24312  timezone = params_value (params, "timezone");
24313 
24314  CHECK_PARAM_INVALID (schedule_id, "Save Schedule", "edit_schedule");
24315  CHECK_PARAM_INVALID (name, "Save Schedule", "edit_schedule");
24316  CHECK_PARAM_INVALID (comment, "Save Schedule", "edit_schedule");
24317  CHECK_PARAM_INVALID (hour, "Save Schedule", "edit_schedule");
24318  CHECK_PARAM_INVALID (minute, "Save Schedule", "edit_schedule");
24319  CHECK_PARAM_INVALID (day_of_month, "Save Schedule", "edit_schedule");
24320  CHECK_PARAM_INVALID (duration, "Save Schedule", "edit_schedule");
24321  CHECK_PARAM_INVALID (duration_unit, "Save Schedule", "edit_schedule");
24322  CHECK_PARAM_INVALID (month, "Save Schedule", "edit_schedule");
24323  CHECK_PARAM_INVALID (period, "Save Schedule", "edit_schedule");
24324  CHECK_PARAM_INVALID (period_unit, "Save Schedule", "edit_schedule");
24325  CHECK_PARAM_INVALID (year, "Save Schedule", "edit_schedule");
24326  CHECK_PARAM_INVALID (timezone, "Save Schedule", "edit_schedule");
24327 
24328  response = NULL;
24329  entity = NULL;
24330  switch (ompf (connection, credentials,
24331  &response,
24332  &entity,
24333  response_data,
24334  "<modify_schedule schedule_id=\"%s\">"
24335  "<name>%s</name>"
24336  "<comment>%s</comment>"
24337  "<first_time>"
24338  "<hour>%s</hour>"
24339  "<minute>%s</minute>"
24340  "<day_of_month>%s</day_of_month>"
24341  "<month>%s</month>"
24342  "<year>%s</year>"
24343  "</first_time>"
24344  "<timezone>%s</timezone>"
24345  "<period>"
24346  "<unit>%s</unit>"
24347  "%s"
24348  "</period>"
24349  "<duration>"
24350  "<unit>%s</unit>"
24351  "%s"
24352  "</duration>"
24353  "</modify_schedule>",
24354  schedule_id,
24355  name ? name : "",
24356  comment ? comment : "",
24357  hour,
24358  minute,
24359  day_of_month,
24360  month,
24361  year,
24362  timezone,
24363  (strcmp (period_unit, "")
24364  ? period_unit
24365  : "second"),
24366  period,
24367  (strcmp (duration_unit, "")
24368  ? duration_unit
24369  : "second"),
24370  duration))
24371  {
24372  case 0:
24373  case -1:
24374  break;
24375  case 1:
24376  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24377  return gsad_message (credentials,
24378  "Internal error", __FUNCTION__, __LINE__,
24379  "An internal error occurred while saving a schedule. "
24380  "The schedule remains the same. "
24381  "Diagnostics: Failure to send command to manager daemon.",
24382  "/omp?cmd=get_schedules", response_data);
24383  case 2:
24384  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24385  return gsad_message (credentials,
24386  "Internal error", __FUNCTION__, __LINE__,
24387  "An internal error occurred while saving a schedule. "
24388  "It is unclear whether the schedule has been saved or not. "
24389  "Diagnostics: Failure to receive response from manager daemon.",
24390  "/omp?cmd=get_schedules", response_data);
24391  default:
24392  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24393  return gsad_message (credentials,
24394  "Internal error", __FUNCTION__, __LINE__,
24395  "An internal error occurred while saving a schedule. "
24396  "It is unclear whether the schedule has been saved or not. "
24397  "Diagnostics: Internal Error.",
24398  "/omp?cmd=get_schedules", response_data);
24399  }
24400 
24401  ret = response_from_entity (connection, credentials, params, entity,
24402  (no_redirect && strcmp (no_redirect, "0")),
24403  NULL, "get_schedules",
24404  NULL, "edit_schedule",
24405  "Save Schedule", response_data);
24406  free_entity (entity);
24407  g_free (response);
24408  return ret;
24409 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_tag_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a tag, get all tags, XSL transform 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
Result of XSL transformation.

Definition at line 10373 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, and params_value().

10375 {
10376  gchar *response;
10377  const char *name, *comment, *value, *resource_type, *resource_id, *active;
10378  const char *tag_id, *no_redirect;
10379  entity_t entity;
10380  char* ret;
10381 
10382  no_redirect = params_value (params, "no_redirect");
10383  tag_id = params_value (params, "tag_id");
10384  name = params_value (params, "tag_name");
10385  comment = params_value (params, "comment");
10386  value = params_value (params, "tag_value");
10387  resource_type = params_value (params, "resource_type");
10388  resource_id = params_value (params, "resource_id");
10389  active = params_value (params, "active");
10390 
10391  CHECK_PARAM_INVALID (tag_id, "Save Tag", "edit_tag")
10392  CHECK_PARAM_INVALID (name, "Save Tag", "edit_tag")
10393  CHECK_PARAM_INVALID (comment, "Save Tag", "edit_tag")
10394  CHECK_PARAM_INVALID (value, "Save Tag", "edit_tag")
10395  CHECK_PARAM_INVALID (resource_type, "Save Tag", "edit_tag")
10396  CHECK_PARAM_INVALID (resource_id, "Save Tag", "edit_tag")
10397  CHECK_PARAM_INVALID (active, "Save Tag", "edit_tag")
10398 
10399  response = NULL;
10400  entity = NULL;
10401  switch (ompf (connection, credentials,
10402  &response,
10403  &entity,
10404  response_data,
10405  "<modify_tag tag_id=\"%s\">"
10406  "<name>%s</name>"
10407  "<comment>%s</comment>"
10408  "<value>%s</value>"
10409  "<resource id=\"%s\">"
10410  "<type>%s</type>"
10411  "</resource>"
10412  "<active>%s</active>"
10413  "</modify_tag>",
10414  tag_id,
10415  name,
10416  comment,
10417  value,
10418  resource_id,
10419  resource_type,
10420  active))
10421  {
10422  case 0:
10423  case -1:
10424  break;
10425  case 1:
10426  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10427  return gsad_message (credentials,
10428  "Internal error", __FUNCTION__, __LINE__,
10429  "An internal error occurred while saving a tag. "
10430  "The tag remains the same. "
10431  "Diagnostics: Failure to send command to "
10432  "manager daemon.",
10433  "/omp?cmd=get_targets", response_data);
10434  case 2:
10435  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10436  return gsad_message (credentials,
10437  "Internal error", __FUNCTION__, __LINE__,
10438  "An internal error occurred while saving a tag. "
10439  "It is unclear whether the tag has been saved "
10440  "or not. "
10441  "Diagnostics: Failure to receive response from "
10442  "manager daemon.",
10443  "/omp?cmd=get_tags", response_data);
10444  default:
10445  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10446  return gsad_message (credentials,
10447  "Internal error", __FUNCTION__, __LINE__,
10448  "An internal error occurred while saving a tag. "
10449  "It is unclear whether the tag has been saved "
10450  "or not. "
10451  "Diagnostics: Internal Error.",
10452  "/omp?cmd=get_tags", response_data);
10453  }
10454 
10455  ret = response_from_entity (connection, credentials, params, entity,
10456  (no_redirect && strcmp (no_redirect, "0")),
10457  NULL, "get_tags",
10458  NULL, "edit_tag",
10459  "Save Tag", response_data);
10460 
10461  free_entity (entity);
10462  g_free (response);
10463  return ret;
10464 
10465 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
char * edit_tag(openvas_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
Definition: gsad_omp.c:10280
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_target_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a target, get all targets, XSL transform 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
Result of XSL transformation.

Definition at line 10940 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), GSAD_MESSAGE_INVALID, GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, and params_value().

10942 {
10943  gchar *html, *response;
10944  const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
10945  const char *target_ssh_credential, *port, *target_smb_credential;
10946  const char *target_esxi_credential, *target_snmp_credential, *target_source;
10947  const char *target_id, *port_list_id, *reverse_lookup_only;
10948  const char *reverse_lookup_unify, *alive_tests, *in_use;
10949  GString *command;
10950 
10951  no_redirect = params_value (params, "no_redirect");
10952  alive_tests = params_value (params, "alive_tests");
10953  name = params_value (params, "name");
10954  comment = params_value (params, "comment");
10955  in_use = params_value (params, "in_use");
10956  target_id = params_value (params, "target_id");
10957 
10958  CHECK_PARAM_INVALID (name, "Save Target", "edit_target");
10959  CHECK_PARAM_INVALID (target_id, "Save Target", "edit_target");
10960  CHECK_PARAM_INVALID (comment, "Save Target", "edit_target");
10961  CHECK_PARAM_INVALID (alive_tests, "Save Target", "edit_target");
10962  CHECK_PARAM_INVALID (in_use, "Save Target", "edit_target");
10963 
10964  if (strcmp (in_use, "0"))
10965  {
10966  entity_t entity;
10967  int ret;
10968 
10969  /* Target is in use. Modify fewer fields. */
10970 
10971  command = g_string_new ("");
10972  xml_string_append (command,
10973  "<modify_target target_id=\"%s\">"
10974  "<name>%s</name>"
10975  "<comment>%s</comment>"
10976  "<alive_tests>%s</alive_tests>"
10977  "</modify_target>",
10978  target_id,
10979  name ? name : "",
10980  comment ? comment : "",
10981  alive_tests);
10982 
10983  response = NULL;
10984  entity = NULL;
10985  ret = omp (connection, credentials, &response, &entity, response_data,
10986  command->str);
10987  g_string_free (command, TRUE);
10988  switch (ret)
10989  {
10990  case 0:
10991  case -1:
10992  break;
10993  case 1:
10994  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10995  return gsad_message (credentials,
10996  "Internal error", __FUNCTION__, __LINE__,
10997  "An internal error occurred while saving a target. "
10998  "The target remains the same. "
10999  "Diagnostics: Failure to send command to manager daemon.",
11000  "/omp?cmd=get_targets", response_data);
11001  case 2:
11002  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11003  return gsad_message (credentials,
11004  "Internal error", __FUNCTION__, __LINE__,
11005  "An internal error occurred while saving a target. "
11006  "It is unclear whether the target has been saved or not. "
11007  "Diagnostics: Failure to receive response from manager daemon.",
11008  "/omp?cmd=get_targets", response_data);
11009  default:
11010  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11011  return gsad_message (credentials,
11012  "Internal error", __FUNCTION__, __LINE__,
11013  "An internal error occurred while saving a target. "
11014  "It is unclear whether the target has been saved or not. "
11015  "Diagnostics: Internal Error.",
11016  "/omp?cmd=get_targets", response_data);
11017  }
11018 
11019  html = response_from_entity (connection, credentials, params, entity,
11020  (no_redirect && strcmp (no_redirect, "0")),
11021  NULL, "get_targets",
11022  NULL, "edit_target",
11023  "Save Target", response_data);
11024 
11025  free_entity (entity);
11026  g_free (response);
11027  return html;
11028  }
11029 
11030  hosts = params_value (params, "hosts");
11031  exclude_hosts = params_value (params, "exclude_hosts");
11032  reverse_lookup_only = params_value (params, "reverse_lookup_only");
11033  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
11034  target_source = params_value (params, "target_source");
11035  port_list_id = params_value (params, "port_list_id");
11036  target_ssh_credential = params_value (params, "ssh_credential_id");
11037  port = params_value (params, "port");
11038  target_smb_credential = params_value (params, "smb_credential_id");
11039  target_esxi_credential = params_value (params, "esxi_credential_id");
11040  target_snmp_credential = params_value (params, "snmp_credential_id");
11041 
11042  CHECK_PARAM_INVALID (target_source, "Save Target", "edit_target");
11043  CHECK_PARAM_INVALID (port_list_id, "Save Target", "edit_target");
11044  CHECK_PARAM_INVALID (target_ssh_credential, "Save Target", "edit_target");
11045  CHECK_PARAM_INVALID (target_smb_credential, "Save Target", "edit_target");
11046  CHECK_PARAM_INVALID (target_esxi_credential, "Save Target", "edit_target");
11047  CHECK_PARAM_INVALID (target_snmp_credential, "Save Target", "edit_target");
11048 
11049  if (strcmp (target_ssh_credential, "--")
11050  && strcmp (target_ssh_credential, "0"))
11051  CHECK_PARAM_INVALID (port, "Save Target", "edit_target");
11052 
11053  if (hosts == NULL && strcmp (target_source, "manual") == 0)
11054  {
11055  return new_target (connection, credentials, params,
11056  GSAD_MESSAGE_INVALID_PARAM ("Modify Target"),
11057  response_data);
11058  }
11059  if (strcmp (target_source, "import") == 0 && name == NULL)
11060  {
11061  gchar *msg;
11062  msg = g_strdup_printf (GSAD_MESSAGE_INVALID,
11063  "Given target_source was invalid",
11064  "Modify Target");
11065  html = new_target (connection, credentials, params, msg, response_data);
11066  g_free (msg);
11067  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11068  return html;
11069  }
11070 
11071  {
11072  int ret;
11073  gchar *ssh_credentials_element, *smb_credentials_element;
11074  gchar *esxi_credentials_element, *snmp_credentials_element;
11075  gchar* comment_element;
11076  entity_t entity;
11077 
11078  if (comment)
11079  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
11080  else
11081  comment_element = g_strdup ("");
11082 
11083  if (strcmp (target_ssh_credential, "--") == 0)
11084  ssh_credentials_element = g_strdup ("");
11085  else
11086  ssh_credentials_element =
11087  g_strdup_printf ("<ssh_credential id=\"%s\">"
11088  "<port>%s</port>"
11089  "</ssh_credential>",
11090  target_ssh_credential,
11091  port);
11092 
11093  if (strcmp (target_smb_credential, "--") == 0)
11094  smb_credentials_element = g_strdup ("");
11095  else
11096  smb_credentials_element =
11097  g_strdup_printf ("<smb_credential id=\"%s\"/>",
11098  target_smb_credential);
11099 
11100  if (strcmp (target_esxi_credential, "--") == 0)
11101  esxi_credentials_element = g_strdup ("");
11102  else
11103  esxi_credentials_element =
11104  g_strdup_printf ("<esxi_credential id=\"%s\"/>",
11105  target_esxi_credential);
11106 
11107  if (strcmp (target_snmp_credential, "--") == 0)
11108  snmp_credentials_element = g_strdup ("");
11109  else
11110  snmp_credentials_element =
11111  g_strdup_printf ("<snmp_credential id=\"%s\"/>",
11112  target_snmp_credential);
11113 
11114  command = g_string_new ("");
11115  xml_string_append (command,
11116  "<modify_target target_id=\"%s\">"
11117  "<name>%s</name>"
11118  "<hosts>%s</hosts>"
11119  "<exclude_hosts>%s</exclude_hosts>"
11120  "<reverse_lookup_only>%s</reverse_lookup_only>"
11121  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
11122  "<port_list id=\"%s\"/>"
11123  "<alive_tests>%s</alive_tests>",
11124  target_id,
11125  name,
11126  strcmp (target_source, "file") == 0
11127  ? params_value (params, "file")
11128  : hosts,
11129  exclude_hosts ? exclude_hosts : "",
11130  reverse_lookup_only ? reverse_lookup_only : "0",
11131  reverse_lookup_unify ? reverse_lookup_unify : "0",
11132  port_list_id,
11133  alive_tests);
11134 
11135  g_string_append_printf (command,
11136  "%s%s%s%s%s"
11137  "</modify_target>",
11138  comment_element,
11139  ssh_credentials_element,
11140  smb_credentials_element,
11141  esxi_credentials_element,
11142  snmp_credentials_element);
11143 
11144  g_free (comment_element);
11145  g_free (ssh_credentials_element);
11146  g_free (smb_credentials_element);
11147  g_free (esxi_credentials_element);
11148  g_free (snmp_credentials_element);
11149 
11150  /* Modify the target. */
11151 
11152  ret = openvas_connection_sendf (connection, "%s", command->str);
11153  g_string_free (command, TRUE);
11154 
11155  if (ret == -1)
11156  {
11157  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11158  return gsad_message (credentials,
11159  "Internal error", __FUNCTION__, __LINE__,
11160  "An internal error occurred while modifying target. "
11161  "No target was modified. "
11162  "Diagnostics: Failure to send command to manager daemon.",
11163  "/omp?cmd=get_targets", response_data);
11164  }
11165 
11166  entity = NULL;
11167  if (read_entity_and_text_c (connection, &entity, &response))
11168  {
11169  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11170  return gsad_message (credentials,
11171  "Internal error", __FUNCTION__, __LINE__,
11172  "An internal error occurred while modifying a target. "
11173  "It is unclear whether the target has been modified or not. "
11174  "Diagnostics: Failure to receive response from manager daemon.",
11175  "/omp?cmd=get_targets", response_data);
11176  }
11177 
11178  html = response_from_entity (connection, credentials, params, entity,
11179  (no_redirect && strcmp (no_redirect, "0")),
11180  NULL, "get_targets",
11181  NULL, "edit_target",
11182  "Save Target", response_data);
11183  }
11184 
11185  /* Pass response to handler of following page. */
11186 
11187  return html;
11188 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
Definition: gsad_base.h:44
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save task, get next page, XSL transform 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
Result of XSL transformation.

Definition at line 4639 of file gsad_omp.c.

References CHECK, CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_valid(), params_value(), params_values(), and param::value.

4641 {
4642  gchar *html, *response, *format;
4643  const char *no_redirect;
4644  const char *comment, *name, *schedule_id, *in_assets;
4645  const char *scanner_id, *task_id, *max_checks, *max_hosts;
4646  const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
4647  const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
4648  const char *apply_overrides, *min_qod;
4649  int ret;
4650  params_t *alerts;
4651  GString *alert_element;
4652  entity_t entity;
4653 
4654  no_redirect = params_value (params, "no_redirect");
4655  comment = params_value (params, "comment");
4656  name = params_value (params, "name");
4657  task_id = params_value (params, "task_id");
4658  in_assets = params_value (params, "in_assets");
4659  apply_overrides = params_value (params, "apply_overrides");
4660  min_qod = params_value (params, "min_qod");
4661  target_id = params_value (params, "target_id");
4662  scanner_type = params_value (params, "scanner_type");
4663  hosts_ordering = params_value (params, "hosts_ordering");
4664  config_id = params_value (params, "config_id");
4665  schedule_id = params_value (params, "schedule_id");
4666  schedule_periods = params_value (params, "schedule_periods");
4667  scanner_id = params_value (params, "scanner_id");
4668  max_checks = params_value (params, "max_checks");
4669  source_iface = params_value (params, "source_iface");
4670  auto_delete = params_value (params, "auto_delete");
4671  auto_delete_data = params_value (params, "auto_delete_data");
4672  max_hosts = params_value (params, "max_hosts");
4673  alterable = params_value (params, "alterable");
4674  CHECK_PARAM_INVALID (scanner_type, "Save Task", "edit_task");
4675  if (!strcmp (scanner_type, "1"))
4676  {
4677  hosts_ordering = "";
4678  max_checks = "";
4679  source_iface = "";
4680  max_hosts = "";
4681  }
4682  else if (!strcmp (scanner_type, "3"))
4683  {
4684  config_id = "0";
4685  hosts_ordering = "";
4686  max_checks = "";
4687  source_iface = "";
4688  max_hosts = "";
4689  }
4690 
4691  CHECK_PARAM_INVALID (name, "Save Task", "edit_task");
4692  CHECK_PARAM_INVALID (comment, "Save Task", "edit_task");
4693  CHECK_PARAM_INVALID (target_id, "Save Task", "edit_task");
4694  CHECK_PARAM_INVALID (hosts_ordering, "Save Task", "edit_task");
4695  CHECK_PARAM_INVALID (config_id, "Save Task", "edit_task");
4696  CHECK_PARAM_INVALID (schedule_id, "Save Task", "edit_task");
4697  if (params_given (params, "schedule_periods"))
4698  {
4699  CHECK (schedule_periods);
4700  }
4701  else
4702  schedule_periods = "0";
4703  CHECK_PARAM_INVALID (scanner_id, "Save Task", "edit_task");
4704  CHECK_PARAM_INVALID (task_id, "Save Task", "edit_task");
4705  CHECK_PARAM_INVALID (max_checks, "Save Task", "edit_task");
4706  CHECK_PARAM_INVALID (source_iface, "Save Task", "edit_task");
4707  CHECK_PARAM_INVALID (auto_delete, "Save Task", "edit_task");
4708  CHECK_PARAM_INVALID (auto_delete_data, "Save Task", "edit_task");
4709  CHECK_PARAM_INVALID (max_hosts, "Save Task", "edit_task");
4710  CHECK_PARAM_INVALID (in_assets, "Save Task", "edit_task");
4711 
4712  if (!strcmp (in_assets, "1"))
4713  {
4714  CHECK_PARAM_INVALID (apply_overrides, "Save Task", "edit_task");
4715  CHECK_PARAM_INVALID (min_qod, "Save Task", "edit_task");
4716  }
4717  else
4718  {
4719  if (!params_given (params, "apply_overrides")
4720  || !params_valid (params, "apply_overrides"))
4721  apply_overrides = "";
4722 
4723  if (!params_given (params, "min_qod")
4724  || !params_valid (params, "min_qod"))
4725  min_qod = "";
4726  }
4727 
4728  alert_element = g_string_new ("");
4729  if (params_given (params, "alert_id_optional:"))
4730  alerts = params_values (params, "alert_id_optional:");
4731  else
4732  alerts = params_values (params, "alert_ids:");
4733 
4734  if (alerts)
4735  {
4736  params_iterator_t iter;
4737  char *name;
4738  param_t *param;
4739 
4740  params_iterator_init (&iter, alerts);
4741  while (params_iterator_next (&iter, &name, &param))
4742  {
4743  if (param->value && strcmp (param->value, "0"))
4744  g_string_append_printf (alert_element,
4745  "<alert id=\"%s\"/>",
4746  param->value ? param->value : "");
4747  }
4748  }
4749 
4750  // Remove Alerts from Task if none are given.
4751  if (strcmp (alert_element->str, "") == 0)
4752  g_string_append_printf (alert_element, "<alert id=\"0\"/>");
4753 
4754  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
4755  "<name>%%s</name>"
4756  "<comment>%%s</comment>"
4757  "<hosts_ordering>%s</hosts_ordering>"
4758  "%s"
4759  "<target id=\"%%s\"/>"
4760  "<config id=\"%%s\"/>"
4761  "<schedule id=\"%%s\"/>"
4762  "<schedule_periods>%%s</schedule_periods>"
4763  "<scanner id=\"%%s\"/>"
4764  "<preferences>"
4765  "<preference>"
4766  "<scanner_name>max_checks</scanner_name>"
4767  "<value>%%s</value>"
4768  "</preference>"
4769  "<preference>"
4770  "<scanner_name>max_hosts</scanner_name>"
4771  "<value>%%s</value>"
4772  "</preference>"
4773  "<preference>"
4774  "<scanner_name>in_assets</scanner_name>"
4775  "<value>%%s</value>"
4776  "</preference>"
4777  "<preference>"
4778  "<scanner_name>assets_apply_overrides</scanner_name>"
4779  "<value>%%s</value>"
4780  "</preference>"
4781  "<preference>"
4782  "<scanner_name>assets_min_qod</scanner_name>"
4783  "<value>%%s</value>"
4784  "</preference>"
4785  "<preference>"
4786  "<scanner_name>source_iface</scanner_name>"
4787  "<value>%%s</value>"
4788  "</preference>"
4789  "<preference>"
4790  "<scanner_name>auto_delete</scanner_name>"
4791  "<value>%%s</value>"
4792  "</preference>"
4793  "<preference>"
4794  "<scanner_name>auto_delete_data</scanner_name>"
4795  "<value>%%s</value>"
4796  "</preference>"
4797  "</preferences>"
4798  "%s%i%s"
4799  "</modify_task>",
4800  hosts_ordering,
4801  alert_element->str,
4802  alterable ? "<alterable>" : "",
4803  alterable ? strcmp (alterable, "0") : 0,
4804  alterable ? "</alterable>" : "");
4805  response = NULL;
4806  entity = NULL;
4807  ret = ompf (connection,
4808  credentials,
4809  &response,
4810  &entity,
4811  response_data,
4812  format,
4813  task_id,
4814  name,
4815  comment,
4816  target_id,
4817  config_id,
4818  schedule_id,
4819  schedule_periods,
4820  scanner_id,
4821  max_checks,
4822  max_hosts,
4823  strcmp (in_assets, "0") ? "yes" : "no",
4824  strcmp (apply_overrides, "0") ? "yes" : "no",
4825  min_qod,
4826  source_iface,
4827  auto_delete,
4828  auto_delete_data);
4829  g_free (format);
4830 
4831  g_string_free (alert_element, TRUE);
4832 
4833  switch (ret)
4834  {
4835  case 0:
4836  case -1:
4837  break;
4838  case 1:
4839  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4840  return gsad_message (credentials,
4841  "Internal error", __FUNCTION__, __LINE__,
4842  "An internal error occurred while saving a task. "
4843  "The task was not saved. "
4844  "Diagnostics: Failure to send command to manager daemon.",
4845  "/omp?cmd=get_tasks", response_data);
4846  case 2:
4847  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4848  return gsad_message (credentials,
4849  "Internal error", __FUNCTION__, __LINE__,
4850  "An internal error occurred while saving a task. "
4851  "It is unclear whether the task has been saved or not. "
4852  "Diagnostics: Failure to receive response from manager daemon.",
4853  "/omp?cmd=get_tasks", response_data);
4854  default:
4855  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4856  return gsad_message (credentials,
4857  "Internal error", __FUNCTION__, __LINE__,
4858  "An internal error occurred while saving a task. "
4859  "It is unclear whether the task has been saved or not. "
4860  "Diagnostics: Internal Error.",
4861  "/omp?cmd=get_tasks", response_data);
4862  }
4863 
4864  html = response_from_entity (connection, credentials, params, entity,
4865  (no_redirect && strcmp (no_redirect, "0")),
4866  NULL, "get_tasks",
4867  NULL, "edit_task",
4868  "Save Task", response_data);
4869  free_entity (entity);
4870  g_free (response);
4871  return html;
4872 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9605
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:793
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

char* save_user_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
char **  password_return,
char **  modified_user,
int *  logout_user,
cmd_response_data_t response_data 
)

Modify a user, get all users, XSL transform the result.

Parameters
[in]connectionConnection to manager
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]password_returnPassword. Caller must free.
[out]modified_userName of user modified. Caller must free.
[out]logout_userWhether the user should be logged out.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 25325 of file gsad_omp.c.

References CHECK_PARAM_INVALID, gsad_message(), cmd_response_data_t::http_status_code, logout(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), credentials_t::password, credentials_t::username, and param::value.

Referenced by exec_omp_post().

25328 {
25329  int ret;
25330  gchar *html, *response, *buf;
25331  const char *no_redirect;
25332  const char *user_id, *login, *old_login, *modify_password, *password;
25333  const char *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25334  entity_t entity;
25335  GString *command, *group_elements, *role_elements;
25336  params_t *groups, *roles;
25337  const char *status;
25338 
25339  *password_return = NULL;
25340  *modified_user = NULL;
25341  *logout_user = 0;
25342 
25343  no_redirect = params_value (params, "no_redirect");
25344  /* List of hosts user has/lacks access rights. */
25345  hosts = params_value (params, "access_hosts");
25346  /* Whether hosts grants ("1") or forbids ("0") access. "2" for all
25347  * access. */
25348  hosts_allow = params_value (params, "hosts_allow");
25349  ifaces = params_value (params, "access_ifaces");
25350  ifaces_allow = params_value (params, "ifaces_allow");
25351  login = params_value (params, "login");
25352  old_login = params_value (params, "old_login");
25353  modify_password = params_value (params, "modify_password");
25354  password = params_value (params, "password");
25355  user_id = params_value (params, "user_id");
25356 
25357  CHECK_PARAM_INVALID (user_id, "Edit User", "edit_user");
25358  CHECK_PARAM_INVALID (modify_password, "Edit User", "edit_user");
25359  CHECK_PARAM_INVALID (password, "Edit User", "edit_user");
25360  CHECK_PARAM_INVALID (hosts, "Edit User", "edit_user");
25361  CHECK_PARAM_INVALID (hosts_allow, "Edit User", "edit_user");
25362  CHECK_PARAM_INVALID (ifaces, "Save User", "edit_user");
25363  CHECK_PARAM_INVALID (ifaces_allow, "Save User", "edit_user");
25364 
25365  if (params_given (params, "login")
25366  && !(params_given (params, "current_user")))
25367  {
25368  CHECK_PARAM_INVALID (login, "Save User", "edit_user");
25369  CHECK_PARAM_INVALID (old_login, "Save User", "edit_user");
25370  }
25371 
25372  /* Modify the user. */
25373 
25374  command = g_string_new ("");
25375  buf = g_markup_printf_escaped ("<modify_user user_id=\"%s\">"
25376  "<password modify=\"%s\">"
25377  "%s</password>",
25378  user_id,
25379  modify_password,
25380  password);
25381  g_string_append (command, buf);
25382  g_free (buf);
25383 
25384  if (login)
25385  {
25386  buf = g_markup_printf_escaped ("<new_name>%s</new_name>",
25387  login);
25388  g_string_append (command, buf);
25389  g_free (buf);
25390  }
25391 
25392  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
25393  "<ifaces allow=\"%s\">%s</ifaces>",
25394  hosts_allow, hosts, ifaces_allow, ifaces);
25395  g_string_append (command, buf);
25396  g_free (buf);
25397 
25398  if (modify_password && !strcmp (modify_password, "2"))
25399  g_string_append (command, "<sources><source>ldap_connect</source></sources>");
25400  else if (modify_password && !strcmp (modify_password, "3"))
25401  g_string_append (command, "<sources><source>radius_connect</source></sources>");
25402  else
25403  g_string_append (command, "<sources><source>file</source></sources>");
25404 
25405  group_elements = g_string_new ("<groups>");
25406  if (params_given (params, "group_id_optional:"))
25407  groups = params_values (params, "group_id_optional:");
25408  else
25409  groups = params_values (params, "group_ids:");
25410 
25411  if (groups)
25412  {
25413  params_iterator_t iter;
25414  char *name;
25415  param_t *param;
25416 
25417  params_iterator_init (&iter, groups);
25418  while (params_iterator_next (&iter, &name, &param))
25419  {
25420  if (param->value && strcmp (param->value, "--"))
25421  g_string_append_printf (group_elements,
25422  "<group id=\"%s\"/>",
25423  param->value ? param->value : "");
25424  }
25425  }
25426  g_string_append (command, group_elements->str);
25427  g_string_free (group_elements, TRUE);
25428  g_string_append (command, "</groups>");
25429 
25430  role_elements = g_string_new ("");
25431  if (params_given (params, "role_id_optional:"))
25432  roles = params_values (params, "role_id_optional:");
25433  else
25434  roles = params_values (params, "role_ids:");
25435 
25436  if (roles)
25437  {
25438  params_iterator_t iter;
25439  char *name;
25440  param_t *param;
25441 
25442  params_iterator_init (&iter, roles);
25443  while (params_iterator_next (&iter, &name, &param))
25444  {
25445  if (param->value && strcmp (param->value, "--"))
25446  g_string_append_printf (role_elements,
25447  "<role id=\"%s\"/>",
25448  param->value ? param->value : "");
25449  }
25450  }
25451  else
25452  g_string_append_printf (role_elements, "<role id=\"0\"/>");
25453 
25454  g_string_append (command, role_elements->str);
25455  g_string_free (role_elements, TRUE);
25456 
25457  g_string_append (command, "</modify_user>");
25458 
25459  response = NULL;
25460  entity = NULL;
25461  ret = omp (connection, credentials,
25462  &response,
25463  &entity,
25464  response_data,
25465  command->str);
25466  g_string_free (command, TRUE);
25467  switch (ret)
25468  {
25469  case 0:
25470  status = entity_attribute (entity, "status");
25471  if (status && (strlen (status) > 0) && (status[0] == '2'))
25472  {
25473  *modified_user
25474  = g_strdup (old_login ? old_login : credentials->username);
25475 
25476  if (strcmp (modify_password, "0")
25477  || (login && *modified_user && strcmp (*modified_user, login)))
25478  *logout_user = 1;
25479 
25480  if (strcmp (modify_password, "0")
25481  && strcmp (modify_password, "2")
25482  && strcmp (modify_password, "3")
25483  && params_given (params, "current_user"))
25484  {
25485  g_free (credentials->password);
25486  credentials->password = g_strdup (password);
25487  *password_return = g_strdup (password);
25488  }
25489  }
25490  break;
25491  case -1:
25492  break;
25493  case 1:
25494  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25495  return gsad_message (credentials,
25496  "Internal error", __FUNCTION__, __LINE__,
25497  "An internal error occurred while saving a user. "
25498  "The user was not saved. "
25499  "Diagnostics: Failure to send command to manager daemon.",
25500  "/omp?cmd=get_users", response_data);
25501  case 2:
25502  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25503  return gsad_message (credentials,
25504  "Internal error", __FUNCTION__, __LINE__,
25505  "An internal error occurred while saving a user. "
25506  "It is unclear whether the user has been saved or not. "
25507  "Diagnostics: Failure to receive response from manager daemon.",
25508  "/omp?cmd=get_users", response_data);
25509  default:
25510  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25511  return gsad_message (credentials,
25512  "Internal error", __FUNCTION__, __LINE__,
25513  "An internal error occurred while saving a user. "
25514  "It is unclear whether the user has been saved or not. "
25515  "Diagnostics: Internal Error.",
25516  "/omp?cmd=get_users", response_data);
25517  }
25518 
25519  if (omp_success (entity)
25520  && (!strcmp (modify_password, "2")
25521  || !strcmp (modify_password, "3"))
25522  && params_given (params, "current_user"))
25523  {
25524  free_entity (entity);
25525  g_free (response);
25526  html = logout (credentials,
25527  "Authentication method changed."
25528  " Please login with LDAP password.",
25529  response_data);
25530  }
25531  else
25532  html = response_from_entity (connection, credentials, params, entity,
25533  (no_redirect && strcmp (no_redirect, "0")),
25534  NULL, "get_users",
25535  NULL, "edit_user",
25536  "Save User", response_data);
25537  free_entity (entity);
25538  g_free (response);
25539  return html;
25540 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:777
gchar * value
Definition: gsad_base.h:148
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:695
char * logout(credentials_t *credentials, const gchar *message, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
Definition: gsad_omp.c:25280
char * username
Name of user.
Definition: gsad_base.h:69
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:146
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:887
#define params_iterator_init
Definition: gsad_base.h:189
#define params_iterator_t
Definition: gsad_base.h:187
char * password
User&#39;s password.
Definition: gsad_base.h:70
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1195

Here is the call graph for this function:

Here is the caller graph for this function:

void set_http_status_from_entity ( entity_t  entity,
cmd_response_data_t response_data 
)

Set the HTTP status according to OMP response entity.

Parameters
[in]entityThe OMP response entity.
[in]response_dataResponse data.

Definition at line 885 of file gsad_omp.c.

References gsad_message(), and cmd_response_data_t::http_status_code.

Referenced by clone_omp(), delete_resource(), edit_my_settings_omp(), export_resource(), get_one(), message_invalid(), resource_action(), save_chart_preference_omp(), save_my_settings_omp(), toggle_tag_omp(), verify_agent_omp(), verify_report_format_omp(), and verify_scanner_omp().

887 {
888  if (entity == NULL)
889  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
890  else if (strcmp (entity_attribute (entity, "status_text"),
891  "Permission denied")
892  == 0)
893  response_data->http_status_code = MHD_HTTP_FORBIDDEN;
894  else if (strcmp (entity_attribute (entity, "status"), "404") == 0)
895  response_data->http_status_code = MHD_HTTP_NOT_FOUND;
896  else
897  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
898 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* start_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Start a task, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 5073 of file gsad_omp.c.

References resource_action().

5075 {
5076  return resource_action (connection, credentials, params, "task", "start",
5077  response_data);
5078 }
char * resource_action(openvas_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, XSL transform result.
Definition: gsad_omp.c:3135

Here is the call graph for this function:

char* stop_task_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Stop a task, get all tasks, XSL transform 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
Result of XSL transformation.

Definition at line 5037 of file gsad_omp.c.

References resource_action().

5039 {
5040  return resource_action (connection, credentials, params, "task", "stop",
5041  response_data);
5042 }
char * resource_action(openvas_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, XSL transform result.
Definition: gsad_omp.c:3135

Here is the call graph for this function:

char* sync_cert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with a CERT feed and XSL transform 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
Result of XSL transformation.

Definition at line 23716 of file gsad_omp.c.

References get_one(), and params_t.

23718 {
23719  return sync_feed (connection, credentials, params,
23720  "sync_cert", "Synchronize CERT Feed", "the CERT feed",
23721  response_data);
23722 }

Here is the call graph for this function:

char* sync_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Sync config, get configs, XSL transform 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
Result of XSL transformation.

Definition at line 11821 of file gsad_omp.c.

References CHECK_PARAM, gsad_message(), cmd_response_data_t::http_status_code, params_t, params_value(), param::value, and param::value_size.

11823 {
11824  GString *xml;
11825  const char *config_id, *next;
11826  char *ret;
11827 
11828  config_id = params_value (params, "config_id");
11829  CHECK_PARAM (config_id, "Synchronize Config", get_configs);
11830 
11831  if (openvas_connection_sendf (connection, "<sync_config config_id=\"%s\"/>",
11832  config_id)
11833  == -1)
11834  {
11835  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11836  return gsad_message
11837  (credentials, "Internal error", __FUNCTION__, __LINE__,
11838  "An internal error occurred while synchronizing a config. "
11839  "The config is not synchronized. "
11840  "Diagnostics: Failure to send command to manager daemon.",
11841  "/omp?cmd=get_configs", response_data);
11842  }
11843 
11844  xml = g_string_new ("");
11845 
11846  if (read_string_c (connection, &xml))
11847  {
11848  g_string_free (xml, TRUE);
11849  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11850  return gsad_message
11851  (credentials, "Internal error", __FUNCTION__, __LINE__,
11852  "An internal error occurred while synchronizing a config. "
11853  "It is unclear whether the config has been synchronized or not. "
11854  "Diagnostics: Failure to receive response from manager daemon.",
11855  "/omp?cmd=get_configs", response_data);
11856  }
11857 
11858  next = params_value (params, "next");
11859  if (next && !strcmp (next, "get_config"))
11860  ret = get_config (connection, credentials, params, xml->str, 0,
11861  response_data);
11862  else
11863  ret = get_configs (connection, credentials, params, xml->str,
11864  response_data);
11865  g_string_free (xml, TRUE);
11866  return ret;
11867 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1174

Here is the call graph for this function:

char* sync_feed_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with an NVT feed and XSL transform 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
Result of XSL transformation.

Definition at line 23678 of file gsad_omp.c.

23680 {
23681  return sync_feed (connection, credentials, params,
23682  "sync_feed", "Synchronize Feed", "the NVT feed",
23683  response_data);
23684 }
char* sync_scap_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with a SCAP feed and XSL transform 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
Result of XSL transformation.

Definition at line 23697 of file gsad_omp.c.

23699 {
23700  return sync_feed (connection, credentials, params,
23701  "sync_scap", "Synchronize Feed", "the SCAP feed",
23702  response_data);
23703 }
char* test_alert_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Test an alert, get all alerts XSL transform 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
Result of XSL transformation.

Definition at line 9112 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, and params_value().

9114 {
9115  gchar *html, *response;
9116  const char *no_redirect, *alert_id;
9117  entity_t entity;
9118 
9119  no_redirect = params_value (params, "no_redirect");
9120  alert_id = params_value (params, "alert_id");
9121 
9122  if (alert_id == NULL)
9123  {
9124  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
9125  return gsad_message (credentials,
9126  "Internal error", __FUNCTION__, __LINE__,
9127  "An internal error occurred while testing an alert. "
9128  "Diagnostics: Required parameter was NULL.",
9129  "/omp?cmd=get_alerts", response_data);
9130  }
9131 
9132  /* Test the alert. */
9133 
9134  if (openvas_connection_sendf (connection,
9135  "<test_alert alert_id=\"%s\"/>",
9136  alert_id)
9137  == -1)
9138  {
9139  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9140  return gsad_message (credentials,
9141  "Internal error", __FUNCTION__, __LINE__,
9142  "An internal error occurred while testing an alert. "
9143  "Diagnostics: Failure to send command to manager daemon.",
9144  "/omp?cmd=get_alerts", response_data);
9145  }
9146 
9147  entity = NULL;
9148  if (read_entity_and_text_c (connection, &entity, &response))
9149  {
9150  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9151  return gsad_message (credentials,
9152  "Internal error", __FUNCTION__, __LINE__,
9153  "An internal error occurred while testing an alert. "
9154  "Diagnostics: Failure to receive response from manager daemon.",
9155  "/omp?cmd=get_alerts", response_data);
9156  }
9157 
9158  /* Cleanup, and return transformed XML. */
9159 
9160  html = response_from_entity (connection, credentials, params, entity,
9161  (no_redirect && strcmp (no_redirect, "0")),
9162  NULL, "get_alerts",
9163  NULL, "get_alerts",
9164  "Test Alert", response_data);
9165 
9166  free_entity (entity);
9167  g_free (response);
9168  return html;
9169 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* toggle_tag_omp ( openvas_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
Result of XSL transformation.

Definition at line 10600 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_value(), and set_http_status_from_entity().

10602 {
10603  gchar *html, *response;
10604  const char *no_redirect, *tag_id, *enable;
10605  entity_t entity;
10606 
10607  no_redirect = params_value (params, "no_redirect");
10608  tag_id = params_value (params, "tag_id");
10609  enable = params_value (params, "enable");
10610 
10611  if (tag_id == NULL)
10612  {
10613  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10614  return gsad_message (credentials,
10615  "Internal error", __FUNCTION__, __LINE__,
10616  "An internal error occurred while modifying a tag. "
10617  "The tag was not modified. "
10618  "Diagnostics: Required parameter tag_id was NULL.",
10619  "/omp?cmd=get_tasks", response_data);
10620  }
10621  if (enable == NULL)
10622  {
10623  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10624  return gsad_message (credentials,
10625  "Internal error", __FUNCTION__, __LINE__,
10626  "An internal error occurred while modifying a tag. "
10627  "The tag was not modified. "
10628  "Diagnostics: Required parameter enable was NULL.",
10629  "/omp?cmd=get_tasks", response_data);
10630  }
10631 
10632  /* Delete the resource and get all resources. */
10633 
10634  if (openvas_connection_sendf (connection,
10635  "<modify_tag tag_id=\"%s\">"
10636  "<active>%s</active>"
10637  "</modify_tag>",
10638  tag_id,
10639  enable)
10640  == -1)
10641  {
10642  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10643  return gsad_message (credentials,
10644  "Internal error", __FUNCTION__, __LINE__,
10645  "An internal error occurred while modifying a tag. "
10646  "The tag is not modified. "
10647  "Diagnostics: Failure to send command to"
10648  " manager daemon.",
10649  "/omp?cmd=get_tasks", response_data);
10650  }
10651 
10652  entity = NULL;
10653  if (read_entity_and_text_c (connection, &entity, &response))
10654  {
10655  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10656  return gsad_message (credentials,
10657  "Internal error", __FUNCTION__, __LINE__,
10658  "An internal error occurred while modifying a tag. "
10659  "It is unclear whether the tag has been modified"
10660  " or not. "
10661  "Diagnostics: Failure to read response from"
10662  " manager daemon.",
10663  "/omp?cmd=get_tasks", response_data);
10664  }
10665 
10666  if (! omp_success (entity))
10667  set_http_status_from_entity (entity, response_data);
10668  html = response_from_entity (connection, credentials, params, entity,
10669  (no_redirect && strcmp (no_redirect, "0")),
10670  NULL, "get_tags",
10671  NULL, "get_tags",
10672  "Toggle Tag", response_data);
10673 
10674  free_entity (entity);
10675  g_free (response);
10676 
10677  return html;
10678 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

int token_user_remove ( const char *  token)

Remove a user from the session "database", releasing the user_t too.

Parameters
[in]tokenUser's token.
Returns
0 success, -1 error.

Definition at line 980 of file gsad.c.

References token_user(), and users.

Referenced by logout().

981 {
982  user_t *user;
983  if (token_user (token, &user))
984  return -1;
985  g_ptr_array_remove (users, (gpointer) user);
986  g_mutex_unlock (mutex);
987  return 0;
988 }
GPtrArray * users
User session data.
Definition: gsad.c:340
User information structure, for sessions.
Definition: gsad.c:416
int token_user(const gchar *token, user_t **user_return)
Find a user, given a token.
Definition: gsad.c:938

Here is the call graph for this function:

Here is the caller graph for this function:

char* upload_config_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload scan config 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
Result of XSL transformation.

Definition at line 11362 of file gsad_omp.c.

11364 {
11365  return upload_config (connection, credentials, params, NULL, response_data);
11366 }
char* upload_port_list_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload port list 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
Result of XSL transformation.

Definition at line 22428 of file gsad_omp.c.

22431 {
22432  return upload_port_list (connection, credentials, params, NULL,
22433  response_data);
22434 }
char* upload_report_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload report 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
Result of XSL transformation.

Definition at line 3837 of file gsad_omp.c.

3839 {
3840  return upload_report (connection, credentials, params, NULL, response_data);
3841 }
char* verify_agent_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify agent, get agents, XSL transform 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
Result of XSL transformation.

Definition at line 7454 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_value(), and set_http_status_from_entity().

7456 {
7457  gchar *html, *response;
7458  const char *agent_id;
7459  int ret;
7460  entity_t entity;
7461 
7462  agent_id = params_value (params, "agent_id");
7463  if (agent_id == NULL)
7464  {
7465  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
7466  return gsad_message (credentials,
7467  "Internal error", __FUNCTION__, __LINE__,
7468  "An internal error occurred while verifying an agent. "
7469  "Diagnostics: Required parameter was NULL.",
7470  "/omp?cmd=get_agents", response_data);
7471  }
7472  response = NULL;
7473  entity = NULL;
7474  ret = ompf (connection, credentials,
7475  &response,
7476  &entity,
7477  response_data,
7478  "<verify_agent agent_id=\"%s\" />",
7479  agent_id);
7480 
7481  switch (ret)
7482  {
7483  case 0:
7484  case -1:
7485  break;
7486  case 1:
7487  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7488  return gsad_message (credentials,
7489  "Internal error", __FUNCTION__, __LINE__,
7490  "An internal error occurred while verifying a agent. "
7491  "The agent was not verified. "
7492  "Diagnostics: Failure to send command to manager daemon.",
7493  "/omp?cmd=get_agents", response_data);
7494  case 2:
7495  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7496  return gsad_message (credentials,
7497  "Internal error", __FUNCTION__, __LINE__,
7498  "An internal error occurred while verifying a agent. "
7499  "It is unclear whether the agent was verified or not. "
7500  "Diagnostics: Failure to send command to manager daemon.",
7501  "/omp?cmd=get_agents", response_data);
7502  default:
7503  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7504  return gsad_message (credentials,
7505  "Internal error", __FUNCTION__, __LINE__,
7506  "An internal error occurred while verifying a agent. "
7507  "It is unclear whether the agent was verified or not. "
7508  "Diagnostics: Failure to send command to manager daemon.",
7509  "/omp?cmd=get_agents", response_data);
7510  }
7511 
7512  if (omp_success (entity))
7513  {
7514  html = next_page (connection, credentials, params, response,
7515  response_data);
7516  if (html == NULL)
7517  {
7518  free_entity (entity);
7519  g_free (response);
7520  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7521  return gsad_message (credentials,
7522  "Internal error", __FUNCTION__, __LINE__,
7523  "An internal error occurred while verifying a agent. "
7524  "It is unclear whether the agent was verified or not. "
7525  "Diagnostics: Failure to receive response from manager daemon.",
7526  "/omp?cmd=get_agents", response_data);
7527  }
7528  }
7529  else
7530  {
7531  set_http_status_from_entity (entity, response_data);
7532  html = get_agents (connection, credentials, params, response,
7533  response_data);
7534  }
7535  free_entity (entity);
7536  g_free (response);
7537  return html;
7538 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* verify_report_format_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify report format, get report formats, XSL transform 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
Result of XSL transformation.

Definition at line 18529 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_value(), and set_http_status_from_entity().

18532 {
18533  int ret;
18534  gchar *html, *response;
18535  const char *report_format_id;
18536  entity_t entity;
18537 
18538  report_format_id = params_value (params, "report_format_id");
18539  if (report_format_id == NULL)
18540  {
18541  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
18542  return gsad_message (credentials,
18543  "Internal error", __FUNCTION__, __LINE__,
18544  "An internal error occurred while verifying a report format. "
18545  "Diagnostics: Required parameter was NULL.",
18546  "/omp?cmd=get_report_formats", response_data);
18547  }
18548 
18549  /* Verify the report format. */
18550 
18551  response = NULL;
18552  entity = NULL;
18553  ret = ompf (connection, credentials,
18554  &response,
18555  &entity,
18556  response_data,
18557  "<verify_report_format report_format_id=\"%s\"/>",
18558  report_format_id);
18559 
18560  switch (ret)
18561  {
18562  case 0:
18563  case -1:
18564  break;
18565  case 1:
18566  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18567  return gsad_message (credentials,
18568  "Internal error", __FUNCTION__, __LINE__,
18569  "An internal error occurred while verifying a report format. "
18570  "The report format was not verified. "
18571  "Diagnostics: Failure to send command to manager daemon.",
18572  "/omp?cmd=get_report_formats", response_data);
18573  case 2:
18574  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18575  return gsad_message (credentials,
18576  "Internal error", __FUNCTION__, __LINE__,
18577  "An internal error occurred while verifying a report format. "
18578  "It is unclear whether the report format was verified or not. "
18579  "Diagnostics: Failure to send command to manager daemon.",
18580  "/omp?cmd=get_report_formats", response_data);
18581  default:
18582  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18583  return gsad_message (credentials,
18584  "Internal error", __FUNCTION__, __LINE__,
18585  "An internal error occurred while verifying a report format. "
18586  "It is unclear whether the report format was verified or not. "
18587  "Diagnostics: Failure to send command to manager daemon.",
18588  "/omp?cmd=get_report_formats", response_data);
18589  }
18590 
18591  if (omp_success (entity))
18592  {
18593  html = next_page (connection, credentials, params, response,
18594  response_data);
18595  if (html == NULL)
18596  {
18597  free_entity (entity);
18598  g_free (response);
18599  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18600  return gsad_message (credentials,
18601  "Internal error", __FUNCTION__, __LINE__,
18602  "An internal error occurred while verifying a report format. "
18603  "It is unclear whether the report format was verified or not. "
18604  "Diagnostics: Failure to receive response from manager daemon.",
18605  "/omp?cmd=get_report_formats", response_data);
18606  }
18607  }
18608  else
18609  {
18610  set_http_status_from_entity (entity, response_data);
18611  html = get_report_formats (connection, credentials, params, response,
18612  response_data);
18613  }
18614  free_entity (entity);
18615  g_free (response);
18616  return html;
18617 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711

Here is the call graph for this function:

char* verify_scanner_omp ( openvas_connection_t *  connection,
credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify scanner, get scanners, XSL transform 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
Result of XSL transformation.

Definition at line 16792 of file gsad_omp.c.

References CHECK_PARAM, gsad_message(), cmd_response_data_t::http_status_code, params_value(), and set_http_status_from_entity().

16795 {
16796  gchar *html, *response;
16797  const char *scanner_id, *next;
16798  int ret;
16799  entity_t entity;
16800 
16801  scanner_id = params_value (params, "scanner_id");
16802  CHECK_PARAM (scanner_id, "Verify Scanner", get_scanners);
16803 
16804 
16805  ret = ompf (connection, credentials,
16806  &response,
16807  &entity,
16808  response_data,
16809  "<verify_scanner scanner_id=\"%s\"/>",
16810  scanner_id);
16811 
16812  switch (ret)
16813  {
16814  case 0:
16815  case -1:
16816  break;
16817  case 1:
16818  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16819  return gsad_message (credentials,
16820  "Internal error", __FUNCTION__, __LINE__,
16821  "An internal error occurred while verifying a scanner. "
16822  "The scanner was not verified. "
16823  "Diagnostics: Failure to send command to manager daemon.",
16824  "/omp?cmd=get_scanners", response_data);
16825  case 2:
16826  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16827  return gsad_message (credentials,
16828  "Internal error", __FUNCTION__, __LINE__,
16829  "An internal error occurred while verifying a scanner. "
16830  "It is unclear whether the scanner was verified or not. "
16831  "Diagnostics: Failure to send command to manager daemon.",
16832  "/omp?cmd=get_scanners", response_data);
16833  default:
16834  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16835  return gsad_message (credentials,
16836  "Internal error", __FUNCTION__, __LINE__,
16837  "An internal error occurred while verifying a scanner. "
16838  "It is unclear whether the scanner was verified or not. "
16839  "Diagnostics: Failure to send command to manager daemon.",
16840  "/omp?cmd=get_scanners", response_data);
16841  }
16842 
16843  if (omp_success (entity))
16844  {
16845  html = next_page (connection, credentials, params, response,
16846  response_data);
16847  if (html == NULL)
16848  {
16849  free_entity (entity);
16850  g_free (response);
16851  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16852  return gsad_message (credentials,
16853  "Internal error", __FUNCTION__, __LINE__,
16854  "An internal error occurred while verifying a scanner. "
16855  "It is unclear whether the scanner was verified or not. "
16856  "Diagnostics: Failure to receive response from manager daemon.",
16857  "/omp?cmd=get_scanners", response_data);
16858  }
16859  }
16860  else
16861  {
16862  set_http_status_from_entity (entity, response_data);
16863  next = params_value (params, "next");
16864  if (next && !strcmp (next, "get_scanner"))
16865  html = get_scanner (connection, credentials, params, response,
16866  response_data);
16867  else
16868  html = get_scanners (connection, credentials, params, response,
16869  response_data);
16870  }
16871 
16872  free_entity (entity);
16873  g_free (response);
16874  return html;
16875 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:885
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:467
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:711
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1174

Here is the call graph for this function:

char* wizard_get_omp ( openvas_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
Result of XSL transformation.

Definition at line 26327 of file gsad_omp.c.

26329 {
26330  return wizard_get (connection, credentials, params, NULL, response_data);
26331 }
char* wizard_omp ( openvas_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
Result of XSL transformation.

Definition at line 26201 of file gsad_omp.c.

References gsad_message(), cmd_response_data_t::http_status_code, params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), and param::value.

26203 {
26204  return wizard (connection, credentials, params, NULL, response_data);
26205 }

Here is the call graph for this function:

Variable Documentation

gchar* manager_address = NULL

The address the manager is on.

Definition at line 96 of file gsad_omp.c.

Referenced by authenticate_omp(), manager_connect(), and omp_init().

int manager_port = 9390

The port the manager is on.

Definition at line 101 of file gsad_omp.c.

Referenced by authenticate_omp(), manager_connect(), and omp_init().

int manager_use_tls = 0

Whether to use TLS for Manager connections.

Definition at line 91 of file gsad_omp.c.

Referenced by omp_init(), and openvas_connection_open().