Greenbone Security Assistant  8.0.0
gsad_gmp.h File Reference

Headers for GSA's GMP communication module. More...

#include "gsad_cmd.h"
#include "gsad_content_type.h"
#include "gsad_http.h"
#include "gsad_user.h"
#include <glib.h>
#include <gvm/util/serverutils.h>
Include dependency graph for gsad_gmp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gmp_init (const gchar *, const gchar *, int)
 Init the GSA GMP library. More...
 
int manager_connect (credentials_t *, gvm_connection_t *, cmd_response_data_t *)
 Connect to Greenbone Vulnerability Manager daemon. More...
 
char * clone_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Clone a resource, envelope the result. More...
 
char * create_report_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Returns page to create a new container task. More...
 
char * import_report_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Import report, get all reports, envelope the result. More...
 
char * create_container_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a container task, serve next page. More...
 
char * create_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a task, get all tasks, envelope the result. More...
 
char * delete_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a task, get all tasks, envelope the result. More...
 
char * save_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save task, get next page, envelope the result. More...
 
char * save_container_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save container task, get next page, envelope the result. More...
 
char * resume_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Resume a task, get all tasks, envelope the result. More...
 
char * start_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Start a task, get all tasks, envelope the result. More...
 
char * stop_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Stop a task, get all tasks, envelope the result. More...
 
char * move_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Reassign a task to a new GMP slave. More...
 
char * get_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a task, envelope the result. More...
 
char * get_tasks_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all tasks, envelope the result. More...
 
char * get_tasks_chart_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * export_task_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a task. More...
 
char * export_tasks_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of tasks. More...
 
char * delete_report_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete report, get task status, envelope the result. More...
 
char * get_report_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a report and envelope the result. More...
 
char * get_reports_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all reports, envelope the result. More...
 
char * report_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Run alert for a report. More...
 
char * download_ssl_cert (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get an SSL Certificate. More...
 
char * download_ca_pub (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a Scanner's CA Certificate. More...
 
char * download_key_pub (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a Scanner's Certificate. More...
 
char * export_result_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a result. More...
 
char * export_results_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of results. More...
 
char * get_result_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one result, envelope the result. More...
 
char * get_results_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all results, envelope the result. More...
 
char * new_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Returns page to create a new alert. More...
 
char * create_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create an alert, get all alerts, envelope the result. More...
 
char * delete_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete an alert, get all alerts, envelope the result. More...
 
char * test_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Test an alert, get all alerts envelope the result. More...
 
char * get_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one alert, envelope the result. More...
 
char * edit_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Setup edit_alert XML, envelope the result. More...
 
char * save_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify an alert, get all alerts, envelope the result. More...
 
char * get_alerts_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all alerts, envelope the result. More...
 
char * export_alert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export an alert. More...
 
char * export_alerts_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of alerts. More...
 
int download_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, char **, char **, cmd_response_data_t *)
 Export a Credential in a defined format. More...
 
char * export_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a Credential. More...
 
char * export_credentials_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of Credentials. More...
 
char * get_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one credential, envelope the result. More...
 
char * get_credentials_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one or all credentials, envelope the result. More...
 
char * create_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a credential, get all credentials, envelope result. More...
 
char * delete_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete credential, get all credentials, envelope result. More...
 
char * save_credential_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save credential, get next page, envelope the result. More...
 
char * get_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one agent, envelope the result. More...
 
char * get_agents_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all agents, envelope the result. More...
 
int download_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, char **, char **, cmd_response_data_t *)
 Get an agent, envelope the result. More...
 
char * save_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a agent, get all agents, envelope the result. More...
 
char * create_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create an agent, get all agents, envelope result. More...
 
char * delete_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete agent, get all agents, envelope result. More...
 
char * verify_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Verify agent, get agents, envelope the result. More...
 
char * export_agent_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a agent. More...
 
char * export_agents_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of agents. More...
 
char * get_aggregate_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get an aggregate of resources. More...
 
char * create_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a scanner, get all scanners, envelope the result. More...
 
char * get_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one scanner, envelope the result. More...
 
char * get_scanners_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all scanners, envelope the result. More...
 
char * save_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save scanner, get next page, envelope the result. More...
 
char * delete_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a scanner, get all scanners, envelope the result. More...
 
char * export_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a scanner. More...
 
char * export_scanners_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of scanners. More...
 
char * verify_scanner_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Verify scanner, get scanners, envelope the result. More...
 
char * create_schedule_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a schedule, get all schedules, envelope the result. More...
 
char * delete_schedule_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a schedule, get all schedules, envelope the result. More...
 
char * get_schedule_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one schedule, envelope the result. More...
 
char * get_schedules_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all schedules, envelope the result. More...
 
char * save_schedule_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save schedule, get next page, envelope the result. More...
 
char * export_schedule_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a schedule. More...
 
char * export_schedules_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of schedules. More...
 
char * create_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a tag, envelope the result. More...
 
char * create_tags_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * delete_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete note, get next page, envelope the result. More...
 
char * export_tags_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of tags. More...
 
char * export_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a tag. More...
 
char * get_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one tag, envelope the result. More...
 
char * get_tags_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all tags, envelope the result. More...
 
char * save_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a tag, get all tags, envelope the result. More...
 
char * toggle_tag_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Set tag enabled status. More...
 
char * get_target_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one target, envelope the result. More...
 
char * get_targets_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all targets, envelope the result. More...
 
char * export_targets_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of targets. More...
 
char * export_target_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a target. More...
 
char * create_target_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a target, get all targets, envelope the result. More...
 
char * delete_target_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a target, get all targets, envelope the result. More...
 
char * save_target_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a target, get all targets, envelope the result. More...
 
char * edit_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a config, envelope the result. More...
 
char * get_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a config, envelope the result. More...
 
char * get_configs_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all scan configs, envelope the result. More...
 
char * save_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save details of an NVT for a config and return the next page. More...
 
char * edit_config_family_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get details of a family for editing a config, envelope result. More...
 
char * get_config_family_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get details of a family for a config, envelope the result. More...
 
char * save_config_family_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get details of an NVT for a config, envelope the result. More...
 
char * edit_config_nvt_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Edit details of an NVT for a config, envelope the result. More...
 
char * get_config_nvt_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get details of an NVT for a config, envelope the result. More...
 
char * save_config_nvt_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save NVT prefs for a config, get NVT details, envelope result. More...
 
char * create_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create config, get all configs, envelope the result. More...
 
char * import_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Import config, get all configs, envelope the result. More...
 
char * delete_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete config, get all configs, envelope the result. More...
 
char * sync_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Sync config, get configs, envelope the result. More...
 
char * export_config_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a config. More...
 
char * export_configs_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of scan configs. More...
 
char * export_preference_file_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a file preference. More...
 
char * export_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a report format. More...
 
char * export_report_formats_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of Report Formats. More...
 
char * create_group_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a group, get all groups, envelope the result. More...
 
char * delete_group_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a group, get all groups, envelope the result. More...
 
char * export_group_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a group. More...
 
char * export_groups_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of groups. More...
 
char * get_group_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one group, envelope the result. More...
 
char * get_groups_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all groups, envelope the result. More...
 
char * save_group_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a group, return the next page. More...
 
char * get_notes_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all notes, envelope the result. More...
 
char * get_note_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get a note, envelope the result. More...
 
char * create_note_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a note, get report, envelope the result. More...
 
char * delete_note_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete note, get next page, envelope the result. More...
 
char * save_note_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save note, get next page, envelope the result. More...
 
char * export_note_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a note. More...
 
char * export_notes_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of notes. More...
 
char * create_permission_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a permission, get all permissions, envelope the result. More...
 
char * create_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create multiple permission, get next page, envelope the result. More...
 
char * delete_permission_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a permission, get all permissions, envelope the result. More...
 
char * export_permission_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a permission. More...
 
char * export_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of permissions. More...
 
char * get_permission_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one permission, envelope the result. More...
 
char * get_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all permissions, envelope the result. More...
 
char * save_permission_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a permission, get all permissions, envelope the result. More...
 
char * create_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a port list, get all port lists, envelope the result. More...
 
char * create_port_range_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Add a range to a port list, envelope the result. More...
 
char * get_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one port_list, envelope the result. More...
 
char * save_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a port list, get all port list, envelope the result. More...
 
char * get_port_lists_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all port_lists, envelope the result. More...
 
char * delete_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a port list, get all port lists, envelope the result. More...
 
char * delete_port_range_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a port range, get the port list, envelope the result. More...
 
char * export_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a Port List. More...
 
char * export_port_lists_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of Port Lists. More...
 
char * import_port_list_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Import port list, get all port_lists, envelope the result. More...
 
char * create_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a role, get all roles, envelope the result. More...
 
char * delete_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a role, get all roles, envelope the result. More...
 
char * edit_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Setup edit_role XML, envelope the result. More...
 
char * export_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a role. More...
 
char * export_roles_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of roles. More...
 
char * get_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one role, envelope the result. More...
 
char * get_roles_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all roles, envelope the result. More...
 
char * save_role_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a role, return the next page. More...
 
char * get_overrides_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all overrides, envelope the result. More...
 
char * get_override_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get an override, envelope the result. More...
 
char * create_override_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create an override, get report, envelope the result. More...
 
char * delete_override_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete override, get next page, envelope the result. More...
 
char * save_override_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save override, get next page, envelope the result. More...
 
char * export_override_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export an override. More...
 
char * export_overrides_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of overrides. More...
 
char * get_slave_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * get_slaves_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * create_slave_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * save_slave_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * delete_slave_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * export_slave_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * export_slaves_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * get_system_reports_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all system reports, envelope the result. More...
 
char * get_system_report_gmp (gvm_connection_t *, credentials_t *, const char *, params_t *, cmd_response_data_t *)
 Return system report image. More...
 
char * get_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one report format, envelope the result. More...
 
char * get_report_formats_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all Report Formats, envelope the result. More...
 
char * delete_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete report format, get report formats, envelope the result. More...
 
char * import_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Import report format, get all report formats, envelope result. More...
 
char * save_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save report_format, get next page, envelope the result. More...
 
char * verify_report_format_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Verify report format, get report formats, envelope the result. More...
 
char * get_feeds_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get descriptions of the feeds connected to the manager. More...
 
char * sync_feed_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Synchronize with an NVT feed and envelope the result. More...
 
char * sync_scap_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Synchronize with a SCAP feed and envelope the result. More...
 
char * sync_cert_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Synchronize with a CERT feed and envelope the result. More...
 
char * create_filter_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a filter, get all filters, envelope the result. More...
 
char * delete_filter_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a filter, get all filters, envelope the result. More...
 
char * export_filter_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a filter. More...
 
char * export_filters_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of filters. More...
 
char * get_filter_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one filter, envelope the result. More...
 
char * get_filters_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all filters, envelope the result. More...
 
char * save_filter_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a filter, get all filters, envelope the result. More...
 
char * create_user_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a user, get all users, envelope the result. More...
 
char * delete_user_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a user, get all users, envelope the result. More...
 
char * export_user_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a user. More...
 
char * export_users_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of users. More...
 
char * get_user_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get one user, envelope the result. More...
 
char * get_users_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all users, envelope the result. More...
 
char * save_user_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a user, get all users, envelope the result. More...
 
char * get_vulns_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get multiple vulns, envelope the result. More...
 
char * save_auth_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save authentication settings. More...
 
char * bulk_delete_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete multiple resources, get next page, envelope the result. More...
 
char * bulk_export_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export multiple resources. More...
 
char * run_wizard_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Run a wizard and envelope the result. More...
 
char * wizard_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Returns a wizard page. More...
 
char * wizard_get_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Returns a wizard_get page. More...
 
char * cvss_calculator (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * get_trash_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *)
 Get all trash, envelope the result. More...
 
char * restore_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Restore a resource, get all trash, envelope the result. More...
 
char * delete_from_trash_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a resource from the trashcan. More...
 
char * empty_trashcan_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Empty the trashcan, get all trash, envelope the result. More...
 
char * get_settings_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all user defined settings. More...
 
char * save_my_settings_gmp (gvm_connection_t *, credentials_t *, params_t *, const gchar *, cmd_response_data_t *)
 Returns page with user's settings, for editing. More...
 
char * get_setting_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * save_setting_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Save user setting. More...
 
char * auth_settings_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * get_info_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get info, envelope the result. More...
 
char * get_info (gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
 Requests SecInfo. More...
 
char * create_asset_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create an asset, get report, envelope the result. More...
 
char * create_host_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a host, serve next page. More...
 
char * delete_asset_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete an asset, go to the next page. More...
 
char * save_asset_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify an asset, get all assets, envelope the result. More...
 
char * get_assets_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get assets, envelope the result. More...
 
char * get_asset_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get asset, envelope the result. More...
 
char * export_asset_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export an asset. More...
 
char * export_assets_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Export a list of assets. More...
 
char * get_assets_chart_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * get_tickets_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get all tickets, envelope the result. More...
 
char * get_ticket_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get single tickets, envelope the result. More...
 
char * create_ticket_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Create a ticket. More...
 
char * save_ticket_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Modify a ticket. More...
 
char * delete_ticket_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Delete a ticket. More...
 
char * renew_session_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 
char * ping_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *)
 Get assets, envelope the result. More...
 
int login (http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
 Login and create a session. More...
 

Detailed Description

Headers for GSA's GMP communication module.

Definition in file gsad_gmp.h.

Function Documentation

◆ auth_settings_gmp()

char* auth_settings_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

Definition at line 17238 of file gsad_gmp.c.

17240 {
17241  GString *xml;
17242  gchar *buf;
17243  const char *name;
17244 
17245  name = params_value (params, "name");
17246 
17247  CHECK_VARIABLE_INVALID (name, "Auth settings");
17248 
17249  xml = g_string_new ("");
17250  buf = g_markup_printf_escaped ("<auth_settings name=\"%s\">", name);
17251  g_string_append (xml, buf);
17252  g_free (buf);
17253 
17254  if (command_enabled (credentials, "DESCRIBE_AUTH"))
17255  {
17256  gchar *response = NULL;
17257  entity_t entity = NULL;
17258 
17259  switch (gmp (connection, credentials, &response, &entity, response_data,
17260  "<describe_auth/>"))
17261  {
17262  case 0:
17263  case -1:
17264  break;
17265  case 1:
17266  cmd_response_data_set_status_code (response_data,
17267  MHD_HTTP_INTERNAL_SERVER_ERROR);
17268  return gsad_message (
17269  credentials, "Internal error", __FUNCTION__, __LINE__,
17270  "An internal error occurred getting the auth list. "
17271  "Diagnostics: Failure to send command to manager daemon.",
17272  response_data);
17273  case 2:
17274  cmd_response_data_set_status_code (response_data,
17275  MHD_HTTP_INTERNAL_SERVER_ERROR);
17276  return gsad_message (
17277  credentials, "Internal error", __FUNCTION__, __LINE__,
17278  "An internal error occurred getting the auth list. "
17279  "Diagnostics: Failure to receive response from manager daemon.",
17280  response_data);
17281  default:
17282  cmd_response_data_set_status_code (response_data,
17283  MHD_HTTP_INTERNAL_SERVER_ERROR);
17284  return gsad_message (
17285  credentials, "Internal error", __FUNCTION__, __LINE__,
17286  "An internal error occurred getting the auth list. "
17287  "Diagnostics: Internal Error.",
17288  response_data);
17289  }
17290 
17291  g_string_append (xml, response);
17292  free_entity (entity);
17293  g_free (response);
17294  }
17295 
17296  g_string_append (xml, "</auth_settings>");
17297 
17298  return envelope_gmp (connection, credentials, params,
17299  g_string_free (xml, FALSE), response_data);
17300 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA GMP library.
Definition: gsad_gmp.c:352
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ bulk_delete_gmp()

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

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

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

Definition at line 18260 of file gsad_gmp.c.

18262 {
18263  const char *type;
18264  GString *commands_xml;
18265  params_t *selected_ids;
18266  params_iterator_t iter;
18267  param_t *param;
18268  gchar *param_name;
18269  gchar *html, *response;
18270  entity_t entity;
18271  gchar *extra_attribs;
18272 
18273  type = params_value (params, "resource_type");
18274  if (type == NULL)
18275  {
18276  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
18277  return gsad_message (
18278  credentials, "Internal error", __FUNCTION__, __LINE__,
18279  "An internal error occurred while deleting resources. "
18280  "The resources were not deleted. "
18281  "Diagnostics: Required parameter 'resource_type' was NULL.",
18282  response_data);
18283  }
18284 
18285  /* Extra attributes */
18286  extra_attribs = NULL;
18287 
18288  /* Inheritor of user's resource */
18289  if (strcmp (type, "user") == 0)
18290  {
18291  const char *inheritor_id;
18292  inheritor_id = params_value (params, "inheritor_id");
18293  if (inheritor_id)
18294  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
18295  }
18296 
18297  commands_xml = g_string_new ("<commands>");
18298 
18299  selected_ids = params_values (params, "bulk_selected:");
18300  if (selected_ids)
18301  {
18302  params_iterator_init (&iter, selected_ids);
18303  while (params_iterator_next (&iter, &param_name, &param))
18304  {
18305  xml_string_append (commands_xml,
18306  "<delete_%s %s_id=\"%s\" ultimate=\"0\"", type,
18307  type, param_name);
18308  if (extra_attribs)
18309  g_string_append_printf (commands_xml, " %s/>", extra_attribs);
18310  else
18311  g_string_append (commands_xml, "/>");
18312  }
18313  }
18314 
18315  g_string_append (commands_xml, "</commands>");
18316 
18317  /* Delete the resources and get all resources. */
18318 
18319  if (gvm_connection_sendf_xml (connection, commands_xml->str) == -1)
18320  {
18321  g_string_free (commands_xml, TRUE);
18322  cmd_response_data_set_status_code (response_data,
18323  MHD_HTTP_INTERNAL_SERVER_ERROR);
18324  return gsad_message (
18325  credentials, "Internal error", __FUNCTION__, __LINE__,
18326  "An internal error occurred while deleting resources. "
18327  "The resources were not deleted. "
18328  "Diagnostics: Failure to send command to manager daemon.",
18329  response_data);
18330  }
18331  g_string_free (commands_xml, TRUE);
18332 
18333  entity = NULL;
18334  if (read_entity_and_text_c (connection, &entity, &response))
18335  {
18336  cmd_response_data_set_status_code (response_data,
18337  MHD_HTTP_INTERNAL_SERVER_ERROR);
18338  return gsad_message (
18339  credentials, "Internal error", __FUNCTION__, __LINE__,
18340  "An internal error occurred while deleting resources. "
18341  "It is unclear whether the resources have been deleted or not. "
18342  "Diagnostics: Failure to read response from manager daemon.",
18343  response_data);
18344  }
18345 
18346  /* Cleanup, and return transformed XML. */
18347  html = response_from_entity (connection, credentials, params, entity,
18348  "Bulk Delete", response_data);
18349  g_free (response);
18350  free_entity (entity);
18351 
18352  return html;
18353 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ bulk_export_gmp()

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

Export multiple resources.

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

Definition at line 18366 of file gsad_gmp.c.

18368 {
18369  const gchar *type, *filter, *bulk_select;
18370  gchar *param_name;
18371  GString *bulk_string;
18372  params_t *selected_ids;
18373  params_iterator_t iter;
18374  param_t *param;
18375 
18376  type = params_value (params, "resource_type");
18377  filter = params_value (params, "filter");
18378  bulk_select = params_value (params, "bulk_select");
18379 
18380  CHECK_VARIABLE_INVALID (type, "Bulk Export")
18381  CHECK_VARIABLE_INVALID (bulk_select, "Bulk Export")
18382 
18383  if (bulk_select && str_equal (bulk_select, "1"))
18384  {
18385  bulk_string = g_string_new ("first=1 rows=-1 uuid=");
18386 
18387  selected_ids = params_values (params, "bulk_selected:");
18388  if (selected_ids)
18389  {
18390  params_iterator_init (&iter, selected_ids);
18391  while (params_iterator_next (&iter, &param_name, &param))
18392  {
18393  xml_string_append (bulk_string, " uuid=%s", param_name);
18394  }
18395  }
18396  }
18397  else
18398  {
18399  bulk_string = g_string_new (filter ?: "");
18400  }
18401 
18402  params_add (params, "filter", g_string_free (bulk_string, FALSE));
18403 
18404  return export_many (connection, type, credentials, params, response_data);
18405 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738
Request parameter.
Definition: gsad_params.h:38
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ clone_gmp()

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

Clone a resource, envelope the result.

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

Definition at line 6868 of file gsad_gmp.c.

6870 {
6871  gchar *html, *response;
6872  const char *id, *type, *alterable;
6873  entity_t entity;
6874 
6875  id = params_value (params, "id");
6876  type = params_value (params, "resource_type");
6877  alterable = params_value (params, "alterable");
6878 
6879  CHECK_VARIABLE_INVALID (id, "Clone");
6880  CHECK_VARIABLE_INVALID (type, "Clone");
6881 
6882  /* Clone the resource. */
6883 
6884  if (alterable && strcmp (alterable, "0"))
6885  {
6886  if (gvm_connection_sendf (connection,
6887  "<create_%s>"
6888  "<copy>%s</copy>"
6889  "<alterable>1</alterable>"
6890  "</create_%s>",
6891  type, id, type)
6892  == -1)
6893  {
6894  cmd_response_data_set_status_code (response_data,
6895  MHD_HTTP_INTERNAL_SERVER_ERROR);
6896  return gsad_message (
6897  credentials, "Internal error", __FUNCTION__, __LINE__,
6898  "An internal error occurred while cloning a resource. "
6899  "The resource was not cloned. "
6900  "Diagnostics: Failure to send command to manager daemon.",
6901  response_data);
6902  }
6903  }
6904  else if (gvm_connection_sendf (connection,
6905  "<create_%s>"
6906  "<copy>%s</copy>"
6907  "</create_%s>",
6908  type, id, type)
6909  == -1)
6910  {
6911  cmd_response_data_set_status_code (response_data,
6912  MHD_HTTP_INTERNAL_SERVER_ERROR);
6913  return gsad_message (
6914  credentials, "Internal error", __FUNCTION__, __LINE__,
6915  "An internal error occurred while cloning a resource. "
6916  "The resource was not cloned. "
6917  "Diagnostics: Failure to send command to manager daemon.",
6918  response_data);
6919  }
6920 
6921  entity = NULL;
6922  if (read_entity_and_text_c (connection, &entity, &response))
6923  {
6924  cmd_response_data_set_status_code (response_data,
6925  MHD_HTTP_INTERNAL_SERVER_ERROR);
6926  return gsad_message (
6927  credentials, "Internal error", __FUNCTION__, __LINE__,
6928  "An internal error occurred while cloning a resource. "
6929  "It is unclear whether the resource has been cloned or not. "
6930  "Diagnostics: Failure to read response from manager daemon.",
6931  response_data);
6932  }
6933 
6934  /* Cleanup, and return next page. */
6935  html = response_from_entity (connection, credentials, params, entity, "Clone",
6936  response_data);
6937 
6938  free_entity (entity);
6939  g_free (response);
6940 
6941  return html;
6942 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_agent_gmp()

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

Create an agent, get all agents, envelope result.

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

Definition at line 4436 of file gsad_gmp.c.

4438 {
4439  entity_t entity;
4440  gchar *response, *html;
4441  const char *name, *comment, *installer, *installer_filename, *installer_sig;
4442  const char *howto_install, *howto_use;
4443  int installer_size, installer_sig_size, howto_install_size, howto_use_size;
4444  int ret;
4445  gchar *name_escaped, *comment_escaped;
4446  gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
4447  gchar *command;
4448 
4449  name = params_value (params, "name");
4450  comment = params_value (params, "comment");
4451  installer = params_value (params, "installer");
4452  installer_filename = params_filename (params, "installer");
4453  installer_size = params_value_size (params, "installer");
4454  installer_sig = params_value (params, "installer_sig");
4455  installer_sig_size = params_value_size (params, "installer_sig");
4456  howto_install = params_value (params, "howto_install");
4457  howto_install_size = params_value_size (params, "howto_install");
4458  howto_use = params_value (params, "howto_use");
4459  howto_use_size = params_value_size (params, "howto_use");
4460 
4461  CHECK_VARIABLE_INVALID (name, "Create Agent");
4462  CHECK_VARIABLE_INVALID (comment, "Create Agent");
4463 
4464  /* Create the agent. */
4465 
4466  installer_64 = (installer_size > 0)
4467  ? g_base64_encode ((guchar *) installer, installer_size)
4468  : g_strdup ("");
4469 
4470  installer_sig_64 =
4471  (installer_sig_size > 0)
4472  ? g_base64_encode ((guchar *) installer_sig, installer_sig_size)
4473  : g_strdup ("");
4474 
4475  howto_install_64 =
4476  (howto_install_size > 0)
4477  ? g_base64_encode ((guchar *) howto_install, howto_install_size)
4478  : g_strdup ("");
4479 
4480  howto_use_64 = (howto_use_size > 0)
4481  ? g_base64_encode ((guchar *) howto_use, howto_use_size)
4482  : g_strdup ("");
4483 
4484  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
4485  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
4486 
4487  command = g_strdup_printf ("<create_agent>"
4488  "<name>%s</name>"
4489  "%s%s%s"
4490  "<installer>"
4491  "%s"
4492  "<signature>%s</signature>"
4493  "<filename>%s</filename>"
4494  "</installer>"
4495  "<howto_install>%s</howto_install>"
4496  "<howto_use>%s</howto_use>"
4497  "</create_agent>",
4498  name_escaped, comment_escaped ? "<comment>" : "",
4499  comment_escaped ? comment_escaped : "",
4500  comment_escaped ? "</comment>" : "", installer_64,
4501  installer_sig_64,
4502  installer_filename ? installer_filename : "",
4503  howto_install_64, howto_use_64);
4504 
4505  ret =
4506  gmp (connection, credentials, &response, &entity, response_data, command);
4507  g_free (command);
4508 
4509  g_free (installer_64);
4510  g_free (howto_install_64);
4511  g_free (howto_use_64);
4512  g_free (name_escaped);
4513  g_free (comment_escaped);
4514 
4515  switch (ret)
4516  {
4517  case 0:
4518  break;
4519  case -1:
4520  /* 'gmp' set response. */
4521  return response;
4522  case 1:
4523  cmd_response_data_set_status_code (response_data,
4524  MHD_HTTP_INTERNAL_SERVER_ERROR);
4525  return gsad_message (
4526  credentials, "Internal error", __FUNCTION__, __LINE__,
4527  "An internal error occurred while creating a new agent. "
4528  "No new agent was created. "
4529  "Diagnostics: Failure to send command to manager daemon.",
4530  response_data);
4531  case 2:
4532  cmd_response_data_set_status_code (response_data,
4533  MHD_HTTP_INTERNAL_SERVER_ERROR);
4534  return gsad_message (
4535  credentials, "Internal error", __FUNCTION__, __LINE__,
4536  "An internal error occurred while creating a new agent. "
4537  "It is unclear whether the agent has been created or not. "
4538  "Diagnostics: Failure to receive response from manager daemon.",
4539  response_data);
4540  default:
4541  cmd_response_data_set_status_code (response_data,
4542  MHD_HTTP_INTERNAL_SERVER_ERROR);
4543  return gsad_message (
4544  credentials, "Internal error", __FUNCTION__, __LINE__,
4545  "An internal error occurred while creating a new agent. "
4546  "It is unclear whether the agent has been created or not. "
4547  "Diagnostics: Internal Error.",
4548  response_data);
4549  }
4550 
4551  if (entity_attribute (entity, "id"))
4552  params_add (params, "agent_id", entity_attribute (entity, "id"));
4553  html = response_from_entity (connection, credentials, params, entity,
4554  "Create Agent", response_data);
4555  free_entity (entity);
4556  g_free (response);
4557  return html;
4558 }
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
Definition: gsad_base.c:237
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
const char * params_filename(params_t *params, const char *name)
Get filename of param.
Definition: gsad_base.c:271
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_alert_gmp()

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

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

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

Definition at line 5688 of file gsad_gmp.c.

5690 {
5691  int ret;
5692  gchar *html, *response;
5693  const char *name, *comment, *active, *condition, *event, *method, *filter_id;
5694  params_t *method_data, *event_data, *condition_data, *report_formats;
5695  entity_t entity;
5696  GString *xml;
5697 
5698  name = params_value (params, "name");
5699  comment = params_value (params, "comment");
5700  active = params_value (params, "active");
5701  condition = params_value (params, "condition");
5702  event = params_value (params, "event");
5703  method = params_value (params, "method");
5704  filter_id = params_value (params, "filter_id");
5705 
5706  CHECK_VARIABLE_INVALID (name, "Create Alert");
5707  CHECK_VARIABLE_INVALID (active, "Create Alert");
5708  CHECK_VARIABLE_INVALID (comment, "Create Alert");
5709  CHECK_VARIABLE_INVALID (condition, "Create Alert");
5710  CHECK_VARIABLE_INVALID (event, "Create Alert");
5711  CHECK_VARIABLE_INVALID (method, "Create Alert");
5712  CHECK_VARIABLE_INVALID (filter_id, "Create Alert");
5713 
5714  /* Create the alert. */
5715 
5716  method_data = params_values (params, "method_data:");
5717  event_data = params_values (params, "event_data:");
5718  condition_data = params_values (params, "condition_data:");
5719  report_formats = params_values (params, "report_format_ids:");
5720 
5721  xml = g_string_new ("");
5722 
5723  if (str_equal (event, EVENT_TYPE_NEW_SECINFO) && event_data)
5724  {
5725  params_iterator_t iter;
5726  char *name;
5727  param_t *param;
5728 
5729  params_iterator_init (&iter, event_data);
5730  while (params_iterator_next (&iter, &name, &param))
5731  if (str_equal (name, "feed_event") && param->value
5732  && str_equal (param->value, "updated"))
5733  {
5735  break;
5736  }
5737  }
5738 
5739  xml_string_append (xml,
5740  "<create_alert>"
5741  "<name>%s</name>"
5742  "<filter id=\"%s\"/>"
5743  "<active>%s</active>"
5744  "<comment>%s</comment>"
5745  "<event>%s",
5746  name, filter_id, active, comment ? comment : "", event);
5747 
5748  append_alert_event_data (xml, event_data, event);
5749 
5750  xml_string_append (xml,
5751  "</event>"
5752  "<method>%s",
5753  method);
5754 
5755  append_alert_method_data (xml, method_data, method, report_formats);
5756 
5757  xml_string_append (xml,
5758  "</method>"
5759  "<condition>%s",
5760  condition);
5761 
5762  append_alert_condition_data (xml, condition_data, condition);
5763 
5764  xml_string_append (xml, "</condition>"
5765  "</create_alert>");
5766 
5767  ret =
5768  gmp (connection, credentials, &response, &entity, response_data, xml->str);
5769  g_string_free (xml, TRUE);
5770  switch (ret)
5771  {
5772  case 0:
5773  case -1:
5774  break;
5775  case 1:
5776  cmd_response_data_set_status_code (response_data,
5777  MHD_HTTP_INTERNAL_SERVER_ERROR);
5778  return gsad_message (
5779  credentials, "Internal error", __FUNCTION__, __LINE__,
5780  "An internal error occurred while creating a new alert. "
5781  "No new alert was created. "
5782  "Diagnostics: Failure to send command to manager daemon.",
5783  response_data);
5784  case 2:
5785  cmd_response_data_set_status_code (response_data,
5786  MHD_HTTP_INTERNAL_SERVER_ERROR);
5787  return gsad_message (
5788  credentials, "Internal error", __FUNCTION__, __LINE__,
5789  "An internal error occurred while creating a new alert. "
5790  "It is unclear whether the alert has been created or not. "
5791  "Diagnostics: Failure to receive response from manager daemon.",
5792  response_data);
5793  default:
5794  cmd_response_data_set_status_code (response_data,
5795  MHD_HTTP_INTERNAL_SERVER_ERROR);
5796  return gsad_message (
5797  credentials, "Internal error", __FUNCTION__, __LINE__,
5798  "An internal error occurred while creating a new alert. "
5799  "It is unclear whether the alert has been created or not. "
5800  "Diagnostics: Internal Error.",
5801  response_data);
5802  }
5803 
5804  if (entity_attribute (entity, "id"))
5805  params_add (params, "alert_id", entity_attribute (entity, "id"));
5806  html = response_from_entity (connection, credentials, params, entity,
5807  "Create Alert", response_data);
5808  free_entity (entity);
5809  g_free (response);
5810  return html;
5811 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
#define EVENT_TYPE_UPDATED_SECINFO
Definition: gsad_gmp.c:5429
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
static void append_alert_condition_data(GString *xml, params_t *data, const char *condition)
Send condition data for an alert.
Definition: gsad_gmp.c:5472
#define EVENT_TYPE_NEW_SECINFO
Definition: gsad_gmp.c:5428
static void append_alert_event_data(GString *xml, params_t *data, const char *event)
Send event data for an alert.
Definition: gsad_gmp.c:5444
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static void append_alert_method_data(GString *xml, params_t *data, const char *method, params_t *report_formats)
Send method data for an alert.
Definition: gsad_gmp.c:5522
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_asset_gmp()

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

Create an asset, get report, envelope the result.

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

Definition at line 18674 of file gsad_gmp.c.

18676 {
18677  char *ret;
18678  gchar *response;
18679  const char *report_id, *filter;
18680  entity_t entity;
18681 
18682  report_id = params_value (params, "report_id");
18683  filter = params_value (params, "filter");
18684 
18685  CHECK_VARIABLE_INVALID (report_id, "Create Asset");
18686  CHECK_VARIABLE_INVALID (filter, "Create Asset");
18687 
18688  response = NULL;
18689  entity = NULL;
18690  switch (gmpf (connection, credentials, &response, &entity, response_data,
18691  "<create_asset>"
18692  "<report id=\"%s\">"
18693  "<filter><term>%s</term></filter>"
18694  "</report>"
18695  "</create_asset>",
18696  report_id, filter))
18697  {
18698  case 0:
18699  case -1:
18700  break;
18701  case 1:
18702  cmd_response_data_set_status_code (response_data,
18703  MHD_HTTP_INTERNAL_SERVER_ERROR);
18704  return gsad_message (
18705  credentials, "Internal error", __FUNCTION__, __LINE__,
18706  "An internal error occurred while creating an asset. "
18707  "No new asset was created. "
18708  "Diagnostics: Failure to send command to manager daemon.",
18709  response_data);
18710  case 2:
18711  cmd_response_data_set_status_code (response_data,
18712  MHD_HTTP_INTERNAL_SERVER_ERROR);
18713  return gsad_message (
18714  credentials, "Internal error", __FUNCTION__, __LINE__,
18715  "An internal error occurred while creating an asset. "
18716  "It is unclear whether the asset has been created or not. "
18717  "Diagnostics: Failure to receive response from manager daemon.",
18718  response_data);
18719  default:
18720  cmd_response_data_set_status_code (response_data,
18721  MHD_HTTP_INTERNAL_SERVER_ERROR);
18722  return gsad_message (
18723  credentials, "Internal error", __FUNCTION__, __LINE__,
18724  "An internal error occurred while creating an asset. "
18725  "It is unclear whether the asset has been created or not. "
18726  "Diagnostics: Internal Error.",
18727  response_data);
18728  }
18729 
18730  ret = response_from_entity (connection, credentials, params, entity,
18731  "Create Asset", response_data);
18732  free_entity (entity);
18733  g_free (response);
18734  return ret;
18735 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_config_gmp()

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

Create config, get all configs, envelope the result.

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

Definition at line 7884 of file gsad_gmp.c.

7886 {
7887  gchar *html, *response;
7888  const char *name, *comment, *base, *scanner = NULL;
7889  entity_t entity;
7890 
7891  name = params_value (params, "name");
7892  comment = params_value (params, "comment");
7893  base = params_value (params, "base");
7894 
7895  CHECK_VARIABLE_INVALID (name, "New Config");
7896  CHECK_VARIABLE_INVALID (comment, "New Config");
7897  CHECK_VARIABLE_INVALID (base, "New Config");
7898  if (str_equal (base, "0"))
7899  {
7900  scanner = params_value (params, "scanner_id");
7901  CHECK_VARIABLE_INVALID (scanner, "New Config");
7902  }
7903 
7904  /* Create the config. */
7905  switch (gmpf (connection, credentials, &response, &entity, response_data,
7906  "<create_config>"
7907  "<name>%s</name>"
7908  "<copy>%s</copy>"
7909  "<comment>%s</comment>"
7910  "<scanner>%s</scanner>"
7911  "</create_config>",
7912  name, base, comment, scanner ?: ""))
7913  {
7914  case 0:
7915  case -1:
7916  break;
7917  case 1:
7918  cmd_response_data_set_status_code (response_data,
7919  MHD_HTTP_INTERNAL_SERVER_ERROR);
7920  return gsad_message (
7921  credentials, "Internal error", __FUNCTION__, __LINE__,
7922  "An internal error occurred while creating a new config. "
7923  "No new config was created. "
7924  "Diagnostics: Failure to send command to manager daemon.",
7925  response_data);
7926  case 2:
7927  cmd_response_data_set_status_code (response_data,
7928  MHD_HTTP_INTERNAL_SERVER_ERROR);
7929  return gsad_message (
7930  credentials, "Internal error", __FUNCTION__, __LINE__,
7931  "An internal error occurred while creating a new config. "
7932  "It is unclear whether the config has been created or not. "
7933  "Diagnostics: Failure to receive response from manager daemon.",
7934  response_data);
7935  default:
7936  cmd_response_data_set_status_code (response_data,
7937  MHD_HTTP_INTERNAL_SERVER_ERROR);
7938  return gsad_message (
7939  credentials, "Internal error", __FUNCTION__, __LINE__,
7940  "An internal error occurred while creating a new config. "
7941  "It is unclear whether the config has been created or not. "
7942  "Diagnostics: Internal Error.",
7943  response_data);
7944  }
7945 
7946  if (entity_attribute (entity, "id"))
7947  params_add (params, "config_id", entity_attribute (entity, "id"));
7948  html = response_from_entity (connection, credentials, params, entity,
7949  "Create Config", response_data);
7950 
7951  free_entity (entity);
7952  g_free (response);
7953  return html;
7954 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_container_task_gmp()

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

Create a container task, serve next page.

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

Definition at line 2401 of file gsad_gmp.c.

2404 {
2405  entity_t entity;
2406  int ret;
2407  gchar *command, *html, *response;
2408  const char *name, *comment;
2409 
2410  name = params_value (params, "name");
2411  comment = params_value (params, "comment");
2412  CHECK_VARIABLE_INVALID (name, "Create Container Task");
2413  CHECK_VARIABLE_INVALID (comment, "Create Container Task");
2414 
2415  command = g_markup_printf_escaped ("<create_task>"
2416  "<target id=\"0\"/>"
2417  "<name>%s</name>"
2418  "<comment>%s</comment>"
2419  "</create_task>",
2420  name, comment);
2421  ret =
2422  gmp (connection, credentials, &response, &entity, response_data, command);
2423  g_free (command);
2424 
2425  switch (ret)
2426  {
2427  case 0:
2428  break;
2429  case -1:
2430  /* 'gmp' set response. */
2431  return response;
2432  case 1:
2433  cmd_response_data_set_status_code (response_data,
2434  MHD_HTTP_INTERNAL_SERVER_ERROR);
2435  return gsad_message (
2436  credentials, "Internal error", __FUNCTION__, __LINE__,
2437  "An internal error occurred while creating a container task. "
2438  "No task was created. "
2439  "Diagnostics: Failure to send command to manager daemon.",
2440  response_data);
2441  case 2:
2442  cmd_response_data_set_status_code (response_data,
2443  MHD_HTTP_INTERNAL_SERVER_ERROR);
2444  return gsad_message (
2445  credentials, "Internal error", __FUNCTION__, __LINE__,
2446  "An internal error occurred while creating a container task. "
2447  "It is unclear whether the task has been created or not. "
2448  "Diagnostics: Failure to receive response from manager daemon.",
2449  response_data);
2450  default:
2451  cmd_response_data_set_status_code (response_data,
2452  MHD_HTTP_INTERNAL_SERVER_ERROR);
2453  return gsad_message (
2454  credentials, "Internal error", __FUNCTION__, __LINE__,
2455  "An internal error occurred while creating a container task. "
2456  "It is unclear whether the task has been created or not. "
2457  "Diagnostics: Internal Error.",
2458  response_data);
2459  }
2460 
2461  if (entity_attribute (entity, "id"))
2462  params_add (params, "task_id", entity_attribute (entity, "id"));
2463  html = response_from_entity (connection, credentials, params, entity,
2464  "Create Container Task", response_data);
2465  free_entity (entity);
2466  g_free (response);
2467  return html;
2468 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_credential_gmp()

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

Create a credential, get all credentials, envelope result.

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

Definition at line 3585 of file gsad_gmp.c.

3587 {
3588  int ret;
3589  gchar *html, *response;
3590  const char *name, *comment, *login, *type, *password, *passphrase;
3591  const char *private_key, *public_key, *certificate, *community;
3592  const char *privacy_password, *auth_algorithm, *privacy_algorithm;
3593  const char *autogenerate, *allow_insecure;
3594  entity_t entity;
3595 
3596  name = params_value (params, "name");
3597  comment = params_value (params, "comment");
3598  login = params_value (params, "credential_login");
3599  type = params_value (params, "credential_type");
3600  password = params_value (params, "lsc_password");
3601  passphrase = params_value (params, "passphrase");
3602  private_key = params_value (params, "private_key");
3603  public_key = params_value (params, "public_key");
3604  certificate = params_value (params, "certificate");
3605  community = params_value (params, "community");
3606  privacy_password = params_value (params, "privacy_password");
3607  auth_algorithm = params_value (params, "auth_algorithm");
3608  privacy_algorithm = params_value (params, "privacy_algorithm");
3609  allow_insecure = params_value (params, "allow_insecure");
3610  autogenerate = params_value (params, "autogenerate");
3611 
3612  CHECK_VARIABLE_INVALID (name, "Create Credential");
3613  CHECK_VARIABLE_INVALID (comment, "Create Credential");
3614  CHECK_VARIABLE_INVALID (type, "Create Credential");
3615  CHECK_VARIABLE_INVALID (allow_insecure, "Create Credential");
3616  CHECK_VARIABLE_INVALID (autogenerate, "Create Credential");
3617 
3618  if (str_equal (autogenerate, "1"))
3619  {
3620  if (str_equal (type, "cc"))
3621  {
3622  // Auto-generate types without username
3623  ret =
3624  gmpf (connection, credentials, &response, &entity, response_data,
3625  "<create_credential>"
3626  "<name>%s</name>"
3627  "<comment>%s</comment>"
3628  "<type>%s</type>"
3629  "<allow_insecure>%s</allow_insecure>"
3630  "</create_credential>",
3631  name, comment ? comment : "", type, allow_insecure);
3632  }
3633  else
3634  {
3635  // Auto-generate types with username
3636  CHECK_VARIABLE_INVALID (login, "Create Credential");
3637 
3638  ret =
3639  gmpf (connection, credentials, &response, &entity, response_data,
3640  "<create_credential>"
3641  "<name>%s</name>"
3642  "<comment>%s</comment>"
3643  "<type>%s</type>"
3644  "<login>%s</login>"
3645  "<allow_insecure>%s</allow_insecure>"
3646  "</create_credential>",
3647  name, comment ? comment : "", type, login, allow_insecure);
3648  }
3649  }
3650  else
3651  {
3652  if (str_equal (type, "up"))
3653  {
3654  CHECK_VARIABLE_INVALID (login, "Create Credential");
3655  CHECK_VARIABLE_INVALID (password, "Create Credential");
3656 
3657  ret =
3658  gmpf (connection, credentials, &response, &entity, response_data,
3659  "<create_credential>"
3660  "<name>%s</name>"
3661  "<comment>%s</comment>"
3662  "<type>%s</type>"
3663  "<login>%s</login>"
3664  "<password>%s</password>"
3665  "<allow_insecure>%s</allow_insecure>"
3666  "</create_credential>",
3667  name, comment ? comment : "", type, login ? login : "",
3668  password ? password : "", allow_insecure);
3669  }
3670  else if (str_equal (type, "usk"))
3671  {
3672  CHECK_VARIABLE_INVALID (login, "Create Credential");
3673  CHECK_VARIABLE_INVALID (passphrase, "Create Credential");
3674  CHECK_VARIABLE_INVALID (private_key, "Create Credential");
3675 
3676  ret =
3677  gmpf (connection, credentials, &response, &entity, response_data,
3678  "<create_credential>"
3679  "<name>%s</name>"
3680  "<comment>%s</comment>"
3681  "<type>%s</type>"
3682  "<login>%s</login>"
3683  "<key>"
3684  "<private>%s</private>"
3685  "<phrase>%s</phrase>"
3686  "</key>"
3687  "<allow_insecure>%s</allow_insecure>"
3688  "</create_credential>",
3689  name, comment ? comment : "", type, login ? login : "",
3690  private_key ? private_key : "", passphrase ? passphrase : "",
3691  allow_insecure);
3692  }
3693  else if (str_equal (type, "cc"))
3694  {
3695  CHECK_VARIABLE_INVALID (certificate, "Create Credential");
3696  CHECK_VARIABLE_INVALID (private_key, "Create Credential");
3697 
3698  ret = gmpf (
3699  connection, credentials, &response, &entity, response_data,
3700  "<create_credential>"
3701  "<name>%s</name>"
3702  "<comment>%s</comment>"
3703  "<type>%s</type>"
3704  "<certificate>%s</certificate>"
3705  "<key>"
3706  "<private>%s</private>"
3707  "</key>"
3708  "<allow_insecure>%s</allow_insecure>"
3709  "</create_credential>",
3710  name, comment ? comment : "", type, certificate ? certificate : "",
3711  private_key ? private_key : "", allow_insecure);
3712  }
3713  else if (str_equal (type, "snmp"))
3714  {
3715  CHECK_VARIABLE_INVALID (community, "Create Credential");
3716  CHECK_VARIABLE_INVALID (login, "Create Credential");
3717  CHECK_VARIABLE_INVALID (password, "Create Credential");
3718  CHECK_VARIABLE_INVALID (privacy_password, "Create Credential");
3719  CHECK_VARIABLE_INVALID (auth_algorithm, "Create Credential");
3720  CHECK_VARIABLE_INVALID (privacy_algorithm, "Create Credential");
3721 
3722  if (privacy_password && strcmp (privacy_password, ""))
3723  ret = gmpf (
3724  connection, credentials, &response, &entity, response_data,
3725  "<create_credential>"
3726  "<name>%s</name>"
3727  "<comment>%s</comment>"
3728  "<type>%s</type>"
3729  "<community>%s</community>"
3730  "<login>%s</login>"
3731  "<password>%s</password>"
3732  "<privacy>"
3733  "<password>%s</password>"
3734  "<algorithm>%s</algorithm>"
3735  "</privacy>"
3736  "<auth_algorithm>%s</auth_algorithm>"
3737  "<allow_insecure>%s</allow_insecure>"
3738  "</create_credential>",
3739  name, comment ? comment : "", type, community ? community : "",
3740  login ? login : "", password ? password : "",
3741  privacy_password ? privacy_password : "",
3742  privacy_algorithm ? privacy_algorithm : "",
3743  auth_algorithm ? auth_algorithm : "", allow_insecure);
3744  else
3745  ret = gmpf (
3746  connection, credentials, &response, &entity, response_data,
3747  "<create_credential>"
3748  "<name>%s</name>"
3749  "<comment>%s</comment>"
3750  "<type>%s</type>"
3751  "<community>%s</community>"
3752  "<login>%s</login>"
3753  "<password>%s</password>"
3754  "<auth_algorithm>%s</auth_algorithm>"
3755  "<allow_insecure>%s</allow_insecure>"
3756  "</create_credential>",
3757  name, comment ? comment : "", type, community ? community : "",
3758  login ? login : "", password ? password : "",
3759  auth_algorithm ? auth_algorithm : "", allow_insecure);
3760  }
3761  else if (str_equal (type, "pgp"))
3762  {
3763  CHECK_VARIABLE_INVALID (public_key, "Create Credential");
3764 
3765  ret = gmpf (
3766  connection, credentials, &response, &entity, response_data,
3767  "<create_credential>"
3768  "<name>%s</name>"
3769  "<comment>%s</comment>"
3770  "<type>%s</type>"
3771  "<key>"
3772  "<public>%s</public>"
3773  "</key>"
3774  "<allow_insecure>%s</allow_insecure>"
3775  "</create_credential>",
3776  name, comment ? comment : "", type, public_key, allow_insecure);
3777  }
3778  else if (str_equal (type, "smime"))
3779  {
3780  CHECK_VARIABLE_INVALID (certificate, "Create Credential");
3781 
3782  ret = gmpf (
3783  connection, credentials, &response, &entity, response_data,
3784  "<create_credential>"
3785  "<name>%s</name>"
3786  "<comment>%s</comment>"
3787  "<type>%s</type>"
3788  "<certificate>%s</certificate>"
3789  "<allow_insecure>%s</allow_insecure>"
3790  "</create_credential>",
3791  name, comment ? comment : "", type, certificate, allow_insecure);
3792  }
3793  else if (type && (strcmp (type, "pw") == 0))
3794  {
3795  CHECK_VARIABLE_INVALID (password, "Create Credential");
3796 
3797  ret =
3798  gmpf (connection, credentials, &response, &entity, response_data,
3799  "<create_credential>"
3800  "<name>%s</name>"
3801  "<comment>%s</comment>"
3802  "<type>%s</type>"
3803  "<password>%s</password>"
3804  "<allow_insecure>%s</allow_insecure>"
3805  "</create_credential>",
3806  name, comment ? comment : "", type, password ? password : "",
3807  allow_insecure);
3808  }
3809  else
3810  {
3811  cmd_response_data_set_status_code (response_data,
3812  MHD_HTTP_INTERNAL_SERVER_ERROR);
3813  return gsad_message (
3814  credentials, "Internal error", __FUNCTION__, __LINE__,
3815  "An internal error occurred while creating a new credential. "
3816  "The credential could not be created. "
3817  "Diagnostics: Unrecognized credential type.",
3818  response_data);
3819  }
3820  }
3821 
3822  /* Create the credential. */
3823  switch (ret)
3824  {
3825  case 0:
3826  case -1:
3827  break;
3828  case 1:
3829  cmd_response_data_set_status_code (response_data,
3830  MHD_HTTP_INTERNAL_SERVER_ERROR);
3831  return gsad_message (
3832  credentials, "Internal error", __FUNCTION__, __LINE__,
3833  "An internal error occurred while creating a new credential. "
3834  "It is unclear whether the credential has been created or not. "
3835  "Diagnostics: Failure to send command to manager daemon.",
3836  response_data);
3837  case 2:
3838  cmd_response_data_set_status_code (response_data,
3839  MHD_HTTP_INTERNAL_SERVER_ERROR);
3840  return gsad_message (
3841  credentials, "Internal error", __FUNCTION__, __LINE__,
3842  "An internal error occurred while creating a new credential. "
3843  "It is unclear whether the credential has been created or not. "
3844  "Diagnostics: Failure to receive response from manager daemon.",
3845  response_data);
3846  default:
3847  cmd_response_data_set_status_code (response_data,
3848  MHD_HTTP_INTERNAL_SERVER_ERROR);
3849  return gsad_message (
3850  credentials, "Internal error", __FUNCTION__, __LINE__,
3851  "An internal error occurred while creating a new credential. "
3852  "It is unclear whether the credential has been created or not. "
3853  "Diagnostics: Internal Error.",
3854  response_data);
3855  }
3856 
3857  if (entity_attribute (entity, "id"))
3858  params_add (params, "credential_id", entity_attribute (entity, "id"));
3859  html = response_from_entity (connection, credentials, params, entity,
3860  "Create Credential", response_data);
3861  free_entity (entity);
3862  g_free (response);
3863  return html;
3864 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:19384
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_filter_gmp()

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

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

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

Definition at line 16486 of file gsad_gmp.c.

16488 {
16489  gchar *html, *response;
16490  const char *name, *comment, *term, *type;
16491  entity_t entity;
16492 
16493  name = params_value (params, "name");
16494  comment = params_value (params, "comment");
16495  term = params_value (params, "term");
16496  type = params_value (params, "optional_resource_type");
16497 
16498  CHECK_VARIABLE_INVALID (name, "Create Filter");
16499  CHECK_VARIABLE_INVALID (comment, "Create Filter");
16500  CHECK_VARIABLE_INVALID (term, "Create Filter");
16501  CHECK_VARIABLE_INVALID (type, "Create Filter");
16502 
16503  switch (gmpf (connection, credentials, &response, &entity, response_data,
16504  "<create_filter>"
16505  "<name>%s</name>"
16506  "<comment>%s</comment>"
16507  "<term>%s</term>"
16508  "<type>%s</type>"
16509  "</create_filter>",
16510  name, comment, term, type))
16511  {
16512  case 0:
16513  case -1:
16514  break;
16515  case 1:
16516  cmd_response_data_set_status_code (response_data,
16517  MHD_HTTP_INTERNAL_SERVER_ERROR);
16518  return gsad_message (
16519  credentials, "Internal error", __FUNCTION__, __LINE__,
16520  "An internal error occurred while creating a new alert. "
16521  "No new alert was created. "
16522  "Diagnostics: Failure to send command to manager daemon.",
16523  response_data);
16524  case 2:
16525  cmd_response_data_set_status_code (response_data,
16526  MHD_HTTP_INTERNAL_SERVER_ERROR);
16527  return gsad_message (
16528  credentials, "Internal error", __FUNCTION__, __LINE__,
16529  "An internal error occurred while creating a new alert. "
16530  "It is unclear whether the alert has been created or not. "
16531  "Diagnostics: Failure to receive response from manager daemon.",
16532  response_data);
16533  default:
16534  cmd_response_data_set_status_code (response_data,
16535  MHD_HTTP_INTERNAL_SERVER_ERROR);
16536  return gsad_message (
16537  credentials, "Internal error", __FUNCTION__, __LINE__,
16538  "An internal error occurred while creating a new alert. "
16539  "It is unclear whether the alert has been created or not. "
16540  "Diagnostics: Internal Error.",
16541  response_data);
16542  }
16543 
16544  if (gmp_success (entity))
16545  {
16546  const char *filter_id;
16547 
16548  filter_id = entity_attribute (entity, "id");
16549  if (filter_id && strlen (filter_id))
16550  {
16551  param_t *param;
16552  param = params_add (params, "filt_id", filter_id);
16553  param->valid = 1;
16554  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
16555  }
16556  }
16557 
16558  if (entity_attribute (entity, "id"))
16559  params_add (params, "filter_id", entity_attribute (entity, "id"));
16560  html = response_from_entity (connection, credentials, params, entity,
16561  "Create Filter", response_data);
16562  free_entity (entity);
16563  g_free (response);
16564  return html;
16565 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
gchar * value
Definition: gsad_params.h:40
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:656
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int valid_utf8
Definition: gsad_params.h:45
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
int valid
Definition: gsad_params.h:44
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp_success(), gmpf(), gsad_message(), params_add(), params_value(), response_from_entity(), param::valid, param::valid_utf8, and param::value.

Here is the call graph for this function:

◆ create_group_gmp()

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

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

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

Definition at line 14153 of file gsad_gmp.c.

14155 {
14156  gchar *html, *response, *command, *specials_element;
14157  const char *name, *comment, *users, *grant_full;
14158  entity_t entity;
14159  GString *xml;
14160  int ret;
14161 
14162  name = params_value (params, "name");
14163  comment = params_value (params, "comment");
14164  grant_full = params_value (params, "grant_full");
14165  users = params_value (params, "users");
14166 
14167  CHECK_VARIABLE_INVALID (name, "Create Group");
14168  CHECK_VARIABLE_INVALID (comment, "Create Group");
14169  CHECK_VARIABLE_INVALID (users, "Create Group");
14170 
14171  /* Create the group. */
14172 
14173  xml = g_string_new ("");
14174 
14175  xml_string_append (xml,
14176  "<name>%s</name>"
14177  "<comment>%s</comment>"
14178  "<users>%s</users>",
14179  name, comment, users);
14180 
14181  if (grant_full)
14182  specials_element = g_strdup_printf ("<full/>");
14183  else
14184  specials_element = NULL;
14185 
14186  command = g_strdup_printf ("<create_group>"
14187  "%s"
14188  "<specials>"
14189  "%s"
14190  "</specials>"
14191  "</create_group>",
14192  xml->str, specials_element);
14193 
14194  g_string_free (xml, TRUE);
14195  g_free (specials_element);
14196 
14197  ret =
14198  gmp (connection, credentials, &response, &entity, response_data, command);
14199  g_free (command);
14200  switch (ret)
14201  {
14202  case 0:
14203  case -1:
14204  break;
14205  case 1:
14206  cmd_response_data_set_status_code (response_data,
14207  MHD_HTTP_INTERNAL_SERVER_ERROR);
14208  return gsad_message (
14209  credentials, "Internal error", __FUNCTION__, __LINE__,
14210  "An internal error occurred while creating a new group. "
14211  "No new group was created. "
14212  "Diagnostics: Failure to send command to manager daemon.",
14213  response_data);
14214  case 2:
14215  cmd_response_data_set_status_code (response_data,
14216  MHD_HTTP_INTERNAL_SERVER_ERROR);
14217  return gsad_message (
14218  credentials, "Internal error", __FUNCTION__, __LINE__,
14219  "An internal error occurred while creating a new group. "
14220  "It is unclear whether the group has been created or not. "
14221  "Diagnostics: Failure to receive response from manager daemon.",
14222  response_data);
14223  default:
14224  cmd_response_data_set_status_code (response_data,
14225  MHD_HTTP_INTERNAL_SERVER_ERROR);
14226  return gsad_message (
14227  credentials, "Internal error", __FUNCTION__, __LINE__,
14228  "An internal error occurred while creating a new group. "
14229  "It is unclear whether the group has been created or not. "
14230  "Diagnostics: Internal Error.",
14231  response_data);
14232  }
14233 
14234  if (entity_attribute (entity, "id"))
14235  params_add (params, "group_id", entity_attribute (entity, "id"));
14236  html = response_from_entity (connection, credentials, params, entity,
14237  "Create Group", response_data);
14238  free_entity (entity);
14239  g_free (response);
14240  return html;
14241 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
GPtrArray * users
User session data.
Definition: gsad_session.c:39
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_host_gmp()

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

Create a host, serve next page.

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

Definition at line 18420 of file gsad_gmp.c.

18422 {
18423  int ret;
18424  gchar *html, *response;
18425  const char *name, *comment;
18426  entity_t entity;
18427  GString *xml;
18428 
18429  name = params_value (params, "name");
18430  CHECK_VARIABLE_INVALID (name, "Create Host");
18431 
18432  comment = params_value (params, "comment");
18433  CHECK_VARIABLE_INVALID (comment, "Create Host");
18434 
18435  /* Create the host. */
18436 
18437  xml = g_string_new ("");
18438 
18439  xml_string_append (xml,
18440  "<create_asset>"
18441  "<asset>"
18442  "<type>host</type>"
18443  "<name>%s</name>"
18444  "<comment>%s</comment>"
18445  "</asset>"
18446  "</create_asset>",
18447  name, comment);
18448 
18449  ret =
18450  gmp (connection, credentials, &response, &entity, response_data, xml->str);
18451  g_string_free (xml, TRUE);
18452  switch (ret)
18453  {
18454  case 0:
18455  case -1:
18456  break;
18457  case 1:
18458  cmd_response_data_set_status_code (response_data,
18459  MHD_HTTP_INTERNAL_SERVER_ERROR);
18460  return gsad_message (
18461  credentials, "Internal error", __FUNCTION__, __LINE__,
18462  "An internal error occurred while creating a new host. "
18463  "No new host was created. "
18464  "Diagnostics: Failure to send command to manager daemon.",
18465  response_data);
18466  case 2:
18467  cmd_response_data_set_status_code (response_data,
18468  MHD_HTTP_INTERNAL_SERVER_ERROR);
18469  return gsad_message (
18470  credentials, "Internal error", __FUNCTION__, __LINE__,
18471  "An internal error occurred while creating a new host. "
18472  "It is unclear whether the host has been created or not. "
18473  "Diagnostics: Failure to receive response from manager daemon.",
18474  response_data);
18475  default:
18476  cmd_response_data_set_status_code (response_data,
18477  MHD_HTTP_INTERNAL_SERVER_ERROR);
18478  return gsad_message (
18479  credentials, "Internal error", __FUNCTION__, __LINE__,
18480  "An internal error occurred while creating a new host. "
18481  "It is unclear whether the host has been created or not. "
18482  "Diagnostics: Internal Error.",
18483  response_data);
18484  }
18485 
18486  if (entity_attribute (entity, "id"))
18487  params_add (params, "asset_id", entity_attribute (entity, "id"));
18488  html = response_from_entity (connection, credentials, params, entity,
18489  "Create Host", response_data);
18490  free_entity (entity);
18491  g_free (response);
18492  return html;
18493 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_note_gmp()

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

Create a note, get report, envelope the result.

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

Definition at line 10971 of file gsad_gmp.c.

10973 {
10974  char *ret;
10975  gchar *response;
10976  const char *oid, *severity, *port, *hosts;
10977  const char *text, *task_id, *result_id;
10978  /* For get_report. */
10979  const char *active, *days;
10980  entity_t entity;
10981 
10982  oid = params_value (params, "oid");
10983  CHECK_VARIABLE_INVALID (oid, "Create Note");
10984 
10985  port = get_port_from_params (params);
10986  hosts = get_hosts_from_params (params);
10987  task_id = get_task_id_from_params (params);
10988  severity = get_severity_from_params (params);
10989  result_id = get_result_id_from_params (params);
10990 
10991  CHECK_VARIABLE_INVALID (severity, "Create Note");
10992  CHECK_VARIABLE_INVALID (hosts, "Create Note");
10993 
10994  active = params_value (params, "active");
10995  CHECK_VARIABLE_INVALID (active, "Create Note");
10996 
10997  text = params_value (params, "text");
10998  days = params_value (params, "days");
10999 
11000  response = NULL;
11001  entity = NULL;
11002  switch (gmpf (connection, credentials, &response, &entity, response_data,
11003  "<create_note>"
11004  "<active>%s</active>"
11005  "<nvt oid=\"%s\"/>"
11006  "<hosts>%s</hosts>"
11007  "<port>%s</port>"
11008  "<severity>%s</severity>"
11009  "<text>%s</text>"
11010  "<task id=\"%s\"/>"
11011  "<result id=\"%s\"/>"
11012  "</create_note>",
11013  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
11014  hosts ? hosts : "", port ? port : "", severity ? severity : "",
11015  text ? text : "", task_id ? task_id : "",
11016  result_id ? result_id : ""))
11017  {
11018  case 0:
11019  case -1:
11020  break;
11021  case 1:
11022  cmd_response_data_set_status_code (response_data,
11023  MHD_HTTP_INTERNAL_SERVER_ERROR);
11024  return gsad_message (
11025  credentials, "Internal error", __FUNCTION__, __LINE__,
11026  "An internal error occurred while creating a new note. "
11027  "No new note was created. "
11028  "Diagnostics: Failure to send command to manager daemon.",
11029  response_data);
11030  case 2:
11031  cmd_response_data_set_status_code (response_data,
11032  MHD_HTTP_INTERNAL_SERVER_ERROR);
11033  return gsad_message (
11034  credentials, "Internal error", __FUNCTION__, __LINE__,
11035  "An internal error occurred while creating a new note. "
11036  "It is unclear whether the note has been created or not. "
11037  "Diagnostics: Failure to receive response from manager daemon.",
11038  response_data);
11039  default:
11040  cmd_response_data_set_status_code (response_data,
11041  MHD_HTTP_INTERNAL_SERVER_ERROR);
11042  return gsad_message (
11043  credentials, "Internal error", __FUNCTION__, __LINE__,
11044  "An internal error occurred while creating a new note. "
11045  "It is unclear whether the note has been created or not. "
11046  "Diagnostics: Internal Error.",
11047  response_data);
11048  }
11049 
11050  if (entity_attribute (entity, "id"))
11051  params_add (params, "note_id", entity_attribute (entity, "id"));
11052  ret = response_from_entity (connection, credentials, params, entity,
11053  "Create Note", response_data);
11054  free_entity (entity);
11055  g_free (response);
11056  return ret;
11057 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
const char * get_port_from_params(params_t *params)
Get a port from request params.
Definition: gsad_gmp.c:10842
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
const char * get_severity_from_params(params_t *params)
Get severity from request params.
Definition: gsad_gmp.c:10923
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
Definition: gsad_gmp.c:10903
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
Definition: gsad_gmp.c:10868
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
Definition: gsad_gmp.c:10946
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_override_gmp()

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

Create an override, get report, envelope the result.

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

Definition at line 11262 of file gsad_gmp.c.

11264 {
11265  char *ret;
11266  gchar *response;
11267  const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
11268  const char *text, *task_id, *result_id;
11269  /* For get_report. */
11270  const char *active, *days;
11271  entity_t entity;
11272 
11273  oid = params_value (params, "oid");
11274  CHECK_VARIABLE_INVALID (oid, "Create Override");
11275 
11276  port = get_port_from_params (params);
11277  hosts = get_hosts_from_params (params);
11278  task_id = get_task_id_from_params (params);
11279  severity = get_severity_from_params (params);
11280  result_id = get_result_id_from_params (params);
11281 
11282  custom_severity = params_value (params, "custom_severity");
11283  CHECK_VARIABLE_INVALID (custom_severity, "Create Override");
11284 
11285  if (custom_severity != NULL && strcmp (custom_severity, "0"))
11286  {
11287  if (params_valid (params, "new_severity"))
11288  new_severity = params_value (params, "new_severity");
11289  else if (params_original_value (params, "new_severity") == NULL
11290  || strcmp (params_original_value (params, "new_severity"), ""))
11291  new_severity = NULL;
11292  else
11293  new_severity = "";
11294  CHECK_VARIABLE_INVALID (new_severity, "Create Override");
11295  }
11296  else
11297  {
11298  if (params_valid (params, "new_severity_from_list"))
11299  new_severity = params_value (params, "new_severity_from_list");
11300  else if (params_original_value (params, "new_severity_from_list") == NULL
11301  || strcmp (
11302  params_original_value (params, "new_severity_from_list"),
11303  ""))
11304  new_severity = NULL;
11305  else
11306  new_severity = "";
11307  CHECK_VARIABLE_INVALID (new_severity, "Create Override");
11308  }
11309 
11310  active = params_value (params, "active");
11311  CHECK_VARIABLE_INVALID (active, "Create Override");
11312 
11313  text = params_value (params, "text");
11314  days = params_value (params, "days");
11315 
11316  response = NULL;
11317  entity = NULL;
11318  switch (gmpf (connection, credentials, &response, &entity, response_data,
11319  "<create_override>"
11320  "<active>%s</active>"
11321  "<nvt oid=\"%s\"/>"
11322  "<hosts>%s</hosts>"
11323  "<port>%s</port>"
11324  "<severity>%s</severity>"
11325  "<new_severity>%s</new_severity>"
11326  "<text>%s</text>"
11327  "<task id=\"%s\"/>"
11328  "<result id=\"%s\"/>"
11329  "</create_override>",
11330  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
11331  hosts ? hosts : "", port ? port : "", severity ? severity : "",
11332  new_severity, text ? text : "", task_id ? task_id : "",
11333  result_id ? result_id : ""))
11334  {
11335  case 0:
11336  case -1:
11337  break;
11338  case 1:
11339  cmd_response_data_set_status_code (response_data,
11340  MHD_HTTP_INTERNAL_SERVER_ERROR);
11341  return gsad_message (
11342  credentials, "Internal error", __FUNCTION__, __LINE__,
11343  "An internal error occurred while creating a new override. "
11344  "No new override was created. "
11345  "Diagnostics: Failure to send command to manager daemon.",
11346  response_data);
11347  case 2:
11348  cmd_response_data_set_status_code (response_data,
11349  MHD_HTTP_INTERNAL_SERVER_ERROR);
11350  return gsad_message (
11351  credentials, "Internal error", __FUNCTION__, __LINE__,
11352  "An internal error occurred while creating a new override. "
11353  "It is unclear whether the override has been created or not. "
11354  "Diagnostics: Failure to receive response from manager daemon.",
11355  response_data);
11356  default:
11357  cmd_response_data_set_status_code (response_data,
11358  MHD_HTTP_INTERNAL_SERVER_ERROR);
11359  return gsad_message (
11360  credentials, "Internal error", __FUNCTION__, __LINE__,
11361  "An internal error occurred while creating a new override. "
11362  "It is unclear whether the override has been created or not. "
11363  "Diagnostics: Internal Error.",
11364  response_data);
11365  }
11366 
11367  if (entity_attribute (entity, "id"))
11368  params_add (params, "override_id", entity_attribute (entity, "id"));
11369  ret = response_from_entity (connection, credentials, params, entity,
11370  "Create Override", response_data);
11371  free_entity (entity);
11372  g_free (response);
11373  return ret;
11374 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
const char * get_port_from_params(params_t *params)
Get a port from request params.
Definition: gsad_gmp.c:10842
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:255
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
const char * get_severity_from_params(params_t *params)
Get severity from request params.
Definition: gsad_gmp.c:10923
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
Definition: gsad_gmp.c:10903
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
Definition: gsad_gmp.c:10868
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
Definition: gsad_gmp.c:10946
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:303

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

Here is the call graph for this function:

◆ create_permission_gmp()

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

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

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

Definition at line 14466 of file gsad_gmp.c.

14468 {
14469  int ret;
14470  gchar *html, *response;
14471  const char *name, *comment, *resource_id, *resource_type;
14472  const char *subject_id, *subject_type, *subject_name;
14473  entity_t entity;
14474 
14475  gchar *subject_response;
14476  entity_t get_subject_entity = NULL;
14477  entity_t subject_entity;
14478 
14479  name = params_value (params, "permission");
14480  comment = params_value (params, "comment");
14481  resource_id = params_value (params, "id_or_empty");
14482  resource_type = params_value (params, "optional_resource_type");
14483  subject_type = params_value (params, "subject_type");
14484  subject_name = params_value (params, "subject_name");
14485 
14486  CHECK_VARIABLE_INVALID (name, "Create Permission");
14487  CHECK_VARIABLE_INVALID (comment, "Create Permission");
14488  if (params_given (params, "id_or_empty"))
14489  CHECK_VARIABLE_INVALID (resource_id, "Create Permission");
14490  CHECK_VARIABLE_INVALID (subject_type, "Create Permission");
14491  if (params_given (params, "optional_resource_type"))
14492  CHECK_VARIABLE_INVALID (resource_type, "Create Permission");
14493 
14494  if (params_given (params, "subject_name"))
14495  {
14496  CHECK_VARIABLE_INVALID (subject_name, "Create Permission");
14497  subject_id = NULL;
14498  ret = gmpf (connection, credentials, &subject_response,
14499  &get_subject_entity, response_data,
14500  "<get_%ss filter=\"rows=1 name=%s\">"
14501  "</get_%ss>",
14502  subject_type, subject_name, subject_type);
14503 
14504  switch (ret)
14505  {
14506  case 0:
14507  case -1:
14508  break;
14509  case 1:
14510  cmd_response_data_set_status_code (response_data,
14511  MHD_HTTP_INTERNAL_SERVER_ERROR);
14512  return gsad_message (credentials, "Internal error", __FUNCTION__,
14513  __LINE__,
14514  "An internal error occurred while getting"
14515  " the subject for a permission. "
14516  "The permission was not created. "
14517  "Diagnostics: Failure to send command"
14518  " to manager daemon.",
14519  response_data);
14520  case 2:
14521  cmd_response_data_set_status_code (response_data,
14522  MHD_HTTP_INTERNAL_SERVER_ERROR);
14523  return gsad_message (credentials, "Internal error", __FUNCTION__,
14524  __LINE__,
14525  "An internal error occurred while getting"
14526  " the subject for a permission. "
14527  "The permission was not created. "
14528  "Diagnostics: Failure to receive response"
14529  " from manager daemon.",
14530  response_data);
14531  default:
14532  cmd_response_data_set_status_code (response_data,
14533  MHD_HTTP_INTERNAL_SERVER_ERROR);
14534  return gsad_message (credentials, "Internal error", __FUNCTION__,
14535  __LINE__,
14536  "An internal error occurred while getting"
14537  " the subject for a permission. "
14538  "The permission was not created. "
14539  "Diagnostics: Internal Error.",
14540  response_data);
14541  }
14542 
14543  subject_entity = entity_child (get_subject_entity, subject_type);
14544 
14545  if (subject_entity)
14546  subject_id = entity_attribute (subject_entity, "id");
14547 
14548  if (subject_id == NULL)
14549  {
14550  cmd_response_data_set_status_code (response_data,
14551  MHD_HTTP_INTERNAL_SERVER_ERROR);
14552  return gsad_message (credentials, "Internal error", __FUNCTION__,
14553  __LINE__,
14554  "An internal error occurred while creating a "
14555  "permission. Could not find Subject."
14556  "The permission was not created. "
14557  "Diagnostics: Internal Error.",
14558  response_data);
14559  }
14560  }
14561  else if (strcmp (subject_type, "user") == 0)
14562  subject_id = params_value (params, "permission_user_id");
14563  else if (strcmp (subject_type, "group") == 0)
14564  subject_id = params_value (params, "permission_group_id");
14565  else if (strcmp (subject_type, "role") == 0)
14566  subject_id = params_value (params, "permission_role_id");
14567  else
14568  subject_id = NULL;
14569 
14570  CHECK_VARIABLE_INVALID (subject_id, "Create Permission");
14571 
14572  /* Create the permission(s). */
14573 
14574  if (strcmp (name, "task_proxy") == 0)
14575  {
14576  response = NULL;
14577  entity = NULL;
14578  ret = gmpf (connection, credentials, &response, &entity, response_data,
14579  "<commands>"
14580  "<create_permission>"
14581  "<name>get_tasks</name>"
14582  "<comment>%s</comment>"
14583  "<resource id=\"%s\"/>"
14584  "<subject id=\"%s\"><type>%s</type></subject>"
14585  "</create_permission>"
14586  "<create_permission>"
14587  "<name>modify_task</name>"
14588  "<comment>%s</comment>"
14589  "<resource id=\"%s\"/>"
14590  "<subject id=\"%s\"><type>%s</type></subject>"
14591  "</create_permission>"
14592  "<create_permission>"
14593  "<name>start_task</name>"
14594  "<comment>%s</comment>"
14595  "<resource id=\"%s\"/>"
14596  "<subject id=\"%s\"><type>%s</type></subject>"
14597  "</create_permission>"
14598  "<create_permission>"
14599  "<name>stop_task</name>"
14600  "<comment>%s</comment>"
14601  "<resource id=\"%s\"/>"
14602  "<subject id=\"%s\"><type>%s</type></subject>"
14603  "</create_permission>"
14604  "<create_permission>"
14605  "<name>resume_task</name>"
14606  "<comment>%s</comment>"
14607  "<resource id=\"%s\"/>"
14608  "<subject id=\"%s\"><type>%s</type></subject>"
14609  "</create_permission>"
14610  "</commands>",
14611  comment ? comment : "", resource_id ? resource_id : "",
14612  subject_id, subject_type, comment ? comment : "",
14613  resource_id ? resource_id : "", subject_id, subject_type,
14614  comment ? comment : "", resource_id ? resource_id : "",
14615  subject_id, subject_type, comment ? comment : "",
14616  resource_id ? resource_id : "", subject_id, subject_type,
14617  comment ? comment : "", resource_id ? resource_id : "",
14618  subject_id, subject_type);
14619 
14620  if (get_subject_entity)
14621  free_entity (get_subject_entity);
14622 
14623  switch (ret)
14624  {
14625  case 0:
14626  case -1:
14627  break;
14628  case 1:
14629  cmd_response_data_set_status_code (response_data,
14630  MHD_HTTP_INTERNAL_SERVER_ERROR);
14631  return gsad_message (
14632  credentials, "Internal error", __FUNCTION__, __LINE__,
14633  "An internal error occurred while creating a permission. "
14634  "The permission was not created. "
14635  "Diagnostics: Failure to send command to manager daemon.",
14636  response_data);
14637  case 2:
14638  cmd_response_data_set_status_code (response_data,
14639  MHD_HTTP_INTERNAL_SERVER_ERROR);
14640  return gsad_message (
14641  credentials, "Internal error", __FUNCTION__, __LINE__,
14642  "An internal error occurred while creating a permission. "
14643  "It is unclear whether the permission has been created or not. "
14644  "Diagnostics: Failure to receive response from manager daemon.",
14645  response_data);
14646  default:
14647  cmd_response_data_set_status_code (response_data,
14648  MHD_HTTP_INTERNAL_SERVER_ERROR);
14649  return gsad_message (
14650  credentials, "Internal error", __FUNCTION__, __LINE__,
14651  "An internal error occurred while creating a permission. "
14652  "It is unclear whether the permission has been created or not. "
14653  "Diagnostics: Internal Error.",
14654  response_data);
14655  }
14656 
14657  if (entity_attribute (entity, "id"))
14658  params_add (params, "permission_id", entity_attribute (entity, "id"));
14659  html = response_from_entity (connection, credentials, params, entity,
14660  "Create Permission", response_data);
14661  }
14662  else
14663  {
14664  response = NULL;
14665  entity = NULL;
14666  ret = gmpf (connection, credentials, &response, &entity, response_data,
14667  "<create_permission>"
14668  "<name>%s</name>"
14669  "<comment>%s</comment>"
14670  "<resource id=\"%s\">"
14671  "<type>%s</type>"
14672  "</resource>"
14673  "<subject id=\"%s\"><type>%s</type></subject>"
14674  "</create_permission>",
14675  name, comment ? comment : "", resource_id ? resource_id : "",
14676  resource_type ? resource_type : "", subject_id, subject_type);
14677 
14678  if (get_subject_entity)
14679  free_entity (get_subject_entity);
14680 
14681  switch (ret)
14682  {
14683  case 0:
14684  case -1:
14685  break;
14686  case 1:
14687  cmd_response_data_set_status_code (response_data,
14688  MHD_HTTP_INTERNAL_SERVER_ERROR);
14689  return gsad_message (
14690  credentials, "Internal error", __FUNCTION__, __LINE__,
14691  "An internal error occurred while creating a permission. "
14692  "The permission was not created. "
14693  "Diagnostics: Failure to send command to manager daemon.",
14694  response_data);
14695  case 2:
14696  cmd_response_data_set_status_code (response_data,
14697  MHD_HTTP_INTERNAL_SERVER_ERROR);
14698  return gsad_message (
14699  credentials, "Internal error", __FUNCTION__, __LINE__,
14700  "An internal error occurred while creating a permission. "
14701  "It is unclear whether the permission has been created or not. "
14702  "Diagnostics: Failure to receive response from manager daemon.",
14703  response_data);
14704  default:
14705  cmd_response_data_set_status_code (response_data,
14706  MHD_HTTP_INTERNAL_SERVER_ERROR);
14707  return gsad_message (
14708  credentials, "Internal error", __FUNCTION__, __LINE__,
14709  "An internal error occurred while creating a permission. "
14710  "It is unclear whether the permission has been created or not. "
14711  "Diagnostics: Internal Error.",
14712  response_data);
14713  }
14714 
14715  if (entity_attribute (entity, "id"))
14716  params_add (params, "permission_id", entity_attribute (entity, "id"));
14717  html = response_from_entity (connection, credentials, params, entity,
14718  "Create Permission", response_data);
14719  }
14720  free_entity (entity);
14721  g_free (response);
14722  return html;
14723 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_permissions_gmp()

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

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

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

Definition at line 14785 of file gsad_gmp.c.

14788 {
14789  int ret;
14790  gchar *html, *response, *summary_response;
14791  int successes;
14792  const char *permission, *comment, *resource_id, *resource_type;
14793  const char *subject_id, *subject_type, *subject_name;
14794  const char *permission_resource_type;
14795  int include_related;
14796 
14797  entity_t entity;
14798 
14799  gchar *subject_response;
14800  entity_t get_subject_entity = NULL;
14801  entity_t subject_entity;
14802 
14803  permission = params_value (params, "permission");
14804  comment = params_value (params, "comment");
14805  resource_id = params_value (params, "resource_id");
14806  resource_type = params_value (params, "resource_type");
14807  subject_type = params_value (params, "subject_type");
14808  subject_name = params_value (params, "subject_name");
14809 
14810  CHECK_VARIABLE_INVALID (params_value (params, "include_related"),
14811  "Create Permission");
14812  CHECK_VARIABLE_INVALID (permission, "Create Permission");
14813  CHECK_VARIABLE_INVALID (comment, "Create Permission");
14814  CHECK_VARIABLE_INVALID (resource_id, "Create Permission");
14815  CHECK_VARIABLE_INVALID (subject_type, "Create Permission");
14816  CHECK_VARIABLE_INVALID (resource_type, "Create Permission");
14817 
14818  if (str_equal (resource_type, "host") || str_equal (resource_type, "os"))
14819  {
14820  permission_resource_type = "asset";
14821  }
14822  else
14823  permission_resource_type = resource_type;
14824 
14825  include_related = atoi (params_value (params, "include_related"));
14826 
14827  if (params_given (params, "subject_name"))
14828  {
14829  CHECK_VARIABLE_INVALID (subject_name, "Create Permission");
14830  subject_id = NULL;
14831  ret = gmpf (connection, credentials, &subject_response,
14832  &get_subject_entity, response_data,
14833  "<get_%ss filter=\"rows=1 name=%s\">"
14834  "</get_%ss>",
14835  subject_type, subject_name, subject_type);
14836 
14837  switch (ret)
14838  {
14839  case 0:
14840  case -1:
14841  break;
14842  case 1:
14843  cmd_response_data_set_status_code (response_data,
14844  MHD_HTTP_INTERNAL_SERVER_ERROR);
14845  return gsad_message (credentials, "Internal error", __FUNCTION__,
14846  __LINE__,
14847  "An internal error occurred while getting"
14848  " the subject for a permission. "
14849  "The permission was not created. "
14850  "Diagnostics: Failure to send command"
14851  " to manager daemon.",
14852  response_data);
14853  case 2:
14854  cmd_response_data_set_status_code (response_data,
14855  MHD_HTTP_INTERNAL_SERVER_ERROR);
14856  return gsad_message (credentials, "Internal error", __FUNCTION__,
14857  __LINE__,
14858  "An internal error occurred while getting"
14859  " the subject for a permission. "
14860  "The permission was not created. "
14861  "Diagnostics: Failure to receive response"
14862  " from manager daemon.",
14863  response_data);
14864  default:
14865  cmd_response_data_set_status_code (response_data,
14866  MHD_HTTP_INTERNAL_SERVER_ERROR);
14867  return gsad_message (credentials, "Internal error", __FUNCTION__,
14868  __LINE__,
14869  "An internal error occurred while getting"
14870  " the subject for a permission. "
14871  "The permission was not created. "
14872  "Diagnostics: Internal Error.",
14873  response_data);
14874  }
14875 
14876  subject_entity = entity_child (get_subject_entity, subject_type);
14877 
14878  if (subject_entity)
14879  subject_id = entity_attribute (subject_entity, "id");
14880 
14881  if (subject_id == NULL)
14882  {
14883  cmd_response_data_set_status_code (response_data,
14884  MHD_HTTP_INTERNAL_SERVER_ERROR);
14885  return gsad_message (credentials, "Internal error", __FUNCTION__,
14886  __LINE__,
14887  "An internal error occurred while creating a "
14888  "permission. Could not find Subject."
14889  "The permission was not created. "
14890  "Diagnostics: Internal Error.",
14891  response_data);
14892  }
14893  }
14894  else if (str_equal (subject_type, "user"))
14895  subject_id = params_value (params, "permission_user_id");
14896  else if (str_equal (subject_type, "group"))
14897  subject_id = params_value (params, "permission_group_id");
14898  else if (str_equal (subject_type, "role"))
14899  subject_id = params_value (params, "permission_role_id");
14900  else
14901  subject_id = NULL;
14902 
14903  CHECK_VARIABLE_INVALID (subject_id, "Create Permission");
14904 
14905  successes = 0;
14906 
14907  /* Create the permission(s). */
14908 
14909  // Main resource permissions
14910  if (include_related != 2)
14911  {
14912  if (strcmp (permission, "read") == 0 || strcmp (permission, "proxy") == 0)
14913  {
14914  response = NULL;
14915  entity = NULL;
14916  ret =
14917  gmpf (connection, credentials, &response, &entity, response_data,
14918  "<create_permission>"
14919  "<name>get_%ss</name>"
14920  "<comment>%s</comment>"
14921  "<resource id=\"%s\">"
14922  "</resource>"
14923  "<subject id=\"%s\"><type>%s</type></subject>"
14924  "</create_permission>",
14925  permission_resource_type, comment ? comment : "", resource_id,
14926  subject_id, subject_type);
14927 
14929  }
14930 
14931  if ((strcmp (permission, "proxy") == 0)
14932  && strcmp (permission_resource_type, "result")
14933  && strcmp (permission_resource_type, "report"))
14934  {
14935  response = NULL;
14936  entity = NULL;
14937  ret =
14938  gmpf (connection, credentials, &response, &entity, response_data,
14939  "<create_permission>"
14940  "<name>modify_%s</name>"
14941  "<comment>%s</comment>"
14942  "<resource id=\"%s\">"
14943  "</resource>"
14944  "<subject id=\"%s\"><type>%s</type></subject>"
14945  "</create_permission>",
14946  permission_resource_type, comment ? comment : "", resource_id,
14947  subject_id, subject_type);
14948 
14950 
14951  if (strcmp (permission_resource_type, "task") == 0)
14952  {
14953  response = NULL;
14954  entity = NULL;
14955  ret = gmpf (connection, credentials, &response, &entity,
14956  response_data,
14957  "<create_permission>"
14958  "<name>start_%s</name>"
14959  "<comment>%s</comment>"
14960  "<resource id=\"%s\">"
14961  "</resource>"
14962  "<subject id=\"%s\"><type>%s</type></subject>"
14963  "</create_permission>",
14964  permission_resource_type, comment ? comment : "",
14965  resource_id, subject_id, subject_type);
14966 
14968 
14969  response = NULL;
14970  entity = NULL;
14971  ret = gmpf (connection, credentials, &response, &entity,
14972  response_data,
14973  "<create_permission>"
14974  "<name>stop_%s</name>"
14975  "<comment>%s</comment>"
14976  "<resource id=\"%s\">"
14977  "</resource>"
14978  "<subject id=\"%s\"><type>%s</type></subject>"
14979  "</create_permission>",
14980  permission_resource_type, comment ? comment : "",
14981  resource_id, subject_id, subject_type);
14982 
14984 
14985  response = NULL;
14986  entity = NULL;
14987  ret = gmpf (connection, credentials, &response, &entity,
14988  response_data,
14989  "<create_permission>"
14990  "<name>resume_%s</name>"
14991  "<comment>%s</comment>"
14992  "<resource id=\"%s\">"
14993  "</resource>"
14994  "<subject id=\"%s\"><type>%s</type></subject>"
14995  "</create_permission>",
14996  permission_resource_type, comment ? comment : "",
14997  resource_id, subject_id, subject_type);
14998 
15000  }
15001 
15002  if (strcmp (permission_resource_type, "alert") == 0)
15003  {
15004  response = NULL;
15005  entity = NULL;
15006  ret = gmpf (connection, credentials, &response, &entity,
15007  response_data,
15008  "<create_permission>"
15009  "<name>test_%s</name>"
15010  "<comment>%s</comment>"
15011  "<resource id=\"%s\">"
15012  "</resource>"
15013  "<subject id=\"%s\"><type>%s</type></subject>"
15014  "</create_permission>",
15015  permission_resource_type, comment ? comment : "",
15016  resource_id, subject_id, subject_type);
15017 
15019  }
15020 
15021  if (strcmp (permission_resource_type, "agent") == 0
15022  || strcmp (permission_resource_type, "report_format") == 0
15023  || strcmp (permission_resource_type, "scanner") == 0)
15024  {
15025  response = NULL;
15026  entity = NULL;
15027  ret = gmpf (connection, credentials, &response, &entity,
15028  response_data,
15029  "<create_permission>"
15030  "<name>verify_%s</name>"
15031  "<comment>%s</comment>"
15032  "<resource id=\"%s\">"
15033  "</resource>"
15034  "<subject id=\"%s\"><type>%s</type></subject>"
15035  "</create_permission>",
15036  permission_resource_type, comment ? comment : "",
15037  resource_id, subject_id, subject_type);
15038 
15040  }
15041  }
15042  }
15043 
15044  // Related permissions
15045  if (include_related)
15046  {
15047  params_t *related;
15048  related = params_values (params, "related:");
15049  if (related)
15050  {
15051  params_iterator_t iter;
15052  char *name;
15053  param_t *param;
15054 
15055  params_iterator_init (&iter, related);
15056  while (params_iterator_next (&iter, &name, &param))
15057  {
15058  char *related_id = name;
15059  char *related_type;
15060 
15061  if (str_equal (param->value, "host")
15062  || str_equal (param->value, "os"))
15063  {
15064  related_type = "asset";
15065  }
15066  else
15067  related_type = param->value;
15068 
15069  if (strcmp (permission, "read") == 0
15070  || strcmp (permission, "proxy") == 0)
15071  {
15072  response = NULL;
15073  entity = NULL;
15074  ret = gmpf (connection, credentials, &response, &entity,
15075  response_data,
15076  "<create_permission>"
15077  "<name>get_%ss</name>"
15078  "<comment>%s</comment>"
15079  "<resource id=\"%s\">"
15080  "</resource>"
15081  "<subject id=\"%s\"><type>%s</type></subject>"
15082  "</create_permission>",
15083  related_type, comment ? comment : "", related_id,
15084  subject_id, subject_type);
15085 
15087  }
15088 
15089  if ((strcmp (permission, "proxy") == 0)
15090  && strcmp (related_type, "result")
15091  && strcmp (related_type, "report"))
15092  {
15093  response = NULL;
15094  entity = NULL;
15095  ret = gmpf (connection, credentials, &response, &entity,
15096  response_data,
15097  "<create_permission>"
15098  "<name>modify_%s</name>"
15099  "<comment>%s</comment>"
15100  "<resource id=\"%s\">"
15101  "</resource>"
15102  "<subject id=\"%s\"><type>%s</type></subject>"
15103  "</create_permission>",
15104  related_type, comment ? comment : "", related_id,
15105  subject_id, subject_type);
15106 
15108 
15109  if (strcmp (related_type, "task") == 0)
15110  {
15111  response = NULL;
15112  entity = NULL;
15113  ret = gmpf (connection, credentials, &response, &entity,
15114  response_data,
15115  "<create_permission>"
15116  "<name>start_%s</name>"
15117  "<comment>%s</comment>"
15118  "<resource id=\"%s\">"
15119  "</resource>"
15120  "<subject id=\"%s\"><type>%s</type></subject>"
15121  "</create_permission>",
15122  related_type, comment ? comment : "",
15123  related_id, subject_id, subject_type);
15124 
15126 
15127  response = NULL;
15128  entity = NULL;
15129  ret = gmpf (connection, credentials, &response, &entity,
15130  response_data,
15131  "<create_permission>"
15132  "<name>stop_%s</name>"
15133  "<comment>%s</comment>"
15134  "<resource id=\"%s\">"
15135  "</resource>"
15136  "<subject id=\"%s\"><type>%s</type></subject>"
15137  "</create_permission>",
15138  related_type, comment ? comment : "",
15139  related_id, subject_id, subject_type);
15140 
15142 
15143  response = NULL;
15144  entity = NULL;
15145  ret = gmpf (connection, credentials, &response, &entity,
15146  response_data,
15147  "<create_permission>"
15148  "<name>resume_%s</name>"
15149  "<comment>%s</comment>"
15150  "<resource id=\"%s\">"
15151  "</resource>"
15152  "<subject id=\"%s\"><type>%s</type></subject>"
15153  "</create_permission>",
15154  related_type, comment ? comment : "",
15155  related_id, subject_id, subject_type);
15156 
15158  }
15159 
15160  if (strcmp (related_type, "alert") == 0)
15161  {
15162  response = NULL;
15163  entity = NULL;
15164  ret = gmpf (connection, credentials, &response, &entity,
15165  response_data,
15166  "<create_permission>"
15167  "<name>test_%s</name>"
15168  "<comment>%s</comment>"
15169  "<resource id=\"%s\">"
15170  "</resource>"
15171  "<subject id=\"%s\"><type>%s</type></subject>"
15172  "</create_permission>",
15173  related_type, comment ? comment : "",
15174  related_id, subject_id, subject_type);
15175 
15177  }
15178 
15179  if (strcmp (related_type, "agent") == 0
15180  || strcmp (related_type, "report_format") == 0
15181  || strcmp (related_type, "scanner") == 0)
15182  {
15183  response = NULL;
15184  entity = NULL;
15185  ret = gmpf (connection, credentials, &response, &entity,
15186  response_data,
15187  "<create_permission>"
15188  "<name>verify_%s</name>"
15189  "<comment>%s</comment>"
15190  "<resource id=\"%s\">"
15191  "</resource>"
15192  "<subject id=\"%s\"><type>%s</type></subject>"
15193  "</create_permission>",
15194  related_type, comment ? comment : "",
15195  related_id, subject_id, subject_type);
15196 
15198  }
15199  }
15200  }
15201  }
15202  }
15203 
15204  if (get_subject_entity)
15205  free_entity (get_subject_entity);
15206 
15207  summary_response =
15208  g_strdup_printf ("Successfully created %i permissions", successes);
15209 
15210  html = action_result (connection, credentials, params, response_data,
15211  "Create Permissions", summary_response, NULL, NULL);
15212  return html;
15213 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
#define CHECK_GMPF_RET
Definition: gsad_gmp.c:14725
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
Definition: gsad_gmp.c:965
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_port_list_gmp()

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

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

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

Definition at line 15372 of file gsad_gmp.c.

15374 {
15375  gchar *html, *response;
15376  const char *name, *comment, *port_range, *from_file;
15377  entity_t entity;
15378 
15379  name = params_value (params, "name");
15380  comment = params_value (params, "comment");
15381  port_range = params_value (params, "port_range");
15382  from_file = params_value (params, "from_file");
15383 
15384  CHECK_VARIABLE_INVALID (name, "Create Port List");
15385  CHECK_VARIABLE_INVALID (comment, "Create Port List");
15386  CHECK_VARIABLE_INVALID (port_range, "Create Port List");
15387  CHECK_VARIABLE_INVALID (from_file, "Create Port List");
15388 
15389  /* Create the port_list. */
15390 
15391  switch (gmpf (
15392  connection, credentials, &response, &entity, response_data,
15393  "<create_port_list>"
15394  "<name>%s</name>"
15395  "<port_range>%s</port_range>"
15396  "<comment>%s</comment>"
15397  "</create_port_list>",
15398  name, strcmp (from_file, "0") ? params_value (params, "file") : port_range,
15399  comment ? comment : ""))
15400  {
15401  case 0:
15402  case -1:
15403  break;
15404  case 1:
15405  cmd_response_data_set_status_code (response_data,
15406  MHD_HTTP_INTERNAL_SERVER_ERROR);
15407  return gsad_message (
15408  credentials, "Internal error", __FUNCTION__, __LINE__,
15409  "An internal error occurred while creating a new port list. "
15410  "No new port list was created. "
15411  "Diagnostics: Failure to send command to manager daemon.",
15412  response_data);
15413  case 2:
15414  cmd_response_data_set_status_code (response_data,
15415  MHD_HTTP_INTERNAL_SERVER_ERROR);
15416  return gsad_message (
15417  credentials, "Internal error", __FUNCTION__, __LINE__,
15418  "An internal error occurred while creating a new port list. "
15419  "It is unclear whether the port list has been created or not. "
15420  "Diagnostics: Failure to receive response from manager daemon.",
15421  response_data);
15422  default:
15423  cmd_response_data_set_status_code (response_data,
15424  MHD_HTTP_INTERNAL_SERVER_ERROR);
15425  return gsad_message (
15426  credentials, "Internal error", __FUNCTION__, __LINE__,
15427  "An internal error occurred while creating a new port list. "
15428  "It is unclear whether the port list has been created or not. "
15429  "Diagnostics: Internal Error.",
15430  response_data);
15431  }
15432 
15433  if (entity_attribute (entity, "id"))
15434  params_add (params, "port_list_id", entity_attribute (entity, "id"));
15435  html = response_from_entity (connection, credentials, params, entity,
15436  "Create Port List", response_data);
15437  free_entity (entity);
15438  g_free (response);
15439  return html;
15440 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_port_range_gmp()

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

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

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

Definition at line 15453 of file gsad_gmp.c.

15455 {
15456  int ret;
15457  gchar *html, *response;
15458  const char *port_list_id, *start, *end, *type;
15459  entity_t entity;
15460 
15461  port_list_id = params_value (params, "port_list_id");
15462  start = params_value (params, "port_range_start");
15463  end = params_value (params, "port_range_end");
15464  type = params_value (params, "port_type");
15465 
15466  CHECK_VARIABLE_INVALID (port_list_id, "Create Port Range");
15467  CHECK_VARIABLE_INVALID (start, "Create Port Range");
15468  CHECK_VARIABLE_INVALID (end, "Create Port Range");
15469  CHECK_VARIABLE_INVALID (type, "Create Port Range");
15470 
15471  /* Create the port range. */
15472 
15473  response = NULL;
15474  entity = NULL;
15475  ret = gmpf (connection, credentials, &response, &entity, response_data,
15476  "<create_port_range>"
15477  "<port_list id=\"%s\"/>"
15478  "<start>%s</start>"
15479  "<end>%s</end>"
15480  "<type>%s</type>"
15481  "</create_port_range>",
15482  port_list_id, start, end, type);
15483 
15484  switch (ret)
15485  {
15486  case 0:
15487  case -1:
15488  break;
15489  case 1:
15490  cmd_response_data_set_status_code (response_data,
15491  MHD_HTTP_INTERNAL_SERVER_ERROR);
15492  return gsad_message (
15493  credentials, "Internal error", __FUNCTION__, __LINE__,
15494  "An internal error occurred while creating a Port Range. "
15495  "The Port Range was not created. "
15496  "Diagnostics: Failure to send command to manager daemon.",
15497  response_data);
15498  case 2:
15499  cmd_response_data_set_status_code (response_data,
15500  MHD_HTTP_INTERNAL_SERVER_ERROR);
15501  return gsad_message (
15502  credentials, "Internal error", __FUNCTION__, __LINE__,
15503  "An internal error occurred while creating a Port Range. "
15504  "It is unclear whether the Port Range has been created or not. "
15505  "Diagnostics: Failure to receive response from manager daemon.",
15506  response_data);
15507  default:
15508  cmd_response_data_set_status_code (response_data,
15509  MHD_HTTP_INTERNAL_SERVER_ERROR);
15510  return gsad_message (
15511  credentials, "Internal error", __FUNCTION__, __LINE__,
15512  "An internal error occurred while creating a Port Range. "
15513  "It is unclear whether the Port Range has been created or not. "
15514  "Diagnostics: Internal Error.",
15515  response_data);
15516  }
15517 
15518  html = response_from_entity (connection, credentials, params, entity,
15519  "Create Port Range", response_data);
15520  free_entity (entity);
15521  g_free (response);
15522  return html;
15523 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_report_gmp()

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

Returns page to create a new container task.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]messageIf not NULL, display message.
[in]extra_xmlExtra XML to insert inside page element.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.Create a report, get all tasks, envelope the result.
Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 2245 of file gsad_gmp.c.

2247 {
2248  entity_t entity;
2249  int ret;
2250  gchar *command, *html, *response;
2251  const char *task_id, *name, *comment, *xml_file;
2252  const char *in_assets;
2253 
2254  task_id = params_value (params, "task_id");
2255  xml_file = params_value (params, "xml_file");
2256  name = params_value (params, "name");
2257  comment = params_value (params, "comment");
2258  in_assets = params_value (params, "in_assets");
2259 
2260  if (task_id == NULL)
2261  {
2262  CHECK_VARIABLE_INVALID (name, "Create Report");
2263  CHECK_VARIABLE_INVALID (comment, "Create Report");
2264  }
2265  CHECK_VARIABLE_INVALID (xml_file, "Create Report");
2266 
2267  if (params_given (params, "in_assets"))
2268  CHECK_VARIABLE_INVALID (xml_file, "Create Report");
2269 
2270  if (strlen (xml_file) == 0)
2271  {
2272  if (task_id)
2273  return message_invalid (connection, credentials, params, response_data,
2274  "Report required", "Create Report");
2275 
2276  /* Create only the container task. */
2277 
2278  command = g_markup_printf_escaped ("<create_task>"
2279  "<target id=\"0\"/>"
2280  "<name>%s</name>"
2281  "<comment>%s</comment>"
2282  "</create_task>",
2283  name, comment);
2284  }
2285  else
2286  {
2287  gchar **xml_file_array, *xml_file_escaped;
2288 
2289  xml_file_array = g_strsplit (xml_file, "%", -1);
2290  if (xml_file_array != NULL && xml_file_array[0] != NULL)
2291  xml_file_escaped = g_strjoinv ("%%", xml_file_array);
2292  else
2293  xml_file_escaped = g_strdup (xml_file);
2294  g_strfreev (xml_file_array);
2295 
2296  if (task_id)
2297  command =
2298  g_strdup_printf ("<create_report>"
2299  "<in_assets>%s</in_assets>"
2300  "<task id=\"%s\"/>"
2301  "%s"
2302  "</create_report>",
2303  in_assets ? in_assets : "0", task_id ? task_id : "0",
2304  xml_file_escaped ? xml_file_escaped : "");
2305  else
2306  {
2307  gchar *name_escaped, *comment_escaped;
2308  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
2309  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
2310  command = g_strdup_printf ("<create_report>"
2311  "<in_assets>%s</in_assets>"
2312  "<task>"
2313  "<name>%s</name>"
2314  "<comment>%s</comment>"
2315  "</task>"
2316  "%s"
2317  "</create_report>",
2318  in_assets ? in_assets : "", name_escaped,
2319  comment_escaped, xml_file_escaped);
2320  g_free (name_escaped);
2321  g_free (comment_escaped);
2322  }
2323  g_free (xml_file_escaped);
2324  }
2325 
2326  ret =
2327  gmp (connection, credentials, &response, &entity, response_data, command);
2328  g_free (command);
2329 
2330  switch (ret)
2331  {
2332  case 0:
2333  break;
2334  case -1:
2335  /* 'gmp' set response. */
2336  return response;
2337  case 1:
2338  cmd_response_data_set_status_code (response_data,
2339  MHD_HTTP_INTERNAL_SERVER_ERROR);
2340  return gsad_message (
2341  credentials, "Internal error", __FUNCTION__, __LINE__,
2342  "An internal error occurred while creating a new report. "
2343  "No new report was created. "
2344  "Diagnostics: Failure to send command to manager daemon.",
2345  response_data);
2346  case 2:
2347  cmd_response_data_set_status_code (response_data,
2348  MHD_HTTP_INTERNAL_SERVER_ERROR);
2349  return gsad_message (
2350  credentials, "Internal error", __FUNCTION__, __LINE__,
2351  "An internal error occurred while creating a new report. "
2352  "It is unclear whether the report has been created or not. "
2353  "Diagnostics: Failure to receive response from manager daemon.",
2354  response_data);
2355  default:
2356  cmd_response_data_set_status_code (response_data,
2357  MHD_HTTP_INTERNAL_SERVER_ERROR);
2358  return gsad_message (
2359  credentials, "Internal error", __FUNCTION__, __LINE__,
2360  "An internal error occurred while creating a new report. "
2361  "It is unclear whether the report has been created or not. "
2362  "Diagnostics: Internal Error.",
2363  response_data);
2364  }
2365 
2366  html = response_from_entity (connection, credentials, params, entity,
2367  "Import Report", response_data);
2368  free_entity (entity);
2369  g_free (response);
2370  return html;
2371 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
gchar * message_invalid(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *op_name)
Check a param using the direct response method.
Definition: gsad_gmp.c:1004
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Referenced by import_report_gmp().

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

◆ create_role_gmp()

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

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

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

Definition at line 15817 of file gsad_gmp.c.

15819 {
15820  char *ret;
15821  gchar *response;
15822  const char *name, *comment, *users;
15823  entity_t entity;
15824 
15825  name = params_value (params, "name");
15826  comment = params_value (params, "comment");
15827  users = params_value (params, "users");
15828 
15829  CHECK_VARIABLE_INVALID (name, "Create Role");
15830  CHECK_VARIABLE_INVALID (comment, "Create Role");
15831  CHECK_VARIABLE_INVALID (users, "Create Role");
15832 
15833  response = NULL;
15834  entity = NULL;
15835  switch (gmpf (connection, credentials, &response, &entity, response_data,
15836  "<create_role>"
15837  "<name>%s</name>"
15838  "<comment>%s</comment>"
15839  "<users>%s</users>"
15840  "</create_role>",
15841  name, comment, users))
15842  {
15843  case 0:
15844  case -1:
15845  break;
15846  case 1:
15847  cmd_response_data_set_status_code (response_data,
15848  MHD_HTTP_INTERNAL_SERVER_ERROR);
15849  return gsad_message (
15850  credentials, "Internal error", __FUNCTION__, __LINE__,
15851  "An internal error occurred while creating a new role. "
15852  "No new role was created. "
15853  "Diagnostics: Failure to send command to manager daemon.",
15854  response_data);
15855  case 2:
15856  cmd_response_data_set_status_code (response_data,
15857  MHD_HTTP_INTERNAL_SERVER_ERROR);
15858  return gsad_message (
15859  credentials, "Internal error", __FUNCTION__, __LINE__,
15860  "An internal error occurred while creating a new role. "
15861  "It is unclear whether the role has been created or not. "
15862  "Diagnostics: Failure to receive response from manager daemon.",
15863  response_data);
15864  default:
15865  cmd_response_data_set_status_code (response_data,
15866  MHD_HTTP_INTERNAL_SERVER_ERROR);
15867  return gsad_message (
15868  credentials, "Internal error", __FUNCTION__, __LINE__,
15869  "An internal error occurred while creating a new role. "
15870  "It is unclear whether the role has been created or not. "
15871  "Diagnostics: Internal Error.",
15872  response_data);
15873  }
15874 
15875  if (entity_attribute (entity, "id"))
15876  params_add (params, "role_id", entity_attribute (entity, "id"));
15877  ret = response_from_entity (connection, credentials, params, entity,
15878  "Create Role", response_data);
15879  free_entity (entity);
15880  g_free (response);
15881  return ret;
15882 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
GPtrArray * users
User session data.
Definition: gsad_session.c:39
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_scanner_gmp()

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

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

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

Definition at line 11692 of file gsad_gmp.c.

11694 {
11695  int ret;
11696  char *html;
11697  gchar *response = NULL;
11698  const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
11699  entity_t entity = NULL;
11700 
11701  name = params_value (params, "name");
11702  comment = params_value (params, "comment");
11703  host = params_value (params, "scanner_host");
11704  port = params_value (params, "port");
11705  type = params_value (params, "scanner_type");
11706  ca_pub = params_value (params, "ca_pub");
11707  credential_id = params_value (params, "credential_id");
11708  CHECK_VARIABLE_INVALID (name, "Create Scanner");
11709  CHECK_VARIABLE_INVALID (comment, "Create Scanner");
11710  CHECK_VARIABLE_INVALID (host, "Create Scanner");
11711  CHECK_VARIABLE_INVALID (port, "Create Scanner");
11712  CHECK_VARIABLE_INVALID (type, "Create Scanner");
11713  if (params_given (params, "ca_pub"))
11714  CHECK_VARIABLE_INVALID (ca_pub, "Create Scanner");
11715  CHECK_VARIABLE_INVALID (credential_id, "Create Scanner");
11716 
11717  if (ca_pub)
11718  ret = gmpf (connection, credentials, &response, &entity, response_data,
11719  "<create_scanner>"
11720  "<name>%s</name><comment>%s</comment>"
11721  "<host>%s</host><port>%s</port><type>%s</type>"
11722  "<ca_pub>%s</ca_pub>"
11723  "<credential id=\"%s\"/>"
11724  "</create_scanner>",
11725  name, comment, host, port, type, ca_pub, credential_id);
11726  else
11727  ret = gmpf (connection, credentials, &response, &entity, response_data,
11728  "<create_scanner>"
11729  "<name>%s</name><comment>%s</comment>"
11730  "<host>%s</host><port>%s</port><type>%s</type>"
11731  "<credential id=\"%s\"/>"
11732  "</create_scanner>",
11733  name, comment, host, port, type, credential_id);
11734  switch (ret)
11735  {
11736  case 0:
11737  case -1:
11738  break;
11739  case 1:
11740  cmd_response_data_set_status_code (response_data,
11741  MHD_HTTP_INTERNAL_SERVER_ERROR);
11742  return gsad_message (
11743  credentials, "Internal error", __FUNCTION__, __LINE__,
11744  "An internal error occurred while creating a new scanner. "
11745  "No new scanner was created. "
11746  "Diagnostics: Failure to send command to manager daemon.",
11747  response_data);
11748  case 2:
11749  cmd_response_data_set_status_code (response_data,
11750  MHD_HTTP_INTERNAL_SERVER_ERROR);
11751  return gsad_message (
11752  credentials, "Internal error", __FUNCTION__, __LINE__,
11753  "An internal error occurred while creating a new scanner. "
11754  "It is unclear whether the scanner has been created or not. "
11755  "Diagnostics: Failure to receive response from manager daemon.",
11756  response_data);
11757  default:
11758  cmd_response_data_set_status_code (response_data,
11759  MHD_HTTP_INTERNAL_SERVER_ERROR);
11760  return gsad_message (
11761  credentials, "Internal error", __FUNCTION__, __LINE__,
11762  "An internal error occurred while creating a new scanner. "
11763  "It is unclear whether the scanner has been created or not. "
11764  "Diagnostics: Internal Error.",
11765  response_data);
11766  }
11767 
11768  if (entity_attribute (entity, "id"))
11769  params_add (params, "scanner_id", entity_attribute (entity, "id"));
11770  html = response_from_entity (connection, credentials, params, entity,
11771  "Create Scanner", response_data);
11772  free_entity (entity);
11773  g_free (response);
11774  return html;
11775 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_schedule_gmp()

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

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

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

Definition at line 12038 of file gsad_gmp.c.

12040 {
12041  char *ret;
12042  gchar *response;
12043  const char *name, *comment, *timezone, *icalendar;
12044  entity_t entity;
12045 
12046  name = params_value (params, "name");
12047  comment = params_value (params, "comment");
12048  timezone = params_value (params, "timezone");
12049  icalendar = params_value (params, "icalendar");
12050 
12051  CHECK_VARIABLE_INVALID (name, "Create Schedule");
12052  CHECK_VARIABLE_INVALID (comment, "Create Schedule");
12053  CHECK_VARIABLE_INVALID (timezone, "Create Schedule");
12054  CHECK_VARIABLE_INVALID (icalendar, "Create Schedule");
12055 
12056  response = NULL;
12057  entity = NULL;
12058  switch (gmpf (connection, credentials, &response, &entity, response_data,
12059  "<create_schedule>"
12060  "<name>%s</name>"
12061  "<comment>%s</comment>"
12062  "<timezone>%s</timezone>"
12063  "<icalendar>%s</icalendar>"
12064  "</create_schedule>",
12065  name, comment, timezone, icalendar))
12066  {
12067  case 0:
12068  case -1:
12069  break;
12070  case 1:
12071  cmd_response_data_set_status_code (response_data,
12072  MHD_HTTP_INTERNAL_SERVER_ERROR);
12073  return gsad_message (
12074  credentials, "Internal error", __FUNCTION__, __LINE__,
12075  "An internal error occurred while creating a new schedule. "
12076  "No new schedule was created. "
12077  "Diagnostics: Failure to send command to manager daemon.",
12078  response_data);
12079  case 2:
12080  cmd_response_data_set_status_code (response_data,
12081  MHD_HTTP_INTERNAL_SERVER_ERROR);
12082  return gsad_message (
12083  credentials, "Internal error", __FUNCTION__, __LINE__,
12084  "An internal error occurred while creating a new schedule. "
12085  "It is unclear whether the schedule has been created or not. "
12086  "Diagnostics: Failure to receive response from manager daemon.",
12087  response_data);
12088  default:
12089  cmd_response_data_set_status_code (response_data,
12090  MHD_HTTP_INTERNAL_SERVER_ERROR);
12091  return gsad_message (
12092  credentials, "Internal error", __FUNCTION__, __LINE__,
12093  "An internal error occurred while creating a new schedule. "
12094  "It is unclear whether the schedule has been created or not. "
12095  "Diagnostics: Internal Error.",
12096  response_data);
12097  }
12098 
12099  if (entity_attribute (entity, "id"))
12100  params_add (params, "schedule_id", entity_attribute (entity, "id"));
12101  ret = response_from_entity (connection, credentials, params, entity,
12102  "Create Schedule", response_data);
12103  free_entity (entity);
12104  g_free (response);
12105  return ret;
12106 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_slave_gmp()

char* create_slave_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ create_tag_gmp()

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

Create a tag, envelope the result.

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

Definition at line 7095 of file gsad_gmp.c.

7097 {
7098  char *ret;
7099  gchar *response;
7100  const char *name, *comment, *filter, *value, *resource_type, *active;
7101  params_t *resource_ids;
7102  GString *command;
7103  entity_t entity;
7104 
7105  name = params_value (params, "tag_name");
7106  comment = params_value (params, "comment");
7107  filter = params_value (params, "filter");
7108  value = params_value (params, "tag_value");
7109  resource_type = params_value (params, "resource_type");
7110  resource_ids = params_values (params, "resource_ids:");
7111  active = params_value (params, "active");
7112 
7113  CHECK_VARIABLE_INVALID (name, "Create Tags")
7114  CHECK_VARIABLE_INVALID (comment, "Create Tags")
7115  if (params_given (params, "filter"))
7116  CHECK_VARIABLE_INVALID (filter, "Create Tags")
7117  CHECK_VARIABLE_INVALID (value, "Create Tags")
7118  CHECK_VARIABLE_INVALID (resource_type, "Create Tags")
7119  CHECK_VARIABLE_INVALID (active, "Create Tags")
7120 
7121  command = g_string_new ("");
7122 
7123  xml_string_append (command,
7124  "<create_tag>"
7125  "<name>%s</name>"
7126  "<comment>%s</comment>"
7127  "<value>%s</value>"
7128  "<active>%s</active>"
7129  "<resources filter=\"%s\">"
7130  "<type>%s</type>",
7131  name, comment, value, active, filter ? filter : "",
7132  resource_type);
7133 
7134  if (resource_ids)
7135  {
7136  params_iterator_t iter;
7137  char *name;
7138  param_t *param;
7139 
7140  params_iterator_init (&iter, resource_ids);
7141  while (params_iterator_next (&iter, &name, &param))
7142  if (param->value && strcmp (param->value, "0"))
7143  g_string_append_printf (command, "<resource id=\"%s\"/>",
7144  param->value ? param->value : "");
7145  }
7146 
7147  xml_string_append (command, "</resources>"
7148  "</create_tag>");
7149 
7150  response = NULL;
7151  entity = NULL;
7152  switch (gmp (connection, credentials, &response, &entity, response_data,
7153  command->str))
7154  {
7155  case 0:
7156  case -1:
7157  break;
7158  case 1:
7159  cmd_response_data_set_status_code (response_data,
7160  MHD_HTTP_INTERNAL_SERVER_ERROR);
7161  g_string_free (command, TRUE);
7162  return gsad_message (
7163  credentials, "Internal error", __FUNCTION__, __LINE__,
7164  "An internal error occurred while creating a new tag. "
7165  "No new tag was created. "
7166  "Diagnostics: Failure to send command to manager daemon.",
7167  response_data);
7168  case 2:
7169  cmd_response_data_set_status_code (response_data,
7170  MHD_HTTP_INTERNAL_SERVER_ERROR);
7171  g_string_free (command, TRUE);
7172  return gsad_message (
7173  credentials, "Internal error", __FUNCTION__, __LINE__,
7174  "An internal error occurred while creating a new tag. "
7175  "It is unclear whether the tag has been created or not. "
7176  "Diagnostics: Failure to receive response from manager daemon.",
7177  response_data);
7178  default:
7179  cmd_response_data_set_status_code (response_data,
7180  MHD_HTTP_INTERNAL_SERVER_ERROR);
7181  g_string_free (command, TRUE);
7182  return gsad_message (
7183  credentials, "Internal error", __FUNCTION__, __LINE__,
7184  "An internal error occurred while creating a new tag. "
7185  "It is unclear whether the tag has been created or not. "
7186  "Diagnostics: Internal Error.",
7187  response_data);
7188  }
7189 
7190  g_string_free (command, TRUE);
7191  ret = response_from_entity (connection, credentials, params, entity,
7192  "Create Tag", response_data);
7193 
7194  free_entity (entity);
7195  g_free (response);
7196  return ret;
7197 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_tags_gmp()

char* create_tags_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ create_target_gmp()

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

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

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

Definition at line 6668 of file gsad_gmp.c.

6670 {
6671  int ret;
6672  gchar *html, *response, *command;
6673  const char *name, *hosts, *exclude_hosts, *comment;
6674  const char *target_ssh_credential, *port, *target_smb_credential;
6675  const char *target_esxi_credential, *target_snmp_credential, *target_source;
6676  const char *target_exclude_source;
6677  const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
6678  const char *alive_tests, *hosts_filter, *file, *exclude_file;
6679  gchar *ssh_credentials_element, *smb_credentials_element;
6680  gchar *esxi_credentials_element, *snmp_credentials_element;
6681  gchar *asset_hosts_element;
6682  gchar *comment_element = NULL;
6683  entity_t entity;
6684  GString *xml;
6685 
6686  name = params_value (params, "name");
6687  hosts = params_value (params, "hosts");
6688  exclude_hosts = params_value (params, "exclude_hosts");
6689  reverse_lookup_only = params_value (params, "reverse_lookup_only");
6690  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
6691  target_source = params_value (params, "target_source");
6692  target_exclude_source = params_value (params, "target_exclude_source");
6693  comment = params_value (params, "comment");
6694  port_list_id = params_value (params, "port_list_id");
6695  target_ssh_credential = params_value (params, "ssh_credential_id");
6696  port = params_value (params, "port");
6697  target_smb_credential = params_value (params, "smb_credential_id");
6698  target_esxi_credential = params_value (params, "esxi_credential_id");
6699  target_snmp_credential = params_value (params, "snmp_credential_id");
6700  alive_tests = params_value (params, "alive_tests");
6701  hosts_filter = params_value (params, "hosts_filter");
6702  file = params_value (params, "file");
6703  exclude_file = params_value (params, "exclude_file");
6704 
6705  CHECK_VARIABLE_INVALID (name, "Create Target");
6706  CHECK_VARIABLE_INVALID (target_source, "Create Target")
6707  if (strcmp (target_source, "manual") == 0)
6708  CHECK_VARIABLE_INVALID (hosts, "Create Target");
6709  if (strcmp (target_source, "file") == 0)
6710  CHECK_VARIABLE_INVALID (file, "Create Target")
6711  /* require hosts_filter if target_source is "asset_hosts" */
6712  if (strcmp (target_source, "asset_hosts") == 0)
6713  CHECK_VARIABLE_INVALID (hosts_filter, "Create Target");
6714 
6715  if (params_given (params, "target_exclude_source"))
6716  {
6717  CHECK_VARIABLE_INVALID (target_exclude_source, "Create Target")
6718  if (strcmp (target_exclude_source, "manual") == 0
6719  /* In case browser doesn't send empty field. */
6720  && params_given (params, "exclude_hosts"))
6721  CHECK_VARIABLE_INVALID (exclude_hosts, "Create Target");
6722  if (strcmp (target_exclude_source, "file") == 0)
6723  CHECK_VARIABLE_INVALID (exclude_file, "Create Target");
6724  }
6725 
6726  CHECK_VARIABLE_INVALID (comment, "Create Target");
6727  CHECK_VARIABLE_INVALID (port_list_id, "Create Target");
6728  CHECK_VARIABLE_INVALID (target_ssh_credential, "Create Target");
6729  if (strcmp (target_ssh_credential, "--"))
6730  CHECK_VARIABLE_INVALID (port, "Create Target");
6731  CHECK_VARIABLE_INVALID (target_smb_credential, "Create Target");
6732  CHECK_VARIABLE_INVALID (target_esxi_credential, "Create Target");
6733  CHECK_VARIABLE_INVALID (target_snmp_credential, "Create Target");
6734  CHECK_VARIABLE_INVALID (alive_tests, "Create Target");
6735 
6736  if (comment != NULL)
6737  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
6738  else
6739  comment_element = g_strdup ("");
6740 
6741  if (strcmp (target_ssh_credential, "0") == 0)
6742  ssh_credentials_element = g_strdup ("");
6743  else
6744  ssh_credentials_element = g_strdup_printf ("<ssh_credential id=\"%s\">"
6745  "<port>%s</port>"
6746  "</ssh_credential>",
6747  target_ssh_credential, port);
6748 
6749  if (strcmp (target_smb_credential, "0") == 0)
6750  smb_credentials_element = g_strdup ("");
6751  else
6752  smb_credentials_element =
6753  g_strdup_printf ("<smb_credential id=\"%s\"/>", target_smb_credential);
6754 
6755  if (strcmp (target_esxi_credential, "0") == 0)
6756  esxi_credentials_element = g_strdup ("");
6757  else
6758  esxi_credentials_element =
6759  g_strdup_printf ("<esxi_credential id=\"%s\"/>", target_esxi_credential);
6760 
6761  if (strcmp (target_snmp_credential, "0") == 0)
6762  snmp_credentials_element = g_strdup ("");
6763  else
6764  snmp_credentials_element =
6765  g_strdup_printf ("<snmp_credential id=\"%s\"/>", target_snmp_credential);
6766 
6767  if (strcmp (target_source, "asset_hosts") == 0)
6768  asset_hosts_element = g_markup_printf_escaped ("<asset_hosts"
6769  " filter=\"%s\"/>",
6770  hosts_filter);
6771  else
6772  asset_hosts_element = g_strdup ("");
6773 
6774  /* Create the target. */
6775 
6776  xml = g_string_new ("");
6777 
6778  xml_string_append (xml,
6779  "<name>%s</name>"
6780  "<hosts>%s</hosts>"
6781  "<exclude_hosts>%s</exclude_hosts>"
6782  "<reverse_lookup_only>%s</reverse_lookup_only>"
6783  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
6784  "<port_list id=\"%s\"/>"
6785  "<alive_tests>%s</alive_tests>",
6786  name, strcmp (target_source, "file") == 0 ? file : hosts,
6787  target_exclude_source
6788  ? (strcmp (target_exclude_source, "file") == 0
6789  ? exclude_file
6790  : (exclude_hosts ? exclude_hosts : ""))
6791  : "",
6792  reverse_lookup_only ? reverse_lookup_only : "0",
6793  reverse_lookup_unify ? reverse_lookup_unify : "0",
6794  port_list_id, alive_tests);
6795 
6796  command = g_strdup_printf ("<create_target>"
6797  "%s%s%s%s%s%s%s"
6798  "</create_target>",
6799  xml->str, comment_element, ssh_credentials_element,
6800  smb_credentials_element, esxi_credentials_element,
6801  snmp_credentials_element, asset_hosts_element);
6802 
6803  g_string_free (xml, TRUE);
6804  g_free (comment_element);
6805  g_free (ssh_credentials_element);
6806  g_free (smb_credentials_element);
6807  g_free (esxi_credentials_element);
6808 
6809  ret =
6810  gmp (connection, credentials, &response, &entity, response_data, command);
6811  g_free (command);
6812  switch (ret)
6813  {
6814  case 0:
6815  break;
6816  case -1:
6817  /* 'gmp' set response. */
6818  return response;
6819  case 1:
6820  cmd_response_data_set_status_code (response_data,
6821  MHD_HTTP_INTERNAL_SERVER_ERROR);
6822  return gsad_message (
6823  credentials, "Internal error", __FUNCTION__, __LINE__,
6824  "An internal error occurred while creating a new target. "
6825  "No new target was created. "
6826  "Diagnostics: Failure to send command to manager daemon.",
6827  response_data);
6828  case 2:
6829  cmd_response_data_set_status_code (response_data,
6830  MHD_HTTP_INTERNAL_SERVER_ERROR);
6831  return gsad_message (
6832  credentials, "Internal error", __FUNCTION__, __LINE__,
6833  "An internal error occurred while creating a new target. "
6834  "It is unclear whether the target has been created or not. "
6835  "Diagnostics: Failure to receive response from manager daemon.",
6836  response_data);
6837  default:
6838  cmd_response_data_set_status_code (response_data,
6839  MHD_HTTP_INTERNAL_SERVER_ERROR);
6840  return gsad_message (
6841  credentials, "Internal error", __FUNCTION__, __LINE__,
6842  "An internal error occurred while creating a new target. "
6843  "It is unclear whether the target has been created or not. "
6844  "Diagnostics: Internal Error.",
6845  response_data);
6846  }
6847 
6848  if (entity_attribute (entity, "id"))
6849  params_add (params, "target_id", entity_attribute (entity, "id"));
6850  html = response_from_entity (connection, credentials, params, entity,
6851  "Create Target", response_data);
6852  free_entity (entity);
6853  g_free (response);
6854  return html;
6855 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ create_task_gmp()

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

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

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

Definition at line 2481 of file gsad_gmp.c.

2483 {
2484  entity_t entity;
2485  int ret;
2486  gchar *schedule_element, *command;
2487  gchar *response, *html;
2488  const char *name, *comment, *config_id, *target_id, *scanner_type;
2489  const char *scanner_id, *schedule_id, *schedule_periods;
2490  const char *max_checks, *max_hosts;
2491  const char *in_assets, *hosts_ordering, *alterable, *source_iface;
2492  const char *add_tag, *tag_id, *auto_delete, *auto_delete_data;
2493  const char *apply_overrides, *min_qod;
2494  gchar *name_escaped, *comment_escaped;
2495  params_t *alerts;
2496  GString *alert_element;
2497 
2498  add_tag = params_value (params, "add_tag");
2499  alterable = params_value (params, "alterable");
2500  apply_overrides = params_value (params, "apply_overrides");
2501  auto_delete = params_value (params, "auto_delete");
2502  auto_delete_data = params_value (params, "auto_delete_data");
2503  comment = params_value (params, "comment");
2504  config_id = params_value (params, "config_id");
2505  hosts_ordering = params_value (params, "hosts_ordering");
2506  in_assets = params_value (params, "in_assets");
2507  max_checks = params_value (params, "max_checks");
2508  max_hosts = params_value (params, "max_hosts");
2509  min_qod = params_value (params, "min_qod");
2510  name = params_value (params, "name");
2511  scanner_id = params_value (params, "scanner_id");
2512  scanner_type = params_value (params, "scanner_type");
2513  schedule_id = params_value (params, "schedule_id");
2514  schedule_periods = params_value (params, "schedule_periods");
2515  source_iface = params_value (params, "source_iface");
2516  tag_id = params_value (params, "tag_id");
2517  target_id = params_value (params, "target_id");
2518 
2519  CHECK_VARIABLE_INVALID (scanner_type, "Create Task");
2520  if (!strcmp (scanner_type, "1"))
2521  {
2522  hosts_ordering = "";
2523  max_checks = "";
2524  source_iface = "";
2525  max_hosts = "";
2526  }
2527  else if (!strcmp (scanner_type, "3"))
2528  {
2529  config_id = "";
2530  hosts_ordering = "";
2531  max_checks = "";
2532  source_iface = "";
2533  max_hosts = "";
2534  }
2535 
2536  CHECK_VARIABLE_INVALID (name, "Create Task");
2537  CHECK_VARIABLE_INVALID (comment, "Create Task");
2538  CHECK_VARIABLE_INVALID (config_id, "Create Task");
2539  CHECK_VARIABLE_INVALID (target_id, "Create Task");
2540  CHECK_VARIABLE_INVALID (hosts_ordering, "Create Task");
2541  CHECK_VARIABLE_INVALID (scanner_id, "Create Task");
2542  CHECK_VARIABLE_INVALID (schedule_id, "Create Task");
2543 
2544  if (str_equal (target_id, "0"))
2545  {
2546  /* Don't allow to create container task via create_task */
2547  return message_invalid (connection, credentials, params, response_data,
2548  "Given target_id was invalid", "Create Task");
2549  }
2550 
2551  if (params_given (params, "schedule_periods"))
2552  {
2553  CHECK_VARIABLE_INVALID (schedule_periods, "Create Task");
2554  }
2555  else
2556  schedule_periods = "0";
2557 
2558  CHECK_VARIABLE_INVALID (in_assets, "Create Task");
2559 
2560  if (!strcmp (in_assets, "1"))
2561  {
2562  CHECK_VARIABLE_INVALID (apply_overrides, "Create Task");
2563  CHECK_VARIABLE_INVALID (min_qod, "Create Task");
2564  }
2565  else
2566  {
2567  if (!params_given (params, "apply_overrides")
2568  || !params_valid (params, "apply_overrides"))
2569  apply_overrides = "";
2570 
2571  if (!params_given (params, "min_qod")
2572  || !params_valid (params, "min_qod"))
2573  min_qod = "";
2574  }
2575 
2576  CHECK_VARIABLE_INVALID (max_checks, "Create Task");
2577  CHECK_VARIABLE_INVALID (source_iface, "Create Task");
2578  CHECK_VARIABLE_INVALID (auto_delete, "Create Task");
2579  CHECK_VARIABLE_INVALID (auto_delete_data, "Create Task");
2580  CHECK_VARIABLE_INVALID (max_hosts, "Create Task");
2581  CHECK_VARIABLE_INVALID (alterable, "Create Task");
2582 
2583  if (add_tag && strcmp (add_tag, "1") == 0)
2584  {
2585  CHECK_VARIABLE_INVALID (tag_id, "Create Task");
2586  }
2587 
2588  if (schedule_id == NULL || strcmp (schedule_id, "0") == 0)
2589  schedule_element = g_strdup ("");
2590  else
2591  schedule_element = g_strdup_printf ("<schedule id=\"%s\"/>", schedule_id);
2592 
2593  alert_element = g_string_new ("");
2594  if (params_given (params, "alert_id_optional:"))
2595  alerts = params_values (params, "alert_id_optional:");
2596  else
2597  alerts = params_values (params, "alert_ids:");
2598 
2599  if (alerts)
2600  {
2601  params_iterator_t iter;
2602  char *name;
2603  param_t *param;
2604 
2605  params_iterator_init (&iter, alerts);
2606  while (params_iterator_next (&iter, &name, &param))
2607  if (param->value && strcmp (param->value, "0"))
2608  g_string_append_printf (alert_element, "<alert id=\"%s\"/>",
2609  param->value ? param->value : "");
2610  }
2611 
2612  name_escaped = name ? g_markup_escape_text (name, -1) : NULL;
2613  comment_escaped = comment ? g_markup_escape_text (comment, -1) : NULL;
2614 
2615  command = g_strdup_printf (
2616  "<create_task>"
2617  "<config id=\"%s\"/>"
2618  "<schedule_periods>%s</schedule_periods>"
2619  "%s%s"
2620  "<target id=\"%s\"/>"
2621  "<scanner id=\"%s\"/>"
2622  "<hosts_ordering>%s</hosts_ordering>"
2623  "<name>%s</name>"
2624  "<comment>%s</comment>"
2625  "<preferences>"
2626  "<preference>"
2627  "<scanner_name>max_checks</scanner_name>"
2628  "<value>%s</value>"
2629  "</preference>"
2630  "<preference>"
2631  "<scanner_name>max_hosts</scanner_name>"
2632  "<value>%s</value>"
2633  "</preference>"
2634  "<preference>"
2635  "<scanner_name>in_assets</scanner_name>"
2636  "<value>%s</value>"
2637  "</preference>"
2638  "<preference>"
2639  "<scanner_name>"
2640  "assets_apply_overrides"
2641  "</scanner_name>"
2642  "<value>%s</value>"
2643  "</preference>"
2644  "<preference>"
2645  "<scanner_name>assets_min_qod</scanner_name>"
2646  "<value>%s</value>"
2647  "</preference>"
2648  "<preference>"
2649  "<scanner_name>source_iface</scanner_name>"
2650  "<value>%s</value>"
2651  "</preference>"
2652  "<preference>"
2653  "<scanner_name>auto_delete</scanner_name>"
2654  "<value>%s</value>"
2655  "</preference>"
2656  "<preference>"
2657  "<scanner_name>auto_delete_data</scanner_name>"
2658  "<value>%s</value>"
2659  "</preference>"
2660  "</preferences>"
2661  "<alterable>%i</alterable>"
2662  "</create_task>",
2663  config_id, schedule_periods, schedule_element, alert_element->str,
2664  target_id, scanner_id, hosts_ordering, name_escaped, comment_escaped,
2665  max_checks, max_hosts, strcmp (in_assets, "0") ? "yes" : "no",
2666  strcmp (apply_overrides, "0") ? "yes" : "no", min_qod, source_iface,
2667  auto_delete, auto_delete_data, alterable ? strcmp (alterable, "0") : 0);
2668 
2669  g_free (name_escaped);
2670  g_free (comment_escaped);
2671 
2672  ret =
2673  gmp (connection, credentials, &response, &entity, response_data, command);
2674  g_free (command);
2675 
2676  g_free (schedule_element);
2677  g_string_free (alert_element, TRUE);
2678 
2679  switch (ret)
2680  {
2681  case 0:
2682  break;
2683  case -1:
2684  /* 'gmp' set response. */
2685  return response;
2686  case 1:
2687  cmd_response_data_set_status_code (response_data,
2688  MHD_HTTP_INTERNAL_SERVER_ERROR);
2689  return gsad_message (
2690  credentials, "Internal error", __FUNCTION__, __LINE__,
2691  "An internal error occurred while creating a new task. "
2692  "No new task was created. "
2693  "Diagnostics: Failure to send command to manager daemon.",
2694  response_data);
2695  case 2:
2696  cmd_response_data_set_status_code (response_data,
2697  MHD_HTTP_INTERNAL_SERVER_ERROR);
2698  return gsad_message (
2699  credentials, "Internal error", __FUNCTION__, __LINE__,
2700  "An internal error occurred while creating a new task. "
2701  "It is unclear whether the task has been created or not. "
2702  "Diagnostics: Failure to receive response from manager daemon.",
2703  response_data);
2704  default:
2705  cmd_response_data_set_status_code (response_data,
2706  MHD_HTTP_INTERNAL_SERVER_ERROR);
2707  return gsad_message (
2708  credentials, "Internal error", __FUNCTION__, __LINE__,
2709  "An internal error occurred while creating a new task. "
2710  "It is unclear whether the task has been created or not. "
2711  "Diagnostics: Internal Error.",
2712  response_data);
2713  }
2714 
2715  if (gmp_success (entity))
2716  {
2717  if (add_tag && strcmp (add_tag, "1") == 0)
2718  {
2719  const char *new_task_id = entity_attribute (entity, "id");
2720  gchar *tag_command, *tag_response;
2721  entity_t tag_entity;
2722 
2723  tag_command = g_markup_printf_escaped ("<modify_tag tag_id=\"%s\">"
2724  "<resources action=\"add\">"
2725  "<resource id=\"%s\"/>"
2726  "</resources>"
2727  "</modify_tag>",
2728  tag_id, new_task_id);
2729 
2730  ret = gmp (connection, credentials, &tag_response, &tag_entity,
2731  response_data, tag_command);
2732 
2733  switch (ret)
2734  {
2735  case 0:
2736  case -1:
2737  break;
2738  case 1:
2739  free_entity (entity);
2740  g_free (response);
2742  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2743  return gsad_message (
2744  credentials, "Internal error", __FUNCTION__, __LINE__,
2745  "An internal error occurred while creating a new tag. "
2746  "No new tag was created. "
2747  "Diagnostics: Failure to send command to manager daemon.",
2748  response_data);
2749  case 2:
2750  free_entity (entity);
2751  g_free (response);
2753  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2754  return gsad_message (
2755  credentials, "Internal error", __FUNCTION__, __LINE__,
2756  "An internal error occurred while creating a new tag. "
2757  "It is unclear whether the tag has been created or not. "
2758  "Diagnostics: Failure to receive response from manager daemon.",
2759  response_data);
2760  default:
2761  free_entity (entity);
2762  g_free (response);
2764  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
2765  return gsad_message (
2766  credentials, "Internal error", __FUNCTION__, __LINE__,
2767  "An internal error occurred while creating a new task. "
2768  "It is unclear whether the tag has been created or not. "
2769  "Diagnostics: Internal Error.",
2770  response_data);
2771  }
2772 
2773  if (entity_attribute (entity, "id"))
2774  params_add (params, "task_id", entity_attribute (entity, "id"));
2775  html =
2776  response_from_entity (connection, credentials, params, tag_entity,
2777  "Create Task and Tag", response_data);
2778  free_entity (tag_entity);
2779  g_free (tag_response);
2780  }
2781  else
2782  {
2783  if (entity_attribute (entity, "id"))
2784  params_add (params, "task_id", entity_attribute (entity, "id"));
2785  html = response_from_entity (connection, credentials, params, entity,
2786  "Create Task", response_data);
2787  }
2788  }
2789  else
2790  {
2791  html = response_from_entity (connection, credentials, params, entity,
2792  "Create Task", response_data);
2793  }
2794  free_entity (entity);
2795  g_free (response);
2796  return html;
2797 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:656
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
gchar * message_invalid(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *op_name)
Check a param using the direct response method.
Definition: gsad_gmp.c:1004
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:303

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

Here is the call graph for this function:

◆ create_ticket_gmp()

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

Create a ticket.

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

Definition at line 18983 of file gsad_gmp.c.

18985 {
18986  gchar *response = NULL;
18987  entity_t entity = NULL;
18988  const gchar *result_id, *user_id, *note;
18989  char *ret;
18990 
18991  result_id = params_value (params, "result_id");
18992  user_id = params_value (params, "user_id");
18993  note = params_value (params, "note");
18994 
18995  CHECK_VARIABLE_INVALID (result_id, "Create Ticket");
18996  CHECK_VARIABLE_INVALID (user_id, "Create Ticket");
18997  CHECK_VARIABLE_INVALID (note, "Create Ticket")
18998 
18999  switch (gmpf (connection, credentials, &response, &entity, response_data,
19000  "<create_ticket>"
19001  "<result id=\"%s\"/>"
19002  "<assigned_to>"
19003  "<user id=\"%s\"/>"
19004  "</assigned_to>"
19005  "<open_note>%s</open_note>"
19006  "</create_ticket>",
19007  result_id, user_id, note ? note : ""))
19008  {
19009  case 0:
19010  case -1:
19011  break;
19012  case 1:
19013  cmd_response_data_set_status_code (response_data,
19014  MHD_HTTP_INTERNAL_SERVER_ERROR);
19015  return gsad_message (
19016  credentials, "Internal error", __FUNCTION__, __LINE__,
19017  "An internal error occurred while creating a ticket. "
19018  "Diagnostics: Failure to send command to manager daemon.",
19019  response_data);
19020  case 2:
19021  cmd_response_data_set_status_code (response_data,
19022  MHD_HTTP_INTERNAL_SERVER_ERROR);
19023  return gsad_message (
19024  credentials, "Internal error", __FUNCTION__, __LINE__,
19025  "An internal error occurred while creating a ticket. "
19026  "It is unclear whether the ticket has been created or not. "
19027  "Diagnostics: Failure to receive response from manager daemon.",
19028  response_data);
19029  default:
19030  cmd_response_data_set_status_code (response_data,
19031  MHD_HTTP_INTERNAL_SERVER_ERROR);
19032  return gsad_message (
19033  credentials, "Internal error", __FUNCTION__, __LINE__,
19034  "An internal error occurred while creating a ticket. "
19035  "It is unclear whether the ticket has been created or not. "
19036  "Diagnostics: Internal Error.",
19037  response_data);
19038  }
19039 
19040  ret = response_from_entity (connection, credentials, params, entity,
19041  "Create Ticket", response_data);
19042 
19043  free_entity (entity);
19044  g_free (response);
19045  return ret;
19046 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
User information structure, for sessions.
Definition: gsad_user.c:42
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ create_user_gmp()

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

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

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

Definition at line 17039 of file gsad_gmp.c.

17041 {
17042  const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
17043  const char *auth_method, *comment;
17044  int ret;
17045  params_t *groups, *roles;
17046  GString *group_elements, *role_elements, *string;
17047  gchar *buf, *response, *html;
17048  entity_t entity;
17049 
17050  name = params_value (params, "login");
17051  password = params_value (params, "password");
17052  hosts = params_value (params, "access_hosts");
17053  hosts_allow = params_value (params, "hosts_allow");
17054  ifaces = params_value (params, "access_ifaces");
17055  ifaces_allow = params_value (params, "ifaces_allow");
17056  auth_method = params_value (params, "auth_method");
17057  comment = params_value (params, "comment");
17058 
17059  CHECK_VARIABLE_INVALID (name, "Create User");
17060  CHECK_VARIABLE_INVALID (hosts, "Create User");
17061  CHECK_VARIABLE_INVALID (hosts_allow, "Create User");
17062  CHECK_VARIABLE_INVALID (ifaces, "Create User");
17063  CHECK_VARIABLE_INVALID (ifaces_allow, "Create User");
17064 
17065  if (auth_method && strcmp (auth_method, "1") == 0)
17066  {
17067  CHECK_VARIABLE_INVALID (password, "Create User");
17068  }
17069 
17070  if (params_given (params, "comment"))
17071  {
17072  CHECK_VARIABLE_INVALID (comment, "Create User");
17073  }
17074 
17075  /* Create the user. */
17076 
17077  string = g_string_new ("<create_user>");
17078  buf = g_markup_printf_escaped ("<name>%s</name>"
17079  "<password>%s</password>",
17080  name, password ? password : "");
17081 
17082  g_string_append (string, buf);
17083  g_free (buf);
17084 
17085  group_elements = g_string_new ("<groups>");
17086  if (params_given (params, "group_id_optional:"))
17087  groups = params_values (params, "group_id_optional:");
17088  else
17089  groups = params_values (params, "group_ids:");
17090 
17091  if (groups)
17092  {
17093  params_iterator_t iter;
17094  char *name;
17095  param_t *param;
17096 
17097  params_iterator_init (&iter, groups);
17098  while (params_iterator_next (&iter, &name, &param))
17099  {
17100  if (param->value && strcmp (param->value, "--"))
17101  g_string_append_printf (group_elements, "<group id=\"%s\"/>",
17102  param->value ? param->value : "");
17103  }
17104  }
17105  g_string_append (string, group_elements->str);
17106  g_string_free (group_elements, TRUE);
17107  g_string_append (string, "</groups>");
17108 
17109  role_elements = g_string_new ("");
17110  if (params_given (params, "role_id_optional:"))
17111  roles = params_values (params, "role_id_optional:");
17112  else
17113  roles = params_values (params, "role_ids:");
17114 
17115  if (roles)
17116  {
17117  params_iterator_t iter;
17118  char *name;
17119  param_t *param;
17120 
17121  params_iterator_init (&iter, roles);
17122  while (params_iterator_next (&iter, &name, &param))
17123  {
17124  if (param->value && strcmp (param->value, "--"))
17125  g_string_append_printf (role_elements, "<role id=\"%s\"/>",
17126  param->value ? param->value : "");
17127  }
17128  }
17129  g_string_append (string, role_elements->str);
17130  g_string_free (role_elements, TRUE);
17131 
17132  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
17133  "<ifaces allow=\"%s\">%s</ifaces>",
17134  hosts_allow, hosts, ifaces_allow, ifaces);
17135  g_string_append (string, buf);
17136  g_free (buf);
17137  if (auth_method && !strcmp (auth_method, "1"))
17138  g_string_append (string,
17139  "<sources><source>ldap_connect</source></sources>");
17140  else if (auth_method && !strcmp (auth_method, "2"))
17141  g_string_append (string,
17142  "<sources><source>radius_connect</source></sources>");
17143 
17144  if (comment)
17145  {
17146  xml_string_append (string, "<comment>%s</comment>", comment);
17147  }
17148 
17149  g_string_append (string, "</create_user>");
17150 
17151  buf = g_string_free (string, FALSE);
17152 
17153  response = NULL;
17154  entity = NULL;
17155  ret = gmp (connection, credentials, &response, &entity, response_data, buf);
17156  g_free (buf);
17157  switch (ret)
17158  {
17159  case 0:
17160  case -1:
17161  break;
17162  case 1:
17163  cmd_response_data_set_status_code (response_data,
17164  MHD_HTTP_INTERNAL_SERVER_ERROR);
17165  return gsad_message (
17166  credentials, "Internal error", __FUNCTION__, __LINE__,
17167  "An internal error occurred while creating a new user. "
17168  "No new user was created. "
17169  "Diagnostics: Failure to send command to manager daemon.",
17170  response_data);
17171  case 2:
17172  cmd_response_data_set_status_code (response_data,
17173  MHD_HTTP_INTERNAL_SERVER_ERROR);
17174  return gsad_message (
17175  credentials, "Internal error", __FUNCTION__, __LINE__,
17176  "An internal error occurred while creating a new user. "
17177  "It is unclear whether the user has been created or not. "
17178  "Diagnostics: Failure to receive response from manager daemon.",
17179  response_data);
17180  default:
17181  cmd_response_data_set_status_code (response_data,
17182  MHD_HTTP_INTERNAL_SERVER_ERROR);
17183  return gsad_message (
17184  credentials, "Internal error", __FUNCTION__, __LINE__,
17185  "An internal error occurred while creating a new user. "
17186  "It is unclear whether the user has been created or not. "
17187  "Diagnostics: Internal Error.",
17188  response_data);
17189  }
17190 
17191  if (entity_attribute (entity, "id"))
17192  params_add (params, "user_id", entity_attribute (entity, "id"));
17193  html = response_from_entity (connection, credentials, params, entity,
17194  "Create User", response_data);
17195  free_entity (entity);
17196  g_free (response);
17197  return html;
17198 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ cvss_calculator()

char* cvss_calculator ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

Definition at line 17574 of file gsad_gmp.c.

17576 {
17577  GString *xml;
17578  const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
17579  const char *cvss_vector, *name;
17580 
17581  cvss_av = params_value (params, "cvss_av");
17582  cvss_au = params_value (params, "cvss_au");
17583  cvss_ac = params_value (params, "cvss_ac");
17584  cvss_c = params_value (params, "cvss_c");
17585  cvss_i = params_value (params, "cvss_i");
17586  cvss_a = params_value (params, "cvss_a");
17587  cvss_vector = params_value (params, "cvss_vector");
17588  name = params_value (params, "name");
17589 
17590  xml = g_string_new ("<cvss_calculator>");
17591 
17592  /* Calculate base score */
17593  if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
17594  {
17595  char *vector =
17596  g_strdup_printf ("AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c", *cvss_av, *cvss_ac,
17597  *cvss_au, *cvss_c, *cvss_i, *cvss_a);
17598 
17599  g_string_append_printf (xml,
17600  "<cvss_vector>%s</cvss_vector>"
17601  "<cvss_score>%.1f</cvss_score>",
17602  vector,
17603  get_cvss_score_from_base_metrics (vector));
17604 
17605  g_string_append_printf (xml,
17606  "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>"
17607  "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>"
17608  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
17609  *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i,
17610  *cvss_a);
17611 
17612  g_free (vector);
17613  }
17614  else if (cvss_vector)
17615  {
17616  double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
17617 
17618  g_string_append_printf (xml,
17619  "<cvss_vector>%s</cvss_vector>"
17620  "<cvss_score>%.1f</cvss_score>",
17621  cvss_vector, cvss_score);
17622 
17623  if (cvss_score != -1.0)
17624  {
17625  cvss_av = strstr (cvss_vector, "AV:");
17626  cvss_ac = strstr (cvss_vector, "/AC:");
17627  cvss_au = strstr (cvss_vector, "/Au:");
17628  if (cvss_au == NULL)
17629  cvss_au = strstr (cvss_vector, "/AU:");
17630  cvss_c = strstr (cvss_vector, "/C:");
17631  cvss_i = strstr (cvss_vector, "/I:");
17632  cvss_a = strstr (cvss_vector, "/A:");
17633 
17634  if (cvss_av && cvss_ac && cvss_au && cvss_c && cvss_i && cvss_a)
17635  g_string_append_printf (xml,
17636  "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>"
17637  "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>"
17638  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
17639  *(cvss_av + 3), *(cvss_ac + 4),
17640  *(cvss_au + 4), *(cvss_c + 3),
17641  *(cvss_i + 3), *(cvss_a + 3));
17642  }
17643  }
17644  else if (name && !strcmp ("vector", name))
17645  {
17646  g_string_append_printf (xml, "<cvss_score>%.1f</cvss_score>", -1.0);
17647  }
17648 
17649  g_string_append (xml, "</cvss_calculator>");
17650  return envelope_gmp (connection, credentials, params,
17651  g_string_free (xml, FALSE), response_data);
17652 }
Structure of credential related information.
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

References envelope_gmp(), and params_value().

Here is the call graph for this function:

◆ delete_agent_gmp()

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

Delete agent, get all agents, envelope result.

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

Definition at line 4571 of file gsad_gmp.c.

4573 {
4574  return move_resource_to_trash (connection, "agent", credentials, params,
4575  response_data);
4576 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_alert_gmp()

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

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

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

Definition at line 5824 of file gsad_gmp.c.

5826 {
5827  return move_resource_to_trash (connection, "alert", credentials, params,
5828  response_data);
5829 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_asset_gmp()

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

Delete an asset, go to the next page.

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

Definition at line 18748 of file gsad_gmp.c.

18750 {
18751  gchar *html, *response, *resource_id;
18752  const char *next_id;
18753  entity_t entity;
18754 
18755  if (params_value (params, "asset_id"))
18756  resource_id = g_strdup (params_value (params, "asset_id"));
18757  else if (params_value (params, "report_id"))
18758  resource_id = g_strdup (params_value (params, "report_id"));
18759  else
18760  {
18761  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
18762  return gsad_message (
18763  credentials, "Internal error", __FUNCTION__, __LINE__,
18764  "An internal error occurred while deleting an asset. "
18765  "The asset was not deleted. "
18766  "Diagnostics: Required parameter was NULL.",
18767  response_data);
18768  }
18769 
18770  /* This is a hack, needed because asset_id is the param name used for
18771  * both the asset being deleted and the asset on the next page. */
18772  next_id = params_value (params, "next_id");
18773  if (next_id && params_value (params, "asset_id"))
18774  {
18775  param_t *param;
18776  param = params_get (params, "asset_id");
18777  g_free (param->value);
18778  param->value = g_strdup (next_id);
18779  param->value_size = strlen (param->value);
18780  }
18781 
18782  /* Delete the resource and get all resources. */
18783 
18784  if (gvm_connection_sendf (
18785  connection, "<delete_asset %s_id=\"%s\"/>",
18786  params_value (params, "asset_id") ? "asset" : "report", resource_id)
18787  == -1)
18788  {
18789  g_free (resource_id);
18790  cmd_response_data_set_status_code (response_data,
18791  MHD_HTTP_INTERNAL_SERVER_ERROR);
18792  return gsad_message (
18793  credentials, "Internal error", __FUNCTION__, __LINE__,
18794  "An internal error occurred while deleting an asset. "
18795  "The asset is not deleted. "
18796  "Diagnostics: Failure to send command to manager daemon.",
18797  response_data);
18798  }
18799 
18800  g_free (resource_id);
18801 
18802  entity = NULL;
18803  if (read_entity_and_text_c (connection, &entity, &response))
18804  {
18805  cmd_response_data_set_status_code (response_data,
18806  MHD_HTTP_INTERNAL_SERVER_ERROR);
18807  return gsad_message (
18808  credentials, "Internal error", __FUNCTION__, __LINE__,
18809  "An internal error occurred while deleting an asset. "
18810  "It is unclear whether the asset has been deleted or not. "
18811  "Diagnostics: Failure to read response from manager daemon.",
18812  response_data);
18813  }
18814 
18815  /* Cleanup, and return transformed XML. */
18816 
18817  html = response_from_entity (connection, credentials, params, entity,
18818  "Delete Asset", response_data);
18819  g_free (response);
18820  free_entity (entity);
18821  return html;
18822 }
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:173
int value_size
Definition: gsad_params.h:46
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ delete_config_gmp()

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

Delete config, get all configs, envelope the result.

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

Definition at line 9360 of file gsad_gmp.c.

9362 {
9363  return move_resource_to_trash (connection, "config", credentials, params,
9364  response_data);
9365 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_credential_gmp()

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

Delete credential, get all credentials, envelope result.

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

Definition at line 4179 of file gsad_gmp.c.

4181 {
4182  return move_resource_to_trash (connection, "credential", credentials, params,
4183  response_data);
4184 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_filter_gmp()

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

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

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

Definition at line 16578 of file gsad_gmp.c.

16580 {
16581  param_t *filt_id, *id;
16582 
16583  filt_id = params_get (params, "filt_id");
16584  id = params_get (params, "filter_id");
16585  if (id && id->value && filt_id && filt_id->value
16586  && (strcmp (id->value, filt_id->value) == 0))
16587  // TODO: Add params_remove.
16588  filt_id->value = NULL;
16589 
16590  return move_resource_to_trash (connection, "filter", credentials, params,
16591  response_data);
16592 }
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:173
Request parameter.
Definition: gsad_params.h:38
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash(), params_get(), and param::value.

Here is the call graph for this function:

◆ delete_from_trash_gmp()

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

Delete a resource from the trashcan.

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

Definition at line 2042 of file gsad_gmp.c.

2044 {
2045  const gchar *resource_type;
2046 
2047  resource_type = params_value (params, "resource_type");
2048 
2049  CHECK_VARIABLE_INVALID (resource_type, "Delete from Trashcan");
2050 
2051  return delete_resource (connection, resource_type, credentials, params, TRUE,
2052  response_data);
2053 }
Structure of credential related information.
char * delete_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
Delete a resource, get all resources, envelope the result.
Definition: gsad_gmp.c:1915
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205

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

Here is the call graph for this function:

◆ delete_group_gmp()

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

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

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

Definition at line 14135 of file gsad_gmp.c.

14137 {
14138  return move_resource_to_trash (connection, "group", credentials, params,
14139  response_data);
14140 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_note_gmp()

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

Delete note, get next page, envelope the result.

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

Definition at line 11070 of file gsad_gmp.c.

11072 {
11073  return move_resource_to_trash (connection, "note", credentials, params,
11074  response_data);
11075 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_override_gmp()

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

Delete override, get next page, envelope the result.

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

Definition at line 11387 of file gsad_gmp.c.

11389 {
11390  return move_resource_to_trash (connection, "override", credentials, params,
11391  response_data);
11392 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_permission_gmp()

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

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

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

Definition at line 14448 of file gsad_gmp.c.

14450 {
14451  return move_resource_to_trash (connection, "permission", credentials, params,
14452  response_data);
14453 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_port_list_gmp()

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

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

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

Definition at line 15689 of file gsad_gmp.c.

15691 {
15692  return move_resource_to_trash (connection, "port_list", credentials, params,
15693  response_data);
15694 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_port_range_gmp()

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

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

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

Definition at line 15707 of file gsad_gmp.c.

15709 {
15710  return delete_resource (connection, "port_range", credentials, params, TRUE,
15711  response_data);
15712 }
Structure of credential related information.
char * delete_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
Delete a resource, get all resources, envelope the result.
Definition: gsad_gmp.c:1915

References delete_resource().

Here is the call graph for this function:

◆ delete_report_format_gmp()

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

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

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

Definition at line 12566 of file gsad_gmp.c.

12569 {
12570  return move_resource_to_trash (connection, "report_format", credentials,
12571  params, response_data);
12572 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_report_gmp()

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

Delete report, get task status, envelope the result.

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

Definition at line 9661 of file gsad_gmp.c.

9663 {
9664  return delete_resource (connection, "report", credentials, params, TRUE,
9665  response_data);
9666 }
Structure of credential related information.
char * delete_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, gboolean ultimate, cmd_response_data_t *response_data)
Delete a resource, get all resources, envelope the result.
Definition: gsad_gmp.c:1915

References delete_resource().

Here is the call graph for this function:

◆ delete_role_gmp()

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

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

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

Definition at line 15799 of file gsad_gmp.c.

15801 {
15802  return move_resource_to_trash (connection, "role", credentials, params,
15803  response_data);
15804 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_scanner_gmp()

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

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

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

Definition at line 11788 of file gsad_gmp.c.

11790 {
11791  return move_resource_to_trash (connection, "scanner", credentials, params,
11792  response_data);
11793 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_schedule_gmp()

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

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

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

Definition at line 12119 of file gsad_gmp.c.

12121 {
12122  return move_resource_to_trash (connection, "schedule", credentials, params,
12123  response_data);
12124 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_slave_gmp()

char* delete_slave_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ delete_tag_gmp()

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

Delete note, get next page, envelope the result.

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

Definition at line 7210 of file gsad_gmp.c.

7212 {
7213  return move_resource_to_trash (connection, "tag", credentials, params,
7214  response_data);
7215 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_target_gmp()

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

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

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

Definition at line 6955 of file gsad_gmp.c.

6957 {
6958  return move_resource_to_trash (connection, "target", credentials, params,
6959  response_data);
6960 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_task_gmp()

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

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

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

Definition at line 2810 of file gsad_gmp.c.

2812 {
2813  return move_resource_to_trash (connection, "task", credentials, params,
2814  response_data);
2815 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_ticket_gmp()

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

Delete a ticket.

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

Definition at line 19142 of file gsad_gmp.c.

19144 {
19145  return move_resource_to_trash (connection, "ticket", credentials, params,
19146  response_data);
19147 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ delete_user_gmp()

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

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

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

Definition at line 16843 of file gsad_gmp.c.

16845 {
16846  return move_resource_to_trash (connection, "user", credentials, params,
16847  response_data);
16848 }
Structure of credential related information.
char * move_resource_to_trash(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Move a resource to the trashcan.
Definition: gsad_gmp.c:2022

References move_resource_to_trash().

Here is the call graph for this function:

◆ download_agent_gmp()

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

Get an agent, envelope the result.

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

Definition at line 4592 of file gsad_gmp.c.

4595 {
4596  entity_t entity;
4597  const char *agent_id, *format;
4598  gsize result_len = 0;
4599 
4600  agent_id = params_value (params, "agent_id");
4601  format = params_value (params, "agent_format");
4602 
4603  if ((agent_id == NULL) || (format == NULL))
4604  {
4605  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
4606  *html =
4607  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
4608  "An internal error occurred while downloading "
4609  "an agent. "
4610  "Diagnostics: Required parameter was NULL.",
4611  response_data);
4612  return 1;
4613  }
4614 
4615  /* Send the request. */
4616 
4617  if (gvm_connection_sendf (connection,
4618  "<get_agents agent_id=\"%s\" format=\"%s\"/>",
4619  agent_id, format)
4620  == -1)
4621  {
4622  cmd_response_data_set_status_code (response_data,
4623  MHD_HTTP_INTERNAL_SERVER_ERROR);
4624  *html =
4625  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
4626  "An internal error occurred while getting agent list. "
4627  "The current list of agents is not available. "
4628  "Diagnostics: Failure to send command to manager daemon.",
4629  response_data);
4630  return 1;
4631  }
4632 
4633  /* Read and handle the response. */
4634 
4635  if (strcmp (format, "installer") == 0 || strcmp (format, "howto_install") == 0
4636  || strcmp (format, "howto_use") == 0)
4637  {
4638  gchar *package_decoded = NULL;
4639  entity_t package_entity = NULL, agent_entity;
4640 
4641  /* A base64 encoded package. */
4642 
4643  entity = NULL;
4644  if (read_entity_c (connection, &entity))
4645  {
4646  cmd_response_data_set_status_code (response_data,
4647  MHD_HTTP_INTERNAL_SERVER_ERROR);
4648  *html = gsad_message (
4649  credentials, "Internal error", __FUNCTION__, __LINE__,
4650  "An internal error occurred while getting a agent. "
4651  "The agent is not available. "
4652  "Diagnostics: Failure to receive response from manager daemon.",
4653  response_data);
4654  return 1;
4655  }
4656 
4657  agent_entity = entity_child (entity, "agent");
4658  if (agent_entity)
4659  package_entity = entity_child (agent_entity, "package");
4660  if (package_entity != NULL)
4661  {
4662  char *package_encoded = entity_text (package_entity);
4663  if (strlen (package_encoded))
4664  {
4665  package_decoded =
4666  (gchar *) g_base64_decode (package_encoded, &result_len);
4667  if (package_decoded == NULL)
4668  {
4669  package_decoded = (gchar *) g_strdup ("");
4670  result_len = 0;
4671  }
4672  }
4673  else
4674  {
4675  package_decoded = (gchar *) g_strdup ("");
4676  result_len = 0;
4677  }
4678  *html = package_decoded;
4679  if (filename)
4680  {
4681  entity_t filename_entity;
4682  filename_entity = entity_child (package_entity, "filename");
4683  if (filename_entity)
4684  *filename = g_strdup (entity_text (filename_entity));
4685  else
4686  *filename = NULL;
4687  if (!(*filename && strlen (*filename)))
4688  {
4689  g_free (*filename);
4690  *filename = g_strdup_printf ("agent-%s-%s", agent_id, format);
4691  }
4692  }
4693  cmd_response_data_set_content_length (response_data, result_len);
4694  free_entity (entity);
4695  return 0;
4696  }
4697  else
4698  {
4699  free_entity (entity);
4700  cmd_response_data_set_status_code (response_data,
4701  MHD_HTTP_INTERNAL_SERVER_ERROR);
4702  *html = gsad_message (
4703  credentials, "Internal error", __FUNCTION__, __LINE__,
4704  "An internal error occurred while getting a agent. "
4705  "The agent could not be delivered. "
4706  "Diagnostics: Failure to receive agent from manager daemon.",
4707  response_data);
4708  return 1;
4709  }
4710  }
4711  else
4712  {
4713  /* An error. */
4714 
4715  entity = NULL;
4716  if (read_entity_c (connection, &entity))
4717  {
4718  cmd_response_data_set_status_code (response_data,
4719  MHD_HTTP_INTERNAL_SERVER_ERROR);
4720  *html = gsad_message (
4721  credentials, "Internal error", __FUNCTION__, __LINE__,
4722  "An internal error occurred while getting a agent. "
4723  "The agent could not be delivered. "
4724  "Diagnostics: Failure to receive agent from manager daemon.",
4725  response_data);
4726  return 1;
4727  }
4728 
4729  free_entity (entity);
4730  cmd_response_data_set_status_code (response_data,
4731  MHD_HTTP_INTERNAL_SERVER_ERROR);
4732  *html = gsad_message (
4733  credentials, "Internal error", __FUNCTION__, __LINE__,
4734  "An internal error occurred while getting a agent. "
4735  "The agent could not be delivered. "
4736  "Diagnostics: Failure to parse agent from manager daemon.",
4737  response_data);
4738  return 1;
4739  }
4740 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ download_ca_pub()

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

Get a Scanner's CA Certificate.

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

Definition at line 10605 of file gsad_gmp.c.

10607 {
10608  const char *ca_pub;
10609  char *unescaped;
10610 
10611  ca_pub = params_value (params, "ca_pub");
10612  if (ca_pub == NULL)
10613  {
10614  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
10615  return gsad_message (credentials, "Internal error", __FUNCTION__,
10616  __LINE__,
10617  "An internal error occurred."
10618  " Diagnostics: ca_pub was NULL.",
10619  response_data);
10620  }
10621  /* The Base64 comes URI escaped as it may contain special characters. */
10622  unescaped = g_uri_unescape_string (ca_pub, NULL);
10623  cmd_response_data_set_content_length (response_data, strlen (unescaped));
10624  return unescaped;
10625 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ download_credential_gmp()

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

Export a Credential in a defined format.

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

Definition at line 3917 of file gsad_gmp.c.

3921 {
3922  entity_t entity;
3923  const char *credential_id, *format;
3924 
3925  assert (html);
3926 
3927  /* Send the request. */
3928 
3929  credential_id = params_value (params, "credential_id");
3930  format = params_value (params, "package_format");
3931 
3932  if ((credential_id == NULL) || (format == NULL))
3933  {
3934  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
3935  *html =
3936  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
3937  "An internal error occurred while getting a credential. "
3938  "Diagnostics: Required parameter was NULL.",
3939  response_data);
3940  return 1;
3941  }
3942 
3943  if (gvm_connection_sendf (connection,
3944  "<get_credentials"
3945  " credential_id=\"%s\""
3946  " format=\"%s\"/>",
3947  credential_id, format)
3948  == -1)
3949  {
3950  cmd_response_data_set_status_code (response_data,
3951  MHD_HTTP_INTERNAL_SERVER_ERROR);
3952  *html =
3953  gsad_message (credentials, "Internal error", __FUNCTION__, __LINE__,
3954  "An internal error occurred while getting a credential. "
3955  "Diagnostics: Failure to send command to manager daemon.",
3956  response_data);
3957  return 1;
3958  }
3959 
3960  /* Read and handle the response. */
3961 
3962  if (strcmp (format, "rpm") == 0 || strcmp (format, "deb") == 0
3963  || strcmp (format, "exe") == 0)
3964  {
3965  gchar *package_decoded = NULL;
3966  entity_t package_entity = NULL, credential_entity;
3967 
3968  /* A base64 encoded package. */
3969 
3970  entity = NULL;
3971  if (read_entity_c (connection, &entity))
3972  {
3973  cmd_response_data_set_status_code (response_data,
3974  MHD_HTTP_INTERNAL_SERVER_ERROR);
3975  *html = gsad_message (
3976  credentials, "Internal error", __FUNCTION__, __LINE__,
3977  "An internal error occurred while getting a credential. "
3978  "The credential is not available. "
3979  "Diagnostics: Failure to receive response from manager daemon.",
3980  response_data);
3981  return 1;
3982  }
3983 
3984  credential_entity = entity_child (entity, "credential");
3985  if (credential_entity)
3986  package_entity = entity_child (credential_entity, "package");
3987  if (package_entity != NULL)
3988  {
3989  gsize len;
3990  char *package_encoded = entity_text (package_entity);
3991  if (strlen (package_encoded))
3992  {
3993  package_decoded =
3994  (gchar *) g_base64_decode (package_encoded, &len);
3995  if (package_decoded == NULL)
3996  {
3997  package_decoded = (gchar *) g_strdup ("");
3998  len = 0;
3999  }
4000  }
4001  else
4002  {
4003  package_decoded = (gchar *) g_strdup ("");
4004  len = 0;
4005  }
4006 
4007  cmd_response_data_set_content_length (response_data, len);
4008 
4009  *html = package_decoded;
4010  if (login)
4011  {
4012  entity_t login_entity;
4013  login_entity = entity_child (credential_entity, "login");
4014  if (login_entity)
4015  *login = g_strdup (entity_text (login_entity));
4016  else
4017  *login = NULL;
4018  }
4019  free_entity (entity);
4020  return 0;
4021  }
4022  else
4023  {
4024  free_entity (entity);
4025  cmd_response_data_set_status_code (response_data,
4026  MHD_HTTP_INTERNAL_SERVER_ERROR);
4027  *html = gsad_message (
4028  credentials, "Internal error", __FUNCTION__, __LINE__,
4029  "An internal error occurred while getting a credential. "
4030  "The credential could not be delivered. "
4031  "Diagnostics: Failure to receive credential from manager daemon.",
4032  response_data);
4033  return 1;
4034  }
4035  }
4036  else
4037  {
4038  entity_t credential_entity, key_entity = NULL;
4039 
4040  /* A key or certificate. */
4041 
4042  entity = NULL;
4043  if (read_entity_c (connection, &entity))
4044  {
4045  cmd_response_data_set_status_code (response_data,
4046  MHD_HTTP_INTERNAL_SERVER_ERROR);
4047  *html = gsad_message (
4048  credentials, "Internal error", __FUNCTION__, __LINE__,
4049  "An internal error occurred while getting a credential. "
4050  "The credential could not be delivered. "
4051  "Diagnostics: Failure to receive credential from manager daemon.",
4052  response_data);
4053  return 1;
4054  }
4055 
4056  credential_entity = entity_child (entity, "credential");
4057  if (credential_entity)
4058  {
4059  if (strcmp (format, "pem") == 0)
4060  key_entity = entity_child (credential_entity, "certificate");
4061  else
4062  key_entity = entity_child (credential_entity, "public_key");
4063  }
4064  if (key_entity != NULL)
4065  {
4066  *html = g_strdup (entity_text (key_entity));
4067  if (login)
4068  {
4069  entity_t login_entity = entity_child (credential_entity, "login");
4070  if (login_entity)
4071  *login = g_strdup (entity_text (login_entity));
4072  else
4073  *login = NULL;
4074  }
4075  free_entity (entity);
4076  return 0;
4077  }
4078  cmd_response_data_set_status_code (response_data,
4079  MHD_HTTP_INTERNAL_SERVER_ERROR);
4080  *html = gsad_message (
4081  credentials, "Internal error", __FUNCTION__, __LINE__,
4082  "An internal error occurred while getting a credential. "
4083  "The credential could not be delivered. "
4084  "Diagnostics: Failure to parse credential from manager daemon.",
4085  response_data);
4086  free_entity (entity);
4087  return 1;
4088  }
4089 }
Structure of credential related information.
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:19384
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ download_key_pub()

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

Get a Scanner's Certificate.

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

Definition at line 10638 of file gsad_gmp.c.

10640 {
10641  const char *key_pub;
10642  char *unescaped;
10643 
10644  key_pub = params_value (params, "key_pub");
10645  if (key_pub == NULL)
10646  {
10647  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
10648  return gsad_message (credentials, "Internal error", __FUNCTION__,
10649  __LINE__,
10650  "An internal error occurred."
10651  " Diagnostics: key_pub was NULL.",
10652  response_data);
10653  }
10654 
10655  /* The Base64 comes URI escaped as it may contain special characters. */
10656  unescaped = g_uri_unescape_string (key_pub, NULL);
10657  cmd_response_data_set_content_length (response_data, strlen (unescaped));
10658  return unescaped;
10659 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ download_ssl_cert()

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

Get an SSL Certificate.

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

Definition at line 10564 of file gsad_gmp.c.

10566 {
10567  const char *ssl_cert;
10568  gchar *cert;
10569  char *unescaped;
10570 
10571  ssl_cert = params_value (params, "ssl_cert");
10572  if (ssl_cert == NULL)
10573  {
10574  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
10575  return gsad_message (credentials, "Internal error", __FUNCTION__,
10576  __LINE__,
10577  "An internal error occurred."
10578  " Diagnostics: ssl_cert was NULL.",
10579  response_data);
10580  }
10581  /* The Base64 comes URI escaped as it may contain special characters. */
10582  unescaped = g_uri_unescape_string (ssl_cert, NULL);
10583 
10584  cert = g_strdup_printf ("-----BEGIN CERTIFICATE-----\n"
10585  "%s\n-----END CERTIFICATE-----\n",
10586  unescaped);
10587 
10588  cmd_response_data_set_content_length (response_data, strlen (cert));
10589 
10590  g_free (unescaped);
10591  return cert;
10592 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ edit_alert_gmp()

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

Setup edit_alert XML, envelope the result.

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

Definition at line 6410 of file gsad_gmp.c.

6412 {
6413  return edit_alert (connection, credentials, params, NULL, response_data);
6414 }
Structure of credential related information.
char * edit_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, envelope the result.
Definition: gsad_gmp.c:6182

References edit_alert().

Here is the call graph for this function:

◆ edit_config_family_gmp()

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

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

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

Definition at line 8862 of file gsad_gmp.c.

8865 {
8866  return get_config_family (connection, credentials, params, 1, response_data);
8867 }
Structure of credential related information.
static char * get_config_family(gvm_connection_t *, credentials_t *, params_t *, int, cmd_response_data_t *)
Get details of a family for a config, envelope the result.
Definition: gsad_gmp.c:8712

References get_config_family().

Here is the call graph for this function:

◆ edit_config_gmp()

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

Get a config, envelope the result.

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

Definition at line 8309 of file gsad_gmp.c.

8311 {
8312  return edit_config (connection, credentials, params, NULL, response_data);
8313 }
Structure of credential related information.
static char * edit_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Get a config, envelope the result.
Definition: gsad_gmp.c:8290

References edit_config().

Here is the call graph for this function:

◆ edit_config_nvt_gmp()

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

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

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

Definition at line 9125 of file gsad_gmp.c.

9127 {
9128  return get_config_nvt (connection, credentials, params, 1, response_data);
9129 }
Structure of credential related information.
static char * get_config_nvt(gvm_connection_t *connection, credentials_t *credentials, params_t *params, int edit, cmd_response_data_t *response_data)
Get details of an NVT for a config, envelope the result.
Definition: gsad_gmp.c:8968

References get_config_nvt().

Here is the call graph for this function:

◆ edit_role_gmp()

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

Setup edit_role XML, envelope the result.

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

Definition at line 16020 of file gsad_gmp.c.

16022 {
16023  return edit_role (connection, credentials, params, NULL, response_data);
16024 }
Structure of credential related information.
static char * edit_role(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Setup edit_role XML, envelope the result.
Definition: gsad_gmp.c:15896

References edit_role().

Here is the call graph for this function:

◆ empty_trashcan_gmp()

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

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

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

Definition at line 7040 of file gsad_gmp.c.

7042 {
7043  GString *xml;
7044  gchar *ret;
7045  entity_t entity;
7046 
7047  xml = g_string_new ("");
7048 
7049  /* Empty the trash. */
7050 
7051  if (gvm_connection_sendf (connection, "<empty_trashcan/>") == -1)
7052  {
7053  g_string_free (xml, TRUE);
7054  cmd_response_data_set_status_code (response_data,
7055  MHD_HTTP_INTERNAL_SERVER_ERROR);
7056  return gsad_message (
7057  credentials, "Internal error", __FUNCTION__, __LINE__,
7058  "An internal error occurred while emptying the trashcan. "
7059  "Diagnostics: Failure to send command to manager daemon.",
7060  response_data);
7061  }
7062 
7063  if (read_entity_and_string_c (connection, &entity, &xml))
7064  {
7065  g_string_free (xml, TRUE);
7066  cmd_response_data_set_status_code (response_data,
7067  MHD_HTTP_INTERNAL_SERVER_ERROR);
7068  return gsad_message (
7069  credentials, "Internal error", __FUNCTION__, __LINE__,
7070  "An internal error occurred while emptying the trashcan. "
7071  "Diagnostics: Failure to read response from manager daemon.",
7072  response_data);
7073  }
7074 
7075  /* Cleanup, and return trash page. */
7076 
7077  ret = response_from_entity (connection, credentials, params, entity,
7078  "Empty Trashcan", response_data);
7079  free_entity (entity);
7080  g_string_free (xml, FALSE);
7081  return ret;
7082 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ export_agent_gmp()

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

Export a agent.

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

Definition at line 4981 of file gsad_gmp.c.

4983 {
4984  return export_resource (connection, "agent", credentials, params,
4985  response_data);
4986 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_agents_gmp()

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

Export a list of agents.

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

Definition at line 5000 of file gsad_gmp.c.

5002 {
5003  return export_many (connection, "agent", credentials, params, response_data);
5004 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_alert_gmp()

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

Export an alert.

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

Definition at line 6632 of file gsad_gmp.c.

6634 {
6635  return export_resource (connection, "alert", credentials, params,
6636  response_data);
6637 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_alerts_gmp()

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

Export a list of alerts.

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

Definition at line 6651 of file gsad_gmp.c.

6653 {
6654  return export_many (connection, "alert", credentials, params, response_data);
6655 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_asset_gmp()

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

Export an asset.

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

Definition at line 18835 of file gsad_gmp.c.

18837 {
18838  return export_resource (connection, "asset", credentials, params,
18839  response_data);
18840 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_assets_gmp()

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

Export a list of assets.

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

Definition at line 18854 of file gsad_gmp.c.

18856 {
18857  return export_many (connection, "asset", credentials, params, response_data);
18858 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_config_gmp()

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

Export a config.

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

Definition at line 9378 of file gsad_gmp.c.

9380 {
9381  return export_resource (connection, "config", credentials, params,
9382  response_data);
9383 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_configs_gmp()

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

Export a list of scan configs.

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

Definition at line 9397 of file gsad_gmp.c.

9399 {
9400  return export_many (connection, "config", credentials, params, response_data);
9401 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_credential_gmp()

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

Export a Credential.

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

Definition at line 4103 of file gsad_gmp.c.

4105 {
4106  return export_resource (connection, "credential", credentials, params,
4107  response_data);
4108 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_credentials_gmp()

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

Export a list of Credentials.

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

Definition at line 4122 of file gsad_gmp.c.

4125 {
4126  return export_many (connection, "credential", credentials, params,
4127  response_data);
4128 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_filter_gmp()

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

Export a filter.

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

Definition at line 16605 of file gsad_gmp.c.

16607 {
16608  return export_resource (connection, "filter", credentials, params,
16609  response_data);
16610 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_filters_gmp()

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

Export a list of filters.

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

Definition at line 16624 of file gsad_gmp.c.

16626 {
16627  return export_many (connection, "filter", credentials, params, response_data);
16628 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_group_gmp()

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

Export a group.

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

Definition at line 14254 of file gsad_gmp.c.

14256 {
14257  return export_resource (connection, "group", credentials, params,
14258  response_data);
14259 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_groups_gmp()

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

Export a list of groups.

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

Definition at line 14273 of file gsad_gmp.c.

14275 {
14276  return export_many (connection, "group", credentials, params, response_data);
14277 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_note_gmp()

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

Export a note.

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

Definition at line 9414 of file gsad_gmp.c.

9416 {
9417  return export_resource (connection, "note", credentials, params,
9418  response_data);
9419 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_notes_gmp()

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

Export a list of notes.

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

Definition at line 9433 of file gsad_gmp.c.

9435 {
9436  return export_many (connection, "note", credentials, params, response_data);
9437 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_override_gmp()

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

Export an override.

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

Definition at line 9450 of file gsad_gmp.c.

9452 {
9453  return export_resource (connection, "override", credentials, params,
9454  response_data);
9455 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_overrides_gmp()

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

Export a list of overrides.

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

Definition at line 9469 of file gsad_gmp.c.

9471 {
9472  return export_many (connection, "override", credentials, params,
9473  response_data);
9474 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_permission_gmp()

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

Export a permission.

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

Definition at line 15228 of file gsad_gmp.c.

15230 {
15231  return export_resource (connection, "permission", credentials, params,
15232  response_data);
15233 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_permissions_gmp()

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

Export a list of permissions.

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

Definition at line 15247 of file gsad_gmp.c.

15250 {
15251  return export_many (connection, "permission", credentials, params,
15252  response_data);
15253 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_port_list_gmp()

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

Export a Port List.

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

Definition at line 9488 of file gsad_gmp.c.

9490 {
9491  return export_resource (connection, "port_list", credentials, params,
9492  response_data);
9493 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_port_lists_gmp()

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

Export a list of Port Lists.

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

Definition at line 9507 of file gsad_gmp.c.

9509 {
9510  return export_many (connection, "port_list", credentials, params,
9511  response_data);
9512 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_preference_file_gmp()

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

Export a file preference.

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

Definition at line 9525 of file gsad_gmp.c.

9528 {
9529  GString *xml;
9530  entity_t entity, preference_entity, value_entity;
9531  const char *config_id, *oid, *preference_name;
9532 
9533  config_id = params_value (params, "config_id");
9534  oid = params_value (params, "oid");
9535  preference_name = params_value (params, "preference_name");
9536 
9537  xml = g_string_new ("<get_preferences_response>");
9538 
9539  CHECK_VARIABLE_INVALID (config_id, "Export Preference File")
9540  CHECK_VARIABLE_INVALID (oid, "Export Preference File")
9541  CHECK_VARIABLE_INVALID (preference_name, "Export Preference File")
9542 
9543  if (gvm_connection_sendf (connection,
9544  "<get_preferences"
9545  " config_id=\"%s\""
9546  " nvt_oid=\"%s\""
9547  " preference=\"%s\"/>",
9548  config_id, oid, preference_name)
9549  == -1)
9550  {
9551  g_string_free (xml, TRUE);
9552  cmd_response_data_set_status_code (response_data,
9553  MHD_HTTP_INTERNAL_SERVER_ERROR);
9554  return gsad_message (
9555  credentials, "Internal error", __FUNCTION__, __LINE__,
9556  "An internal error occurred while getting a preference file. "
9557  "The file could not be delivered. "
9558  "Diagnostics: Failure to send command to manager daemon.",
9559  response_data);
9560  }
9561 
9562  entity = NULL;
9563  if (read_entity_c (connection, &entity))
9564  {
9565  g_string_free (xml, TRUE);
9566  cmd_response_data_set_status_code (response_data,
9567  MHD_HTTP_INTERNAL_SERVER_ERROR);
9568  return gsad_message (
9569  credentials, "Internal error", __FUNCTION__, __LINE__,
9570  "An internal error occurred while getting a preference file. "
9571  "The file could not be delivered. "
9572  "Diagnostics: Failure to receive response from manager daemon.",
9573  response_data);
9574  }
9575 
9576  preference_entity = entity_child (entity, "preference");
9577  if (preference_entity != NULL
9578  && (value_entity = entity_child (preference_entity, "value")))
9579  {
9580  char *content = strdup (entity_text (value_entity));
9581  cmd_response_data_set_content_type (response_data,
9584  response_data,
9585  g_strdup_printf ("attachment; filename=\"pref_file.bin\""));
9586  cmd_response_data_set_content_length (response_data, strlen (content));
9587  free_entity (entity);
9588  g_string_free (xml, TRUE);
9589  return content;
9590  }
9591  else
9592  {
9593  free_entity (entity);
9594  g_string_free (xml, TRUE);
9595  cmd_response_data_set_status_code (response_data,
9596  MHD_HTTP_INTERNAL_SERVER_ERROR);
9597  return gsad_message (
9598  credentials, "Internal error", __FUNCTION__, __LINE__,
9599  "An internal error occurred while getting a preference file. "
9600  "The file could not be delivered. "
9601  "Diagnostics: Failure to receive file from manager daemon.",
9602  response_data);
9603  }
9604 
9605  g_string_append (xml, "</get_preferences_response>");
9606  return envelope_gmp (connection, credentials, params,
9607  g_string_free (xml, FALSE), response_data);
9608 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
void cmd_response_data_set_content_disposition(cmd_response_data_t *data, gchar *content_disposition)
Set content disposition of cmd_response_data_t struct.
Definition: gsad_cmd.c:212
void cmd_response_data_set_content_type(cmd_response_data_t *data, content_type_t content_type)
Set content type of cmd_response_data_t struct.
Definition: gsad_cmd.c:134
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ export_report_format_gmp()

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

Export a report format.

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

Definition at line 9622 of file gsad_gmp.c.

9625 {
9626  return export_resource (connection, "report_format", credentials, params,
9627  response_data);
9628 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_report_formats_gmp()

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

Export a list of Report Formats.

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

Definition at line 9642 of file gsad_gmp.c.

9645 {
9646  return export_many (connection, "report_format", credentials, params,
9647  response_data);
9648 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_result_gmp()

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

Export a result.

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

Definition at line 10673 of file gsad_gmp.c.

10675 {
10676  return export_resource (connection, "result", credentials, params,
10677  response_data);
10678 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_results_gmp()

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

Export a list of results.

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

Definition at line 10692 of file gsad_gmp.c.

10694 {
10695  return export_many (connection, "result", credentials, params, response_data);
10696 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_role_gmp()

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

Export a role.

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

Definition at line 16111 of file gsad_gmp.c.

16113 {
16114  return export_resource (connection, "role", credentials, params,
16115  response_data);
16116 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_roles_gmp()

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

Export a list of roles.

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

Definition at line 16130 of file gsad_gmp.c.

16132 {
16133  return export_many (connection, "role", credentials, params, response_data);
16134 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_scanner_gmp()

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

Export a scanner.

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

Definition at line 11590 of file gsad_gmp.c.

11592 {
11593  return export_resource (connection, "scanner", credentials, params,
11594  response_data);
11595 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_scanners_gmp()

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

Export a list of scanners.

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

Definition at line 11608 of file gsad_gmp.c.

11610 {
11611  return export_many (connection, "scanner", credentials, params,
11612  response_data);
11613 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_schedule_gmp()

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

Export a schedule.

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

Definition at line 16723 of file gsad_gmp.c.

16725 {
16726  return export_resource (connection, "schedule", credentials, params,
16727  response_data);
16728 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_schedules_gmp()

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

Export a list of schedules.

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

Definition at line 16741 of file gsad_gmp.c.

16743 {
16744  return export_many (connection, "schedule", credentials, params,
16745  response_data);
16746 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_slave_gmp()

char* export_slave_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ export_slaves_gmp()

char* export_slaves_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ export_tag_gmp()

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

Export a tag.

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

Definition at line 7356 of file gsad_gmp.c.

7358 {
7359  return export_resource (connection, "tag", credentials, params,
7360  response_data);
7361 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_tags_gmp()

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

Export a list of tags.

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

Definition at line 7375 of file gsad_gmp.c.

7377 {
7378  return export_many (connection, "tag", credentials, params, response_data);
7379 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_target_gmp()

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

Export a target.

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

Definition at line 7848 of file gsad_gmp.c.

7850 {
7851  return export_resource (connection, "target", credentials, params,
7852  response_data);
7853 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_targets_gmp()

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

Export a list of targets.

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

Definition at line 7867 of file gsad_gmp.c.

7869 {
7870  return export_many (connection, "target", credentials, params, response_data);
7871 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_task_gmp()

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

Export a task.

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

Definition at line 3160 of file gsad_gmp.c.

3162 {
3163  return export_resource (connection, "task", credentials, params,
3164  response_data);
3165 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_tasks_gmp()

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

Export a list of tasks.

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

Definition at line 3179 of file gsad_gmp.c.

3181 {
3182  return export_many (connection, "task", credentials, params, response_data);
3183 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ export_user_gmp()

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

Export a user.

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

Definition at line 17548 of file gsad_gmp.c.

17550 {
17551  return export_resource (connection, "user", credentials, params,
17552  response_data);
17553 }
Structure of credential related information.
char * export_resource(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_gmp.c:1586

References export_resource().

Here is the call graph for this function:

◆ export_users_gmp()

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

Export a list of users.

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

Definition at line 17567 of file gsad_gmp.c.

17569 {
17570  return export_many (connection, "user", credentials, params, response_data);
17571 }
Structure of credential related information.
static char * export_many(gvm_connection_t *connection, const char *type, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Export a list of resources.
Definition: gsad_gmp.c:1738

References export_many().

Here is the call graph for this function:

◆ get_agent_gmp()

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

Get one agent, envelope the result.

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

Definition at line 4852 of file gsad_gmp.c.

4854 {
4855  return get_agent (connection, credentials, params, NULL, response_data);
4856 }
Structure of credential related information.
static char * get_agent(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one agent, envelope the result.
Definition: gsad_gmp.c:4833

References get_agent().

Here is the call graph for this function:

◆ get_agents_gmp()

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

Get all agents, envelope the result.

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

Definition at line 4889 of file gsad_gmp.c.

4891 {
4892  return get_agents (connection, credentials, params, NULL, response_data);
4893 }
Structure of credential related information.
static char * get_agents(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all agents, envelope the result.
Definition: gsad_gmp.c:4870

References get_agents().

Here is the call graph for this function:

◆ get_aggregate_gmp()

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

Get an aggregate of resources.

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

Definition at line 5017 of file gsad_gmp.c.

5019 {
5020  params_t *data_columns, *text_columns;
5021  params_t *sort_fields, *sort_stats, *sort_orders;
5022  params_iterator_t data_columns_iterator, text_columns_iterator;
5023  params_iterator_t sort_fields_iterator, sort_stats_iterator;
5024  params_iterator_t sort_orders_iterator;
5025  char *param_name;
5026  param_t *param;
5027 
5028  const char *data_column, *group_column, *subgroup_column, *type;
5029  const char *filter, *filt_id;
5030  const char *first_group, *max_groups;
5031  const char *mode;
5032  gchar *filter_escaped, *command_escaped, *response;
5033  entity_t entity;
5034  GString *xml, *command;
5035  int ret;
5036 
5037  data_columns = params_values (params, "data_columns:");
5038  data_column = params_value (params, "data_column");
5039  text_columns = params_values (params, "text_columns:");
5040  group_column = params_value (params, "group_column");
5041  subgroup_column = params_value (params, "subgroup_column");
5042  type = params_value (params, "aggregate_type");
5043  filter = params_value (params, "filter");
5044  filt_id = params_value (params, "filt_id");
5045  sort_fields = params_values (params, "sort_fields:");
5046  sort_stats = params_values (params, "sort_stats:");
5047  sort_orders = params_values (params, "sort_orders:");
5048  first_group = params_value (params, "first_group");
5049  max_groups = params_value (params, "max_groups");
5050  mode = params_value (params, "aggregate_mode");
5051  if (filter && strcmp (filter, ""))
5052  filter_escaped = g_markup_escape_text (filter, -1);
5053  else
5054  {
5055  if (filt_id == NULL || strcmp (filt_id, "") == 0
5056  || strcmp (filt_id, "0") == 0)
5057  filter_escaped = g_strdup ("rows=-2");
5058  else
5059  filter_escaped = NULL;
5060  }
5061 
5062  xml = g_string_new ("<get_aggregate>");
5063 
5064  command = g_string_new ("<get_aggregates");
5065  g_string_append_printf (command, " type=\"%s\"", type);
5066  if (data_column)
5067  g_string_append_printf (command, " data_column=\"%s\"", data_column);
5068  if (group_column)
5069  g_string_append_printf (command, " group_column=\"%s\"", group_column);
5070  if (subgroup_column)
5071  g_string_append_printf (command, " subgroup_column=\"%s\"",
5072  subgroup_column);
5073  if (filter_escaped && strcmp (filter_escaped, ""))
5074  g_string_append_printf (command, " filter=\"%s\"", filter_escaped);
5075  if (filt_id && strcmp (filt_id, ""))
5076  g_string_append_printf (command, " filt_id=\"%s\"", filt_id);
5077  if (first_group && strcmp (first_group, ""))
5078  g_string_append_printf (command, " first_group=\"%s\"", first_group);
5079  if (max_groups && strcmp (max_groups, ""))
5080  g_string_append_printf (command, " max_groups=\"%s\"", max_groups);
5081  if (mode && strcmp (mode, ""))
5082  g_string_append_printf (command, " mode=\"%s\"", mode);
5083  g_string_append (command, ">");
5084 
5085  if (sort_fields && sort_stats && sort_orders)
5086  {
5087  param_t *field_param, *stat_param, *order_param;
5088  gchar *field_i, *stat_i, *order_i;
5089 
5090  params_iterator_init (&sort_fields_iterator, sort_fields);
5091  params_iterator_init (&sort_stats_iterator, sort_stats);
5092  params_iterator_init (&sort_orders_iterator, sort_orders);
5093 
5094  while (
5095  params_iterator_next (&sort_fields_iterator, &field_i, &field_param)
5096  && params_iterator_next (&sort_stats_iterator, &stat_i, &stat_param)
5097  && params_iterator_next (&sort_orders_iterator, &order_i, &order_param))
5098  {
5099  if (field_param->valid && stat_param->valid && order_param->valid)
5100  {
5101  xml_string_append (command,
5102  "<sort field=\"%s\""
5103  " stat=\"%s\""
5104  " order=\"%s\"/>",
5105  field_param->value ? field_param->value : "",
5106  stat_param->value ? stat_param->value : "",
5107  order_param->value ? order_param->value : "");
5108  }
5109  }
5110  }
5111 
5112  if (data_columns)
5113  {
5114  params_iterator_init (&data_columns_iterator, data_columns);
5115  while (params_iterator_next (&data_columns_iterator, &param_name, &param))
5116  {
5117  if (param->valid)
5118  {
5119  xml_string_append (command, "<data_column>%s</data_column>",
5120  param->value);
5121  }
5122  }
5123  }
5124 
5125  if (text_columns)
5126  {
5127  params_iterator_init (&text_columns_iterator, text_columns);
5128  while (params_iterator_next (&text_columns_iterator, &param_name, &param))
5129  {
5130  if (param->valid)
5131  {
5132  xml_string_append (command, "<text_column>%s</text_column>",
5133  param->value);
5134  }
5135  }
5136  }
5137 
5138  g_string_append (command, "</get_aggregates>");
5139 
5140  g_free (filter_escaped);
5141 
5142  command_escaped = g_markup_escape_text (command->str, -1);
5143  g_string_append (xml, command_escaped);
5144  g_free (command_escaped);
5145 
5146  response = NULL;
5147  ret = gmp (connection, credentials, &response, &entity, response_data,
5148  command->str);
5149  g_string_free (command, TRUE);
5150 
5151  if (ret)
5152  {
5153  free_entity (entity);
5154  g_string_free (xml, TRUE);
5155  }
5156 
5157  switch (ret)
5158  {
5159  case 0:
5160  break;
5161  case 1:
5162  cmd_response_data_set_status_code (response_data,
5163  MHD_HTTP_INTERNAL_SERVER_ERROR);
5164  return gsad_message (
5165  credentials, "Internal error", __FUNCTION__, __LINE__,
5166  "An internal error occurred while getting aggregates. "
5167  "Diagnostics: Failure to send command to manager daemon.",
5168  response_data);
5169  case 2:
5170  cmd_response_data_set_status_code (response_data,
5171  MHD_HTTP_INTERNAL_SERVER_ERROR);
5172  return gsad_message (
5173  credentials, "Internal error", __FUNCTION__, __LINE__,
5174  "An internal error occurred while getting aggregates. "
5175  "Diagnostics: Failure to receive response from manager daemon.",
5176  response_data);
5177  default:
5178  cmd_response_data_set_status_code (response_data,
5179  MHD_HTTP_INTERNAL_SERVER_ERROR);
5180  return gsad_message (
5181  credentials, "Internal error", __FUNCTION__, __LINE__,
5182  "An internal error occurred while getting aggregates. "
5183  "Diagnostics: Internal Error.",
5184  response_data);
5185  }
5186 
5187  if (gmp_success (entity) == 0)
5188  set_http_status_from_entity (entity, response_data);
5189  g_string_append (xml, response);
5190 
5191  g_string_append (xml, "</get_aggregate>");
5192 
5193  free_entity (entity);
5194  g_free (response);
5195  return envelope_gmp (connection, credentials, params,
5196  g_string_free (xml, FALSE), response_data);
5197 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:656
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to GMP response entity.
Definition: gsad_gmp.c:677
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
int valid
Definition: gsad_params.h:44
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ get_alert_gmp()

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

Get one alert, envelope the result.

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

Definition at line 6021 of file gsad_gmp.c.

6023 {
6024  return get_alert (connection, credentials, params, NULL, response_data);
6025 }
Structure of credential related information.
static char * get_alert(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one alert, envelope the result.
Definition: gsad_gmp.c:5843

References get_alert().

Here is the call graph for this function:

◆ get_alerts_gmp()

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

Get all alerts, envelope the result.

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

Definition at line 6164 of file gsad_gmp.c.

6166 {
6167  return get_alerts (connection, credentials, params, NULL, response_data);
6168 }
Structure of credential related information.
static char * get_alerts(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all alerts, envelope the result.
Definition: gsad_gmp.c:6039

References get_alerts().

Here is the call graph for this function:

◆ get_asset_gmp()

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

Get asset, envelope the result.

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

Definition at line 18580 of file gsad_gmp.c.

18582 {
18583  return get_asset (connection, credentials, params, NULL, response_data);
18584 }
Structure of credential related information.
static char * get_asset(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Request an asset.
Definition: gsad_gmp.c:18507

References get_asset().

Here is the call graph for this function:

◆ get_assets_chart_gmp()

char* get_assets_chart_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ get_assets_gmp()

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

Get assets, envelope the result.

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

Definition at line 18657 of file gsad_gmp.c.

18659 {
18660  return get_assets (connection, credentials, params, NULL, response_data);
18661 }
static char * get_assets(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Request assets.
Definition: gsad_gmp.c:18598
Structure of credential related information.

References get_assets().

Here is the call graph for this function:

◆ get_config_family_gmp()

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

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

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

Definition at line 8845 of file gsad_gmp.c.

8847 {
8848  return get_config_family (connection, credentials, params, 0, response_data);
8849 }
Structure of credential related information.
static char * get_config_family(gvm_connection_t *, credentials_t *, params_t *, int, cmd_response_data_t *)
Get details of a family for a config, envelope the result.
Definition: gsad_gmp.c:8712

References get_config_family().

Here is the call graph for this function:

◆ get_config_gmp()

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

Get a config, envelope the result.

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

Definition at line 8273 of file gsad_gmp.c.

8275 {
8276  return get_config (connection, credentials, params, NULL, 0, response_data);
8277 }
Structure of credential related information.
static char * get_config(gvm_connection_t *, credentials_t *, params_t *, const char *, int, cmd_response_data_t *)
Get a config, envelope the result.
Definition: gsad_gmp.c:8078

References get_config().

Here is the call graph for this function:

◆ get_config_nvt_gmp()

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

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

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

Definition at line 9108 of file gsad_gmp.c.

9110 {
9111  return get_config_nvt (connection, credentials, params, 0, response_data);
9112 }
Structure of credential related information.
static char * get_config_nvt(gvm_connection_t *connection, credentials_t *credentials, params_t *params, int edit, cmd_response_data_t *response_data)
Get details of an NVT for a config, envelope the result.
Definition: gsad_gmp.c:8968

References get_config_nvt().

Here is the call graph for this function:

◆ get_configs_gmp()

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

Get all scan configs, envelope the result.

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

Definition at line 8059 of file gsad_gmp.c.

8061 {
8062  return get_configs (connection, credentials, params, NULL, response_data);
8063 }
Structure of credential related information.
static char * get_configs(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all scan configs, envelope the result.
Definition: gsad_gmp.c:8040

References get_configs().

Here is the call graph for this function:

◆ get_credential_gmp()

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

Get one credential, envelope the result.

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

Definition at line 3897 of file gsad_gmp.c.

3899 {
3900  return get_credential (connection, credentials, params, NULL, response_data);
3901 }
Structure of credential related information.
static char * get_credential(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one credential, envelope the result.
Definition: gsad_gmp.c:3878

References get_credential().

Here is the call graph for this function:

◆ get_credentials_gmp()

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

Get one or all credentials, envelope the result.

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

Definition at line 4162 of file gsad_gmp.c.

4164 {
4165  return get_credentials (connection, credentials, params, NULL, response_data);
4166 }
Structure of credential related information.
static char * get_credentials(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one or all credentials, envelope the result.
Definition: gsad_gmp.c:4143

References get_credentials().

Here is the call graph for this function:

◆ get_feeds_gmp()

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

Get descriptions of the feeds connected to the manager.

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

Definition at line 16231 of file gsad_gmp.c.

16233 {
16234  entity_t entity;
16235  char *text = NULL;
16236  gchar *response;
16237  time_t now;
16238  struct tm *tm;
16239  gchar current_timestamp[30];
16240 
16241  if (gvm_connection_sendf (connection, "<get_feeds/>") == -1)
16242  {
16243  cmd_response_data_set_status_code (response_data,
16244  MHD_HTTP_INTERNAL_SERVER_ERROR);
16245  return gsad_message (
16246  credentials, "Internal error", __FUNCTION__, __LINE__,
16247  "An internal error occurred while getting the feed list. "
16248  "The current list of feeds is not available. "
16249  "Diagnostics: Failure to send command to manager daemon.",
16250  response_data);
16251  }
16252 
16253  if (read_entity_and_text_c (connection, &entity, &text))
16254  {
16255  cmd_response_data_set_status_code (response_data,
16256  MHD_HTTP_INTERNAL_SERVER_ERROR);
16257  return gsad_message (
16258  credentials, "Internal error", __FUNCTION__, __LINE__,
16259  "An internal error occurred while getting the feed. "
16260  "The current list of feeds is not available. "
16261  "Diagnostics: Failure to receive response from manager daemon.",
16262  response_data);
16263  }
16264 
16265  time (&now);
16266  tm = gmtime (&now);
16267  if (tm == NULL
16268  || (strftime (current_timestamp, 29, "%Y-%m-%dT%H:%M:%S", tm) == 0))
16269  {
16270  current_timestamp[0] = '\0';
16271  }
16272 
16273  response = g_strdup_printf ("<get_feeds>"
16274  "%s"
16275  "<current_time_utc>%s</current_time_utc>"
16276  "</get_feeds>",
16277  text, current_timestamp);
16278 
16279  g_free (text);
16280 
16281  return envelope_gmp (connection, credentials, params, response,
16282  response_data);
16283 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ get_filter_gmp()

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

Get one filter, envelope the result.

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

Definition at line 16432 of file gsad_gmp.c.

16434 {
16435  return get_filter (connection, credentials, params, NULL, response_data);
16436 }
Structure of credential related information.
static char * get_filter(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one filter, envelope the result.
Definition: gsad_gmp.c:16413

References get_filter().

Here is the call graph for this function:

◆ get_filters_gmp()

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

Get all filters, envelope the result.

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

Definition at line 16469 of file gsad_gmp.c.

16471 {
16472  return get_filters (connection, credentials, params, NULL, response_data);
16473 }
Structure of credential related information.
static char * get_filters(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all filters, envelope the result.
Definition: gsad_gmp.c:16450

References get_filters().

Here is the call graph for this function:

◆ get_group_gmp()

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

Get one group, envelope the result.

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

Definition at line 14081 of file gsad_gmp.c.

14083 {
14084  return get_group (connection, credentials, params, NULL, response_data);
14085 }
Structure of credential related information.
static char * get_group(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one group, envelope the result.
Definition: gsad_gmp.c:14062

References get_group().

Here is the call graph for this function:

◆ get_groups_gmp()

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

Get all groups, envelope the result.

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

Definition at line 14118 of file gsad_gmp.c.

14120 {
14121  return get_groups (connection, credentials, params, NULL, response_data);
14122 }
Structure of credential related information.
static char * get_groups(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all groups, envelope the result.
Definition: gsad_gmp.c:14099

References get_groups().

Here is the call graph for this function:

◆ get_info()

char* get_info ( gvm_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
XML enveloped SecInfo response or error message.

Definition at line 3325 of file gsad_gmp.c.

3328 {
3329  char *ret;
3330  GString *extra_attribs, *extra_response;
3331  const char *info_type;
3332 
3333  info_type = params_value (params, "info_type");
3334  if (info_type == NULL)
3335  {
3336  param_t *param;
3337  param = params_add (params, "info_type", "nvt");
3338  param->valid = 1;
3339  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
3340  info_type = params_value (params, "info_type");
3341  }
3342 
3343  if (strcmp (info_type, "nvt") && strcmp (info_type, "cve")
3344  && strcmp (info_type, "cpe") && strcmp (info_type, "ovaldef")
3345  && strcmp (info_type, "cert_bund_adv")
3346  && strcmp (info_type, "dfn_cert_adv") && strcmp (info_type, "allinfo")
3347  && strcmp (info_type, "NVT") && strcmp (info_type, "CVE")
3348  && strcmp (info_type, "CPE") && strcmp (info_type, "OVALDEF")
3349  && strcmp (info_type, "CERT_BUND_ADV")
3350  && strcmp (info_type, "DFN_CERT_ADV") && strcmp (info_type, "ALLINFO"))
3351  {
3352  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
3353  return gsad_message (credentials, "Internal error", __FUNCTION__,
3354  __LINE__,
3355  "An internal error occurred while getting SecInfo. "
3356  "Diagnostics: Invalid info_type parameter value",
3357  response_data);
3358  }
3359 
3360  if (params_value (params, "info_name") && params_value (params, "info_id"))
3361  {
3362  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
3363  return gsad_message (credentials, "Internal error", __FUNCTION__,
3364  __LINE__,
3365  "An internal error occurred while getting SecInfo. "
3366  "Diagnostics: Both ID and Name set.",
3367  response_data);
3368  }
3369  extra_response = g_string_new (extra_xml ? extra_xml : "");
3370 
3371  if (command_enabled (credentials, "GET_NOTES")
3372  && (strcasecmp (info_type, "NVT") == 0)
3373  && params_value (params, "info_id"))
3374  {
3375  gchar *response;
3376 
3377  if (simple_gmpf (connection, "getting SecInfo", credentials, &response,
3378  response_data,
3379  "<get_notes"
3380  " nvt_oid=\"%s\""
3381  " sort_field=\"notes.text\"/>",
3382  params_value (params, "info_id")))
3383  {
3384  g_string_free (extra_response, TRUE);
3385  return response;
3386  }
3387 
3388  g_string_append (extra_response, response);
3389  }
3390 
3391  if (command_enabled (credentials, "GET_OVERRIDES")
3392  && (strcasecmp (info_type, "NVT") == 0)
3393  && params_value (params, "info_id"))
3394  {
3395  gchar *response;
3396 
3397  if (simple_gmpf (connection, "getting SecInfo", credentials, &response,
3398  response_data,
3399  "<get_overrides"
3400  " nvt_oid=\"%s\""
3401  " sort_field=\"overrides.text\"/>",
3402  params_value (params, "info_id")))
3403  {
3404  g_string_free (extra_response, TRUE);
3405  return response;
3406  }
3407 
3408  g_string_append (extra_response, response);
3409  }
3410 
3411  extra_attribs = g_string_new ("");
3412  g_string_append_printf (extra_attribs, "type=\"%s\"",
3413  params_value (params, "info_type"));
3414  if (params_value (params, "info_name"))
3415  g_string_append_printf (extra_attribs, " name=\"%s\"",
3416  params_value (params, "info_name"));
3417  else if (params_value (params, "info_id"))
3418  g_string_append_printf (extra_attribs, " info_id=\"%s\"",
3419  params_value (params, "info_id"));
3420  if (params_value (params, "details"))
3421  g_string_append_printf (extra_attribs, " details=\"%s\"",
3422  params_value (params, "details"));
3423  ret = get_many (connection, "info", credentials, params, extra_response->str,
3424  extra_attribs->str, response_data);
3425 
3426  g_string_free (extra_response, TRUE);
3427  g_string_free (extra_attribs, TRUE);
3428 
3429  return ret;
3430 }
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
static int simple_gmpf(gvm_connection_t *connection, const gchar *message_operation, credentials_t *credentials, gchar **response, cmd_response_data_t *response_data, const char *format,...)
Run a single GMP command, preparing a response even on error.
Definition: gsad_gmp.c:749
int valid_utf8
Definition: gsad_params.h:45
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA GMP library.
Definition: gsad_gmp.c:352
static char * get_many(gvm_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 all of a particular type of resource, envelope the result.
Definition: gsad_gmp.c:1152
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
int valid
Definition: gsad_params.h:44
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

References cmd_response_data_set_status_code(), command_enabled(), get_many(), gsad_message(), params_add(), params_value(), simple_gmpf(), param::valid, param::valid_utf8, and param::value.

Referenced by get_info_gmp().

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

◆ get_info_gmp()

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

Get info, envelope the result.

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

Definition at line 3443 of file gsad_gmp.c.

3445 {
3446  return get_info (connection, credentials, params, NULL, response_data);
3447 }
Structure of credential related information.
char * get_info(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
Definition: gsad_gmp.c:3325

References get_info().

Here is the call graph for this function:

◆ get_note_gmp()

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

Get a note, envelope the result.

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

Definition at line 10828 of file gsad_gmp.c.

10830 {
10831  return get_note (connection, credentials, params, NULL, response_data);
10832 }
Structure of credential related information.
static char * get_note(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a note, envelope the result.
Definition: gsad_gmp.c:10809

References get_note().

Here is the call graph for this function:

◆ get_notes_gmp()

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

Get all notes, envelope the result.

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

Definition at line 10791 of file gsad_gmp.c.

10793 {
10794  return get_notes (connection, credentials, params, NULL, response_data);
10795 }
Structure of credential related information.
static char * get_notes(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all notes, envelope the result.
Definition: gsad_gmp.c:10772

References get_notes().

Here is the call graph for this function:

◆ get_override_gmp()

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

Get an override, envelope the result.

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

Definition at line 11245 of file gsad_gmp.c.

11247 {
11248  return get_override (connection, credentials, params, NULL, response_data);
11249 }
Structure of credential related information.
static char * get_override(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get a override, envelope the result.
Definition: gsad_gmp.c:11226

References get_override().

Here is the call graph for this function:

◆ get_overrides_gmp()

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

Get all overrides, envelope the result.

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

Definition at line 11208 of file gsad_gmp.c.

11210 {
11211  return get_overrides (connection, credentials, params, NULL, response_data);
11212 }
static char * get_overrides(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all overrides, envelope the result.
Definition: gsad_gmp.c:11189
Structure of credential related information.

References get_overrides().

Here is the call graph for this function:

◆ get_permission_gmp()

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

Get one permission, envelope the result.

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

Definition at line 14394 of file gsad_gmp.c.

14396 {
14397  return get_permission (connection, credentials, params, NULL, response_data);
14398 }
Structure of credential related information.
static char * get_permission(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one permission, envelope the result.
Definition: gsad_gmp.c:14375

References get_permission().

Here is the call graph for this function:

◆ get_permissions_gmp()

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

Get all permissions, envelope the result.

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

Definition at line 14431 of file gsad_gmp.c.

14433 {
14434  return get_permissions (connection, credentials, params, NULL, response_data);
14435 }
Structure of credential related information.
static char * get_permissions(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all permissions, envelope the result.
Definition: gsad_gmp.c:14412

References get_permissions().

Here is the call graph for this function:

◆ get_port_list_gmp()

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

Get one port_list, envelope the result.

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

Definition at line 15556 of file gsad_gmp.c.

15558 {
15559  return get_port_list (connection, credentials, params, NULL, response_data);
15560 }
Structure of credential related information.
static char * get_port_list(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one port_list, envelope the result.
Definition: gsad_gmp.c:15537

References get_port_list().

Here is the call graph for this function:

◆ get_port_lists_gmp()

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

Get all port_lists, envelope the result.

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

Definition at line 15593 of file gsad_gmp.c.

15595 {
15596  return get_port_lists (connection, credentials, params, NULL, response_data);
15597 }
Structure of credential related information.
static char * get_port_lists(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all Port Lists, envelope the result.
Definition: gsad_gmp.c:15574

References get_port_lists().

Here is the call graph for this function:

◆ get_report_format_gmp()

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

Get one report format, envelope the result.

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

Definition at line 12509 of file gsad_gmp.c.

12511 {
12512  return get_report_format (connection, credentials, params, NULL,
12513  response_data);
12514 }
Structure of credential related information.
static char * get_report_format(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one report format, envelope the result.
Definition: gsad_gmp.c:12490

References get_report_format().

Here is the call graph for this function:

◆ get_report_formats_gmp()

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

Get all Report Formats, envelope the result.

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

Definition at line 12547 of file gsad_gmp.c.

12550 {
12551  return get_report_formats (connection, credentials, params, NULL,
12552  response_data);
12553 }
Structure of credential related information.
static char * get_report_formats(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all Report Formats, envelope the result.
Definition: gsad_gmp.c:12528

References get_report_formats().

Here is the call graph for this function:

◆ get_report_gmp()

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

Get a report and envelope the result.

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

Definition at line 10397 of file gsad_gmp.c.

10399 {
10400  return get_report (connection, credentials, params, NULL, response_data);
10401 }
Structure of credential related information.
char * get_report(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Get a report and return the result.
Definition: gsad_gmp.c:9682

References get_report().

Here is the call graph for this function:

◆ get_reports_gmp()

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

Get all reports, envelope the result.

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

Definition at line 10547 of file gsad_gmp.c.

10549 {
10550  return get_reports (connection, credentials, params, NULL, response_data);
10551 }
Structure of credential related information.
static char * get_reports(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all reports, envelope the result.
Definition: gsad_gmp.c:10521

References get_reports().

Here is the call graph for this function:

◆ get_result_gmp()

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

Get one result, envelope the result.

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

Definition at line 10753 of file gsad_gmp.c.

10755 {
10756  return get_one (connection, "result", credentials, params, NULL, NULL,
10757  response_data);
10758 }
Structure of credential related information.
char * get_one(gvm_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, envelope the result.
Definition: gsad_gmp.c:1060

References get_one().

Here is the call graph for this function:

◆ get_results_gmp()

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

Get all results, envelope the result.

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

Definition at line 10736 of file gsad_gmp.c.

10738 {
10739  return get_results (connection, credentials, params, NULL, response_data);
10740 }
static char * get_results(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all results, envelope the result.
Definition: gsad_gmp.c:10710
Structure of credential related information.

References get_results().

Here is the call graph for this function:

◆ get_role_gmp()

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

Get one role, envelope the result.

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

Definition at line 16057 of file gsad_gmp.c.

16059 {
16060  return get_role (connection, credentials, params, NULL, response_data);
16061 }
Structure of credential related information.
static char * get_role(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one role, envelope the result.
Definition: gsad_gmp.c:16038

References get_role().

Here is the call graph for this function:

◆ get_roles_gmp()

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

Get all roles, envelope the result.

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

Definition at line 16094 of file gsad_gmp.c.

16096 {
16097  return get_roles (connection, credentials, params, NULL, response_data);
16098 }
Structure of credential related information.
static char * get_roles(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all roles, envelope the result.
Definition: gsad_gmp.c:16075

References get_roles().

Here is the call graph for this function:

◆ get_scanner_gmp()

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

Get one scanner, envelope the result.

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

Definition at line 11573 of file gsad_gmp.c.

11575 {
11576  return get_scanner (connection, credentials, params, NULL, response_data);
11577 }
Structure of credential related information.
static char * get_scanner(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one scanner, envelope the result.
Definition: gsad_gmp.c:11554

References get_scanner().

Here is the call graph for this function:

◆ get_scanners_gmp()

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

Get all scanners, envelope the result.

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

Definition at line 11536 of file gsad_gmp.c.

11538 {
11539  return get_scanners (connection, credentials, params, NULL, response_data);
11540 }
Structure of credential related information.
static char * get_scanners(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all scanners, envelope the result.
Definition: gsad_gmp.c:11517

References get_scanners().

Here is the call graph for this function:

◆ get_schedule_gmp()

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

Get one schedule, envelope the result.

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

Definition at line 11984 of file gsad_gmp.c.

11986 {
11987  return get_schedule (connection, credentials, params, NULL, response_data);
11988 }
Structure of credential related information.
static char * get_schedule(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one schedule, envelope the result.
Definition: gsad_gmp.c:11965

References get_schedule().

Here is the call graph for this function:

◆ get_schedules_gmp()

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

Get all schedules, envelope the result.

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

Definition at line 12021 of file gsad_gmp.c.

12023 {
12024  return get_schedules (connection, credentials, params, NULL, response_data);
12025 }
Structure of credential related information.
static char * get_schedules(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all schedules, envelope the result.
Definition: gsad_gmp.c:12002

References get_schedules().

Here is the call graph for this function:

◆ get_setting_gmp()

char* get_setting_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

Definition at line 17959 of file gsad_gmp.c.

17961 {
17962  const gchar *setting_id = params_value (params, "setting_id");
17963  CHECK_VARIABLE_INVALID (setting_id, "Get Setting");
17964  GString *xml = g_string_new ("<get_settings>");
17965 
17966  if (gvm_connection_sendf_xml (connection,
17967  "<get_settings"
17968  " setting_id=\"%s\"/>",
17969  setting_id))
17970  {
17971  g_string_free (xml, TRUE);
17972  cmd_response_data_set_status_code (response_data,
17973  MHD_HTTP_INTERNAL_SERVER_ERROR);
17974  return gsad_message (credentials, "Internal error", __FUNCTION__,
17975  __LINE__,
17976  "An internal error occurred while getting the "
17977  "dashboard settings"
17978  "Diagnostics: Failure to send command to manager "
17979  "daemon.",
17980  response_data);
17981  }
17982 
17983  if (read_string_c (connection, &xml))
17984  {
17985  g_string_free (xml, TRUE);
17986  cmd_response_data_set_status_code (response_data,
17987  MHD_HTTP_INTERNAL_SERVER_ERROR);
17988  return gsad_message (credentials, "Internal error", __FUNCTION__,
17989  __LINE__,
17990  "An internal error occurred while getting the "
17991  "dashboard settings"
17992  "Diagnostics: Failure to receive response from "
17993  "manager daemon.",
17994  response_data);
17995  }
17996 
17997  g_string_append (xml, "</get_settings>");
17998  return envelope_gmp (connection, credentials, params,
17999  g_string_free (xml, FALSE), response_data);
18000 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ get_settings_gmp()

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

Get all user defined settings.

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

Definition at line 17799 of file gsad_gmp.c.

17801 {
17802  GString *xml;
17803  gchar *command;
17804  const gchar *filter;
17805 
17806  xml = g_string_new ("<get_settings>");
17807 
17808  /* Get the settings. */
17809 
17810  filter = params_value (params, "filter");
17811  if (filter)
17812  {
17813  command = g_markup_printf_escaped ("<get_settings"
17814  " filter=\"%s\""
17815  " sort_field=\"name\""
17816  " sort_order=\"ascending\"/>",
17817  filter);
17818  }
17819  else
17820  {
17821  command = g_strdup ("<get_settings"
17822  " sort_field=\"name\""
17823  " sort_order=\"ascending\"/>");
17824  }
17825 
17826  if (gvm_connection_sendf (connection, command))
17827  {
17828  g_free (command);
17829 
17830  g_string_free (xml, TRUE);
17831  cmd_response_data_set_status_code (response_data,
17832  MHD_HTTP_INTERNAL_SERVER_ERROR);
17833  return gsad_message (
17834  credentials, "Internal error", __FUNCTION__, __LINE__,
17835  "An internal error occurred while getting the settings. "
17836  "The current list of settings is not available. "
17837  "Diagnostics: Failure to send command to manager daemon.",
17838  response_data);
17839  }
17840 
17841  if (read_string_c (connection, &xml))
17842  {
17843  g_free (command);
17844  g_string_free (xml, TRUE);
17845  cmd_response_data_set_status_code (response_data,
17846  MHD_HTTP_INTERNAL_SERVER_ERROR);
17847  return gsad_message (
17848  credentials, "Internal error", __FUNCTION__, __LINE__,
17849  "An internal error occurred while getting the settings. "
17850  "The current list of settings is not available. "
17851  "Diagnostics: Failure to receive response from manager daemon.",
17852  response_data);
17853  }
17854 
17855  g_free (command);
17856  g_string_append (xml, "</get_settings>");
17857  return envelope_gmp (connection, credentials, params,
17858  g_string_free (xml, FALSE), response_data);
17859 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ get_slave_gmp()

char* get_slave_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ get_slaves_gmp()

char* get_slaves_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ get_system_report_gmp()

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

Return system report image.

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

Definition at line 12328 of file gsad_gmp.c.

12331 {
12332  entity_t entity;
12333  entity_t report_entity;
12334  char name[501];
12335  gchar *gmp_command;
12336  time_t now;
12337  struct tm *now_broken;
12338  const char *slave_id, *duration;
12339  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
12340  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
12341  struct tm start_time, end_time;
12342  gchar *start_time_str, *end_time_str;
12343 
12344  if (url == NULL)
12345  return NULL;
12346 
12347  /* fan/report.png */
12348  if (sscanf (url, "%500[^ /]./report.png", name) == 1)
12349  {
12350  slave_id = params_value (params, "slave_id");
12351 
12352  duration = params_value (params, "duration");
12353 
12354  if (duration && strcmp (duration, ""))
12355  {
12356  gmp_command =
12357  g_markup_printf_escaped ("<get_system_reports"
12358  " name=\"%s\""
12359  " duration=\"%s\""
12360  " slave_id=\"%s\"/>",
12361  name, duration, slave_id ? slave_id : "0");
12362  }
12363  else
12364  {
12365  now = time (NULL);
12366  now_broken = localtime (&now);
12367 
12368  start_year = params_value (params, "start_year");
12369  start_month = params_value (params, "start_month");
12370  start_day = params_value (params, "start_day");
12371  start_hour = params_value (params, "start_hour");
12372  start_minute = params_value (params, "start_minute");
12373 
12374  end_year = params_value (params, "end_year");
12375  end_month = params_value (params, "end_month");
12376  end_day = params_value (params, "end_day");
12377  end_hour = params_value (params, "end_hour");
12378  end_minute = params_value (params, "end_minute");
12379 
12380  start_time.tm_year =
12381  start_year ? atoi (start_year) - 1900 : now_broken->tm_year;
12382  start_time.tm_mon =
12383  start_month ? atoi (start_month) - 1 : now_broken->tm_mon;
12384  start_time.tm_mday =
12385  start_day ? atoi (start_day) : now_broken->tm_mday;
12386  start_time.tm_hour =
12387  start_hour ? atoi (start_hour) : now_broken->tm_hour;
12388  start_time.tm_min =
12389  start_minute ? atoi (start_minute) : now_broken->tm_min;
12390  start_time.tm_zone = now_broken->tm_zone;
12391 
12392  end_time.tm_year =
12393  end_year ? atoi (end_year) - 1900 : now_broken->tm_year;
12394  end_time.tm_mon =
12395  end_month ? atoi (end_month) - 1 : now_broken->tm_mon;
12396  end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
12397  end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
12398  end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
12399  end_time.tm_zone = now_broken->tm_zone;
12400 
12401  start_time_str = g_strdup_printf (
12402  "%04d-%02d-%02dT%02d:%02d:00", start_time.tm_year + 1900,
12403  start_time.tm_mon + 1, start_time.tm_mday, start_time.tm_hour,
12404  start_time.tm_min);
12405 
12406  end_time_str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:00",
12407  end_time.tm_year + 1900,
12408  end_time.tm_mon + 1, end_time.tm_mday,
12409  end_time.tm_hour, end_time.tm_min);
12410 
12411  gmp_command = g_markup_printf_escaped (
12412  "<get_system_reports"
12413  " name=\"%s\""
12414  " start_time=\"%s\""
12415  " end_time=\"%s\""
12416  " slave_id=\"%s\"/>",
12417  name, start_time_str, end_time_str, slave_id ? slave_id : "0");
12418  g_free (start_time_str);
12419  g_free (end_time_str);
12420  }
12421 
12422  if (gvm_connection_sendf (connection, "%s", gmp_command) == -1)
12423  {
12424  g_free (gmp_command);
12425  return NULL;
12426  }
12427  g_free (gmp_command);
12428 
12429  entity = NULL;
12430  if (read_entity_c (connection, &entity))
12431  {
12432  return NULL;
12433  }
12434 
12435  report_entity = entity_child (entity, "system_report");
12436  if (report_entity == NULL)
12437  {
12438  free_entity (entity);
12439  return NULL;
12440  }
12441 
12442  report_entity = entity_child (report_entity, "report");
12443  if (report_entity == NULL)
12444  {
12445  free_entity (entity);
12446  return NULL;
12447  }
12448  else
12449  {
12450  char *content_64 = entity_text (report_entity);
12451  char *content = NULL;
12452  gsize content_length = 0;
12453 
12454  if (content_64 && strlen (content_64))
12455  {
12456  content = (char *) g_base64_decode (content_64, &content_length);
12457 
12458 #if 1
12459  cmd_response_data_set_content_type (response_data,
12461  //*content_disposition = g_strdup_printf ("attachment;
12462  // filename=\"xxx.png\"");
12463 #else
12464  g_free (content);
12465  content = g_strdup ("helo");
12466 #endif
12467  }
12468 
12469  cmd_response_data_set_content_length (response_data, content_length);
12470  free_entity (entity);
12471  return content;
12472  }
12473  }
12474 
12475  return NULL;
12476 }
void cmd_response_data_set_content_type(cmd_response_data_t *data, content_type_t content_type)
Set content type of cmd_response_data_t struct.
Definition: gsad_cmd.c:134
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_content_length(cmd_response_data_t *data, gsize content_length)
Set response content length of cmd_response_data_t struct.
Definition: gsad_cmd.c:186

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

Referenced by handle_system_report().

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

◆ get_system_reports_gmp()

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

Get all system reports, envelope the result.

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

Definition at line 12137 of file gsad_gmp.c.

12140 {
12141  GString *xml;
12142  time_t now, duration, duration_start;
12143  struct tm start_time, end_time;
12144 
12145  const char *slave_id, *given_duration, *range_type;
12146  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
12147  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
12148 
12149  slave_id = params_value (params, "slave_id");
12150 
12151  now = time (NULL);
12152 
12153  given_duration = params_value (params, "duration");
12154  range_type = params_value (params, "range_type");
12155  if (!range_type)
12156  range_type = "duration";
12157 
12158  duration = given_duration ? atoi (given_duration) : 86400;
12159  duration_start = now - duration;
12160 
12161  xml = g_string_new ("<get_system_reports>");
12162 
12163  g_string_append_printf (xml, "<slave id=\"%s\"/>", slave_id ? slave_id : "0");
12164 
12165  if (strcmp (range_type, "duration") == 0)
12166  {
12167  struct tm *time_broken;
12168  time_broken = localtime (&now);
12169  end_time.tm_year = time_broken->tm_year;
12170  end_time.tm_mon = time_broken->tm_mon;
12171  end_time.tm_mday = time_broken->tm_mday;
12172  end_time.tm_hour = time_broken->tm_hour;
12173  end_time.tm_min = time_broken->tm_min;
12174 
12175  time_broken = localtime (&duration_start);
12176  start_time.tm_year = time_broken->tm_year;
12177  start_time.tm_mon = time_broken->tm_mon;
12178  start_time.tm_mday = time_broken->tm_mday;
12179  start_time.tm_hour = time_broken->tm_hour;
12180  start_time.tm_min = time_broken->tm_min;
12181 
12182  g_string_append_printf (xml, "<duration>%ld</duration>", duration);
12183  }
12184  else
12185  {
12186  struct tm *time_broken;
12187  time_broken = localtime (&now);
12188 
12189  start_year = params_value (params, "start_year");
12190  start_month = params_value (params, "start_month");
12191  start_day = params_value (params, "start_day");
12192  start_hour = params_value (params, "start_hour");
12193  start_minute = params_value (params, "start_minute");
12194 
12195  end_year = params_value (params, "end_year");
12196  end_month = params_value (params, "end_month");
12197  end_day = params_value (params, "end_day");
12198  end_hour = params_value (params, "end_hour");
12199  end_minute = params_value (params, "end_minute");
12200 
12201  start_time.tm_year =
12202  start_year ? atoi (start_year) - 1900 : time_broken->tm_year;
12203  start_time.tm_mon =
12204  start_month ? atoi (start_month) - 1 : time_broken->tm_mon;
12205  start_time.tm_mday = start_day ? atoi (start_day) : time_broken->tm_mday;
12206  start_time.tm_hour =
12207  start_hour ? atoi (start_hour) : time_broken->tm_hour;
12208  start_time.tm_min =
12209  start_minute ? atoi (start_minute) : time_broken->tm_min;
12210 
12211  end_time.tm_year =
12212  end_year ? atoi (end_year) - 1900 : time_broken->tm_year;
12213  end_time.tm_mon = end_month ? atoi (end_month) - 1 : time_broken->tm_mon;
12214  end_time.tm_mday = end_day ? atoi (end_day) : time_broken->tm_mday;
12215  end_time.tm_hour = end_hour ? atoi (end_hour) : time_broken->tm_hour;
12216  end_time.tm_min = end_minute ? atoi (end_minute) : time_broken->tm_min;
12217  }
12218 
12219  g_string_append_printf (xml,
12220  "<start_time>"
12221  "<minute>%i</minute>"
12222  "<hour>%i</hour>"
12223  "<day_of_month>%i</day_of_month>"
12224  "<month>%i</month>"
12225  "<year>%i</year>"
12226  "</start_time>",
12227  start_time.tm_min, start_time.tm_hour,
12228  start_time.tm_mday, start_time.tm_mon + 1,
12229  start_time.tm_year + 1900);
12230 
12231  g_string_append_printf (xml,
12232  "<end_time>"
12233  "<minute>%i</minute>"
12234  "<hour>%i</hour>"
12235  "<day_of_month>%i</day_of_month>"
12236  "<month>%i</month>"
12237  "<year>%i</year>"
12238  "</end_time>"
12239  "<range_type>%s</range_type>",
12240  end_time.tm_min, end_time.tm_hour, end_time.tm_mday,
12241  end_time.tm_mon + 1, end_time.tm_year + 1900,
12242  range_type);
12243 
12244  /* Get the system reports. */
12245 
12246  if (gvm_connection_sendf (connection,
12247  "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
12248  slave_id ? slave_id : "0")
12249  == -1)
12250  {
12251  g_string_free (xml, TRUE);
12252  cmd_response_data_set_status_code (response_data,
12253  MHD_HTTP_INTERNAL_SERVER_ERROR);
12254  return gsad_message (
12255  credentials, "Internal error", __FUNCTION__, __LINE__,
12256  "An internal error occurred while getting the system reports. "
12257  "The current list of system reports is not available. "
12258  "Diagnostics: Failure to send command to manager daemon.",
12259  response_data);
12260  }
12261 
12262  if (read_string_c (connection, &xml))
12263  {
12264  g_string_free (xml, TRUE);
12265  cmd_response_data_set_status_code (response_data,
12266  MHD_HTTP_INTERNAL_SERVER_ERROR);
12267  return gsad_message (
12268  credentials, "Internal error", __FUNCTION__, __LINE__,
12269  "An internal error occurred while getting the system reports. "
12270  "The current list of system reports is not available. "
12271  "Diagnostics: Failure to receive response from manager daemon.",
12272  response_data);
12273  }
12274 
12275  if (command_enabled (credentials, "GET_SCANNERS"))
12276  {
12277  /* Get the GMP scanners. */
12278 
12279  if (gvm_connection_sendf (connection,
12280  "<get_scanners"
12281  " filter=\"sort=name rows=-1 type=4\"/>")
12282  == -1)
12283  {
12284  g_string_free (xml, TRUE);
12285  cmd_response_data_set_status_code (response_data,
12286  MHD_HTTP_INTERNAL_SERVER_ERROR);
12287  return gsad_message (
12288  credentials, "Internal error", __FUNCTION__, __LINE__,
12289  "An internal error occurred while getting the system reports. "
12290  "The current list of system reports is not available. "
12291  "Diagnostics: Failure to send command to manager daemon.",
12292  response_data);
12293  }
12294 
12295  if (read_string_c (connection, &xml))
12296  {
12297  g_string_free (xml, TRUE);
12298  cmd_response_data_set_status_code (response_data,
12299  MHD_HTTP_INTERNAL_SERVER_ERROR);
12300  return gsad_message (
12301  credentials, "Internal error", __FUNCTION__, __LINE__,
12302  "An internal error occurred while getting the system reports. "
12303  "The current list of system reports is not available. "
12304  "Diagnostics: Failure to receive response from manager daemon.",
12305  response_data);
12306  }
12307  }
12308 
12309  /* Cleanup, and return transformed XML. */
12310 
12311  g_string_append (xml, "</get_system_reports>");
12312  return envelope_gmp (connection, credentials, params,
12313  g_string_free (xml, FALSE), response_data);
12314 }
Structure of credential related information.
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA GMP library.
Definition: gsad_gmp.c:352
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

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

Here is the call graph for this function:

◆ get_tag_gmp()

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

Get one tag, envelope the result.

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

Definition at line 7412 of file gsad_gmp.c.

7414 {
7415  return get_tag (connection, credentials, params, NULL, response_data);
7416 }
Structure of credential related information.
static char * get_tag(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one tag, envelope the result.
Definition: gsad_gmp.c:7393

References get_tag().

Here is the call graph for this function:

◆ get_tags_gmp()

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

Get all tags, envelope the result.

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

Definition at line 7449 of file gsad_gmp.c.

7451 {
7452  return get_tags (connection, credentials, params, NULL, response_data);
7453 }
Structure of credential related information.
static char * get_tags(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all tags, envelope the result.
Definition: gsad_gmp.c:7430

References get_tags().

Here is the call graph for this function:

◆ get_target_gmp()

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

Get one target, envelope the result.

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

Definition at line 7554 of file gsad_gmp.c.

7556 {
7557  return get_target (connection, credentials, params, NULL, response_data);
7558 }
Structure of credential related information.
static char * get_target(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one target, envelope the result.
Definition: gsad_gmp.c:7535

References get_target().

Here is the call graph for this function:

◆ get_targets_gmp()

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

Get all targets, envelope the result.

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

Definition at line 7591 of file gsad_gmp.c.

7593 {
7594  return get_targets (connection, credentials, params, NULL, response_data);
7595 }
Structure of credential related information.
static char * get_targets(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all targets, envelope the result.
Definition: gsad_gmp.c:7572

References get_targets().

Here is the call graph for this function:

◆ get_task_gmp()

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

Get a task, envelope the result.

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

Definition at line 3567 of file gsad_gmp.c.

3569 {
3570  return get_one (connection, "task", credentials, params, NULL, NULL,
3571  response_data);
3572 }
Structure of credential related information.
char * get_one(gvm_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, envelope the result.
Definition: gsad_gmp.c:1060

References get_one().

Here is the call graph for this function:

◆ get_tasks_chart_gmp()

char* get_tasks_chart_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ get_tasks_gmp()

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

Get all tasks, envelope the result.

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

Definition at line 3550 of file gsad_gmp.c.

3552 {
3553  return get_tasks (connection, credentials, params, NULL, response_data);
3554 }
Structure of credential related information.
static char * get_tasks(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all tasks, envelope the result.
Definition: gsad_gmp.c:3510

References get_tasks().

Here is the call graph for this function:

◆ get_ticket_gmp()

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

Get single tickets, envelope the result.

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

Definition at line 18965 of file gsad_gmp.c.

18967 {
18968  return get_one (connection, "ticket", credentials, params, NULL, NULL,
18969  response_data);
18970 }
Structure of credential related information.
char * get_one(gvm_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, envelope the result.
Definition: gsad_gmp.c:1060

References get_one().

Here is the call graph for this function:

◆ get_tickets_gmp()

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

Get all tickets, envelope the result.

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

Definition at line 18947 of file gsad_gmp.c.

18949 {
18950  return get_many (connection, "ticket", credentials, params, NULL, NULL,
18951  response_data);
18952 }
Structure of credential related information.
static char * get_many(gvm_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 all of a particular type of resource, envelope the result.
Definition: gsad_gmp.c:1152

References get_many().

Here is the call graph for this function:

◆ get_trash_gmp()

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

Get all trash, envelope the result.

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

Definition at line 13226 of file gsad_gmp.c.

13228 {
13229  return get_trash (connection, credentials, params, NULL, response_data);
13230 }
Structure of credential related information.
static char * get_trash(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Setup trash page XML, envelope the result.
Definition: gsad_gmp.c:13159

References get_trash().

Here is the call graph for this function:

◆ get_user_gmp()

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

Get one user, envelope the result.

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

Definition at line 16933 of file gsad_gmp.c.

16935 {
16936  return get_user (connection, credentials, params, NULL, response_data);
16937 }
Structure of credential related information.
static char * get_user(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get one user, envelope the result.
Definition: gsad_gmp.c:16862

References get_user().

Here is the call graph for this function:

◆ get_users_gmp()

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

Get all users, envelope the result.

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

Definition at line 17022 of file gsad_gmp.c.

17024 {
17025  return get_users (connection, credentials, params, NULL, response_data);
17026 }
static char * get_users(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all users, envelope the result.
Definition: gsad_gmp.c:16951
Structure of credential related information.

References get_users().

Here is the call graph for this function:

◆ get_vulns_gmp()

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

Get multiple vulns, envelope the result.

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

Definition at line 17211 of file gsad_gmp.c.

17213 {
17214  return get_vulns (connection, credentials, params, NULL, response_data);
17215 }
Structure of credential related information.
static char * get_vulns(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get multiple vulns, envelope the result.
Definition: gsad_gmp.c:17229

References get_vulns().

Here is the call graph for this function:

◆ gmp_init()

void gmp_init ( const gchar *  manager_address_unix,
const gchar *  manager_address_tls,
int  port_manager 
)

Init the GSA GMP library.

Parameters
[in]manager_address_unixManager address when using UNIX socket.
[in]manager_address_tlsManager address when using TLS-TCP.
[in]port_managerManager port.

Definition at line 368 of file gsad_gmp.c.

370 {
371  if (manager_address_unix)
372  {
373  manager_address = g_strdup (manager_address_unix);
374  manager_use_tls = 0;
375  }
376  else if (manager_address_tls)
377  {
378  manager_address = g_strdup (manager_address_tls);
379  manager_use_tls = 1;
380  }
381  else
382  {
383  manager_address = g_build_filename (GVM_RUN_DIR, "gvmd.sock", NULL);
384  manager_use_tls = 0;
385  }
386  manager_port = port_manager;
387 }
int manager_port
The port the manager is on.
Definition: gsad_gmp.c:140
gchar * manager_address
The address the manager is on.
Definition: gsad_gmp.c:135
int manager_use_tls
Whether to use TLS for Manager connections.
Definition: gsad_gmp.c:130

References manager_address, manager_port, and manager_use_tls.

◆ import_config_gmp()

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

Import config, get all configs, envelope the result.

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

Definition at line 7967 of file gsad_gmp.c.

7969 {
7970  gchar *command, *html, *response;
7971  entity_t entity;
7972  int ret;
7973 
7974  /* Create the config. */
7975 
7976  response = NULL;
7977  entity = NULL;
7978  command = g_strdup_printf ("<create_config>"
7979  "%s"
7980  "</create_config>",
7981  params_value (params, "xml_file"));
7982  ret =
7983  gmp (connection, credentials, &response, &entity, response_data, command);
7984  g_free (command);
7985  switch (ret)
7986  {
7987  case 0:
7988  case -1:
7989  break;
7990  case 1:
7991  cmd_response_data_set_status_code (response_data,
7992  MHD_HTTP_INTERNAL_SERVER_ERROR);
7993  return gsad_message (
7994  credentials, "Internal error", __FUNCTION__, __LINE__,
7995  "An internal error occurred while importing a config. "
7996  "The schedule remains the same. "
7997  "Diagnostics: Failure to send command to manager daemon.",
7998  response_data);
7999  case 2:
8000  cmd_response_data_set_status_code (response_data,
8001  MHD_HTTP_INTERNAL_SERVER_ERROR);
8002  return gsad_message (
8003  credentials, "Internal error", __FUNCTION__, __LINE__,
8004  "An internal error occurred while importing a config. "
8005  "It is unclear whether the schedule has been saved or not. "
8006  "Diagnostics: Failure to receive response from manager daemon.",
8007  response_data);
8008  default:
8009  cmd_response_data_set_status_code (response_data,
8010  MHD_HTTP_INTERNAL_SERVER_ERROR);
8011  return gsad_message (
8012  credentials, "Internal error", __FUNCTION__, __LINE__,
8013  "An internal error occurred while importing a config. "
8014  "It is unclear whether the schedule has been saved or not. "
8015  "Diagnostics: Internal Error.",
8016  response_data);
8017  }
8018 
8019  /* Cleanup, and return transformed XML. */
8020 
8021  html = response_from_entity (connection, credentials, params, entity,
8022  "Import Config", response_data);
8023  free_entity (entity);
8024  g_free (response);
8025  return html;
8026 }
Structure of credential related information.
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ import_port_list_gmp()

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

Import port list, get all port_lists, envelope the result.

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

Definition at line 15725 of file gsad_gmp.c.

15727 {
15728  gchar *command, *html, *response;
15729  entity_t entity;
15730  int ret;
15731 
15732  /* Create the port list. */
15733 
15734  response = NULL;
15735  entity = NULL;
15736  command = g_strdup_printf ("<create_port_list>"
15737  "%s"
15738  "</create_port_list>",
15739  params_value (params, "xml_file"));
15740  ret =
15741  gmp (connection, credentials, &response, &entity, response_data, command);
15742  g_free (command);
15743  switch (ret)
15744  {
15745  case 0:
15746  case -1:
15747  break;
15748  case 1:
15749  cmd_response_data_set_status_code (response_data,
15750  MHD_HTTP_INTERNAL_SERVER_ERROR);
15751  return gsad_message (
15752  credentials, "Internal error", __FUNCTION__, __LINE__,
15753  "An internal error occurred while importing a port_list. "
15754  "The schedule remains the same. "
15755  "Diagnostics: Failure to send command to manager daemon.",
15756  response_data);
15757  case 2:
15758  cmd_response_data_set_status_code (response_data,
15759  MHD_HTTP_INTERNAL_SERVER_ERROR);
15760  return gsad_message (
15761  credentials, "Internal error", __FUNCTION__, __LINE__,
15762  "An internal error occurred while importing a port_list. "
15763  "It is unclear whether the schedule has been saved or not. "
15764  "Diagnostics: Failure to receive response from manager daemon.",
15765  response_data);
15766  default:
15767  cmd_response_data_set_status_code (response_data,
15768  MHD_HTTP_INTERNAL_SERVER_ERROR);
15769  return gsad_message (
15770  credentials, "Internal error", __FUNCTION__, __LINE__,
15771  "An internal error occurred while importing a port_list. "
15772  "It is unclear whether the schedule has been saved or not. "
15773  "Diagnostics: Internal Error.",
15774  response_data);
15775  }
15776 
15777  /* Cleanup, and return transformed XML. */
15778 
15779  html = response_from_entity (connection, credentials, params, entity,
15780  "Import Port List", response_data);
15781  free_entity (entity);
15782  g_free (response);
15783  return html;
15784 }
Structure of credential related information.
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ import_report_format_gmp()

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

Import report format, get all report formats, envelope result.

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

Definition at line 12585 of file gsad_gmp.c.

12588 {
12589  gchar *command, *html, *response;
12590  entity_t entity;
12591  int ret;
12592 
12593  /* Create the report format. */
12594 
12595  response = NULL;
12596  entity = NULL;
12597  command = g_strdup_printf ("<create_report_format>"
12598  "%s"
12599  "</create_report_format>",
12600  params_value (params, "xml_file"));
12601  ret =
12602  gmp (connection, credentials, &response, &entity, response_data, command);
12603  g_free (command);
12604  switch (ret)
12605  {
12606  case 0:
12607  case -1:
12608  break;
12609  case 1:
12610  cmd_response_data_set_status_code (response_data,
12611  MHD_HTTP_INTERNAL_SERVER_ERROR);
12612  return gsad_message (
12613  credentials, "Internal error", __FUNCTION__, __LINE__,
12614  "An internal error occurred while importing a report format. "
12615  "The schedule remains the same. "
12616  "Diagnostics: Failure to send command to manager daemon.",
12617  response_data);
12618  case 2:
12619  cmd_response_data_set_status_code (response_data,
12620  MHD_HTTP_INTERNAL_SERVER_ERROR);
12621  return gsad_message (
12622  credentials, "Internal error", __FUNCTION__, __LINE__,
12623  "An internal error occurred while importing a report format. "
12624  "It is unclear whether the schedule has been saved or not. "
12625  "Diagnostics: Failure to receive response from manager daemon.",
12626  response_data);
12627  default:
12628  cmd_response_data_set_status_code (response_data,
12629  MHD_HTTP_INTERNAL_SERVER_ERROR);
12630  return gsad_message (
12631  credentials, "Internal error", __FUNCTION__, __LINE__,
12632  "An internal error occurred while importing a report format. "
12633  "It is unclear whether the schedule has been saved or not. "
12634  "Diagnostics: Internal Error.",
12635  response_data);
12636  }
12637 
12638  /* Cleanup, and return transformed XML. */
12639 
12640  if (entity_attribute (entity, "id"))
12641  params_add (params, "report_format_id", entity_attribute (entity, "id"));
12642  html = response_from_entity (connection, credentials, params, entity,
12643  "Create Report Format", response_data);
12644 
12645  free_entity (entity);
12646  g_free (response);
12647  return html;
12648 }
Structure of credential related information.
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:318

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

Here is the call graph for this function:

◆ import_report_gmp()

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

Import report, get all reports, envelope the result.

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

Definition at line 2384 of file gsad_gmp.c.

2386 {
2387  return create_report_gmp (connection, credentials, params, response_data);
2388 }
Structure of credential related information.
char * create_report_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Returns page to create a new container task.
Definition: gsad_gmp.c:2245

References create_report_gmp().

Here is the call graph for this function:

◆ login()

int login ( http_connection_t *  con,
params_t *  params,
cmd_response_data_t *  response_data,
const char *  client_address 
)

Login and create a session.

Parameters
[in]conHTTP Connection
[in]paramsRequest parameters
[out]response_dataExtra data return for the HTTP response
[in]client_addressClient address
Returns
MHD_YES on success. MHD_NO on errors.

Definition at line 19384 of file gsad_gmp.c.

19386 {
19387  int ret;
19388  authentication_reason_t auth_reason;
19390  gchar *timezone;
19391  gchar *role;
19392  gchar *capabilities;
19393  gchar *severity;
19394  gchar *language;
19395  gchar *pw_warning;
19396 
19397  const char *password = params_value (params, "password");
19398  const char *login = params_value (params, "login");
19399 
19400  if ((password == NULL)
19401  && (params_original_value (params, "password") == NULL))
19402  password = "";
19403 
19404  if (login && password)
19405  {
19406  ret = authenticate_gmp (login, password, &role, &timezone, &severity,
19407  &capabilities, &language, &pw_warning);
19408  if (ret)
19409  {
19410  int status;
19411  if (ret == -1)
19412  status = MHD_HTTP_INTERNAL_SERVER_ERROR;
19413  if (ret == 2)
19414  status = MHD_HTTP_SERVICE_UNAVAILABLE;
19415  else
19416  status = MHD_HTTP_UNAUTHORIZED;
19417 
19418  auth_reason = ret == 2 ? GMP_SERVICE_DOWN
19419  : (ret == -1 ? LOGIN_ERROR : LOGIN_FAILED);
19420 
19421  g_warning ("Authentication failure for '%s' from %s", login ?: "",
19422  client_address);
19423  return handler_send_reauthentication (con, status, auth_reason);
19424  }
19425  else
19426  {
19427  user_t *user;
19428  user = user_add (login, password, timezone, severity, role,
19429  capabilities, language, pw_warning, client_address);
19430 
19431  g_message ("Authentication success for '%s' from %s", login ?: "",
19432  client_address);
19433 
19434  credentials = credentials_new (user, language);
19435 
19436  gchar *data =
19437  envelope_gmp (NULL, credentials, params, NULL, response_data);
19438 
19439  ret = handler_create_response (con, data, response_data,
19440  user_get_cookie (user));
19441 
19442  user_free (user);
19443 
19445 
19446  g_free (timezone);
19447  g_free (severity);
19448  g_free (capabilities);
19449  g_free (language);
19450  g_free (role);
19451  g_free (pw_warning);
19452 
19453  return ret;
19454  }
19455  }
19456  else
19457  {
19458  g_warning ("Authentication failure for '%s' from %s", login ?: "",
19459  client_address);
19460  return handler_send_reauthentication (con, MHD_HTTP_UNAUTHORIZED,
19461  LOGIN_FAILED);
19462  }
19463 }
int handler_send_reauthentication(http_connection_t *connection, int http_status_code, authentication_reason_t reason)
Allow for reauthentication of a user.
Definition: gsad_http.c:459
Structure of credential related information.
user_t * user_add(const gchar *username, const gchar *password, const gchar *timezone, const gchar *severity, const gchar *role, const gchar *capabilities, const gchar *language, const gchar *pw_warning, const char *address)
Add a user.
Definition: gsad_user.c:359
int authenticate_gmp(const gchar *username, const gchar *password, gchar **role, gchar **timezone, gchar **severity, gchar **capabilities, gchar **language, gchar **pw_warning)
Check authentication credentials.
Definition: gsad_gmp.c:19273
void user_free(user_t *user)
Definition: gsad_user.c:102
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:19384
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:255
enum authentication_reason authentication_reason_t
Definition: gsad_http.h:171
credentials_t * credentials_new(user_t *user, const gchar *language)
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
int handler_create_response(http_connection_t *connection, gchar *data, cmd_response_data_t *response_data, const gchar *sid)
Create and send a response.
Definition: gsad_http.c:368
User information structure, for sessions.
Definition: gsad_user.c:42
void credentials_free(credentials_t *creds)
const gchar * user_get_cookie(user_t *user)
Definition: gsad_user.c:169
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

References authenticate_gmp(), credentials_free(), credentials_new(), envelope_gmp(), GMP_SERVICE_DOWN, handler_create_response(), handler_send_reauthentication(), login(), LOGIN_ERROR, LOGIN_FAILED, params_original_value(), params_value(), user_add(), user_free(), and user_get_cookie().

Referenced by create_credential_gmp(), download_credential_gmp(), login(), save_credential_gmp(), and save_user_gmp().

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

◆ manager_connect()

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

Connect to Greenbone Vulnerability Manager daemon.

Parameters
[in]credentialsUsername and password for authentication.
[out]connectionConnection to Manager on success.
[out]response_dataExtra data return for the HTTP response.
Returns
0 success, -1 failed to connect, -2 authentication failed.

Definition at line 19475 of file gsad_gmp.c.

19477 {
19478  gmp_authenticate_info_opts_t auth_opts;
19479 
19481  {
19482  cmd_response_data_set_status_code (response_data,
19483  MHD_HTTP_SERVICE_UNAVAILABLE);
19484  return -1;
19485  }
19486 
19488  auth_opts = gmp_authenticate_info_opts_defaults;
19489  auth_opts.username = user_get_username (user);
19490  auth_opts.password = user_get_password (user);
19491  if (gmp_authenticate_info_ext_c (connection, auth_opts))
19492  {
19493  g_debug ("authenticate failed!\n");
19494  gvm_connection_close (connection);
19495  return -2;
19496  }
19497 
19498 #ifdef DEBUG
19499  /* Enable this if you need the CGI to sleep after launch. This can be useful
19500  * if you need to attach to manager process the CGI is talking to for
19501  * debugging purposes.
19502  *
19503  * An easier method is to run gsad under gdb and set a breakpoint here.
19504  */
19505  g_debug ("Sleeping!");
19506  sleep (10);
19507 #endif
19508  return 0;
19509 }
int manager_port
The port the manager is on.
Definition: gsad_gmp.c:140
Structure of credential related information.
const gchar * user_get_username(user_t *user)
Definition: gsad_user.c:157
const gchar * user_get_password(user_t *user)
Definition: gsad_user.c:217
int gvm_connection_open(gvm_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_gmp.c:19235
User information structure, for sessions.
Definition: gsad_user.c:42
gchar * manager_address
The address the manager is on.
Definition: gsad_gmp.c:135
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
user_t * credentials_get_user(credentials_t *cred)

References cmd_response_data_set_status_code(), credentials_get_user(), gvm_connection_open(), manager_address, manager_port, user_get_password(), and user_get_username().

Referenced by handle_system_report().

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

◆ move_task_gmp()

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

Reassign a task to a new GMP slave.

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

Definition at line 3250 of file gsad_gmp.c.

3252 {
3253  gchar *command, *response, *html;
3254  const char *task_id, *slave_id;
3255  int ret;
3256  entity_t entity;
3257 
3258  slave_id = params_value (params, "slave_id");
3259  task_id = params_value (params, "task_id");
3260 
3261  command = g_strdup_printf ("<move_task task_id=\"%s\" slave_id=\"%s\"/>",
3262  task_id ? task_id : "", slave_id ? slave_id : "");
3263 
3264  response = NULL;
3265  entity = NULL;
3266  ret =
3267  gmp (connection, credentials, &response, &entity, response_data, command);
3268  g_free (command);
3269  switch (ret)
3270  {
3271  case 0:
3272  break;
3273  case -1:
3274  /* 'gmp' set response. */
3275  return response;
3276  case 1:
3277  cmd_response_data_set_status_code (response_data,
3278  MHD_HTTP_INTERNAL_SERVER_ERROR);
3279  return gsad_message (
3280  credentials, "Internal error", __FUNCTION__, __LINE__,
3281  "An internal error occurred while moving a task. "
3282  "The task was not moved. "
3283  "Diagnostics: Failure to send command to manager daemon.",
3284  response_data);
3285  case 2:
3286  cmd_response_data_set_status_code (response_data,
3287  MHD_HTTP_INTERNAL_SERVER_ERROR);
3288  return gsad_message (
3289  credentials, "Internal error", __FUNCTION__, __LINE__,
3290  "An internal error occurred while moving a task. "
3291  "It is unclear whether the task has been moved or not. "
3292  "Diagnostics: Failure to receive response from manager daemon.",
3293  response_data);
3294  default:
3295  cmd_response_data_set_status_code (response_data,
3296  MHD_HTTP_INTERNAL_SERVER_ERROR);
3297  return gsad_message (
3298  credentials, "Internal error", __FUNCTION__, __LINE__,
3299  "An internal error occurred while moving a task. "
3300  "It is unclear whether the task has been moved or not. "
3301  "Diagnostics: Internal Error.",
3302  response_data);
3303  }
3304 
3305  html = response_from_entity (connection, credentials, params, entity,
3306  "Move Task", response_data);
3307 
3308  free_entity (entity);
3309  g_free (response);
3310  return html;
3311 }
Structure of credential related information.
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ new_alert_gmp()

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

Returns page to create a new alert.

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

Definition at line 5418 of file gsad_gmp.c.

5420 {
5421  return new_alert (connection, credentials, params, NULL, response_data);
5422 }
Structure of credential related information.
static char * new_alert(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Returns page to create a new alert.
Definition: gsad_gmp.c:5211

References new_alert().

Here is the call graph for this function:

◆ ping_gmp()

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

Get assets, envelope the result.

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

Definition at line 19179 of file gsad_gmp.c.

19181 {
19182  return action_result (connection, credentials, params, response_data, "ping",
19183  "pong", NULL, NULL);
19184 }
Structure of credential related information.
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
Definition: gsad_gmp.c:965

References action_result().

Here is the call graph for this function:

◆ renew_session_gmp()

char* renew_session_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

Definition at line 19150 of file gsad_gmp.c.

19152 {
19153  gchar *html;
19154  gchar *message;
19156 
19159 
19160  message = g_strdup_printf ("%ld", user_get_session_timeout (user));
19161 
19162  html = action_result (connection, credentials, params, response_data,
19163  "renew_session", message, NULL, NULL);
19164  g_free (message);
19165  return html;
19166 }
void user_renew_session(user_t *user)
Definition: gsad_user.c:60
Structure of credential related information.
const gchar * user_get_token(user_t *user)
Definition: gsad_user.c:175
const time_t user_get_session_timeout(user_t *user)
Definition: gsad_user.c:229
void session_add_user(const gchar *id, user_t *user)
Add user to the session "database".
Definition: gsad_session.c:147
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
Definition: gsad_gmp.c:965
User information structure, for sessions.
Definition: gsad_user.c:42
user_t * credentials_get_user(credentials_t *cred)

References action_result(), credentials_get_user(), session_add_user(), user_get_session_timeout(), user_get_token(), and user_renew_session().

Here is the call graph for this function:

◆ report_alert_gmp()

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

Run alert for a report.

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

Definition at line 10414 of file gsad_gmp.c.

10416 {
10417  entity_t entity;
10418  const char *alert_id, *report_id;
10419  const char *status, *filter;
10420  gchar *response, *html;
10421  int ret;
10422 
10423  alert_id = params_value (params, "alert_id");
10424  report_id = params_value (params, "report_id");
10425 
10426  if ((alert_id == NULL) || (report_id == NULL))
10427  {
10428  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
10429  return gsad_message (credentials, "Bad Request", __FUNCTION__, __LINE__,
10430  "Missing parameter alert_id or report_id. "
10431  "Diagnostics: Required parameter was NULL.",
10432  response_data);
10433  }
10434 
10435  filter = params_value (params, "filter");
10436 
10437  if (filter == NULL && !params_given (params, "filter"))
10438  filter = "first=1 rows=-1"
10439  " result_hosts_only=0"
10440  " apply_overrides=1"
10441  " notes=1 overrides=1"
10442  " sort-reverse=severity";
10443 
10444  ret = gvm_connection_sendf_xml (connection,
10445  "<get_reports"
10446  " report_id=\"%s\""
10447  " ignore_pagination=\"1\""
10448  " filter=\"%s\""
10449  " alert_id=\"%s\"/>",
10450  report_id, filter ? filter : "", alert_id);
10451  if (ret == -1)
10452  {
10453  cmd_response_data_set_status_code (response_data,
10454  MHD_HTTP_INTERNAL_SERVER_ERROR);
10455  return gsad_message (
10456  credentials, "Internal error", __FUNCTION__, __LINE__,
10457  "An internal error occurred while getting a report. "
10458  "The report could not be delivered. "
10459  "Diagnostics: Failure to send command to manager daemon.",
10460  response_data);
10461  }
10462 
10463  if (read_entity_and_text_c (connection, &entity, &response))
10464  {
10465  cmd_response_data_set_status_code (response_data,
10466  MHD_HTTP_INTERNAL_SERVER_ERROR);
10467  return gsad_message (credentials, "Internal error", __FUNCTION__,
10468  __LINE__,
10469  "An internal error occurred while getting a report. "
10470  "The report could not be delivered. "
10471  "Diagnostics: Failure to receive response from "
10472  "manager daemon.",
10473  response_data);
10474  }
10475 
10476  status = entity_attribute (entity, "status");
10477  if ((status == NULL) || (strlen (status) == 0))
10478  {
10479  free_entity (entity);
10480  g_free (response);
10481  cmd_response_data_set_status_code (response_data,
10482  MHD_HTTP_INTERNAL_SERVER_ERROR);
10483  return gsad_message (
10484  credentials, "Internal error", __FUNCTION__, __LINE__,
10485  "An internal error occurred while getting a report. "
10486  "The report could not be delivered. "
10487  "Diagnostics: Failure to parse response from manager daemon.",
10488  response_data);
10489  }
10490  if (strcmp (status, "200"))
10491  {
10492  free_entity (entity);
10493  g_free (response);
10494  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
10495  return gsad_message (credentials, "Failed", __FUNCTION__, __LINE__,
10496  "Running the report alert failed."
10497  "The report could not be delivered.",
10498  response_data);
10499  }
10500 
10501  html = response_from_entity (connection, credentials, params, entity,
10502  "Report Alert", response_data);
10503 
10504  free_entity (entity);
10505  g_free (response);
10506  return html;
10507 }
Structure of credential related information.
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ restore_gmp()

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

Restore a resource, get all trash, envelope the result.

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

Definition at line 6974 of file gsad_gmp.c.

6976 {
6977  GString *xml;
6978  gchar *ret;
6979  entity_t entity;
6980  const char *target_id;
6981 
6982  target_id = params_value (params, "target_id");
6983 
6984  CHECK_VARIABLE_INVALID (target_id, "Restore")
6985 
6986  xml = g_string_new ("");
6987 
6988  /* Restore the resource. */
6989 
6990  if (gvm_connection_sendf (connection,
6991  "<restore"
6992  " id=\"%s\"/>",
6993  target_id)
6994  == -1)
6995  {
6996  g_string_free (xml, TRUE);
6997  cmd_response_data_set_status_code (response_data,
6998  MHD_HTTP_INTERNAL_SERVER_ERROR);
6999  return gsad_message (
7000  credentials, "Internal error", __FUNCTION__, __LINE__,
7001  "An internal error occurred while restoring a resource. "
7002  "The resource was not deleted. "
7003  "Diagnostics: Failure to send command to manager daemon.",
7004  response_data);
7005  }
7006 
7007  if (read_entity_and_string_c (connection, &entity, &xml))
7008  {
7009  g_string_free (xml, TRUE);
7010  cmd_response_data_set_status_code (response_data,
7011  MHD_HTTP_INTERNAL_SERVER_ERROR);
7012  return gsad_message (
7013  credentials, "Internal error", __FUNCTION__, __LINE__,
7014  "An internal error occurred while restoring a resource. "
7015  "It is unclear whether the resource has been restored or not. "
7016  "Diagnostics: Failure to read response from manager daemon.",
7017  response_data);
7018  }
7019 
7020  /* Cleanup, and return trash page. */
7021 
7022  ret = response_from_entity (connection, credentials, params, entity,
7023  "Restore", response_data);
7024  free_entity (entity);
7025  g_string_free (xml, FALSE);
7026  return ret;
7027 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ resume_task_gmp()

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

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

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

Definition at line 3214 of file gsad_gmp.c.

3216 {
3217  return resource_action (connection, credentials, params, "task", "resume",
3218  response_data);
3219 }
Structure of credential related information.
char * resource_action(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, envelope result.
Definition: gsad_gmp.c:2068

References resource_action().

Here is the call graph for this function:

◆ run_wizard_gmp()

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

Run a wizard and envelope the result.

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

Definition at line 13019 of file gsad_gmp.c.

13021 {
13022  const char *name;
13023  int ret;
13024  GString *run;
13025  param_t *param;
13026  gchar *param_name, *html, *response;
13027  params_iterator_t iter;
13028  params_t *wizard_params;
13029  entity_t entity;
13030 
13031  /* The naming is a bit subtle here, because the HTTP request
13032  * parameters are called "param"s and so are the GMP wizard
13033  * parameters. */
13034 
13035  name = params_value (params, "name");
13036  if (name == NULL)
13037  {
13038  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
13039  return gsad_message (
13040  credentials, "Internal error", __FUNCTION__, __LINE__,
13041  "An internal error occurred while trying to start a wizard. "
13042  "Diagnostics: Required parameter 'name' was NULL.",
13043  response_data);
13044  }
13045  run = g_string_new ("<run_wizard>");
13046 
13047  g_string_append_printf (run,
13048  "<name>%s</name>"
13049  "<params>",
13050  name);
13051 
13052  wizard_params = params_values (params, "event_data:");
13053  if (wizard_params)
13054  {
13055  params_iterator_init (&iter, wizard_params);
13056  while (params_iterator_next (&iter, &param_name, &param))
13057  xml_string_append (run,
13058  "<param>"
13059  "<name>%s</name>"
13060  "<value>%s</value>"
13061  "</param>",
13062  param_name, param->value);
13063  }
13064 
13065  g_string_append (run, "</params></run_wizard>");
13066 
13067  response = NULL;
13068  entity = NULL;
13069  ret =
13070  gmp (connection, credentials, &response, &entity, response_data, run->str);
13071  g_string_free (run, TRUE);
13072  switch (ret)
13073  {
13074  case 0:
13075  case -1:
13076  break;
13077  case 1:
13078  cmd_response_data_set_status_code (response_data,
13079  MHD_HTTP_INTERNAL_SERVER_ERROR);
13080  return gsad_message (
13081  credentials, "Internal error", __FUNCTION__, __LINE__,
13082  "An internal error occurred while running a wizard. "
13083  "The wizard did not start. "
13084  "Diagnostics: Failure to send command to manager daemon.",
13085  response_data);
13086  case 2:
13087  cmd_response_data_set_status_code (response_data,
13088  MHD_HTTP_INTERNAL_SERVER_ERROR);
13089  return gsad_message (
13090  credentials, "Internal error", __FUNCTION__, __LINE__,
13091  "An internal error occurred while running a wizard. "
13092  "It is unclear whether the wizard started or not. "
13093  "Diagnostics: Failure to receive response from manager daemon.",
13094  response_data);
13095  default:
13096  cmd_response_data_set_status_code (response_data,
13097  MHD_HTTP_INTERNAL_SERVER_ERROR);
13098  return gsad_message (credentials, "Internal error", __FUNCTION__,
13099  __LINE__,
13100  "An internal error occurred while running a wizard. "
13101  "It is unclear whether the wizard started or not. "
13102  "Diagnostics: Internal Error.",
13103  response_data);
13104  }
13105 
13106  html = response_from_entity (connection, credentials, params, entity,
13107  "Run Wizard", response_data);
13108  free_entity (entity);
13109  g_free (response);
13110  return html;
13111 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_agent_gmp()

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

Modify a agent, get all agents, envelope the result.

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

Definition at line 4753 of file gsad_gmp.c.

4755 {
4756  int ret;
4757  gchar *html, *response;
4758  const char *agent_id, *name, *comment;
4759  entity_t entity;
4760 
4761  agent_id = params_value (params, "agent_id");
4762  name = params_value (params, "name");
4763  comment = params_value (params, "comment");
4764 
4765  CHECK_VARIABLE_INVALID (agent_id, "Save Agent");
4766  CHECK_VARIABLE_INVALID (name, "Save Agent");
4767  CHECK_VARIABLE_INVALID (comment, "Save Agent");
4768 
4769  /* Modify the agent. */
4770 
4771  response = NULL;
4772  entity = NULL;
4773  ret = gmpf (connection, credentials, &response, &entity, response_data,
4774  "<modify_agent agent_id=\"%s\">"
4775  "<name>%s</name>"
4776  "<comment>%s</comment>"
4777  "</modify_agent>",
4778  agent_id, name, comment);
4779 
4780  switch (ret)
4781  {
4782  case 0:
4783  case -1:
4784  break;
4785  case 1:
4786  cmd_response_data_set_status_code (response_data,
4787  MHD_HTTP_INTERNAL_SERVER_ERROR);
4788  return gsad_message (
4789  credentials, "Internal error", __FUNCTION__, __LINE__,
4790  "An internal error occurred while saving a agent. "
4791  "The agent was not saved. "
4792  "Diagnostics: Failure to send command to manager daemon.",
4793  response_data);
4794  case 2:
4795  cmd_response_data_set_status_code (response_data,
4796  MHD_HTTP_INTERNAL_SERVER_ERROR);
4797  return gsad_message (
4798  credentials, "Internal error", __FUNCTION__, __LINE__,
4799  "An internal error occurred while saving a agent. "
4800  "It is unclear whether the agent has been saved or not. "
4801  "Diagnostics: Failure to receive response from manager daemon.",
4802  response_data);
4803  default:
4804  cmd_response_data_set_status_code (response_data,
4805  MHD_HTTP_INTERNAL_SERVER_ERROR);
4806  return gsad_message (
4807  credentials, "Internal error", __FUNCTION__, __LINE__,
4808  "An internal error occurred while saving a agent. "
4809  "It is unclear whether the agent has been saved or not. "
4810  "Diagnostics: Internal Error.",
4811  response_data);
4812  }
4813 
4814  html = response_from_entity (connection, credentials, params, entity,
4815  "Save Agent", response_data);
4816  free_entity (entity);
4817  g_free (response);
4818  return html;
4819 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_alert_gmp()

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

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

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

Definition at line 6427 of file gsad_gmp.c.

6429 {
6430  GString *xml;
6431  int ret;
6432  gchar *html, *response;
6433  const char *name, *comment, *alert_id;
6434  const char *event, *condition, *method;
6435  const char *filter_id, *active;
6436  params_t *event_data, *condition_data, *method_data, *report_formats;
6437  entity_t entity;
6438 
6439  name = params_value (params, "name");
6440  comment = params_value (params, "comment");
6441  condition = params_value (params, "condition");
6442  event = params_value (params, "event");
6443  method = params_value (params, "method");
6444  alert_id = params_value (params, "alert_id");
6445  filter_id = params_value (params, "filter_id");
6446  active = params_value (params, "active");
6447 
6448  CHECK_VARIABLE_INVALID (name, "Save Alert");
6449  CHECK_VARIABLE_INVALID (comment, "Save Alert");
6450  CHECK_VARIABLE_INVALID (alert_id, "Save Alert");
6451  CHECK_VARIABLE_INVALID (condition, "Save Alert");
6452  CHECK_VARIABLE_INVALID (event, "Save Alert");
6453  CHECK_VARIABLE_INVALID (method, "Save Alert");
6454  CHECK_VARIABLE_INVALID (filter_id, "Save Alert");
6455  CHECK_VARIABLE_INVALID (active, "Save Alert");
6456 
6457  xml = g_string_new ("");
6458 
6459  /* Modify the alert. */
6460 
6461  event_data = params_values (params, "event_data:");
6462  condition_data = params_values (params, "condition_data:");
6463  method_data = params_values (params, "method_data:");
6464  report_formats = params_values (params, "report_format_ids:");
6465 
6466  if (str_equal (event, EVENT_TYPE_NEW_SECINFO) && event_data)
6467  {
6468  params_iterator_t iter;
6469  char *name;
6470  param_t *param;
6471 
6472  params_iterator_init (&iter, event_data);
6473  while (params_iterator_next (&iter, &name, &param))
6474  if (str_equal (name, "feed_event") && param->value
6475  && str_equal (param->value, "updated"))
6476  {
6478  break;
6479  }
6480  }
6481 
6482  xml_string_append (xml,
6483  "<modify_alert alert_id=\"%s\">"
6484  "<name>%s</name>"
6485  "<filter id=\"%s\"/>"
6486  "<active>%s</active>"
6487  "<comment>%s</comment>"
6488  "<event>%s",
6489  alert_id, name, filter_id, active, comment ? comment : "",
6490  event);
6491 
6492  append_alert_event_data (xml, event_data, event);
6493 
6494  xml_string_append (xml,
6495  "</event>"
6496  "<method>%s",
6497  method);
6498 
6499  append_alert_method_data (xml, method_data, method, report_formats);
6500 
6501  xml_string_append (xml,
6502  "</method>"
6503  "<condition>%s",
6504  condition);
6505 
6506  append_alert_condition_data (xml, condition_data, condition);
6507 
6508  xml_string_append (xml, "</condition>"
6509  "</modify_alert>");
6510 
6511  ret =
6512  gmp (connection, credentials, &response, &entity, response_data, xml->str);
6513  g_string_free (xml, TRUE);
6514  switch (ret)
6515  {
6516  case 0:
6517  case -1:
6518  break;
6519  case 1:
6520  cmd_response_data_set_status_code (response_data,
6521  MHD_HTTP_INTERNAL_SERVER_ERROR);
6522  return gsad_message (
6523  credentials, "Internal error", __FUNCTION__, __LINE__,
6524  "An internal error occurred while saving a new alert. "
6525  "No new alert was created. "
6526  "Diagnostics: Failure to send command to manager daemon.",
6527  response_data);
6528  case 2:
6529  cmd_response_data_set_status_code (response_data,
6530  MHD_HTTP_INTERNAL_SERVER_ERROR);
6531  return gsad_message (
6532  credentials, "Internal error", __FUNCTION__, __LINE__,
6533  "An internal error occurred while saving a new alert. "
6534  "It is unclear whether the alert has been created or not. "
6535  "Diagnostics: Failure to receive response from manager daemon.",
6536  response_data);
6537  default:
6538  cmd_response_data_set_status_code (response_data,
6539  MHD_HTTP_INTERNAL_SERVER_ERROR);
6540  return gsad_message (
6541  credentials, "Internal error", __FUNCTION__, __LINE__,
6542  "An internal error occurred while saving a new alert. "
6543  "It is unclear whether the alert has been created or not. "
6544  "Diagnostics: Internal Error.",
6545  response_data);
6546  }
6547 
6548  html = response_from_entity (connection, credentials, params, entity,
6549  "Save Alert", response_data);
6550  free_entity (entity);
6551  g_free (response);
6552  return html;
6553 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
#define EVENT_TYPE_UPDATED_SECINFO
Definition: gsad_gmp.c:5429
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
static void append_alert_condition_data(GString *xml, params_t *data, const char *condition)
Send condition data for an alert.
Definition: gsad_gmp.c:5472
#define EVENT_TYPE_NEW_SECINFO
Definition: gsad_gmp.c:5428
static void append_alert_event_data(GString *xml, params_t *data, const char *event)
Send event data for an alert.
Definition: gsad_gmp.c:5444
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
static void append_alert_method_data(GString *xml, params_t *data, const char *method, params_t *report_formats)
Send method data for an alert.
Definition: gsad_gmp.c:5522

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

Here is the call graph for this function:

◆ save_asset_gmp()

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

Modify an asset, get all assets, envelope the result.

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

Definition at line 18871 of file gsad_gmp.c.

18873 {
18874  int ret;
18875  gchar *html, *response;
18876  const char *asset_id, *comment;
18877  entity_t entity;
18878 
18879  asset_id = params_value (params, "asset_id");
18880  comment = params_value (params, "comment");
18881 
18882  CHECK_VARIABLE_INVALID (asset_id, "Save Asset");
18883  CHECK_VARIABLE_INVALID (comment, "Save Asset");
18884 
18885  /* Modify the asset. */
18886 
18887  response = NULL;
18888  entity = NULL;
18889  ret = gmpf (connection, credentials, &response, &entity, response_data,
18890  "<modify_asset asset_id=\"%s\">"
18891  "<comment>%s</comment>"
18892  "</modify_asset>",
18893  asset_id, comment);
18894 
18895  switch (ret)
18896  {
18897  case 0:
18898  case -1:
18899  break;
18900  case 1:
18901  cmd_response_data_set_status_code (response_data,
18902  MHD_HTTP_INTERNAL_SERVER_ERROR);
18903  return gsad_message (
18904  credentials, "Internal error", __FUNCTION__, __LINE__,
18905  "An internal error occurred while saving an asset. "
18906  "The asset was not saved. "
18907  "Diagnostics: Failure to send command to manager daemon.",
18908  response_data);
18909  case 2:
18910  cmd_response_data_set_status_code (response_data,
18911  MHD_HTTP_INTERNAL_SERVER_ERROR);
18912  return gsad_message (
18913  credentials, "Internal error", __FUNCTION__, __LINE__,
18914  "An internal error occurred while saving an asset. "
18915  "It is unclear whether the asset has been saved or not. "
18916  "Diagnostics: Failure to receive response from manager daemon.",
18917  response_data);
18918  default:
18919  cmd_response_data_set_status_code (response_data,
18920  MHD_HTTP_INTERNAL_SERVER_ERROR);
18921  return gsad_message (
18922  credentials, "Internal error", __FUNCTION__, __LINE__,
18923  "An internal error occurred while saving an asset. "
18924  "It is unclear whether the asset has been saved or not. "
18925  "Diagnostics: Internal Error.",
18926  response_data);
18927  }
18928 
18929  html = response_from_entity (connection, credentials, params, entity,
18930  "Save Asset", response_data);
18931  free_entity (entity);
18932  g_free (response);
18933  return html;
18934 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_auth_gmp()

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

Save authentication settings.

Parameters
[in]connectionConnection to manager.
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
XML enveloped list of users and configuration.
Warning
authdn shall contain a single s, handle with care.
authdn shall contain a single s, handle with care.
authdn shall contain a single s, handle with care.

Definition at line 17674 of file gsad_gmp.c.

17676 {
17677  int ret;
17678  entity_t entity = NULL;
17679  char *html, *response = NULL, *truefalse;
17680  const char *method;
17681 
17682  if (params_value (params, "enable")
17683  && (strcmp (params_value (params, "enable"), "1") == 0))
17684  truefalse = "true";
17685  else
17686  truefalse = "false";
17687 
17688  method = params_value (params, "group");
17689  CHECK_VARIABLE_INVALID (method, "Save Authentication");
17690  if (!strcmp (method, "method:ldap_connect"))
17691  {
17692  const char *ldaphost, *authdn, *certificate;
17693  ldaphost = params_value (params, "ldaphost");
17694  authdn = params_value (params, "authdn");
17695  certificate = params_value (params, "certificate");
17696 
17697  CHECK_VARIABLE_INVALID (ldaphost, "Save Authentication");
17698  CHECK_VARIABLE_INVALID (authdn, "Save Authentication");
17699  if (params_given (params, "certificate") && strcmp (certificate, ""))
17700  {
17701  CHECK_VARIABLE_INVALID (certificate, "Save Authentication");
17703  ret =
17704  gmpf (connection, credentials, &response, &entity, response_data,
17705  "<modify_auth>"
17706  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
17707  AUTH_CONF_SETTING ("ldaphost", "%s")
17708  AUTH_CONF_SETTING ("authdn", "%s")
17709  AUTH_CONF_SETTING ("cacert", "%s") "</group>"
17710  "</modify_auth>",
17711  method, truefalse, ldaphost, authdn, certificate);
17712  }
17713  else
17715  ret = gmpf (connection, credentials, &response, &entity, response_data,
17716  "<modify_auth>"
17717  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
17718  AUTH_CONF_SETTING ("ldaphost", "%s")
17719  AUTH_CONF_SETTING ("authdn", "%s") "</group>"
17720  "</modify_auth>",
17721  method, truefalse, ldaphost, authdn);
17722  }
17723  else if (!strcmp (method, "method:radius_connect"))
17724  {
17725  const char *radiushost, *radiuskey;
17726  radiushost = params_value (params, "radiushost");
17727  radiuskey = params_value (params, "radiuskey");
17728 
17729  CHECK_VARIABLE_INVALID (radiushost, "Save Authentication");
17730  CHECK_VARIABLE_INVALID (radiuskey, "Save Authentication");
17732  ret = gmpf (connection, credentials, &response, &entity, response_data,
17733  "<modify_auth>"
17734  "<group name=\"%s\">" AUTH_CONF_SETTING ("enable", "%s")
17735  AUTH_CONF_SETTING ("radiushost", "%s")
17736  AUTH_CONF_SETTING ("radiuskey", "%s") "</group>"
17737  "</modify_auth>",
17738  method, truefalse, radiushost, radiuskey);
17739  }
17740  else
17741  return get_users (
17742  connection, credentials, params,
17743  GSAD_MESSAGE_INVALID_PARAM ("Save Authentication Configuration"),
17744  response_data);
17745 
17746  switch (ret)
17747  {
17748  case 0:
17749  case -1:
17750  break;
17751  case 1:
17752  cmd_response_data_set_status_code (response_data,
17753  MHD_HTTP_INTERNAL_SERVER_ERROR);
17754  return gsad_message (
17755  credentials, "Internal error", __FUNCTION__, __LINE__,
17756  "An internal error occurred while saving the auth settings. "
17757  "The settings were not saved. "
17758  "Diagnostics: Failure to send command to manager daemon.",
17759  response_data);
17760  case 2:
17761  cmd_response_data_set_status_code (response_data,
17762  MHD_HTTP_INTERNAL_SERVER_ERROR);
17763  return gsad_message (
17764  credentials, "Internal error", __FUNCTION__, __LINE__,
17765  "An internal error occurred while saving the auth settings. "
17766  "It is unclear whether the settings have been saved or not. "
17767  "Diagnostics: Failure to receive response from manager daemon.",
17768  response_data);
17769  default:
17770  cmd_response_data_set_status_code (response_data,
17771  MHD_HTTP_INTERNAL_SERVER_ERROR);
17772  return gsad_message (
17773  credentials, "Internal error", __FUNCTION__, __LINE__,
17774  "An internal error occurred while saving the auth settings. "
17775  "It is unclear whether the settings have been saved or not. "
17776  "Diagnostics: Internal Error.",
17777  response_data);
17778  }
17779 
17780  html =
17781  response_from_entity (connection, credentials, params, entity,
17782  "Save Authentication Configuration", response_data);
17783  free_entity (entity);
17784  g_free (response);
17785  return html;
17786 }
static char * get_users(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all users, envelope the result.
Definition: gsad_gmp.c:16951
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_gmp.
Definition: gsad_gmp.c:17657
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_gmp.c:83
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

References AUTH_CONF_SETTING, CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), get_users(), gmpf(), gsad_message(), GSAD_MESSAGE_INVALID_PARAM, params_given(), params_value(), and response_from_entity().

Here is the call graph for this function:

◆ save_config_family_gmp()

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

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

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

Definition at line 8880 of file gsad_gmp.c.

8883 {
8884  char *ret;
8885  const char *config_id, *family;
8886  params_t *nvts;
8887 
8888  config_id = params_value (params, "config_id");
8889  family = params_value (params, "family");
8890 
8891  CHECK_VARIABLE_INVALID (config_id, "Save Config Family")
8892  CHECK_VARIABLE_INVALID (family, "Save Config Family")
8893 
8894  /* Set the NVT selection. */
8895 
8896  if (gvm_connection_sendf (connection,
8897  "<modify_config config_id=\"%s\">"
8898  "<nvt_selection>"
8899  "<family>%s</family>",
8900  config_id, family)
8901  == -1)
8902  {
8903  cmd_response_data_set_status_code (response_data,
8904  MHD_HTTP_INTERNAL_SERVER_ERROR);
8905  return gsad_message (
8906  credentials, "Internal error", __FUNCTION__, __LINE__,
8907  "An internal error occurred while saving a config. "
8908  "It is unclear whether the entire config has been saved. "
8909  "Diagnostics: Failure to send command to manager daemon.",
8910  response_data);
8911  }
8912 
8913  nvts = params_values (params, "nvt:");
8914  if (nvts)
8915  {
8916  params_iterator_t iter;
8917  char *name;
8918  param_t *param;
8919 
8920  params_iterator_init (&iter, nvts);
8921  while (params_iterator_next (&iter, &name, &param))
8922  if (gvm_connection_sendf (connection, "<nvt oid=\"%s\"/>", name) == -1)
8923  {
8924  cmd_response_data_set_status_code (response_data,
8925  MHD_HTTP_INTERNAL_SERVER_ERROR);
8926  return gsad_message (
8927  credentials, "Internal error", __FUNCTION__, __LINE__,
8928  "An internal error occurred while saving a config. "
8929  "It is unclear whether the entire config has been saved. "
8930  "Diagnostics: Failure to send command to manager daemon.",
8931  response_data);
8932  }
8933  }
8934 
8935  if (gvm_connection_sendf (connection, "</nvt_selection>"
8936  "</modify_config>")
8937  == -1)
8938  {
8939  cmd_response_data_set_status_code (response_data,
8940  MHD_HTTP_INTERNAL_SERVER_ERROR);
8941  return gsad_message (
8942  credentials, "Internal error", __FUNCTION__, __LINE__,
8943  "An internal error occurred while saving a config. "
8944  "It is unclear whether the entire config has been saved. "
8945  "Diagnostics: Failure to send command to manager daemon.",
8946  response_data);
8947  }
8948 
8949  ret =
8950  check_modify_config (connection, credentials, params, "get_config_family",
8951  "edit_config_family", NULL, response_data);
8952 
8953  return ret;
8954 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static char * check_modify_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Check a modify_config response.
Definition: gsad_gmp.c:570
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_config_gmp()

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

Save details of an NVT for a config and return the next page.

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

Definition at line 8453 of file gsad_gmp.c.

8455 {
8456  int gmp_ret;
8457  char *ret, *osp_ret;
8458  params_t *preferences, *selects, *trends;
8459  const char *config_id, *name, *comment, *scanner_id;
8460  int success;
8461 
8462  config_id = params_value (params, "config_id");
8463  name = params_value (params, "name");
8464  comment = params_value (params, "comment");
8465  scanner_id = params_value (params, "scanner_id");
8466 
8467  CHECK_VARIABLE_INVALID (config_id, "Save Config");
8468  CHECK_VARIABLE_INVALID (name, "Save Config");
8469  CHECK_VARIABLE_INVALID (comment, "Save Config");
8470 
8471  /* Save name and comment. */
8472 
8473  if (scanner_id)
8474  gmp_ret = gvm_connection_sendf_xml (connection,
8475  "<modify_config config_id=\"%s\">"
8476  "<name>%s</name>"
8477  "<comment>%s</comment>"
8478  "<scanner>%s</scanner>"
8479  "</modify_config>",
8480  params_value (params, "config_id"),
8481  name, comment, scanner_id);
8482  else
8483  gmp_ret = gvm_connection_sendf_xml (connection,
8484  "<modify_config config_id=\"%s\">"
8485  "<name>%s</name>"
8486  "<comment>%s</comment>"
8487  "</modify_config>",
8488  params_value (params, "config_id"),
8489  name, comment);
8490 
8491  if (gmp_ret == -1)
8492  {
8493  cmd_response_data_set_status_code (response_data,
8494  MHD_HTTP_INTERNAL_SERVER_ERROR);
8495  return gsad_message (
8496  credentials, "Internal error", __FUNCTION__, __LINE__,
8497  "An internal error occurred while saving a config. "
8498  "It is unclear whether the entire config has been saved. "
8499  "Diagnostics: Failure to send command to manager daemon.",
8500  response_data);
8501  }
8502 
8503  ret = check_modify_config (connection, credentials, params, "get_config",
8504  "edit_config", &success, response_data);
8505  if (success == 0)
8506  {
8507  return ret;
8508  }
8509 
8510  /* Save preferences. */
8511 
8512  preferences = params_values (params, "preference:");
8513  if (preferences)
8514  {
8515  params_iterator_t iter;
8516  char *param_name;
8517  param_t *param;
8518 
8519  params_iterator_init (&iter, preferences);
8520  while (params_iterator_next (&iter, &param_name, &param))
8521  {
8522  gchar *value;
8523 
8524  value = param->value_size ? g_base64_encode ((guchar *) param->value,
8525  param->value_size)
8526  : g_strdup ("");
8527 
8528  if (gvm_connection_sendf (connection,
8529  "<modify_config config_id=\"%s\">"
8530  "<preference>"
8531  "<name>%s</name>"
8532  "<value>%s</value>"
8533  "</preference>"
8534  "</modify_config>",
8535  params_value (params, "config_id"),
8536  param_name, value)
8537  == -1)
8538  {
8539  g_free (value);
8541  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8542  return gsad_message (
8543  credentials, "Internal error", __FUNCTION__, __LINE__,
8544  "An internal error occurred while saving a config. "
8545  "It is unclear whether the entire config has been saved. "
8546  "Diagnostics: Failure to send command to manager daemon.",
8547  response_data);
8548  }
8549  g_free (value);
8550  g_free (ret);
8551 
8552  ret =
8553  check_modify_config (connection, credentials, params, "get_config",
8554  "edit_config", &success, response_data);
8555  if (success == 0)
8556  {
8557  return ret;
8558  }
8559  }
8560  }
8561 
8562  /* OSP config file preference. */
8563  osp_ret = save_osp_prefs (connection, credentials, params, "get_config",
8564  "edit_config", &success, response_data);
8565  if (osp_ret)
8566  {
8567  g_free (ret);
8568  ret = osp_ret;
8569  }
8570 
8571  if (success == 0)
8572  {
8573  if (osp_ret == NULL)
8574  {
8575  cmd_response_data_set_status_code (response_data,
8576  MHD_HTTP_INTERNAL_SERVER_ERROR);
8577  return gsad_message (
8578  credentials, "Internal error", __FUNCTION__, __LINE__,
8579  "An internal error occurred while saving a config. "
8580  "It is unclear whether the entire config has been saved. "
8581  "Diagnostics: save_osp_prefs returned NULL unexpectedly.",
8582  response_data);
8583  }
8584  return ret;
8585  }
8586 
8587  /* Update the config. */
8588 
8589  trends = params_values (params, "trend:");
8590  selects = params_values (params, "select:");
8591 
8592  if (trends || selects || params_value (params, "trend"))
8593  {
8594  if (gvm_connection_sendf (
8595  connection,
8596  "<modify_config config_id=\"%s\">"
8597  "<family_selection>"
8598  "<growing>%i</growing>",
8599  params_value (params, "config_id"),
8600  trends && params_value (params, "trend")
8601  && strcmp (params_value (params, "trend"), "0"))
8602  == -1)
8603  {
8604  cmd_response_data_set_status_code (response_data,
8605  MHD_HTTP_INTERNAL_SERVER_ERROR);
8606  return gsad_message (
8607  credentials, "Internal error", __FUNCTION__, __LINE__,
8608  "An internal error occurred while saving a config. "
8609  "It is unclear whether the entire config has been saved. "
8610  "Diagnostics: Failure to send command to manager daemon.",
8611  response_data);
8612  }
8613 
8614  if (selects)
8615  {
8616  gchar *family;
8617  params_iterator_t iter;
8618  param_t *param;
8619 
8620  params_iterator_init (&iter, selects);
8621  while (params_iterator_next (&iter, &family, &param))
8622  if (gvm_connection_sendf (connection,
8623  "<family>"
8624  "<name>%s</name>"
8625  "<all>1</all>"
8626  "<growing>%i</growing>"
8627  "</family>",
8628  family,
8629  trends && member1 (trends, family))
8630  == -1)
8631  {
8633  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8634  return gsad_message (
8635  credentials, "Internal error", __FUNCTION__, __LINE__,
8636  "An internal error occurred while saving a config. "
8637  "It is unclear whether the entire config has been saved. "
8638  "Diagnostics: Failure to send command to manager daemon.",
8639  response_data);
8640  }
8641  }
8642 
8643  if (trends)
8644  {
8645  gchar *family;
8646  params_iterator_t iter;
8647  param_t *param;
8648 
8649  params_iterator_init (&iter, trends);
8650  while (params_iterator_next (&iter, &family, &param))
8651  {
8652  if (param->value_size == 0)
8653  continue;
8654  if (param->value[0] == '0')
8655  continue;
8656  if (selects && member (selects, family))
8657  continue;
8658  if (gvm_connection_sendf (connection,
8659  "<family>"
8660  "<name>%s</name>"
8661  "<all>0</all>"
8662  "<growing>1</growing>"
8663  "</family>",
8664  family)
8665  == -1)
8666  {
8668  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
8669  return gsad_message (
8670  credentials, "Internal error", __FUNCTION__, __LINE__,
8671  "An internal error occurred while saving a config. "
8672  "It is unclear whether the entire config has been saved. "
8673  "Diagnostics: Failure to send command to manager daemon.",
8674  response_data);
8675  }
8676  }
8677  }
8678 
8679  if (gvm_connection_sendf (connection, "</family_selection>"
8680  "</modify_config>")
8681  == -1)
8682  {
8683  cmd_response_data_set_status_code (response_data,
8684  MHD_HTTP_INTERNAL_SERVER_ERROR);
8685  return gsad_message (
8686  credentials, "Internal error", __FUNCTION__, __LINE__,
8687  "An internal error occurred while saving a config. "
8688  "It is unclear whether the entire config has been saved. "
8689  "Diagnostics: Failure to send command to manager daemon.",
8690  response_data);
8691  }
8692 
8693  g_free (ret);
8694  ret = check_modify_config (connection, credentials, params, "get_config",
8695  "edit_config", NULL, response_data);
8696  }
8697  return ret;
8698 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static char * check_modify_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Check a modify_config response.
Definition: gsad_gmp.c:570
static char * save_osp_prefs(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Save OSP file preferences.
Definition: gsad_gmp.c:8386
int value_size
Definition: gsad_params.h:46
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
static int member(params_t *params, const char *string)
Look for a param with name equal to a given string.
Definition: gsad_gmp.c:520
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
Definition: gsad_gmp.c:542

References check_modify_config(), CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gsad_message(), member(), member1(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), save_osp_prefs(), param::value, and param::value_size.

Here is the call graph for this function:

◆ save_config_nvt_gmp()

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

Save NVT prefs for a config, get NVT details, envelope result.

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

Definition at line 9142 of file gsad_gmp.c.

9144 {
9145  params_t *preferences;
9146  const char *config_id;
9147  int success;
9148  char *modify_config_ret;
9149 
9150  modify_config_ret = NULL;
9151  config_id = params_value (params, "config_id");
9152 
9153  preferences = params_values (params, "preference:");
9154  if (preferences)
9155  {
9156  param_t *preference;
9157  gchar *preference_name;
9158  params_iterator_t iter;
9159 
9160  /* Save preferences. */
9161 
9162  params_iterator_init (&iter, preferences);
9163  while (params_iterator_next (&iter, &preference_name, &preference))
9164  {
9165  int type_start, type_end, count, ret, is_timeout = 0;
9166  gchar *value;
9167 
9168  g_free (modify_config_ret);
9169  modify_config_ret = NULL;
9170 
9171  /* Passwords and files have checkboxes to control whether they
9172  * must be reset. This works around the need for the Manager to
9173  * send the actual password or show the actual file. */
9174 
9175  /* LDAPsearch[entry]:Timeout value */
9176  count = sscanf (preference_name, "%*[^[][%n%*[^]]%n]:", &type_start,
9177  &type_end);
9178  if (count == 0 && type_start > 0 && type_end > 0)
9179  {
9180  if (strncmp (preference_name + type_start, "password",
9181  type_end - type_start)
9182  == 0)
9183  {
9184  int found = 0;
9185  params_t *passwords;
9186 
9187  passwords = params_values (params, "password:");
9188  if (passwords)
9189  {
9190  param_t *password;
9191  gchar *password_name;
9192  params_iterator_t password_params;
9193 
9194  params_iterator_init (&password_params, passwords);
9195  while (params_iterator_next (&password_params,
9196  &password_name, &password))
9197  if (strcmp (password_name, preference_name) == 0)
9198  {
9199  found = 1;
9200  break;
9201  }
9202  }
9203  if (found == 0)
9204  /* Skip modifying the password preference. */
9205  continue;
9206  }
9207  else if (strncmp (preference_name + type_start, "file",
9208  type_end - type_start)
9209  == 0)
9210  {
9211  int found = 0;
9212  params_t *files;
9213 
9214  files = params_values (params, "file:");
9215  if (files)
9216  {
9217  param_t *file;
9218  gchar *file_name;
9219  params_iterator_t file_params;
9220 
9221  params_iterator_init (&file_params, files);
9222  while (
9223  params_iterator_next (&file_params, &file_name, &file))
9224  if (strcmp (file_name, preference_name) == 0)
9225  {
9226  found = 1;
9227  break;
9228  }
9229  }
9230  if (found == 0)
9231  /* Skip modifying the file preference. */
9232  continue;
9233  }
9234  else if (strncmp (preference_name + type_start, "scanner",
9235  type_end - type_start)
9236  == 0)
9237  {
9238  /* Presume it's the timeout. */
9239  is_timeout = 1;
9240  }
9241  }
9242 
9243  value = preference->value_size
9244  ? g_base64_encode ((guchar *) preference->value,
9245  preference->value_size)
9246  : g_strdup ("");
9247 
9248  if (is_timeout)
9249  {
9250  const char *timeout;
9251  gchar *preference_name_escaped;
9252 
9253  timeout = params_value (params, "timeout");
9254 
9255  if (timeout == NULL)
9256  {
9257  g_free (value);
9258  cmd_response_data_set_status_code (response_data,
9259  MHD_HTTP_BAD_REQUEST);
9260  return gsad_message (
9261  credentials, "Internal error", __FUNCTION__, __LINE__,
9262  "An internal error occurred while saving a config. "
9263  "It is unclear whether the entire config has been saved. "
9264  "Diagnostics: Required parameter was NULL.",
9265  response_data);
9266  }
9267 
9268  preference_name_escaped =
9269  g_markup_escape_text (preference_name, -1);
9270 
9271  if (strcmp (timeout, "0") == 0)
9272  /* Leave out the value to clear the preference. */
9273  ret = gvm_connection_sendf (connection,
9274  "<modify_config"
9275  " config_id=\"%s\">"
9276  "<preference>"
9277  "<name>%s</name>"
9278  "</preference>"
9279  "</modify_config>",
9280  config_id, preference_name_escaped);
9281  else
9282  ret = gvm_connection_sendf (connection,
9283  "<modify_config"
9284  " config_id=\"%s\">"
9285  "<preference>"
9286  "<name>%s</name>"
9287  "<value>%s</value>"
9288  "</preference>"
9289  "</modify_config>",
9290  config_id, preference_name_escaped,
9291  value);
9292 
9293  g_free (preference_name_escaped);
9294  }
9295  else
9296  {
9297  gchar *preference_name_escaped;
9298  preference_name_escaped =
9299  g_markup_escape_text (preference_name, -1);
9300  ret =
9301  gvm_connection_sendf (connection,
9302  "<modify_config"
9303  " config_id=\"%s\">"
9304  "<preference>"
9305  "<nvt oid=\"%s\"/>"
9306  "<name>%s</name>"
9307  "<value>%s</value>"
9308  "</preference>"
9309  "</modify_config>",
9310  config_id, params_value (params, "oid"),
9311  preference_name_escaped, value);
9312  g_free (preference_name_escaped);
9313  }
9314 
9315  if (ret == -1)
9316  {
9317  g_free (value);
9319  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
9320  return gsad_message (
9321  credentials, "Internal error", __FUNCTION__, __LINE__,
9322  "An internal error occurred while saving a config. "
9323  "It is unclear whether the entire config has been saved. "
9324  "Diagnostics: Failure to send command to manager daemon.",
9325  response_data);
9326  }
9327  g_free (value);
9328 
9329  modify_config_ret = check_modify_config (
9330  connection, credentials, params, "get_config_nvt",
9331  "edit_config_nvt", &success, response_data);
9332  if (success == 0)
9333  {
9334  return modify_config_ret;
9335  }
9336  }
9337  }
9338 
9339  /* Create a generic success message in case modify_config_ret is NULL,
9340  * which could happen if the last preference is a password and skipped.
9341  * This assumes that messages are returned earlier in case of errors. */
9342  modify_config_ret = action_result (
9343  connection, credentials, params, response_data, "Modify Config",
9344  "All NVT preferences modified successfully", NULL, NULL);
9345 
9346  return modify_config_ret;
9347 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
static char * check_modify_config(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *next, const char *fail_next, int *success, cmd_response_data_t *response_data)
Check a modify_config response.
Definition: gsad_gmp.c:570
int value_size
Definition: gsad_params.h:46
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * action_result(gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *, const char *action, const char *message, const char *details, const char *id)
Generate a enveloped GMP XML containing an action result.
Definition: gsad_gmp.c:965
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

References action_result(), check_modify_config(), cmd_response_data_set_status_code(), gsad_message(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), param::value, and param::value_size.

Here is the call graph for this function:

◆ save_container_task_gmp()

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

Save container task, get next page, envelope the result.

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

Definition at line 3059 of file gsad_gmp.c.

3062 {
3063  gchar *format, *response, *html;
3064  const char *comment, *name, *task_id;
3065  const char *in_assets, *auto_delete, *auto_delete_data;
3066  int ret;
3067  entity_t entity;
3068 
3069  comment = params_value (params, "comment");
3070  in_assets = params_value (params, "in_assets");
3071  name = params_value (params, "name");
3072  task_id = params_value (params, "task_id");
3073  auto_delete = params_value (params, "auto_delete");
3074  auto_delete_data = params_value (params, "auto_delete_data");
3075  CHECK_VARIABLE_INVALID (name, "Save Task")
3076  CHECK_VARIABLE_INVALID (comment, "Save Task")
3077  CHECK_VARIABLE_INVALID (task_id, "Save Task")
3078  CHECK_VARIABLE_INVALID (in_assets, "Save Task")
3079  CHECK_VARIABLE_INVALID (auto_delete, "Save Task");
3080  CHECK_VARIABLE_INVALID (auto_delete_data, "Save Task");
3081 
3082  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
3083  "<name>%%s</name>"
3084  "<comment>%%s</comment>"
3085  "<preferences>"
3086  "<preference>"
3087  "<scanner_name>in_assets</scanner_name>"
3088  "<value>%%s</value>"
3089  "</preference>"
3090  "<preference>"
3091  "<scanner_name>auto_delete</scanner_name>"
3092  "<value>%%s</value>"
3093  "</preference>"
3094  "<preference>"
3095  "<scanner_name>auto_delete_data</scanner_name>"
3096  "<value>%%s</value>"
3097  "</preference>"
3098  "</preferences>"
3099  "</modify_task>");
3100 
3101  response = NULL;
3102  entity = NULL;
3103  ret =
3104  gmpf (connection, credentials, &response, &entity, response_data, format,
3105  task_id, name, comment, strcmp (in_assets, "0") ? "yes" : "no",
3106  auto_delete, auto_delete_data);
3107  g_free (format);
3108  switch (ret)
3109  {
3110  case 0:
3111  case -1:
3112  break;
3113  case 1:
3114  cmd_response_data_set_status_code (response_data,
3115  MHD_HTTP_INTERNAL_SERVER_ERROR);
3116  return gsad_message (
3117  credentials, "Internal error", __FUNCTION__, __LINE__,
3118  "An internal error occurred while saving a task. "
3119  "No new task was created. "
3120  "Diagnostics: Failure to send command to manager daemon.",
3121  response_data);
3122  case 2:
3123  cmd_response_data_set_status_code (response_data,
3124  MHD_HTTP_INTERNAL_SERVER_ERROR);
3125  return gsad_message (
3126  credentials, "Internal error", __FUNCTION__, __LINE__,
3127  "An internal error occurred while saving a task. "
3128  "It is unclear whether the task has been created or not. "
3129  "Diagnostics: Failure to receive response from manager daemon.",
3130  response_data);
3131  default:
3132  cmd_response_data_set_status_code (response_data,
3133  MHD_HTTP_INTERNAL_SERVER_ERROR);
3134  return gsad_message (
3135  credentials, "Internal error", __FUNCTION__, __LINE__,
3136  "An internal error occurred while saving a task. "
3137  "It is unclear whether the task has been created or not. "
3138  "Diagnostics: Internal Error.",
3139  response_data);
3140  }
3141 
3142  html = response_from_entity (connection, credentials, params, entity,
3143  "Save Container Task", response_data);
3144  free_entity (entity);
3145  g_free (response);
3146  return html;
3147 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_credential_gmp()

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

Save credential, get next page, envelope the result.

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

Definition at line 4197 of file gsad_gmp.c.

4199 {
4200  int ret, change_password, change_ssh_passphrase;
4201  int change_community, change_privacy_password;
4202  gchar *html, *response;
4203  const char *credential_id, *public_key;
4204  const char *name, *comment, *login, *password, *passphrase, *type;
4205  const char *private_key, *certificate, *community, *privacy_password;
4206  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
4207  GString *command;
4208  entity_t entity;
4209 
4210  credential_id = params_value (params, "credential_id");
4211  type = params_value (params, "credential_type");
4212  name = params_value (params, "name");
4213  comment = params_value (params, "comment");
4214  login = params_value (params, "credential_login");
4215  password = params_value (params, "password");
4216  passphrase = params_value (params, "passphrase");
4217  private_key = params_value (params, "private_key");
4218  certificate = params_value (params, "certificate");
4219  community = params_value (params, "community");
4220  privacy_password = params_value (params, "privacy_password");
4221  auth_algorithm = params_value (params, "auth_algorithm");
4222  privacy_algorithm = params_value (params, "privacy_algorithm");
4223  allow_insecure = params_value (params, "allow_insecure");
4224  public_key = params_value (params, "public_key");
4225 
4226  CHECK_VARIABLE_INVALID (credential_id, "Save Credential");
4227  CHECK_VARIABLE_INVALID (name, "Save Credential");
4228  CHECK_VARIABLE_INVALID (comment, "Save Credential");
4229  CHECK_VARIABLE_INVALID (allow_insecure, "Save Credential");
4230  CHECK_VARIABLE_INVALID (type, "Save Credential");
4231 
4232  if (str_equal (type, "cc"))
4233  {
4234  if (params_given (params, "certificate"))
4235  CHECK_VARIABLE_INVALID (certificate, "Save Credential");
4236 
4237  if (params_given (params, "private_key"))
4238  CHECK_VARIABLE_INVALID (private_key, "Save Credential");
4239 
4240  if (params_given (params, "change_passphrase"))
4241  CHECK_VARIABLE_INVALID (passphrase, "Save Credential");
4242  }
4243  else if (str_equal (type, "snmp"))
4244  {
4245  if (params_given (params, "auth_algorithm"))
4246  CHECK_VARIABLE_INVALID (auth_algorithm, "Save Credential");
4247 
4248  if (params_given (params, "privacy_algorithm"))
4249  CHECK_VARIABLE_INVALID (privacy_algorithm, "Save Credential");
4250 
4251  if (params_given (params, "change_privacy_password"))
4252  CHECK_VARIABLE_INVALID (privacy_password, "Save Credential");
4253 
4254  if (params_given (params, "change_community"))
4255  CHECK_VARIABLE_INVALID (community, "Save Credential");
4256  }
4257  else if (str_equal (type, "up") | str_equal (type, "pw"))
4258  {
4259  if (params_given (params, "change_password"))
4260  CHECK_VARIABLE_INVALID (password, "Save Credential");
4261  }
4262  else if (str_equal (type, "smime"))
4263  {
4264  if (params_given (params, "certificate"))
4265  CHECK_VARIABLE_INVALID (certificate, "Save Credential");
4266  }
4267  else if (str_equal (type, "smime"))
4268  {
4269  if (params_given (params, "public_key"))
4270  CHECK_VARIABLE_INVALID (public_key, "Save Credential");
4271  }
4272 
4273  if (params_given (params, "login"))
4274  CHECK_VARIABLE_INVALID (login, "Save Credential");
4275 
4276  change_password = params_value_bool (params, "change_password");
4277 
4278  /* Prepare command */
4279  command = g_string_new ("");
4280 
4281  xml_string_append (command,
4282  "<modify_credential credential_id=\"%s\">"
4283  "<name>%s</name>"
4284  "<comment>%s</comment>"
4285  "<allow_insecure>%s</allow_insecure>",
4286  credential_id, name, comment, allow_insecure);
4287 
4288  if (str_equal (type, "snmp"))
4289  {
4290  change_community = params_value_bool (params, "change_community");
4291  change_privacy_password =
4292  params_value_bool (params, "change_privacy_password");
4293 
4294  if (auth_algorithm)
4295  xml_string_append (command, "<auth_algorithm>%s</auth_algorithm>",
4296  auth_algorithm);
4297 
4298  if (change_community)
4299  xml_string_append (command, "<community>%s</community>", community);
4300 
4301  if (privacy_algorithm || change_privacy_password)
4302  {
4303  xml_string_append (command, "<privacy>");
4304  if (privacy_algorithm)
4305  {
4306  xml_string_append (command, "<algorithm>%s</algorithm>",
4307  privacy_algorithm);
4308  }
4309  if (change_privacy_password && privacy_password)
4310  {
4311  xml_string_append (command, "<password>%s</password>",
4312  privacy_password);
4313  }
4314 
4315  xml_string_append (command, "</privacy>");
4316  }
4317  }
4318  else if (str_equal (type, "cc"))
4319  {
4320  if ((certificate && strcmp (certificate, "")))
4321  {
4322  xml_string_append (command, "<certificate>%s</certificate>",
4323  certificate);
4324  }
4325 
4326  if ((private_key && strcmp (private_key, "")))
4327  {
4328  xml_string_append (command, "<key>");
4329  xml_string_append (command, "<private>%s</private>", private_key);
4330  xml_string_append (command, "</key>");
4331  }
4332  }
4333  else if (str_equal (type, "usk"))
4334  {
4335  change_ssh_passphrase = params_value_bool (params, "change_passphrase");
4336 
4337  if ((private_key && strcmp (private_key, "")) || change_ssh_passphrase)
4338  {
4339  xml_string_append (command, "<key>");
4340  if (change_ssh_passphrase)
4341  xml_string_append (command, "<phrase>%s</phrase>", passphrase);
4342  if (private_key)
4343  xml_string_append (command, "<private>%s</private>", private_key);
4344  xml_string_append (command, "</key>");
4345  }
4346  }
4347  else if (str_equal (type, "up") | str_equal (type, "pw"))
4348  {
4349  if (change_password)
4350  xml_string_append (command, "<password>%s</password>", password);
4351  }
4352  else if (str_equal (type, "smime"))
4353  {
4354  if ((certificate && strcmp (certificate, "")))
4355  {
4356  xml_string_append (command, "<certificate>%s</certificate>",
4357  certificate);
4358  }
4359  }
4360  else if (str_equal (type, "pgp"))
4361  {
4362  if ((public_key && strcmp (public_key, "")))
4363  {
4364  xml_string_append (command, "<key>");
4365  xml_string_append (command, "<public>%s</public>", public_key);
4366  xml_string_append (command, "</key>");
4367  }
4368  }
4369 
4370  if (login && strcmp (login, ""))
4371  xml_string_append (command, "<login>%s</login>", login);
4372 
4373  xml_string_append (command, "</modify_credential>");
4374 
4375  /* Modify the credential. */
4376  response = NULL;
4377  entity = NULL;
4378  ret = gmp (connection, credentials, &response, &entity, response_data,
4379  command->str);
4380  g_string_free (command, TRUE);
4381 
4382  switch (ret)
4383  {
4384  case 0:
4385  break;
4386  case -1:
4387  /* 'gmp' set response. */
4388  return response;
4389  case 1:
4390  cmd_response_data_set_status_code (response_data,
4391  MHD_HTTP_INTERNAL_SERVER_ERROR);
4392  return gsad_message (
4393  credentials, "Internal error", __FUNCTION__, __LINE__,
4394  "An internal error occurred while saving a Credential. "
4395  "The Credential was not saved. "
4396  "Diagnostics: Failure to send command to manager daemon.",
4397  response_data);
4398  case 2:
4399  cmd_response_data_set_status_code (response_data,
4400  MHD_HTTP_INTERNAL_SERVER_ERROR);
4401  return gsad_message (
4402  credentials, "Internal error", __FUNCTION__, __LINE__,
4403  "An internal error occurred while saving a Credential. "
4404  "It is unclear whether the Credential has been saved or not. "
4405  "Diagnostics: Failure to receive response from manager daemon.",
4406  response_data);
4407  default:
4408  cmd_response_data_set_status_code (response_data,
4409  MHD_HTTP_INTERNAL_SERVER_ERROR);
4410  return gsad_message (
4411  credentials, "Internal error", __FUNCTION__, __LINE__,
4412  "An internal error occurred while saving a Credential. "
4413  "It is unclear whether the Credential has been saved or not. "
4414  "Diagnostics: Internal Error.",
4415  response_data);
4416  }
4417 
4418  html = response_from_entity (connection, credentials, params, entity,
4419  "Save Credential", response_data);
4420  free_entity (entity);
4421  g_free (response);
4422  return html;
4423 }
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:19384
gboolean params_value_bool(params_t *params, const char *name)
Get boolean value of param.
Definition: gsad_base.c:221
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), gmp(), gsad_message(), login(), params_given(), params_value(), params_value_bool(), response_from_entity(), and str_equal().

Here is the call graph for this function:

◆ save_filter_gmp()

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

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

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

Definition at line 16641 of file gsad_gmp.c.

16643 {
16644  entity_t entity;
16645  gchar *html, *response;
16646  const char *filter_id, *name, *comment, *term, *type;
16647 
16648  filter_id = params_value (params, "filter_id");
16649  name = params_value (params, "name");
16650  comment = params_value (params, "comment");
16651  term = params_value (params, "term");
16652  type = params_value (params, "optional_resource_type");
16653 
16654  CHECK_VARIABLE_INVALID (filter_id, "Save Filter");
16655  CHECK_VARIABLE_INVALID (name, "Save Filter");
16656  CHECK_VARIABLE_INVALID (comment, "Save Filter");
16657  CHECK_VARIABLE_INVALID (term, "Save Filter");
16658  CHECK_VARIABLE_INVALID (type, "Save Filter");
16659 
16660  {
16661  int ret;
16662 
16663  /* Modify the filter. */
16664 
16665  ret = gvm_connection_sendf_xml (connection,
16666  "<modify_filter filter_id=\"%s\">"
16667  "<name>%s</name>"
16668  "<comment>%s</comment>"
16669  "<term>%s</term>"
16670  "<type>%s</type>"
16671  "</modify_filter>",
16672  filter_id, name, comment, term, type);
16673 
16674  if (ret == -1)
16675  {
16676  cmd_response_data_set_status_code (response_data,
16677  MHD_HTTP_INTERNAL_SERVER_ERROR);
16678  return gsad_message (
16679  credentials, "Internal error", __FUNCTION__, __LINE__,
16680  "An internal error occurred while modifying a filter. "
16681  "The filter was not modified. "
16682  "Diagnostics: Failure to send command to manager daemon.",
16683  response_data);
16684  }
16685 
16686  entity = NULL;
16687  if (read_entity_and_text_c (connection, &entity, &response))
16688  {
16689  cmd_response_data_set_status_code (response_data,
16690  MHD_HTTP_INTERNAL_SERVER_ERROR);
16691  return gsad_message (
16692  credentials, "Internal error", __FUNCTION__, __LINE__,
16693  "An internal error occurred while modifying a filter. "
16694  "It is unclear whether the filter has been modified or not. "
16695  "Diagnostics: Failure to receive response from manager daemon.",
16696  response_data);
16697  }
16698  }
16699 
16700  /* Pass response to handler of following page. */
16701 
16702  html = response_from_entity (connection, credentials, params, entity,
16703  "Save Filter", response_data);
16704 
16705  free_entity (entity);
16706  g_free (response);
16707  return html;
16708 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_group_gmp()

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

Modify a group, return the next page.

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

Definition at line 14290 of file gsad_gmp.c.

14292 {
14293  int ret;
14294  gchar *html, *response;
14295  const char *group_id, *name, *comment, *users;
14296  entity_t entity;
14297 
14298  group_id = params_value (params, "group_id");
14299  name = params_value (params, "name");
14300  comment = params_value (params, "comment");
14301  users = params_value (params, "users");
14302 
14303  CHECK_VARIABLE_INVALID (group_id, "Save Group");
14304  CHECK_VARIABLE_INVALID (name, "Save Group");
14305  CHECK_VARIABLE_INVALID (comment, "Save Group");
14306  CHECK_VARIABLE_INVALID (users, "Save Group");
14307 
14308  /* Modify the Group. */
14309 
14310  response = NULL;
14311  entity = NULL;
14312  ret = gmpf (connection, credentials, &response, &entity, response_data,
14313  "<modify_group group_id=\"%s\">"
14314  "<name>%s</name>"
14315  "<comment>%s</comment>"
14316  "<users>%s</users>"
14317  "</modify_group>",
14318  group_id, name, comment, users);
14319 
14320  switch (ret)
14321  {
14322  case 0:
14323  case -1:
14324  break;
14325  case 1:
14326  cmd_response_data_set_status_code (response_data,
14327  MHD_HTTP_INTERNAL_SERVER_ERROR);
14328  return gsad_message (
14329  credentials, "Internal error", __FUNCTION__, __LINE__,
14330  "An internal error occurred while saving a group. "
14331  "The group was not saved. "
14332  "Diagnostics: Failure to send command to manager daemon.",
14333  response_data);
14334  case 2:
14335  cmd_response_data_set_status_code (response_data,
14336  MHD_HTTP_INTERNAL_SERVER_ERROR);
14337  return gsad_message (
14338  credentials, "Internal error", __FUNCTION__, __LINE__,
14339  "An internal error occurred while saving a group. "
14340  "It is unclear whether the group has been saved or not. "
14341  "Diagnostics: Failure to receive response from manager daemon.",
14342  response_data);
14343  default:
14344  cmd_response_data_set_status_code (response_data,
14345  MHD_HTTP_INTERNAL_SERVER_ERROR);
14346  return gsad_message (
14347  credentials, "Internal error", __FUNCTION__, __LINE__,
14348  "An internal error occurred while saving a group. "
14349  "It is unclear whether the group has been saved or not. "
14350  "Diagnostics: Internal Error.",
14351  response_data);
14352  }
14353 
14354  html = response_from_entity (connection, credentials, params, entity,
14355  "Save Group", response_data);
14356  free_entity (entity);
14357  g_free (response);
14358  return html;
14359 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
GPtrArray * users
User session data.
Definition: gsad_session.c:39
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_my_settings_gmp()

char* save_my_settings_gmp ( gvm_connection_t *  connection,
credentials_t *  credentials,
params_t *  params,
const gchar *  accept_language,
cmd_response_data_t *  response_data 
)

Returns page with user's settings, for editing.

Parameters
[in]connectionConnection to manager.
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]accept_languageAccept-Language, from browser.
[out]timezoneTimezone. Caller must free.
[out]passwordPassword. Caller must free.
[out]severitySeverity. Caller must free.
[out]languageLanguage. Caller must free.
[out]response_dataExtra data return for the HTTP response.
Returns
Enveloped XML object.

Definition at line 13317 of file gsad_gmp.c.

13320 {
13321  const char *lang, *text, *old_passwd, *passwd, *max;
13322  const char *details_fname, *list_fname, *report_fname;
13323  gchar *lang_64, *text_64, *max_64, *fname_64;
13324  GString *xml;
13325  entity_t entity;
13326  params_t *changed, *defaults, *filters;
13327  int modify_failed = 0;
13328  const char *changed_value;
13329  gboolean user_changed = 0;
13330 
13332 
13333  changed = params_values (params, "settings_changed:");
13334 
13335  text = params_value (params, "text");
13336  old_passwd = params_value (params, "old_password");
13337  passwd = params_value (params, "password");
13338  max = params_value (params, "max");
13339  lang = params_value (params, "lang");
13340  details_fname = params_value (params, "details_fname");
13341  list_fname = params_value (params, "list_fname");
13342  report_fname = params_value (params, "report_fname");
13343 
13344  CHECK_VARIABLE_INVALID (text, "Save Settings")
13345  CHECK_VARIABLE_INVALID (text, "Save Settings")
13346  CHECK_VARIABLE_INVALID (old_passwd, "Save Settings")
13347  CHECK_VARIABLE_INVALID (max, "Save Settings")
13348  CHECK_VARIABLE_INVALID (lang, "Save Settings")
13349  CHECK_VARIABLE_INVALID (details_fname, "Save Settings")
13350  CHECK_VARIABLE_INVALID (list_fname, "Save Settings")
13351  CHECK_VARIABLE_INVALID (report_fname, "Save Settings")
13352 
13353  xml = g_string_new ("");
13354 
13355  changed_value = params_value (changed, "password");
13356  if ((strlen (passwd) || strlen (old_passwd))
13357  && (changed_value == NULL
13358  || (strcmp (changed_value, "") && strcmp (changed_value, "0"))))
13359  {
13360  gchar *passwd_64;
13361  gmp_authenticate_info_opts_t auth_opts;
13362 
13363  /* Send Password setting */
13364 
13365  auth_opts = gmp_authenticate_info_opts_defaults;
13366  auth_opts.username = user_get_username (user);
13367  auth_opts.password = old_passwd;
13368  switch (gmp_authenticate_info_ext_c (connection, auth_opts))
13369  {
13370  case 0:
13371  break;
13372  case 1:
13373  cmd_response_data_set_status_code (response_data,
13374  MHD_HTTP_INTERNAL_SERVER_ERROR);
13375  return gsad_message (
13376  credentials, "Internal error", __FUNCTION__, __LINE__,
13377  "An internal error occurred while saving settings. "
13378  "The settings remains the same. "
13379  "Diagnostics: Manager closed connection during authenticate.",
13380  response_data);
13381  case 2:
13382  cmd_response_data_set_status_code (response_data,
13383  MHD_HTTP_INTERNAL_SERVER_ERROR);
13384  return gsad_message (
13385  credentials, "Invalid Password", __FUNCTION__, __LINE__,
13386  "You tried to change your password, but the old"
13387  " password was not provided or was incorrect. "
13388  " Please enter the correct old password or remove"
13389  " old and new passwords to apply any other changes"
13390  " of your settings.",
13391  response_data);
13392  default:
13393  cmd_response_data_set_status_code (response_data,
13394  MHD_HTTP_INTERNAL_SERVER_ERROR);
13395  return gsad_message (
13396  credentials, "Internal error", __FUNCTION__, __LINE__,
13397  "An internal error occurred while saving settings. "
13398  "The settings remains the same. "
13399  "Diagnostics: Internal Error.",
13400  response_data);
13401  }
13402 
13403  passwd_64 = g_base64_encode ((guchar *) passwd, strlen (passwd));
13404 
13405  if (gvm_connection_sendf (connection,
13406  "<modify_setting>"
13407  "<name>Password</name>"
13408  "<value>%s</value>"
13409  "</modify_setting>",
13410  passwd_64 ? passwd_64 : "")
13411  == -1)
13412  {
13413  g_free (passwd_64);
13414  cmd_response_data_set_status_code (response_data,
13415  MHD_HTTP_INTERNAL_SERVER_ERROR);
13416  return gsad_message (
13417  credentials, "Internal error", __FUNCTION__, __LINE__,
13418  "An internal error occurred while saving settings. "
13419  "It is unclear whether all the settings were saved. "
13420  "Diagnostics: Failure to send command to manager daemon.",
13421  response_data);
13422  }
13423  g_free (passwd_64);
13424 
13425  entity = NULL;
13426  xml_string_append (xml, "<save_setting name=\"Password\">");
13427  if (read_entity_and_string_c (connection, &entity, &xml))
13428  {
13429  g_string_free (xml, TRUE);
13430  cmd_response_data_set_status_code (response_data,
13431  MHD_HTTP_INTERNAL_SERVER_ERROR);
13432  return gsad_message (
13433  credentials, "Internal error", __FUNCTION__, __LINE__,
13434  "An internal error occurred while saving settings. "
13435  "Diagnostics: Failure to receive response from manager daemon.",
13436  response_data);
13437  }
13438  xml_string_append (xml, "</save_setting>");
13439 
13440  if (gmp_success (entity) == 1)
13441  {
13442  user_set_password (user, passwd);
13444  user_changed = 1;
13445  }
13446  else
13447  {
13448  set_http_status_from_entity (entity, response_data);
13449  modify_failed = 1;
13450  }
13451  }
13452 
13453  /* Send Timezone */
13454  changed_value = params_value (changed, "timezone");
13455  if (changed_value == NULL
13456  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13457  {
13458  text_64 = g_base64_encode ((guchar *) text, strlen (text));
13459 
13460  if (gvm_connection_sendf (connection,
13461  "<modify_setting>"
13462  "<name>Timezone</name>"
13463  "<value>%s</value>"
13464  "</modify_setting>",
13465  text_64 ? text_64 : "")
13466  == -1)
13467  {
13468  g_free (text_64);
13469  cmd_response_data_set_status_code (response_data,
13470  MHD_HTTP_INTERNAL_SERVER_ERROR);
13471  return gsad_message (
13472  credentials, "Internal error", __FUNCTION__, __LINE__,
13473  "An internal error occurred while saving settings. "
13474  "It is unclear whether all the settings were saved. "
13475  "Diagnostics: Failure to send command to manager daemon.",
13476  response_data);
13477  }
13478  g_free (text_64);
13479 
13480  entity = NULL;
13481  xml_string_append (xml, "<save_setting name=\"Timezone\">");
13482  if (read_entity_and_string_c (connection, &entity, &xml))
13483  {
13484  g_string_free (xml, TRUE);
13485  cmd_response_data_set_status_code (response_data,
13486  MHD_HTTP_INTERNAL_SERVER_ERROR);
13487  return gsad_message (
13488  credentials, "Internal error", __FUNCTION__, __LINE__,
13489  "An internal error occurred while saving settings. "
13490  "Diagnostics: Failure to receive response from manager daemon.",
13491  response_data);
13492  }
13493  xml_string_append (xml, "</save_setting>");
13494 
13495  if (gmp_success (entity) == 1)
13496  {
13497  const gchar *timezone = strlen (text) ? text : "UTC";
13498 
13499  user_set_timezone (user, timezone);
13500  user_changed = 1;
13501 
13502  /* Set the timezone, so that the ENVELOPE/TIME
13503  * uses the right timezone. */
13504 
13505  if (setenv ("TZ", timezone, 1) == -1)
13506  {
13507  g_critical ("%s: failed to set TZ\n", __FUNCTION__);
13508  exit (EXIT_FAILURE);
13509  }
13510  tzset ();
13511  }
13512  else
13513  {
13514  set_http_status_from_entity (entity, response_data);
13515  modify_failed = 1;
13516  }
13517  }
13518 
13519  /* Send Rows Per Page */
13520  changed_value = params_value (changed, "max");
13521  if (changed_value == NULL
13522  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13523  {
13524  max_64 = g_base64_encode ((guchar *) max, strlen (max));
13525 
13526  if (gvm_connection_sendf (connection,
13527  "<modify_setting"
13528  " setting_id"
13529  "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">"
13530  "<value>%s</value>"
13531  "</modify_setting>",
13532  max_64 ? max_64 : "")
13533  == -1)
13534  {
13535  g_free (max_64);
13536  cmd_response_data_set_status_code (response_data,
13537  MHD_HTTP_INTERNAL_SERVER_ERROR);
13538  return gsad_message (
13539  credentials, "Internal error", __FUNCTION__, __LINE__,
13540  "An internal error occurred while saving settings. "
13541  "It is unclear whether all the settings were saved. "
13542  "Diagnostics: Failure to send command to manager daemon.",
13543  response_data);
13544  }
13545  g_free (max_64);
13546 
13547  entity = NULL;
13548  xml_string_append (xml, "<save_setting id=\"%s\">",
13549  "5f5a8712-8017-11e1-8556-406186ea4fc5");
13550  if (read_entity_and_string_c (connection, &entity, &xml))
13551  {
13552  g_string_free (xml, TRUE);
13553  cmd_response_data_set_status_code (response_data,
13554  MHD_HTTP_INTERNAL_SERVER_ERROR);
13555  return gsad_message (
13556  credentials, "Internal error", __FUNCTION__, __LINE__,
13557  "An internal error occurred while saving settings. "
13558  "It is unclear whether all the settings were saved. "
13559  "Diagnostics: Failure to receive response from manager daemon.",
13560  response_data);
13561  }
13562  xml_string_append (xml, "</save_setting>");
13563  if (gmp_success (entity) != 1)
13564  {
13565  set_http_status_from_entity (entity, response_data);
13566  modify_failed = 1;
13567  }
13568  }
13569 
13570  /* Send resource details export file name format. */
13571  changed_value = params_value (changed, "details_fname");
13572  if (changed_value == NULL
13573  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13574  {
13575  fname_64 =
13576  g_base64_encode ((guchar *) details_fname, strlen (details_fname));
13577 
13578  if (gvm_connection_sendf (connection,
13579  "<modify_setting"
13580  " setting_id"
13581  "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">"
13582  "<value>%s</value>"
13583  "</modify_setting>",
13584  fname_64 ? fname_64 : "")
13585  == -1)
13586  {
13587  g_free (fname_64);
13588  cmd_response_data_set_status_code (response_data,
13589  MHD_HTTP_INTERNAL_SERVER_ERROR);
13590  return gsad_message (
13591  credentials, "Internal error", __FUNCTION__, __LINE__,
13592  "An internal error occurred while saving settings. "
13593  "It is unclear whether all the settings were saved. "
13594  "Diagnostics: Failure to send command to manager daemon.",
13595  response_data);
13596  }
13597  g_free (fname_64);
13598 
13599  entity = NULL;
13600  xml_string_append (xml, "<save_setting id=\"%s\">",
13601  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
13602  if (read_entity_and_string_c (connection, &entity, &xml))
13603  {
13604  g_string_free (xml, TRUE);
13605  cmd_response_data_set_status_code (response_data,
13606  MHD_HTTP_INTERNAL_SERVER_ERROR);
13607  return gsad_message (
13608  credentials, "Internal error", __FUNCTION__, __LINE__,
13609  "An internal error occurred while saving settings. "
13610  "It is unclear whether all the settings were saved. "
13611  "Diagnostics: Failure to receive response from manager daemon.",
13612  response_data);
13613  }
13614  xml_string_append (xml, "</save_setting>");
13615  if (gmp_success (entity) != 1)
13616  {
13617  set_http_status_from_entity (entity, response_data);
13618  modify_failed = 1;
13619  }
13620  }
13621 
13622  /* Send resource list export file name format. */
13623  changed_value = params_value (changed, "list_fname");
13624  if (changed_value == NULL
13625  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13626  {
13627  fname_64 = g_base64_encode ((guchar *) list_fname, strlen (list_fname));
13628 
13629  if (gvm_connection_sendf (connection,
13630  "<modify_setting"
13631  " setting_id"
13632  "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">"
13633  "<value>%s</value>"
13634  "</modify_setting>",
13635  fname_64 ? fname_64 : "")
13636  == -1)
13637  {
13638  g_free (fname_64);
13639  cmd_response_data_set_status_code (response_data,
13640  MHD_HTTP_INTERNAL_SERVER_ERROR);
13641  return gsad_message (
13642  credentials, "Internal error", __FUNCTION__, __LINE__,
13643  "An internal error occurred while saving settings. "
13644  "It is unclear whether all the settings were saved. "
13645  "Diagnostics: Failure to send command to manager daemon.",
13646  response_data);
13647  }
13648  g_free (fname_64);
13649 
13650  entity = NULL;
13651  xml_string_append (xml, "<save_setting id=\"%s\">",
13652  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
13653  if (read_entity_and_string_c (connection, &entity, &xml))
13654  {
13655  g_string_free (xml, TRUE);
13656  cmd_response_data_set_status_code (response_data,
13657  MHD_HTTP_INTERNAL_SERVER_ERROR);
13658  return gsad_message (
13659  credentials, "Internal error", __FUNCTION__, __LINE__,
13660  "An internal error occurred while saving settings. "
13661  "It is unclear whether all the settings were saved. "
13662  "Diagnostics: Failure to receive response from manager daemon.",
13663  response_data);
13664  }
13665  xml_string_append (xml, "</save_setting>");
13666  if (gmp_success (entity) != 1)
13667  {
13668  set_http_status_from_entity (entity, response_data);
13669  modify_failed = 1;
13670  }
13671  }
13672 
13673  /* Send report export file name format. */
13674  changed_value = params_value (changed, "report_fname");
13675  if (changed_value == NULL
13676  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13677  {
13678  fname_64 =
13679  g_base64_encode ((guchar *) report_fname, strlen (report_fname));
13680 
13681  if (gvm_connection_sendf (connection,
13682  "<modify_setting"
13683  " setting_id"
13684  "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">"
13685  "<value>%s</value>"
13686  "</modify_setting>",
13687  fname_64 ? fname_64 : "")
13688  == -1)
13689  {
13690  g_free (fname_64);
13691  cmd_response_data_set_status_code (response_data,
13692  MHD_HTTP_INTERNAL_SERVER_ERROR);
13693  return gsad_message (
13694  credentials, "Internal error", __FUNCTION__, __LINE__,
13695  "An internal error occurred while saving settings. "
13696  "It is unclear whether all the settings were saved. "
13697  "Diagnostics: Failure to send command to manager daemon.",
13698  response_data);
13699  }
13700  g_free (fname_64);
13701 
13702  entity = NULL;
13703  xml_string_append (xml, "<save_setting id=\"%s\">",
13704  "e1a2ae0b-736e-4484-b029-330c9e15b900");
13705  if (read_entity_and_string_c (connection, &entity, &xml))
13706  {
13707  g_string_free (xml, TRUE);
13708  cmd_response_data_set_status_code (response_data,
13709  MHD_HTTP_INTERNAL_SERVER_ERROR);
13710  return gsad_message (
13711  credentials, "Internal error", __FUNCTION__, __LINE__,
13712  "An internal error occurred while saving settings. "
13713  "It is unclear whether all the settings were saved. "
13714  "Diagnostics: Failure to receive response from manager daemon.",
13715  response_data);
13716  }
13717  xml_string_append (xml, "</save_setting>");
13718  if (gmp_success (entity) != 1)
13719  {
13720  set_http_status_from_entity (entity, response_data);
13721  modify_failed = 1;
13722  }
13723  }
13724 
13725  /* Send User Interface Language. */
13726  changed_value = params_value (changed, "lang");
13727  if (changed_value == NULL
13728  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13729  {
13730  lang_64 = g_base64_encode ((guchar *) lang, strlen (lang));
13731 
13732  if (gvm_connection_sendf (connection,
13733  "<modify_setting"
13734  " setting_id"
13735  "=\"6765549a-934e-11e3-b358-406186ea4fc5\">"
13736  "<value>%s</value>"
13737  "</modify_setting>",
13738  lang_64 ? lang_64 : "")
13739  == -1)
13740  {
13741  g_free (lang_64);
13742  cmd_response_data_set_status_code (response_data,
13743  MHD_HTTP_INTERNAL_SERVER_ERROR);
13744  return gsad_message (
13745  credentials, "Internal error", __FUNCTION__, __LINE__,
13746  "An internal error occurred while saving settings. "
13747  "It is unclear whether all the settings were saved. "
13748  "Diagnostics: Failure to send command to manager daemon.",
13749  response_data);
13750  }
13751  g_free (lang_64);
13752 
13753  entity = NULL;
13754  xml_string_append (xml, "<save_setting id=\"%s\">",
13755  "6765549a-934e-11e3-b358-406186ea4fc5");
13756  if (read_entity_and_string_c (connection, &entity, &xml))
13757  {
13758  g_string_free (xml, TRUE);
13759  cmd_response_data_set_status_code (response_data,
13760  MHD_HTTP_INTERNAL_SERVER_ERROR);
13761  return gsad_message (
13762  credentials, "Internal error", __FUNCTION__, __LINE__,
13763  "An internal error occurred while saving settings. "
13764  "It is unclear whether all the settings were saved. "
13765  "Diagnostics: Failure to receive response from manager daemon.",
13766  response_data);
13767  }
13768  xml_string_append (xml, "</save_setting>");
13769  if (gmp_success (entity) == 1)
13770  {
13771  user_set_language (user, lang);
13772  user_changed = 1;
13773  }
13774  else
13775  {
13776  set_http_status_from_entity (entity, response_data);
13777  modify_failed = 1;
13778  }
13779  }
13780 
13781  /* Send default resources */
13782 
13783  defaults = params_values (params, "settings_default:");
13784  if (send_settings_filters (connection, defaults, changed, xml, &modify_failed,
13785  response_data))
13786  {
13787  cmd_response_data_set_status_code (response_data,
13788  MHD_HTTP_INTERNAL_SERVER_ERROR);
13789  return gsad_message (
13790  credentials, "Internal error", __FUNCTION__, __LINE__,
13791  "An internal error occurred while saving settings. "
13792  "It is unclear whether all the settings were saved. "
13793  "Diagnostics: Failure to send command to manager daemon.",
13794  response_data);
13795  }
13796 
13797  /* Send resources filters */
13798 
13799  filters = params_values (params, "settings_filter:");
13800  if (send_settings_filters (connection, filters, changed, xml, &modify_failed,
13801  response_data))
13802  {
13803  cmd_response_data_set_status_code (response_data,
13804  MHD_HTTP_INTERNAL_SERVER_ERROR);
13805  return gsad_message (
13806  credentials, "Internal error", __FUNCTION__, __LINE__,
13807  "An internal error occurred while saving settings. "
13808  "It is unclear whether all the settings were saved. "
13809  "Diagnostics: Failure to send command to manager daemon.",
13810  response_data);
13811  }
13812 
13813  /* Send Severity Class. */
13814 
13815  changed_value = params_value (changed, "severity_class");
13816  if (changed_value == NULL
13817  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13818  {
13819  text = params_value (params, "severity_class");
13820  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13821  : g_strdup (""));
13822 
13823  if (gvm_connection_sendf (connection,
13824  "<modify_setting"
13825  " setting_id"
13826  "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">"
13827  "<value>%s</value>"
13828  "</modify_setting>",
13829  text_64 ? text_64 : "")
13830  == -1)
13831  {
13832  g_free (text_64);
13833  cmd_response_data_set_status_code (response_data,
13834  MHD_HTTP_INTERNAL_SERVER_ERROR);
13835  return gsad_message (
13836  credentials, "Internal error", __FUNCTION__, __LINE__,
13837  "An internal error occurred while saving settings. "
13838  "It is unclear whether all the settings were saved. "
13839  "Diagnostics: Failure to send command to manager daemon.",
13840  response_data);
13841  }
13842  g_free (text_64);
13843 
13844  entity = NULL;
13845  xml_string_append (xml, "<save_setting id=\"%s\">",
13846  "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
13847  if (read_entity_and_string_c (connection, &entity, &xml))
13848  {
13849  g_string_free (xml, TRUE);
13850  cmd_response_data_set_status_code (response_data,
13851  MHD_HTTP_INTERNAL_SERVER_ERROR);
13852  return gsad_message (
13853  credentials, "Internal error", __FUNCTION__, __LINE__,
13854  "An internal error occurred while saving settings. "
13855  "It is unclear whether all the settings were saved. "
13856  "Diagnostics: Failure to receive response from manager daemon.",
13857  response_data);
13858  }
13859  xml_string_append (xml, "</save_setting>");
13860 
13861  if (gmp_success (entity) == 1)
13862  {
13863  if ((text != NULL) && (strlen (text) > 0))
13864  {
13865  user_set_severity (user, text);
13866  user_changed = 1;
13867  }
13868  }
13869  else
13870  {
13871  set_http_status_from_entity (entity, response_data);
13872  modify_failed = 1;
13873  }
13874  }
13875 
13876  /* Send Dynamic Severity setting. */
13877 
13878  changed_value = params_value (changed, "dynamic_severity");
13879  if (changed_value == NULL
13880  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13881  {
13882  text = params_value (params, "dynamic_severity");
13883  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13884  : g_strdup (""));
13885 
13886  if (gvm_connection_sendf (connection,
13887  "<modify_setting"
13888  " setting_id"
13889  "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">"
13890  "<value>%s</value>"
13891  "</modify_setting>",
13892  text_64 ? text_64 : "")
13893  == -1)
13894  {
13895  g_free (text_64);
13896  cmd_response_data_set_status_code (response_data,
13897  MHD_HTTP_INTERNAL_SERVER_ERROR);
13898  return gsad_message (
13899  credentials, "Internal error", __FUNCTION__, __LINE__,
13900  "An internal error occurred while saving settings. "
13901  "It is unclear whether all the settings were saved. "
13902  "Diagnostics: Failure to send command to manager daemon.",
13903  response_data);
13904  }
13905  g_free (text_64);
13906 
13907  entity = NULL;
13908  xml_string_append (xml, "<save_setting id=\"%s\">",
13909  "77ec2444-e7f2-4a80-a59b-f4237782d93f");
13910  if (read_entity_and_string_c (connection, &entity, &xml))
13911  {
13912  g_string_free (xml, TRUE);
13913  cmd_response_data_set_status_code (response_data,
13914  MHD_HTTP_INTERNAL_SERVER_ERROR);
13915  return gsad_message (
13916  credentials, "Internal error", __FUNCTION__, __LINE__,
13917  "An internal error occurred while saving settings. "
13918  "It is unclear whether all the settings were saved. "
13919  "Diagnostics: Failure to receive response from manager daemon.",
13920  response_data);
13921  }
13922  xml_string_append (xml, "</save_setting>");
13923  if (gmp_success (entity) != 1)
13924  {
13925  set_http_status_from_entity (entity, response_data);
13926  modify_failed = 1;
13927  }
13928  }
13929 
13930  /* Send Default Severity setting. */
13931  changed_value = params_value (changed, "default_severity");
13932  if (changed_value == NULL
13933  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13934  {
13935  text = params_value (params, "default_severity");
13936  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13937  : g_strdup (""));
13938 
13939  if (gvm_connection_sendf (connection,
13940  "<modify_setting"
13941  " setting_id"
13942  "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">"
13943  "<value>%s</value>"
13944  "</modify_setting>",
13945  text_64 ? text_64 : "")
13946  == -1)
13947  {
13948  g_free (text_64);
13949  cmd_response_data_set_status_code (response_data,
13950  MHD_HTTP_INTERNAL_SERVER_ERROR);
13951  return gsad_message (
13952  credentials, "Internal error", __FUNCTION__, __LINE__,
13953  "An internal error occurred while saving settings. "
13954  "It is unclear whether all the settings were saved. "
13955  "Diagnostics: Failure to send command to manager daemon.",
13956  response_data);
13957  }
13958  g_free (text_64);
13959 
13960  entity = NULL;
13961  xml_string_append (xml, "<save_setting id=\"%s\">",
13962  "7eda49c5-096c-4bef-b1ab-d080d87300df");
13963  if (read_entity_and_string_c (connection, &entity, &xml))
13964  {
13965  g_string_free (xml, TRUE);
13966  cmd_response_data_set_status_code (response_data,
13967  MHD_HTTP_INTERNAL_SERVER_ERROR);
13968  return gsad_message (
13969  credentials, "Internal error", __FUNCTION__, __LINE__,
13970  "An internal error occurred while saving settings. "
13971  "It is unclear whether all the settings were saved. "
13972  "Diagnostics: Failure to receive response from manager daemon.",
13973  response_data);
13974  }
13975  xml_string_append (xml, "</save_setting>");
13976  if (gmp_success (entity) != 1)
13977  {
13978  set_http_status_from_entity (entity, response_data);
13979  modify_failed = 1;
13980  }
13981  }
13982 
13983  /* Send Auto Cache Rebuild setting. */
13984 
13985  changed_value = params_value (changed, "auto_cache_rebuild");
13986  if (changed_value == NULL
13987  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
13988  {
13989  text = params_value (params, "auto_cache_rebuild");
13990  text_64 = (text ? g_base64_encode ((guchar *) text, strlen (text))
13991  : g_strdup (""));
13992 
13993  if (gvm_connection_sendf (connection,
13994  "<modify_setting"
13995  " setting_id"
13996  "=\"a09285b0-2d47-49b6-a4ef-946ee71f1d5c\">"
13997  "<value>%s</value>"
13998  "</modify_setting>",
13999  text_64 ? text_64 : "")
14000  == -1)
14001  {
14002  g_free (text_64);
14003  gvm_connection_close (connection);
14004  cmd_response_data_set_status_code (response_data,
14005  MHD_HTTP_INTERNAL_SERVER_ERROR);
14006  return gsad_message (
14007  credentials, "Internal error", __FUNCTION__, __LINE__,
14008  "An internal error occurred while saving settings. "
14009  "It is unclear whether all the settings were saved. "
14010  "Diagnostics: Failure to send command to manager daemon.",
14011  response_data);
14012  }
14013  g_free (text_64);
14014 
14015  entity = NULL;
14016  xml_string_append (xml, "<save_setting id=\"%s\">",
14017  "a09285b0-2d47-49b6-a4ef-946ee71f1d5c");
14018  if (read_entity_and_string_c (connection, &entity, &xml))
14019  {
14020  g_string_free (xml, TRUE);
14021  gvm_connection_close (connection);
14022  cmd_response_data_set_status_code (response_data,
14023  MHD_HTTP_INTERNAL_SERVER_ERROR);
14024  return gsad_message (
14025  credentials, "Internal error", __FUNCTION__, __LINE__,
14026  "An internal error occurred while saving settings. "
14027  "It is unclear whether all the settings were saved. "
14028  "Diagnostics: Failure to receive response from manager daemon.",
14029  response_data);
14030  }
14031  xml_string_append (xml, "</save_setting>");
14032  if (gmp_success (entity) != 1)
14033  {
14034  set_http_status_from_entity (entity, response_data);
14035  modify_failed = 1;
14036  }
14037  }
14038 
14039  if (user_changed)
14040  {
14042  }
14043 
14044  return envelope_gmp (connection, credentials, params,
14045  g_string_free (xml, FALSE), response_data);
14046 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:656
static int send_settings_filters(gvm_connection_t *connection, params_t *data, params_t *changed, GString *xml, int *modify_failed_flag, cmd_response_data_t *response_data)
Send settings resource filters.
Definition: gsad_gmp.c:13244
Structure of credential related information.
void user_set_severity(user_t *user, const gchar *severity)
Set severity class of user.
Definition: gsad_user.c:274
void user_set_password(user_t *user, const gchar *password)
Set password of user.
Definition: gsad_user.c:257
void user_set_language(user_t *user, const gchar *language)
Set language of user.
Definition: gsad_user.c:289
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
const gchar * user_get_username(user_t *user)
Definition: gsad_user.c:157
const gchar * user_get_token(user_t *user)
Definition: gsad_user.c:175
void session_add_user(const gchar *id, user_t *user)
Add user to the session "database".
Definition: gsad_session.c:147
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to GMP response entity.
Definition: gsad_gmp.c:677
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void user_set_timezone(user_t *user, const gchar *timezone)
Set timezone of user.
Definition: gsad_user.c:242
void session_remove_other_sessions(const gchar *id, user_t *user)
Removes all session of the user, except the one with the passed id.
Definition: gsad_session.c:181
User information structure, for sessions.
Definition: gsad_user.c:42
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
user_t * credentials_get_user(credentials_t *cred)
static char * envelope_gmp(gvm_connection_t *connection, credentials_t *credentials, params_t *params, gchar *xml, cmd_response_data_t *response_data)
Wrap some XML in an envelope.
Definition: gsad_gmp.c:443

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), credentials_get_user(), envelope_gmp(), gmp_success(), gsad_message(), params_t, params_value(), params_values(), send_settings_filters(), session_add_user(), session_remove_other_sessions(), set_http_status_from_entity(), user_get_token(), user_get_username(), user_set_language(), user_set_password(), user_set_severity(), and user_set_timezone().

Here is the call graph for this function:

◆ save_note_gmp()

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

Save note, get next page, envelope the result.

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

Definition at line 11088 of file gsad_gmp.c.

11090 {
11091  gchar *response;
11092  entity_t entity;
11093  const char *note_id, *text, *hosts, *port, *severity, *task_id;
11094  const char *result_id, *active, *days, *oid;
11095  char *ret;
11096 
11097  note_id = params_value (params, "note_id");
11098 
11099  oid = params_value (params, "oid");
11100 
11101  text = params_value (params, "text");
11102  if (text == NULL)
11103  params_given (params, "text") || (text = "");
11104 
11105  port = get_port_from_params (params);
11106  hosts = get_hosts_from_params (params);
11107  task_id = get_task_id_from_params (params);
11108  severity = get_severity_from_params (params);
11109  result_id = get_result_id_from_params (params);
11110 
11111  active = params_value (params, "active");
11112  days = params_value (params, "days");
11113 
11114  CHECK_VARIABLE_INVALID (oid, "Save Note");
11115  CHECK_VARIABLE_INVALID (active, "Save Note");
11116  CHECK_VARIABLE_INVALID (note_id, "Save Note");
11117  CHECK_VARIABLE_INVALID (days, "Save Note");
11118 
11119  response = NULL;
11120  entity = NULL;
11121  switch (gmpf (connection, credentials, &response, &entity, response_data,
11122  "<modify_note note_id=\"%s\">"
11123  "<active>%s</active>"
11124  "<hosts>%s</hosts>"
11125  "<port>%s</port>"
11126  "<severity>%s</severity>"
11127  "<text>%s</text>"
11128  "<task id=\"%s\"/>"
11129  "<result id=\"%s\"/>"
11130  "<nvt oid=\"%s\"/>"
11131  "</modify_note>",
11132  note_id, strcmp (active, "1") ? active : (days ? days : "-1"),
11133  hosts ? hosts : "", port ? port : "", severity ? severity : "",
11134  text ? text : "", task_id ? task_id : "",
11135  result_id ? result_id : "", oid))
11136  {
11137  case 0:
11138  case -1:
11139  break;
11140  case 1:
11141  cmd_response_data_set_status_code (response_data,
11142  MHD_HTTP_INTERNAL_SERVER_ERROR);
11143  return gsad_message (
11144  credentials, "Internal error", __FUNCTION__, __LINE__,
11145  "An internal error occurred while saving a note. "
11146  "The note remains the same. "
11147  "Diagnostics: Failure to send command to manager daemon.",
11148  response_data);
11149  case 2:
11150  cmd_response_data_set_status_code (response_data,
11151  MHD_HTTP_INTERNAL_SERVER_ERROR);
11152  return gsad_message (
11153  credentials, "Internal error", __FUNCTION__, __LINE__,
11154  "An internal error occurred while saving a note. "
11155  "It is unclear whether the note has been saved or not. "
11156  "Diagnostics: Failure to receive response from manager daemon.",
11157  response_data);
11158  default:
11159  cmd_response_data_set_status_code (response_data,
11160  MHD_HTTP_INTERNAL_SERVER_ERROR);
11161  return gsad_message (
11162  credentials, "Internal error", __FUNCTION__, __LINE__,
11163  "An internal error occurred while saving a note. "
11164  "It is unclear whether the note has been saved or not. "
11165  "Diagnostics: Internal Error.",
11166  response_data);
11167  }
11168 
11169  ret = response_from_entity (connection, credentials, params, entity,
11170  "Save Note", response_data);
11171 
11172  free_entity (entity);
11173  g_free (response);
11174  return ret;
11175 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
const char * get_port_from_params(params_t *params)
Get a port from request params.
Definition: gsad_gmp.c:10842
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
const char * get_severity_from_params(params_t *params)
Get severity from request params.
Definition: gsad_gmp.c:10923
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
Definition: gsad_gmp.c:10903
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
Definition: gsad_gmp.c:10868
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
Definition: gsad_gmp.c:10946

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

Here is the call graph for this function:

◆ save_override_gmp()

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

Save override, get next page, envelope the result.

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

Definition at line 11405 of file gsad_gmp.c.

11407 {
11408  gchar *response;
11409  entity_t entity;
11410  const char *override_id, *text, *hosts, *port;
11411  const char *severity, *custom_severity, *new_severity;
11412  const char *task_id, *result_id, *active, *days, *oid;
11413  char *ret;
11414 
11415  override_id = params_value (params, "override_id");
11416 
11417  port = get_port_from_params (params);
11418  hosts = get_hosts_from_params (params);
11419  task_id = get_task_id_from_params (params);
11420  severity = get_severity_from_params (params);
11421  result_id = get_result_id_from_params (params);
11422 
11423  text = params_value (params, "text");
11424  if (text == NULL)
11425  params_given (params, "text") || (text = "");
11426 
11427  custom_severity = params_value (params, "custom_severity");
11428  if (custom_severity && strcmp (custom_severity, "0") != 0)
11429  new_severity = params_value (params, "new_severity");
11430  else
11431  new_severity = params_value (params, "new_severity_from_list");
11432 
11433  active = params_value (params, "active");
11434  days = params_value (params, "days");
11435  oid = params_value (params, "oid");
11436 
11437  CHECK_VARIABLE_INVALID (active, "Save Override");
11438  CHECK_VARIABLE_INVALID (override_id, "Save Override");
11439  CHECK_VARIABLE_INVALID (new_severity, "Save Override");
11440  CHECK_VARIABLE_INVALID (days, "Save Override");
11441  CHECK_VARIABLE_INVALID (oid, "Save Override");
11442 
11443  response = NULL;
11444  entity = NULL;
11445  switch (gmpf (connection, credentials, &response, &entity, response_data,
11446  "<modify_override override_id=\"%s\">"
11447  "<active>%s</active>"
11448  "<nvt oid=\"%s\"/>"
11449  "<hosts>%s</hosts>"
11450  "<port>%s</port>"
11451  "<severity>%s</severity>"
11452  "<new_severity>%s</new_severity>"
11453  "<text>%s</text>"
11454  "<task id=\"%s\"/>"
11455  "<result id=\"%s\"/>"
11456  "</modify_override>",
11457  override_id,
11458  strcmp (active, "1") ? active : (days ? days : "-1"), oid,
11459  hosts ? hosts : "", port ? port : "", severity ? severity : "",
11460  new_severity, text ? text : "", task_id ? task_id : "",
11461  result_id ? result_id : ""))
11462  {
11463  case 0:
11464  case -1:
11465  break;
11466  case 1:
11467  cmd_response_data_set_status_code (response_data,
11468  MHD_HTTP_INTERNAL_SERVER_ERROR);
11469  return gsad_message (
11470  credentials, "Internal error", __FUNCTION__, __LINE__,
11471  "An internal error occurred while saving a override. "
11472  "The override remains the same. "
11473  "Diagnostics: Failure to send command to manager daemon.",
11474  response_data);
11475  case 2:
11476  cmd_response_data_set_status_code (response_data,
11477  MHD_HTTP_INTERNAL_SERVER_ERROR);
11478  return gsad_message (
11479  credentials, "Internal error", __FUNCTION__, __LINE__,
11480  "An internal error occurred while saving a override. "
11481  "It is unclear whether the override has been saved or not. "
11482  "Diagnostics: Failure to receive response from manager daemon.",
11483  response_data);
11484  default:
11485  cmd_response_data_set_status_code (response_data,
11486  MHD_HTTP_INTERNAL_SERVER_ERROR);
11487  return gsad_message (
11488  credentials, "Internal error", __FUNCTION__, __LINE__,
11489  "An internal error occurred while saving a override. "
11490  "It is unclear whether the override has been saved or not. "
11491  "Diagnostics: Internal Error.",
11492  response_data);
11493  }
11494 
11495  ret = response_from_entity (connection, credentials, params, entity,
11496  "Save Override", response_data);
11497 
11498  free_entity (entity);
11499  g_free (response);
11500  return ret;
11501 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
const char * get_port_from_params(params_t *params)
Get a port from request params.
Definition: gsad_gmp.c:10842
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
const char * get_severity_from_params(params_t *params)
Get severity from request params.
Definition: gsad_gmp.c:10923
const char * get_task_id_from_params(params_t *params)
Get task_id from request params.
Definition: gsad_gmp.c:10903
const char * get_hosts_from_params(params_t *params)
Get hosts from request params.
Definition: gsad_gmp.c:10868
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
const char * get_result_id_from_params(params_t *params)
Get result_id from request params.
Definition: gsad_gmp.c:10946

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

Here is the call graph for this function:

◆ save_permission_gmp()

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

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

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

Definition at line 15266 of file gsad_gmp.c.

15268 {
15269  gchar *html, *response;
15270  const char *permission_id, *name, *comment, *resource_id, *resource_type;
15271  const char *subject_id, *subject_type;
15272  entity_t entity;
15273  int ret;
15274 
15275  permission_id = params_value (params, "permission_id");
15276  name = params_value (params, "permission");
15277  comment = params_value (params, "comment");
15278  subject_type = params_value (params, "subject_type");
15279  resource_id = params_value (params, "id_or_empty");
15280  resource_type = params_value (params, "optional_resource_type");
15281 
15282  CHECK_VARIABLE_INVALID (permission_id, "Save Permission");
15283  CHECK_VARIABLE_INVALID (name, "Save Permission");
15284  CHECK_VARIABLE_INVALID (comment, "Save Permission");
15285  CHECK_VARIABLE_INVALID (resource_id, "Save Permission");
15286  CHECK_VARIABLE_INVALID (subject_type, "Save Permission");
15287  if (params_given (params, "optional_resource_type"))
15288  CHECK_VARIABLE_INVALID (resource_type, "Save Permission");
15289 
15290  if (strcmp (subject_type, "user") == 0)
15291  subject_id = params_value (params, "user_id");
15292  else if (strcmp (subject_type, "group") == 0)
15293  subject_id = params_value (params, "group_id");
15294  else if (strcmp (subject_type, "role") == 0)
15295  subject_id = params_value (params, "role_id");
15296  else
15297  subject_id = NULL;
15298  CHECK_VARIABLE_INVALID (subject_id, "Save Permission");
15299 
15300  /* Modify the permission. */
15301 
15302  response = NULL;
15303  entity = NULL;
15304  ret = gmpf (connection, credentials, &response, &entity, response_data,
15305  "<modify_permission permission_id=\"%s\">"
15306  "<name>%s</name>"
15307  "<comment>%s</comment>"
15308  "<subject id=\"%s\">"
15309  "<type>%s</type>"
15310  "</subject>"
15311  "<resource id=\"%s\">"
15312  "<type>%s</type>"
15313  "</resource>"
15314  "</modify_permission>",
15315  permission_id, name, comment, subject_id, subject_type,
15316  (resource_id && strlen (resource_id)) ? resource_id : "0",
15317  resource_type ? resource_type : "");
15318  switch (ret)
15319  {
15320  case 0:
15321  case -1:
15322  break;
15323  case 1:
15324  cmd_response_data_set_status_code (response_data,
15325  MHD_HTTP_INTERNAL_SERVER_ERROR);
15326  return gsad_message (
15327  credentials, "Internal error", __FUNCTION__, __LINE__,
15328  "An internal error occurred while modifying a permission. "
15329  "The permission was not modified. "
15330  "Diagnostics: Failure to send command to manager daemon.",
15331  response_data);
15332  case 2:
15333  cmd_response_data_set_status_code (response_data,
15334  MHD_HTTP_INTERNAL_SERVER_ERROR);
15335  return gsad_message (
15336  credentials, "Internal error", __FUNCTION__, __LINE__,
15337  "An internal error occurred while modifying a permission. "
15338  "It is unclear whether the permission has been modified or not. "
15339  "Diagnostics: Failure to receive response from manager daemon.",
15340  response_data);
15341  default:
15342  cmd_response_data_set_status_code (response_data,
15343  MHD_HTTP_INTERNAL_SERVER_ERROR);
15344  return gsad_message (
15345  credentials, "Internal error", __FUNCTION__, __LINE__,
15346  "An internal error occurred while modifying a permission. "
15347  "It is unclear whether the permission has been modified or not. "
15348  "Diagnostics: Internal Error.",
15349  response_data);
15350  }
15351 
15352  html = response_from_entity (connection, credentials, params, entity,
15353  "Save Permission", response_data);
15354  free_entity (entity);
15355  g_free (response);
15356  return html;
15357 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_port_list_gmp()

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

Modify a port list, get all port list, envelope the result.

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

Definition at line 15610 of file gsad_gmp.c.

15612 {
15613  int ret;
15614  gchar *html, *response;
15615  const char *port_list_id, *name, *comment;
15616  entity_t entity;
15617 
15618  port_list_id = params_value (params, "port_list_id");
15619  name = params_value (params, "name");
15620  comment = params_value (params, "comment");
15621 
15622  CHECK_VARIABLE_INVALID (port_list_id, "Save Port List");
15623  CHECK_VARIABLE_INVALID (name, "Save Port List");
15624  CHECK_VARIABLE_INVALID (comment, "Save Port List");
15625 
15626  /* Modify the Port List. */
15627 
15628  response = NULL;
15629  entity = NULL;
15630  ret = gmpf (connection, credentials, &response, &entity, response_data,
15631  "<modify_port_list port_list_id=\"%s\">"
15632  "<name>%s</name>"
15633  "<comment>%s</comment>"
15634  "</modify_port_list>",
15635  port_list_id, name, comment);
15636 
15637  switch (ret)
15638  {
15639  case 0:
15640  case -1:
15641  break;
15642  case 1:
15643  cmd_response_data_set_status_code (response_data,
15644  MHD_HTTP_INTERNAL_SERVER_ERROR);
15645  return gsad_message (
15646  credentials, "Internal error", __FUNCTION__, __LINE__,
15647  "An internal error occurred while saving a Port List. "
15648  "The Port List was not saved. "
15649  "Diagnostics: Failure to send command to manager daemon.",
15650  response_data);
15651  case 2:
15652  cmd_response_data_set_status_code (response_data,
15653  MHD_HTTP_INTERNAL_SERVER_ERROR);
15654  return gsad_message (
15655  credentials, "Internal error", __FUNCTION__, __LINE__,
15656  "An internal error occurred while saving a Port List. "
15657  "It is unclear whether the Port List has been saved or not. "
15658  "Diagnostics: Failure to receive response from manager daemon.",
15659  response_data);
15660  default:
15661  cmd_response_data_set_status_code (response_data,
15662  MHD_HTTP_INTERNAL_SERVER_ERROR);
15663  return gsad_message (
15664  credentials, "Internal error", __FUNCTION__, __LINE__,
15665  "An internal error occurred while saving a Port List. "
15666  "It is unclear whether the Port List has been saved or not. "
15667  "Diagnostics: Internal Error.",
15668  response_data);
15669  }
15670 
15671  html = response_from_entity (connection, credentials, params, entity,
15672  "Save Port List", response_data);
15673  free_entity (entity);
15674  g_free (response);
15675  return html;
15676 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_report_format_gmp()

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

Save report_format, get next page, envelope the result.

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

Definition at line 12661 of file gsad_gmp.c.

12664 {
12665  int ret;
12666  gchar *html, *response;
12667  params_t *preferences, *id_list_params, *include_id_lists;
12668  const char *report_format_id, *name, *summary, *enable;
12669  entity_t entity;
12670 
12671  report_format_id = params_value (params, "report_format_id");
12672  name = params_value (params, "name");
12673  summary = params_value (params, "summary");
12674  enable = params_value (params, "enable");
12675 
12676  CHECK_VARIABLE_INVALID (report_format_id, "Save Report Format");
12677  CHECK_VARIABLE_INVALID (name, "Save Report Format");
12678  CHECK_VARIABLE_INVALID (summary, "Save Report Format");
12679  CHECK_VARIABLE_INVALID (enable, "Save Report Format");
12680 
12681  id_list_params = params_values (params, "id_list:");
12682  include_id_lists = params_values (params, "include_id_list:");
12683  if (include_id_lists)
12684  {
12685  GHashTable *id_lists;
12686  param_t *param;
12687  gchar *param_name, *pref_name, *value, *old_values, *new_values;
12688  params_iterator_t iter;
12689  GHashTableIter hash_table_iter;
12690 
12691  id_lists =
12692  g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
12693 
12694  params_iterator_init (&iter, include_id_lists);
12695  while (params_iterator_next (&iter, &param_name, &param))
12696  {
12697  if (param->value == NULL)
12698  continue;
12699 
12700  g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (""));
12701  }
12702 
12703  params_iterator_init (&iter, id_list_params);
12704  while (params_iterator_next (&iter, &param_name, &param))
12705  {
12706  if (param->value == NULL)
12707  continue;
12708 
12709  gchar *colon_pos = strchr (param->value, ':');
12710 
12711  pref_name = g_strndup (param->value, colon_pos - param->value);
12712  value = g_strdup (colon_pos + 1);
12713 
12714  old_values = g_hash_table_lookup (id_lists, pref_name);
12715 
12716  if (old_values && strcmp (old_values, ""))
12717  {
12718  new_values = g_strdup_printf ("%s,%s", old_values, value);
12719  g_hash_table_insert (id_lists, pref_name, new_values);
12720  g_free (value);
12721  }
12722  else if (old_values)
12723  {
12724  g_hash_table_insert (id_lists, pref_name, value);
12725  }
12726  }
12727 
12728  g_hash_table_iter_init (&hash_table_iter, id_lists);
12729  while (g_hash_table_iter_next (&hash_table_iter, (void **) &pref_name,
12730  (void **) &value))
12731  {
12732  gchar *value_64;
12733 
12734  value_64 = strlen (value)
12735  ? g_base64_encode ((guchar *) value, strlen (value))
12736  : g_strdup ("");
12737 
12738  response = NULL;
12739  entity = NULL;
12740  ret =
12741  gmpf (connection, credentials, &response, &entity, response_data,
12742  "<modify_report_format"
12743  " report_format_id=\"%s\">"
12744  "<param>"
12745  "<name>%s</name>"
12746  "<value>%s</value>"
12747  "</param>"
12748  "</modify_report_format>",
12749  report_format_id, pref_name, value_64);
12750  g_free (value_64);
12751  switch (ret)
12752  {
12753  case 0:
12754  break;
12755  case 1:
12757  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12758  return gsad_message (
12759  credentials, "Internal error", __FUNCTION__, __LINE__,
12760  "An internal error occurred while saving a Report Format. "
12761  "The Report Format was not saved. "
12762  "Diagnostics: Failure to send command to manager daemon.",
12763  response_data);
12764  case 2:
12766  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12767  return gsad_message (
12768  credentials, "Internal error", __FUNCTION__, __LINE__,
12769  "An internal error occurred while saving a Report Format. "
12770  "It is unclear whether the Report Format has been saved or "
12771  "not. "
12772  "Diagnostics: Failure to receive response from manager daemon.",
12773  response_data);
12774  case -1:
12775  default:
12777  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12778  return gsad_message (
12779  credentials, "Internal error", __FUNCTION__, __LINE__,
12780  "An internal error occurred while saving a Report Format. "
12781  "It is unclear whether the Report Format has been saved or "
12782  "not. "
12783  "Diagnostics: Internal Error.",
12784  response_data);
12785  }
12786 
12787  /* TODO Check if succeeded. response_from_entity_if_failed? */
12788  }
12789  }
12790 
12791  /* Modify the Report Format. */
12792 
12793  preferences = params_values (params, "preference:");
12794  if (preferences)
12795  {
12796  param_t *param;
12797  gchar *param_name;
12798  params_iterator_t iter;
12799 
12800  /* The naming is a bit subtle here, because the HTTP request
12801  * parameters are called "param"s and so are the GMP report format
12802  * parameters. */
12803 
12804  params_iterator_init (&iter, preferences);
12805  while (params_iterator_next (&iter, &param_name, &param))
12806  {
12807  int type_start, type_end, count;
12808  /* LDAPsearch[entry]:Timeout value */
12809  count =
12810  sscanf (param_name, "%*[^[][%n%*[^]]%n]:", &type_start, &type_end);
12811  if (count == 0 && type_start > 0 && type_end > 0)
12812  {
12813  gchar *value;
12814 
12815  value =
12816  param->value_size
12817  ? g_base64_encode ((guchar *) param->value, param->value_size)
12818  : g_strdup ("");
12819 
12820  response = NULL;
12821  entity = NULL;
12822  ret = gmpf (connection, credentials, &response, &entity,
12823  response_data,
12824  "<modify_report_format"
12825  " report_format_id=\"%s\">"
12826  "<param>"
12827  "<name>%s</name>"
12828  "<value>%s</value>"
12829  "</param>"
12830  "</modify_report_format>",
12831  report_format_id, param_name + type_end + 2, value);
12832  g_free (value);
12833  switch (ret)
12834  {
12835  case 0:
12836  break;
12837  case 1:
12839  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12840  return gsad_message (
12841  credentials, "Internal error", __FUNCTION__, __LINE__,
12842  "An internal error occurred while saving a Report Format. "
12843  "The Report Format was not saved. "
12844  "Diagnostics: Failure to send command to manager daemon.",
12845  response_data);
12846  case 2:
12848  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12849  return gsad_message (
12850  credentials, "Internal error", __FUNCTION__, __LINE__,
12851  "An internal error occurred while saving a Report Format. "
12852  "It is unclear whether the Report Format has been saved or "
12853  "not. "
12854  "Diagnostics: Failure to receive response from manager "
12855  "daemon.",
12856  response_data);
12857  case -1:
12858  default:
12860  response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
12861  return gsad_message (
12862  credentials, "Internal error", __FUNCTION__, __LINE__,
12863  "An internal error occurred while saving a Report Format. "
12864  "It is unclear whether the Report Format has been saved or "
12865  "not. "
12866  "Diagnostics: Internal Error.",
12867  response_data);
12868  }
12869 
12870  /* TODO Check if succeeded. response_from_entity_if_failed? */
12871  }
12872  }
12873  }
12874 
12875  response = NULL;
12876  entity = NULL;
12877  ret = gmpf (connection, credentials, &response, &entity, response_data,
12878  "<modify_report_format"
12879  " report_format_id=\"%s\">"
12880  "<name>%s</name>"
12881  "<summary>%s</summary>"
12882  "<active>%s</active>"
12883  "</modify_report_format>",
12884  report_format_id, name, summary, enable);
12885 
12886  switch (ret)
12887  {
12888  case 0:
12889  break;
12890  case -1:
12891  return response;
12892  case 1:
12893  cmd_response_data_set_status_code (response_data,
12894  MHD_HTTP_INTERNAL_SERVER_ERROR);
12895  return gsad_message (
12896  credentials, "Internal error", __FUNCTION__, __LINE__,
12897  "An internal error occurred while saving a Report Format. "
12898  "The Report Format was not saved. "
12899  "Diagnostics: Failure to send command to manager daemon.",
12900  response_data);
12901  case 2:
12902  cmd_response_data_set_status_code (response_data,
12903  MHD_HTTP_INTERNAL_SERVER_ERROR);
12904  return gsad_message (
12905  credentials, "Internal error", __FUNCTION__, __LINE__,
12906  "An internal error occurred while saving a Report Format. "
12907  "It is unclear whether the Report Format has been saved or not. "
12908  "Diagnostics: Failure to receive response from manager daemon.",
12909  response_data);
12910  default:
12911  cmd_response_data_set_status_code (response_data,
12912  MHD_HTTP_INTERNAL_SERVER_ERROR);
12913  return gsad_message (
12914  credentials, "Internal error", __FUNCTION__, __LINE__,
12915  "An internal error occurred while saving a Report Format. "
12916  "It is unclear whether the Report Format has been saved or not. "
12917  "Diagnostics: Internal Error.",
12918  response_data);
12919  }
12920 
12921  html = response_from_entity (connection, credentials, params, entity,
12922  "Save Report Format", response_data);
12923  free_entity (entity);
12924  g_free (response);
12925  return html;
12926 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int value_size
Definition: gsad_params.h:46
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_role_gmp()

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

Modify a role, return the next page.

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

Definition at line 16147 of file gsad_gmp.c.

16149 {
16150  int ret;
16151  gchar *html, *response;
16152  const char *role_id, *name, *comment, *users;
16153  entity_t entity;
16154 
16155  role_id = params_value (params, "role_id");
16156  name = params_value (params, "name");
16157  comment = params_value (params, "comment");
16158  users = params_value (params, "users");
16159 
16160  CHECK_VARIABLE_INVALID (role_id, "Save Role");
16161  CHECK_VARIABLE_INVALID (name, "Save Role");
16162  CHECK_VARIABLE_INVALID (comment, "Save Role");
16163  CHECK_VARIABLE_INVALID (users, "Save Role");
16164 
16165  /* Modify the Role. */
16166 
16167  response = NULL;
16168  entity = NULL;
16169  ret = gmpf (connection, credentials, &response, &entity, response_data,
16170  "<modify_role role_id=\"%s\">"
16171  "<name>%s</name>"
16172  "<comment>%s</comment>"
16173  "<users>%s</users>"
16174  "</modify_role>",
16175  role_id, name, comment, users);
16176 
16177  switch (ret)
16178  {
16179  case 0:
16180  case -1:
16181  break;
16182  case 1:
16183  cmd_response_data_set_status_code (response_data,
16184  MHD_HTTP_INTERNAL_SERVER_ERROR);
16185  return gsad_message (
16186  credentials, "Internal error", __FUNCTION__, __LINE__,
16187  "An internal error occurred while saving a role. "
16188  "The role was not saved. "
16189  "Diagnostics: Failure to send command to manager daemon.",
16190  response_data);
16191  case 2:
16192  cmd_response_data_set_status_code (response_data,
16193  MHD_HTTP_INTERNAL_SERVER_ERROR);
16194  return gsad_message (
16195  credentials, "Internal error", __FUNCTION__, __LINE__,
16196  "An internal error occurred while saving a role. "
16197  "It is unclear whether the role has been saved or not. "
16198  "Diagnostics: Failure to receive response from manager daemon.",
16199  response_data);
16200  default:
16201  cmd_response_data_set_status_code (response_data,
16202  MHD_HTTP_INTERNAL_SERVER_ERROR);
16203  return gsad_message (
16204  credentials, "Internal error", __FUNCTION__, __LINE__,
16205  "An internal error occurred while saving a role. "
16206  "It is unclear whether the role has been saved or not. "
16207  "Diagnostics: Internal Error.",
16208  response_data);
16209  }
16210 
16211  html = response_from_entity (connection, credentials, params, entity,
16212  "Save Role", response_data);
16213  free_entity (entity);
16214  g_free (response);
16215  return html;
16216 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
GPtrArray * users
User session data.
Definition: gsad_session.c:39
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_scanner_gmp()

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

Save scanner, get next page, envelope the result.

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

Definition at line 11806 of file gsad_gmp.c.

11808 {
11809  gchar *response = NULL;
11810  entity_t entity = NULL;
11811  const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
11812  const char *credential_id, *which_cert;
11813  char *html;
11814  int ret, is_unix_socket, in_use;
11815 
11816  scanner_id = params_value (params, "scanner_id");
11817  name = params_value (params, "name");
11818  comment = params_value (params, "comment");
11819  host = params_value (params, "scanner_host");
11820  is_unix_socket = (host && *host == '/') ? 1 : 0;
11821  port = params_value (params, "port");
11822  type = params_value (params, "scanner_type");
11823  which_cert = params_value (params, "which_cert");
11824  ca_pub = params_value (params, "ca_pub");
11825  credential_id = params_value (params, "credential_id");
11826  CHECK_VARIABLE_INVALID (scanner_id, "Edit Scanner");
11827  CHECK_VARIABLE_INVALID (name, "Edit Scanner");
11828  if (params_given (params, "scanner_host") == 0)
11829  in_use = 1;
11830  else
11831  {
11832  in_use = 0;
11833  CHECK_VARIABLE_INVALID (host, "Edit Scanner");
11834  CHECK_VARIABLE_INVALID (port, "Edit Scanner");
11835  CHECK_VARIABLE_INVALID (type, "Edit Scanner");
11836  }
11837  if (is_unix_socket == 0)
11838  {
11839  CHECK_VARIABLE_INVALID (ca_pub, "Edit Scanner");
11840  CHECK_VARIABLE_INVALID (credential_id, "Edit Scanner");
11841  CHECK_VARIABLE_INVALID (which_cert, "Edit Scanner");
11842  }
11843 
11844  if (is_unix_socket)
11845  {
11846  ret = gmpf (connection, credentials, &response, &entity, response_data,
11847  "<modify_scanner scanner_id=\"%s\">"
11848  "<name>%s</name>"
11849  "<comment>%s</comment>"
11850  "</modify_scanner>",
11851  scanner_id, name, comment ?: "");
11852  }
11853  else if (strcmp (which_cert, "new") == 0
11854  || strcmp (which_cert, "default") == 0)
11855  {
11856  if (ca_pub == NULL)
11857  ca_pub = "";
11858  if (in_use)
11859  ret =
11860  gmpf (connection, credentials, &response, &entity, response_data,
11861  "<modify_scanner scanner_id=\"%s\">"
11862  "<name>%s</name>"
11863  "<comment>%s</comment>"
11864  "<ca_pub>%s</ca_pub>"
11865  "<credential id=\"%s\"/>"
11866  "</modify_scanner>",
11867  scanner_id, name, comment ?: "",
11868  strcmp (which_cert, "new") == 0 ? ca_pub : "", credential_id);
11869  else
11870  ret =
11871  gmpf (connection, credentials, &response, &entity, response_data,
11872  "<modify_scanner scanner_id=\"%s\">"
11873  "<name>%s</name>"
11874  "<comment>%s</comment>"
11875  "<host>%s</host>"
11876  "<port>%s</port>"
11877  "<type>%s</type>"
11878  "<ca_pub>%s</ca_pub>"
11879  "<credential id=\"%s\"/>"
11880  "</modify_scanner>",
11881  scanner_id, name, comment ?: "", host, port, type,
11882  strcmp (which_cert, "new") == 0 ? ca_pub : "", credential_id);
11883  }
11884  else
11885  {
11886  /* Using existing CA cert. */
11887  if (in_use)
11888  ret = gmpf (connection, credentials, &response, &entity, response_data,
11889  "<modify_scanner scanner_id=\"%s\">"
11890  "<name>%s</name>"
11891  "<comment>%s</comment>"
11892  "<credential id=\"%s\"/>"
11893  "</modify_scanner>",
11894  scanner_id, name, comment ?: "", credential_id);
11895  else
11896  ret = gmpf (connection, credentials, &response, &entity, response_data,
11897  "<modify_scanner scanner_id=\"%s\">"
11898  "<name>%s</name>"
11899  "<comment>%s</comment>"
11900  "<host>%s</host>"
11901  "<port>%s</port>"
11902  "<type>%s</type>"
11903  "<credential id=\"%s\"/>"
11904  "</modify_scanner>",
11905  scanner_id, name, comment ?: "", host, port, type,
11906  credential_id);
11907  }
11908 
11909  switch (ret)
11910  {
11911  case 0:
11912  case -1:
11913  break;
11914  case 1:
11915  cmd_response_data_set_status_code (response_data,
11916  MHD_HTTP_INTERNAL_SERVER_ERROR);
11917  return gsad_message (
11918  credentials, "Internal error", __FUNCTION__, __LINE__,
11919  "An internal error occurred while saving a scanner. "
11920  "The scanner remains the same. "
11921  "Diagnostics: Failure to send command to manager daemon.",
11922  response_data);
11923  case 2:
11924  cmd_response_data_set_status_code (response_data,
11925  MHD_HTTP_INTERNAL_SERVER_ERROR);
11926  return gsad_message (
11927  credentials, "Internal error", __FUNCTION__, __LINE__,
11928  "An internal error occurred while saving a scanner. "
11929  "It is unclear whether the scanner has been saved or not. "
11930  "Diagnostics: Failure to receive response from manager daemon.",
11931  response_data);
11932  default:
11933  cmd_response_data_set_status_code (response_data,
11934  MHD_HTTP_INTERNAL_SERVER_ERROR);
11935  return gsad_message (
11936  credentials, "Internal error", __FUNCTION__, __LINE__,
11937  "An internal error occurred while saving a scanner. "
11938  "It is unclear whether the scanner has been saved or not. "
11939  "Diagnostics: Internal Error.",
11940  response_data);
11941  }
11942 
11943  html = response_from_entity (connection, credentials, params, entity,
11944  "Save Scanner", response_data);
11945 
11946  free_entity (entity);
11947  g_free (response);
11948  return html;
11949 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
gboolean is_unix_socket()
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_schedule_gmp()

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

Save schedule, get next page, envelope the result.

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

Definition at line 16759 of file gsad_gmp.c.

16761 {
16762  gchar *response;
16763  entity_t entity;
16764  const char *schedule_id, *name, *comment, *timezone, *icalendar;
16765  char *ret;
16766 
16767  schedule_id = params_value (params, "schedule_id");
16768  name = params_value (params, "name");
16769  comment = params_value (params, "comment");
16770  icalendar = params_value (params, "icalendar");
16771  timezone = params_value (params, "timezone");
16772 
16773  CHECK_VARIABLE_INVALID (schedule_id, "Save Schedule");
16774  CHECK_VARIABLE_INVALID (name, "Save Schedule");
16775  CHECK_VARIABLE_INVALID (comment, "Save Schedule");
16776  CHECK_VARIABLE_INVALID (icalendar, "Save Schedule");
16777  CHECK_VARIABLE_INVALID (timezone, "Save Schedule");
16778 
16779  response = NULL;
16780  entity = NULL;
16781  switch (gmpf (connection, credentials, &response, &entity, response_data,
16782  "<modify_schedule schedule_id=\"%s\">"
16783  "<name>%s</name>"
16784  "<comment>%s</comment>"
16785  "<timezone>%s</timezone>"
16786  "<icalendar>%s</icalendar>"
16787  "</modify_schedule>",
16788  schedule_id, name ? name : "", comment ? comment : "", timezone,
16789  icalendar))
16790  {
16791  case 0:
16792  case -1:
16793  break;
16794  case 1:
16795  cmd_response_data_set_status_code (response_data,
16796  MHD_HTTP_INTERNAL_SERVER_ERROR);
16797  return gsad_message (
16798  credentials, "Internal error", __FUNCTION__, __LINE__,
16799  "An internal error occurred while saving a schedule. "
16800  "The schedule remains the same. "
16801  "Diagnostics: Failure to send command to manager daemon.",
16802  response_data);
16803  case 2:
16804  cmd_response_data_set_status_code (response_data,
16805  MHD_HTTP_INTERNAL_SERVER_ERROR);
16806  return gsad_message (
16807  credentials, "Internal error", __FUNCTION__, __LINE__,
16808  "An internal error occurred while saving a schedule. "
16809  "It is unclear whether the schedule has been saved or not. "
16810  "Diagnostics: Failure to receive response from manager daemon.",
16811  response_data);
16812  default:
16813  cmd_response_data_set_status_code (response_data,
16814  MHD_HTTP_INTERNAL_SERVER_ERROR);
16815  return gsad_message (
16816  credentials, "Internal error", __FUNCTION__, __LINE__,
16817  "An internal error occurred while saving a schedule. "
16818  "It is unclear whether the schedule has been saved or not. "
16819  "Diagnostics: Internal Error.",
16820  response_data);
16821  }
16822 
16823  ret = response_from_entity (connection, credentials, params, entity,
16824  "Save Schedule", response_data);
16825  free_entity (entity);
16826  g_free (response);
16827  return ret;
16828 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_setting_gmp()

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

Save user setting.

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

Definition at line 17872 of file gsad_gmp.c.

17874 {
17875  const gchar *setting_id = params_value (params, "setting_id");
17876  const gchar *setting_value = params_value (params, "setting_value");
17877  const gchar *setting_name = NULL;
17878 
17879  CHECK_VARIABLE_INVALID (setting_id, "Save Setting");
17880  CHECK_VARIABLE_INVALID (setting_value, "Save Setting");
17881 
17882  if (params_given (params, "setting_name"))
17883  {
17884  setting_name = params_value (params, "setting_name");
17885  CHECK_VARIABLE_INVALID (setting_name, "Save Settings")
17886  }
17887 
17888  gchar *value_64 =
17889  g_base64_encode ((guchar *) setting_value, strlen (setting_value));
17890  gchar *html;
17891  gchar *response = NULL;
17892  entity_t entity = NULL;
17893  int ret;
17894  GString *xml = g_string_new ("");
17895 
17896  xml_string_append (xml,
17897  "<modify_setting setting_id=\"%s\">"
17898  "<value>%s</value>",
17899  setting_id, value_64);
17900 
17901  if (setting_name)
17902  {
17903  xml_string_append (xml, "<name>%s</name>", setting_name);
17904  }
17905 
17906  xml_string_append (xml, "</modify_setting>");
17907 
17909 
17910  ret =
17911  gmp (connection, credentials, &response, &entity, response_data, xml->str);
17912 
17913  g_free (value_64);
17914  g_string_free (xml, TRUE);
17915 
17916  switch (ret)
17917  {
17918  case 0:
17919  case -1:
17920  break;
17921  case 1:
17922  cmd_response_data_set_status_code (response_data,
17923  MHD_HTTP_INTERNAL_SERVER_ERROR);
17924  return gsad_message (
17925  credentials, "Internal error", __FUNCTION__, __LINE__,
17926  "An internal error occurred while saving settings. "
17927  "It is unclear whether all the settings were saved. "
17928  "Diagnostics: Failure to send command to manager daemon.",
17929  response_data);
17930  case 2:
17931 
17932  cmd_response_data_set_status_code (response_data,
17933  MHD_HTTP_INTERNAL_SERVER_ERROR);
17934  return gsad_message (
17935  credentials, "Internal error", __FUNCTION__, __LINE__,
17936  "An internal error occurred while saving settings. "
17937  "It is unclear whether all the settings were saved. "
17938  "Diagnostics: Failure to receive response from manager daemon.",
17939  response_data);
17940  default:
17941 
17942  cmd_response_data_set_status_code (response_data,
17943  MHD_HTTP_INTERNAL_SERVER_ERROR);
17944  return gsad_message (credentials, "Internal error", __FUNCTION__,
17945  __LINE__,
17946  "An internal error occurred while saving settings. "
17947  "It is unclear whether all the settings were saved. "
17948  "Diagnostics: Internal Error.",
17949  response_data);
17950  }
17951  html = response_from_entity (connection, credentials, params, entity,
17952  "Save Setting", response_data);
17953  free_entity (entity);
17954  g_free (response);
17955  return html;
17956 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
void cmd_response_data_set_content_type(cmd_response_data_t *data, content_type_t content_type)
Set content type of cmd_response_data_t struct.
Definition: gsad_cmd.c:134
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_slave_gmp()

char* save_slave_gmp ( gvm_connection_t *  ,
credentials_t *  ,
params_t *  ,
cmd_response_data_t *   
)

◆ save_tag_gmp()

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

Modify a tag, get all tags, envelope the result.

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

Definition at line 7228 of file gsad_gmp.c.

7230 {
7231  gchar *response;
7232  const char *name, *comment, *filter, *value, *resource_type, *active;
7233  const char *resources_action;
7234  params_t *resource_ids;
7235  const char *tag_id;
7236  GString *command;
7237  entity_t entity;
7238  char *ret;
7239 
7240  tag_id = params_value (params, "tag_id");
7241  name = params_value (params, "tag_name");
7242  comment = params_value (params, "comment");
7243  filter = params_value (params, "filter");
7244  value = params_value (params, "tag_value");
7245  resource_type = params_value (params, "resource_type");
7246  resource_ids = params_values (params, "resource_ids:");
7247  resources_action = params_value (params, "resources_action");
7248  active = params_value (params, "active");
7249 
7250  CHECK_VARIABLE_INVALID (tag_id, "Save Tag")
7251  CHECK_VARIABLE_INVALID (name, "Save Tag")
7252  CHECK_VARIABLE_INVALID (comment, "Save Tag")
7253  if (params_given (params, "filter"))
7254  CHECK_VARIABLE_INVALID (filter, "Save Tag")
7255  CHECK_VARIABLE_INVALID (value, "Save Tag")
7256  if (params_given (params, "resources_action"))
7257  CHECK_VARIABLE_INVALID (resources_action, "Save Tag")
7258  CHECK_VARIABLE_INVALID (resource_type, "Save Tag")
7259  CHECK_VARIABLE_INVALID (active, "Save Tag")
7260 
7261  command = g_string_new ("");
7262 
7263  xml_string_append (command,
7264  "<modify_tag tag_id=\"%s\">"
7265  "<name>%s</name>"
7266  "<comment>%s</comment>"
7267  "<value>%s</value>"
7268  "<active>%s</active>"
7269  "<resources action=\"%s\" filter=\"%s\">"
7270  "<type>%s</type>",
7271  tag_id, name, comment, value, active,
7272  resources_action ? resources_action : "",
7273  filter ? filter : "", resource_type);
7274 
7275  if (resource_ids)
7276  {
7277  params_iterator_t iter;
7278  char *name;
7279  param_t *param;
7280 
7281  params_iterator_init (&iter, resource_ids);
7282  while (params_iterator_next (&iter, &name, &param))
7283  if (param->value && strcmp (param->value, "0"))
7284  g_string_append_printf (command, "<resource id=\"%s\"/>",
7285  param->value ? param->value : "");
7286  }
7287 
7288  xml_string_append (command, "</resources>"
7289  "</modify_tag>");
7290 
7291  response = NULL;
7292  entity = NULL;
7293  switch (gmp (connection, credentials, &response, &entity, response_data,
7294  command->str))
7295  {
7296  case 0:
7297  case -1:
7298  break;
7299  case 1:
7300  cmd_response_data_set_status_code (response_data,
7301  MHD_HTTP_INTERNAL_SERVER_ERROR);
7302  g_string_free (command, TRUE);
7303  return gsad_message (credentials, "Internal error", __FUNCTION__,
7304  __LINE__,
7305  "An internal error occurred while saving a tag. "
7306  "The tag remains the same. "
7307  "Diagnostics: Failure to send command to "
7308  "manager daemon.",
7309  response_data);
7310  case 2:
7311  cmd_response_data_set_status_code (response_data,
7312  MHD_HTTP_INTERNAL_SERVER_ERROR);
7313  g_string_free (command, TRUE);
7314  return gsad_message (credentials, "Internal error", __FUNCTION__,
7315  __LINE__,
7316  "An internal error occurred while saving a tag. "
7317  "It is unclear whether the tag has been saved "
7318  "or not. "
7319  "Diagnostics: Failure to receive response from "
7320  "manager daemon.",
7321  response_data);
7322  default:
7323  cmd_response_data_set_status_code (response_data,
7324  MHD_HTTP_INTERNAL_SERVER_ERROR);
7325  g_string_free (command, TRUE);
7326  return gsad_message (credentials, "Internal error", __FUNCTION__,
7327  __LINE__,
7328  "An internal error occurred while saving a tag. "
7329  "It is unclear whether the tag has been saved "
7330  "or not. "
7331  "Diagnostics: Internal Error.",
7332  response_data);
7333  }
7334 
7335  g_string_free (command, TRUE);
7336  ret = response_from_entity (connection, credentials, params, entity,
7337  "Save Tag", response_data);
7338 
7339  free_entity (entity);
7340  g_free (response);
7341  return ret;
7342 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_target_gmp()

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

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

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

Definition at line 7608 of file gsad_gmp.c.

7610 {
7611  gchar *html, *response;
7612  const char *name, *hosts, *exclude_hosts, *comment;
7613  const char *target_ssh_credential, *port, *target_smb_credential;
7614  const char *target_esxi_credential, *target_snmp_credential;
7615  const char *target_source, *target_exclude_source;
7616  const char *target_id, *port_list_id, *reverse_lookup_only;
7617  const char *reverse_lookup_unify, *alive_tests, *in_use;
7618  GString *command;
7619 
7620  alive_tests = params_value (params, "alive_tests");
7621  name = params_value (params, "name");
7622  comment = params_value (params, "comment");
7623  in_use = params_value (params, "in_use");
7624  target_id = params_value (params, "target_id");
7625 
7626  CHECK_VARIABLE_INVALID (name, "Save Target");
7627  CHECK_VARIABLE_INVALID (target_id, "Save Target");
7628  CHECK_VARIABLE_INVALID (comment, "Save Target");
7629  CHECK_VARIABLE_INVALID (alive_tests, "Save Target");
7630  CHECK_VARIABLE_INVALID (in_use, "Save Target");
7631 
7632  if (str_equal (in_use, "1"))
7633  {
7634  entity_t entity;
7635  int ret;
7636 
7637  /* Target is in use. Modify fewer fields. */
7638 
7639  command = g_string_new ("");
7640  xml_string_append (command,
7641  "<modify_target target_id=\"%s\">"
7642  "<name>%s</name>"
7643  "<comment>%s</comment>"
7644  "<alive_tests>%s</alive_tests>"
7645  "</modify_target>",
7646  target_id, name ? name : "", comment ? comment : "",
7647  alive_tests);
7648 
7649  response = NULL;
7650  entity = NULL;
7651  ret = gmp (connection, credentials, &response, &entity, response_data,
7652  command->str);
7653  g_string_free (command, TRUE);
7654  switch (ret)
7655  {
7656  case 0:
7657  case -1:
7658  break;
7659  case 1:
7660  cmd_response_data_set_status_code (response_data,
7661  MHD_HTTP_INTERNAL_SERVER_ERROR);
7662  return gsad_message (
7663  credentials, "Internal error", __FUNCTION__, __LINE__,
7664  "An internal error occurred while saving a target. "
7665  "The target remains the same. "
7666  "Diagnostics: Failure to send command to manager daemon.",
7667  response_data);
7668  case 2:
7669  cmd_response_data_set_status_code (response_data,
7670  MHD_HTTP_INTERNAL_SERVER_ERROR);
7671  return gsad_message (
7672  credentials, "Internal error", __FUNCTION__, __LINE__,
7673  "An internal error occurred while saving a target. "
7674  "It is unclear whether the target has been saved or not. "
7675  "Diagnostics: Failure to receive response from manager daemon.",
7676  response_data);
7677  default:
7678  cmd_response_data_set_status_code (response_data,
7679  MHD_HTTP_INTERNAL_SERVER_ERROR);
7680  return gsad_message (
7681  credentials, "Internal error", __FUNCTION__, __LINE__,
7682  "An internal error occurred while saving a target. "
7683  "It is unclear whether the target has been saved or not. "
7684  "Diagnostics: Internal Error.",
7685  response_data);
7686  }
7687 
7688  html = response_from_entity (connection, credentials, params, entity,
7689  "Save Target", response_data);
7690 
7691  free_entity (entity);
7692  g_free (response);
7693  return html;
7694  }
7695 
7696  hosts = params_value (params, "hosts");
7697  exclude_hosts = params_value (params, "exclude_hosts");
7698  reverse_lookup_only = params_value (params, "reverse_lookup_only");
7699  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
7700  target_source = params_value (params, "target_source");
7701  target_exclude_source = params_value (params, "target_exclude_source");
7702  port_list_id = params_value (params, "port_list_id");
7703  target_ssh_credential = params_value (params, "ssh_credential_id");
7704  port = params_value (params, "port");
7705  target_smb_credential = params_value (params, "smb_credential_id");
7706  target_esxi_credential = params_value (params, "esxi_credential_id");
7707  target_snmp_credential = params_value (params, "snmp_credential_id");
7708 
7709  CHECK_VARIABLE_INVALID (target_source, "Save Target");
7710  CHECK_VARIABLE_INVALID (target_exclude_source, "Save Target");
7711  CHECK_VARIABLE_INVALID (port_list_id, "Save Target");
7712  CHECK_VARIABLE_INVALID (target_ssh_credential, "Save Target");
7713  CHECK_VARIABLE_INVALID (target_smb_credential, "Save Target");
7714  CHECK_VARIABLE_INVALID (target_esxi_credential, "Save Target");
7715  CHECK_VARIABLE_INVALID (target_snmp_credential, "Save Target");
7716 
7717  if (strcmp (target_ssh_credential, "--")
7718  && strcmp (target_ssh_credential, "0"))
7719  CHECK_VARIABLE_INVALID (port, "Save Target");
7720 
7721  if (str_equal (target_source, "manual"))
7722  {
7723  CHECK_VARIABLE_INVALID (hosts, "Save Target")
7724  }
7725 
7726  {
7727  int ret;
7728  gchar *ssh_credentials_element, *smb_credentials_element;
7729  gchar *esxi_credentials_element, *snmp_credentials_element;
7730  gchar *comment_element;
7731  entity_t entity;
7732 
7733  if (comment)
7734  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
7735  else
7736  comment_element = g_strdup ("");
7737 
7738  if (str_equal (target_ssh_credential, "--"))
7739  ssh_credentials_element = g_strdup ("");
7740  else
7741  ssh_credentials_element = g_strdup_printf ("<ssh_credential id=\"%s\">"
7742  "<port>%s</port>"
7743  "</ssh_credential>",
7744  target_ssh_credential, port);
7745 
7746  if (str_equal (target_smb_credential, "--"))
7747  smb_credentials_element = g_strdup ("");
7748  else
7749  smb_credentials_element =
7750  g_strdup_printf ("<smb_credential id=\"%s\"/>", target_smb_credential);
7751 
7752  if (str_equal (target_esxi_credential, "--"))
7753  esxi_credentials_element = g_strdup ("");
7754  else
7755  esxi_credentials_element = g_strdup_printf (
7756  "<esxi_credential id=\"%s\"/>", target_esxi_credential);
7757 
7758  if (str_equal (target_snmp_credential, "--"))
7759  snmp_credentials_element = g_strdup ("");
7760  else
7761  snmp_credentials_element = g_strdup_printf (
7762  "<snmp_credential id=\"%s\"/>", target_snmp_credential);
7763 
7764  command = g_string_new ("");
7765  xml_string_append (
7766  command,
7767  "<modify_target target_id=\"%s\">"
7768  "<name>%s</name>"
7769  "<hosts>%s</hosts>"
7770  "<exclude_hosts>%s</exclude_hosts>"
7771  "<reverse_lookup_only>%s</reverse_lookup_only>"
7772  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
7773  "<port_list id=\"%s\"/>"
7774  "<alive_tests>%s</alive_tests>",
7775  target_id, name,
7776  str_equal (target_source, "file") ? params_value (params, "file") : hosts,
7777  str_equal (target_exclude_source, "file")
7778  ? params_value (params, "exclude_file")
7779  : exclude_hosts,
7780  reverse_lookup_only ? reverse_lookup_only : "0",
7781  reverse_lookup_unify ? reverse_lookup_unify : "0", port_list_id,
7782  alive_tests);
7783 
7784  g_string_append_printf (command,
7785  "%s%s%s%s%s"
7786  "</modify_target>",
7787  comment_element, ssh_credentials_element,
7788  smb_credentials_element, esxi_credentials_element,
7789  snmp_credentials_element);
7790 
7791  g_free (comment_element);
7792  g_free (ssh_credentials_element);
7793  g_free (smb_credentials_element);
7794  g_free (esxi_credentials_element);
7795  g_free (snmp_credentials_element);
7796 
7797  /* Modify the target. */
7798 
7799  ret = gvm_connection_sendf (connection, "%s", command->str);
7800  g_string_free (command, TRUE);
7801 
7802  if (ret == -1)
7803  {
7804  cmd_response_data_set_status_code (response_data,
7805  MHD_HTTP_INTERNAL_SERVER_ERROR);
7806  return gsad_message (
7807  credentials, "Internal error", __FUNCTION__, __LINE__,
7808  "An internal error occurred while modifying target. "
7809  "No target was modified. "
7810  "Diagnostics: Failure to send command to manager daemon.",
7811  response_data);
7812  }
7813 
7814  entity = NULL;
7815  if (read_entity_and_text_c (connection, &entity, &response))
7816  {
7817  cmd_response_data_set_status_code (response_data,
7818  MHD_HTTP_INTERNAL_SERVER_ERROR);
7819  return gsad_message (
7820  credentials, "Internal error", __FUNCTION__, __LINE__,
7821  "An internal error occurred while modifying a target. "
7822  "It is unclear whether the target has been modified or not. "
7823  "Diagnostics: Failure to receive response from manager daemon.",
7824  response_data);
7825  }
7826 
7827  html = response_from_entity (connection, credentials, params, entity,
7828  "Save Target", response_data);
7829  }
7830 
7831  /* Pass response to handler of following page. */
7832 
7833  return html;
7834 }
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_task_gmp()

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

Save task, get next page, envelope the result.

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

Definition at line 2828 of file gsad_gmp.c.

2830 {
2831  gchar *html, *response, *format;
2832  const char *comment, *name, *schedule_id, *in_assets;
2833  const char *scanner_id, *task_id, *max_checks, *max_hosts;
2834  const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
2835  const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
2836  const char *apply_overrides, *min_qod;
2837  int ret;
2838  params_t *alerts;
2839  GString *alert_element;
2840  entity_t entity;
2841 
2842  alterable = params_value (params, "alterable");
2843  apply_overrides = params_value (params, "apply_overrides");
2844  auto_delete = params_value (params, "auto_delete");
2845  auto_delete_data = params_value (params, "auto_delete_data");
2846  comment = params_value (params, "comment");
2847  config_id = params_value (params, "config_id");
2848  hosts_ordering = params_value (params, "hosts_ordering");
2849  in_assets = params_value (params, "in_assets");
2850  max_checks = params_value (params, "max_checks");
2851  max_hosts = params_value (params, "max_hosts");
2852  min_qod = params_value (params, "min_qod");
2853  name = params_value (params, "name");
2854  scanner_id = params_value (params, "scanner_id");
2855  scanner_type = params_value (params, "scanner_type");
2856  schedule_id = params_value (params, "schedule_id");
2857  schedule_periods = params_value (params, "schedule_periods");
2858  source_iface = params_value (params, "source_iface");
2859  target_id = params_value (params, "target_id");
2860  task_id = params_value (params, "task_id");
2861 
2862  if (scanner_type != NULL)
2863  {
2864  CHECK_VARIABLE_INVALID (scanner_type, "Save Task");
2865  if (!strcmp (scanner_type, "1"))
2866  {
2867  hosts_ordering = "";
2868  max_checks = "";
2869  source_iface = "";
2870  max_hosts = "";
2871  }
2872  else if (!strcmp (scanner_type, "3"))
2873  {
2874  config_id = "0";
2875  hosts_ordering = "";
2876  max_checks = "";
2877  source_iface = "";
2878  max_hosts = "";
2879  }
2880  }
2881 
2882  CHECK_VARIABLE_INVALID (name, "Save Task");
2883  CHECK_VARIABLE_INVALID (comment, "Save Task");
2884  CHECK_VARIABLE_INVALID (target_id, "Save Task");
2885  CHECK_VARIABLE_INVALID (hosts_ordering, "Save Task");
2886  CHECK_VARIABLE_INVALID (config_id, "Save Task");
2887  CHECK_VARIABLE_INVALID (schedule_id, "Save Task");
2888  if (params_given (params, "schedule_periods"))
2889  {
2890  CHECK_VARIABLE_INVALID (schedule_periods, "Save Task");
2891  }
2892  else
2893  schedule_periods = "0";
2894  CHECK_VARIABLE_INVALID (scanner_id, "Save Task");
2895  CHECK_VARIABLE_INVALID (task_id, "Save Task");
2896  CHECK_VARIABLE_INVALID (max_checks, "Save Task");
2897  CHECK_VARIABLE_INVALID (source_iface, "Save Task");
2898  CHECK_VARIABLE_INVALID (auto_delete, "Save Task");
2899  CHECK_VARIABLE_INVALID (auto_delete_data, "Save Task");
2900  CHECK_VARIABLE_INVALID (max_hosts, "Save Task");
2901  CHECK_VARIABLE_INVALID (in_assets, "Save Task");
2902 
2903  if (!strcmp (in_assets, "1"))
2904  {
2905  CHECK_VARIABLE_INVALID (apply_overrides, "Save Task");
2906  CHECK_VARIABLE_INVALID (min_qod, "Save Task");
2907  }
2908  else
2909  {
2910  if (!params_given (params, "apply_overrides")
2911  || !params_valid (params, "apply_overrides"))
2912  apply_overrides = "";
2913 
2914  if (!params_given (params, "min_qod")
2915  || !params_valid (params, "min_qod"))
2916  min_qod = "";
2917  }
2918 
2919  alert_element = g_string_new ("");
2920  if (params_given (params, "alert_id_optional:"))
2921  alerts = params_values (params, "alert_id_optional:");
2922  else
2923  alerts = params_values (params, "alert_ids:");
2924 
2925  if (alerts)
2926  {
2927  params_iterator_t iter;
2928  char *name;
2929  param_t *param;
2930 
2931  params_iterator_init (&iter, alerts);
2932  while (params_iterator_next (&iter, &name, &param))
2933  {
2934  if (param->value && strcmp (param->value, "0"))
2935  g_string_append_printf (alert_element, "<alert id=\"%s\"/>",
2936  param->value ? param->value : "");
2937  }
2938  }
2939 
2940  // Remove Alerts from Task if none are given.
2941  if (strcmp (alert_element->str, "") == 0)
2942  g_string_append_printf (alert_element, "<alert id=\"0\"/>");
2943 
2944  format = g_strdup_printf (
2945  "<modify_task task_id=\"%%s\">"
2946  "<name>%%s</name>"
2947  "<comment>%%s</comment>"
2948  "<hosts_ordering>%s</hosts_ordering>"
2949  "%s"
2950  "<target id=\"%%s\"/>"
2951  "<config id=\"%%s\"/>"
2952  "<schedule id=\"%%s\"/>"
2953  "<schedule_periods>%%s</schedule_periods>"
2954  "<scanner id=\"%%s\"/>"
2955  "<preferences>"
2956  "<preference>"
2957  "<scanner_name>max_checks</scanner_name>"
2958  "<value>%%s</value>"
2959  "</preference>"
2960  "<preference>"
2961  "<scanner_name>max_hosts</scanner_name>"
2962  "<value>%%s</value>"
2963  "</preference>"
2964  "<preference>"
2965  "<scanner_name>in_assets</scanner_name>"
2966  "<value>%%s</value>"
2967  "</preference>"
2968  "<preference>"
2969  "<scanner_name>assets_apply_overrides</scanner_name>"
2970  "<value>%%s</value>"
2971  "</preference>"
2972  "<preference>"
2973  "<scanner_name>assets_min_qod</scanner_name>"
2974  "<value>%%s</value>"
2975  "</preference>"
2976  "<preference>"
2977  "<scanner_name>source_iface</scanner_name>"
2978  "<value>%%s</value>"
2979  "</preference>"
2980  "<preference>"
2981  "<scanner_name>auto_delete</scanner_name>"
2982  "<value>%%s</value>"
2983  "</preference>"
2984  "<preference>"
2985  "<scanner_name>auto_delete_data</scanner_name>"
2986  "<value>%%s</value>"
2987  "</preference>"
2988  "</preferences>"
2989  "%s%i%s"
2990  "</modify_task>",
2991  hosts_ordering, alert_element->str, alterable ? "<alterable>" : "",
2992  alterable ? strcmp (alterable, "0") : 0, alterable ? "</alterable>" : "");
2993  response = NULL;
2994  entity = NULL;
2995  ret = gmpf (connection, credentials, &response, &entity, response_data,
2996  format, task_id, name, comment, target_id, config_id, schedule_id,
2997  schedule_periods, scanner_id, max_checks, max_hosts,
2998  strcmp (in_assets, "0") ? "yes" : "no",
2999  strcmp (apply_overrides, "0") ? "yes" : "no", min_qod,
3000  source_iface, auto_delete, auto_delete_data);
3001  g_free (format);
3002 
3003  g_string_free (alert_element, TRUE);
3004 
3005  switch (ret)
3006  {
3007  case 0:
3008  case -1:
3009  break;
3010  case 1:
3011  cmd_response_data_set_status_code (response_data,
3012  MHD_HTTP_INTERNAL_SERVER_ERROR);
3013  return gsad_message (
3014  credentials, "Internal error", __FUNCTION__, __LINE__,
3015  "An internal error occurred while saving a task. "
3016  "The task was not saved. "
3017  "Diagnostics: Failure to send command to manager daemon.",
3018  response_data);
3019  case 2:
3020  cmd_response_data_set_status_code (response_data,
3021  MHD_HTTP_INTERNAL_SERVER_ERROR);
3022  return gsad_message (
3023  credentials, "Internal error", __FUNCTION__, __LINE__,
3024  "An internal error occurred while saving a task. "
3025  "It is unclear whether the task has been saved or not. "
3026  "Diagnostics: Failure to receive response from manager daemon.",
3027  response_data);
3028  default:
3029  cmd_response_data_set_status_code (response_data,
3030  MHD_HTTP_INTERNAL_SERVER_ERROR);
3031  return gsad_message (
3032  credentials, "Internal error", __FUNCTION__, __LINE__,
3033  "An internal error occurred while saving a task. "
3034  "It is unclear whether the task has been saved or not. "
3035  "Diagnostics: Internal Error.",
3036  response_data);
3037  }
3038 
3039  html = response_from_entity (connection, credentials, params, entity,
3040  "Save Task", response_data);
3041  free_entity (entity);
3042  g_free (response);
3043  return html;
3044 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
gchar * value
Definition: gsad_params.h:40
Structure of credential related information.
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:303

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

Here is the call graph for this function:

◆ save_ticket_gmp()

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

Modify a ticket.

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

Definition at line 19059 of file gsad_gmp.c.

19061 {
19062  gchar *response = NULL;
19063  entity_t entity = NULL;
19064  const gchar *ticket_id, *status, *open_note, *fixed_note, *closed_note;
19065  const gchar *user_id;
19066  gchar *ret;
19067 
19068  ticket_id = params_value (params, "ticket_id");
19069  status = params_value (params, "ticket_status");
19070  open_note = params_value (params, "open_note");
19071  fixed_note = params_value (params, "fixed_note");
19072  closed_note = params_value (params, "closed_note");
19073  user_id = params_value (params, "user_id");
19074 
19075  CHECK_VARIABLE_INVALID (ticket_id, "Save Ticket");
19076  CHECK_VARIABLE_INVALID (status, "Save Ticket");
19077  CHECK_VARIABLE_INVALID (user_id, "Save Ticket");
19078  CHECK_VARIABLE_INVALID (open_note, "Save Ticket");
19079  CHECK_VARIABLE_INVALID (fixed_note, "Save Ticket");
19080  CHECK_VARIABLE_INVALID (closed_note, "Save Ticket");
19081 
19082  switch (gmpf (connection, credentials, &response, &entity, response_data,
19083  "<modify_ticket ticket_id=\"%s\">"
19084  "<assigned_to><user id=\"%s\"/></assigned_to>"
19085  "<status>%s</status>"
19086  "<open_note>%s</open_note>"
19087  "<fixed_note>%s</fixed_note>"
19088  "<closed_note>%s</closed_note>"
19089  "</modify_ticket>",
19090  ticket_id, user_id, status, open_note, fixed_note, closed_note))
19091  {
19092  case 0:
19093  case -1:
19094  break;
19095  case 1:
19096  cmd_response_data_set_status_code (response_data,
19097  MHD_HTTP_INTERNAL_SERVER_ERROR);
19098  return gsad_message (
19099  credentials, "Internal error", __FUNCTION__, __LINE__,
19100  "An internal error occurred while saving a ticket. "
19101  "Diagnostics: Failure to send command to manager daemon.",
19102  response_data);
19103  case 2:
19104  cmd_response_data_set_status_code (response_data,
19105  MHD_HTTP_INTERNAL_SERVER_ERROR);
19106  return gsad_message (
19107  credentials, "Internal error", __FUNCTION__, __LINE__,
19108  "An internal error occurred while saving a ticket. "
19109  "It is unclear whether the ticket has been saved or not. "
19110  "Diagnostics: Failure to receive response from manager daemon.",
19111  response_data);
19112  default:
19113  cmd_response_data_set_status_code (response_data,
19114  MHD_HTTP_INTERNAL_SERVER_ERROR);
19115  return gsad_message (
19116  credentials, "Internal error", __FUNCTION__, __LINE__,
19117  "An internal error occurred while saving a ticket. "
19118  "It is unclear whether the ticket has been saved or not. "
19119  "Diagnostics: Internal Error.",
19120  response_data);
19121  }
19122 
19123  ret = response_from_entity (connection, credentials, params, entity,
19124  "Save Ticket", response_data);
19125 
19126  free_entity (entity);
19127  g_free (response);
19128  return ret;
19129 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ save_user_gmp()

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

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

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

Definition at line 17313 of file gsad_gmp.c.

17315 {
17316  int ret;
17317  gchar *html, *response, *buf;
17318  const char *user_id, *login, *old_login, *modify_password, *password;
17319  const char *hosts, *hosts_allow, *ifaces, *ifaces_allow, *comment;
17320  entity_t entity;
17321  GString *command, *group_elements, *role_elements;
17322  params_t *groups, *roles;
17323 
17324  /* List of hosts user has/lacks access rights. */
17325  hosts = params_value (params, "access_hosts");
17326  /* Whether hosts grants ("1") or forbids ("0") access. "2" for all
17327  * access. */
17328  hosts_allow = params_value (params, "hosts_allow");
17329  ifaces = params_value (params, "access_ifaces");
17330  ifaces_allow = params_value (params, "ifaces_allow");
17331  login = params_value (params, "login");
17332  old_login = params_value (params, "old_login");
17333  modify_password = params_value (params, "modify_password");
17334  password = params_value (params, "password");
17335  user_id = params_value (params, "user_id");
17336  comment = params_value (params, "comment");
17337 
17338  CHECK_VARIABLE_INVALID (user_id, "Save User");
17339  CHECK_VARIABLE_INVALID (modify_password, "Save User");
17340  CHECK_VARIABLE_INVALID (hosts, "Save User");
17341  CHECK_VARIABLE_INVALID (hosts_allow, "Save User");
17342  CHECK_VARIABLE_INVALID (ifaces, "Save User");
17343  CHECK_VARIABLE_INVALID (ifaces_allow, "Save User");
17344  CHECK_VARIABLE_INVALID (login, "Save User");
17345  CHECK_VARIABLE_INVALID (old_login, "Save User");
17346 
17347  if (modify_password && str_equal (modify_password, "1"))
17348  {
17349  // require password if modify_password is 1 (== set new password)
17350  CHECK_VARIABLE_INVALID (password, "Save User");
17351  }
17352 
17353  if (params_given (params, "comment"))
17354  {
17355  CHECK_VARIABLE_INVALID (comment, "Save User");
17356  }
17357 
17358  /* Modify the user. */
17359 
17360  command = g_string_new ("");
17361  buf = g_markup_printf_escaped ("<modify_user user_id=\"%s\">"
17362  "<password modify=\"%s\">"
17363  "%s</password>",
17364  user_id, modify_password,
17365  password ? password : "");
17366  g_string_append (command, buf);
17367  g_free (buf);
17368 
17369  if (login)
17370  {
17371  buf = g_markup_printf_escaped ("<new_name>%s</new_name>", login);
17372  g_string_append (command, buf);
17373  g_free (buf);
17374  }
17375 
17376  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
17377  "<ifaces allow=\"%s\">%s</ifaces>",
17378  hosts_allow, hosts, ifaces_allow, ifaces);
17379  g_string_append (command, buf);
17380  g_free (buf);
17381 
17382  if (modify_password && !strcmp (modify_password, "2"))
17383  g_string_append (command,
17384  "<sources><source>ldap_connect</source></sources>");
17385  else if (modify_password && !strcmp (modify_password, "3"))
17386  g_string_append (command,
17387  "<sources><source>radius_connect</source></sources>");
17388  else
17389  g_string_append (command, "<sources><source>file</source></sources>");
17390 
17391  group_elements = g_string_new ("<groups>");
17392  if (params_given (params, "group_id_optional:"))
17393  groups = params_values (params, "group_id_optional:");
17394  else
17395  groups = params_values (params, "group_ids:");
17396 
17397  if (groups)
17398  {
17399  params_iterator_t iter;
17400  char *name;
17401  param_t *param;
17402 
17403  params_iterator_init (&iter, groups);
17404  while (params_iterator_next (&iter, &name, &param))
17405  {
17406  if (param->value && strcmp (param->value, "--"))
17407  g_string_append_printf (group_elements, "<group id=\"%s\"/>",
17408  param->value ? param->value : "");
17409  }
17410  }
17411  g_string_append (command, group_elements->str);
17412  g_string_free (group_elements, TRUE);
17413  g_string_append (command, "</groups>");
17414 
17415  role_elements = g_string_new ("");
17416  if (params_given (params, "role_id_optional:"))
17417  roles = params_values (params, "role_id_optional:");
17418  else
17419  roles = params_values (params, "role_ids:");
17420 
17421  if (roles)
17422  {
17423  params_iterator_t iter;
17424  char *name;
17425  param_t *param;
17426 
17427  params_iterator_init (&iter, roles);
17428  while (params_iterator_next (&iter, &name, &param))
17429  {
17430  if (param->value && strcmp (param->value, "--"))
17431  g_string_append_printf (role_elements, "<role id=\"%s\"/>",
17432  param->value ? param->value : "");
17433  }
17434  }
17435  else
17436  g_string_append_printf (role_elements, "<role id=\"0\"/>");
17437 
17438  g_string_append (command, role_elements->str);
17439  g_string_free (role_elements, TRUE);
17440 
17441  if (comment)
17442  {
17443  xml_string_append (command, "<comment>%s</comment>", comment);
17444  }
17445 
17446  g_string_append (command, "</modify_user>");
17447 
17448  response = NULL;
17449  entity = NULL;
17450  ret = gmp (connection, credentials, &response, &entity, response_data,
17451  command->str);
17452  g_string_free (command, TRUE);
17453 
17454  user_t *current_user = credentials_get_user (credentials);
17455 
17456  switch (ret)
17457  {
17458  case 0:
17459  if (gmp_success (entity) == 1)
17460  {
17461  user_t *user = session_get_user_by_username (old_login);
17462 
17463  if (user
17464  && (!str_equal (modify_password, "0")
17465  || !str_equal (old_login, login)))
17466  {
17467  /* logout all other user sessions if new password was set,
17468  authentication type has changed or username has changed */
17470  user);
17471  }
17472 
17473  if (str_equal (old_login, user_get_username (current_user)))
17474  {
17475  /* update username of current user */
17476  user_set_username (current_user, login);
17477 
17478  if (str_equal (modify_password, "1"))
17479  {
17480  /* update password of current user */
17481  user_set_password (current_user, password);
17482  }
17483  }
17484  }
17485  break;
17486  case -1:
17487  break;
17488  case 1:
17489  cmd_response_data_set_status_code (response_data,
17490  MHD_HTTP_INTERNAL_SERVER_ERROR);
17491  return gsad_message (
17492  credentials, "Internal error", __FUNCTION__, __LINE__,
17493  "An internal error occurred while saving a user. "
17494  "The user was not saved. "
17495  "Diagnostics: Failure to send command to manager daemon.",
17496  response_data);
17497  case 2:
17498  cmd_response_data_set_status_code (response_data,
17499  MHD_HTTP_INTERNAL_SERVER_ERROR);
17500  return gsad_message (
17501  credentials, "Internal error", __FUNCTION__, __LINE__,
17502  "An internal error occurred while saving a user. "
17503  "It is unclear whether the user has been saved or not. "
17504  "Diagnostics: Failure to receive response from manager daemon.",
17505  response_data);
17506  default:
17507  cmd_response_data_set_status_code (response_data,
17508  MHD_HTTP_INTERNAL_SERVER_ERROR);
17509  return gsad_message (
17510  credentials, "Internal error", __FUNCTION__, __LINE__,
17511  "An internal error occurred while saving a user. "
17512  "It is unclear whether the user has been saved or not. "
17513  "Diagnostics: Internal Error.",
17514  response_data);
17515  }
17516 
17517  if (gmp_success (entity)
17518  && (str_equal (modify_password, "2") || !str_equal (modify_password, "3"))
17519  && str_equal (old_login, user_get_username (current_user)))
17520  {
17521  free_entity (entity);
17522  g_free (response);
17523 
17524  cmd_response_data_set_status_code (response_data, MHD_HTTP_UNAUTHORIZED);
17525  return gsad_message (
17526  credentials, "Authentication Required", __FUNCTION__, __LINE__,
17527  "Authentication method changed. Please login with ", response_data);
17528  }
17529  else
17530  html = response_from_entity (connection, credentials, params, entity,
17531  "Save User", response_data);
17532  free_entity (entity);
17533  g_free (response);
17534  return html;
17535 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:287
gchar * value
Definition: gsad_params.h:40
static int gmp_success(entity_t entity)
Check whether an GMP command failed.
Definition: gsad_gmp.c:656
Structure of credential related information.
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
void user_set_password(user_t *user, const gchar *password)
Set password of user.
Definition: gsad_user.c:257
#define params_iterator_t
Definition: gsad_params.h:94
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:189
static int gmp(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *)
Run a single GMP command.
Definition: gsad_gmp.c:706
void user_set_username(user_t *user, const gchar *username)
Set username of user.
Definition: gsad_user.c:311
user_t * session_get_user_by_username(const gchar *username)
Definition: gsad_session.c:116
int login(http_connection_t *con, params_t *params, cmd_response_data_t *response_data, const char *client_address)
Login and create a session.
Definition: gsad_gmp.c:19384
const gchar * user_get_username(user_t *user)
Definition: gsad_user.c:157
const gchar * user_get_token(user_t *user)
Definition: gsad_user.c:175
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
Request parameter.
Definition: gsad_params.h:38
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:394
void session_remove_other_sessions(const gchar *id, user_t *user)
Removes all session of the user, except the one with the passed id.
Definition: gsad_session.c:181
User information structure, for sessions.
Definition: gsad_user.c:42
#define params_iterator_init
Definition: gsad_params.h:96
#define params_t
Definition: gsad_params.h:31
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160
user_t * credentials_get_user(credentials_t *cred)

References CHECK_VARIABLE_INVALID, cmd_response_data_set_status_code(), credentials_get_user(), gmp(), gmp_success(), gsad_message(), login(), params_given(), params_iterator_init, params_iterator_next(), params_iterator_t, params_t, params_value(), params_values(), response_from_entity(), session_get_user_by_username(), session_remove_other_sessions(), str_equal(), user_get_token(), user_get_username(), user_set_password(), user_set_username(), and param::value.

Here is the call graph for this function:

◆ start_task_gmp()

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

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

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

Definition at line 3232 of file gsad_gmp.c.

3234 {
3235  return resource_action (connection, credentials, params, "task", "start",
3236  response_data);
3237 }
Structure of credential related information.
char * resource_action(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, envelope result.
Definition: gsad_gmp.c:2068

References resource_action().

Here is the call graph for this function:

◆ stop_task_gmp()

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

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

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

Definition at line 3196 of file gsad_gmp.c.

3198 {
3199  return resource_action (connection, credentials, params, "task", "stop",
3200  response_data);
3201 }
Structure of credential related information.
char * resource_action(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, envelope result.
Definition: gsad_gmp.c:2068

References resource_action().

Here is the call graph for this function:

◆ sync_cert_gmp()

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

Synchronize with a CERT feed and envelope the result.

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

Definition at line 16392 of file gsad_gmp.c.

16394 {
16395  return sync_feed (connection, credentials, params, "sync_cert",
16396  "Synchronize CERT Feed", "the CERT feed", response_data);
16397 }
Structure of credential related information.
static char * sync_feed(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
Synchronize with a feed and envelope the result.
Definition: gsad_gmp.c:16299

References sync_feed().

Here is the call graph for this function:

◆ sync_config_gmp()

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

Sync config, get configs, envelope the result.

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

Definition at line 8326 of file gsad_gmp.c.

8328 {
8329  GString *xml;
8330  const char *config_id;
8331  char *ret;
8332 
8333  config_id = params_value (params, "config_id");
8334  CHECK_VARIABLE_INVALID (config_id, "Synchronize Config");
8335 
8336  if (gvm_connection_sendf (connection, "<sync_config config_id=\"%s\"/>",
8337  config_id)
8338  == -1)
8339  {
8340  cmd_response_data_set_status_code (response_data,
8341  MHD_HTTP_INTERNAL_SERVER_ERROR);
8342  return gsad_message (
8343  credentials, "Internal error", __FUNCTION__, __LINE__,
8344  "An internal error occurred while synchronizing a config. "
8345  "The config is not synchronized. "
8346  "Diagnostics: Failure to send command to manager daemon.",
8347  response_data);
8348  }
8349 
8350  xml = g_string_new ("");
8351 
8352  if (read_string_c (connection, &xml))
8353  {
8354  g_string_free (xml, TRUE);
8355  cmd_response_data_set_status_code (response_data,
8356  MHD_HTTP_INTERNAL_SERVER_ERROR);
8357  return gsad_message (
8358  credentials, "Internal error", __FUNCTION__, __LINE__,
8359  "An internal error occurred while synchronizing a config. "
8360  "It is unclear whether the config has been synchronized or not. "
8361  "Diagnostics: Failure to receive response from manager daemon.",
8362  response_data);
8363  }
8364 
8365  // TODO return action result
8366  ret = get_configs (connection, credentials, params, xml->str, response_data);
8367 
8368  g_string_free (xml, TRUE);
8369  return ret;
8370 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
static char * get_configs(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Get all scan configs, envelope the result.
Definition: gsad_gmp.c:8040
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ sync_feed_gmp()

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

Synchronize with an NVT feed and envelope the result.

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

Definition at line 16356 of file gsad_gmp.c.

16358 {
16359  return sync_feed (connection, credentials, params, "sync_feed",
16360  "Synchronize Feed", "the NVT feed", response_data);
16361 }
Structure of credential related information.
static char * sync_feed(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
Synchronize with a feed and envelope the result.
Definition: gsad_gmp.c:16299

References sync_feed().

Here is the call graph for this function:

◆ sync_scap_gmp()

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

Synchronize with a SCAP feed and envelope the result.

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

Definition at line 16374 of file gsad_gmp.c.

16376 {
16377  return sync_feed (connection, credentials, params, "sync_scap",
16378  "Synchronize Feed", "the SCAP feed", response_data);
16379 }
Structure of credential related information.
static char * sync_feed(gvm_connection_t *connection, credentials_t *credentials, params_t *params, const char *sync_cmd, const char *action, const char *feed_name, cmd_response_data_t *response_data)
Synchronize with a feed and envelope the result.
Definition: gsad_gmp.c:16299

References sync_feed().

Here is the call graph for this function:

◆ test_alert_gmp()

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

Test an alert, get all alerts envelope the result.

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

Definition at line 6566 of file gsad_gmp.c.

6568 {
6569  gchar *html, *response;
6570  const char *alert_id;
6571  entity_t entity;
6572 
6573  alert_id = params_value (params, "alert_id");
6574 
6575  if (alert_id == NULL)
6576  {
6577  cmd_response_data_set_status_code (response_data,
6579  return gsad_message (credentials, "Invalid request", __FUNCTION__,
6580  __LINE__,
6581  "Missing parameter alert_id."
6582  "Diagnostics: Required parameter was NULL.",
6583  response_data);
6584  }
6585 
6586  /* Test the alert. */
6587 
6588  if (gvm_connection_sendf (connection, "<test_alert alert_id=\"%s\"/>",
6589  alert_id)
6590  == -1)
6591  {
6592  cmd_response_data_set_status_code (response_data,
6593  MHD_HTTP_INTERNAL_SERVER_ERROR);
6594  return gsad_message (
6595  credentials, "Internal error", __FUNCTION__, __LINE__,
6596  "An internal error occurred while testing an alert. "
6597  "Diagnostics: Failure to send command to manager daemon.",
6598  response_data);
6599  }
6600 
6601  entity = NULL;
6602  if (read_entity_and_text_c (connection, &entity, &response))
6603  {
6604  cmd_response_data_set_status_code (response_data,
6605  MHD_HTTP_INTERNAL_SERVER_ERROR);
6606  return gsad_message (
6607  credentials, "Internal error", __FUNCTION__, __LINE__,
6608  "An internal error occurred while testing an alert. "
6609  "Diagnostics: Failure to receive response from manager daemon.",
6610  response_data);
6611  }
6612 
6613  html = response_from_entity (connection, credentials, params, entity,
6614  "Test Alert", response_data);
6615 
6616  free_entity (entity);
6617  g_free (response);
6618  return html;
6619 }
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
#define GSAD_STATUS_INVALID_REQUEST
HTTP status code for expected failure of gmp requests e.g. if some parameter was missing or invalid.
Definition: gsad_gmp.c:96
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ toggle_tag_gmp()

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

Set tag enabled status.

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

Definition at line 7466 of file gsad_gmp.c.

7468 {
7469  gchar *html, *response;
7470  const char *tag_id, *enable;
7471  entity_t entity;
7472 
7473  tag_id = params_value (params, "tag_id");
7474  enable = params_value (params, "enable");
7475 
7476  CHECK_VARIABLE_INVALID (tag_id, "Toggle Tag")
7477  CHECK_VARIABLE_INVALID (enable, "Toggle Tag")
7478 
7479  /* Delete the resource and get all resources. */
7480 
7481  if (gvm_connection_sendf (connection,
7482  "<modify_tag tag_id=\"%s\">"
7483  "<active>%s</active>"
7484  "</modify_tag>",
7485  tag_id, enable)
7486  == -1)
7487  {
7488  cmd_response_data_set_status_code (response_data,
7489  MHD_HTTP_INTERNAL_SERVER_ERROR);
7490  return gsad_message (credentials, "Internal error", __FUNCTION__,
7491  __LINE__,
7492  "An internal error occurred while modifying a tag. "
7493  "The tag is not modified. "
7494  "Diagnostics: Failure to send command to"
7495  " manager daemon.",
7496  response_data);
7497  }
7498 
7499  entity = NULL;
7500  if (read_entity_and_text_c (connection, &entity, &response))
7501  {
7502  cmd_response_data_set_status_code (response_data,
7503  MHD_HTTP_INTERNAL_SERVER_ERROR);
7504  return gsad_message (credentials, "Internal error", __FUNCTION__,
7505  __LINE__,
7506  "An internal error occurred while modifying a tag. "
7507  "It is unclear whether the tag has been modified"
7508  " or not. "
7509  "Diagnostics: Failure to read response from"
7510  " manager daemon.",
7511  response_data);
7512  }
7513 
7514  html = response_from_entity (connection, credentials, params, entity,
7515  "Toggle Tag", response_data);
7516 
7517  free_entity (entity);
7518  g_free (response);
7519 
7520  return html;
7521 }
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ verify_agent_gmp()

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

Verify agent, get agents, envelope the result.

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

Definition at line 4906 of file gsad_gmp.c.

4908 {
4909  gchar *html, *response;
4910  const char *agent_id;
4911  int ret;
4912  entity_t entity;
4913 
4914  agent_id = params_value (params, "agent_id");
4915  if (agent_id == NULL)
4916  {
4917  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
4918  return gsad_message (
4919  credentials, "Internal error", __FUNCTION__, __LINE__,
4920  "An internal error occurred while verifying an agent. "
4921  "Diagnostics: Required parameter was NULL.",
4922  response_data);
4923  }
4924  response = NULL;
4925  entity = NULL;
4926  ret = gmpf (connection, credentials, &response, &entity, response_data,
4927  "<verify_agent agent_id=\"%s\" />", agent_id);
4928 
4929  switch (ret)
4930  {
4931  case 0:
4932  case -1:
4933  break;
4934  case 1:
4935  cmd_response_data_set_status_code (response_data,
4936  MHD_HTTP_INTERNAL_SERVER_ERROR);
4937  return gsad_message (
4938  credentials, "Internal error", __FUNCTION__, __LINE__,
4939  "An internal error occurred while verifying a agent. "
4940  "The agent was not verified. "
4941  "Diagnostics: Failure to send command to manager daemon.",
4942  response_data);
4943  case 2:
4944  cmd_response_data_set_status_code (response_data,
4945  MHD_HTTP_INTERNAL_SERVER_ERROR);
4946  return gsad_message (
4947  credentials, "Internal error", __FUNCTION__, __LINE__,
4948  "An internal error occurred while verifying a agent. "
4949  "It is unclear whether the agent was verified or not. "
4950  "Diagnostics: Failure to send command to manager daemon.",
4951  response_data);
4952  default:
4953  cmd_response_data_set_status_code (response_data,
4954  MHD_HTTP_INTERNAL_SERVER_ERROR);
4955  return gsad_message (
4956  credentials, "Internal error", __FUNCTION__, __LINE__,
4957  "An internal error occurred while verifying a agent. "
4958  "It is unclear whether the agent was verified or not. "
4959  "Diagnostics: Failure to send command to manager daemon.",
4960  response_data);
4961  }
4962 
4963  html = response_from_entity (connection, credentials, params, entity,
4964  "Verify Agent", response_data);
4965  free_entity (entity);
4966  g_free (response);
4967  return html;
4968 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ verify_report_format_gmp()

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

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

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

Definition at line 12939 of file gsad_gmp.c.

12942 {
12943  int ret;
12944  gchar *html, *response;
12945  const char *report_format_id;
12946  entity_t entity;
12947 
12948  report_format_id = params_value (params, "report_format_id");
12949  if (report_format_id == NULL)
12950  {
12951  cmd_response_data_set_status_code (response_data, MHD_HTTP_BAD_REQUEST);
12952  return gsad_message (
12953  credentials, "Internal error", __FUNCTION__, __LINE__,
12954  "An internal error occurred while verifying a report format. "
12955  "Diagnostics: Required parameter was NULL.",
12956  response_data);
12957  }
12958 
12959  /* Verify the report format. */
12960 
12961  response = NULL;
12962  entity = NULL;
12963  ret =
12964  gmpf (connection, credentials, &response, &entity, response_data,
12965  "<verify_report_format report_format_id=\"%s\"/>", report_format_id);
12966 
12967  switch (ret)
12968  {
12969  case 0:
12970  case -1:
12971  break;
12972  case 1:
12973  cmd_response_data_set_status_code (response_data,
12974  MHD_HTTP_INTERNAL_SERVER_ERROR);
12975  return gsad_message (
12976  credentials, "Internal error", __FUNCTION__, __LINE__,
12977  "An internal error occurred while verifying a report format. "
12978  "The report format was not verified. "
12979  "Diagnostics: Failure to send command to manager daemon.",
12980  response_data);
12981  case 2:
12982  cmd_response_data_set_status_code (response_data,
12983  MHD_HTTP_INTERNAL_SERVER_ERROR);
12984  return gsad_message (
12985  credentials, "Internal error", __FUNCTION__, __LINE__,
12986  "An internal error occurred while verifying a report format. "
12987  "It is unclear whether the report format was verified or not. "
12988  "Diagnostics: Failure to send command to manager daemon.",
12989  response_data);
12990  default:
12991  cmd_response_data_set_status_code (response_data,
12992  MHD_HTTP_INTERNAL_SERVER_ERROR);
12993  return gsad_message (
12994  credentials, "Internal error", __FUNCTION__, __LINE__,
12995  "An internal error occurred while verifying a report format. "
12996  "It is unclear whether the report format was verified or not. "
12997  "Diagnostics: Failure to send command to manager daemon.",
12998  response_data);
12999  }
13000 
13001  html = response_from_entity (connection, credentials, params, entity,
13002  "Verify Report Format", response_data);
13003  free_entity (entity);
13004  g_free (response);
13005  return html;
13006 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ verify_scanner_gmp()

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

Verify scanner, get scanners, envelope the result.

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

Definition at line 11626 of file gsad_gmp.c.

11628 {
11629  gchar *html, *response;
11630  const char *scanner_id;
11631  int ret;
11632  entity_t entity;
11633 
11634  scanner_id = params_value (params, "scanner_id");
11635  CHECK_VARIABLE_INVALID (scanner_id, "Verify Scanner");
11636 
11637  ret = gmpf (connection, credentials, &response, &entity, response_data,
11638  "<verify_scanner scanner_id=\"%s\"/>", scanner_id);
11639 
11640  switch (ret)
11641  {
11642  case 0:
11643  case -1:
11644  break;
11645  case 1:
11646  cmd_response_data_set_status_code (response_data,
11647  MHD_HTTP_INTERNAL_SERVER_ERROR);
11648  return gsad_message (
11649  credentials, "Internal error", __FUNCTION__, __LINE__,
11650  "An internal error occurred while verifying a scanner. "
11651  "The scanner was not verified. "
11652  "Diagnostics: Failure to send command to manager daemon.",
11653  response_data);
11654  case 2:
11655  cmd_response_data_set_status_code (response_data,
11656  MHD_HTTP_INTERNAL_SERVER_ERROR);
11657  return gsad_message (
11658  credentials, "Internal error", __FUNCTION__, __LINE__,
11659  "An internal error occurred while verifying a scanner. "
11660  "It is unclear whether the scanner was verified or not. "
11661  "Diagnostics: Failure to send command to manager daemon.",
11662  response_data);
11663  default:
11664  cmd_response_data_set_status_code (response_data,
11665  MHD_HTTP_INTERNAL_SERVER_ERROR);
11666  return gsad_message (
11667  credentials, "Internal error", __FUNCTION__, __LINE__,
11668  "An internal error occurred while verifying a scanner. "
11669  "It is unclear whether the scanner was verified or not. "
11670  "Diagnostics: Failure to send command to manager daemon.",
11671  response_data);
11672  }
11673 
11674  html = response_from_entity (connection, credentials, params, entity,
11675  "Verify Scanner", response_data);
11676  free_entity (entity);
11677  g_free (response);
11678  return html;
11679 }
static int gmpf(gvm_connection_t *, credentials_t *, gchar **, entity_t *, cmd_response_data_t *, const char *,...)
Run a single formatted GMP command.
Definition: gsad_gmp.c:859
Structure of credential related information.
#define CHECK_VARIABLE_INVALID(name, op_name)
Check if variable is NULL.
Definition: gsad_gmp.c:119
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_http.c:978
static gchar * response_from_entity(gvm_connection_t *, credentials_t *, params_t *, entity_t, const char *, cmd_response_data_t *)
Set redirect or return a basic action_result page based on entity.
Definition: gsad_gmp.c:1023
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:205
void cmd_response_data_set_status_code(cmd_response_data_t *data, int http_status_code)
Set status code of cmd_response_data_t struct.
Definition: gsad_cmd.c:160

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

Here is the call graph for this function:

◆ wizard_get_gmp()

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

Returns a wizard_get page.

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

Definition at line 18243 of file gsad_gmp.c.

18245 {
18246  return wizard_get (connection, credentials, params, NULL, response_data);
18247 }
static char * wizard_get(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard_get page.
Definition: gsad_gmp.c:18135
Structure of credential related information.

References wizard_get().

Here is the call graph for this function:

◆ wizard_gmp()

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

Returns a wizard page.

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

Definition at line 18117 of file gsad_gmp.c.

18119 {
18120  return wizard (connection, credentials, params, NULL, response_data);
18121 }
Structure of credential related information.
static char * wizard(gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *)
Returns a wizard page.
Definition: gsad_gmp.c:18016

References wizard().

Here is the call graph for this function: