Greenbone Security Assistant  7.0.0
gsad_omp.h File Reference

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

#include <glib.h>
#include "gsad_base.h"
Include dependency graph for gsad_omp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

Detailed Description

Headers for GSA's OMP communication module.

Definition in file gsad_omp.h.

Function Documentation

char* auth_settings_omp ( credentials_t ,
params_t ,
cmd_response_data_t  
)

Definition at line 25651 of file gsad_omp.c.

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

25653 {
25654  GString * xml;
25655  gchar * buf;
25656  const char *name;
25657 
25658  name = params_value (params, "name");
25659 
25660  CHECK_PARAM_INVALID (name, "Auth settings", "auth_settings");
25661 
25662  xml = g_string_new ("");
25663  buf = g_markup_printf_escaped ("<auth_settings name=\"%s\">", name);
25664  g_string_append (xml, buf);
25665  g_free (buf);
25666 
25667  if (command_enabled (credentials, "DESCRIBE_AUTH"))
25668  {
25669  gchar * response = NULL;
25670  entity_t entity = NULL;
25671 
25672  switch (omp (credentials, &response, &entity, response_data,
25673  "<describe_auth/>"))
25674  {
25675  case 0:
25676  case -1:
25677  break;
25678  case 1:
25679  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25680  return gsad_message (credentials,
25681  "Internal error", __FUNCTION__, __LINE__,
25682  "An internal error occurred getting the auth list. "
25683  "Diagnostics: Failure to send command to manager daemon.",
25684  "/omp?cmd=get_users", response_data);
25685  case 2:
25686  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25687  return gsad_message (credentials,
25688  "Internal error", __FUNCTION__, __LINE__,
25689  "An internal error occurred getting the auth list. "
25690  "Diagnostics: Failure to receive response from manager daemon.",
25691  "/omp?cmd=get_users", response_data);
25692  default:
25693  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25694  return gsad_message (credentials,
25695  "Internal error", __FUNCTION__, __LINE__,
25696  "An internal error occurred getting the auth list. "
25697  "Diagnostics: Internal Error.",
25698  "/omp?cmd=get_users", response_data);
25699  }
25700 
25701 
25702  g_string_append (xml, response);
25703  free_entity (entity);
25704  g_free (response);
25705  }
25706 
25707  g_string_append (xml, "</auth_settings>");
25708 
25709  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
25710  response_data);
25711 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:304

Here is the call graph for this function:

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

Check authentication credentials.

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

Definition at line 28065 of file gsad_omp.c.

References manager_address, manager_port, and openvas_connection_open().

Referenced by exec_omp_post(), and user_find().

28069 {
28070  openvas_connection_t connection;
28071  int auth;
28072  omp_authenticate_info_opts_t auth_opts;
28073 
28074  if (openvas_connection_open (&connection,
28076  manager_port))
28077  {
28078  g_debug ("%s failed to acquire socket!\n", __FUNCTION__);
28079  return 2;
28080  }
28081 
28082 #ifdef DEBUG_AUTH
28083  /* Enable this if you need the CGI to sleep after launch. This can be useful
28084  * if you need to attach to manager process the CGI is talking to for
28085  * debugging purposes.
28086  *
28087  * It's probably easier to run gsad in the foreground under gdb and
28088  * set a break point here.
28089  */
28090  g_debug ("Sleeping!");
28091  sleep (20);
28092 #endif
28093 
28094  auth_opts = omp_authenticate_info_opts_defaults;
28095  auth_opts.username = username;
28096  auth_opts.password = password;
28097  auth_opts.role = role;
28098  auth_opts.severity = severity;
28099  auth_opts.timezone = timezone;
28100  auth_opts.pw_warning = pw_warning;
28101 
28102  auth = omp_authenticate_info_ext_c (&connection, auth_opts);
28103  if (auth == 0)
28104  {
28105  entity_t entity;
28106  const char* status;
28107  char first;
28108  gchar *response;
28109  int ret;
28110 
28111  /* Get language setting. */
28112 
28113  ret = setting_get_value (&connection,
28114  "6765549a-934e-11e3-b358-406186ea4fc5",
28115  language,
28116  NULL);
28117 
28118  switch (ret)
28119  {
28120  case 0:
28121  break;
28122  case 1:
28123  case 2:
28124  openvas_connection_close (&connection);
28125  return 2;
28126  default:
28127  openvas_connection_close (&connection);
28128  return -1;
28129  }
28130 
28131  /* Request help. */
28132 
28133  ret = openvas_connection_sendf (&connection,
28134  "<help format=\"XML\" type=\"brief\"/>");
28135  if (ret)
28136  {
28137  openvas_connection_close (&connection);
28138  return 2;
28139  }
28140 
28141  /* Read the response. */
28142 
28143  entity = NULL;
28144  if (read_entity_and_text_c (&connection, &entity, &response))
28145  {
28146  openvas_connection_close (&connection);
28147  return 2;
28148  }
28149 
28150  /* Check the response. */
28151 
28152  status = entity_attribute (entity, "status");
28153  if (status == NULL
28154  || strlen (status) == 0)
28155  {
28156  g_free (response);
28157  free_entity (entity);
28158  return -1;
28159  }
28160  first = status[0];
28161  free_entity (entity);
28162  if (first == '2')
28163  {
28164  *capabilities = response;
28165  }
28166  else
28167  {
28168  openvas_connection_close (&connection);
28169  g_free (response);
28170  return -1;
28171  }
28172 
28173  /* Get the chart preferences */
28174 
28175  ret = openvas_connection_sendf (&connection,
28176  "<get_settings"
28177  " filter='name~\"Dashboard\"'/>");
28178  if (ret)
28179  {
28180  openvas_connection_close (&connection);
28181  return 2;
28182  }
28183 
28184  /* Read the response */
28185  entity = NULL;
28186  if (read_entity_and_text_c (&connection, &entity, &response))
28187  {
28188  openvas_connection_close (&connection);
28189  return 2;
28190  }
28191 
28192  /* Check the response. */
28193  status = entity_attribute (entity, "status");
28194  if (status == NULL
28195  || strlen (status) == 0)
28196  {
28197  g_free (response);
28198  free_entity (entity);
28199  return -1;
28200  }
28201  first = status[0];
28202  if (first == '2')
28203  {
28204  entities_t entities = entity->entities;
28205  entity_t child_entity;
28206  *chart_prefs = g_tree_new_full ((GCompareDataFunc) g_strcmp0,
28207  NULL, g_free, g_free);
28208 
28209  while ((child_entity = first_entity (entities)))
28210  {
28211  if (strcmp (entity_name (child_entity), "setting") == 0)
28212  {
28213  const char *setting_id
28214  = entity_attribute (child_entity, "id");
28215  const char *setting_value
28216  = entity_text (entity_child (child_entity, "value"));
28217 
28218  if (setting_id && setting_value)
28219  g_tree_insert (*chart_prefs,
28220  g_strdup (setting_id),
28221  g_strdup (setting_value));
28222  }
28223  entities = next_entities (entities);
28224  }
28225  free_entity (entity);
28226  g_free (response);
28227  }
28228  else
28229  {
28230  free_entity (entity);
28231  g_free (response);
28232  openvas_connection_close (&connection);
28233  return -1;
28234  }
28235 
28236  /* Get autorefresh setting. */
28237 
28238  ret = setting_get_value (&connection,
28239  "578a1c14-e2dc-45ef-a591-89d31391d007",
28240  autorefresh,
28241  NULL);
28242 
28243  switch (ret)
28244  {
28245  case 0:
28246  break;
28247  case 1:
28248  case 2:
28249  openvas_connection_close (&connection);
28250  return 2;
28251  default:
28252  openvas_connection_close (&connection);
28253  return -1;
28254  }
28255 
28256  openvas_connection_close (&connection);
28257  return 0;
28258  }
28259  else
28260  {
28261  openvas_connection_close (&connection);
28262  return 1;
28263  }
28264 }
gchar * manager_address
The address the manager is on.
Definition: gsad_omp.c:96
int manager_port
The port the manager is on.
Definition: gsad_omp.c:101
int openvas_connection_open(openvas_connection_t *connection, const gchar *address, int port)
Connect to an address.
Definition: gsad_omp.c:28023

Here is the call graph for this function:

Here is the caller graph for this function:

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

Delete multiple resources, get next page, XSL transform the result.

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

Definition at line 27059 of file gsad_omp.c.

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

27061 {
27062  openvas_connection_t connection;
27063  const char *no_redirect, *type;
27064  GString *commands_xml;
27065  params_t *selected_ids;
27066  params_iterator_t iter;
27067  param_t *param;
27068  gchar *param_name;
27069  gchar *html, *response;
27070  entity_t entity;
27071  gchar *extra_attribs;
27072 
27073  no_redirect = params_value (params, "no_redirect");
27074  type = params_value (params, "resource_type");
27075  if (type == NULL)
27076  {
27077  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27078  return gsad_message (credentials,
27079  "Internal error", __FUNCTION__, __LINE__,
27080  "An internal error occurred while deleting resources. "
27081  "The resources were not deleted. "
27082  "Diagnostics: Required parameter 'resource_type' was NULL.",
27083  "/omp?cmd=get_tasks", response_data);
27084  }
27085 
27086  /* Extra attributes */
27087  extra_attribs = NULL;
27088 
27089  /* Inheritor of user's resource */
27090  if (strcmp (type, "user") == 0)
27091  {
27092  const char* inheritor_id;
27093  inheritor_id = params_value (params, "inheritor_id");
27094  if (inheritor_id)
27095  extra_attribs = g_strdup_printf ("inheritor_id=\"%s\"", inheritor_id);
27096  }
27097 
27098  commands_xml = g_string_new ("<commands>");
27099 
27100  selected_ids = params_values (params, "bulk_selected:");
27101  if (selected_ids)
27102  {
27103  params_iterator_init (&iter, selected_ids);
27104  while (params_iterator_next (&iter, &param_name, &param))
27105  {
27106  xml_string_append (commands_xml,
27107  "<delete_%s %s_id=\"%s\" ultimate=\"0\"",
27108  type,
27109  type,
27110  param_name);
27111  if (extra_attribs)
27112  g_string_append_printf (commands_xml, " %s/>", extra_attribs);
27113  else
27114  g_string_append (commands_xml, "/>");
27115  }
27116  }
27117 
27118  g_string_append (commands_xml, "</commands>");
27119 
27120  switch (manager_connect (credentials, &connection, &html,
27121  response_data))
27122  {
27123  case 0:
27124  break;
27125  case -1:
27126  if (html)
27127  return html;
27128  /* Fall through. */
27129  default:
27130  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27131  return gsad_message (credentials,
27132  "Internal error", __FUNCTION__, __LINE__,
27133  "An internal error occurred while deleting resources. "
27134  "The resources were not deleted. "
27135  "Diagnostics: Failure to connect to manager daemon.",
27136  "/omp?cmd=get_tasks", response_data);
27137  }
27138 
27139  /* Delete the resources and get all resources. */
27140 
27141  if (openvas_connection_sendf_xml (&connection,
27142  commands_xml->str)
27143  == -1)
27144  {
27145  g_string_free (commands_xml, TRUE);
27146  openvas_connection_close (&connection);
27147  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27148  return gsad_message (credentials,
27149  "Internal error", __FUNCTION__, __LINE__,
27150  "An internal error occurred while deleting resources. "
27151  "The resources were not deleted. "
27152  "Diagnostics: Failure to send command to manager daemon.",
27153  "/omp?cmd=get_tasks", response_data);
27154  }
27155  g_string_free (commands_xml, TRUE);
27156 
27157  entity = NULL;
27158  if (read_entity_and_text_c (&connection, &entity, &response))
27159  {
27160  openvas_connection_close (&connection);
27161  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27162  return gsad_message (credentials,
27163  "Internal error", __FUNCTION__, __LINE__,
27164  "An internal error occurred while deleting resources. "
27165  "It is unclear whether the resources have been deleted or not. "
27166  "Diagnostics: Failure to read response from manager daemon.",
27167  "/omp?cmd=get_tasks", response_data);
27168  }
27169 
27170  openvas_connection_close (&connection);
27171 
27172  /* Cleanup, and return transformed XML. */
27173 
27174  if (params_given (params, "next") == 0)
27175  {
27176  gchar *next;
27177  next = g_strdup_printf ("get_%ss", type);
27178  params_add (params, "next", next);
27179  g_free (next);
27180  }
27181  html = response_from_entity (credentials, params, entity,
27182  (no_redirect && strcmp (no_redirect, "0")),
27183  NULL, NULL,
27184  NULL, NULL,
27185  "Bulk Delete", response_data);
27186  g_free (response);
27187  free_entity (entity);
27188 
27189  return html;
27190 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Clone a resource, XSL transform the result.

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

Definition at line 9795 of file gsad_omp.c.

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

9797 {
9798  openvas_connection_t connection;
9799  gchar *html, *response;
9800  const char *id, *type, *alterable, *no_redirect, *next_id;
9801  gchar *next_id_name, *cap_type, *prev_action;
9802  entity_t entity;
9803 
9804  id = params_value (params, "id");
9805  type = params_value (params, "resource_type");
9806  alterable = params_value (params, "alterable");
9807  no_redirect = params_value (params, "no_redirect");
9808 
9809  CHECK (id);
9810  CHECK (type);
9811 
9812  switch (manager_connect (credentials, &connection, &html,
9813  response_data))
9814  {
9815  case 0:
9816  break;
9817  case -1:
9818  if (html)
9819  return html;
9820  /* Fall through. */
9821  default:
9822  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9823  return gsad_message (credentials,
9824  "Internal error", __FUNCTION__, __LINE__,
9825  "An internal error occurred while cloning a resource. "
9826  "The resource was not cloned. "
9827  "Diagnostics: Failure to connect to manager daemon.",
9828  "/omp?cmd=get_tasks", response_data);
9829  }
9830 
9831  /* Clone the resource. */
9832 
9833  if (alterable && strcmp (alterable, "0"))
9834  {
9835  if (openvas_connection_sendf (&connection,
9836  "<create_%s>"
9837  "<copy>%s</copy>"
9838  "<alterable>1</alterable>"
9839  "</create_%s>",
9840  type,
9841  id,
9842  type)
9843  == -1)
9844  {
9845  openvas_connection_close (&connection);
9846  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9847  return gsad_message (credentials,
9848  "Internal error", __FUNCTION__, __LINE__,
9849  "An internal error occurred while cloning a resource. "
9850  "The resource was not cloned. "
9851  "Diagnostics: Failure to send command to manager daemon.",
9852  "/omp?cmd=get_tasks", response_data);
9853  }
9854  }
9855  else if (openvas_connection_sendf (&connection,
9856  "<create_%s>"
9857  "<copy>%s</copy>"
9858  "</create_%s>",
9859  type,
9860  id,
9861  type)
9862  == -1)
9863  {
9864  openvas_connection_close (&connection);
9865  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9866  return gsad_message (credentials,
9867  "Internal error", __FUNCTION__, __LINE__,
9868  "An internal error occurred while cloning a resource. "
9869  "The resource was not cloned. "
9870  "Diagnostics: Failure to send command to manager daemon.",
9871  "/omp?cmd=get_tasks", response_data);
9872  }
9873 
9874  entity = NULL;
9875  if (read_entity_and_text_c (&connection, &entity, &response))
9876  {
9877  openvas_connection_close (&connection);
9878  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9879  return gsad_message (credentials,
9880  "Internal error", __FUNCTION__, __LINE__,
9881  "An internal error occurred while cloning a resource. "
9882  "It is unclear whether the resource has been cloned or not. "
9883  "Diagnostics: Failure to read response from manager daemon.",
9884  "/omp?cmd=get_tasks", response_data);
9885  }
9886 
9887  openvas_connection_close (&connection);
9888 
9889  /* Cleanup, and return next page. */
9890 
9891  if (omp_success (entity) == 0 || params_given (params, "next") == 0)
9892  {
9893  gchar *next;
9894  next = g_strdup_printf ("get_%ss", type);
9895  params_add (params, "next", next);
9896  g_free (next);
9897  }
9898 
9899  if (omp_success (entity))
9900  {
9901  next_id = entity_attribute (entity, "id");
9902  if (next_id == NULL)
9903  {
9904  free_entity (entity);
9905  g_free (response);
9906  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9907  return gsad_message (credentials,
9908  "Internal error", __FUNCTION__, __LINE__,
9909  "An internal error occurred while cloning a resource. "
9910  "The resource remains the same. "
9911  "Diagnostics: Error getting new resource.",
9912  "/omp?cmd=get_tasks", response_data);
9913  }
9914  next_id_name = g_strdup_printf ("%s_id", type);
9915  params_add (params, next_id_name, next_id);
9916  g_free (next_id_name);
9917  }
9918  else
9919  {
9920  set_http_status_from_entity (entity, response_data);
9921  next_id_name = NULL;
9922  next_id = NULL;
9923  }
9924 
9925  cap_type = capitalize (type);
9926  prev_action = g_strdup_printf ("Clone %s", cap_type);
9927  html = response_from_entity (credentials, params, entity,
9928  (no_redirect && strcmp (no_redirect, "0")),
9929  NULL, NULL,
9930  NULL, NULL,
9931  prev_action, response_data);
9932 
9933  free_entity (entity);
9934  g_free (cap_type);
9935  g_free (prev_action);
9936  g_free (response);
9937 
9938  return html;
9939 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9772
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

void cmd_response_data_init ( cmd_response_data_t data)

Initializes a cmd_response_data_t struct.

Parameters
[in]dataThe cmd_response_data_t struct to initialize

Definition at line 347 of file gsad_omp.c.

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

Referenced by exec_omp_post(), and handle_request().

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

Here is the caller graph for this function:

void cmd_response_data_reset ( cmd_response_data_t data)

Clears a cmd_response_data_t struct.

Parameters
[in]dataStruct to reset.

Definition at line 359 of file gsad_omp.c.

Referenced by exec_omp_post(), and handle_request().

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

Here is the caller graph for this function:

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

Create an agent, get all agents, XSL transform result.

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

Definition at line 7061 of file gsad_omp.c.

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

7063 {
7064  entity_t entity;
7065  gchar *response, *html;
7066  const char *no_redirect;
7067  const char *name, *comment, *installer, *installer_filename, *installer_sig;
7068  const char *howto_install, *howto_use;
7069  int installer_size, installer_sig_size, howto_install_size, howto_use_size;
7070  int ret;
7071  gchar *installer_64, *installer_sig_64, *howto_install_64, *howto_use_64;
7072  gchar *command;
7073 
7074  no_redirect = params_value (params, "no_redirect");
7075  name = params_value (params, "name");
7076  comment = params_value (params, "comment");
7077  installer = params_value (params, "installer");
7078  installer_filename = params_filename (params, "installer");
7079  installer_size = params_value_size (params, "installer");
7080  installer_sig = params_value (params, "installer_sig");
7081  installer_sig_size = params_value_size (params, "installer_sig");
7082  howto_install = params_value (params, "howto_install");
7083  howto_install_size = params_value_size (params, "howto_install");
7084  howto_use = params_value (params, "howto_use");
7085  howto_use_size = params_value_size (params, "howto_use");
7086 
7087  CHECK_PARAM_INVALID (name, "Create Agent", "new_agent");
7088  CHECK_PARAM_INVALID (comment, "Create Agent", "new_agent");
7089 
7090  /* Create the agent. */
7091 
7092  installer_64 = (installer_size > 0)
7093  ? g_base64_encode ((guchar *) installer,
7094  installer_size)
7095  : g_strdup ("");
7096 
7097  installer_sig_64 = (installer_sig_size > 0)
7098  ? g_base64_encode ((guchar *) installer_sig,
7099  installer_sig_size)
7100  : g_strdup ("");
7101 
7102  howto_install_64 = (howto_install_size > 0)
7103  ? g_base64_encode ((guchar *) howto_install,
7104  howto_install_size)
7105  : g_strdup ("");
7106 
7107  howto_use_64 = (howto_use_size > 0)
7108  ? g_base64_encode ((guchar *) howto_use,
7109  howto_use_size)
7110  : g_strdup ("");
7111 
7112  command = g_strdup_printf ("<create_agent>"
7113  "<name>%s</name>"
7114  "%s%s%s"
7115  "<installer>"
7116  "%s"
7117  "<signature>%s</signature>"
7118  "<filename>%s</filename>"
7119  "</installer>"
7120  "<howto_install>%s</howto_install>"
7121  "<howto_use>%s</howto_use>"
7122  "</create_agent>",
7123  name, comment ? "<comment>" : "",
7124  comment ? comment : "",
7125  comment ? "</comment>" : "",
7126  installer_64,
7127  installer_sig_64,
7128  installer_filename ? installer_filename : "",
7129  howto_install_64,
7130  howto_use_64);
7131 
7132  ret = omp (credentials,
7133  &response,
7134  &entity,
7135  response_data,
7136  command);
7137  g_free (command);
7138 
7139  g_free (installer_64);
7140  g_free (howto_install_64);
7141  g_free (howto_use_64);
7142 
7143  switch (ret)
7144  {
7145  case 0:
7146  break;
7147  case -1:
7148  /* 'omp' set response. */
7149  return response;
7150  case 1:
7151  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7152  return gsad_message (credentials,
7153  "Internal error", __FUNCTION__, __LINE__,
7154  "An internal error occurred while creating a new agent. "
7155  "No new agent was created. "
7156  "Diagnostics: Failure to send command to manager daemon.",
7157  "/omp?cmd=get_agents", response_data);
7158  case 2:
7159  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7160  return gsad_message (credentials,
7161  "Internal error", __FUNCTION__, __LINE__,
7162  "An internal error occurred while creating a new agent. "
7163  "It is unclear whether the agent has been created or not. "
7164  "Diagnostics: Failure to receive response from manager daemon.",
7165  "/omp?cmd=get_agents", response_data);
7166  default:
7167  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7168  return gsad_message (credentials,
7169  "Internal error", __FUNCTION__, __LINE__,
7170  "An internal error occurred while creating a new agent. "
7171  "It is unclear whether the agent has been created or not. "
7172  "Diagnostics: Internal Error.",
7173  "/omp?cmd=get_agents", response_data);
7174  }
7175 
7176  if (entity_attribute (entity, "id"))
7177  params_add (params, "agent_id", entity_attribute (entity, "id"));
7178  html = response_from_entity (credentials, params, entity,
7179  (no_redirect && strcmp (no_redirect, "0")),
7180  NULL, "get_agents",
7181  NULL, "new_agent",
7182  "Create Agent", response_data);
7183  free_entity (entity);
7184  g_free (response);
7185  return html;
7186 }
int params_value_size(params_t *params, const char *name)
Get the size of the value of param.
Definition: gsad_base.c:698
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_filename(params_t *params, const char *name)
Get filename of param.
Definition: gsad_base.c:732
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create an alert, get all alerts, XSL transform the result.

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

Definition at line 8347 of file gsad_omp.c.

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

8349 {
8350  int ret;
8351  gchar *html, *response;
8352  const char *no_redirect;
8353  const char *name, *comment, *condition, *event, *method, *filter_id;
8354  params_t *method_data, *event_data, *condition_data;
8355  entity_t entity;
8356  GString *xml;
8357 
8358  no_redirect = params_value (params, "no_redirect");
8359  name = params_value (params, "name");
8360  comment = params_value (params, "comment");
8361  condition = params_value (params, "condition");
8362  event = params_value (params, "event");
8363  method = params_value (params, "method");
8364  filter_id = params_value (params, "filter_id");
8365 
8366  CHECK_PARAM_INVALID (name, "Create Alert", "new_alert");
8367  CHECK_PARAM_INVALID (comment, "Create Alert", "new_alert");
8368  CHECK_PARAM_INVALID (condition, "Create Alert", "new_alert");
8369  CHECK_PARAM_INVALID (event, "Create Alert", "new_alert");
8370  CHECK_PARAM_INVALID (method, "Create Alert", "new_alert");
8371  CHECK_PARAM_INVALID (filter_id, "Create Alert", "new_alert");
8372 
8373  /* Create the alert. */
8374 
8375  method_data = params_values (params, "method_data:");
8376  event_data = params_values (params, "event_data:");
8377  condition_data = params_values (params, "condition_data:");
8378 
8379  xml = g_string_new ("");
8380 
8381  if ((strcmp (event, "New SecInfo arrived") == 0) && event_data)
8382  {
8383  params_iterator_t iter;
8384  char *name;
8385  param_t *param;
8386 
8387  params_iterator_init (&iter, event_data);
8388  while (params_iterator_next (&iter, &name, &param))
8389  if ((strcmp (name, "feed_event") == 0)
8390  && param->value
8391  && (strcmp (param->value, "updated") == 0))
8392  {
8393  event = "Updated SecInfo arrived";
8394  break;
8395  }
8396  }
8397 
8398  xml_string_append (xml,
8399  "<create_alert>"
8400  "<name>%s</name>"
8401  "<filter id=\"%s\"/>"
8402  "<comment>%s</comment>"
8403  "<event>%s",
8404  name,
8405  filter_id,
8406  comment ? comment : "",
8407  event);
8408 
8409  append_alert_event_data (xml, event_data, event);
8410 
8411  xml_string_append (xml,
8412  "</event>"
8413  "<method>%s",
8414  method);
8415 
8416  append_alert_method_data (xml, method_data, method);
8417 
8418  xml_string_append (xml,
8419  "</method>"
8420  "<condition>%s",
8421  condition);
8422 
8423  append_alert_condition_data (xml, condition_data, condition);
8424 
8425  xml_string_append (xml,
8426  "</condition>"
8427  "</create_alert>");
8428 
8429  ret = omp (credentials,
8430  &response,
8431  &entity,
8432  response_data,
8433  xml->str);
8434  g_string_free (xml, TRUE);
8435  switch (ret)
8436  {
8437  case 0:
8438  case -1:
8439  break;
8440  case 1:
8441  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8442  return gsad_message (credentials,
8443  "Internal error", __FUNCTION__, __LINE__,
8444  "An internal error occurred while creating a new alert. "
8445  "No new alert was created. "
8446  "Diagnostics: Failure to send command to manager daemon.",
8447  "/omp?cmd=get_alerts", response_data);
8448  case 2:
8449  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8450  return gsad_message (credentials,
8451  "Internal error", __FUNCTION__, __LINE__,
8452  "An internal error occurred while creating a new alert. "
8453  "It is unclear whether the alert has been created or not. "
8454  "Diagnostics: Failure to receive response from manager daemon.",
8455  "/omp?cmd=get_alerts", response_data);
8456  default:
8457  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
8458  return gsad_message (credentials,
8459  "Internal error", __FUNCTION__, __LINE__,
8460  "An internal error occurred while creating a new alert. "
8461  "It is unclear whether the alert has been created or not. "
8462  "Diagnostics: Internal Error.",
8463  "/omp?cmd=get_alerts", response_data);
8464  }
8465 
8466  if (entity_attribute (entity, "id"))
8467  params_add (params, "alert_id", entity_attribute (entity, "id"));
8468  html = response_from_entity (credentials, params, entity,
8469  (no_redirect && strcmp (no_redirect, "0")),
8470  NULL, "get_alerts",
8471  NULL, "new_alert",
8472  "Create Alert", response_data);
8473  free_entity (entity);
8474  g_free (response);
8475  return html;
8476 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create an asset, get report, XSL transform the result.

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

Definition at line 27504 of file gsad_omp.c.

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

27506 {
27507  char *ret;
27508  gchar *response;
27509  const char *no_redirect, *report_id, *filter;
27510  entity_t entity;
27511 
27512  no_redirect = params_value (params, "no_redirect");
27513  report_id = params_value (params, "report_id");
27514  filter = params_value (params, "filter");
27515 
27516  CHECK_PARAM_INVALID (report_id, "Create Asset", "get_report_section");
27517  CHECK_PARAM_INVALID (filter, "Create Asset", "get_report_section");
27518 
27519  response = NULL;
27520  entity = NULL;
27521  switch (ompf (credentials,
27522  &response,
27523  &entity,
27524  response_data,
27525  "<create_asset>"
27526  "<report id=\"%s\">"
27527  "<filter><term>%s</term></filter>"
27528  "</report>"
27529  "</create_asset>",
27530  report_id,
27531  filter))
27532  {
27533  case 0:
27534  case -1:
27535  break;
27536  case 1:
27537  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27538  return gsad_message (credentials,
27539  "Internal error", __FUNCTION__, __LINE__,
27540  "An internal error occurred while creating an asset. "
27541  "No new asset was created. "
27542  "Diagnostics: Failure to send command to manager daemon.",
27543  "/omp?cmd=get_tasks", response_data);
27544  case 2:
27545  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27546  return gsad_message (credentials,
27547  "Internal error", __FUNCTION__, __LINE__,
27548  "An internal error occurred while creating an asset. "
27549  "It is unclear whether the asset has been created or not. "
27550  "Diagnostics: Failure to receive response from manager daemon.",
27551  "/omp?cmd=get_tasks", response_data);
27552  default:
27553  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27554  return gsad_message (credentials,
27555  "Internal error", __FUNCTION__, __LINE__,
27556  "An internal error occurred while creating an asset. "
27557  "It is unclear whether the asset has been created or not. "
27558  "Diagnostics: Internal Error.",
27559  "/omp?cmd=get_tasks", response_data);
27560  }
27561 
27562  ret = response_from_entity (credentials, params, entity,
27563  (no_redirect && strcmp (no_redirect, "0")),
27564  NULL, "get_report_section",
27565  NULL, "get_report_section",
27566  "Create Asset", response_data);
27567  free_entity (entity);
27568  g_free (response);
27569  return ret;
27570 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Create config, get all configs, XSL transform the result.

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

Definition at line 11648 of file gsad_omp.c.

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

11650 {
11651  gchar *html, *response;
11652  const char *no_redirect, *name, *comment, *base, *scanner = NULL;
11653  entity_t entity;
11654 
11655  no_redirect = params_value (params, "no_redirect");
11656  name = params_value (params, "name");
11657  comment = params_value (params, "comment");
11658  base = params_value (params, "base");
11659 
11660  CHECK_PARAM_INVALID (name, "New Config", "new_config");
11661  CHECK_PARAM_INVALID (comment, "New Config", "new_config");
11662  CHECK_PARAM_INVALID (base, "New Config", "new_config");
11663  if (!strcmp (base, "0"))
11664  {
11665  scanner = params_value (params, "scanner_id");
11666  CHECK_PARAM_INVALID (scanner, "New Config", "new_config");
11667  }
11668 
11669  /* Create the config. */
11670  switch (ompf (credentials,
11671  &response,
11672  &entity,
11673  response_data,
11674  "<create_config>"
11675  "<name>%s</name>"
11676  "<copy>%s</copy>"
11677  "<comment>%s</comment>"
11678  "<scanner>%s</scanner>"
11679  "</create_config>",
11680  name, base, comment,
11681  scanner ?: ""))
11682  {
11683  case 0:
11684  case -1:
11685  break;
11686  case 1:
11687  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11688  return gsad_message (credentials,
11689  "Internal error", __FUNCTION__, __LINE__,
11690  "An internal error occurred while creating a new config. "
11691  "No new config was created. "
11692  "Diagnostics: Failure to send command to manager daemon.",
11693  "/omp?cmd=get_configs", response_data);
11694  case 2:
11695  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11696  return gsad_message (credentials,
11697  "Internal error", __FUNCTION__, __LINE__,
11698  "An internal error occurred while creating a new config. "
11699  "It is unclear whether the config has been created or not. "
11700  "Diagnostics: Failure to receive response from manager daemon.",
11701  "/omp?cmd=get_configs", response_data);
11702  default:
11703  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11704  return gsad_message (credentials,
11705  "Internal error", __FUNCTION__, __LINE__,
11706  "An internal error occurred while creating a new config. "
11707  "It is unclear whether the config has been created or not. "
11708  "Diagnostics: Internal Error.",
11709  "/omp?cmd=get_configs", response_data);
11710  }
11711 
11712  if (entity_attribute (entity, "id"))
11713  params_add (params, "config_id", entity_attribute (entity, "id"));
11714  html = response_from_entity (credentials, params, entity,
11715  (no_redirect && strcmp (no_redirect, "0")),
11716  NULL, "get_configs",
11717  NULL, "new_config",
11718  "Create Config", response_data);
11719 
11720  free_entity (entity);
11721  g_free (response);
11722  return html;
11723 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_container_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a container task, serve next page.

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

Definition at line 4134 of file gsad_omp.c.

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

4136 {
4137  entity_t entity;
4138  int ret;
4139  gchar *command, *html, *response;
4140  const char *no_redirect, *name, *comment;
4141 
4142  no_redirect = params_value (params, "no_redirect");
4143  name = params_value (params, "name");
4144  comment = params_value (params, "comment");
4145  CHECK_PARAM_INVALID (name, "Create Container Task", "new_container_task");
4146  CHECK_PARAM_INVALID (comment, "Create Container Task", "new_container_task");
4147 
4148  command = g_strdup_printf ("<create_task>"
4149  "<target id=\"0\"/>"
4150  "<name>%s</name>"
4151  "<comment>%s</comment>"
4152  "</create_task>",
4153  name,
4154  comment);
4155  ret = omp (credentials,
4156  &response,
4157  &entity,
4158  response_data,
4159  command);
4160  g_free (command);
4161 
4162  switch (ret)
4163  {
4164  case 0:
4165  break;
4166  case -1:
4167  /* 'omp' set response. */
4168  return response;
4169  case 1:
4170  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4171  return gsad_message (credentials,
4172  "Internal error", __FUNCTION__, __LINE__,
4173  "An internal error occurred while creating a container task. "
4174  "No task was created. "
4175  "Diagnostics: Failure to send command to manager daemon.",
4176  "/omp?cmd=get_tasks", response_data);
4177  case 2:
4178  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4179  return gsad_message (credentials,
4180  "Internal error", __FUNCTION__, __LINE__,
4181  "An internal error occurred while creating a container task. "
4182  "It is unclear whether the task has been created or not. "
4183  "Diagnostics: Failure to receive response from manager daemon.",
4184  "/omp?cmd=get_tasks", response_data);
4185  default:
4186  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4187  return gsad_message (credentials,
4188  "Internal error", __FUNCTION__, __LINE__,
4189  "An internal error occurred while creating a container task. "
4190  "It is unclear whether the task has been created or not. "
4191  "Diagnostics: Internal Error.",
4192  "/omp?cmd=get_tasks", response_data);
4193  }
4194 
4195  if (entity_attribute (entity, "id"))
4196  params_add (params, "task_id", entity_attribute (entity, "id"));
4197  html = response_from_entity (credentials, params, entity,
4198  (no_redirect && strcmp (no_redirect, "0")),
4199  NULL, "get_tasks",
4200  NULL, "new_container_task",
4201  "Create Container Task", response_data);
4202  free_entity (entity);
4203  g_free (response);
4204  return html;
4205 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a credential, get all credentials, XSL transform result.

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

Definition at line 6110 of file gsad_omp.c.

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

6112 {
6113  int ret;
6114  gchar *html, *response;
6115  const char *no_redirect;
6116  const char *name, *comment, *login, *type, *password, *passphrase;
6117  const char *private_key, *certificate, *community, *privacy_password;
6118  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6119  int autogenerate;
6120  entity_t entity;
6121 
6122  no_redirect = params_value (params, "no_redirect");
6123  name = params_value (params, "name");
6124  comment = params_value (params, "comment");
6125  login = params_value (params, "credential_login");
6126  type = params_value (params, "base");
6127  password = params_value (params, "lsc_password");
6128  passphrase = params_value (params, "passphrase");
6129  private_key = params_value (params, "private_key");
6130  certificate = params_value (params, "certificate");
6131  community = params_value (params, "community");
6132  privacy_password = params_value (params, "privacy_password");
6133  auth_algorithm = params_value (params, "auth_algorithm");
6134  privacy_algorithm = params_value (params, "privacy_algorithm");
6135  allow_insecure = params_value (params, "allow_insecure");
6136 
6137  if (params_value (params, "autogenerate"))
6138  autogenerate = strcmp (params_value (params, "autogenerate"), "0");
6139  else
6140  return message_invalid (credentials, params, response_data,
6141  "Given autogenerate was invalid",
6142  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
6143  "Create Credential", "new_credential");
6144 
6145  CHECK_PARAM_INVALID (name, "Create Credential", "new_credential");
6146  CHECK_PARAM_INVALID (comment, "Create Credential", "new_credential");
6147  CHECK_PARAM_INVALID (type, "Create Credential", "new_credential");
6148  CHECK_PARAM_INVALID (allow_insecure, "Create Credential", "new_credential");
6149 
6150  if (autogenerate)
6151  {
6152  if (type && (strcmp (type, "cc") == 0))
6153  {
6154  // Auto-generate types without username
6155  ret = ompf (credentials,
6156  &response,
6157  &entity,
6158  response_data,
6159  "<create_credential>"
6160  "<name>%s</name>"
6161  "<comment>%s</comment>"
6162  "<type>%s</type>"
6163  "<allow_insecure>%s</allow_insecure>"
6164  "</create_credential>",
6165  name,
6166  comment ? comment : "",
6167  type,
6168  allow_insecure);
6169  }
6170  else
6171  {
6172  // Auto-generate types with username
6173  CHECK_PARAM_INVALID (login, "Create Credential", "new_credential");
6174 
6175  ret = ompf (credentials,
6176  &response,
6177  &entity,
6178  response_data,
6179  "<create_credential>"
6180  "<name>%s</name>"
6181  "<comment>%s</comment>"
6182  "<type>%s</type>"
6183  "<login>%s</login>"
6184  "<allow_insecure>%s</allow_insecure>"
6185  "</create_credential>",
6186  name,
6187  comment ? comment : "",
6188  type,
6189  login,
6190  allow_insecure);
6191  }
6192  }
6193  else
6194  {
6195  if (type && (strcmp (type, "up") == 0))
6196  {
6197  CHECK_PARAM_INVALID (login,
6198  "Create Credential", "new_credential");
6199  CHECK_PARAM_INVALID (password,
6200  "Create Credential", "new_credential");
6201 
6202  ret = ompf (credentials,
6203  &response,
6204  &entity,
6205  response_data,
6206  "<create_credential>"
6207  "<name>%s</name>"
6208  "<comment>%s</comment>"
6209  "<type>%s</type>"
6210  "<login>%s</login>"
6211  "<password>%s</password>"
6212  "<allow_insecure>%s</allow_insecure>"
6213  "</create_credential>",
6214  name,
6215  comment ? comment : "",
6216  type,
6217  login ? login : "",
6218  password ? password : "",
6219  allow_insecure);
6220  }
6221  else if (type && (strcmp (type, "usk") == 0))
6222  {
6223  CHECK_PARAM_INVALID (login,
6224  "Create Credential", "new_credential");
6225  CHECK_PARAM_INVALID (passphrase,
6226  "Create Credential", "new_credential");
6227  CHECK_PARAM_INVALID (private_key,
6228  "Create Credential", "new_credential");
6229 
6230  ret = ompf (credentials,
6231  &response,
6232  &entity,
6233  response_data,
6234  "<create_credential>"
6235  "<name>%s</name>"
6236  "<comment>%s</comment>"
6237  "<type>%s</type>"
6238  "<login>%s</login>"
6239  "<key>"
6240  "<private>%s</private>"
6241  "<phrase>%s</phrase>"
6242  "</key>"
6243  "<allow_insecure>%s</allow_insecure>"
6244  "</create_credential>",
6245  name,
6246  comment ? comment : "",
6247  type,
6248  login ? login : "",
6249  private_key ? private_key : "",
6250  passphrase ? passphrase : "",
6251  allow_insecure);
6252  }
6253  else if (type && (strcmp (type, "cc") == 0))
6254  {
6255  CHECK_PARAM_INVALID (certificate,
6256  "Create Credential", "new_credential");
6257  CHECK_PARAM_INVALID (private_key,
6258  "Create Credential", "new_credential");
6259 
6260  ret = ompf (credentials,
6261  &response,
6262  &entity,
6263  response_data,
6264  "<create_credential>"
6265  "<name>%s</name>"
6266  "<comment>%s</comment>"
6267  "<type>%s</type>"
6268  "<certificate>%s</certificate>"
6269  "<key>"
6270  "<private>%s</private>"
6271  "</key>"
6272  "<allow_insecure>%s</allow_insecure>"
6273  "</create_credential>",
6274  name,
6275  comment ? comment : "",
6276  type,
6277  certificate ? certificate : "",
6278  private_key ? private_key : "",
6279  allow_insecure);
6280 
6281  }
6282  else if (type && (strcmp (type, "snmp") == 0))
6283  {
6284  CHECK_PARAM_INVALID (community,
6285  "Create Credential", "new_credential");
6286  CHECK_PARAM_INVALID (login,
6287  "Create Credential", "new_credential");
6288  CHECK_PARAM_INVALID (password,
6289  "Create Credential", "new_credential");
6290  CHECK_PARAM_INVALID (privacy_password,
6291  "Create Credential", "new_credential");
6292  CHECK_PARAM_INVALID (auth_algorithm,
6293  "Create Credential", "new_credential");
6294  CHECK_PARAM_INVALID (privacy_algorithm,
6295  "Create Credential", "new_credential");
6296 
6297  if (privacy_password && strcmp (privacy_password, ""))
6298  ret = ompf (credentials,
6299  &response,
6300  &entity,
6301  response_data,
6302  "<create_credential>"
6303  "<name>%s</name>"
6304  "<comment>%s</comment>"
6305  "<type>%s</type>"
6306  "<community>%s</community>"
6307  "<login>%s</login>"
6308  "<password>%s</password>"
6309  "<privacy>"
6310  "<password>%s</password>"
6311  "<algorithm>%s</algorithm>"
6312  "</privacy>"
6313  "<auth_algorithm>%s</auth_algorithm>"
6314  "<allow_insecure>%s</allow_insecure>"
6315  "</create_credential>",
6316  name,
6317  comment ? comment : "",
6318  type,
6319  community ? community : "",
6320  login ? login : "",
6321  password ? password : "",
6322  privacy_password ? privacy_password : "",
6323  privacy_algorithm ? privacy_algorithm : "",
6324  auth_algorithm ? auth_algorithm : "",
6325  allow_insecure);
6326  else
6327  ret = ompf (credentials,
6328  &response,
6329  &entity,
6330  response_data,
6331  "<create_credential>"
6332  "<name>%s</name>"
6333  "<comment>%s</comment>"
6334  "<type>%s</type>"
6335  "<community>%s</community>"
6336  "<login>%s</login>"
6337  "<password>%s</password>"
6338  "<auth_algorithm>%s</auth_algorithm>"
6339  "<allow_insecure>%s</allow_insecure>"
6340  "</create_credential>",
6341  name,
6342  comment ? comment : "",
6343  type,
6344  community ? community : "",
6345  login ? login : "",
6346  password ? password : "",
6347  auth_algorithm ? auth_algorithm : "",
6348  allow_insecure);
6349  }
6350  else
6351  {
6352  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6353  return gsad_message (credentials,
6354  "Internal error", __FUNCTION__, __LINE__,
6355  "An internal error occurred while creating a new credential. "
6356  "The credential could not be created. "
6357  "Diagnostics: Unrecognized credential type.",
6358  "/omp?cmd=get_credentials", response_data);
6359  }
6360  }
6361 
6362  /* Create the credential. */
6363  switch (ret)
6364  {
6365  case 0:
6366  case -1:
6367  break;
6368  case 1:
6369  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6370  return gsad_message (credentials,
6371  "Internal error", __FUNCTION__, __LINE__,
6372  "An internal error occurred while creating a new credential. "
6373  "It is unclear whether the credential has been created or not. "
6374  "Diagnostics: Failure to send command to manager daemon.",
6375  "/omp?cmd=get_credentials", response_data);
6376  case 2:
6377  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6378  return gsad_message (credentials,
6379  "Internal error", __FUNCTION__, __LINE__,
6380  "An internal error occurred while creating a new credential. "
6381  "It is unclear whether the credential has been created or not. "
6382  "Diagnostics: Failure to receive response from manager daemon.",
6383  "/omp?cmd=get_credentials", response_data);
6384  default:
6385  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6386  return gsad_message (credentials,
6387  "Internal error", __FUNCTION__, __LINE__,
6388  "An internal error occurred while creating a new credential. "
6389  "It is unclear whether the credential has been created or not. "
6390  "Diagnostics: Internal Error.",
6391  "/omp?cmd=get_credentials", response_data);
6392  }
6393 
6394  if (entity_attribute (entity, "id"))
6395  params_add (params, "credential_id", entity_attribute (entity, "id"));
6396  html = response_from_entity (credentials, params, entity,
6397  (no_redirect && strcmp (no_redirect, "0")),
6398  NULL, "get_credentials",
6399  NULL, "new_credential",
6400  "Create Credential",
6401  response_data);
6402  free_entity (entity);
6403  g_free (response);
6404  return html;
6405 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a filter, get all filters, XSL transform the result.

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

Definition at line 24302 of file gsad_omp.c.

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

24304 {
24305  gchar *html, *response;
24306  const char *no_redirect, *name, *comment, *term, *type;
24307  entity_t entity;
24308 
24309  no_redirect = params_value (params, "no_redirect");
24310  name = params_value (params, "name");
24311  comment = params_value (params, "comment");
24312  term = params_value (params, "term");
24313  type = params_value (params, "optional_resource_type");
24314 
24315  CHECK_PARAM_INVALID (name, "Create Filter", "new_filter");
24316  CHECK_PARAM_INVALID (comment, "Create Filter", "new_filter");
24317  CHECK_PARAM_INVALID (term, "Create Filter", "new_filter");
24318  CHECK_PARAM_INVALID (type, "Create Filter", "new_filter");
24319 
24320  switch (ompf (credentials,
24321  &response,
24322  &entity,
24323  response_data,
24324  "<create_filter>"
24325  "<name>%s</name>"
24326  "<comment>%s</comment>"
24327  "<term>%s</term>"
24328  "<type>%s</type>"
24329  "</create_filter>",
24330  name,
24331  comment,
24332  term,
24333  type))
24334  {
24335  case 0:
24336  case -1:
24337  break;
24338  case 1:
24339  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24340  return gsad_message (credentials,
24341  "Internal error", __FUNCTION__, __LINE__,
24342  "An internal error occurred while creating a new alert. "
24343  "No new alert was created. "
24344  "Diagnostics: Failure to send command to manager daemon.",
24345  "/omp?cmd=get_alerts", response_data);
24346  case 2:
24347  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24348  return gsad_message (credentials,
24349  "Internal error", __FUNCTION__, __LINE__,
24350  "An internal error occurred while creating a new alert. "
24351  "It is unclear whether the alert has been created or not. "
24352  "Diagnostics: Failure to receive response from manager daemon.",
24353  "/omp?cmd=get_alerts", response_data);
24354  default:
24355  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24356  return gsad_message (credentials,
24357  "Internal error", __FUNCTION__, __LINE__,
24358  "An internal error occurred while creating a new alert. "
24359  "It is unclear whether the alert has been created or not. "
24360  "Diagnostics: Internal Error.",
24361  "/omp?cmd=get_alerts", response_data);
24362  }
24363 
24364  if (omp_success (entity))
24365  {
24366  const char *filter_id;
24367 
24368  filter_id = entity_attribute (entity, "id");
24369  if (filter_id && strlen (filter_id))
24370  {
24371  param_t *param;
24372  param = params_add (params, "filt_id", filter_id);
24373  param->valid = 1;
24374  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
24375  }
24376  }
24377 
24378  if (entity_attribute (entity, "id"))
24379  params_add (params, "filter_id", entity_attribute (entity, "id"));
24380  html = response_from_entity (credentials, params, entity,
24381  (no_redirect && strcmp (no_redirect, "0")),
24382  NULL, "get_filters",
24383  NULL, "new_filter",
24384  "Create Filter", response_data);
24385  free_entity (entity);
24386  g_free (response);
24387  return html;
24388 }
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int valid_utf8
Definition: gsad_base.h:151
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int valid
Definition: gsad_base.h:150
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a group, get all groups, XSL transform the result.

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

Definition at line 20814 of file gsad_omp.c.

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

20816 {
20817  gchar *html, *response, *command, *specials_element;
20818  const char *no_redirect, *name, *comment, *users, *grant_full;
20819  entity_t entity;
20820  GString *xml;
20821  int ret;
20822 
20823  no_redirect = params_value (params, "no_redirect");
20824  name = params_value (params, "name");
20825  comment = params_value (params, "comment");
20826  grant_full = params_value (params, "grant_full");
20827  users = params_value (params, "users");
20828 
20829  CHECK_PARAM_INVALID (name, "Create Group", "new_group");
20830  CHECK_PARAM_INVALID (comment, "Create Group", "new_group");
20831  CHECK_PARAM_INVALID (users, "Create Group", "new_group");
20832 
20833  /* Create the group. */
20834 
20835  xml = g_string_new ("");
20836 
20837  xml_string_append (xml,
20838  "<name>%s</name>"
20839  "<comment>%s</comment>"
20840  "<users>%s</users>",
20841  name,
20842  comment,
20843  users);
20844 
20845  if (grant_full)
20846  specials_element = g_strdup_printf ("<full/>");
20847  else
20848  specials_element = NULL;
20849 
20850  command = g_strdup_printf ("<create_group>"
20851  "%s"
20852  "<specials>"
20853  "%s"
20854  "</specials>"
20855  "</create_group>",
20856  xml->str,
20857  specials_element);
20858 
20859  g_string_free (xml, TRUE);
20860  g_free (specials_element);
20861 
20862  ret = omp (credentials, &response, &entity, response_data, command);
20863  g_free (command);
20864  switch (ret)
20865  {
20866  case 0:
20867  case -1:
20868  break;
20869  case 1:
20870  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20871  return gsad_message (credentials,
20872  "Internal error", __FUNCTION__, __LINE__,
20873  "An internal error occurred while creating a new group. "
20874  "No new group was created. "
20875  "Diagnostics: Failure to send command to manager daemon.",
20876  "/omp?cmd=get_groups", response_data);
20877  case 2:
20878  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20879  return gsad_message (credentials,
20880  "Internal error", __FUNCTION__, __LINE__,
20881  "An internal error occurred while creating a new group. "
20882  "It is unclear whether the group has been created or not. "
20883  "Diagnostics: Failure to receive response from manager daemon.",
20884  "/omp?cmd=get_groups", response_data);
20885  default:
20886  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20887  return gsad_message (credentials,
20888  "Internal error", __FUNCTION__, __LINE__,
20889  "An internal error occurred while creating a new group. "
20890  "It is unclear whether the group has been created or not. "
20891  "Diagnostics: Internal Error.",
20892  "/omp?cmd=get_groups", response_data);
20893  }
20894 
20895  if (entity_attribute (entity, "id"))
20896  params_add (params, "group_id", entity_attribute (entity, "id"));
20897  html = response_from_entity (credentials, params, entity,
20898  (no_redirect && strcmp (no_redirect, "0")),
20899  NULL, "get_groups",
20900  NULL, "new_group",
20901  "Create Group", response_data);
20902  free_entity (entity);
20903  g_free (response);
20904  return html;
20905 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* create_host_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Create a host, serve next page.

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

Definition at line 27244 of file gsad_omp.c.

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

27246 {
27247  int ret;
27248  gchar *html, *response;
27249  const char *no_redirect, *name, *comment;
27250  entity_t entity;
27251  GString *xml;
27252 
27253  no_redirect = params_value (params, "no_redirect");
27254 
27255  name = params_value (params, "name");
27256  CHECK_PARAM_INVALID (name, "Create Host", "new_host");
27257 
27258  comment = params_value (params, "comment");
27259  CHECK_PARAM_INVALID (comment, "Create Host", "new_host");
27260 
27261  /* Create the host. */
27262 
27263  xml = g_string_new ("");
27264 
27265  xml_string_append (xml,
27266  "<create_asset>"
27267  "<asset>"
27268  "<type>host</type>"
27269  "<name>%s</name>"
27270  "<comment>%s</comment>"
27271  "</asset>"
27272  "</create_asset>",
27273  name,
27274  comment);
27275 
27276  ret = omp (credentials,
27277  &response,
27278  &entity,
27279  response_data,
27280  xml->str);
27281  g_string_free (xml, TRUE);
27282  switch (ret)
27283  {
27284  case 0:
27285  case -1:
27286  break;
27287  case 1:
27288  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27289  return gsad_message (credentials,
27290  "Internal error", __FUNCTION__, __LINE__,
27291  "An internal error occurred while creating a new host. "
27292  "No new host was created. "
27293  "Diagnostics: Failure to send command to manager daemon.",
27294  "/omp?cmd=get_assets", response_data);
27295  case 2:
27296  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27297  return gsad_message (credentials,
27298  "Internal error", __FUNCTION__, __LINE__,
27299  "An internal error occurred while creating a new host. "
27300  "It is unclear whether the host has been created or not. "
27301  "Diagnostics: Failure to receive response from manager daemon.",
27302  "/omp?cmd=get_assets", response_data);
27303  default:
27304  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27305  return gsad_message (credentials,
27306  "Internal error", __FUNCTION__, __LINE__,
27307  "An internal error occurred while creating a new host. "
27308  "It is unclear whether the host has been created or not. "
27309  "Diagnostics: Internal Error.",
27310  "/omp?cmd=get_assets", response_data);
27311  }
27312 
27313  if (entity_attribute (entity, "id"))
27314  params_add (params, "asset_id", entity_attribute (entity, "id"));
27315  html = response_from_entity (credentials, params, entity,
27316  (no_redirect && strcmp (no_redirect, "0")),
27317  NULL, "get_assets",
27318  NULL, "new_host",
27319  "Create Host", response_data);
27320  free_entity (entity);
27321  g_free (response);
27322  return html;
27323 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a note, get report, XSL transform the result.

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

Definition at line 15942 of file gsad_omp.c.

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

15944 {
15945  char *ret;
15946  gchar *response;
15947  const char *no_redirect, *oid, *severity, *port, *hosts;
15948  const char *text, *task_id, *note_result_id;
15949  /* For get_report. */
15950  const char *active, *days;
15951  entity_t entity;
15952 
15953  no_redirect = params_value (params, "no_redirect");
15954  oid = params_value (params, "oid");
15955  CHECK_PARAM_INVALID (oid, "Create Note", "new_note");
15956 
15957  if (params_valid (params, "severity"))
15958  severity = params_value (params, "severity");
15959  else if (params_given (params, "severity")
15960  && strcmp (params_original_value (params, "severity"), ""))
15961  severity = NULL;
15962  else
15963  severity = "";
15964  CHECK_PARAM_INVALID (severity, "Create Note", "new_note");
15965 
15966  port = params_value (params, "port");
15967  if (port == NULL)
15968  port = "";
15969  if (strcmp (port, "--") == 0)
15970  {
15971  int num = -1;
15972 
15973  port = params_value (params, "port_manual");
15974  if (port)
15975  num = atoi (port);
15976  if (num < 0 || num > 65535)
15977  port = NULL;
15978  }
15979  CHECK_PARAM_INVALID (port, "Create Note", "new_note");
15980 
15981  if (params_valid (params, "hosts"))
15982  {
15983  hosts = params_value (params, "hosts");
15984  if (strcmp (hosts, "--") == 0)
15985  {
15986  if (params_valid (params, "hosts_manual"))
15987  hosts = params_value (params, "hosts_manual");
15988  else if (params_given (params, "hosts_manual")
15989  && strcmp (params_original_value (params, "hosts_manual"),
15990  ""))
15991  hosts = NULL;
15992  else
15993  hosts = "";
15994  }
15995  }
15996  else if (strcmp (params_original_value (params, "hosts"), ""))
15997  hosts = NULL;
15998  else
15999  hosts = "";
16000  CHECK_PARAM_INVALID (hosts, "Create Note", "new_note");
16001 
16002  if (params_valid (params, "note_task_id"))
16003  {
16004  task_id = params_value (params, "note_task_id");
16005  if (task_id && (strcmp (task_id, "0") == 0))
16006  task_id = params_value (params, "note_task_uuid");
16007  }
16008  else if (params_given (params, "note_task_id")
16009  && strcmp (params_original_value (params, "note_task_id"), ""))
16010  task_id = NULL;
16011  else
16012  task_id = "";
16013 
16014  active = params_value (params, "active");
16015  CHECK_PARAM_INVALID (active, "Create Note", "new_note");
16016 
16017  text = params_value (params, "text");
16018  days = params_value (params, "days");
16019 
16020  note_result_id = params_value (params, "note_result_id");
16021  if (note_result_id && (strcmp (note_result_id, "0") == 0))
16022  note_result_id = params_value (params, "note_result_uuid");
16023 
16024  response = NULL;
16025  entity = NULL;
16026  switch (ompf (credentials,
16027  &response,
16028  &entity,
16029  response_data,
16030  "<create_note>"
16031  "<active>%s</active>"
16032  "<nvt oid=\"%s\"/>"
16033  "<hosts>%s</hosts>"
16034  "<port>%s</port>"
16035  "<severity>%s</severity>"
16036  "<text>%s</text>"
16037  "<task id=\"%s\"/>"
16038  "<result id=\"%s\"/>"
16039  "</create_note>",
16040  strcmp (active, "1")
16041  ? active
16042  : (days ? days : "-1"),
16043  oid,
16044  hosts,
16045  port,
16046  severity,
16047  text ? text : "",
16048  task_id,
16049  note_result_id))
16050  {
16051  case 0:
16052  case -1:
16053  break;
16054  case 1:
16055  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16056  return gsad_message (credentials,
16057  "Internal error", __FUNCTION__, __LINE__,
16058  "An internal error occurred while creating a new note. "
16059  "No new note was created. "
16060  "Diagnostics: Failure to send command to manager daemon.",
16061  "/omp?cmd=get_notes", response_data);
16062  case 2:
16063  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16064  return gsad_message (credentials,
16065  "Internal error", __FUNCTION__, __LINE__,
16066  "An internal error occurred while creating a new note. "
16067  "It is unclear whether the note has been created or not. "
16068  "Diagnostics: Failure to receive response from manager daemon.",
16069  "/omp?cmd=get_notes", response_data);
16070  default:
16071  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16072  return gsad_message (credentials,
16073  "Internal error", __FUNCTION__, __LINE__,
16074  "An internal error occurred while creating a new note. "
16075  "It is unclear whether the note has been created or not. "
16076  "Diagnostics: Internal Error.",
16077  "/omp?cmd=get_notes", response_data);
16078  }
16079 
16080  if (entity_attribute (entity, "id"))
16081  params_add (params, "note_id", entity_attribute (entity, "id"));
16082  ret = response_from_entity (credentials, params, entity,
16083  (no_redirect && strcmp (no_redirect, "0")),
16084  NULL, "get_notes",
16085  NULL, "new_note",
16086  "Create Note", response_data);
16087  free_entity (entity);
16088  g_free (response);
16089  return ret;
16090 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

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

Create an override, get report, XSL transform the result.

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

Definition at line 16658 of file gsad_omp.c.

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

16660 {
16661  char *ret;
16662  gchar *response;
16663  const char *no_redirect;
16664  const char *oid, *severity, *custom_severity, *new_severity, *port, *hosts;
16665  const char *text, *task_id, *override_result_id;
16666  /* For get_report. */
16667  const char *active, *days;
16668  entity_t entity;
16669 
16670  no_redirect = params_value (params, "no_redirect");
16671  oid = params_value (params, "oid");
16672  CHECK_PARAM_INVALID (oid, "Create Override", "new_override");
16673 
16674  if (params_valid (params, "severity"))
16675  severity = params_value (params, "severity");
16676  else if (params_given (params, "severity")
16677  && strcmp (params_original_value (params, "severity"), ""))
16678  severity = NULL;
16679  else
16680  severity = "";
16681  CHECK_PARAM_INVALID (severity, "Create Override", "new_override");
16682 
16683  custom_severity = params_value (params, "custom_severity");
16684  CHECK_PARAM_INVALID (custom_severity, "Create Override", "new_override");
16685 
16686  if (custom_severity != NULL && strcmp (custom_severity, "0"))
16687  {
16688  if (params_valid (params, "new_severity"))
16689  new_severity = params_value (params, "new_severity");
16690  else if (params_original_value (params, "new_severity") == NULL
16691  || strcmp (params_original_value (params, "new_severity"), ""))
16692  new_severity = NULL;
16693  else
16694  new_severity = "";
16695  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16696  }
16697  else
16698  {
16699  if (params_valid (params, "new_severity_from_list"))
16700  new_severity = params_value (params, "new_severity_from_list");
16701  else if (params_original_value (params, "new_severity_from_list") == NULL
16702  || strcmp (params_original_value (params,
16703  "new_severity_from_list"),
16704  ""))
16705  new_severity = NULL;
16706  else
16707  new_severity = "";
16708  CHECK_PARAM_INVALID (new_severity, "Create Override", "new_override");
16709  }
16710 
16711  port = params_value (params, "port");
16712  if (port == NULL)
16713  port = "";
16714  if (strcmp (port, "--") == 0)
16715  {
16716  int num = -1;
16717 
16718  port = params_value (params, "port_manual");
16719  if (port)
16720  num = atoi (port);
16721  if (num < 0 || num > 65535)
16722  port = NULL;
16723  }
16724  CHECK_PARAM_INVALID (port, "Create Override", "new_override");
16725 
16726  if (params_valid (params, "hosts"))
16727  {
16728  hosts = params_value (params, "hosts");
16729  if (strcmp (hosts, "--") == 0)
16730  {
16731  if (params_valid (params, "hosts_manual"))
16732  hosts = params_value (params, "hosts_manual");
16733  else if (params_given (params, "hosts_manual")
16734  && strcmp (params_original_value (params, "hosts_manual"),
16735  ""))
16736  hosts = NULL;
16737  else
16738  hosts = "";
16739  }
16740  }
16741  else if (strcmp (params_original_value (params, "hosts"), ""))
16742  hosts = NULL;
16743  else
16744  hosts = "";
16745  CHECK_PARAM_INVALID (hosts, "Create Override", "new_override");
16746 
16747  if (params_valid (params, "override_task_id"))
16748  {
16749  task_id = params_value (params, "override_task_id");
16750  if (task_id && (strcmp (task_id, "0") == 0))
16751  task_id = params_value (params, "override_task_uuid");
16752  }
16753  else
16754  task_id = "";
16755 
16756  active = params_value (params, "active");
16757  CHECK_PARAM_INVALID (active, "Create Override", "new_override");
16758 
16759  text = params_value (params, "text");
16760  days = params_value (params, "days");
16761 
16762  override_result_id = params_value (params, "override_result_id");
16763  if (override_result_id && (strcmp (override_result_id, "0") == 0))
16764  override_result_id = params_value (params, "override_result_uuid");
16765 
16766  response = NULL;
16767  entity = NULL;
16768  switch (ompf (credentials,
16769  &response,
16770  &entity,
16771  response_data,
16772  "<create_override>"
16773  "<active>%s</active>"
16774  "<nvt oid=\"%s\"/>"
16775  "<hosts>%s</hosts>"
16776  "<port>%s</port>"
16777  "<severity>%s</severity>"
16778  "<new_severity>%s</new_severity>"
16779  "<text>%s</text>"
16780  "<task id=\"%s\"/>"
16781  "<result id=\"%s\"/>"
16782  "</create_override>",
16783  strcmp (active, "1")
16784  ? active
16785  : (days ? days : "-1"),
16786  oid,
16787  hosts,
16788  port,
16789  severity,
16790  new_severity,
16791  text ? text : "",
16792  task_id,
16793  override_result_id))
16794  {
16795  case 0:
16796  case -1:
16797  break;
16798  case 1:
16799  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16800  return gsad_message (credentials,
16801  "Internal error", __FUNCTION__, __LINE__,
16802  "An internal error occurred while creating a new override. "
16803  "No new override was created. "
16804  "Diagnostics: Failure to send command to manager daemon.",
16805  "/omp?cmd=get_overrides", response_data);
16806  case 2:
16807  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16808  return gsad_message (credentials,
16809  "Internal error", __FUNCTION__, __LINE__,
16810  "An internal error occurred while creating a new override. "
16811  "It is unclear whether the override has been created or not. "
16812  "Diagnostics: Failure to receive response from manager daemon.",
16813  "/omp?cmd=get_overrides", response_data);
16814  default:
16815  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16816  return gsad_message (credentials,
16817  "Internal error", __FUNCTION__, __LINE__,
16818  "An internal error occurred while creating a new override. "
16819  "It is unclear whether the override has been created or not. "
16820  "Diagnostics: Internal Error.",
16821  "/omp?cmd=get_overrides", response_data);
16822  }
16823 
16824  if (entity_attribute (entity, "id"))
16825  params_add (params, "override_id", entity_attribute (entity, "id"));
16826  ret = response_from_entity (credentials, params, entity,
16827  (no_redirect && strcmp (no_redirect, "0")),
16828  NULL, "get_overrides",
16829  NULL, "new_override",
16830  "Create Override", response_data);
16831  free_entity (entity);
16832  g_free (response);
16833  return ret;
16834 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

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

Create a permission, get all permissions, XSL transform the result.

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

Definition at line 21365 of file gsad_omp.c.

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

21367 {
21368  int ret;
21369  gchar *html, *response;
21370  const char *no_redirect, *name, *comment, *resource_id, *resource_type;
21371  const char *subject_id, *subject_type, *subject_name;
21372  entity_t entity;
21373 
21374  gchar *subject_response;
21375  entity_t get_subject_entity = NULL;
21376  entity_t subject_entity;
21377 
21378  no_redirect = params_value (params, "no_redirect");
21379  name = params_value (params, "permission");
21380  comment = params_value (params, "comment");
21381  resource_id = params_value (params, "id_or_empty");
21382  resource_type = params_value (params, "optional_resource_type");
21383  subject_type = params_value (params, "subject_type");
21384  subject_name = params_value (params, "subject_name");
21385 
21386  CHECK_PARAM_INVALID (name, "Create Permission", "new_permission");
21387  CHECK_PARAM_INVALID (comment, "Create Permission", "new_permission");
21388  if (params_given (params, "id_or_empty"))
21389  CHECK_PARAM_INVALID (resource_id, "Create Permission", "new_permission");
21390  CHECK_PARAM_INVALID (subject_type, "Create Permission", "new_permission");
21391  if (params_given (params, "optional_resource_type"))
21392  CHECK_PARAM_INVALID (resource_type, "Create Permission", "new_permission");
21393 
21394  if (params_given (params, "subject_name"))
21395  {
21396  CHECK_PARAM_INVALID (subject_name,
21397  "Create Permission", "new_permission");
21398  subject_id = NULL;
21399  ret = ompf (credentials,
21400  &subject_response,
21401  &get_subject_entity,
21402  response_data,
21403  "<get_%ss filter=\"rows=1 name=%s\">"
21404  "</get_%ss>",
21405  subject_type,
21406  subject_name,
21407  subject_type);
21408 
21409  switch (ret)
21410  {
21411  case 0:
21412  case -1:
21413  break;
21414  case 1:
21415  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21416  return gsad_message (credentials,
21417  "Internal error", __FUNCTION__, __LINE__,
21418  "An internal error occurred while getting"
21419  " the subject for a permission. "
21420  "The permission was not created. "
21421  "Diagnostics: Failure to send command"
21422  " to manager daemon.",
21423  "/omp?cmd=get_permissions", response_data);
21424  case 2:
21425  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21426  return gsad_message (credentials,
21427  "Internal error", __FUNCTION__, __LINE__,
21428  "An internal error occurred while getting"
21429  " the subject for a permission. "
21430  "The permission was not created. "
21431  "Diagnostics: Failure to receive response"
21432  " from manager daemon.",
21433  "/omp?cmd=get_permissions", response_data);
21434  default:
21435  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21436  return gsad_message (credentials,
21437  "Internal error", __FUNCTION__, __LINE__,
21438  "An internal error occurred while getting"
21439  " the subject for a permission. "
21440  "The permission was not created. "
21441  "Diagnostics: Internal Error.",
21442  "/omp?cmd=get_permissions", response_data);
21443  }
21444 
21445  subject_entity = entity_child (get_subject_entity, subject_type);
21446 
21447  if (subject_entity)
21448  subject_id = entity_attribute (subject_entity, "id");
21449 
21450  if (subject_id == NULL)
21451  {
21452  gchar *msg;
21453  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
21454  " operation=\"create_permission\">"
21455  "Could not find a %s with name '%s'."
21456  "</gsad_msg>",
21457  subject_type,
21458  subject_name ? subject_name : "");
21459  return next_page (credentials, params, msg, response_data);
21460  }
21461  }
21462  else if (strcmp (subject_type, "user") == 0)
21463  subject_id = params_value (params, "permission_user_id");
21464  else if (strcmp (subject_type, "group") == 0)
21465  subject_id = params_value (params, "permission_group_id");
21466  else if (strcmp (subject_type, "role") == 0)
21467  subject_id = params_value (params, "permission_role_id");
21468  else
21469  subject_id = NULL;
21470  CHECK_PARAM_INVALID (subject_id, "Create Permission", "new_permission");
21471 
21472  /* Create the permission(s). */
21473 
21474  if (strcmp (name, "task_proxy") == 0)
21475  {
21476  response = NULL;
21477  entity = NULL;
21478  ret = ompf (credentials,
21479  &response,
21480  &entity,
21481  response_data,
21482  "<commands>"
21483  "<create_permission>"
21484  "<name>get_tasks</name>"
21485  "<comment>%s</comment>"
21486  "<resource id=\"%s\"/>"
21487  "<subject id=\"%s\"><type>%s</type></subject>"
21488  "</create_permission>"
21489  "<create_permission>"
21490  "<name>modify_task</name>"
21491  "<comment>%s</comment>"
21492  "<resource id=\"%s\"/>"
21493  "<subject id=\"%s\"><type>%s</type></subject>"
21494  "</create_permission>"
21495  "<create_permission>"
21496  "<name>start_task</name>"
21497  "<comment>%s</comment>"
21498  "<resource id=\"%s\"/>"
21499  "<subject id=\"%s\"><type>%s</type></subject>"
21500  "</create_permission>"
21501  "<create_permission>"
21502  "<name>stop_task</name>"
21503  "<comment>%s</comment>"
21504  "<resource id=\"%s\"/>"
21505  "<subject id=\"%s\"><type>%s</type></subject>"
21506  "</create_permission>"
21507  "<create_permission>"
21508  "<name>resume_task</name>"
21509  "<comment>%s</comment>"
21510  "<resource id=\"%s\"/>"
21511  "<subject id=\"%s\"><type>%s</type></subject>"
21512  "</create_permission>"
21513  "</commands>",
21514  comment ? comment : "",
21515  resource_id ? resource_id : "",
21516  subject_id,
21517  subject_type,
21518  comment ? comment : "",
21519  resource_id ? resource_id : "",
21520  subject_id,
21521  subject_type,
21522  comment ? comment : "",
21523  resource_id ? resource_id : "",
21524  subject_id,
21525  subject_type,
21526  comment ? comment : "",
21527  resource_id ? resource_id : "",
21528  subject_id,
21529  subject_type,
21530  comment ? comment : "",
21531  resource_id ? resource_id : "",
21532  subject_id,
21533  subject_type);
21534 
21535  if (get_subject_entity)
21536  free_entity (get_subject_entity);
21537 
21538  switch (ret)
21539  {
21540  case 0:
21541  case -1:
21542  break;
21543  case 1:
21544  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21545  return gsad_message (credentials,
21546  "Internal error", __FUNCTION__, __LINE__,
21547  "An internal error occurred while creating a permission. "
21548  "The permission was not created. "
21549  "Diagnostics: Failure to send command to manager daemon.",
21550  "/omp?cmd=get_permissions", response_data);
21551  case 2:
21552  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21553  return gsad_message (credentials,
21554  "Internal error", __FUNCTION__, __LINE__,
21555  "An internal error occurred while creating a permission. "
21556  "It is unclear whether the permission has been created or not. "
21557  "Diagnostics: Failure to receive response from manager daemon.",
21558  "/omp?cmd=get_permissions", response_data);
21559  default:
21560  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21561  return gsad_message (credentials,
21562  "Internal error", __FUNCTION__, __LINE__,
21563  "An internal error occurred while creating a permission. "
21564  "It is unclear whether the permission has been created or not. "
21565  "Diagnostics: Internal Error.",
21566  "/omp?cmd=get_permissions", response_data);
21567  }
21568 
21569  if (entity_attribute (entity, "id"))
21570  params_add (params, "permission_id", entity_attribute (entity, "id"));
21571  html = response_from_entity (credentials, params, entity,
21572  (no_redirect && strcmp (no_redirect, "0")),
21573  NULL, "get_permissions",
21574  NULL, "new_permission",
21575  "Create Permission", response_data);
21576  }
21577  else
21578  {
21579  response = NULL;
21580  entity = NULL;
21581  ret = ompf (credentials,
21582  &response,
21583  &entity,
21584  response_data,
21585  "<create_permission>"
21586  "<name>%s</name>"
21587  "<comment>%s</comment>"
21588  "<resource id=\"%s\">"
21589  "<type>%s</type>"
21590  "</resource>"
21591  "<subject id=\"%s\"><type>%s</type></subject>"
21592  "</create_permission>",
21593  name,
21594  comment ? comment : "",
21595  resource_id ? resource_id : "",
21596  resource_type ? resource_type : "",
21597  subject_id,
21598  subject_type);
21599 
21600  if (get_subject_entity)
21601  free_entity (get_subject_entity);
21602 
21603  switch (ret)
21604  {
21605  case 0:
21606  case -1:
21607  break;
21608  case 1:
21609  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21610  return gsad_message (credentials,
21611  "Internal error", __FUNCTION__, __LINE__,
21612  "An internal error occurred while creating a permission. "
21613  "The permission was not created. "
21614  "Diagnostics: Failure to send command to manager daemon.",
21615  "/omp?cmd=get_permissions", response_data);
21616  case 2:
21617  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21618  return gsad_message (credentials,
21619  "Internal error", __FUNCTION__, __LINE__,
21620  "An internal error occurred while creating a permission. "
21621  "It is unclear whether the permission has been created or not. "
21622  "Diagnostics: Failure to receive response from manager daemon.",
21623  "/omp?cmd=get_permissions", response_data);
21624  default:
21625  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21626  return gsad_message (credentials,
21627  "Internal error", __FUNCTION__, __LINE__,
21628  "An internal error occurred while creating a permission. "
21629  "It is unclear whether the permission has been created or not. "
21630  "Diagnostics: Internal Error.",
21631  "/omp?cmd=get_permissions", response_data);
21632  }
21633 
21634  if (entity_attribute (entity, "id"))
21635  params_add (params, "permission_id", entity_attribute (entity, "id"));
21636  html = response_from_entity (credentials, params, entity,
21637  (no_redirect && strcmp (no_redirect, "0")),
21638  NULL, "get_permissions",
21639  NULL, "new_permission",
21640  "Create Permission", response_data);
21641  }
21642  free_entity (entity);
21643  g_free (response);
21644  return html;
21645 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create multiple permission, get next page, XSL transform the result.

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

Definition at line 22003 of file gsad_omp.c.

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

22005 {
22006  int ret;
22007  gchar *html, *response, *summary_response, *next_url;
22008  int successes;
22009  const char *no_redirect, *permission, *comment, *resource_id, *resource_type;
22010  const char *subject_id, *subject_type, *subject_name;
22011  int include_related;
22012 
22013  entity_t entity;
22014 
22015  gchar *subject_response;
22016  entity_t get_subject_entity = NULL;
22017  entity_t subject_entity;
22018 
22019  no_redirect = params_value (params, "no_redirect");
22020  permission = params_value (params, "permission");
22021  comment = params_value (params, "comment");
22022  resource_id = params_value (params, "resource_id");
22023  resource_type = params_value (params, "resource_type");
22024  subject_type = params_value (params, "subject_type");
22025  subject_name = params_value (params, "subject_name");
22026 
22027  include_related = atoi (params_value (params, "include_related"));
22028  CHECK_PARAM (params_value (params, "include_related"),
22029  "Create Permission", new_permission);
22030 
22031  CHECK_PARAM (permission, "Create Permission", new_permission);
22032  CHECK_PARAM (comment, "Create Permission", new_permission);
22033  CHECK_PARAM (resource_id, "Create Permission", new_permission);
22034  CHECK_PARAM (subject_type, "Create Permission", new_permission);
22035  CHECK_PARAM (resource_type, "Create Permission", new_permission);
22036 
22037  if (params_given (params, "subject_name"))
22038  {
22039  CHECK_PARAM (subject_name, "Create Permission", new_permission);
22040  subject_id = NULL;
22041  ret = ompf (credentials,
22042  &subject_response,
22043  &get_subject_entity,
22044  response_data,
22045  "<get_%ss filter=\"rows=1 name=%s\">"
22046  "</get_%ss>",
22047  subject_type,
22048  subject_name,
22049  subject_type);
22050 
22051  switch (ret)
22052  {
22053  case 0:
22054  case -1:
22055  break;
22056  case 1:
22057  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22058  return gsad_message (credentials,
22059  "Internal error", __FUNCTION__, __LINE__,
22060  "An internal error occurred while getting"
22061  " the subject for a permission. "
22062  "The permission was not created. "
22063  "Diagnostics: Failure to send command"
22064  " to manager daemon.",
22065  "/omp?cmd=get_permissions", response_data);
22066  case 2:
22067  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22068  return gsad_message (credentials,
22069  "Internal error", __FUNCTION__, __LINE__,
22070  "An internal error occurred while getting"
22071  " the subject for a permission. "
22072  "The permission was not created. "
22073  "Diagnostics: Failure to receive response"
22074  " from manager daemon.",
22075  "/omp?cmd=get_permissions", response_data);
22076  default:
22077  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22078  return gsad_message (credentials,
22079  "Internal error", __FUNCTION__, __LINE__,
22080  "An internal error occurred while getting"
22081  " the subject for a permission. "
22082  "The permission was not created. "
22083  "Diagnostics: Internal Error.",
22084  "/omp?cmd=get_permissions", response_data);
22085  }
22086 
22087  subject_entity = entity_child (get_subject_entity, subject_type);
22088 
22089  if (subject_entity)
22090  subject_id = entity_attribute (subject_entity, "id");
22091 
22092  if (subject_id == NULL)
22093  {
22094  gchar *msg;
22095  msg = g_strdup_printf ("<gsad_msg status_text=\"Subject not found\""
22096  " operation=\"create_permission\">"
22097  "Could not find a %s with name '%s'."
22098  "</gsad_msg>",
22099  subject_type,
22100  subject_name ? subject_name : "");
22101  return next_page (credentials, params, msg, response_data);
22102  }
22103  }
22104  else if (strcmp (subject_type, "user") == 0)
22105  subject_id = params_value (params, "permission_user_id");
22106  else if (strcmp (subject_type, "group") == 0)
22107  subject_id = params_value (params, "permission_group_id");
22108  else if (strcmp (subject_type, "role") == 0)
22109  subject_id = params_value (params, "permission_role_id");
22110  else
22111  subject_id = NULL;
22112  CHECK_PARAM (subject_id, "Create Permission", new_permission);
22113 
22114  successes = 0;
22115 
22116  /* Create the permission(s). */
22117 
22118  // Main resource permissions
22119  if (include_related != 2)
22120  {
22121  if (strcmp (permission, "read") == 0
22122  || strcmp (permission, "proxy") == 0)
22123  {
22124  response = NULL;
22125  entity = NULL;
22126  ret = ompf (credentials,
22127  &response,
22128  &entity,
22129  response_data,
22130  "<create_permission>"
22131  "<name>get_%ss</name>"
22132  "<comment>%s</comment>"
22133  "<resource id=\"%s\">"
22134  "</resource>"
22135  "<subject id=\"%s\"><type>%s</type></subject>"
22136  "</create_permission>",
22137  resource_type,
22138  comment ? comment : "",
22139  resource_id,
22140  subject_id,
22141  subject_type);
22142 
22144  }
22145 
22146  if ((strcmp (permission, "proxy") == 0)
22147  && strcmp (resource_type, "result")
22148  && strcmp (resource_type, "report"))
22149  {
22150  response = NULL;
22151  entity = NULL;
22152  ret = ompf (credentials,
22153  &response,
22154  &entity,
22155  response_data,
22156  "<create_permission>"
22157  "<name>modify_%s</name>"
22158  "<comment>%s</comment>"
22159  "<resource id=\"%s\">"
22160  "</resource>"
22161  "<subject id=\"%s\"><type>%s</type></subject>"
22162  "</create_permission>",
22163  resource_type,
22164  comment ? comment : "",
22165  resource_id,
22166  subject_id,
22167  subject_type);
22168 
22170 
22171  if (strcmp (resource_type, "task") == 0)
22172  {
22173  response = NULL;
22174  entity = NULL;
22175  ret = ompf (credentials,
22176  &response,
22177  &entity,
22178  response_data,
22179  "<create_permission>"
22180  "<name>start_%s</name>"
22181  "<comment>%s</comment>"
22182  "<resource id=\"%s\">"
22183  "</resource>"
22184  "<subject id=\"%s\"><type>%s</type></subject>"
22185  "</create_permission>",
22186  resource_type,
22187  comment ? comment : "",
22188  resource_id,
22189  subject_id,
22190  subject_type);
22191 
22193 
22194  response = NULL;
22195  entity = NULL;
22196  ret = ompf (credentials,
22197  &response,
22198  &entity,
22199  response_data,
22200  "<create_permission>"
22201  "<name>stop_%s</name>"
22202  "<comment>%s</comment>"
22203  "<resource id=\"%s\">"
22204  "</resource>"
22205  "<subject id=\"%s\"><type>%s</type></subject>"
22206  "</create_permission>",
22207  resource_type,
22208  comment ? comment : "",
22209  resource_id,
22210  subject_id,
22211  subject_type);
22212 
22214 
22215  response = NULL;
22216  entity = NULL;
22217  ret = ompf (credentials,
22218  &response,
22219  &entity,
22220  response_data,
22221  "<create_permission>"
22222  "<name>resume_%s</name>"
22223  "<comment>%s</comment>"
22224  "<resource id=\"%s\">"
22225  "</resource>"
22226  "<subject id=\"%s\"><type>%s</type></subject>"
22227  "</create_permission>",
22228  resource_type,
22229  comment ? comment : "",
22230  resource_id,
22231  subject_id,
22232  subject_type);
22233 
22235  }
22236 
22237  if (strcmp (resource_type, "alert") == 0)
22238  {
22239  response = NULL;
22240  entity = NULL;
22241  ret = ompf (credentials,
22242  &response,
22243  &entity,
22244  response_data,
22245  "<create_permission>"
22246  "<name>test_%s</name>"
22247  "<comment>%s</comment>"
22248  "<resource id=\"%s\">"
22249  "</resource>"
22250  "<subject id=\"%s\"><type>%s</type></subject>"
22251  "</create_permission>",
22252  resource_type,
22253  comment ? comment : "",
22254  resource_id,
22255  subject_id,
22256  subject_type);
22257 
22259  }
22260 
22261  if (strcmp (resource_type, "agent") == 0
22262  || strcmp (resource_type, "report_format") == 0
22263  || strcmp (resource_type, "scanner") == 0)
22264  {
22265  response = NULL;
22266  entity = NULL;
22267  ret = ompf (credentials,
22268  &response,
22269  &entity,
22270  response_data,
22271  "<create_permission>"
22272  "<name>verify_%s</name>"
22273  "<comment>%s</comment>"
22274  "<resource id=\"%s\">"
22275  "</resource>"
22276  "<subject id=\"%s\"><type>%s</type></subject>"
22277  "</create_permission>",
22278  resource_type,
22279  comment ? comment : "",
22280  resource_id,
22281  subject_id,
22282  subject_type);
22283 
22285  }
22286  }
22287  }
22288 
22289  // Related permissions
22290  if (include_related)
22291  {
22292  params_t *related;
22293  related = params_values (params, "related:");
22294  if (related)
22295  {
22296  params_iterator_t iter;
22297  char *name;
22298  param_t *param;
22299 
22300  params_iterator_init (&iter, related);
22301  while (params_iterator_next (&iter, &name, &param))
22302  {
22303  char *related_id = name;
22304  char *related_type = param->value;
22305 
22306  if (strcmp (permission, "read") == 0
22307  || strcmp (permission, "proxy") == 0)
22308  {
22309  response = NULL;
22310  entity = NULL;
22311  ret = ompf (credentials,
22312  &response,
22313  &entity,
22314  response_data,
22315  "<create_permission>"
22316  "<name>get_%ss</name>"
22317  "<comment>%s</comment>"
22318  "<resource id=\"%s\">"
22319  "</resource>"
22320  "<subject id=\"%s\"><type>%s</type></subject>"
22321  "</create_permission>",
22322  related_type,
22323  comment ? comment : "",
22324  related_id,
22325  subject_id,
22326  subject_type);
22327 
22329  }
22330 
22331  if ((strcmp (permission, "proxy") == 0)
22332  && strcmp (related_type, "result")
22333  && strcmp (related_type, "report"))
22334  {
22335  response = NULL;
22336  entity = NULL;
22337  ret = ompf (credentials,
22338  &response,
22339  &entity,
22340  response_data,
22341  "<create_permission>"
22342  "<name>modify_%s</name>"
22343  "<comment>%s</comment>"
22344  "<resource id=\"%s\">"
22345  "</resource>"
22346  "<subject id=\"%s\"><type>%s</type></subject>"
22347  "</create_permission>",
22348  related_type,
22349  comment ? comment : "",
22350  related_id,
22351  subject_id,
22352  subject_type);
22353 
22355 
22356  if (strcmp (related_type, "task") == 0)
22357  {
22358  response = NULL;
22359  entity = NULL;
22360  ret = ompf (credentials,
22361  &response,
22362  &entity,
22363  response_data,
22364  "<create_permission>"
22365  "<name>start_%s</name>"
22366  "<comment>%s</comment>"
22367  "<resource id=\"%s\">"
22368  "</resource>"
22369  "<subject id=\"%s\"><type>%s</type></subject>"
22370  "</create_permission>",
22371  related_type,
22372  comment ? comment : "",
22373  related_id,
22374  subject_id,
22375  subject_type);
22376 
22378 
22379  response = NULL;
22380  entity = NULL;
22381  ret = ompf (credentials,
22382  &response,
22383  &entity,
22384  response_data,
22385  "<create_permission>"
22386  "<name>stop_%s</name>"
22387  "<comment>%s</comment>"
22388  "<resource id=\"%s\">"
22389  "</resource>"
22390  "<subject id=\"%s\"><type>%s</type></subject>"
22391  "</create_permission>",
22392  related_type,
22393  comment ? comment : "",
22394  related_id,
22395  subject_id,
22396  subject_type);
22397 
22399 
22400  response = NULL;
22401  entity = NULL;
22402  ret = ompf (credentials,
22403  &response,
22404  &entity,
22405  response_data,
22406  "<create_permission>"
22407  "<name>resume_%s</name>"
22408  "<comment>%s</comment>"
22409  "<resource id=\"%s\">"
22410  "</resource>"
22411  "<subject id=\"%s\"><type>%s</type></subject>"
22412  "</create_permission>",
22413  related_type,
22414  comment ? comment : "",
22415  related_id,
22416  subject_id,
22417  subject_type);
22418 
22420  }
22421 
22422  if (strcmp (related_type, "alert") == 0)
22423  {
22424  response = NULL;
22425  entity = NULL;
22426  ret = ompf (credentials,
22427  &response,
22428  &entity,
22429  response_data,
22430  "<create_permission>"
22431  "<name>test_%s</name>"
22432  "<comment>%s</comment>"
22433  "<resource id=\"%s\">"
22434  "</resource>"
22435  "<subject id=\"%s\"><type>%s</type></subject>"
22436  "</create_permission>",
22437  related_type,
22438  comment ? comment : "",
22439  related_id,
22440  subject_id,
22441  subject_type);
22442 
22444  }
22445 
22446  if (strcmp (related_type, "agent") == 0
22447  || strcmp (related_type, "report_format") == 0
22448  || strcmp (related_type, "scanner") == 0)
22449  {
22450  response = NULL;
22451  entity = NULL;
22452  ret = ompf (credentials,
22453  &response,
22454  &entity,
22455  response_data,
22456  "<create_permission>"
22457  "<name>verify_%s</name>"
22458  "<comment>%s</comment>"
22459  "<resource id=\"%s\">"
22460  "</resource>"
22461  "<subject id=\"%s\"><type>%s</type></subject>"
22462  "</create_permission>",
22463  related_type,
22464  comment ? comment : "",
22465  related_id,
22466  subject_id,
22467  subject_type);
22468 
22470  }
22471  }
22472  }
22473  }
22474  }
22475 
22476  if (get_subject_entity)
22477  free_entity (get_subject_entity);
22478 
22479  summary_response = g_strdup_printf("Successfully created %i permissions",
22480  successes);
22481 
22482  next_url = next_page_url (credentials, params,
22483  NULL, "new_permissions",
22484  "Create Permissions",
22485  G_STRINGIFY (MHD_HTTP_CREATED),
22486  summary_response);
22487 
22488  if (no_redirect)
22489  {
22490  html = action_result_page (credentials, response_data,
22491  "Create Permissions",
22492  G_STRINGIFY (MHD_HTTP_CREATED),
22493  summary_response,
22494  next_url);
22495  g_free (next_url);
22496  }
22497  else
22498  {
22499  html = NULL;
22500  response_data->redirect = next_url;
22501  }
22502  return html;
22503 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_OMPF_RET
Definition: gsad_omp.c:21647
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1184
char * new_permission(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
Definition: gsad_omp.c:21188
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

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

Create a port list, get all port lists, XSL transform the result.

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

Definition at line 22919 of file gsad_omp.c.

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

22921 {
22922  gchar *html, *response;
22923  const char *no_redirect, *name, *comment, *port_range, *from_file;
22924  entity_t entity;
22925 
22926  no_redirect = params_value (params, "no_redirect");
22927  name = params_value (params, "name");
22928  comment = params_value (params, "comment");
22929  port_range = params_value (params, "port_range");
22930  from_file = params_value (params, "from_file");
22931 
22932  CHECK_PARAM_INVALID (name, "Create Port List", "new_port_list");
22933  CHECK_PARAM_INVALID (comment, "Create Port List", "new_port_list");
22934  CHECK_PARAM_INVALID (port_range, "Create Port List", "new_port_list");
22935  CHECK_PARAM_INVALID (from_file, "Create Port List", "new_port_list");
22936 
22937  /* Create the port_list. */
22938 
22939  switch (ompf (credentials,
22940  &response,
22941  &entity,
22942  response_data,
22943  "<create_port_list>"
22944  "<name>%s</name>"
22945  "<port_range>%s</port_range>"
22946  "<comment>%s</comment>"
22947  "</create_port_list>",
22948  name,
22949  strcmp (from_file, "0")
22950  ? params_value (params, "file")
22951  : port_range,
22952  comment ? comment : ""))
22953  {
22954  case 0:
22955  case -1:
22956  break;
22957  case 1:
22958  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22959  return gsad_message (credentials,
22960  "Internal error", __FUNCTION__, __LINE__,
22961  "An internal error occurred while creating a new port list. "
22962  "No new port list was created. "
22963  "Diagnostics: Failure to send command to manager daemon.",
22964  "/omp?cmd=get_port_lists", response_data);
22965  case 2:
22966  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22967  return gsad_message (credentials,
22968  "Internal error", __FUNCTION__, __LINE__,
22969  "An internal error occurred while creating a new port list. "
22970  "It is unclear whether the port list has been created or not. "
22971  "Diagnostics: Failure to receive response from manager daemon.",
22972  "/omp?cmd=get_port_lists", response_data);
22973  default:
22974  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22975  return gsad_message (credentials,
22976  "Internal error", __FUNCTION__, __LINE__,
22977  "An internal error occurred while creating a new port list. "
22978  "It is unclear whether the port list has been created or not. "
22979  "Diagnostics: Internal Error.",
22980  "/omp?cmd=get_port_lists", response_data);
22981  }
22982 
22983  if (entity_attribute (entity, "id"))
22984  params_add (params, "port_list_id", entity_attribute (entity, "id"));
22985  html = response_from_entity (credentials, params, entity,
22986  (no_redirect && strcmp (no_redirect, "0")),
22987  NULL, "get_port_lists",
22988  NULL, "new_port_list",
22989  "Create Port List", response_data);
22990  free_entity (entity);
22991  g_free (response);
22992  return html;
22993 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Add a range to a port list, XSL transform the result.

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

Definition at line 23044 of file gsad_omp.c.

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

23046 {
23047  int ret;
23048  gchar *html, *response;
23049  const char *no_redirect, *port_list_id, *start, *end, *type;
23050  entity_t entity;
23051 
23052  no_redirect = params_value (params, "no_redirect");
23053  port_list_id = params_value (params, "port_list_id");
23054  start = params_value (params, "port_range_start");
23055  end = params_value (params, "port_range_end");
23056  type = params_value (params, "port_type");
23057 
23058  CHECK_PARAM_INVALID (port_list_id, "Create Port Range", "edit_port_list");
23059  CHECK_PARAM_INVALID (start, "Create Port Range", "edit_port_list");
23060  CHECK_PARAM_INVALID (end, "Create Port Range", "edit_port_list");
23061  CHECK_PARAM_INVALID (type, "Create Port Range", "edit_port_list");
23062 
23063  /* Create the port range. */
23064 
23065  response = NULL;
23066  entity = NULL;
23067  ret = ompf (credentials,
23068  &response,
23069  &entity,
23070  response_data,
23071  "<create_port_range>"
23072  "<port_list id=\"%s\"/>"
23073  "<start>%s</start>"
23074  "<end>%s</end>"
23075  "<type>%s</type>"
23076  "</create_port_range>",
23077  port_list_id,
23078  start,
23079  end,
23080  type);
23081 
23082  switch (ret)
23083  {
23084  case 0:
23085  case -1:
23086  break;
23087  case 1:
23088  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23089  return gsad_message (credentials,
23090  "Internal error", __FUNCTION__, __LINE__,
23091  "An internal error occurred while creating a Port Range. "
23092  "The Port Range was not created. "
23093  "Diagnostics: Failure to send command to manager daemon.",
23094  "/omp?cmd=get_port_lists", response_data);
23095  case 2:
23096  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23097  return gsad_message (credentials,
23098  "Internal error", __FUNCTION__, __LINE__,
23099  "An internal error occurred while creating a Port Range. "
23100  "It is unclear whether the Port Range has been created or not. "
23101  "Diagnostics: Failure to receive response from manager daemon.",
23102  "/omp?cmd=get_port_lists", response_data);
23103  default:
23104  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23105  return gsad_message (credentials,
23106  "Internal error", __FUNCTION__, __LINE__,
23107  "An internal error occurred while creating a Port Range. "
23108  "It is unclear whether the Port Range has been created or not. "
23109  "Diagnostics: Internal Error.",
23110  "/omp?cmd=get_port_lists", response_data);
23111  }
23112 
23113  html = response_from_entity (credentials, params, entity,
23114  (no_redirect && strcmp (no_redirect, "0")),
23115  NULL, "edit_port_list",
23116  NULL, "edit_port_list",
23117  "Create Port Range", response_data);
23118  free_entity (entity);
23119  g_free (response);
23120  return html;
23121 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Create a report, get all tasks, XSL transform the result.

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

Definition at line 3972 of file gsad_omp.c.

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

Referenced by import_report_omp().

3974 {
3975  entity_t entity;
3976  int ret;
3977  gchar *command, *html, *response;
3978  const char *no_redirect, *cmd, *task_id, *name, *comment, *xml_file;
3979  const char *in_assets;
3980 
3981  no_redirect = params_value (params, "no_redirect");
3982  task_id = params_value (params, "task_id");
3983  xml_file = params_value (params, "xml_file");
3984  name = params_value (params, "name");
3985  comment = params_value (params, "comment");
3986  in_assets = params_value (params, "in_assets");
3987 
3988  if (task_id == NULL)
3989  {
3990  CHECK_PARAM_INVALID (name, "Create Report", "new_container_task");
3991  CHECK_PARAM_INVALID (comment, "Create Report", "new_container_task");
3992  }
3993  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3994 
3995  if (params_given (params, "in_assets"))
3996  CHECK_PARAM_INVALID (xml_file, "Create Report", "new_container_task");
3997 
3998  if (strlen (xml_file) == 0)
3999  {
4000  if (task_id)
4001  return message_invalid (credentials, params, response_data,
4002  "Report required",
4003  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
4004  "Create Report", "new_container_task");
4005 
4006  /* Create only the container task. */
4007 
4008  command = g_strdup_printf ("<create_task>"
4009  "<target id=\"0\"/>"
4010  "<name>%s</name>"
4011  "<comment>%s</comment>"
4012  "</create_task>",
4013  name,
4014  comment);
4015  }
4016  else
4017  {
4018  gchar **xml_file_array, *xml_file_escaped;
4019 
4020  xml_file_array = g_strsplit (xml_file, "%", -1);
4021  if (xml_file_array != NULL && xml_file_array[0] != NULL)
4022  xml_file_escaped = g_strjoinv ("%%", xml_file_array);
4023  else
4024  xml_file_escaped = g_strdup (xml_file);
4025  g_strfreev (xml_file_array);
4026 
4027  if (task_id)
4028  command = g_strdup_printf ("<create_report>"
4029  "<in_assets>%s</in_assets>"
4030  "<task id=\"%s\"/>"
4031  "%s"
4032  "</create_report>",
4033  in_assets ? in_assets : "0",
4034  task_id ? task_id : "0",
4035  xml_file_escaped ? xml_file_escaped : "");
4036  else
4037  command = g_strdup_printf ("<create_report>"
4038  "<in_assets>%s</in_assets>"
4039  "<task>"
4040  "<name>%s</name>"
4041  "<comment>%s</comment>"
4042  "</task>"
4043  "%s"
4044  "</create_report>",
4045  in_assets ? in_assets : "",
4046  name,
4047  comment,
4048  xml_file_escaped);
4049  g_free (xml_file_escaped);
4050  }
4051 
4052  ret = omp (credentials,
4053  &response,
4054  &entity,
4055  response_data,
4056  command);
4057  g_free (command);
4058 
4059  switch (ret)
4060  {
4061  case 0:
4062  break;
4063  case -1:
4064  /* 'omp' set response. */
4065  return response;
4066  case 1:
4067  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4068  return gsad_message (credentials,
4069  "Internal error", __FUNCTION__, __LINE__,
4070  "An internal error occurred while creating a new report. "
4071  "No new report was created. "
4072  "Diagnostics: Failure to send command to manager daemon.",
4073  "/omp?cmd=get_tasks", response_data);
4074  case 2:
4075  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4076  return gsad_message (credentials,
4077  "Internal error", __FUNCTION__, __LINE__,
4078  "An internal error occurred while creating a new report. "
4079  "It is unclear whether the report has been created or not. "
4080  "Diagnostics: Failure to receive response from manager daemon.",
4081  "/omp?cmd=get_tasks", response_data);
4082  default:
4083  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4084  return gsad_message (credentials,
4085  "Internal error", __FUNCTION__, __LINE__,
4086  "An internal error occurred while creating a new report. "
4087  "It is unclear whether the report has been created or not. "
4088  "Diagnostics: Internal Error.",
4089  "/omp?cmd=get_tasks", response_data);
4090  }
4091 
4092  cmd = params_value (params, "cmd");
4093  html = response_from_entity (credentials, params, entity,
4094  (no_redirect && strcmp (no_redirect, "0")),
4095  NULL, "get_tasks",
4096  NULL,
4097  (cmd && strcmp (cmd, "import_report"))
4098  ? "new_container_task" : "upload_report",
4099  "Import Report", response_data);
4100  free_entity (entity);
4101  g_free (response);
4102  return html;
4103 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472

Here is the call graph for this function:

Here is the caller graph for this function:

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

Create a role, get all roles, XSL transform the result.

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

Definition at line 23538 of file gsad_omp.c.

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

23540 {
23541  char *ret;
23542  gchar *response;
23543  const char *no_redirect, *name, *comment, *users;
23544  entity_t entity;
23545 
23546  no_redirect = params_value (params, "no_redirect");
23547  name = params_value (params, "name");
23548  comment = params_value (params, "comment");
23549  users = params_value (params, "users");
23550 
23551  CHECK_PARAM_INVALID (name, "Create Role", "new_role");
23552  CHECK_PARAM_INVALID (comment, "Create Role", "new_role");
23553  CHECK_PARAM_INVALID (users, "Create Role", "new_role");
23554 
23555  response = NULL;
23556  entity = NULL;
23557  switch (ompf (credentials,
23558  &response,
23559  &entity,
23560  response_data,
23561  "<create_role>"
23562  "<name>%s</name>"
23563  "<comment>%s</comment>"
23564  "<users>%s</users>"
23565  "</create_role>",
23566  name,
23567  comment,
23568  users))
23569  {
23570  case 0:
23571  case -1:
23572  break;
23573  case 1:
23574  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23575  return gsad_message (credentials,
23576  "Internal error", __FUNCTION__, __LINE__,
23577  "An internal error occurred while creating a new role. "
23578  "No new role was created. "
23579  "Diagnostics: Failure to send command to manager daemon.",
23580  "/omp?cmd=get_targets", response_data);
23581  case 2:
23582  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23583  return gsad_message (credentials,
23584  "Internal error", __FUNCTION__, __LINE__,
23585  "An internal error occurred while creating a new role. "
23586  "It is unclear whether the role has been created or not. "
23587  "Diagnostics: Failure to receive response from manager daemon.",
23588  "/omp?cmd=get_roles", response_data);
23589  default:
23590  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23591  return gsad_message (credentials,
23592  "Internal error", __FUNCTION__, __LINE__,
23593  "An internal error occurred while creating a new role. "
23594  "It is unclear whether the role has been created or not. "
23595  "Diagnostics: Internal Error.",
23596  "/omp?cmd=get_roles", response_data);
23597  }
23598 
23599  if (entity_attribute (entity, "id"))
23600  params_add (params, "role_id", entity_attribute (entity, "id"));
23601  ret = response_from_entity (credentials, params, entity,
23602  (no_redirect && strcmp (no_redirect, "0")),
23603  NULL, "get_roles",
23604  NULL, "new_role",
23605  "Create Role", response_data);
23606  free_entity (entity);
23607  g_free (response);
23608  return ret;
23609 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a scanner, get all scanners, XSL transform the result.

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

Definition at line 17414 of file gsad_omp.c.

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

17416 {
17417  int ret;
17418  char *html;
17419  gchar *response = NULL;
17420  const char *no_redirect;
17421  const char *name, *comment, *host, *port, *type, *ca_pub, *credential_id;
17422  entity_t entity = NULL;
17423 
17424  no_redirect = params_value (params, "no_redirect");
17425  name = params_value (params, "name");
17426  comment = params_value (params, "comment");
17427  host = params_value (params, "scanner_host");
17428  port = params_value (params, "port");
17429  type = params_value (params, "scanner_type");
17430  ca_pub = params_value (params, "ca_pub");
17431  credential_id = params_value (params, "credential_id");
17432  CHECK_PARAM_INVALID (name, "Create Scanner", "new_scanner");
17433  CHECK_PARAM_INVALID (comment, "Create Scanner", "new_scanner");
17434  CHECK_PARAM_INVALID (host, "Create Scanner", "new_scanner");
17435  CHECK_PARAM_INVALID (port, "Create Scanner", "new_scanner");
17436  CHECK_PARAM_INVALID (type, "Create Scanner", "new_scanner");
17437  if (params_given (params, "ca_pub"))
17438  CHECK_PARAM_INVALID (ca_pub, "Create Scanner", "new_scanner");
17439  CHECK_PARAM_INVALID (credential_id, "Create Scanner", "new_scanner");
17440 
17441  if (ca_pub)
17442  ret = ompf (credentials, &response, &entity, response_data,
17443  "<create_scanner>"
17444  "<name>%s</name><comment>%s</comment>"
17445  "<host>%s</host><port>%s</port><type>%s</type>"
17446  "<ca_pub>%s</ca_pub>"
17447  "<credential id=\"%s\"/>"
17448  "</create_scanner>",
17449  name, comment, host, port, type, ca_pub, credential_id);
17450  else
17451  ret = ompf (credentials, &response, &entity, response_data,
17452  "<create_scanner>"
17453  "<name>%s</name><comment>%s</comment>"
17454  "<host>%s</host><port>%s</port><type>%s</type>"
17455  "<credential id=\"%s\"/>"
17456  "</create_scanner>",
17457  name, comment, host, port, type, credential_id);
17458  switch (ret)
17459  {
17460  case 0:
17461  case -1:
17462  break;
17463  case 1:
17464  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17465  return gsad_message
17466  (credentials, "Internal error", __FUNCTION__, __LINE__,
17467  "An internal error occurred while creating a new scanner. "
17468  "No new scanner was created. "
17469  "Diagnostics: Failure to send command to manager daemon.",
17470  "/omp?cmd=get_scanners", response_data);
17471  case 2:
17472  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17473  return gsad_message
17474  (credentials, "Internal error", __FUNCTION__, __LINE__,
17475  "An internal error occurred while creating a new scanner. "
17476  "It is unclear whether the scanner has been created or not. "
17477  "Diagnostics: Failure to receive response from manager daemon.",
17478  "/omp?cmd=get_scanners", response_data);
17479  default:
17480  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17481  return gsad_message
17482  (credentials, "Internal error", __FUNCTION__, __LINE__,
17483  "An internal error occurred while creating a new scanner. "
17484  "It is unclear whether the scanner has been created or not. "
17485  "Diagnostics: Internal Error.",
17486  "/omp?cmd=get_scanners", response_data);
17487  }
17488 
17489  if (entity_attribute (entity, "id"))
17490  params_add (params, "scanner_id", entity_attribute (entity, "id"));
17491  html = response_from_entity (credentials, params, entity,
17492  (no_redirect && strcmp (no_redirect, "0")),
17493  NULL, "get_scanners",
17494  NULL, "new_scanner",
17495  "Create Scanner", response_data);
17496  free_entity (entity);
17497  g_free (response);
17498  return html;
17499 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a schedule, get all schedules, XSL transform the result.

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

Definition at line 17941 of file gsad_omp.c.

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

17943 {
17944  char *ret;
17945  gchar *response;
17946  const char *no_redirect;
17947  const char *name, *comment, *hour, *minute, *day_of_month, *month, *year;
17948  const char *period, *period_unit, *duration, *duration_unit, *timezone;
17949  entity_t entity;
17950 
17951  no_redirect = params_value (params, "no_redirect");
17952  name = params_value (params, "name");
17953  comment = params_value (params, "comment");
17954  hour = params_value (params, "hour");
17955  minute = params_value (params, "minute");
17956  day_of_month = params_value (params, "day_of_month");
17957  duration = params_value (params, "duration");
17958  duration_unit = params_value (params, "duration_unit");
17959  month = params_value (params, "month");
17960  period = params_value (params, "period");
17961  period_unit = params_value (params, "period_unit");
17962  year = params_value (params, "year");
17963  timezone = params_value (params, "timezone");
17964 
17965  CHECK_PARAM_INVALID (name, "Create Schedule", "new_schedule");
17966  CHECK_PARAM_INVALID (comment, "Create Schedule", "new_schedule");
17967  CHECK_PARAM_INVALID (hour, "Create Schedule", "new_schedule");
17968  CHECK_PARAM_INVALID (minute, "Create Schedule", "new_schedule");
17969  CHECK_PARAM_INVALID (day_of_month, "Create Schedule", "new_schedule");
17970  CHECK_PARAM_INVALID (duration, "Create Schedule", "new_schedule");
17971  CHECK_PARAM_INVALID (duration_unit, "Create Schedule", "new_schedule");
17972  CHECK_PARAM_INVALID (month, "Create Schedule", "new_schedule");
17973  CHECK_PARAM_INVALID (period, "Create Schedule", "new_schedule");
17974  CHECK_PARAM_INVALID (period_unit, "period_unit", "new_schedule");
17975  CHECK_PARAM_INVALID (year, "Create Schedule", "new_schedule");
17976  CHECK_PARAM_INVALID (timezone, "Create Schedule", "new_schedule");
17977 
17978  response = NULL;
17979  entity = NULL;
17980  switch (ompf (credentials,
17981  &response,
17982  &entity,
17983  response_data,
17984  "<create_schedule>"
17985  "<name>%s</name>"
17986  "<comment>%s</comment>"
17987  "<first_time>"
17988  "<hour>%s</hour>"
17989  "<minute>%s</minute>"
17990  "<day_of_month>%s</day_of_month>"
17991  "<month>%s</month>"
17992  "<year>%s</year>"
17993  "</first_time>"
17994  "<period>"
17995  "<unit>%s</unit>"
17996  "%s"
17997  "</period>"
17998  "<duration>"
17999  "<unit>%s</unit>"
18000  "%s"
18001  "</duration>"
18002  "<timezone>%s</timezone>"
18003  "</create_schedule>",
18004  name,
18005  comment,
18006  hour,
18007  minute,
18008  day_of_month,
18009  month,
18010  year,
18011  (strcmp (period_unit, "")
18012  ? period_unit
18013  : "second"),
18014  period,
18015  (strcmp (duration_unit, "")
18016  ? duration_unit
18017  : "second"),
18018  duration,
18019  timezone))
18020  {
18021  case 0:
18022  case -1:
18023  break;
18024  case 1:
18025  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18026  return gsad_message (credentials,
18027  "Internal error", __FUNCTION__, __LINE__,
18028  "An internal error occurred while creating a new schedule. "
18029  "No new schedule was created. "
18030  "Diagnostics: Failure to send command to manager daemon.",
18031  "/omp?cmd=get_schedules", response_data);
18032  case 2:
18033  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18034  return gsad_message (credentials,
18035  "Internal error", __FUNCTION__, __LINE__,
18036  "An internal error occurred while creating a new schedule. "
18037  "It is unclear whether the schedule has been created or not. "
18038  "Diagnostics: Failure to receive response from manager daemon.",
18039  "/omp?cmd=get_schedules", response_data);
18040  default:
18041  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18042  return gsad_message (credentials,
18043  "Internal error", __FUNCTION__, __LINE__,
18044  "An internal error occurred while creating a new schedule. "
18045  "It is unclear whether the schedule has been created or not. "
18046  "Diagnostics: Internal Error.",
18047  "/omp?cmd=get_schedules", response_data);
18048  }
18049 
18050  if (entity_attribute (entity, "id"))
18051  params_add (params, "schedule_id", entity_attribute (entity, "id"));
18052  ret = response_from_entity (credentials, params, entity,
18053  (no_redirect && strcmp (no_redirect, "0")),
18054  NULL, "get_schedules",
18055  NULL, "new_schedule",
18056  "Create Schedule", response_data);
18057  free_entity (entity);
18058  g_free (response);
18059  return ret;
18060 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a tag, get report, XSL transform the result.

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

Definition at line 10357 of file gsad_omp.c.

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

10359 {
10360  char *ret;
10361  const char* no_redirect;
10362  gchar *response;
10363  const char *name, *comment, *value, *resource_type, *resource_id, *active;
10364  entity_t entity;
10365 
10366  no_redirect = params_value (params, "no_redirect");
10367  name = params_value (params, "tag_name");
10368  comment = params_value (params, "comment");
10369  value = params_value (params, "tag_value");
10370  resource_type = params_value (params, "resource_type");
10371  resource_id = params_value (params, "resource_id");
10372  active = params_value (params, "active");
10373 
10374  CHECK_PARAM_INVALID (name, "Create Tag", "new_tag")
10375  CHECK_PARAM_INVALID (comment, "Create Tag", "new_tag")
10376  CHECK_PARAM_INVALID (value, "Create Tag", "new_tag")
10377  CHECK_PARAM_INVALID (resource_type, "Create Tag", "new_tag")
10378  CHECK_PARAM_INVALID (resource_id, "Create Tag", "new_tag")
10379  CHECK_PARAM_INVALID (active, "Create Tag", "new_tag")
10380 
10381  response = NULL;
10382  entity = NULL;
10383  switch (ompf (credentials,
10384  &response,
10385  &entity,
10386  response_data,
10387  "<create_tag>"
10388  "<name>%s</name>"
10389  "<comment>%s</comment>"
10390  "<value>%s</value>"
10391  "<resource id=\"%s\">"
10392  "<type>%s</type>"
10393  "</resource>"
10394  "<active>%s</active>"
10395  "</create_tag>",
10396  name,
10397  comment,
10398  value,
10399  resource_id,
10400  resource_type,
10401  active))
10402  {
10403  case 0:
10404  case -1:
10405  break;
10406  case 1:
10407  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10408  return gsad_message (credentials,
10409  "Internal error", __FUNCTION__, __LINE__,
10410  "An internal error occurred while creating a new tag. "
10411  "No new tag was created. "
10412  "Diagnostics: Failure to send command to manager daemon.",
10413  "/omp?cmd=get_targets", response_data);
10414  case 2:
10415  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10416  return gsad_message (credentials,
10417  "Internal error", __FUNCTION__, __LINE__,
10418  "An internal error occurred while creating a new tag. "
10419  "It is unclear whether the tag has been created or not. "
10420  "Diagnostics: Failure to receive response from manager daemon.",
10421  "/omp?cmd=get_tags", response_data);
10422  default:
10423  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10424  return gsad_message (credentials,
10425  "Internal error", __FUNCTION__, __LINE__,
10426  "An internal error occurred while creating a new tag. "
10427  "It is unclear whether the tag has been created or not. "
10428  "Diagnostics: Internal Error.",
10429  "/omp?cmd=get_tags", response_data);
10430  }
10431 
10432  if (entity_attribute (entity, "id"))
10433  params_add (params, "tag_id", entity_attribute (entity, "id"));
10434  ret = response_from_entity (credentials, params, entity,
10435  (no_redirect && strcmp (no_redirect, "0")),
10436  NULL, "get_tags",
10437  NULL, "new_tag",
10438  "Create Tag", response_data);
10439 
10440  free_entity (entity);
10441  g_free (response);
10442  return ret;
10443 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a target, get all targets, XSL transform the result.

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

Definition at line 9575 of file gsad_omp.c.

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

9577 {
9578  int ret;
9579  gchar *html, *response, *command;
9580  const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
9581  const char *target_ssh_credential, *port, *target_smb_credential;
9582  const char *target_esxi_credential, *target_snmp_credential, *target_source;
9583  const char *port_list_id, *reverse_lookup_only, *reverse_lookup_unify;
9584  const char *alive_tests, *hosts_filter, *file;
9585  gchar *ssh_credentials_element, *smb_credentials_element;
9586  gchar *esxi_credentials_element, *snmp_credentials_element;
9587  gchar *asset_hosts_element;
9588  gchar* comment_element = NULL;
9589  entity_t entity;
9590  GString *xml;
9591 
9592  no_redirect = params_value (params, "no_redirect");
9593  name = params_value (params, "name");
9594  hosts = params_value (params, "hosts");
9595  exclude_hosts = params_value (params, "exclude_hosts");
9596  reverse_lookup_only = params_value (params, "reverse_lookup_only");
9597  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
9598  target_source = params_value (params, "target_source");
9599  comment = params_value (params, "comment");
9600  port_list_id = params_value (params, "port_list_id");
9601  target_ssh_credential = params_value (params, "ssh_credential_id");
9602  port = params_value (params, "port");
9603  target_smb_credential = params_value (params, "smb_credential_id");
9604  target_esxi_credential = params_value (params, "esxi_credential_id");
9605  target_snmp_credential = params_value (params, "snmp_credential_id");
9606  alive_tests = params_value (params, "alive_tests");
9607  hosts_filter = params_value (params, "hosts_filter");
9608  file = params_value (params, "file");
9609 
9610  CHECK_PARAM_INVALID (name, "Create Target", "new_target");
9611  CHECK_PARAM_INVALID (target_source, "Create Target", "new_target")
9612  if (hosts == NULL && strcmp (target_source, "manual") == 0)
9613  return message_invalid (credentials, params, response_data,
9614  "Missing manual list of hosts",
9615  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9616  "Create Target", "new_target");
9617  if (strcmp (target_source, "file") == 0 && file == NULL)
9618  return message_invalid (credentials, params, response_data,
9619  "Missing hosts file",
9620  G_STRINGIFY (MHD_HTTP_BAD_REQUEST),
9621  "Create Target", "new_target");
9622 
9623  /* require hosts_filter if target_source is "asset_hosts" */
9624  if (strcmp (target_source, "asset_hosts") == 0)
9625  CHECK_PARAM_INVALID (hosts_filter, "Create Target", "new_target");
9626 
9627  CHECK_PARAM_INVALID (comment, "Create Target", "new_target");
9628  CHECK_PARAM_INVALID (port_list_id, "Create Target", "new_target");
9629  CHECK_PARAM_INVALID (target_ssh_credential, "Create Target", "new_target");
9630  if (strcmp (target_ssh_credential, "--"))
9631  CHECK_PARAM_INVALID (port, "Create Target", "new_target");
9632  CHECK_PARAM_INVALID (target_smb_credential, "Create Target", "new_target");
9633  CHECK_PARAM_INVALID (target_esxi_credential, "Create Target", "new_target");
9634  CHECK_PARAM_INVALID (target_snmp_credential, "Create Target", "new_target");
9635  CHECK_PARAM_INVALID (alive_tests, "Create Target", "new_target");
9636 
9637  if (comment != NULL)
9638  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
9639  else
9640  comment_element = g_strdup ("");
9641 
9642  if (strcmp (target_ssh_credential, "0") == 0)
9643  ssh_credentials_element = g_strdup ("");
9644  else
9645  ssh_credentials_element =
9646  g_strdup_printf ("<ssh_credential id=\"%s\">"
9647  "<port>%s</port>"
9648  "</ssh_credential>",
9649  target_ssh_credential,
9650  port);
9651 
9652  if (strcmp (target_smb_credential, "0") == 0)
9653  smb_credentials_element = g_strdup ("");
9654  else
9655  smb_credentials_element =
9656  g_strdup_printf ("<smb_credential id=\"%s\"/>",
9657  target_smb_credential);
9658 
9659  if (strcmp (target_esxi_credential, "0") == 0)
9660  esxi_credentials_element = g_strdup ("");
9661  else
9662  esxi_credentials_element =
9663  g_strdup_printf ("<esxi_credential id=\"%s\"/>",
9664  target_esxi_credential);
9665 
9666  if (strcmp (target_snmp_credential, "0") == 0)
9667  snmp_credentials_element = g_strdup ("");
9668  else
9669  snmp_credentials_element =
9670  g_strdup_printf ("<snmp_credential id=\"%s\"/>",
9671  target_snmp_credential);
9672 
9673  if (strcmp (target_source, "asset_hosts") == 0)
9674  asset_hosts_element = g_strdup_printf ("<asset_hosts filter=\"%s\"/>",
9675  hosts_filter);
9676  else
9677  asset_hosts_element = g_strdup ("");
9678 
9679  /* Create the target. */
9680 
9681  xml = g_string_new ("");
9682 
9683  xml_string_append (xml,
9684  "<name>%s</name>"
9685  "<hosts>%s</hosts>"
9686  "<exclude_hosts>%s</exclude_hosts>"
9687  "<reverse_lookup_only>%s</reverse_lookup_only>"
9688  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
9689  "<port_list id=\"%s\"/>"
9690  "<alive_tests>%s</alive_tests>",
9691  name,
9692  strcmp (target_source, "file") == 0 ? file : hosts,
9693  exclude_hosts ? exclude_hosts : "",
9694  reverse_lookup_only ? reverse_lookup_only : "0",
9695  reverse_lookup_unify ? reverse_lookup_unify : "0",
9696  port_list_id,
9697  alive_tests);
9698 
9699  command = g_strdup_printf ("<create_target>"
9700  "%s%s%s%s%s%s%s"
9701  "</create_target>",
9702  xml->str,
9703  comment_element,
9704  ssh_credentials_element,
9705  smb_credentials_element,
9706  esxi_credentials_element,
9707  snmp_credentials_element,
9708  asset_hosts_element);
9709 
9710  g_string_free (xml, TRUE);
9711  g_free (comment_element);
9712  g_free (ssh_credentials_element);
9713  g_free (smb_credentials_element);
9714  g_free (esxi_credentials_element);
9715 
9716  ret = omp (credentials,
9717  &response,
9718  &entity,
9719  response_data,
9720  command);
9721  g_free (command);
9722  switch (ret)
9723  {
9724  case 0:
9725  break;
9726  case -1:
9727  /* 'omp' set response. */
9728  return response;
9729  case 1:
9730  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9731  return gsad_message (credentials,
9732  "Internal error", __FUNCTION__, __LINE__,
9733  "An internal error occurred while creating a new target. "
9734  "No new target was created. "
9735  "Diagnostics: Failure to send command to manager daemon.",
9736  "/omp?cmd=get_targets", response_data);
9737  case 2:
9738  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9739  return gsad_message (credentials,
9740  "Internal error", __FUNCTION__, __LINE__,
9741  "An internal error occurred while creating a new target. "
9742  "It is unclear whether the target has been created or not. "
9743  "Diagnostics: Failure to receive response from manager daemon.",
9744  "/omp?cmd=get_targets", response_data);
9745  default:
9746  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9747  return gsad_message (credentials,
9748  "Internal error", __FUNCTION__, __LINE__,
9749  "An internal error occurred while creating a new target. "
9750  "It is unclear whether the target has been created or not. "
9751  "Diagnostics: Internal Error.",
9752  "/omp?cmd=get_targets", response_data);
9753  }
9754 
9755  if (entity_attribute (entity, "id"))
9756  params_add (params, "target_id", entity_attribute (entity, "id"));
9757  html = response_from_entity (credentials, params, entity,
9758  (no_redirect && strcmp (no_redirect, "0")),
9759  NULL, "get_targets",
9760  NULL, "new_target",
9761  "Create Target", response_data);
9762  free_entity (entity);
9763  g_free (response);
9764  return html;
9765 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * message_invalid(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data, const char *message, const char *status, const char *op_name, const char *next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1472
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Create a task, get all tasks, XSL transform the result.

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

Definition at line 4217 of file gsad_omp.c.

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

4219 {
4220  entity_t entity;
4221  int ret;
4222  gchar *schedule_element, *command;
4223  gchar *response, *html;
4224  const char *no_redirect;
4225  const char *name, *comment, *config_id, *target_id, *scanner_type;
4226  const char *scanner_id, *schedule_id, *schedule_periods;
4227  const char *max_checks, *max_hosts;
4228  const char *in_assets, *hosts_ordering, *alterable, *source_iface;
4229  const char *add_tag, *tag_name, *tag_value, *auto_delete, *auto_delete_data;
4230  const char *apply_overrides, *min_qod;
4231  params_t *alerts;
4232  GString *alert_element;
4233 
4234  no_redirect = params_value (params, "no_redirect");
4235  name = params_value (params, "name");
4236  comment = params_value (params, "comment");
4237  target_id = params_value (params, "target_id");
4238  scanner_type = params_value (params, "scanner_type");
4239  hosts_ordering = params_value (params, "hosts_ordering");
4240  schedule_id = params_value (params, "schedule_id");
4241  schedule_periods = params_value (params, "schedule_periods");
4242  scanner_id = params_value (params, "scanner_id");
4243  config_id = params_value (params, "config_id");
4244  in_assets = params_value (params, "in_assets");
4245  apply_overrides = params_value (params, "apply_overrides");
4246  min_qod = params_value (params, "min_qod");
4247  max_checks = params_value (params, "max_checks");
4248  source_iface = params_value (params, "source_iface");
4249  auto_delete = params_value (params, "auto_delete");
4250  auto_delete_data = params_value (params, "auto_delete_data");
4251  max_hosts = params_value (params, "max_hosts");
4252  alterable = params_value (params, "alterable");
4253  add_tag = params_value (params, "add_tag");
4254  tag_name = params_value (params, "tag_name");
4255  tag_value = params_value (params, "tag_value");
4256  CHECK (scanner_type);
4257  if (!strcmp (scanner_type, "1"))
4258  {
4259  hosts_ordering = "";
4260  max_checks = "";
4261  source_iface = "";
4262  max_hosts = "";
4263  }
4264  else if (!strcmp (scanner_type, "3"))
4265  {
4266  config_id = "";
4267  hosts_ordering = "";
4268  max_checks = "";
4269  source_iface = "";
4270  max_hosts = "";
4271  }
4272 
4273  CHECK (name);
4274  CHECK (comment);
4275  CHECK (config_id);
4276  CHECK (target_id);
4277  CHECK (hosts_ordering);
4278  CHECK (scanner_id);
4279  CHECK (schedule_id);
4280  if (params_given (params, "schedule_periods"))
4281  {
4282  CHECK (schedule_periods);
4283  }
4284  else
4285  schedule_periods = "0";
4286  CHECK (in_assets);
4287  if (!strcmp (in_assets, "1"))
4288  {
4289  CHECK (apply_overrides);
4290  CHECK (min_qod);
4291  }
4292  else
4293  {
4294  if (!params_given (params, "apply_overrides")
4295  || !params_valid (params, "apply_overrides"))
4296  apply_overrides = "";
4297 
4298  if (!params_given (params, "min_qod")
4299  || !params_valid (params, "min_qod"))
4300  min_qod = "";
4301  }
4302  CHECK (max_checks);
4303  CHECK (source_iface);
4304  CHECK (auto_delete);
4305  CHECK (auto_delete_data);
4306  CHECK (max_hosts);
4307  CHECK (alterable);
4308  if (add_tag)
4309  {
4310  CHECK (add_tag);
4311  CHECK (tag_name);
4312  CHECK (tag_value);
4313  }
4314 
4315  if (schedule_id == NULL || strcmp (schedule_id, "0") == 0)
4316  schedule_element = g_strdup ("");
4317  else
4318  schedule_element = g_strdup_printf ("<schedule id=\"%s\"/>", schedule_id);
4319 
4320  alert_element = g_string_new ("");
4321  if (params_given (params, "alert_id_optional:"))
4322  alerts = params_values (params, "alert_id_optional:");
4323  else
4324  alerts = params_values (params, "alert_ids:");
4325 
4326  if (alerts)
4327  {
4328  params_iterator_t iter;
4329  char *name;
4330  param_t *param;
4331 
4332  params_iterator_init (&iter, alerts);
4333  while (params_iterator_next (&iter, &name, &param))
4334  if (param->value && strcmp (param->value, "0"))
4335  g_string_append_printf (alert_element,
4336  "<alert id=\"%s\"/>",
4337  param->value ? param->value : "");
4338  }
4339 
4340  command = g_strdup_printf ("<create_task>"
4341  "<config id=\"%s\"/>"
4342  "<schedule_periods>%s</schedule_periods>"
4343  "%s%s"
4344  "<target id=\"%s\"/>"
4345  "<scanner id=\"%s\"/>"
4346  "<hosts_ordering>%s</hosts_ordering>"
4347  "<name>%s</name>"
4348  "<comment>%s</comment>"
4349  "<preferences>"
4350  "<preference>"
4351  "<scanner_name>max_checks</scanner_name>"
4352  "<value>%s</value>"
4353  "</preference>"
4354  "<preference>"
4355  "<scanner_name>max_hosts</scanner_name>"
4356  "<value>%s</value>"
4357  "</preference>"
4358  "<preference>"
4359  "<scanner_name>in_assets</scanner_name>"
4360  "<value>%s</value>"
4361  "</preference>"
4362  "<preference>"
4363  "<scanner_name>"
4364  "assets_apply_overrides"
4365  "</scanner_name>"
4366  "<value>%s</value>"
4367  "</preference>"
4368  "<preference>"
4369  "<scanner_name>assets_min_qod</scanner_name>"
4370  "<value>%s</value>"
4371  "</preference>"
4372  "<preference>"
4373  "<scanner_name>source_iface</scanner_name>"
4374  "<value>%s</value>"
4375  "</preference>"
4376  "<preference>"
4377  "<scanner_name>auto_delete</scanner_name>"
4378  "<value>%s</value>"
4379  "</preference>"
4380  "<preference>"
4381  "<scanner_name>auto_delete_data</scanner_name>"
4382  "<value>%s</value>"
4383  "</preference>"
4384  "</preferences>"
4385  "<alterable>%i</alterable>"
4386  "</create_task>",
4387  config_id,
4388  schedule_periods,
4389  schedule_element,
4390  alert_element->str,
4391  target_id,
4392  scanner_id,
4393  hosts_ordering,
4394  name,
4395  comment,
4396  max_checks,
4397  max_hosts,
4398  strcmp (in_assets, "0") ? "yes" : "no",
4399  strcmp (apply_overrides, "0") ? "yes" : "no",
4400  min_qod,
4401  source_iface,
4402  auto_delete,
4403  auto_delete_data,
4404  alterable ? strcmp (alterable, "0") : 0);
4405 
4406  ret = omp (credentials,
4407  &response,
4408  &entity,
4409  response_data,
4410  command);
4411  g_free (command);
4412 
4413  g_free (schedule_element);
4414  g_string_free (alert_element, TRUE);
4415 
4416  switch (ret)
4417  {
4418  case 0:
4419  break;
4420  case -1:
4421  /* 'omp' set response. */
4422  return response;
4423  case 1:
4424  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4425  return gsad_message (credentials,
4426  "Internal error", __FUNCTION__, __LINE__,
4427  "An internal error occurred while creating a new task. "
4428  "No new task was created. "
4429  "Diagnostics: Failure to send command to manager daemon.",
4430  "/omp?cmd=get_tasks", response_data);
4431  case 2:
4432  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4433  return gsad_message (credentials,
4434  "Internal error", __FUNCTION__, __LINE__,
4435  "An internal error occurred while creating a new task. "
4436  "It is unclear whether the task has been created or not. "
4437  "Diagnostics: Failure to receive response from manager daemon.",
4438  "/omp?cmd=get_tasks", response_data);
4439  default:
4440  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4441  return gsad_message (credentials,
4442  "Internal error", __FUNCTION__, __LINE__,
4443  "An internal error occurred while creating a new task. "
4444  "It is unclear whether the task has been created or not. "
4445  "Diagnostics: Internal Error.",
4446  "/omp?cmd=get_tasks", response_data);
4447  }
4448 
4449  if (omp_success (entity))
4450  {
4451  if (add_tag && strcmp (add_tag, "0"))
4452  {
4453  const char *new_task_id = entity_attribute (entity, "id");
4454  gchar *tag_command, *tag_response;
4455  entity_t tag_entity;
4456 
4457  if (tag_value && strcmp (tag_value, ""))
4458  tag_command
4459  = g_markup_printf_escaped ("<create_tag>"
4460  "<name>%s</name>"
4461  "<resource id=\"%s\">"
4462  "<type>task</type>"
4463  "</resource>"
4464  "<value>%s</value>"
4465  "</create_tag>",
4466  tag_name,
4467  new_task_id,
4468  tag_value);
4469  else
4470  tag_command
4471  = g_markup_printf_escaped ("<create_tag>"
4472  "<name>%s</name>"
4473  "<resource id=\"%s\">"
4474  "<type>task</type>"
4475  "</resource>"
4476  "</create_tag>",
4477  tag_name,
4478  new_task_id);
4479 
4480  ret = omp (credentials,
4481  &tag_response,
4482  &tag_entity,
4483  response_data,
4484  tag_command);
4485 
4486  switch (ret)
4487  {
4488  case 0:
4489  case -1:
4490  break;
4491  case 1:
4492  free_entity (entity);
4493  g_free (response);
4494  response_data->http_status_code
4495  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4496  return gsad_message (credentials,
4497  "Internal error", __FUNCTION__, __LINE__,
4498  "An internal error occurred while creating a new tag. "
4499  "No new tag was created. "
4500  "Diagnostics: Failure to send command to manager daemon.",
4501  "/omp?cmd=get_tasks", response_data);
4502  case 2:
4503  free_entity (entity);
4504  g_free (response);
4505  response_data->http_status_code
4506  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4507  return gsad_message (credentials,
4508  "Internal error", __FUNCTION__, __LINE__,
4509  "An internal error occurred while creating a new tag. "
4510  "It is unclear whether the tag has been created or not. "
4511  "Diagnostics: Failure to receive response from manager daemon.",
4512  "/omp?cmd=get_tasks", response_data);
4513  default:
4514  free_entity (entity);
4515  g_free (response);
4516  response_data->http_status_code
4517  = MHD_HTTP_INTERNAL_SERVER_ERROR;
4518  return gsad_message (credentials,
4519  "Internal error", __FUNCTION__, __LINE__,
4520  "An internal error occurred while creating a new task. "
4521  "It is unclear whether the tag has been created or not. "
4522  "Diagnostics: Internal Error.",
4523  "/omp?cmd=get_tasks", response_data);
4524  }
4525 
4526  if (entity_attribute (entity, "id"))
4527  params_add (params, "task_id", entity_attribute (entity, "id"));
4528  html
4529  = response_from_entity (credentials, params, tag_entity,
4530  (no_redirect && strcmp (no_redirect, "0")),
4531  NULL, "get_tasks",
4532  NULL, "new_tasks",
4533  "Create Task and Tag", response_data);
4534  free_entity (tag_entity);
4535  g_free (tag_response);
4536  }
4537  else
4538  {
4539  if (entity_attribute (entity, "id"))
4540  params_add (params, "task_id", entity_attribute (entity, "id"));
4541  html
4542  = response_from_entity (credentials, params, entity,
4543  (no_redirect && strcmp (no_redirect, "0")),
4544  NULL, "get_tasks",
4545  NULL, "new_task",
4546  "Create Task", response_data);
4547  }
4548  }
4549  else
4550  {
4551  html = response_from_entity (credentials, params, entity,
4552  (no_redirect && strcmp (no_redirect, "0")),
4553  NULL, "get_tasks",
4554  NULL, "new_task",
4555  "Create Task", response_data);
4556  }
4557  free_entity (entity);
4558  g_free (response);
4559  return html;
4560 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9772
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

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

Create a user, get all users, XSL transform the result.

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

Definition at line 25329 of file gsad_omp.c.

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

25331 {
25332  const char *no_redirect;
25333  const char *name, *password, *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25334  const char *auth_method;
25335  int ret;
25336  params_t *groups, *roles;
25337  GString *group_elements, *role_elements, *string;
25338  gchar *buf, *response, *html;
25339  entity_t entity;
25340 
25341  no_redirect = params_value (params, "no_redirect");
25342  name = params_value (params, "login");
25343  password = params_value (params, "password");
25344  hosts = params_value (params, "access_hosts");
25345  hosts_allow = params_value (params, "hosts_allow");
25346  ifaces = params_value (params, "access_ifaces");
25347  ifaces_allow = params_value (params, "ifaces_allow");
25348  auth_method = params_value (params, "auth_method");
25349 
25350  CHECK_PARAM_INVALID (name, "Create User", "new_user");
25351  CHECK_PARAM_INVALID (password, "Create User", "new_user");
25352  CHECK_PARAM_INVALID (hosts, "Create User", "new_user");
25353  CHECK_PARAM_INVALID (hosts_allow, "Create User", "new_user");
25354  CHECK_PARAM_INVALID (ifaces, "Create User", "new_user");
25355  CHECK_PARAM_INVALID (ifaces_allow, "Create User", "new_user");
25356 
25357  /* Create the user. */
25358 
25359  string = g_string_new ("<create_user>");
25360  buf = g_markup_printf_escaped ("<name>%s</name>"
25361  "<password>%s</password>",
25362  name,
25363  password);
25364 
25365  g_string_append (string, buf);
25366  g_free (buf);
25367 
25368  group_elements = g_string_new ("<groups>");
25369  if (params_given (params, "group_id_optional:"))
25370  groups = params_values (params, "group_id_optional:");
25371  else
25372  groups = params_values (params, "group_ids:");
25373 
25374  if (groups)
25375  {
25376  params_iterator_t iter;
25377  char *name;
25378  param_t *param;
25379 
25380  params_iterator_init (&iter, groups);
25381  while (params_iterator_next (&iter, &name, &param))
25382  {
25383  if (param->value && strcmp (param->value, "--"))
25384  g_string_append_printf (group_elements,
25385  "<group id=\"%s\"/>",
25386  param->value ? param->value : "");
25387  }
25388  }
25389  g_string_append (string, group_elements->str);
25390  g_string_free (group_elements, TRUE);
25391  g_string_append (string, "</groups>");
25392 
25393  role_elements = g_string_new ("");
25394  if (params_given (params, "role_id_optional:"))
25395  roles = params_values (params, "role_id_optional:");
25396  else
25397  roles = params_values (params, "role_ids:");
25398 
25399  if (roles)
25400  {
25401  params_iterator_t iter;
25402  char *name;
25403  param_t *param;
25404 
25405  params_iterator_init (&iter, roles);
25406  while (params_iterator_next (&iter, &name, &param))
25407  {
25408  if (param->value && strcmp (param->value, "--"))
25409  g_string_append_printf (role_elements,
25410  "<role id=\"%s\"/>",
25411  param->value ? param->value : "");
25412  }
25413  }
25414  g_string_append (string, role_elements->str);
25415  g_string_free (role_elements, TRUE);
25416 
25417  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
25418  "<ifaces allow=\"%s\">%s</ifaces>",
25419  hosts_allow, hosts, ifaces_allow, ifaces);
25420  g_string_append (string, buf);
25421  g_free (buf);
25422  if (auth_method && !strcmp (auth_method, "1"))
25423  g_string_append
25424  (string, "<sources><source>ldap_connect</source></sources>");
25425  else if (auth_method && !strcmp (auth_method, "2"))
25426  g_string_append
25427  (string, "<sources><source>radius_connect</source></sources>");
25428  g_string_append (string, "</create_user>");
25429 
25430  buf = g_string_free (string, FALSE);
25431 
25432  response = NULL;
25433  entity = NULL;
25434  ret = omp (credentials, &response, &entity, response_data, buf);
25435  g_free (buf);
25436  switch (ret)
25437  {
25438  case 0:
25439  case -1:
25440  break;
25441  case 1:
25442  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25443  return gsad_message (credentials,
25444  "Internal error", __FUNCTION__, __LINE__,
25445  "An internal error occurred while creating a new user. "
25446  "No new user was created. "
25447  "Diagnostics: Failure to send command to manager daemon.",
25448  "/omp?cmd=get_users", response_data);
25449  case 2:
25450  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25451  return gsad_message (credentials,
25452  "Internal error", __FUNCTION__, __LINE__,
25453  "An internal error occurred while creating a new user. "
25454  "It is unclear whether the user has been created or not. "
25455  "Diagnostics: Failure to receive response from manager daemon.",
25456  "/omp?cmd=get_users", response_data);
25457  default:
25458  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25459  return gsad_message (credentials,
25460  "Internal error", __FUNCTION__, __LINE__,
25461  "An internal error occurred while creating a new user. "
25462  "It is unclear whether the user has been created or not. "
25463  "Diagnostics: Internal Error.",
25464  "/omp?cmd=get_users", response_data);
25465  }
25466 
25467  if (entity_attribute (entity, "id"))
25468  params_add (params, "user_id", entity_attribute (entity, "id"));
25469  html = response_from_entity (credentials, params, entity,
25470  (no_redirect && strcmp (no_redirect, "0")),
25471  NULL, "get_users",
25472  NULL, "new_user",
25473  "Create User", response_data);
25474  free_entity (entity);
25475  g_free (response);
25476  return html;
25477 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

char* cvss_calculator ( credentials_t ,
params_t ,
cmd_response_data_t  
)

Definition at line 26028 of file gsad_omp.c.

References params_value().

Referenced by exec_omp_get().

26030 {
26031  GString *xml;
26032  const char *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a;
26033  const char *cvss_vector, *name;
26034 
26035  cvss_av = params_value (params, "cvss_av");
26036  cvss_au = params_value (params, "cvss_au");
26037  cvss_ac = params_value (params, "cvss_ac");
26038  cvss_c = params_value (params, "cvss_c");
26039  cvss_i = params_value (params, "cvss_i");
26040  cvss_a = params_value (params, "cvss_a");
26041  cvss_vector = params_value (params, "cvss_vector");
26042  name = params_value (params, "name");
26043 
26044  xml = g_string_new ("<cvss_calculator>");
26045 
26046  /* Calculate base score */
26047  if (cvss_av && cvss_au && cvss_ac && cvss_c && cvss_i && cvss_a)
26048  {
26049  char *vector = g_strdup_printf
26050  ("AV:%c/AC:%c/Au:%c/C:%c/I:%c/A:%c",
26051  *cvss_av, *cvss_ac, *cvss_au, *cvss_c, *cvss_i, *cvss_a);
26052 
26053  g_string_append_printf (xml,
26054  "<cvss_vector>%s</cvss_vector>"
26055  "<cvss_score>%.1f</cvss_score>",
26056  vector,
26057  get_cvss_score_from_base_metrics (vector));
26058 
26059  g_string_append_printf
26060  (xml,
26061  "<cvss_av>%c</cvss_av><cvss_au>%c</cvss_au>"
26062  "<cvss_ac>%c</cvss_ac><cvss_c>%c</cvss_c>"
26063  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
26064  *cvss_av, *cvss_au, *cvss_ac, *cvss_c, *cvss_i, *cvss_a);
26065 
26066  g_free (vector);
26067  }
26068  else if (cvss_vector)
26069  {
26070  double cvss_score = get_cvss_score_from_base_metrics (cvss_vector);
26071 
26072  g_string_append_printf (xml,
26073  "<cvss_vector>%s</cvss_vector>"
26074  "<cvss_score>%.1f</cvss_score>",
26075  cvss_vector,
26076  cvss_score);
26077 
26078  if (cvss_score != -1.0)
26079  {
26080  cvss_av = strstr (cvss_vector, "AV:");
26081  cvss_ac = strstr (cvss_vector, "/AC:");
26082  cvss_au = strstr (cvss_vector, "/Au:");
26083  if (cvss_au == NULL)
26084  cvss_au = strstr (cvss_vector, "/AU:");
26085  cvss_c = strstr (cvss_vector, "/C:");
26086  cvss_i = strstr (cvss_vector, "/I:");
26087  cvss_a = strstr (cvss_vector, "/A:");
26088 
26089  if (cvss_av && cvss_ac && cvss_au && cvss_c
26090  && cvss_i && cvss_a)
26091  g_string_append_printf
26092  (xml,
26093  "<cvss_av>%c</cvss_av><cvss_ac>%c</cvss_ac>"
26094  "<cvss_au>%c</cvss_au><cvss_c>%c</cvss_c>"
26095  "<cvss_i>%c</cvss_i><cvss_a>%c</cvss_a>",
26096  *(cvss_av + 3), *(cvss_ac + 4), *(cvss_au + 4),
26097  *(cvss_c + 3), *(cvss_i + 3), *(cvss_a + 3));
26098  }
26099  }
26100  else if (name && !strcmp ("vector", name))
26101  {
26102  g_string_append_printf (xml,
26103  "<cvss_score>%.1f</cvss_score>",
26104  -1.0);
26105  }
26106 
26107  g_string_append (xml, "</cvss_calculator>");
26108  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
26109  response_data);
26110 }
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

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

Show a dashboard.

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

Definition at line 26122 of file gsad_omp.c.

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

Referenced by exec_omp_get().

26124 {
26125  GString *xml;
26126  const char *name;
26127  gchar* response;
26128  entity_t entity;
26129  int ret;
26130 
26131  name = params_value (params, "dashboard_name");
26132  if (name == NULL)
26133  {
26134  if (credentials->guest)
26135  name = "secinfo";
26136  else
26137  name = "main";
26138  }
26139 
26140  xml = g_string_new ("<dashboard>");
26141  g_string_append_printf (xml, "<name>%s</name>", name);
26142 
26143  response = NULL;
26144  entity = NULL;
26145 
26146  // Test if SCAP and CERT databases are available
26147  if (strcasecmp (name, "") == 0
26148  || strcasecmp (name, "Main") == 0
26149  || strcasecmp (name, "SecInfo") == 0)
26150  {
26151  ret = ompf (credentials,
26152  &response,
26153  &entity,
26154  response_data,
26155  "<get_info type=\"cve\" info_id=\"--\"/>");
26156 
26157  switch (ret)
26158  {
26159  case 0:
26160  case -1:
26161  break;
26162  case 1:
26163  g_string_free (xml, TRUE);
26164  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26165  return gsad_message (credentials,
26166  "Internal error", __FUNCTION__, __LINE__,
26167  "An internal error occurred while "
26168  "testing SecInfo database availability. "
26169  "Diagnostics: Failure to send command to "
26170  "manager daemon.",
26171  "/omp?cmd=dashboard", response_data);
26172  case 2:
26173  g_string_free (xml, TRUE);
26174  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26175  return gsad_message (credentials,
26176  "Internal error", __FUNCTION__, __LINE__,
26177  "An internal error occurred while "
26178  "testing SecInfo database availability. "
26179  "Diagnostics: Failure to receive response from "
26180  "manager daemon.",
26181  "/omp?cmd=dashboard", response_data);
26182  default:
26183  g_string_free (xml, TRUE);
26184  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26185  return gsad_message (credentials,
26186  "Internal error", __FUNCTION__, __LINE__,
26187  "An internal error occurred while "
26188  "testing SecInfo database availability. "
26189  "Diagnostics: Internal Error.",
26190  "/omp?cmd=dashboard", response_data);
26191  }
26192  g_string_append_printf (xml,
26193  "<secinfo_test>%s</secinfo_test>",
26194  response);
26195  g_free (response);
26196  free_entity (entity);
26197  }
26198 
26199  if (strcasecmp (name, "SecInfo") == 0)
26200  ret = ompf (credentials,
26201  &response,
26202  &entity,
26203  response_data,
26204  "<get_filters filter=\"type=info or type= first=1 rows=-1\"/>");
26205  else
26206  ret = ompf (credentials,
26207  &response,
26208  &entity,
26209  response_data,
26210  "<get_filters filter=\"first=1 rows=-1\"/>");
26211 
26212  switch (ret)
26213  {
26214  case 0:
26215  case -1:
26216  break;
26217  case 1:
26218  g_string_free (xml, TRUE);
26219  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26220  return gsad_message (credentials,
26221  "Internal error", __FUNCTION__, __LINE__,
26222  "An internal error occurred while getting the "
26223  "filters list. "
26224  "Diagnostics: Failure to send command to "
26225  "manager daemon.",
26226  "/omp?cmd=dashboard", response_data);
26227  case 2:
26228  g_string_free (xml, TRUE);
26229  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26230  return gsad_message (credentials,
26231  "Internal error", __FUNCTION__, __LINE__,
26232  "An internal error occurred while getting the "
26233  "filters list. "
26234  "Diagnostics: Failure to receive response from "
26235  "manager daemon.",
26236  "/omp?cmd=dashboard", response_data);
26237  default:
26238  g_string_free (xml, TRUE);
26239  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26240  return gsad_message (credentials,
26241  "Internal error", __FUNCTION__, __LINE__,
26242  "An internal error occurred while getting the "
26243  "filters list. "
26244  "Diagnostics: Internal Error.",
26245  "/omp?cmd=dashboard", response_data);
26246  }
26247 
26248  g_string_append (xml, response);
26249  g_free (response);
26250  free_entity (entity);
26251 
26252  g_string_append (xml, "</dashboard>");
26253  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
26254  response_data);
26255 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int guest
Whether the user is a guest user.
Definition: gsad_base.h:86
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

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

Delete agent, get all agents, XSL transform result.

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

Definition at line 7198 of file gsad_omp.c.

References delete_resource().

7200 {
7201  return delete_resource ("agent", credentials, params, 0, "get_agents",
7202  response_data);
7203 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete an alert, get all alerts, XSL transform the result.

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

Definition at line 8488 of file gsad_omp.c.

References delete_resource().

8490 {
8491  return delete_resource ("alert", credentials, params, 0, "get_alerts",
8492  response_data);
8493 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

char* delete_asset_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete an asset, go to the next page.

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

Definition at line 27582 of file gsad_omp.c.

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

27584 {
27585  openvas_connection_t connection;
27586  gchar *html, *response, *resource_id;
27587  const char *next_id, *no_redirect;
27588  entity_t entity;
27589  gchar *next_url;
27590 
27591  if (params_value (params, "asset_id"))
27592  resource_id = g_strdup (params_value (params, "asset_id"));
27593  else if (params_value (params, "report_id"))
27594  resource_id = g_strdup (params_value (params, "report_id"));
27595  else
27596  {
27597  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27598  return gsad_message (credentials,
27599  "Internal error", __FUNCTION__, __LINE__,
27600  "An internal error occurred while deleting an asset. "
27601  "The asset was not deleted. "
27602  "Diagnostics: Required parameter was NULL.",
27603  "/omp?cmd=get_tasks", response_data);
27604  }
27605 
27606  /* This is a hack, needed because asset_id is the param name used for
27607  * both the asset being deleted and the asset on the next page. */
27608  next_id = params_value (params, "next_id");
27609  if (next_id
27610  && params_value (params, "asset_id"))
27611  {
27612  param_t *param;
27613  param = params_get (params, "asset_id");
27614  g_free (param->value);
27615  param->value = g_strdup (next_id);
27616  param->value_size = strlen (param->value);
27617  }
27618 
27619  switch (manager_connect (credentials, &connection, &html,
27620  response_data))
27621  {
27622  case 0:
27623  break;
27624  case -1:
27625  if (html)
27626  {
27627  g_free (resource_id);
27628  return html;
27629  }
27630  /* Fall through. */
27631  default:
27632  g_free (resource_id);
27633  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27634  return gsad_message (credentials,
27635  "Internal error", __FUNCTION__, __LINE__,
27636  "An internal error occurred while deleting an asset. "
27637  "The asset is not deleted. "
27638  "Diagnostics: Failure to connect to manager daemon.",
27639  "/omp?cmd=get_tasks", response_data);
27640  }
27641 
27642  /* Delete the resource and get all resources. */
27643 
27644  if (openvas_connection_sendf (&connection,
27645  "<delete_asset %s_id=\"%s\"/>",
27646  params_value (params, "asset_id")
27647  ? "asset" : "report",
27648  resource_id)
27649  == -1)
27650  {
27651  openvas_connection_close (&connection);
27652  g_free (resource_id);
27653  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27654  return gsad_message (credentials,
27655  "Internal error", __FUNCTION__, __LINE__,
27656  "An internal error occurred while deleting an asset. "
27657  "The asset is not deleted. "
27658  "Diagnostics: Failure to send command to manager daemon.",
27659  "/omp?cmd=get_tasks", response_data);
27660  }
27661 
27662  g_free (resource_id);
27663 
27664  entity = NULL;
27665  if (read_entity_and_text_c (&connection, &entity, &response))
27666  {
27667  openvas_connection_close (&connection);
27668  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27669  return gsad_message (credentials,
27670  "Internal error", __FUNCTION__, __LINE__,
27671  "An internal error occurred while deleting an asset. "
27672  "It is unclear whether the asset has been deleted or not. "
27673  "Diagnostics: Failure to read response from manager daemon.",
27674  "/omp?cmd=get_tasks", response_data);
27675  }
27676 
27677  openvas_connection_close (&connection);
27678 
27679  /* Cleanup, and return transformed XML. */
27680 
27681  if (params_given (params, "next") == 0)
27682  params_add (params, "next", "get_asset");
27683 
27684  no_redirect = params_value (params, "no_redirect");
27685  if (no_redirect && strcmp (no_redirect, "0"))
27686  {
27687  html = next_page (credentials, params, response, response_data);
27688  if (html == NULL)
27689  {
27690  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
27691  html = gsad_message (credentials,
27692  "Internal error", __FUNCTION__, __LINE__,
27693  "An internal error occurred while deleting an "
27694  "asset. Diagnostics: Error in parameter next.",
27695  "/omp?cmd=get_tasks", response_data);
27696  }
27697  }
27698  else
27699  {
27700  next_url = next_page_url (credentials, params,
27701  NULL, "get_asset", "delete_asset",
27702  entity_attribute (entity, "status"),
27703  entity_attribute (entity, "status_text"));
27704  response_data->redirect = next_url;
27705 
27706  html = NULL;
27707  }
27708 
27709  g_free (response);
27710  free_entity (entity);
27711  return html;
27712 }
gchar * value
Definition: gsad_base.h:146
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:650
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
int value_size
Definition: gsad_base.h:152
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gchar * redirect
HTTP status code.
Definition: gsad_base.h:94
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Delete config, get all configs, XSL transform the result.

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

Definition at line 13286 of file gsad_omp.c.

References delete_resource().

13288 {
13289  return delete_resource ("config", credentials, params, 0, "get_configs",
13290  response_data);
13291 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete credential, get all credentials, XSL transform result.

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

Definition at line 6750 of file gsad_omp.c.

References delete_resource().

6752 {
6753  return delete_resource ("credential", credentials, params, 0,
6754  "get_credentials", response_data);
6755 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a filter, get all filters, XSL transform the result.

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

Definition at line 24417 of file gsad_omp.c.

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

24419 {
24420  param_t *filt_id, *id;
24421  GList *list;
24422 
24423  filt_id = params_get (params, "filt_id");
24424  id = params_get (params, "filter_id");
24425  if (id && id->value && filt_id && filt_id->value
24426  && (strcmp (id->value, filt_id->value) == 0))
24427  // TODO: Add params_remove.
24428  filt_id->value = NULL;
24429 
24430  /* remove to be deleted key from the user credentials */
24431  if (id && id->value)
24432  {
24433  find_by_value_t find;
24434 
24435  init_find_by_value (&find, id->value);
24436 
24437  g_tree_foreach (credentials->last_filt_ids, (GTraverseFunc)find_by_value,
24438  &find);
24439  if (find.keys != NULL)
24440  {
24441  list = g_list_first (find.keys);
24442 
24443  while (list != NULL)
24444  {
24445  g_debug ("%s removing filter from last filter ids for %s\n",
24446  __FUNCTION__, (char *)list->data);
24447  g_tree_remove (credentials->last_filt_ids, list->data);
24448  list = g_list_next (find.keys);
24449  }
24450  }
24451 
24452  free_find_by_value(&find);
24453  }
24454 
24455  return delete_resource ("filter", credentials, params, 0, "get_filters",
24456  response_data);
24457 }
gchar * value
Definition: gsad_base.h:146
param_t * params_get(params_t *params, const char *name)
Get param.
Definition: gsad_base.c:650
GTree * last_filt_ids
Last filter ids.
Definition: gsad_base.h:83
void init_find_by_value(find_by_value_t *find, gchar *value)
Definition: gsad_omp.c:395
Structure to search a key by value.
Definition: gsad_omp.c:388
Request parameter.
Definition: gsad_base.h:144
GList * keys
Definition: gsad_omp.c:391
void free_find_by_value(find_by_value_t *find)
Definition: gsad_omp.c:402
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a group, get all groups, XSL transform the result.

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

Definition at line 20797 of file gsad_omp.c.

References delete_resource().

20799 {
20800  return delete_resource ("group", credentials, params, 0,
20801  "get_groups", response_data);
20802 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete note, get next page, XSL transform the result.

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

Definition at line 16102 of file gsad_omp.c.

References delete_resource().

16104 {
16105  return delete_resource ("note", credentials, params, 0, NULL, response_data);
16106 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete override, get next page, XSL transform the result.

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

Definition at line 16846 of file gsad_omp.c.

References delete_resource().

16848 {
16849  return delete_resource ("override", credentials, params, 0, NULL,
16850  response_data);
16851 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a permission, get all permissions, XSL transform the result.

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

Definition at line 21170 of file gsad_omp.c.

References delete_resource().

21172 {
21173  return delete_resource ("permission", credentials, params, 0, NULL,
21174  response_data);
21175 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a port list, get all port lists, XSL transform the result.

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

Definition at line 23335 of file gsad_omp.c.

References delete_resource().

23337 {
23338  return delete_resource ("port_list", credentials, params, 0, "get_port_lists",
23339  response_data);
23340 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a port range, get the port list, XSL transform the result.

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

Definition at line 23369 of file gsad_omp.c.

References delete_resource().

23371 {
23372  return delete_resource ("port_range", credentials, params, 1,
23373  "edit_port_list", response_data);
23374 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete report format, get report formats, XSL transform the result.

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

Definition at line 18552 of file gsad_omp.c.

References delete_resource().

18554 {
18555  return delete_resource ("report_format", credentials, params, 0,
18556  "get_report_formats", response_data);
18557 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete report, get task status, XSL transform the result.

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

Definition at line 13651 of file gsad_omp.c.

References delete_resource().

13653 {
13654  return delete_resource ("report", credentials, params, 0, NULL,
13655  response_data);
13656 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a role, get all roles, XSL transform the result.

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

Definition at line 23521 of file gsad_omp.c.

References delete_resource().

23523 {
23524  return delete_resource ("role", credentials, params, 0, "get_roles",
23525  response_data);
23526 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a scanner, get all scanners, XSL transform the result.

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

Definition at line 17511 of file gsad_omp.c.

References delete_resource().

17513 {
17514  return delete_resource ("scanner", credentials, params, 0, "get_scanners",
17515  response_data);
17516 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a schedule, get all schedules, XSL transform the result.

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

Definition at line 18072 of file gsad_omp.c.

References delete_resource().

18074 {
18075  return delete_resource ("schedule", credentials, params, 0, "get_schedules",
18076  response_data);
18077 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete note, get next page, XSL transform the result.

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

Definition at line 10455 of file gsad_omp.c.

References delete_resource().

10457 {
10458  return delete_resource ("tag", credentials, params, 0, NULL, response_data);
10459 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a target, get all targets, XSL transform the result.

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

Definition at line 9953 of file gsad_omp.c.

References delete_resource().

9955 {
9956  return delete_resource ("target", credentials, params, 0, "get_targets",
9957  response_data);
9958 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a task, get all tasks, XSL transform the result.

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

Definition at line 4573 of file gsad_omp.c.

References delete_resource().

4575 {
4576  return delete_resource ("task", credentials, params, 0, NULL, response_data);
4577 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash agent, get all agents, XSL transform the result.

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

Definition at line 9970 of file gsad_omp.c.

References delete_resource().

9972 {
9973  return delete_resource ("agent", credentials, params, 1, "get_trash",
9974  response_data);
9975 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash alert, get all trash, XSL transform the result.

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

Definition at line 10004 of file gsad_omp.c.

References delete_resource().

10006 {
10007  return delete_resource ("alert", credentials, params, 1, "get_trash",
10008  response_data);
10009 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash config, get all trash, XSL transform the result.

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

Definition at line 9987 of file gsad_omp.c.

References delete_resource().

9989 {
9990  return delete_resource ("config", credentials, params, 1, "get_trash",
9991  response_data);
9992 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash credential, get all trash, XSL transform the result.

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

Definition at line 10021 of file gsad_omp.c.

References delete_resource().

10023 {
10024  return delete_resource ("credential", credentials, params, 1, "get_trash",
10025  response_data);
10026 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a filter, get all filters, XSL transform the result.

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

Definition at line 24400 of file gsad_omp.c.

References delete_resource().

24402 {
24403  return delete_resource ("filter", credentials, params, 1, "get_trash",
24404  response_data);
24405 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a group from trash, get all groups, XSL transform the result.

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

Definition at line 20780 of file gsad_omp.c.

References delete_resource().

20782 {
20783  return delete_resource ("group", credentials, params, 1, "get_trash",
20784  response_data);
20785 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a note, get all notes, XSL transform the result.

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

Definition at line 16118 of file gsad_omp.c.

References delete_resource().

16120 {
16121  return delete_resource ("note", credentials, params, 1, "get_trash",
16122  response_data);
16123 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a override, get all overrides, XSL transform the result.

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

Definition at line 16863 of file gsad_omp.c.

References delete_resource().

16865 {
16866  return delete_resource ("override", credentials, params, 1, "get_trash",
16867  response_data);
16868 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a permission, get all permissions, XSL transform the result.

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

Definition at line 21153 of file gsad_omp.c.

References delete_resource().

21155 {
21156  return delete_resource ("permission", credentials, params, 1, "get_trash",
21157  response_data);
21158 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash port list, get all trash, XSL transform the result.

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

Definition at line 23352 of file gsad_omp.c.

References delete_resource().

23354 {
23355  return delete_resource ("port_list", credentials, params, 1, "get_trash",
23356  response_data);
23357 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash report format, get all trash, XSL transform the result.

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

Definition at line 10038 of file gsad_omp.c.

References delete_resource().

10040 {
10041  return delete_resource ("report_format", credentials, params, 1, "get_trash",
10042  response_data);
10043 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a role from trash, get all roles, XSL transform the result.

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

Definition at line 23504 of file gsad_omp.c.

References delete_resource().

23506 {
23507  return delete_resource ("role", credentials, params, 1, "get_trash",
23508  response_data);
23509 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash scanner, get all scanners, XSL transform the result.

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

Definition at line 17528 of file gsad_omp.c.

References delete_resource().

17530 {
17531  return delete_resource ("scanner", credentials, params, 1, "get_trash",
17532  response_data);
17533 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash schedule, get all trash, XSL transform the result.

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

Definition at line 10055 of file gsad_omp.c.

References delete_resource().

10057 {
10058  return delete_resource ("schedule", credentials, params, 1, "get_trash",
10059  response_data);
10060 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a note, get all notes, XSL transform the result.

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

Definition at line 10471 of file gsad_omp.c.

References delete_resource().

10473 {
10474  return delete_resource ("tag", credentials, params, 1, "get_trash",
10475  response_data);
10476 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash target, get all trash, XSL transform the result.

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

Definition at line 10072 of file gsad_omp.c.

References delete_resource().

10074 {
10075  return delete_resource ("target", credentials, params, 1, "get_trash",
10076  response_data);
10077 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Delete a trash task, get all trash, XSL transform the result.

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

Definition at line 10089 of file gsad_omp.c.

References delete_resource().

10091 {
10092  return delete_resource ("task", credentials, params, 1, "get_trash",
10093  response_data);
10094 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Show confirmation deleting a user, XSL transform the result.

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

Definition at line 25148 of file gsad_omp.c.

25150 {
25151  return delete_user_confirm (credentials, params, NULL, response_data);
25152 }
char* delete_user_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Delete a user, get all users, XSL transform the result.

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

Definition at line 25064 of file gsad_omp.c.

References delete_resource().

25066 {
25067  return delete_resource ("user", credentials, params, 0, "get_users",
25068  response_data);
25069 }
char * delete_resource(const char *type, credentials_t *credentials, params_t *params, int ultimate, const char *get, cmd_response_data_t *response_data)
Delete a resource, get all resources, XSL transform the result.
Definition: gsad_omp.c:3073

Here is the call graph for this function:

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

Get an agent, XSL transform the result.

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

Definition at line 7219 of file gsad_omp.c.

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

Referenced by exec_omp_get().

7225 {
7226  entity_t entity;
7227  openvas_connection_t connection;
7228  gchar *connect_html;
7229  const char *agent_id, *format;
7230 
7231  agent_id = params_value (params, "agent_id");
7232  format = params_value (params, "agent_format");
7233 
7234  if ((agent_id == NULL) || (format == NULL))
7235  {
7236  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
7237  *html = gsad_message (credentials,
7238  "Internal error", __FUNCTION__, __LINE__,
7239  "An internal error occurred while downloading "
7240  "an agent. "
7241  "Diagnostics: Required parameter was NULL.",
7242  "/omp?cmd=get_agents", response_data);
7243  return 1;
7244  }
7245 
7246  *result_len = 0;
7247 
7248  switch (manager_connect (credentials, &connection, &connect_html,
7249  response_data))
7250  {
7251  case 0:
7252  break;
7253  case -1:
7254  if (connect_html)
7255  {
7256  *html = connect_html;
7257  return 1;
7258  }
7259  /* Fall through. */
7260  default:
7261  {
7262  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7263  *html = gsad_message (credentials,
7264  "Internal error", __FUNCTION__, __LINE__,
7265  "An internal error occurred while getting the agent list. "
7266  "The current list of agents is not available. "
7267  "Diagnostics: Failure to connect to manager daemon.",
7268  "/omp?cmd=get_agents", response_data);
7269  return 1;
7270  }
7271  }
7272 
7273  /* Send the request. */
7274 
7275  if (openvas_connection_sendf (&connection,
7276  "<get_agents agent_id=\"%s\" format=\"%s\"/>",
7277  agent_id,
7278  format)
7279  == -1)
7280  {
7281  openvas_connection_close (&connection);
7282  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7283  *html = gsad_message (credentials,
7284  "Internal error", __FUNCTION__, __LINE__,
7285  "An internal error occurred while getting agent list. "
7286  "The current list of agents is not available. "
7287  "Diagnostics: Failure to send command to manager daemon.",
7288  "/omp?cmd=get_agents", response_data);
7289  return 1;
7290  }
7291 
7292  /* Read and handle the response. */
7293 
7294  if (strcmp (format, "installer") == 0
7295  || strcmp (format, "howto_install") == 0
7296  || strcmp (format, "howto_use") == 0)
7297  {
7298  gchar *package_decoded = NULL;
7299  entity_t package_entity = NULL, agent_entity;
7300 
7301  /* A base64 encoded package. */
7302 
7303  entity = NULL;
7304  if (read_entity_c (&connection, &entity))
7305  {
7306  openvas_connection_close (&connection);
7307  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7308  *html = gsad_message (credentials,
7309  "Internal error", __FUNCTION__, __LINE__,
7310  "An internal error occurred while getting a agent. "
7311  "The agent is not available. "
7312  "Diagnostics: Failure to receive response from manager daemon.",
7313  "/omp?cmd=get_agents", response_data);
7314  return 1;
7315  }
7316 
7317  agent_entity = entity_child (entity, "agent");
7318  if (agent_entity)
7319  package_entity = entity_child (agent_entity, "package");
7320  if (package_entity != NULL)
7321  {
7322  char *package_encoded = entity_text (package_entity);
7323  if (strlen (package_encoded))
7324  {
7325  package_decoded = (gchar *) g_base64_decode (package_encoded,
7326  result_len);
7327  if (package_decoded == NULL)
7328  {
7329  package_decoded = (gchar *) g_strdup ("");
7330  *result_len = 0;
7331  }
7332  }
7333  else
7334  {
7335  package_decoded = (gchar *) g_strdup ("");
7336  *result_len = 0;
7337  }
7338  openvas_connection_close (&connection);
7339  *html = package_decoded;
7340  if (filename)
7341  {
7342  entity_t filename_entity;
7343  filename_entity = entity_child (package_entity,
7344  "filename");
7345  if (filename_entity)
7346  *filename = g_strdup (entity_text (filename_entity));
7347  else
7348  *filename = NULL;
7349  if (!(*filename && strlen (*filename)))
7350  {
7351  g_free(*filename);
7352  *filename = g_strdup_printf ("agent-%s-%s", agent_id, format);
7353  }
7354  }
7355  free_entity (entity);
7356  return 0;
7357  }
7358  else
7359  {
7360  free_entity (entity);
7361  openvas_connection_close (&connection);
7362  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7363  *html = gsad_message (credentials,
7364  "Internal error", __FUNCTION__, __LINE__,
7365  "An internal error occurred while getting a agent. "
7366  "The agent could not be delivered. "
7367  "Diagnostics: Failure to receive agent from manager daemon.",
7368  "/omp?cmd=get_tasks", response_data);
7369  return 1;
7370  }
7371  }
7372  else
7373  {
7374  /* An error. */
7375 
7376  entity = NULL;
7377  if (read_entity_c (&connection, &entity))
7378  {
7379  openvas_connection_close (&connection);
7380  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7381  *html = gsad_message (credentials,
7382  "Internal error", __FUNCTION__, __LINE__,
7383  "An internal error occurred while getting a agent. "
7384  "The agent could not be delivered. "
7385  "Diagnostics: Failure to receive agent from manager daemon.",
7386  "/omp?cmd=get_tasks", response_data);
7387  return 1;
7388  }
7389  openvas_connection_close (&connection);
7390 
7391  free_entity (entity);
7392  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7393  *html = gsad_message (credentials,
7394  "Internal error", __FUNCTION__, __LINE__,
7395  "An internal error occurred while getting a agent. "
7396  "The agent could not be delivered. "
7397  "Diagnostics: Failure to parse agent from manager daemon.",
7398  "/omp?cmd=get_tasks", response_data);
7399  return 1;
7400  }
7401 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

Here is the caller graph for this function:

char* download_ca_pub ( credentials_t credentials,
params_t params,
gsize *  response_size,
cmd_response_data_t response_data 
)

Get a Scanner's CA Certificate.

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

Definition at line 15295 of file gsad_omp.c.

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

Referenced by exec_omp_get().

15297 {
15298  const char *ca_pub;
15299  char *unescaped;
15300 
15301  ca_pub = params_value (params, "ca_pub");
15302  if (ca_pub == NULL)
15303  {
15304  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
15305  return gsad_message (credentials,
15306  "Internal error", __FUNCTION__, __LINE__,
15307  "An internal error occurred."
15308  " Diagnostics: ca_pub was NULL.",
15309  "/omp?cmd=get_reports", response_data);
15310  }
15311  /* The Base64 comes URI escaped as it may contain special characters. */
15312  unescaped = g_uri_unescape_string (ca_pub, NULL);
15313  *response_size = strlen (unescaped);
15314  return unescaped;
15315 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

int download_credential_omp ( credentials_t credentials,
params_t params,
gsize *  result_len,
char **  html,
char **  login,
cmd_response_data_t response_data 
)

Export a Credential in a defined format.

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

Definition at line 6455 of file gsad_omp.c.

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

Referenced by exec_omp_get().

6461 {
6462  entity_t entity;
6463  openvas_connection_t connection;
6464  gchar *connect_html;
6465  const char *credential_id, *format;
6466 
6467  assert (html);
6468 
6469  if (result_len) *result_len = 0;
6470 
6471  switch (manager_connect (credentials, &connection, &connect_html,
6472  response_data))
6473  {
6474  case 0:
6475  break;
6476  case -1:
6477  if (connect_html)
6478  {
6479  *html = connect_html;
6480  return 1;
6481  }
6482  /* Fall through. */
6483  default:
6484  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6485  *html = gsad_message (credentials,
6486  "Internal error", __FUNCTION__, __LINE__,
6487  "An internal error occurred while getting a credential. "
6488  "Diagnostics: Failure to connect to manager daemon.",
6489  "/omp?cmd=get_credentials", response_data);
6490  return 1;
6491  }
6492 
6493  /* Send the request. */
6494 
6495  credential_id = params_value (params, "credential_id");
6496  format = params_value (params, "package_format");
6497 
6498  if ((credential_id == NULL) || (format == NULL))
6499  {
6500  openvas_connection_close (&connection);
6501  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
6502  *html = gsad_message (credentials,
6503  "Internal error", __FUNCTION__, __LINE__,
6504  "An internal error occurred while getting a credential. "
6505  "Diagnostics: Required parameter was NULL.",
6506  "/omp?cmd=get_credentials", response_data);
6507  return 1;
6508  }
6509 
6510  if (openvas_connection_sendf (&connection,
6511  "<get_credentials"
6512  " credential_id=\"%s\""
6513  " format=\"%s\"/>",
6514  credential_id,
6515  format)
6516  == -1)
6517  {
6518  openvas_connection_close (&connection);
6519  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6520  *html = gsad_message (credentials,
6521  "Internal error", __FUNCTION__, __LINE__,
6522  "An internal error occurred while getting a credential. "
6523  "Diagnostics: Failure to send command to manager daemon.",
6524  "/omp?cmd=get_credentials", response_data);
6525  return 1;
6526  }
6527 
6528  /* Read and handle the response. */
6529 
6530  if (strcmp (format, "rpm") == 0
6531  || strcmp (format, "deb") == 0
6532  || strcmp (format, "exe") == 0)
6533  {
6534  gchar *package_decoded = NULL;
6535  entity_t package_entity = NULL, credential_entity;
6536 
6537  /* A base64 encoded package. */
6538 
6539  entity = NULL;
6540  if (read_entity_c (&connection, &entity))
6541  {
6542  openvas_connection_close (&connection);
6543  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6544  *html = gsad_message (credentials,
6545  "Internal error", __FUNCTION__, __LINE__,
6546  "An internal error occurred while getting a credential. "
6547  "The credential is not available. "
6548  "Diagnostics: Failure to receive response from manager daemon.",
6549  "/omp?cmd=get_credentials", response_data);
6550  return 1;
6551  }
6552 
6553  credential_entity = entity_child (entity, "credential");
6554  if (credential_entity)
6555  package_entity = entity_child (credential_entity, "package");
6556  if (package_entity != NULL)
6557  {
6558  gsize len;
6559  char *package_encoded = entity_text (package_entity);
6560  if (strlen (package_encoded))
6561  {
6562  package_decoded = (gchar *) g_base64_decode (package_encoded,
6563  &len);
6564  if (package_decoded == NULL)
6565  {
6566  package_decoded = (gchar *) g_strdup ("");
6567  len = 0;
6568  }
6569  }
6570  else
6571  {
6572  package_decoded = (gchar *) g_strdup ("");
6573  len = 0;
6574  }
6575  if (result_len) *result_len = len;
6576  openvas_connection_close (&connection);
6577  *html = package_decoded;
6578  if (login)
6579  {
6580  entity_t login_entity;
6581  login_entity = entity_child (credential_entity, "login");
6582  if (login_entity)
6583  *login = g_strdup (entity_text (login_entity));
6584  else
6585  *login = NULL;
6586  }
6587  free_entity (entity);
6588  return 0;
6589  }
6590  else
6591  {
6592  free_entity (entity);
6593  openvas_connection_close (&connection);
6594  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6595  *html = gsad_message (credentials,
6596  "Internal error", __FUNCTION__, __LINE__,
6597  "An internal error occurred while getting a credential. "
6598  "The credential could not be delivered. "
6599  "Diagnostics: Failure to receive credential from manager daemon.",
6600  "/omp?cmd=get_credentials", response_data);
6601  return 1;
6602  }
6603  }
6604  else
6605  {
6606  entity_t credential_entity, key_entity = NULL;
6607 
6608  /* A key or certificate. */
6609 
6610  entity = NULL;
6611  if (read_entity_c (&connection, &entity))
6612  {
6613  openvas_connection_close (&connection);
6614  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6615  *html = gsad_message (credentials,
6616  "Internal error", __FUNCTION__, __LINE__,
6617  "An internal error occurred while getting a credential. "
6618  "The credential could not be delivered. "
6619  "Diagnostics: Failure to receive credential from manager daemon.",
6620  "/omp?cmd=get_credentials", response_data);
6621  return 1;
6622  }
6623  openvas_connection_close (&connection);
6624 
6625  credential_entity = entity_child (entity, "credential");
6626  if (credential_entity)
6627  {
6628  if (strcmp (format, "pem") == 0)
6629  key_entity = entity_child (credential_entity, "certificate");
6630  else
6631  key_entity = entity_child (credential_entity, "public_key");
6632  }
6633  if (key_entity != NULL)
6634  {
6635  *html = g_strdup (entity_text (key_entity));
6636  if (login)
6637  {
6638  entity_t login_entity = entity_child (credential_entity, "login");
6639  if (login_entity)
6640  *login = g_strdup (entity_text (login_entity));
6641  else
6642  *login = NULL;
6643  }
6644  free_entity (entity);
6645  return 0;
6646  }
6647  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6648  *html = gsad_message (credentials,
6649  "Internal error", __FUNCTION__, __LINE__,
6650  "An internal error occurred while getting a credential. "
6651  "The credential could not be delivered. "
6652  "Diagnostics: Failure to parse credential from manager daemon.",
6653  "/omp?cmd=get_credentials", response_data);
6654  free_entity (entity);
6655  return 1;
6656  }
6657 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

Here is the caller graph for this function:

char* download_key_pub ( credentials_t credentials,
params_t params,
gsize *  response_size,
cmd_response_data_t response_data 
)

Get a Scanner's Certificate.

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

Definition at line 15328 of file gsad_omp.c.

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

Referenced by exec_omp_get().

15330 {
15331  const char *key_pub;
15332  char *unescaped;
15333 
15334  key_pub = params_value (params, "key_pub");
15335  if (key_pub == NULL)
15336  {
15337  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
15338  return gsad_message (credentials,
15339  "Internal error", __FUNCTION__, __LINE__,
15340  "An internal error occurred."
15341  " Diagnostics: key_pub was NULL.",
15342  "/omp?cmd=get_reports", response_data);
15343  }
15344 
15345  /* The Base64 comes URI escaped as it may contain special characters. */
15346  unescaped = g_uri_unescape_string (key_pub, NULL);
15347  *response_size = strlen (unescaped);
15348  return unescaped;
15349 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

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

Get an SSL Certificate.

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

Definition at line 15254 of file gsad_omp.c.

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

Referenced by exec_omp_get().

15256 {
15257  const char *ssl_cert;
15258  gchar *cert;
15259  char *unescaped;
15260 
15261  ssl_cert = params_value (params, "ssl_cert");
15262  if (ssl_cert == NULL)
15263  {
15264  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
15265  return gsad_message (credentials,
15266  "Internal error", __FUNCTION__, __LINE__,
15267  "An internal error occurred."
15268  " Diagnostics: ssl_cert was NULL.",
15269  "/omp?cmd=get_reports", response_data);
15270  }
15271  /* The Base64 comes URI escaped as it may contain special characters. */
15272  unescaped = g_uri_unescape_string (ssl_cert, NULL);
15273 
15274  cert = g_strdup_printf ("-----BEGIN CERTIFICATE-----\n"
15275  "%s\n-----END CERTIFICATE-----\n",
15276  unescaped);
15277 
15278  *response_size = strlen (cert);
15279 
15280  g_free (unescaped);
15281  return cert;
15282 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

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

Setup edit_agent XML, XSL transform the result.

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

Definition at line 7431 of file gsad_omp.c.

References edit_agent().

7433 {
7434  return edit_agent (credentials, params, NULL, response_data);
7435 }
char * edit_agent(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_agent XML, XSL transform the result.
Definition: gsad_omp.c:7414

Here is the call graph for this function:

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

Setup edit_alert XML, XSL transform the result.

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

Definition at line 9079 of file gsad_omp.c.

References edit_alert().

9081 {
9082  return edit_alert (credentials, params, NULL, response_data);
9083 }
char * edit_alert(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_alert XML, XSL transform the result.
Definition: gsad_omp.c:8828

Here is the call graph for this function:

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

Setup edit_asset XML, XSL transform the result.

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

Definition at line 27854 of file gsad_omp.c.

References edit_asset().

27856 {
27857  return edit_asset (credentials, params, NULL, response_data);
27858 }
char * edit_asset(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit XML, XSL transform the result.
Definition: gsad_omp.c:27768

Here is the call graph for this function:

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

Get details of a family for editing a config, XSL transform result.

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

Definition at line 12700 of file gsad_omp.c.

12702 {
12703  return get_config_family (credentials, params, 1, response_data);
12704 }
char* edit_config_nvt_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

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

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

Definition at line 13024 of file gsad_omp.c.

13026 {
13027  return get_config_nvt (credentials, params, 1, response_data);
13028 }
char* edit_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a config, XSL transform the result.

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

Definition at line 12090 of file gsad_omp.c.

12092 {
12093  return edit_config (credentials, params, NULL, response_data);
12094 }
char* edit_credential_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_credential XML, XSL transform the result.

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

Definition at line 6801 of file gsad_omp.c.

6803 {
6804  return edit_credential (credentials, params, NULL, response_data);
6805 }
char* edit_filter_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_filter XML, XSL transform the result.

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

Definition at line 24487 of file gsad_omp.c.

References edit_filter().

24489 {
24490  return edit_filter (credentials, params, NULL, response_data);
24491 }
char * edit_filter(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_filter XML, XSL transform the result.
Definition: gsad_omp.c:24470

Here is the call graph for this function:

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

Setup edit_group XML, XSL transform the result.

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

Definition at line 20935 of file gsad_omp.c.

References edit_group().

20937 {
20938  return edit_group (credentials, params, NULL, response_data);
20939 }
char * edit_group(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_group XML, XSL transform the result.
Definition: gsad_omp.c:20918

Here is the call graph for this function:

char* edit_my_settings_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page with user's settings, for editing.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 19638 of file gsad_omp.c.

19640 {
19641  return edit_my_settings (credentials, params, NULL, response_data);
19642 }
char* edit_note_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Edit note, get next page, XSL transform the result.

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

Definition at line 16221 of file gsad_omp.c.

References edit_note().

16223 {
16224  return edit_note (credentials, params, NULL, response_data);
16225 }
char * edit_note(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit note, get next page, XSL transform the result.
Definition: gsad_omp.c:16136

Here is the call graph for this function:

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

Edit override, get next page, XSL transform the result.

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

Definition at line 16966 of file gsad_omp.c.

References edit_override().

16968 {
16969  return edit_override (credentials, params, NULL, response_data);
16970 }
char * edit_override(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Edit override, get next page, XSL transform the result.
Definition: gsad_omp.c:16881

Here is the call graph for this function:

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

Setup edit_permission XML, XSL transform the result.

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

Definition at line 22679 of file gsad_omp.c.

References edit_permission().

22681 {
22682  return edit_permission (credentials, params, NULL, response_data);
22683 }
char * edit_permission(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_permission XML, XSL transform the result.
Definition: gsad_omp.c:22518

Here is the call graph for this function:

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

Setup edit_port_list XML, XSL transform the result.

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

Definition at line 23235 of file gsad_omp.c.

23237 {
23238  return edit_port_list (credentials, params, NULL, response_data);
23239 }
char* edit_report_format_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_report_format XML, XSL transform the result.

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

Definition at line 18605 of file gsad_omp.c.

18607 {
18608  return edit_report_format (credentials, params, NULL, response_data);
18609 }
char* edit_role_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_role XML, XSL transform the result.

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

Definition at line 23736 of file gsad_omp.c.

23738 {
23739  return edit_role (credentials, params, NULL, response_data);
23740 }
char* edit_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_scanner XML, XSL transform the result.

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

Definition at line 17650 of file gsad_omp.c.

References edit_scanner().

17652 {
17653  return edit_scanner (credentials, params, NULL, response_data);
17654 }
char * edit_scanner(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_scanner XML, XSL transform the result.
Definition: gsad_omp.c:17546

Here is the call graph for this function:

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

Setup edit_schedule XML, XSL transform the result.

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

Definition at line 24693 of file gsad_omp.c.

References edit_schedule().

24695 {
24696  return edit_schedule (credentials, params, NULL, response_data);
24697 }
char * edit_schedule(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_schedule XML, XSL transform the result.
Definition: gsad_omp.c:24676

Here is the call graph for this function:

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

Setup edit_tag XML, XSL transform the result.

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

Definition at line 10586 of file gsad_omp.c.

References edit_tag().

10588 {
10589  return edit_tag (credentials, params, NULL, response_data);
10590 }
char * edit_tag(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
Definition: gsad_omp.c:10489

Here is the call graph for this function:

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

Setup edit_target XML, XSL transform the result.

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

Definition at line 11113 of file gsad_omp.c.

References edit_target().

11115 {
11116  return edit_target (credentials, params, NULL, response_data);
11117 }
char * edit_target(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_target XML, XSL transform the result.
Definition: gsad_omp.c:10931

Here is the call graph for this function:

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

Setup edit_task XML, XSL transform the result.

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

Definition at line 4738 of file gsad_omp.c.

4740 {
4741  return edit_task (credentials, params, NULL, response_data);
4742 }
char* edit_user_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Setup edit_user XML, XSL transform the result.

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

Definition at line 25644 of file gsad_omp.c.

References edit_user().

25646 {
25647  return edit_user (credentials, params, NULL, response_data);
25648 }
char * edit_user(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_user XML, XSL transform the result.
Definition: gsad_omp.c:25490

Here is the call graph for this function:

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

Empty the trashcan, get all trash, XSL transform the result.

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

Definition at line 10206 of file gsad_omp.c.

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

10208 {
10209  GString *xml;
10210  const char* no_redirect;
10211  gchar *ret;
10212  openvas_connection_t connection;
10213  entity_t entity;
10214  gchar *html;
10215 
10216  no_redirect = params_value (params, "no_redirect");
10217 
10218  switch (manager_connect (credentials, &connection, &html,
10219  response_data))
10220  {
10221  case 0:
10222  break;
10223  case -1:
10224  if (html)
10225  return html;
10226  /* Fall through. */
10227  default:
10228  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10229  return gsad_message (credentials,
10230  "Internal error", __FUNCTION__, __LINE__,
10231  "An internal error occurred while emptying the trashcan. "
10232  "Diagnostics: Failure to connect to manager daemon.",
10233  "/omp?cmd=get_trash", response_data);
10234  }
10235 
10236  xml = g_string_new ("");
10237 
10238  /* Empty the trash. */
10239 
10240  if (openvas_connection_sendf (&connection,
10241  "<empty_trashcan/>")
10242  == -1)
10243  {
10244  g_string_free (xml, TRUE);
10245  openvas_connection_close (&connection);
10246  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10247  return gsad_message (credentials,
10248  "Internal error", __FUNCTION__, __LINE__,
10249  "An internal error occurred while emptying the trashcan. "
10250  "Diagnostics: Failure to send command to manager daemon.",
10251  "/omp?cmd=get_trash", response_data);
10252  }
10253 
10254  if (read_entity_and_string_c (&connection, &entity, &xml))
10255  {
10256  g_string_free (xml, TRUE);
10257  openvas_connection_close (&connection);
10258  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10259  return gsad_message (credentials,
10260  "Internal error", __FUNCTION__, __LINE__,
10261  "An internal error occurred while emptying the trashcan. "
10262  "Diagnostics: Failure to read response from manager daemon.",
10263  "/omp?cmd=get_trash", response_data);
10264  }
10265 
10266  /* Cleanup, and return trash page. */
10267 
10268  openvas_connection_close (&connection);
10269 
10270  ret = response_from_entity (credentials, params, entity,
10271  (no_redirect && strcmp (no_redirect, "0")),
10272  NULL, "get_trash",
10273  NULL, "get_trash",
10274  "Empty Trashcan", response_data);
10275  free_entity (entity);
10276  g_string_free (xml, FALSE);
10277  return ret;
10278 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

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

Export a agent.

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

Definition at line 7695 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

7698 {
7699  return export_resource ("agent", credentials, params, content_type,
7700  content_disposition, content_length, response_data);
7701 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of agents.

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

Definition at line 7717 of file gsad_omp.c.

Referenced by exec_omp_get().

7720 {
7721  return export_many ("agent", credentials, params, content_type,
7722  content_disposition, content_length, response_data);
7723 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export an alert.

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

Definition at line 9331 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

9334 {
9335  return export_resource ("alert", credentials, params, content_type,
9336  content_disposition, content_length, response_data);
9337 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of alerts.

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

Definition at line 9353 of file gsad_omp.c.

Referenced by exec_omp_get().

9356 {
9357  return export_many ("alert", credentials, params, content_type,
9358  content_disposition, content_length, response_data);
9359 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export an asset.

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

Definition at line 27727 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

27730 {
27731  return export_resource ("asset", credentials, params, content_type,
27732  content_disposition, content_length, response_data);
27733 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of assets.

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

Definition at line 27749 of file gsad_omp.c.

Referenced by exec_omp_get().

27752 {
27753  return export_many ("asset", credentials, params, content_type,
27754  content_disposition, content_length, response_data);
27755 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a config.

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

Definition at line 13306 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13309 {
13310  return export_resource ("config", credentials, params, content_type,
13311  content_disposition, content_length, response_data);
13312 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of scan configs.

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

Definition at line 13328 of file gsad_omp.c.

Referenced by exec_omp_get().

13331 {
13332  return export_many ("config", credentials, params, content_type,
13333  content_disposition, content_length, response_data);
13334 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a Credential.

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

Definition at line 6673 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

6677 {
6678  return export_resource ("credential", credentials, params, content_type,
6679  content_disposition, content_length, response_data);
6680 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of Credentials.

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

Definition at line 6696 of file gsad_omp.c.

Referenced by exec_omp_get().

6700 {
6701  return export_many ("credential", credentials, params, content_type,
6702  content_disposition, content_length, response_data);
6703 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a filter.

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

Definition at line 24506 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

24509 {
24510  return export_resource ("filter", credentials, params, content_type,
24511  content_disposition, content_length, response_data);
24512 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of filters.

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

Definition at line 24528 of file gsad_omp.c.

Referenced by exec_omp_get().

24531 {
24532  return export_many ("filter", credentials, params, content_type,
24533  content_disposition, content_length, response_data);
24534 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a group.

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

Definition at line 20954 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

20957 {
20958  return export_resource ("group", credentials, params, content_type,
20959  content_disposition, content_length, response_data);
20960 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of groups.

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

Definition at line 20976 of file gsad_omp.c.

Referenced by exec_omp_get().

20979 {
20980  return export_many ("group", credentials, params, content_type,
20981  content_disposition, content_length, response_data);
20982 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a note.

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

Definition at line 13349 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13352 {
13353  return export_resource ("note", credentials, params, content_type,
13354  content_disposition, content_length, response_data);
13355 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of notes.

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

Definition at line 13371 of file gsad_omp.c.

Referenced by exec_omp_get().

13374 {
13375  return export_many ("note", credentials, params, content_type,
13376  content_disposition, content_length, response_data);
13377 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Download the OMP doc.

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

Definition at line 20550 of file gsad_omp.c.

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

Referenced by exec_omp_get().

20554 {
20555  entity_t entity, response;
20556  openvas_connection_t connection;
20557  char *content = NULL;
20558  gchar *html;
20559  const char *format;
20560  time_t now;
20561  struct tm *tm;
20562 
20563  *content_length = 0;
20564 
20565  switch (manager_connect (credentials, &connection, &html,
20566  response_data))
20567  {
20568  case 0:
20569  break;
20570  case -1:
20571  if (html)
20572  return html;
20573  /* Fall through. */
20574  default:
20575  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20576  return gsad_message (credentials,
20577  "Internal error", __FUNCTION__, __LINE__,
20578  "An internal error occurred while getting the OMP doc. "
20579  "Diagnostics: Failure to connect to manager daemon.",
20580  "/omp?cmd=get_protocol_doc", response_data);
20581  }
20582 
20583  format = params_value (params, "protocol_format")
20584  ? params_value (params, "protocol_format")
20585  : "xml";
20586 
20587  if (openvas_connection_sendf (&connection,
20588  "<help format=\"%s\"/>",
20589  format)
20590  == -1)
20591  {
20592  openvas_connection_close (&connection);
20593  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20594  return gsad_message (credentials,
20595  "Internal error", __FUNCTION__, __LINE__,
20596  "An internal error occurred while getting a list. "
20597  "The list could not be delivered. "
20598  "Diagnostics: Failure to send command to manager daemon.",
20599  "/omp?cmd=get_protocol_doc", response_data);
20600  }
20601 
20602  response = NULL;
20603  if (read_entity_and_text_c (&connection, &response, &content))
20604  {
20605  openvas_connection_close (&connection);
20606  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20607  return gsad_message (credentials,
20608  "Internal error", __FUNCTION__, __LINE__,
20609  "An internal error occurred while getting OMP doc. "
20610  "Diagnostics: Failure to receive response from manager daemon.",
20611  "/omp?cmd=get_protocol_doc", response_data);
20612  }
20613  openvas_connection_close (&connection);
20614 
20615  if (strcmp (format, "xml") == 0)
20616  *content_length = strlen (content);
20617  else
20618  {
20619  char *content_64;
20620  entity = entity_child (response, "schema");
20621  if (entity == NULL)
20622  {
20623  free_entity (response);
20624  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20625  return gsad_message (credentials,
20626  "Internal error", __FUNCTION__, __LINE__,
20627  "An internal error occurred while getting OMP doc. "
20628  "Diagnostics: Schema element missing.",
20629  "/omp?cmd=get_protocol_doc", response_data);
20630  }
20631 
20632  content_64 = entity_text (entity);
20633  if (strlen (content_64) == 0)
20634  {
20635  free_entity (response);
20636  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20637  return gsad_message (credentials,
20638  "Internal error", __FUNCTION__, __LINE__,
20639  "An internal error occurred while getting OMP doc. "
20640  "Diagnostics: Schema empty.",
20641  "/omp?cmd=get_protocol_doc", response_data);
20642  }
20643 
20644  content = (char *) g_base64_decode (content_64, content_length);
20645  }
20646 
20647  now = time (NULL);
20648  tm = localtime (&now);
20650  *content_disposition = g_strdup_printf ("attachment;"
20651  " filename=\"omp-%d-%d-%d.%s\"",
20652  tm->tm_mday,
20653  tm->tm_mon + 1,
20654  tm->tm_year +1900,
20655  format);
20656  free_entity (response);
20657  openvas_connection_close (&connection);
20658  return content;
20659 }
content_type
Content types.
Definition: gsad_base.h:118
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export an override.

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

Definition at line 13392 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13396 {
13397  return export_resource ("override", credentials, params, content_type,
13398  content_disposition, content_length, response_data);
13399 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of overrides.

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

Definition at line 13415 of file gsad_omp.c.

Referenced by exec_omp_get().

13419 {
13420  return export_many ("override", credentials, params, content_type,
13421  content_disposition, content_length, response_data);
13422 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a permission.

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

Definition at line 22698 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

22702 {
22703  return export_resource ("permission", credentials, params, content_type,
22704  content_disposition, content_length, response_data);
22705 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of permissions.

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

Definition at line 22721 of file gsad_omp.c.

Referenced by exec_omp_get().

22725 {
22726  return export_many ("permission", credentials, params, content_type,
22727  content_disposition, content_length, response_data);
22728 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a Port List.

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

Definition at line 13438 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13442 {
13443  return export_resource ("port_list", credentials, params, content_type,
13444  content_disposition, content_length,
13445  response_data);
13446 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of Port Lists.

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

Definition at line 13462 of file gsad_omp.c.

Referenced by exec_omp_get().

13466 {
13467  return export_many ("port_list", credentials, params, content_type,
13468  content_disposition, content_length, response_data);
13469 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a file preference.

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

Definition at line 13484 of file gsad_omp.c.

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

Referenced by exec_omp_get().

13488 {
13489  GString *xml;
13490  entity_t entity, preference_entity, value_entity;
13491  openvas_connection_t connection;
13492  gchar *html;
13493  const char *config_id, *oid, *preference_name;
13494 
13495  *content_length = 0;
13496 
13497  switch (manager_connect (credentials, &connection, &html,
13498  response_data))
13499  {
13500  case 0:
13501  break;
13502  case -1:
13503  if (html)
13504  return html;
13505  /* Fall through. */
13506  default:
13507  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13508  return gsad_message (credentials,
13509  "Internal error", __FUNCTION__, __LINE__,
13510  "An internal error occurred while getting a preference file. "
13511  "The file could not be delivered. "
13512  "Diagnostics: Failure to connect to manager daemon.",
13513  "/omp?cmd=get_tasks", response_data);
13514  }
13515 
13516  config_id = params_value (params, "config_id");
13517  oid = params_value (params, "oid");
13518  preference_name = params_value (params, "preference_name");
13519 
13520  xml = g_string_new ("<get_preferences_response>");
13521 
13522  if (config_id == NULL || oid == NULL || preference_name == NULL)
13523  g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Export Preference File"));
13524  else
13525  {
13526  if (openvas_connection_sendf (&connection,
13527  "<get_preferences"
13528  " config_id=\"%s\""
13529  " nvt_oid=\"%s\""
13530  " preference=\"%s\"/>",
13531  config_id,
13532  oid,
13533  preference_name)
13534  == -1)
13535  {
13536  g_string_free (xml, TRUE);
13537  openvas_connection_close (&connection);
13538  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13539  return gsad_message (credentials,
13540  "Internal error", __FUNCTION__, __LINE__,
13541  "An internal error occurred while getting a preference file. "
13542  "The file could not be delivered. "
13543  "Diagnostics: Failure to send command to manager daemon.",
13544  "/omp?cmd=get_tasks", response_data);
13545  }
13546 
13547  entity = NULL;
13548  if (read_entity_c (&connection, &entity))
13549  {
13550  g_string_free (xml, TRUE);
13551  openvas_connection_close (&connection);
13552  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13553  return gsad_message (credentials,
13554  "Internal error", __FUNCTION__, __LINE__,
13555  "An internal error occurred while getting a preference file. "
13556  "The file could not be delivered. "
13557  "Diagnostics: Failure to receive response from manager daemon.",
13558  "/omp?cmd=get_tasks", response_data);
13559  }
13560 
13561  preference_entity = entity_child (entity, "preference");
13562  if (preference_entity != NULL
13563  && (value_entity = entity_child (preference_entity, "value")))
13564  {
13565  char *content = strdup (entity_text (value_entity));
13567  *content_disposition = g_strdup_printf ("attachment; filename=\"pref_file.bin\"");
13568  *content_length = strlen (content);
13569  free_entity (entity);
13570  g_string_free (xml, TRUE);
13571  openvas_connection_close (&connection);
13572  return content;
13573  }
13574  else
13575  {
13576  free_entity (entity);
13577  g_string_free (xml, TRUE);
13578  openvas_connection_close (&connection);
13579  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13580  return gsad_message (credentials,
13581  "Internal error", __FUNCTION__, __LINE__,
13582  "An internal error occurred while getting a preference file. "
13583  "The file could not be delivered. "
13584  "Diagnostics: Failure to receive file from manager daemon.",
13585  "/omp?cmd=get_tasks", response_data);
13586  }
13587  }
13588 
13589  g_string_append (xml, "</get_preferences_response>");
13590  openvas_connection_close (&connection);
13591  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
13592  response_data);
13593 }
content_type
Content types.
Definition: gsad_base.h:118
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a report format.

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

Definition at line 13609 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

13613 {
13614  return export_resource ("report_format", credentials, params, content_type,
13615  content_disposition, content_length, response_data);
13616 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of Report Formats.

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

Definition at line 13632 of file gsad_omp.c.

Referenced by exec_omp_get().

13636 {
13637  return export_many ("report_format", credentials, params, content_type,
13638  content_disposition, content_length, response_data);
13639 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a result.

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

Definition at line 15365 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

15368 {
15369  return export_resource ("result", credentials, params, content_type,
15370  content_disposition, content_length, response_data);
15371 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of results.

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

Definition at line 15387 of file gsad_omp.c.

Referenced by exec_omp_get().

15391 {
15392  return export_many ("result", credentials, params, content_type,
15393  content_disposition, content_length, response_data);
15394 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a role.

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

Definition at line 23821 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

23824 {
23825  return export_resource ("role", credentials, params, content_type,
23826  content_disposition, content_length, response_data);
23827 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of roles.

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

Definition at line 23843 of file gsad_omp.c.

Referenced by exec_omp_get().

23846 {
23847  return export_many ("role", credentials, params, content_type,
23848  content_disposition, content_length, response_data);
23849 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a scanner.

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

Definition at line 17195 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

17199 {
17200  return export_resource ("scanner", credentials, params, content_type,
17201  content_disposition, content_length, response_data);
17202 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of scanners.

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

Definition at line 17217 of file gsad_omp.c.

Referenced by exec_omp_get().

17221 {
17222  return export_many ("scanner", credentials, params, content_type,
17223  content_disposition, content_length, response_data);
17224 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a schedule.

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

Definition at line 24712 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

24716 {
24717  return export_resource ("schedule", credentials, params, content_type,
24718  content_disposition, content_length, response_data);
24719 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of schedules.

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

Definition at line 24734 of file gsad_omp.c.

Referenced by exec_omp_get().

24738 {
24739  return export_many ("schedule", credentials, params, content_type,
24740  content_disposition, content_length, response_data);
24741 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a tag.

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

Definition at line 10710 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

10713 {
10714  return export_resource ("tag", credentials, params, content_type,
10715  content_disposition, content_length, response_data);
10716 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of tags.

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

Definition at line 10732 of file gsad_omp.c.

Referenced by exec_omp_get().

10735 {
10736  return export_many ("tag", credentials, params, content_type,
10737  content_disposition, content_length, response_data);
10738 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a target.

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

Definition at line 11486 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

11489 {
11490  return export_resource ("target", credentials, params, content_type,
11491  content_disposition, content_length, response_data);
11492 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of targets.

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

Definition at line 11508 of file gsad_omp.c.

Referenced by exec_omp_get().

11511 {
11512  return export_many ("target", credentials, params, content_type,
11513  content_disposition, content_length, response_data);
11514 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a task.

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

Definition at line 5104 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

5107 {
5108  return export_resource ("task", credentials, params, content_type,
5109  content_disposition, content_length, response_data);
5110 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of tasks.

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

Definition at line 5126 of file gsad_omp.c.

Referenced by exec_omp_get().

5129 {
5130  return export_many ("task", credentials, params, content_type,
5131  content_disposition, content_length, response_data);
5132 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Export a user.

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

Definition at line 25997 of file gsad_omp.c.

References export_resource().

Referenced by exec_omp_get().

26000 {
26001  return export_resource ("user", credentials, params, content_type,
26002  content_disposition, content_length, response_data);
26003 }
content_type
Content types.
Definition: gsad_base.h:118
char * export_resource(const char *type, credentials_t *credentials, params_t *params, enum content_type *content_type, char **content_disposition, gsize *content_length, cmd_response_data_t *response_data)
Export a resource.
Definition: gsad_omp.c:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

Export a list of users.

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

Definition at line 26019 of file gsad_omp.c.

Referenced by exec_omp_get().

26022 {
26023  return export_many ("user", credentials, params, content_type,
26024  content_disposition, content_length, response_data);
26025 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Get one agent, XSL transform the result.

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

Definition at line 7548 of file gsad_omp.c.

7550 {
7551  return get_agent (credentials, params, NULL, response_data);
7552 }
char* get_agents_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all agents, XSL transform the result.

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

Definition at line 7582 of file gsad_omp.c.

7584 {
7585  return get_agents (credentials, params, NULL, response_data);
7586 }
char* get_aggregate_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get an aggregate of resources.

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

Definition at line 7735 of file gsad_omp.c.

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

7737 {
7738  params_t *data_columns, *text_columns;
7739  params_t *sort_fields, *sort_stats, *sort_orders;
7740  params_iterator_t data_columns_iterator, text_columns_iterator;
7741  params_iterator_t sort_fields_iterator, sort_stats_iterator;
7742  params_iterator_t sort_orders_iterator;
7743  char *param_name;
7744  param_t *param;
7745 
7746  const char *data_column, *group_column, *subgroup_column, *type;
7747  const char *filter, *filt_id, *xml_param;
7748  const char *first_group, *max_groups;
7749  const char *mode;
7750  gchar *filter_escaped, *command_escaped, *response;
7751  entity_t entity;
7752  GString *xml, *command;
7753  int ret;
7754 
7755  data_columns = params_values (params, "data_columns:");
7756  data_column = params_value (params, "data_column");
7757  text_columns = params_values (params, "text_columns:");
7758  group_column = params_value (params, "group_column");
7759  subgroup_column = params_value (params, "subgroup_column");
7760  type = params_value (params, "aggregate_type");
7761  filter = params_value (params, "filter");
7762  filt_id = params_value (params, "filt_id");
7763  sort_fields = params_values (params, "sort_fields:");
7764  sort_stats = params_values (params, "sort_stats:");
7765  sort_orders = params_values (params, "sort_orders:");
7766  first_group = params_value (params, "first_group");
7767  max_groups = params_value (params, "max_groups");
7768  mode = params_value (params, "aggregate_mode");
7769  if (filter)
7770  filter_escaped = g_markup_escape_text (filter, -1);
7771  else
7772  {
7773  if (filt_id == NULL
7774  || strcmp (filt_id, "") == 0
7775  || strcmp (filt_id, "0") == 0)
7776  filter_escaped = g_strdup ("rows=-2");
7777  else
7778  filter_escaped = NULL;
7779  }
7780  xml_param = params_value (params, "xml");
7781 
7782  if (xml_param == NULL || atoi (xml_param) == 0)
7783  {
7784  return xsl_transform_omp (credentials, g_strdup ("<get_aggregate/>"),
7785  response_data);
7786  }
7787  xml = g_string_new ("<get_aggregate>");
7788 
7789  command = g_string_new ("<get_aggregates");
7790  g_string_append_printf (command, " type=\"%s\"", type);
7791  if (data_column)
7792  g_string_append_printf (command, " data_column=\"%s\"", data_column);
7793  if (group_column)
7794  g_string_append_printf (command, " group_column=\"%s\"", group_column);
7795  if (subgroup_column)
7796  g_string_append_printf (command,
7797  " subgroup_column=\"%s\"", subgroup_column);
7798  if (filter_escaped && strcmp (filter_escaped, ""))
7799  g_string_append_printf (command, " filter=\"%s\"", filter_escaped);
7800  if (filt_id && strcmp (filt_id, ""))
7801  g_string_append_printf (command, " filt_id=\"%s\"", filt_id);
7802  if (first_group && strcmp (first_group, ""))
7803  g_string_append_printf (command, " first_group=\"%s\"", first_group);
7804  if (max_groups && strcmp (max_groups, ""))
7805  g_string_append_printf (command, " max_groups=\"%s\"", max_groups);
7806  if (mode && strcmp (mode, ""))
7807  g_string_append_printf (command, " mode=\"%s\"", mode);
7808  g_string_append (command, ">");
7809 
7810  if (sort_fields && sort_stats && sort_orders)
7811  {
7812  param_t *field_param, *stat_param, *order_param;
7813  gchar *field_i, *stat_i, *order_i;
7814 
7815  params_iterator_init (&sort_fields_iterator, sort_fields);
7816  params_iterator_init (&sort_stats_iterator, sort_stats);
7817  params_iterator_init (&sort_orders_iterator, sort_orders);
7818 
7819  while (params_iterator_next (&sort_fields_iterator,
7820  &field_i, &field_param)
7821  && params_iterator_next (&sort_stats_iterator,
7822  &stat_i, &stat_param)
7823  && params_iterator_next (&sort_orders_iterator,
7824  &order_i, &order_param))
7825  {
7826  if (field_param->valid && stat_param->valid && order_param->valid)
7827  {
7828  xml_string_append (command,
7829  "<sort field=\"%s\""
7830  " stat=\"%s\""
7831  " order=\"%s\"/>",
7832  field_param->value ? field_param->value : "",
7833  stat_param->value ? stat_param->value : "",
7834  order_param->value ? order_param->value : "");
7835  }
7836  }
7837  }
7838 
7839  if (data_columns)
7840  {
7841  params_iterator_init (&data_columns_iterator, data_columns);
7842  while (params_iterator_next (&data_columns_iterator, &param_name, &param))
7843  {
7844  if (param->valid)
7845  {
7846  xml_string_append (command,
7847  "<data_column>%s</data_column>",
7848  param->value);
7849  }
7850  }
7851  }
7852 
7853  if (text_columns)
7854  {
7855  params_iterator_init (&text_columns_iterator, text_columns);
7856  while (params_iterator_next (&text_columns_iterator, &param_name, &param))
7857  {
7858  if (param->valid)
7859  {
7860  xml_string_append (command,
7861  "<text_column>%s</text_column>",
7862  param->value);
7863  }
7864  }
7865  }
7866 
7867  g_string_append (command, "</get_aggregates>");
7868 
7869  g_free (filter_escaped);
7870 
7871  command_escaped = g_markup_escape_text (command->str, -1);
7872  g_string_append (xml, command_escaped);
7873  g_free (command_escaped);
7874 
7875  ret = omp (credentials, &response, &entity, response_data, command->str);
7876  g_string_free (command, TRUE);
7877  switch (ret)
7878  {
7879  case 0:
7880  break;
7881  case -1:
7882  /* 'omp' set response. */
7883  return response;
7884  case 1:
7885  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7886  return gsad_message (credentials,
7887  "Internal error", __FUNCTION__, __LINE__,
7888  "An internal error occurred while getting aggregates. "
7889  "Diagnostics: Failure to send command to manager daemon.",
7890  "/omp?cmd=get_tasks", response_data);
7891  case 2:
7892  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7893  return gsad_message (credentials,
7894  "Internal error", __FUNCTION__, __LINE__,
7895  "An internal error occurred while getting aggregates. "
7896  "Diagnostics: Failure to receive response from manager daemon.",
7897  "/omp?cmd=get_tasks", response_data);
7898  default:
7899  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7900  return gsad_message (credentials,
7901  "Internal error", __FUNCTION__, __LINE__,
7902  "An internal error occurred while getting aggregates. "
7903  "Diagnostics: Internal Error.",
7904  "/omp?cmd=get_tasks", response_data);
7905  }
7906 
7907  g_string_append (xml, response);
7908 
7909  g_string_append (xml, "</get_aggregate>");
7910 
7911  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
7912  response_data);
7913 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
int valid
Definition: gsad_base.h:150
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

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

Get one alert, XSL transform the result.

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

Definition at line 8673 of file gsad_omp.c.

8675 {
8676  return get_alert (credentials, params, NULL, response_data);
8677 }
char* get_alerts_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all alerts, XSL transform the result.

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

Definition at line 8811 of file gsad_omp.c.

8813 {
8814  return get_alerts (credentials, params, NULL, response_data);
8815 }
char* get_asset_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get asset, XSL transform the result.

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

Definition at line 27412 of file gsad_omp.c.

27414 {
27415  return get_asset (credentials, params, NULL, response_data);
27416 }
char* get_assets_chart_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get an assets chart, XSL transform the result.

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

Definition at line 27968 of file gsad_omp.c.

27970 {
27971  return get_assets_chart (credentials, params, NULL, response_data);
27972 }
char* get_assets_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get assets, XSL transform the result.

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

Definition at line 27488 of file gsad_omp.c.

27490 {
27491  return get_assets (credentials, params, NULL, response_data);
27492 }
char* get_config_family_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get details of a family for a config, XSL transform the result.

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

Definition at line 12684 of file gsad_omp.c.

12686 {
12687  return get_config_family (credentials, params, 0, response_data);
12688 }
char* get_config_nvt_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

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

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

Definition at line 13008 of file gsad_omp.c.

13010 {
13011  return get_config_nvt (credentials, params, 0, response_data);
13012 }
char* get_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a config, XSL transform the result.

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

Definition at line 12058 of file gsad_omp.c.

12060 {
12061  return get_config (credentials, params, NULL, 0, response_data);
12062 }
char* get_configs_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all scan configs, XSL transform the result.

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

Definition at line 11826 of file gsad_omp.c.

11828 {
11829  return get_configs (credentials, params, NULL, response_data);
11830 }
char* get_credential_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one credential, XSL transform the result.

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

Definition at line 6435 of file gsad_omp.c.

6437 {
6438  return get_credential (credentials, params, NULL, response_data);
6439 }
char* get_credentials_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one or all credentials, XSL transform the result.

Parameters
[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 6734 of file gsad_omp.c.

6736 {
6737  return get_credentials (credentials, params, NULL, response_data);
6738 }
char* get_feeds_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get descriptions of the feeds connected to the manager.

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

Definition at line 23952 of file gsad_omp.c.

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

23954 {
23955  entity_t entity;
23956  char *text = NULL;
23957  openvas_connection_t connection;
23958  gchar *html, *response;
23959  time_t now;
23960  struct tm *tm;
23961  gchar current_timestamp[30];
23962 
23963  switch (manager_connect (credentials, &connection, &html,
23964  response_data))
23965  {
23966  case -1:
23967  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23968  if (html)
23969  return html;
23970  return gsad_message (credentials,
23971  "Internal error", __FUNCTION__, __LINE__,
23972  "An internal error occurred while getting the feed list. "
23973  "The current list of feeds is not available. "
23974  "Diagnostics: Failure to connect to manager daemon.",
23975  "/omp?cmd=get_tasks", response_data);
23976  case -2:
23977  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23978  return xsl_transform_omp (credentials,
23979  g_strdup
23980  ("<gsad_msg status_text=\"Access refused.\""
23981  " operation=\"List Feeds\">"
23982  "Only users given the Administrator role"
23983  " may access Feed Administration."
23984  "</gsad_msg>"),
23985  response_data);
23986  }
23987 
23988  if (openvas_connection_sendf (&connection,
23989  "<commands>"
23990  "<get_feeds/>"
23991  "</commands>")
23992  == -1)
23993  {
23994  openvas_connection_close (&connection);
23995  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23996  return gsad_message (credentials,
23997  "Internal error", __FUNCTION__, __LINE__,
23998  "An internal error occurred while getting the feed list. "
23999  "The current list of feeds is not available. "
24000  "Diagnostics: Failure to send command to manager daemon.",
24001  "/omp?cmd=get_tasks", response_data);
24002  }
24003 
24004  if (read_entity_and_text_c (&connection, &entity, &text))
24005  {
24006  openvas_connection_close (&connection);
24007  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24008  return gsad_message (credentials,
24009  "Internal error", __FUNCTION__, __LINE__,
24010  "An internal error occurred while getting the feed. "
24011  "The current list of feeds is not available. "
24012  "Diagnostics: Failure to receive response from manager daemon.",
24013  "/omp?cmd=get_tasks", response_data);
24014  }
24015 
24016  time (&now);
24017  tm = gmtime (&now);
24018  if (tm == NULL
24019  || (strftime (current_timestamp,
24020  29,
24021  "%Y-%m-%dT%H:%M:%S",
24022  tm)
24023  == 0))
24024  {
24025  current_timestamp[0] = '\0';
24026  }
24027 
24028  response = g_strdup_printf ("<get_feeds>"
24029  "%s"
24030  "<current_time_utc>%s</current_time_utc>"
24031  "</get_feeds>",
24032  text,
24033  current_timestamp);
24034 
24035  g_free (text);
24036 
24037  openvas_connection_close (&connection);
24038  return xsl_transform_omp (credentials, response, response_data);
24039 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

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

Get one filter, XSL transform the result.

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

Definition at line 24229 of file gsad_omp.c.

24231 {
24232  return get_filter (credentials, params, NULL, response_data);
24233 }
char* get_filters_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all filters, XSL transform the result.

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

Definition at line 24263 of file gsad_omp.c.

24265 {
24266  return get_filters (credentials, params, NULL, response_data);
24267 }
char* get_group_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one group, XSL transform the result.

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

Definition at line 20691 of file gsad_omp.c.

20693 {
20694  return get_group (credentials, params, NULL, response_data);
20695 }
char* get_groups_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all groups, XSL transform the result.

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

Definition at line 20725 of file gsad_omp.c.

20727 {
20728  return get_groups (credentials, params, NULL, response_data);
20729 }
char* get_info ( credentials_t credentials,
params_t params,
const char *  extra_xml,
cmd_response_data_t response_data 
)

Requests SecInfo.

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

Definition at line 5403 of file gsad_omp.c.

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

Referenced by exec_omp_get(), and get_info_omp().

5405 {
5406  char *ret;
5407  GString *extra_attribs, *extra_response;
5408  const char *info_type;
5409 
5410  info_type = params_value (params, "info_type");
5411  if (info_type == NULL)
5412  {
5413  param_t *param;
5414  param = params_add (params, "info_type", "nvt");
5415  param->valid = 1;
5416  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
5417  info_type = params_value (params, "info_type");
5418  }
5419 
5420  if (strcmp (info_type, "nvt")
5421  && strcmp (info_type, "cve")
5422  && strcmp (info_type, "cpe")
5423  && strcmp (info_type, "ovaldef")
5424  && strcmp (info_type, "cert_bund_adv")
5425  && strcmp (info_type, "dfn_cert_adv")
5426  && strcmp (info_type, "allinfo")
5427  && strcmp (info_type, "NVT")
5428  && strcmp (info_type, "CVE")
5429  && strcmp (info_type, "CPE")
5430  && strcmp (info_type, "OVALDEF")
5431  && strcmp (info_type, "CERT_BUND_ADV")
5432  && strcmp (info_type, "DFN_CERT_ADV")
5433  && strcmp (info_type, "ALLINFO"))
5434  {
5435  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
5436  return gsad_message (credentials,
5437  "Internal error", __FUNCTION__, __LINE__,
5438  "An internal error occurred while getting SecInfo. "
5439  "Diagnostics: Invalid info_type parameter value",
5440  "/omp?cmd=get_info", response_data);
5441  }
5442 
5443  if (params_value (params, "info_name")
5444  && params_value (params, "info_id"))
5445  {
5446  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
5447  return gsad_message (credentials,
5448  "Internal error", __FUNCTION__, __LINE__,
5449  "An internal error occurred while getting SecInfo. "
5450  "Diagnostics: Both ID and Name set.",
5451  "/omp?cmd=get_info", response_data);
5452  }
5453  extra_response = g_string_new (extra_xml ? extra_xml : "");
5454 
5455  if (command_enabled (credentials, "GET_NOTES")
5456  && (strcasecmp (info_type, "NVT") == 0)
5457  && params_value (params, "info_id"))
5458  {
5459  gchar *response;
5460 
5461  if (simple_ompf ("getting SecInfo", credentials, &response, response_data,
5462  "<get_notes"
5463  " nvt_oid=\"%s\""
5464  " sort_field=\"notes.text\"/>",
5465  params_value (params, "info_id")))
5466  {
5467  g_string_free (extra_response, TRUE);
5468  return response;
5469  }
5470 
5471  g_string_append (extra_response, response);
5472  }
5473 
5474  if (command_enabled (credentials, "GET_OVERRIDES")
5475  && (strcasecmp (info_type, "NVT") == 0)
5476  && params_value (params, "info_id"))
5477  {
5478  gchar *response;
5479 
5480  if (simple_ompf ("getting SecInfo", credentials, &response, response_data,
5481  "<get_overrides"
5482  " nvt_oid=\"%s\""
5483  " sort_field=\"overrides.text\"/>",
5484  params_value (params, "info_id")))
5485  {
5486  g_string_free (extra_response, TRUE);
5487  return response;
5488  }
5489 
5490  g_string_append (extra_response, response);
5491  }
5492 
5493  extra_attribs = g_string_new("");
5494  g_string_append_printf (extra_attribs, "type=\"%s\"",
5495  params_value (params, "info_type"));
5496  if (params_value (params, "info_name"))
5497  g_string_append_printf (extra_attribs,
5498  " name=\"%s\"",
5499  params_value (params, "info_name"));
5500  else if (params_value (params, "info_id"))
5501  g_string_append_printf (extra_attribs,
5502  " info_id=\"%s\"",
5503  params_value (params, "info_id"));
5504  if (params_value (params, "details"))
5505  g_string_append_printf (extra_attribs,
5506  " details=\"%s\"",
5507  params_value (params, "details"));
5508  ret = get_many ("info", credentials, params, extra_response->str,
5509  extra_attribs->str, response_data);
5510 
5511  g_string_free (extra_response, TRUE);
5512  g_string_free (extra_attribs, TRUE);
5513 
5514  return ret;
5515 }
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int valid_utf8
Definition: gsad_base.h:151
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int valid
Definition: gsad_base.h:150
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:304
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

Here is the caller graph for this function:

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

Get info, XSL transform the result.

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

Definition at line 5527 of file gsad_omp.c.

References get_info().

5529 {
5530  return get_info (credentials, params, NULL, response_data);
5531 }
char * get_info(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Requests SecInfo.
Definition: gsad_omp.c:5403

Here is the call graph for this function:

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

Returns page with user's settings.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 19414 of file gsad_omp.c.

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

19416 {
19417  GString *commands;
19418  int ret;
19419  entity_t entity;
19420  gchar *response;
19421 
19422  commands = g_string_new ("<commands>");
19423  if (command_enabled (credentials, "GET_ALERTS"))
19424  g_string_append (commands, "<get_alerts/>");
19425  if (command_enabled (credentials, "GET_CONFIGS"))
19426  g_string_append (commands, "<get_configs/>");
19427  if (command_enabled (credentials, "GET_FILTERS"))
19428  g_string_append (commands, "<get_filters/>");
19429  if (command_enabled (credentials, "GET_CREDENTIALS"))
19430  g_string_append (commands, "<get_credentials/>");
19431  if (command_enabled (credentials, "GET_PORT_LISTS"))
19432  g_string_append (commands, "<get_port_lists/>");
19433  if (command_enabled (credentials, "GET_REPORT_FORMATS"))
19434  g_string_append (commands, "<get_report_formats/>");
19435  if (command_enabled (credentials, "GET_SCANNERS"))
19436  g_string_append (commands, "<get_scanners/>");
19437  if (command_enabled (credentials, "GET_SCHEDULES"))
19438  g_string_append (commands, "<get_schedules/>");
19439  if (command_enabled (credentials, "GET_TARGETS"))
19440  g_string_append (commands, "<get_targets/>");
19441  g_string_append (commands, "</commands>");
19442 
19443  /* Get Filters and other resource lists. */
19444  response = NULL;
19445  entity = NULL;
19446  ret = omp (credentials, &response, &entity, response_data, commands->str);
19447  g_string_free (commands, TRUE);
19448  switch (ret)
19449  {
19450  case 0:
19451  case -1:
19452  break;
19453  case 1:
19454  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19455  return gsad_message (credentials,
19456  "Internal error", __FUNCTION__, __LINE__,
19457  "An internal error occurred while getting resources "
19458  "for the settings. "
19459  "Diagnostics: Failure to send command to manager daemon.",
19460  "/omp?cmd=get_my_settings", response_data);
19461  case 2:
19462  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19463  return gsad_message (credentials,
19464  "Internal error", __FUNCTION__, __LINE__,
19465  "An internal error occurred while getting resources "
19466  "for the settings. "
19467  "Diagnostics: Failure to receive response from manager daemon.",
19468  "/omp?cmd=get_alerts", response_data);
19469  default:
19470  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19471  return gsad_message (credentials,
19472  "Internal error", __FUNCTION__, __LINE__,
19473  "An internal error occurred while getting resources "
19474  "for the settings. "
19475  "It is unclear whether the task has been saved or not. "
19476  "Diagnostics: Internal Error.",
19477  "/omp?cmd=get_alerts", response_data);
19478  }
19479  free_entity (entity);
19480 
19481  return get_my_settings (credentials, params, response, response_data);
19482 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:304

Here is the call graph for this function:

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

Get a note, XSL transform the result.

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

Definition at line 15705 of file gsad_omp.c.

15707 {
15708  return get_note (credentials, params, NULL, response_data);
15709 }
char* get_notes_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all notes, XSL transform the result.

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

Definition at line 15672 of file gsad_omp.c.

15674 {
15675  return get_notes (credentials, params, NULL, response_data);
15676 }
char* get_nvts_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Requests NVT details, accepting extra commands.

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

Definition at line 5543 of file gsad_omp.c.

5545 {
5546  return get_nvts (credentials, params, NULL, NULL, response_data);
5547 }
char* get_override_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get an override, XSL transform the result.

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

Definition at line 16419 of file gsad_omp.c.

16421 {
16422  return get_override (credentials, params, NULL, response_data);
16423 }
char* get_overrides_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all overrides, XSL transform the result.

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

Definition at line 16385 of file gsad_omp.c.

16387 {
16388  return get_overrides (credentials, params, NULL, response_data);
16389 }
char* get_permission_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one permission, XSL transform the result.

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

Definition at line 21103 of file gsad_omp.c.

21105 {
21106  return get_permission (credentials, params, NULL, response_data);
21107 }
char* get_permissions_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all permissions, XSL transform the result.

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

Definition at line 21137 of file gsad_omp.c.

21139 {
21140  return get_permissions (credentials, params, NULL, response_data);
21141 }
char* get_port_list_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one port_list, XSL transform the result.

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

Definition at line 23151 of file gsad_omp.c.

23153 {
23154  return get_port_list (credentials, params, NULL, response_data);
23155 }
char* get_port_lists_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all port_lists, XSL transform the result.

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

Definition at line 23185 of file gsad_omp.c.

23187 {
23188  return get_port_lists (credentials, params, NULL, response_data);
23189 }
char* get_protocol_doc_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get OMP doc.

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

Definition at line 20469 of file gsad_omp.c.

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

20471 {
20472  GString *xml;
20473  openvas_connection_t connection;
20474  gchar *html;
20475  entity_t help_response;
20476 
20477  switch (manager_connect (credentials, &connection, &html,
20478  response_data))
20479  {
20480  case 0:
20481  break;
20482  case -1:
20483  if (html)
20484  return html;
20485  /* Fall through. */
20486  default:
20487  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20488  return gsad_message (credentials,
20489  "Internal error", __FUNCTION__, __LINE__,
20490  "An internal error occurred while getting the OMP doc. "
20491  "The resource is currently not available. "
20492  "Diagnostics: Failure to connect to manager daemon.",
20493  "/omp?cmd=get_tasks", response_data);
20494  }
20495 
20496  xml = g_string_new ("");
20497  g_string_append_printf (xml, "<get_protocol_doc>");
20498 
20499  /* Get the resource. */
20500 
20501  if (openvas_connection_sendf (&connection, "<help format=\"XML\"/>")
20502  == -1)
20503  {
20504  g_string_free (xml, TRUE);
20505  openvas_connection_close (&connection);
20506  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20507  return gsad_message (credentials,
20508  "Internal error", __FUNCTION__, __LINE__,
20509  "An internal error occurred while getting the OMP doc. "
20510  "Diagnostics: Failure to send command to manager daemon.",
20511  "/omp?cmd=get_tasks", response_data);
20512  }
20513 
20514  help_response = NULL;
20515  if (read_entity_and_string_c (&connection, &help_response, &xml))
20516  {
20517  g_string_free (xml, TRUE);
20518  openvas_connection_close (&connection);
20519  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20520  return gsad_message (credentials,
20521  "Internal error", __FUNCTION__, __LINE__,
20522  "An internal error occurred while getting the OMP doc. "
20523  "Diagnostics: Failure to receive response from manager daemon.",
20524  "/omp?cmd=get_tasks", response_data);
20525  }
20526  free_entity (help_response);
20527 
20528  openvas_connection_close (&connection);
20529 
20530  /* Cleanup, and return transformed XML. */
20531 
20532  g_string_append_printf (xml, "</get_protocol_doc>");
20533  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
20534  response_data);
20535 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

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

Get one report format, XSL transform the result.

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

Definition at line 18463 of file gsad_omp.c.

18465 {
18466  return get_report_format (credentials, params, NULL, response_data);
18467 }
char* get_report_formats_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all Report Formats, XSL transform the result.

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

Definition at line 18497 of file gsad_omp.c.

18499 {
18500  return get_report_formats (credentials, params, NULL, response_data);
18501 }
char* get_report_omp ( credentials_t credentials,
params_t params,
gsize *  report_len,
gchar **  content_type,
char **  content_disposition,
cmd_response_data_t response_data 
)

Get a report and XSL transform the result.

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

Definition at line 15060 of file gsad_omp.c.

Referenced by exec_omp_get().

15063 {
15064  char *result;
15065  int error = 0;
15066 
15067  result = get_report (credentials, params, NULL, report_len, content_type,
15068  content_disposition, NULL, &error, response_data);
15069 
15070  return error ? result : xsl_transform_omp (credentials, result,
15071  response_data);
15072 }
content_type
Content types.
Definition: gsad_base.h:118

Here is the caller graph for this function:

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

Get a report section, XSL transform the result.

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

Definition at line 15237 of file gsad_omp.c.

Referenced by exec_omp_post().

15239 {
15240  return get_report_section (credentials, params, NULL, response_data);
15241 }

Here is the caller graph for this function:

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

Get all reports, XSL transform the result.

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

Definition at line 15109 of file gsad_omp.c.

15111 {
15112  return get_reports (credentials, params, NULL, response_data);
15113 }
char* get_result_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one result, XSL transform the result.

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

Definition at line 15603 of file gsad_omp.c.

References params_value().

15605 {
15606  return get_result (credentials,
15607  params_value (params, "result_id"),
15608  params_value (params, "task_id"),
15609  params_value (params, "name"),
15610  params_value (params, "apply_overrides"),
15611  NULL,
15612  params_value (params, "report_id"),
15613  params_value (params, "autofp"),
15614  NULL,
15615  response_data);
15616 }
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Get all results, XSL transform the result.

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

Definition at line 15431 of file gsad_omp.c.

15433 {
15434  return get_results (credentials,
15435  params,
15436  NULL,
15437  response_data);
15438 }
char* get_role_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one role, XSL transform the result.

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

Definition at line 23769 of file gsad_omp.c.

23771 {
23772  return get_role (credentials, params, NULL, response_data);
23773 }
char* get_roles_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all roles, XSL transform the result.

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

Definition at line 23802 of file gsad_omp.c.

23804 {
23805  return get_roles (credentials, params, NULL, response_data);
23806 }
char* get_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one scanner, XSL transform the result.

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

Definition at line 17176 of file gsad_omp.c.

17178 {
17179  return get_scanner (credentials, params, NULL, response_data);
17180 }
char* get_scanners_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all scanners, XSL transform the result.

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

Definition at line 17142 of file gsad_omp.c.

17144 {
17145  return get_scanners (credentials, params, NULL, response_data);
17146 }
char* get_schedule_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one schedule, XSL transform the result.

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

Definition at line 17830 of file gsad_omp.c.

17832 {
17833  return get_schedule (credentials, params, NULL, response_data);
17834 }
char* get_schedules_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all schedules, XSL transform the result.

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

Definition at line 17864 of file gsad_omp.c.

17866 {
17867  return get_schedules (credentials, params, NULL, response_data);
17868 }
char* get_slave_omp ( credentials_t ,
params_t ,
cmd_response_data_t  
)
char* get_slaves_omp ( credentials_t ,
params_t ,
cmd_response_data_t  
)
char* get_system_report_omp ( credentials_t credentials,
const char *  url,
params_t params,
enum content_type content_type,
gsize *  content_length,
cmd_response_data_t response_data 
)

Return system report image.

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

Definition at line 18276 of file gsad_omp.c.

References GSAD_CONTENT_TYPE_IMAGE_PNG, manager_connect(), and params_value().

Referenced by handle_request().

18281 {
18282  entity_t entity;
18283  entity_t report_entity;
18284  openvas_connection_t connection;
18285  char name[501];
18286  time_t now;
18287  struct tm *now_broken;
18288  const char *slave_id;
18289  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
18290  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
18291  struct tm start_time, end_time;
18292 
18293  *content_length = 0;
18294 
18295  if (url == NULL)
18296  return NULL;
18297 
18298  slave_id = params_value (params, "slave_id");
18299 
18300  now = time (NULL);
18301  now_broken = localtime (&now);
18302 
18303  start_year = params_value (params, "start_year");
18304  start_month = params_value (params, "start_month");
18305  start_day = params_value (params, "start_day");
18306  start_hour = params_value (params, "start_hour");
18307  start_minute = params_value (params, "start_minute");
18308 
18309  end_year = params_value (params, "end_year");
18310  end_month = params_value (params, "end_month");
18311  end_day = params_value (params, "end_day");
18312  end_hour = params_value (params, "end_hour");
18313  end_minute = params_value (params, "end_minute");
18314 
18315  start_time.tm_year = start_year ? atoi (start_year) - 1900
18316  : now_broken->tm_year;
18317  start_time.tm_mon = start_month ? atoi (start_month) - 1
18318  : now_broken->tm_mon;
18319  start_time.tm_mday = start_day ? atoi (start_day) : now_broken->tm_mday;
18320  start_time.tm_hour = start_hour ? atoi (start_hour) : now_broken->tm_hour;
18321  start_time.tm_min = start_minute ? atoi (start_minute) : now_broken->tm_min;
18322  start_time.tm_zone = now_broken->tm_zone;
18323 
18324  end_time.tm_year = end_year ? atoi (end_year) - 1900
18325  : now_broken->tm_year;
18326  end_time.tm_mon = end_month ? atoi (end_month) - 1
18327  : now_broken->tm_mon;
18328  end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
18329  end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
18330  end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
18331  end_time.tm_zone = now_broken->tm_zone;
18332 
18333  /* fan/report.png */
18334  if (sscanf (url, "%500[^ /]./report.png", name) == 1)
18335  {
18336  gchar *omp_command;
18337 
18338  if (manager_connect (credentials, &connection, NULL,
18339  response_data))
18340  return NULL;
18341 
18342  gchar *start_time_str, *end_time_str;
18343 
18344 
18345  start_time_str
18346  = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:00",
18347  start_time.tm_year + 1900,
18348  start_time.tm_mon + 1,
18349  start_time.tm_mday,
18350  start_time.tm_hour,
18351  start_time.tm_min);
18352 
18353  end_time_str
18354  = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:00",
18355  end_time.tm_year + 1900,
18356  end_time.tm_mon + 1,
18357  end_time.tm_mday,
18358  end_time.tm_hour,
18359  end_time.tm_min);
18360 
18361  omp_command
18362  = g_markup_printf_escaped ("<get_system_reports"
18363  " name=\"%s\""
18364  " start_time=\"%s\""
18365  " end_time=\"%s\""
18366  " slave_id=\"%s\"/>",
18367  name,
18368  start_time_str,
18369  end_time_str,
18370  slave_id ? slave_id : "0");
18371  g_free (start_time_str);
18372  g_free (end_time_str);
18373 
18374  if (openvas_connection_sendf (&connection,
18375  "%s",
18376  omp_command)
18377  == -1)
18378  {
18379  g_free (omp_command);
18380  openvas_connection_close (&connection);
18381  return NULL;
18382  }
18383  g_free (omp_command);
18384 
18385  entity = NULL;
18386  if (read_entity_c (&connection, &entity))
18387  {
18388  openvas_connection_close (&connection);
18389  return NULL;
18390  }
18391 
18392  report_entity = entity_child (entity, "system_report");
18393  if (report_entity == NULL)
18394  {
18395  free_entity (entity);
18396  openvas_connection_close (&connection);
18397  return NULL;
18398  }
18399 
18400  report_entity = entity_child (report_entity, "report");
18401  if (report_entity == NULL)
18402  {
18403  free_entity (entity);
18404  openvas_connection_close (&connection);
18405  return NULL;
18406  }
18407  else
18408  {
18409  char *content_64 = entity_text (report_entity);
18410  char *content = NULL;
18411 
18412  if (content_64 && strlen (content_64))
18413  {
18414  content = (char *) g_base64_decode (content_64,
18415  content_length);
18416 
18417 #if 1
18419  //*content_disposition = g_strdup_printf ("attachment; filename=\"xxx.png\"");
18420 #else
18421  g_free (content);
18422  content = g_strdup ("helo");
18423 #endif
18424  }
18425 
18426  free_entity (entity);
18427  openvas_connection_close (&connection);
18428  return content;
18429  }
18430  }
18431 
18432  return NULL;
18433 }
content_type
Content types.
Definition: gsad_base.h:118
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

Here is the caller graph for this function:

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

Get all system reports, XSL transform the result.

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

Definition at line 18089 of file gsad_omp.c.

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

18091 {
18092  GString *xml;
18093  openvas_connection_t connection;
18094  gchar *html;
18095  time_t now;
18096  struct tm *now_broken;
18097  struct tm start_time, end_time;
18098 
18099  const char *slave_id;
18100  const char *start_year, *start_month, *start_day, *start_hour, *start_minute;
18101  const char *end_year, *end_month, *end_day, *end_hour, *end_minute;
18102 
18103  slave_id = params_value (params, "slave_id");
18104 
18105  now = time (NULL);
18106  now_broken = localtime (&now);
18107 
18108  start_year = params_value (params, "start_year");
18109  start_month = params_value (params, "start_month");
18110  start_day = params_value (params, "start_day");
18111  start_hour = params_value (params, "start_hour");
18112  start_minute = params_value (params, "start_minute");
18113 
18114  end_year = params_value (params, "end_year");
18115  end_month = params_value (params, "end_month");
18116  end_day = params_value (params, "end_day");
18117  end_hour = params_value (params, "end_hour");
18118  end_minute = params_value (params, "end_minute");
18119 
18120  start_time.tm_year = start_year ? atoi (start_year) - 1900
18121  : now_broken->tm_year;
18122  start_time.tm_mon = start_month ? atoi (start_month) - 1
18123  : now_broken->tm_mon;
18124  start_time.tm_mday = start_day ? atoi (start_day) : now_broken->tm_mday;
18125  start_time.tm_hour = start_hour ? atoi (start_hour) : now_broken->tm_hour;
18126  start_time.tm_min = start_minute ? atoi (start_minute) : now_broken->tm_min;
18127 
18128  end_time.tm_year = end_year ? atoi (end_year) - 1900
18129  : now_broken->tm_year;
18130  end_time.tm_mon = end_month ? atoi (end_month) - 1
18131  : now_broken->tm_mon;
18132  end_time.tm_mday = end_day ? atoi (end_day) : now_broken->tm_mday;
18133  end_time.tm_hour = end_hour ? atoi (end_hour) : now_broken->tm_hour;
18134  end_time.tm_min = end_minute ? atoi (end_minute) : now_broken->tm_min;
18135 
18136  switch (manager_connect (credentials, &connection, &html,
18137  response_data))
18138  {
18139  case 0:
18140  break;
18141  case -1:
18142  if (html)
18143  return html;
18144  /* Fall through. */
18145  default:
18146  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18147  return gsad_message (credentials,
18148  "Internal error", __FUNCTION__, __LINE__,
18149  "An internal error occurred while getting the system reports. "
18150  "The current list of system reports is not available. "
18151  "Diagnostics: Failure to connect to manager daemon.",
18152  "/omp?cmd=get_tasks", response_data);
18153  }
18154 
18155  xml = g_string_new ("<get_system_reports>");
18156 
18157  g_string_append_printf (xml,
18158  "<slave id=\"%s\"/>",
18159  slave_id ? slave_id : "0");
18160 
18161 
18162  g_string_append_printf (xml,
18163  "<start_time>"
18164  "<minute>%i</minute>"
18165  "<hour>%i</hour>"
18166  "<day_of_month>%i</day_of_month>"
18167  "<month>%i</month>"
18168  "<year>%i</year>"
18169  "</start_time>",
18170  start_time.tm_min,
18171  start_time.tm_hour,
18172  start_time.tm_mday,
18173  start_time.tm_mon + 1,
18174  start_time.tm_year + 1900);
18175 
18176  g_string_append_printf (xml,
18177  "<end_time>"
18178  "<minute>%i</minute>"
18179  "<hour>%i</hour>"
18180  "<day_of_month>%i</day_of_month>"
18181  "<month>%i</month>"
18182  "<year>%i</year>"
18183  "</end_time>",
18184  end_time.tm_min,
18185  end_time.tm_hour,
18186  end_time.tm_mday,
18187  end_time.tm_mon + 1,
18188  end_time.tm_year + 1900);
18189 
18190  /* Get the system reports. */
18191 
18192  if (openvas_connection_sendf (&connection,
18193  "<get_system_reports brief=\"1\" slave_id=\"%s\"/>",
18194  slave_id ? slave_id : "0")
18195  == -1)
18196  {
18197  g_string_free (xml, TRUE);
18198  openvas_connection_close (&connection);
18199  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18200  return gsad_message (credentials,
18201  "Internal error", __FUNCTION__, __LINE__,
18202  "An internal error occurred while getting the system reports. "
18203  "The current list of system reports is not available. "
18204  "Diagnostics: Failure to send command to manager daemon.",
18205  "/omp?cmd=get_tasks", response_data);
18206  }
18207 
18208  if (read_string_c (&connection, &xml))
18209  {
18210  g_string_free (xml, TRUE);
18211  openvas_connection_close (&connection);
18212  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18213  return gsad_message (credentials,
18214  "Internal error", __FUNCTION__, __LINE__,
18215  "An internal error occurred while getting the system reports. "
18216  "The current list of system reports is not available. "
18217  "Diagnostics: Failure to receive response from manager daemon.",
18218  "/omp?cmd=get_tasks", response_data);
18219  }
18220 
18221  if (command_enabled (credentials, "GET_SCANNERS"))
18222  {
18223  /* Get the OMP scanners. */
18224 
18225  if (openvas_connection_sendf (&connection,
18226  "<get_scanners"
18227  " filter=\"sort=name rows=-1 type=4\"/>")
18228  == -1)
18229  {
18230  g_string_free (xml, TRUE);
18231  openvas_connection_close (&connection);
18232  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18233  return gsad_message (credentials,
18234  "Internal error", __FUNCTION__, __LINE__,
18235  "An internal error occurred while getting the system reports. "
18236  "The current list of system reports is not available. "
18237  "Diagnostics: Failure to send command to manager daemon.",
18238  "/omp?cmd=get_tasks", response_data);
18239  }
18240 
18241  if (read_string_c (&connection, &xml))
18242  {
18243  g_string_free (xml, TRUE);
18244  openvas_connection_close (&connection);
18245  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18246  return gsad_message (credentials,
18247  "Internal error", __FUNCTION__, __LINE__,
18248  "An internal error occurred while getting the system reports. "
18249  "The current list of system reports is not available. "
18250  "Diagnostics: Failure to receive response from manager daemon.",
18251  "/omp?cmd=get_tasks", response_data);
18252  }
18253  }
18254 
18255  /* Cleanup, and return transformed XML. */
18256 
18257  g_string_append (xml, "</get_system_reports>");
18258  openvas_connection_close (&connection);
18259  return xsl_transform_omp (credentials, g_string_free (xml, FALSE),
18260  response_data);
18261 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
int command_enabled(credentials_t *credentials, const gchar *name)
Init the GSA OMP library.
Definition: gsad_omp.c:304

Here is the call graph for this function:

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

Get one tag, XSL transform the result.

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

Definition at line 10767 of file gsad_omp.c.

10769 {
10770  return get_tag (credentials, params, NULL, response_data);
10771 }
char* get_tags_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all tags, XSL transform the result.

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

Definition at line 10800 of file gsad_omp.c.

10802 {
10803  return get_tags (credentials, params, NULL, response_data);
10804 }
char* get_target_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one target, XSL transform the result.

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

Definition at line 11147 of file gsad_omp.c.

11149 {
11150  return get_target (credentials, params, NULL, response_data);
11151 }
char* get_targets_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all targets, XSL transform the result.

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

Definition at line 11181 of file gsad_omp.c.

11183 {
11184  return get_targets (credentials, params, NULL, response_data);
11185 }
char* get_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a task, XSL transform the result.

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

Definition at line 6071 of file gsad_omp.c.

6073 {
6074  return get_task (credentials, params, NULL, response_data);
6075 }
char* get_tasks_chart_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get a tasks chart, XSL transform the result.

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

Definition at line 5687 of file gsad_omp.c.

5689 {
5690  return get_tasks_chart (credentials, params, NULL, response_data);
5691 }
char* get_tasks_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all tasks, XSL transform the result.

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

Definition at line 5653 of file gsad_omp.c.

5655 {
5656  return get_tasks (credentials, params, NULL, response_data);
5657 }
char* get_trash_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all trash, XSL transform the result.

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

Definition at line 19317 of file gsad_omp.c.

19319 {
19320  return get_trash (credentials, params, NULL, response_data);
19321 }
char* get_user_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get one user, XSL transform the result.

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

Definition at line 25230 of file gsad_omp.c.

25232 {
25233  return get_user (credentials, params, NULL, response_data);
25234 }
char* get_users_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Get all users, XSL transform the result.

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

Definition at line 25313 of file gsad_omp.c.

25315 {
25316  return get_users (credentials, params, NULL, response_data);
25317 }
char* import_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Import config, get all configs, XSL transform the result.

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

Definition at line 11735 of file gsad_omp.c.

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

11737 {
11738  const char *no_redirect;
11739  gchar *command, *html, *response;
11740  entity_t entity;
11741  int ret;
11742 
11743  no_redirect = params_value (params, "no_redirect");
11744 
11745  /* Create the config. */
11746 
11747  response = NULL;
11748  entity = NULL;
11749  command = g_strdup_printf ("<create_config>"
11750  "%s"
11751  "</create_config>",
11752  params_value (params, "xml_file"));
11753  ret = omp (credentials, &response, &entity, response_data, command);
11754  g_free (command);
11755  switch (ret)
11756  {
11757  case 0:
11758  case -1:
11759  break;
11760  case 1:
11761  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11762  return gsad_message (credentials,
11763  "Internal error", __FUNCTION__, __LINE__,
11764  "An internal error occurred while importing a config. "
11765  "The schedule remains the same. "
11766  "Diagnostics: Failure to send command to manager daemon.",
11767  "/omp?cmd=get_configs", response_data);
11768  case 2:
11769  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11770  return gsad_message (credentials,
11771  "Internal error", __FUNCTION__, __LINE__,
11772  "An internal error occurred while importing a config. "
11773  "It is unclear whether the schedule has been saved or not. "
11774  "Diagnostics: Failure to receive response from manager daemon.",
11775  "/omp?cmd=get_configs", response_data);
11776  default:
11777  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11778  return gsad_message (credentials,
11779  "Internal error", __FUNCTION__, __LINE__,
11780  "An internal error occurred while importing a config. "
11781  "It is unclear whether the schedule has been saved or not. "
11782  "Diagnostics: Internal Error.",
11783  "/omp?cmd=get_configs", response_data);
11784  }
11785 
11786  /* Cleanup, and return transformed XML. */
11787 
11788  html = response_from_entity (credentials, params, entity,
11789  (no_redirect && strcmp (no_redirect, "0")),
11790  NULL, "get_configs",
11791  NULL, "new_config",
11792  "Import Config", response_data);
11793  free_entity (entity);
11794  g_free (response);
11795  return html;
11796 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Import port list, get all port_lists, XSL transform the result.

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

Definition at line 23386 of file gsad_omp.c.

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

23388 {
23389  const char *no_redirect;
23390  gchar *command, *html, *response;
23391  entity_t entity;
23392  int ret;
23393 
23394  no_redirect = params_value (params, "no_redirect");
23395 
23396  /* Create the port list. */
23397 
23398  response = NULL;
23399  entity = NULL;
23400  command = g_strdup_printf ("<create_port_list>"
23401  "%s"
23402  "</create_port_list>",
23403  params_value (params, "xml_file"));
23404  ret = omp (credentials, &response, &entity, response_data, command);
23405  g_free (command);
23406  switch (ret)
23407  {
23408  case 0:
23409  case -1:
23410  break;
23411  case 1:
23412  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23413  return gsad_message (credentials,
23414  "Internal error", __FUNCTION__, __LINE__,
23415  "An internal error occurred while importing a port_list. "
23416  "The schedule remains the same. "
23417  "Diagnostics: Failure to send command to manager daemon.",
23418  "/omp?cmd=get_port_lists",
23419  response_data);
23420  case 2:
23421  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23422  return gsad_message (credentials,
23423  "Internal error", __FUNCTION__, __LINE__,
23424  "An internal error occurred while importing a port_list. "
23425  "It is unclear whether the schedule has been saved or not. "
23426  "Diagnostics: Failure to receive response from manager daemon.",
23427  "/omp?cmd=get_port_lists",
23428  response_data);
23429  default:
23430  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23431  return gsad_message (credentials,
23432  "Internal error", __FUNCTION__, __LINE__,
23433  "An internal error occurred while importing a port_list. "
23434  "It is unclear whether the schedule has been saved or not. "
23435  "Diagnostics: Internal Error.",
23436  "/omp?cmd=get_port_lists",
23437  response_data);
23438  }
23439 
23440  /* Cleanup, and return transformed XML. */
23441 
23442  html = response_from_entity (credentials, params, entity,
23443  (no_redirect && strcmp (no_redirect, "0")),
23444  NULL, "get_port_lists",
23445  NULL, "new_port_list",
23446  "Import Port List", response_data);
23447  free_entity (entity);
23448  g_free (response);
23449  return html;
23450 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Import report format, get all report formats, XSL transform result.

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

Definition at line 18621 of file gsad_omp.c.

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

18623 {
18624  const char* no_redirect;
18625  gchar *command, *html, *response;
18626  entity_t entity;
18627  int ret;
18628 
18629  no_redirect = params_value (params, "no_redirect");
18630 
18631  /* Create the report format. */
18632 
18633  response = NULL;
18634  entity = NULL;
18635  command = g_strdup_printf ("<create_report_format>"
18636  "%s"
18637  "</create_report_format>",
18638  params_value (params, "xml_file"));
18639  ret = omp (credentials, &response, &entity, response_data, command);
18640  g_free (command);
18641  switch (ret)
18642  {
18643  case 0:
18644  case -1:
18645  break;
18646  case 1:
18647  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18648  return gsad_message (credentials,
18649  "Internal error", __FUNCTION__, __LINE__,
18650  "An internal error occurred while importing a report format. "
18651  "The schedule remains the same. "
18652  "Diagnostics: Failure to send command to manager daemon.",
18653  "/omp?cmd=get_report_formats", response_data);
18654  case 2:
18655  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18656  return gsad_message (credentials,
18657  "Internal error", __FUNCTION__, __LINE__,
18658  "An internal error occurred while importing a report format. "
18659  "It is unclear whether the schedule has been saved or not. "
18660  "Diagnostics: Failure to receive response from manager daemon.",
18661  "/omp?cmd=get_report_formats", response_data);
18662  default:
18663  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18664  return gsad_message (credentials,
18665  "Internal error", __FUNCTION__, __LINE__,
18666  "An internal error occurred while importing a report format. "
18667  "It is unclear whether the schedule has been saved or not. "
18668  "Diagnostics: Internal Error.",
18669  "/omp?cmd=get_report_formats", response_data);
18670  }
18671 
18672  /* Cleanup, and return transformed XML. */
18673 
18674  if (entity_attribute (entity, "id"))
18675  params_add (params, "report_format_id", entity_attribute (entity, "id"));
18676  html = response_from_entity (credentials, params, entity,
18677  (no_redirect && strcmp (no_redirect, "0")),
18678  NULL, "get_report_formats",
18679  NULL, "new_report_format",
18680  "Create Report Format", response_data);
18681 
18682  free_entity (entity);
18683  g_free (response);
18684  return html;
18685 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779

Here is the call graph for this function:

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

Import report, get all reports, XSL transform the result.

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

Definition at line 4115 of file gsad_omp.c.

References create_report_omp().

4117 {
4118  return create_report_omp (credentials, params, response_data);
4119 }
char * create_report_omp(credentials_t *credentials, params_t *params, cmd_response_data_t *response_data)
Create a report, get all tasks, XSL transform the result.
Definition: gsad_omp.c:3972

Here is the call graph for this function:

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

Reassign a task to a new OMP slave.

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

Definition at line 5192 of file gsad_omp.c.

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

5194 {
5195  gchar *command, *response, *html;
5196  const char *no_redirect, *task_id, *slave_id;
5197  int ret;
5198  entity_t entity;
5199 
5200  no_redirect = params_value (params, "no_redirect");
5201  slave_id = params_value (params, "slave_id");
5202  task_id = params_value (params, "task_id");
5203 
5204  command = g_strdup_printf ("<move_task task_id=\"%s\" slave_id=\"%s\"/>",
5205  task_id ? task_id : "",
5206  slave_id ? slave_id : "");
5207 
5208  response = NULL;
5209  entity = NULL;
5210  ret = omp (credentials, &response, &entity, response_data, command);
5211  g_free (command);
5212  switch (ret)
5213  {
5214  case 0:
5215  break;
5216  case -1:
5217  /* 'omp' set response. */
5218  return response;
5219  case 1:
5220  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5221  return gsad_message (credentials,
5222  "Internal error", __FUNCTION__, __LINE__,
5223  "An internal error occurred while moving a task. "
5224  "The task was not moved. "
5225  "Diagnostics: Failure to send command to manager daemon.",
5226  "/omp?cmd=get_tasks", response_data);
5227  case 2:
5228  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5229  return gsad_message (credentials,
5230  "Internal error", __FUNCTION__, __LINE__,
5231  "An internal error occurred while moving a task. "
5232  "It is unclear whether the task has been moved or not. "
5233  "Diagnostics: Failure to receive response from manager daemon.",
5234  "/omp?cmd=get_tasks", response_data);
5235  default:
5236  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5237  return gsad_message (credentials,
5238  "Internal error", __FUNCTION__, __LINE__,
5239  "An internal error occurred while moving a task. "
5240  "It is unclear whether the task has been moved or not. "
5241  "Diagnostics: Internal Error.",
5242  "/omp?cmd=get_tasks", response_data);
5243  }
5244 
5245  html = response_from_entity (credentials, params, entity,
5246  (no_redirect && strcmp (no_redirect, "0")),
5247  NULL, "get_tasks",
5248  NULL, "get_tasks",
5249  "Move Task", response_data);
5250 
5251  free_entity (entity);
5252  g_free (response);
5253  return html;
5254 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

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

Return the new agent page.

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

Definition at line 7045 of file gsad_omp.c.

7047 {
7048  return new_agent (credentials, params, NULL, response_data);
7049 }
char* new_alert_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new alert.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 8124 of file gsad_omp.c.

8126 {
8127  return new_alert (credentials, params, NULL, response_data);
8128 }
char* new_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new scan config page.

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

Definition at line 11591 of file gsad_omp.c.

11593 {
11594  return new_config (credentials, params, NULL, response_data);
11595 }
char* new_container_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new task.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 3898 of file gsad_omp.c.

3900 {
3901  return new_container_task (credentials, NULL, params, NULL, response_data);
3902 }
char* new_credential_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new Credential.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 6767 of file gsad_omp.c.

6769 {
6770  return new_credential (credentials, params, NULL, response_data);
6771 }
char* new_filter_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new filter.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 24546 of file gsad_omp.c.

Referenced by exec_omp_get().

24548 {
24549  return new_filter (credentials, params, NULL, response_data);
24550 }

Here is the caller graph for this function:

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

Returns page to create a new group.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 20764 of file gsad_omp.c.

20766 {
20767  return new_group (credentials, params, NULL, response_data);
20768 }
char* new_host_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new host page.

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

Definition at line 27228 of file gsad_omp.c.

27230 {
27231  return new_host (credentials, params, NULL, response_data);
27232 }
char* new_note_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new notes page.

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

Definition at line 15926 of file gsad_omp.c.

References new_note().

15928 {
15929  return new_note (credentials, params, NULL, response_data);
15930 }
char * new_note(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new notes page.
Definition: gsad_omp.c:15722

Here is the call graph for this function:

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

Return the new overrides page.

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

Definition at line 16642 of file gsad_omp.c.

References new_override().

16644 {
16645  return new_override (credentials, params, NULL, response_data);
16646 }
char * new_override(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Return the new overrides page.
Definition: gsad_omp.c:16436

Here is the call graph for this function:

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

Setup new_permission XML, XSL transform the result.

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

Definition at line 21349 of file gsad_omp.c.

References new_permission().

21351 {
21352  return new_permission (credentials, params, NULL, response_data);
21353 }
char * new_permission(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permission XML, XSL transform the result.
Definition: gsad_omp.c:21188

Here is the call graph for this function:

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

Setup new_permission XML, XSL transform the result.

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

Definition at line 21987 of file gsad_omp.c.

References new_permissions().

21989 {
21990  return new_permissions (credentials, params, NULL, response_data);
21991 }
char * new_permissions(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup new_permissions XML, XSL transform the result.
Definition: gsad_omp.c:21708

Here is the call graph for this function:

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

Return the new Port List page.

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

Definition at line 23201 of file gsad_omp.c.

23203 {
23204  return new_port_list (credentials, params, NULL, response_data);
23205 }
char* new_port_range_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new Port Range page.

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

Definition at line 23028 of file gsad_omp.c.

23030 {
23031  return new_port_range (credentials, params, NULL, response_data);
23032 }
char* new_report_format_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new report format page.

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

Definition at line 18536 of file gsad_omp.c.

18538 {
18539  return new_report_format (credentials, params, NULL, response_data);
18540 }
char* new_role_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new role.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 23488 of file gsad_omp.c.

23490 {
23491  return new_role (credentials, params, NULL, response_data);
23492 }
char* new_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new scanner page.

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

Definition at line 17307 of file gsad_omp.c.

17309 {
17310  return new_scanner (credentials, params, NULL, response_data);
17311 }
char* new_schedule_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the new schedule page.

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

Definition at line 17925 of file gsad_omp.c.

17927 {
17928  return new_schedule (credentials, params, NULL, response_data);
17929 }
char* new_slave_omp ( credentials_t ,
params_t ,
cmd_response_data_t  
)
char* new_tag_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new target.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 10341 of file gsad_omp.c.

10343 {
10344  return new_tag (credentials, params, NULL, response_data);
10345 }
char* new_target_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new target.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 9559 of file gsad_omp.c.

9561 {
9562  return new_target (credentials, params, NULL, response_data);
9563 }
char* new_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new task.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 3850 of file gsad_omp.c.

3852 {
3853  return new_task (credentials, NULL, params, NULL, response_data);
3854 }
char* new_user_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns page to create a new user.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 25048 of file gsad_omp.c.

25050 {
25051  return new_user (credentials, params, NULL, response_data);
25052 }
void omp_init ( const gchar *  manager_address_unix,
const gchar *  manager_address_tls,
int  port_manager 
)

Init the GSA OMP library.

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

Definition at line 318 of file gsad_omp.c.

References manager_address, manager_port, and manager_use_tls.

Referenced by main().

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

Here is the caller graph for this function:

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

Returns a process_bulk page.

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

Definition at line 26768 of file gsad_omp.c.

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

Referenced by exec_omp_post().

26772 {
26773  GString *bulk_string;
26774  const char *type, *subtype, *action;
26775  char *param_name;
26776  params_t *selected_ids;
26777  param_t *param;
26778  params_iterator_t iter;
26779 
26780  type = params_value (params, "resource_type");
26781  if (type == NULL)
26782  {
26783  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26784  return gsad_message (credentials,
26785  "Internal error", __FUNCTION__, __LINE__,
26786  "An internal error occurred while performing a bulk action. "
26787  "Diagnostics: Required parameter 'resource_type' was NULL.",
26788  "/omp?cmd=get_tasks", response_data);
26789  }
26790  if (strcmp (type, "info") == 0)
26791  {
26792  subtype = params_value (params, "info_type");
26793  if (subtype == NULL)
26794  {
26795  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26796  return gsad_message (credentials,
26797  "Internal error", __FUNCTION__, __LINE__,
26798  "An internal error occurred while performing a bulk action. "
26799  "Diagnostics: Required parameter 'info_type' was NULL.",
26800  "/omp?cmd=get_tasks", response_data);
26801  }
26802  }
26803  else
26804  subtype = NULL;
26805 
26806  if (params_valid (params, "bulk_create.x"))
26807  action = "create";
26808  else if (params_valid (params, "bulk_delete.x"))
26809  action = "delete";
26810  else if (params_valid (params, "bulk_export.x"))
26811  action = "export";
26812  else if (params_value (params, "bulk_trash.x"))
26813  action = "trash";
26814  else
26815  {
26816  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26817  return gsad_message (credentials,
26818  "Internal error", __FUNCTION__, __LINE__,
26819  "An internal error occurred while performing a bulk action. "
26820  "Diagnostics: Could not determine the action.",
26821  "/omp?cmd=get_tasks", response_data);
26822  }
26823 
26824  if (strcmp (action, "create") == 0)
26825  {
26826  if (params_value (params, "bulk_select")
26827  && strcmp (params_value (params, "bulk_select"), "1") == 0)
26828  {
26829  bulk_string = g_string_new ("first=1 rows=-1");
26830 
26831  selected_ids = params_values (params, "bulk_selected:");
26832  if (selected_ids)
26833  {
26834  params_iterator_init (&iter, selected_ids);
26835  while (params_iterator_next (&iter, &param_name, &param))
26836  xml_string_append (bulk_string,
26837  " uuid=%s",
26838  param_name);
26839  }
26840  }
26841  else if (params_value (params, "bulk_select")
26842  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26843  {
26844  bulk_string = g_string_new ("first=1 rows=-1 ");
26845  g_string_append (bulk_string, params_value (params, "filter") ? : "");
26846  }
26847  else
26848  {
26849  bulk_string = g_string_new (params_value (params, "filter") ? : "");
26850  }
26851  param = params_add (params, "hosts_filter", bulk_string->str);
26852  param->valid = 1;
26853  param->valid_utf8 = g_utf8_validate (param->value, -1, NULL);
26854  g_string_free (bulk_string, TRUE);
26855 
26856  return new_target (credentials, params, NULL, response_data);
26857  }
26858 
26859  if (strcmp (action, "export") == 0)
26860  {
26861  if (params_value (params, "bulk_select")
26862  && strcmp (params_value (params, "bulk_select"), "1") == 0)
26863  {
26864  bulk_string
26865  = g_string_new ("first=1 rows=-1 uuid=");
26866 
26867  selected_ids = params_values (params, "bulk_selected:");
26868  if (selected_ids)
26869  {
26870  params_iterator_init (&iter, selected_ids);
26871  while (params_iterator_next (&iter, &param_name, &param))
26872  xml_string_append (bulk_string,
26873  " uuid=%s",
26874  param_name);
26875  }
26876  }
26877  else if (params_value (params, "bulk_select")
26878  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26879  {
26880  bulk_string
26881  = g_string_new ("first=1 rows=-1 ");
26882  g_string_append (bulk_string, params_value (params, "filter") ? : "");
26883  }
26884  else
26885  {
26886  bulk_string
26887  = g_string_new (params_value (params, "filter") ? : "");
26888  }
26889  params_add (params, "filter", g_string_free (bulk_string, FALSE));
26890 
26891  return export_many (type, credentials, params, content_type,
26892  content_disposition, content_length, response_data);
26893  }
26894 
26895  bulk_string = g_string_new ("<process_bulk>");
26896 
26897  g_string_append_printf (bulk_string,
26898  "<type>%s</type>"
26899  "<action>%s</action>",
26900  type,
26901  action);
26902 
26903  g_string_append (bulk_string, "<selections>");
26904 
26905  if (params_value (params, "bulk_select")
26906  && strcmp (params_value (params, "bulk_select"), "2") == 0)
26907  {
26908  int ret;
26909  entity_t entity;
26910  gchar *response;
26911 
26912  ret = ompf (credentials, &response, &entity, response_data,
26913  "<get_%ss filter=\"first=1 rows=-1 %s\"/>",
26914  type,
26915  params_value (params, "filter") ? : "");
26916 
26917  if (ret)
26918  {
26919  free_entity (entity);
26920  g_free (response);
26921  g_string_free (bulk_string, TRUE);
26922  }
26923  switch (ret)
26924  {
26925  case 0:
26926  case -1:
26927  break;
26928  case 1:
26929  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26930  return gsad_message (credentials,
26931  "Internal error", __FUNCTION__, __LINE__,
26932  "An internal error occurred while getting a"
26933  " resources list. "
26934  "Diagnostics: Failure to send command to"
26935  " manager daemon.",
26936  "/omp?cmd=get_my_settings", response_data);
26937  case 2:
26938  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26939  return gsad_message (credentials,
26940  "Internal error", __FUNCTION__, __LINE__,
26941  "An internal error occurred while getting a"
26942  " resources list. "
26943  "Diagnostics: Failure to receive response from"
26944  " manager daemon.",
26945  "/omp?cmd=get_my_settings", response_data);
26946  default:
26947  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26948  return gsad_message (credentials,
26949  "Internal error", __FUNCTION__, __LINE__,
26950  "An internal error occurred while getting a"
26951  " resources list. "
26952  "Diagnostics: Internal Error.",
26953  "/omp?cmd=get_my_settings", response_data);
26954  }
26955 
26956  entities_t entities = entity->entities;
26957  entity_t child_entity;
26958 
26959  while ((child_entity = first_entity (entities)))
26960  {
26961  if (strcmp (entity_name (child_entity), type) == 0)
26962  {
26963  const char *resource_id
26964  = entity_attribute (child_entity, "id");
26965 
26966  if (resource_id)
26967  xml_string_append (bulk_string,
26968  "<selection id=\"%s\" />",
26969  resource_id);
26970  }
26971  entities = next_entities (entities);
26972  }
26973  }
26974  else
26975  {
26976  selected_ids = params_values (params, "bulk_selected:");
26977  if (selected_ids)
26978  {
26979  params_iterator_init (&iter, selected_ids);
26980  while (params_iterator_next (&iter, &param_name, &param))
26981  xml_string_append (bulk_string,
26982  "<selection id=\"%s\" />",
26983  param_name);
26984  }
26985  }
26986  g_string_append (bulk_string, "</selections>");
26987 
26988  if (strcmp (action, "delete") == 0 && strcmp (type, "user") == 0)
26989  {
26990  int ret;
26991  entity_t entity;
26992  gchar *response;
26993 
26994  ret = ompf (credentials, &response, &entity, response_data,
26995  "<get_users filter=\"first=1 rows=-1\"/>",
26996  type,
26997  params_value (params, "filter") ? : "");
26998 
26999  if (ret)
27000  {
27001  free_entity (entity);
27002  g_free (response);
27003  g_string_free (bulk_string, TRUE);
27004  }
27005  switch (ret)
27006  {
27007  case 0:
27008  case -1:
27009  break;
27010  case 1:
27011  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27012  return gsad_message (credentials,
27013  "Internal error", __FUNCTION__, __LINE__,
27014  "An internal error occurred while getting a"
27015  " resources list. "
27016  "Diagnostics: Failure to send command to"
27017  " manager daemon.",
27018  "/omp?cmd=get_my_settings", response_data);
27019  case 2:
27020  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27021  return gsad_message (credentials,
27022  "Internal error", __FUNCTION__, __LINE__,
27023  "An internal error occurred while getting a"
27024  " resources list. "
27025  "Diagnostics: Failure to receive response from"
27026  " manager daemon.",
27027  "/omp?cmd=get_my_settings", response_data);
27028  default:
27029  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27030  return gsad_message (credentials,
27031  "Internal error", __FUNCTION__, __LINE__,
27032  "An internal error occurred while getting a"
27033  " resources list. "
27034  "Diagnostics: Internal Error.",
27035  "/omp?cmd=get_my_settings", response_data);
27036  }
27037 
27038  g_string_append (bulk_string, response);
27039  free_entity (entity);
27040  g_free (response);
27041  }
27042 
27043  g_string_append (bulk_string, "</process_bulk>");
27044 
27045  return xsl_transform_omp (credentials, g_string_free (bulk_string, FALSE),
27046  response_data);
27047 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
content_type
Content types.
Definition: gsad_base.h:118
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int valid_utf8
Definition: gsad_base.h:151
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
int valid
Definition: gsad_base.h:150
#define params_iterator_t
Definition: gsad_base.h:185
param_t * params_add(params_t *params, const char *name, const char *value)
Add a param.
Definition: gsad_base.c:779
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

Here is the caller graph for this function:

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

Restore a resource, get all trash, XSL transform the result.

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

Definition at line 10106 of file gsad_omp.c.

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

10108 {
10109  GString *xml;
10110  gchar *ret;
10111  openvas_connection_t connection;
10112  entity_t entity;
10113  gchar *html;
10114  const char *target_id, *no_redirect;
10115 
10116  target_id = params_value (params, "target_id");
10117  no_redirect = params_value (params, "no_redirect");
10118 
10119  if (target_id == NULL)
10120  {
10121  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10122  return gsad_message (credentials,
10123  "Internal error", __FUNCTION__, __LINE__,
10124  "An internal error occurred while restoring a resource. "
10125  "The resource was not restored. "
10126  "Diagnostics: Required parameter was NULL.",
10127  "/omp?cmd=get_tasks", response_data);
10128  }
10129 
10130  switch (manager_connect (credentials, &connection, &html,
10131  response_data))
10132  {
10133  case 0:
10134  break;
10135  case -1:
10136  if (html)
10137  return html;
10138  /* Fall through. */
10139  default:
10140  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10141  return gsad_message (credentials,
10142  "Internal error", __FUNCTION__, __LINE__,
10143  "An internal error occurred while restoring a resource. "
10144  "The resource was not restored. "
10145  "Diagnostics: Failure to connect to manager daemon.",
10146  "/omp?cmd=get_trash", response_data);
10147  }
10148 
10149  xml = g_string_new ("");
10150 
10151  /* Restore the resource. */
10152 
10153  if (openvas_connection_sendf (&connection,
10154  "<restore"
10155  " id=\"%s\"/>",
10156  target_id)
10157  == -1)
10158  {
10159  g_string_free (xml, TRUE);
10160  openvas_connection_close (&connection);
10161  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10162  return gsad_message (credentials,
10163  "Internal error", __FUNCTION__, __LINE__,
10164  "An internal error occurred while restoring a resource. "
10165  "The resource was not deleted. "
10166  "Diagnostics: Failure to send command to manager daemon.",
10167  "/omp?cmd=get_trash", response_data);
10168  }
10169 
10170  if (read_entity_and_string_c (&connection, &entity, &xml))
10171  {
10172  g_string_free (xml, TRUE);
10173  openvas_connection_close (&connection);
10174  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10175  return gsad_message (credentials,
10176  "Internal error", __FUNCTION__, __LINE__,
10177  "An internal error occurred while restoring a resource. "
10178  "It is unclear whether the resource has been restored or not. "
10179  "Diagnostics: Failure to read response from manager daemon.",
10180  "/omp?cmd=get_trash", response_data);
10181  }
10182 
10183  /* Cleanup, and return trash page. */
10184 
10185  openvas_connection_close (&connection);
10186  ret = response_from_entity (credentials, params, entity,
10187  (no_redirect && strcmp (no_redirect, "0")),
10188  NULL, "get_trash",
10189  NULL, "get_trash",
10190  "Restore", response_data);
10191  free_entity (entity);
10192  g_string_free (xml, FALSE);
10193  return ret;
10194 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

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

Resume a task, get all tasks, XSL transform the result.

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

Definition at line 5160 of file gsad_omp.c.

References resource_action().

5162 {
5163  return resource_action (credentials, params, "task", "resume", response_data);
5164 }
char * resource_action(credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, XSL transform result.
Definition: gsad_omp.c:3224

Here is the call graph for this function:

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

Run a wizard and XSL transform the result.

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

Definition at line 19089 of file gsad_omp.c.

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

19091 {
19092  const char *no_redirect, *name;
19093  int ret;
19094  GString *run;
19095  param_t *param;
19096  gchar *param_name, *html, *response;
19097  params_iterator_t iter;
19098  params_t *wizard_params;
19099  entity_t entity;
19100 
19101  /* The naming is a bit subtle here, because the HTTP request
19102  * parameters are called "param"s and so are the OMP wizard
19103  * parameters. */
19104 
19105  no_redirect = params_value (params, "no_redirect");
19106  name = params_value (params, "name");
19107  if (name == NULL)
19108  {
19109  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
19110  return gsad_message (credentials,
19111  "Internal error", __FUNCTION__, __LINE__,
19112  "An internal error occurred while trying to start a wizard. "
19113  "Diagnostics: Required parameter 'name' was NULL.",
19114  "/omp?cmd=get_tasks", response_data);
19115  }
19116  run = g_string_new ("<run_wizard>");
19117 
19118  g_string_append_printf (run,
19119  "<name>%s</name>"
19120  "<params>",
19121  name);
19122 
19123  wizard_params = params_values (params, "event_data:");
19124  if (wizard_params)
19125  {
19126  params_iterator_init (&iter, wizard_params);
19127  while (params_iterator_next (&iter, &param_name, &param))
19128  xml_string_append (run,
19129  "<param>"
19130  "<name>%s</name>"
19131  "<value>%s</value>"
19132  "</param>",
19133  param_name,
19134  param->value);
19135  }
19136 
19137  g_string_append (run, "</params></run_wizard>");
19138 
19139  response = NULL;
19140  entity = NULL;
19141  ret = omp (credentials, &response, &entity, response_data, run->str);
19142  g_string_free (run, TRUE);
19143  switch (ret)
19144  {
19145  case 0:
19146  case -1:
19147  break;
19148  case 1:
19149  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19150  return gsad_message (credentials,
19151  "Internal error", __FUNCTION__, __LINE__,
19152  "An internal error occurred while running a wizard. "
19153  "The wizard did not start. "
19154  "Diagnostics: Failure to send command to manager daemon.",
19155  "/omp?cmd=get_tasks", response_data);
19156  case 2:
19157  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19158  return gsad_message (credentials,
19159  "Internal error", __FUNCTION__, __LINE__,
19160  "An internal error occurred while running a wizard. "
19161  "It is unclear whether the wizard started or not. "
19162  "Diagnostics: Failure to receive response from manager daemon.",
19163  "/omp?cmd=get_tasks", response_data);
19164  default:
19165  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19166  return gsad_message (credentials,
19167  "Internal error", __FUNCTION__, __LINE__,
19168  "An internal error occurred while running a wizard. "
19169  "It is unclear whether the wizard started or not. "
19170  "Diagnostics: Internal Error.",
19171  "/omp?cmd=get_tasks", response_data);
19172  }
19173 
19174  html = response_from_entity (credentials, params, entity,
19175  (no_redirect && strcmp (no_redirect, "0")),
19176  NULL, "wizard",
19177  NULL, "wizard",
19178  "Run Wizard", response_data);
19179  free_entity (entity);
19180  g_free (response);
19181  return html;
19182 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_agent_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a agent, get all agents, XSL transform the result.

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

Definition at line 7447 of file gsad_omp.c.

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

7449 {
7450  int ret;
7451  gchar *html, *response;
7452  const char *no_redirect, *agent_id, *name, *comment;
7453  entity_t entity;
7454 
7455  no_redirect = params_value (params, "no_redirect");
7456  agent_id = params_value (params, "agent_id");
7457  name = params_value (params, "name");
7458  comment = params_value (params, "comment");
7459 
7460  CHECK_PARAM_INVALID (agent_id, "Save Agent", "edit_agent");
7461  CHECK_PARAM_INVALID (name, "Save Agent", "edit_agent");
7462  CHECK_PARAM_INVALID (comment, "Save Agent", "edit_agent");
7463 
7464  /* Modify the agent. */
7465 
7466  response = NULL;
7467  entity = NULL;
7468  ret = ompf (credentials,
7469  &response,
7470  &entity,
7471  response_data,
7472  "<modify_agent agent_id=\"%s\">"
7473  "<name>%s</name>"
7474  "<comment>%s</comment>"
7475  "</modify_agent>",
7476  agent_id,
7477  name,
7478  comment);
7479 
7480  switch (ret)
7481  {
7482  case 0:
7483  case -1:
7484  break;
7485  case 1:
7486  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7487  return gsad_message (credentials,
7488  "Internal error", __FUNCTION__, __LINE__,
7489  "An internal error occurred while saving a agent. "
7490  "The agent was not saved. "
7491  "Diagnostics: Failure to send command to manager daemon.",
7492  "/omp?cmd=get_agents", response_data);
7493  case 2:
7494  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7495  return gsad_message (credentials,
7496  "Internal error", __FUNCTION__, __LINE__,
7497  "An internal error occurred while saving a agent. "
7498  "It is unclear whether the agent has been saved or not. "
7499  "Diagnostics: Failure to receive response from manager daemon.",
7500  "/omp?cmd=get_agents", response_data);
7501  default:
7502  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7503  return gsad_message (credentials,
7504  "Internal error", __FUNCTION__, __LINE__,
7505  "An internal error occurred while saving a agent. "
7506  "It is unclear whether the agent has been saved or not. "
7507  "Diagnostics: Internal Error.",
7508  "/omp?cmd=get_agents", response_data);
7509  }
7510 
7511  html = response_from_entity (credentials, params, entity,
7512  (no_redirect && strcmp (no_redirect, "0")),
7513  NULL, "get_agents",
7514  NULL, "edit_agent",
7515  "Save Agent", response_data);
7516  free_entity (entity);
7517  g_free (response);
7518  return html;
7519 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_alert_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify an alert, get all alerts, XSL transform the result.

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

Definition at line 9095 of file gsad_omp.c.

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

9097 {
9098  GString *xml;
9099  int ret;
9100  gchar *html, *response;
9101  const char *no_redirect, *name, *comment, *alert_id;
9102  const char *event, *condition, *method;
9103  const char *filter_id;
9104  params_t *event_data, *condition_data, *method_data;
9105  entity_t entity;
9106 
9107  no_redirect = params_value (params, "no_redirect");
9108  name = params_value (params, "name");
9109  comment = params_value (params, "comment");
9110  condition = params_value (params, "condition");
9111  event = params_value (params, "event");
9112  method = params_value (params, "method");
9113  alert_id = params_value (params, "alert_id");
9114  filter_id = params_value (params, "filter_id");
9115 
9116  CHECK_PARAM_INVALID (name, "Save Alert", "edit_alert");
9117  CHECK_PARAM_INVALID (comment, "Save Alert", "edit_alert");
9118  CHECK_PARAM_INVALID (alert_id, "Save Alert", "edit_alert");
9119  CHECK_PARAM_INVALID (condition, "Save Alert", "edit_alert");
9120  CHECK_PARAM_INVALID (event, "Save Alert", "edit_alert");
9121  CHECK_PARAM_INVALID (method, "Save Alert", "edit_alert");
9122  CHECK_PARAM_INVALID (filter_id, "Save Alert", "edit_alert");
9123 
9124  xml = g_string_new ("");
9125 
9126  /* Modify the alert. */
9127 
9128  event_data = params_values (params, "event_data:");
9129  condition_data = params_values (params, "condition_data:");
9130  method_data = params_values (params, "method_data:");
9131 
9132  if ((strcmp (event, "New SecInfo arrived") == 0) && event_data)
9133  {
9134  params_iterator_t iter;
9135  char *name;
9136  param_t *param;
9137 
9138  params_iterator_init (&iter, event_data);
9139  while (params_iterator_next (&iter, &name, &param))
9140  if ((strcmp (name, "feed_event") == 0)
9141  && param->value
9142  && (strcmp (param->value, "updated") == 0))
9143  {
9144  event = "Updated SecInfo arrived";
9145  break;
9146  }
9147  }
9148 
9149  xml_string_append (xml,
9150  "<modify_alert alert_id=\"%s\">"
9151  "<name>%s</name>"
9152  "<filter id=\"%s\"/>"
9153  "<comment>%s</comment>"
9154  "<event>%s",
9155  alert_id,
9156  name,
9157  filter_id,
9158  comment ? comment : "",
9159  event);
9160 
9161  append_alert_event_data (xml, event_data, event);
9162 
9163  xml_string_append (xml,
9164  "</event>"
9165  "<method>%s",
9166  method);
9167 
9168  append_alert_method_data (xml, method_data, method);
9169 
9170  xml_string_append (xml,
9171  "</method>"
9172  "<condition>%s",
9173  condition);
9174 
9175  append_alert_condition_data (xml, condition_data, condition);
9176 
9177  xml_string_append (xml,
9178  "</condition>"
9179  "</modify_alert>");
9180 
9181  ret = omp (credentials,
9182  &response,
9183  &entity,
9184  response_data,
9185  xml->str);
9186  g_string_free (xml, TRUE);
9187  switch (ret)
9188  {
9189  case 0:
9190  case -1:
9191  break;
9192  case 1:
9193  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9194  return gsad_message (credentials,
9195  "Internal error", __FUNCTION__, __LINE__,
9196  "An internal error occurred while saving a new alert. "
9197  "No new alert was created. "
9198  "Diagnostics: Failure to send command to manager daemon.",
9199  "/omp?cmd=get_alerts", response_data);
9200  case 2:
9201  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9202  return gsad_message (credentials,
9203  "Internal error", __FUNCTION__, __LINE__,
9204  "An internal error occurred while saving a new alert. "
9205  "It is unclear whether the alert has been created or not. "
9206  "Diagnostics: Failure to receive response from manager daemon.",
9207  "/omp?cmd=get_alerts", response_data);
9208  default:
9209  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9210  return gsad_message (credentials,
9211  "Internal error", __FUNCTION__, __LINE__,
9212  "An internal error occurred while saving a new alert. "
9213  "It is unclear whether the alert has been created or not. "
9214  "Diagnostics: Internal Error.",
9215  "/omp?cmd=get_alerts", response_data);
9216  }
9217 
9218  html = response_from_entity (credentials, params, entity,
9219  (no_redirect && strcmp (no_redirect, "0")),
9220  NULL, "get_alerts",
9221  NULL, "edit_alert",
9222  "Save Alert", response_data);
9223  free_entity (entity);
9224  g_free (response);
9225  return html;
9226 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_asset_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify an asset, get all assets, XSL transform the result.

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

Definition at line 27870 of file gsad_omp.c.

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

27872 {
27873  int ret;
27874  gchar *html, *response;
27875  const char *no_redirect, *asset_id, *comment;
27876  entity_t entity;
27877 
27878  no_redirect = params_value (params, "no_redirect");
27879  asset_id = params_value (params, "asset_id");
27880  comment = params_value (params, "comment");
27881 
27882  CHECK_PARAM_INVALID (asset_id, "Save Asset", "edit_asset");
27883  CHECK_PARAM_INVALID (comment, "Save Asset", "edit_asset");
27884 
27885  /* Modify the asset. */
27886 
27887  response = NULL;
27888  entity = NULL;
27889  ret = ompf (credentials,
27890  &response,
27891  &entity,
27892  response_data,
27893  "<modify_asset asset_id=\"%s\">"
27894  "<comment>%s</comment>"
27895  "</modify_asset>",
27896  asset_id,
27897  comment);
27898 
27899  switch (ret)
27900  {
27901  case 0:
27902  case -1:
27903  break;
27904  case 1:
27905  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27906  return gsad_message (credentials,
27907  "Internal error", __FUNCTION__, __LINE__,
27908  "An internal error occurred while saving an asset. "
27909  "The asset was not saved. "
27910  "Diagnostics: Failure to send command to manager daemon.",
27911  "/omp?cmd=get_assets", response_data);
27912  case 2:
27913  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27914  return gsad_message (credentials,
27915  "Internal error", __FUNCTION__, __LINE__,
27916  "An internal error occurred while saving an asset. "
27917  "It is unclear whether the asset has been saved or not. "
27918  "Diagnostics: Failure to receive response from manager daemon.",
27919  "/omp?cmd=get_assets", response_data);
27920  default:
27921  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
27922  return gsad_message (credentials,
27923  "Internal error", __FUNCTION__, __LINE__,
27924  "An internal error occurred while saving an asset. "
27925  "It is unclear whether the asset has been saved or not. "
27926  "Diagnostics: Internal Error.",
27927  "/omp?cmd=get_assets", response_data);
27928  }
27929 
27930  html = response_from_entity (credentials, params, entity,
27931  (no_redirect && strcmp (no_redirect, "0")),
27932  NULL, "get_assets",
27933  NULL, "edit_asset",
27934  "Save Asset", response_data);
27935  free_entity (entity);
27936  g_free (response);
27937  return html;
27938 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_auth_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save authentication settings.

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

Definition at line 26276 of file gsad_omp.c.

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

26278 {
26279  int ret;
26280  entity_t entity = NULL;
26281  char *html, *response = NULL, *truefalse;
26282  const char *no_redirect, *method;
26283 
26284  if (params_value (params, "enable")
26285  && (strcmp (params_value (params, "enable"), "1") == 0))
26286  truefalse = "true";
26287  else
26288  truefalse = "false";
26289 
26290  no_redirect = params_value (params, "no_redirect");
26291  method = params_value (params, "group");
26292  CHECK_PARAM_INVALID (method, "Save Authentication", "get_users");
26293  if (!strcmp (method, "method:ldap_connect"))
26294  {
26295  const char *ldaphost, *authdn, *certificate;
26296  ldaphost = params_value (params, "ldaphost");
26297  authdn = params_value (params, "authdn");
26298  certificate = params_value (params, "certificate");
26299 
26300  CHECK_PARAM_INVALID (ldaphost, "Save Authentication", "get_users");
26301  CHECK_PARAM_INVALID (authdn, "Save Authentication", "get_users");
26302  if (params_given (params, "certificate") && strcmp (certificate, ""))
26303  {
26304  CHECK_PARAM_INVALID (certificate, "Save Authentication", "get_users");
26306  ret = ompf (credentials, &response, &entity, response_data,
26307  "<modify_auth>"
26308  "<group name=\"%s\">"
26309  AUTH_CONF_SETTING ("enable", "%s")
26310  AUTH_CONF_SETTING ("ldaphost", "%s")
26311  AUTH_CONF_SETTING ("authdn", "%s")
26312  AUTH_CONF_SETTING ("cacert", "%s")
26313  "</group>"
26314  "</modify_auth>", method, truefalse, ldaphost, authdn,
26315  certificate);
26316  }
26317  else
26319  ret = ompf (credentials, &response, &entity, response_data,
26320  "<modify_auth>"
26321  "<group name=\"%s\">"
26322  AUTH_CONF_SETTING ("enable", "%s")
26323  AUTH_CONF_SETTING ("ldaphost", "%s")
26324  AUTH_CONF_SETTING ("authdn", "%s")
26325  "</group>"
26326  "</modify_auth>", method, truefalse, ldaphost, authdn);
26327  }
26328  else if (!strcmp (method, "method:radius_connect"))
26329  {
26330  const char *radiushost, *radiuskey;
26331  radiushost = params_value (params, "radiushost");
26332  radiuskey = params_value (params, "radiuskey");
26333 
26334  CHECK_PARAM_INVALID (radiushost, "Save Authentication", "get_users");
26335  CHECK_PARAM_INVALID (radiuskey, "Save Authentication", "get_users");
26337  ret = ompf (credentials, &response, &entity, response_data,
26338  "<modify_auth>"
26339  "<group name=\"%s\">"
26340  AUTH_CONF_SETTING ("enable", "%s")
26341  AUTH_CONF_SETTING ("radiushost", "%s")
26342  AUTH_CONF_SETTING ("radiuskey", "%s")
26343  "</group>"
26344  "</modify_auth>", method, truefalse, radiushost, radiuskey);
26345  }
26346  else
26347  return get_users (credentials, params,
26349  ("Save Authentication Configuration"),
26350  response_data);
26351 
26352  switch (ret)
26353  {
26354  case 0:
26355  case -1:
26356  break;
26357  case 1:
26358  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26359  return gsad_message (credentials,
26360  "Internal error", __FUNCTION__, __LINE__,
26361  "An internal error occurred while saving the auth settings. "
26362  "The settings were not saved. "
26363  "Diagnostics: Failure to send command to manager daemon.",
26364  "/omp?cmd=get_users", response_data);
26365  case 2:
26366  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26367  return gsad_message (credentials,
26368  "Internal error", __FUNCTION__, __LINE__,
26369  "An internal error occurred while saving the auth settings. "
26370  "It is unclear whether the settings have been saved or not. "
26371  "Diagnostics: Failure to receive response from manager daemon.",
26372  "/omp?cmd=get_users", response_data);
26373  default:
26374  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26375  return gsad_message (credentials,
26376  "Internal error", __FUNCTION__, __LINE__,
26377  "An internal error occurred while saving the auth settings. "
26378  "It is unclear whether the settings have been saved or not. "
26379  "Diagnostics: Internal Error.",
26380  "/omp?cmd=get_users", response_data);
26381  }
26382 
26383  html = response_from_entity (credentials, params, entity,
26384  (no_redirect && strcmp (no_redirect, "0")),
26385  NULL, NULL,
26386  NULL, "modify_auth",
26387  "Save Authentication Configuration",
26388  response_data);
26389  free_entity (entity);
26390  g_free (response);
26391  return html;
26392 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
#define AUTH_CONF_SETTING(key, value)
Generate AUTH_CONF_SETTING element for save_auth_omp.
Definition: gsad_omp.c:26260

Here is the call graph for this function:

char* save_chart_preference_omp ( credentials_t credentials,
params_t params,
gchar **  pref_id,
gchar **  pref_value,
cmd_response_data_t response_data 
)

Save chart preferences.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[in]pref_idPreference ID.
[in]pref_valuePreference value.
[out]response_dataExtra data return for the HTTP response.
Returns
SAVE_CHART_PREFERENCE OMP response.

Definition at line 26406 of file gsad_omp.c.

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

Referenced by exec_omp_post().

26409 {
26410  *pref_id = g_strdup (params_value (params, "chart_preference_id"));
26411  *pref_value = g_strdup (params_value (params, "chart_preference_value"));
26412 
26413  gchar* value_64 = g_base64_encode ((guchar*)*pref_value,
26414  strlen (*pref_value));
26415  gchar* response;
26416  entity_t entity;
26417  int ret;
26418 
26419  if (*pref_id == NULL)
26420  {
26421  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26422  return ("<save_chart_preference_response"
26423  " status=\"400\" status_text=\"Invalid or missing name\"/>");
26424  }
26425  if (*pref_value == NULL)
26426  {
26427  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
26428  return ("<save_chart_preference_response"
26429  " status=\"400\" status_text=\"Invalid or missing value\"/>");
26430  }
26431 
26432  response = NULL;
26433  entity = NULL;
26434  ret = ompf (credentials, &response, &entity, response_data,
26435  "<modify_setting setting_id=\"%s\">"
26436  "<value>%s</value>"
26437  "</modify_setting>",
26438  *pref_id, value_64);
26439  g_free (value_64);
26440  switch (ret)
26441  {
26442  case 0:
26443  case -1:
26444  break;
26445  case 1:
26446  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26447  return gsad_message (credentials,
26448  "Internal error", __FUNCTION__, __LINE__,
26449  "An internal error occurred while saving settings. "
26450  "It is unclear whether all the settings were saved. "
26451  "Diagnostics: Failure to send command to manager daemon.",
26452  "/omp?cmd=get_my_settings", response_data);
26453  case 2:
26454  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26455  return gsad_message (credentials,
26456  "Internal error", __FUNCTION__, __LINE__,
26457  "An internal error occurred while saving settings. "
26458  "It is unclear whether all the settings were saved. "
26459  "Diagnostics: Failure to receive response from manager daemon.",
26460  "/omp?cmd=get_my_settings", response_data);
26461  default:
26462  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
26463  return gsad_message (credentials,
26464  "Internal error", __FUNCTION__, __LINE__,
26465  "An internal error occurred while saving settings. "
26466  "It is unclear whether all the settings were saved. "
26467  "Diagnostics: Internal Error.",
26468  "/omp?cmd=get_my_settings", response_data);
26469  }
26470 
26471  if (omp_success (entity))
26472  {
26473  free_entity (entity);
26474  g_free (response);
26475  return ("<save_chart_preference_response"
26476  " status=\"200\" status_text=\"OK\"/>");
26477  }
26478  else
26479  {
26480  set_http_status_from_entity (entity, response_data);
26481  gchar* ret_response
26482  = g_strdup_printf("<save_chart_preference_response"
26483  " status=\"%s\" status_text=\"%s\"/>",
26484  entity_attribute (entity, "status"),
26485  entity_attribute (entity, "status_text"));
26486  free_entity (entity);
26487  g_free (response);
26488  return ret_response;
26489  }
26490 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

Here is the caller graph for this function:

char* save_config_family_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

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

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

Definition at line 12716 of file gsad_omp.c.

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

12718 {
12719  openvas_connection_t connection;
12720  char *ret;
12721  gchar *html;
12722  const char *config_id, *family;
12723  params_t *nvts;
12724 
12725  config_id = params_value (params, "config_id");
12726  family = params_value (params, "family");
12727 
12728  if ((config_id == NULL) || (family == NULL))
12729  {
12730  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
12731  return gsad_message (credentials,
12732  "Internal error", __FUNCTION__, __LINE__,
12733  "An internal error occurred while saving getting config family. "
12734  "The config has not been saved. "
12735  "Diagnostics: Required parameter was NULL.",
12736  "/omp?cmd=get_configs", response_data);
12737  }
12738 
12739  switch (manager_connect (credentials, &connection, &html,
12740  response_data))
12741  {
12742  case 0:
12743  break;
12744  case -1:
12745  if (html)
12746  return html;
12747  /* Fall through. */
12748  default:
12749  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12750  return gsad_message (credentials,
12751  "Internal error", __FUNCTION__, __LINE__,
12752  "An internal error occurred while saving a config. "
12753  "The current list of configs is not available. "
12754  "The config has not been saved. "
12755  "Diagnostics: Failure to connect to manager daemon.",
12756  "/omp?cmd=get_configs", response_data);
12757  }
12758 
12759  /* Set the NVT selection. */
12760 
12761  if (openvas_connection_sendf (&connection,
12762  "<modify_config config_id=\"%s\">"
12763  "<nvt_selection>"
12764  "<family>%s</family>",
12765  config_id,
12766  family)
12767  == -1)
12768  {
12769  openvas_connection_close (&connection);
12770  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12771  return gsad_message (credentials,
12772  "Internal error", __FUNCTION__, __LINE__,
12773  "An internal error occurred while saving a config. "
12774  "It is unclear whether the entire config has been saved. "
12775  "Diagnostics: Failure to send command to manager daemon.",
12776  "/omp?cmd=get_configs", response_data);
12777  }
12778 
12779  nvts = params_values (params, "nvt:");
12780  if (nvts)
12781  {
12782  params_iterator_t iter;
12783  char *name;
12784  param_t *param;
12785 
12786  params_iterator_init (&iter, nvts);
12787  while (params_iterator_next (&iter, &name, &param))
12788  if (openvas_connection_sendf (&connection,
12789  "<nvt oid=\"%s\"/>",
12790  name)
12791  == -1)
12792  {
12793  openvas_connection_close (&connection);
12794  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12795  return gsad_message (credentials,
12796  "Internal error", __FUNCTION__, __LINE__,
12797  "An internal error occurred while saving a config. "
12798  "It is unclear whether the entire config has been saved. "
12799  "Diagnostics: Failure to send command to manager daemon.",
12800  "/omp?cmd=get_configs", response_data);
12801  }
12802  }
12803 
12804  if (openvas_connection_sendf (&connection,
12805  "</nvt_selection>"
12806  "</modify_config>")
12807  == -1)
12808  {
12809  openvas_connection_close (&connection);
12810  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12811  return gsad_message (credentials,
12812  "Internal error", __FUNCTION__, __LINE__,
12813  "An internal error occurred while saving a config. "
12814  "It is unclear whether the entire config has been saved. "
12815  "Diagnostics: Failure to send command to manager daemon.",
12816  "/omp?cmd=get_configs", response_data);
12817  }
12818 
12819  ret = check_modify_config (credentials, &connection, params,
12820  "get_config_family", "edit_config_family",
12821  NULL, response_data);
12822 
12823  openvas_connection_close (&connection);
12824  return ret;
12825 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_config_nvt_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save NVT prefs for a config, get NVT details, XSL transform result.

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

Definition at line 13040 of file gsad_omp.c.

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

13042 {
13043  params_t *preferences;
13044  const char *config_id;
13045  int success;
13046  char *modify_config_ret;
13047 
13048  modify_config_ret = NULL;
13049  config_id = params_value (params, "config_id");
13050 
13051  preferences = params_values (params, "preference:");
13052  if (preferences)
13053  {
13054  openvas_connection_t connection;
13055  gchar *html;
13056  param_t *preference;
13057  gchar *preference_name;
13058  params_iterator_t iter;
13059 
13060  /* Save preferences. */
13061 
13062  switch (manager_connect (credentials, &connection, &html,
13063  response_data))
13064  {
13065  case 0:
13066  break;
13067  case -1:
13068  if (html)
13069  return html;
13070  /* Fall through. */
13071  default:
13072  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13073  return gsad_message (credentials,
13074  "Internal error", __FUNCTION__, __LINE__,
13075  "An internal error occurred while getting list of configs. "
13076  "The current list of configs is not available. "
13077  "Diagnostics: Failure to connect to manager daemon.",
13078  "/omp?cmd=get_configs", response_data);
13079  }
13080 
13081  params_iterator_init (&iter, preferences);
13082  while (params_iterator_next (&iter, &preference_name, &preference))
13083  {
13084  int type_start, type_end, count, ret, is_timeout = 0;
13085  gchar *value;
13086 
13087  g_free (modify_config_ret);
13088  modify_config_ret = NULL;
13089 
13090  /* Passwords and files have checkboxes to control whether they
13091  * must be reset. This works around the need for the Manager to
13092  * send the actual password or show the actual file. */
13093 
13094  /* LDAPsearch[entry]:Timeout value */
13095  count = sscanf (preference_name,
13096  "%*[^[][%n%*[^]]%n]:",
13097  &type_start,
13098  &type_end);
13099  if (count == 0 && type_start > 0 && type_end > 0)
13100  {
13101  if (strncmp (preference_name + type_start,
13102  "password",
13103  type_end - type_start)
13104  == 0)
13105  {
13106  int found = 0;
13107  params_t *passwords;
13108 
13109  passwords = params_values (params, "password:");
13110  if (passwords)
13111  {
13112  param_t *password;
13113  gchar *password_name;
13114  params_iterator_t password_params;
13115 
13116  params_iterator_init (&password_params, passwords);
13117  while (params_iterator_next (&password_params,
13118  &password_name,
13119  &password))
13120  if (strcmp (password_name, preference_name) == 0)
13121  {
13122  found = 1;
13123  break;
13124  }
13125  }
13126  if (found == 0)
13127  /* Skip modifying the password preference. */
13128  continue;
13129  }
13130  else if (strncmp (preference_name + type_start,
13131  "file",
13132  type_end - type_start)
13133  == 0)
13134  {
13135  int found = 0;
13136  params_t *files;
13137 
13138  files = params_values (params, "file:");
13139  if (files)
13140  {
13141  param_t *file;
13142  gchar *file_name;
13143  params_iterator_t file_params;
13144 
13145  params_iterator_init (&file_params, files);
13146  while (params_iterator_next (&file_params,
13147  &file_name,
13148  &file))
13149  if (strcmp (file_name, preference_name) == 0)
13150  {
13151  found = 1;
13152  break;
13153  }
13154  }
13155  if (found == 0)
13156  /* Skip modifying the file preference. */
13157  continue;
13158  }
13159  else if (strncmp (preference_name + type_start,
13160  "scanner",
13161  type_end - type_start)
13162  == 0)
13163  {
13164  /* Presume it's the timeout. */
13165  is_timeout = 1;
13166  }
13167  }
13168 
13169  value = preference->value_size
13170  ? g_base64_encode ((guchar *) preference->value,
13171  preference->value_size)
13172  : g_strdup ("");
13173 
13174  if (is_timeout)
13175  {
13176  const char *timeout;
13177  gchar *preference_name_escaped;
13178 
13179  timeout = params_value (params, "timeout");
13180 
13181  if (timeout == NULL)
13182  {
13183  g_free (value);
13184  openvas_connection_close (&connection);
13185  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
13186  return gsad_message (credentials,
13187  "Internal error", __FUNCTION__, __LINE__,
13188  "An internal error occurred while saving a config. "
13189  "It is unclear whether the entire config has been saved. "
13190  "Diagnostics: Required parameter was NULL.",
13191  "/omp?cmd=get_configs", response_data);
13192  }
13193 
13194  preference_name_escaped = g_markup_escape_text (preference_name,
13195  -1);
13196 
13197  if (strcmp (timeout, "0") == 0)
13198  /* Leave out the value to clear the preference. */
13199  ret = openvas_connection_sendf (&connection,
13200  "<modify_config"
13201  " config_id=\"%s\">"
13202  "<preference>"
13203  "<name>%s</name>"
13204  "</preference>"
13205  "</modify_config>",
13206  config_id,
13207  preference_name_escaped);
13208  else
13209  ret = openvas_connection_sendf (&connection,
13210  "<modify_config"
13211  " config_id=\"%s\">"
13212  "<preference>"
13213  "<name>%s</name>"
13214  "<value>%s</value>"
13215  "</preference>"
13216  "</modify_config>",
13217  config_id,
13218  preference_name_escaped,
13219  value);
13220 
13221  g_free (preference_name_escaped);
13222  }
13223  else
13224  {
13225  gchar *preference_name_escaped;
13226  preference_name_escaped = g_markup_escape_text (preference_name,
13227  -1);
13228  ret = openvas_connection_sendf (&connection,
13229  "<modify_config"
13230  " config_id=\"%s\">"
13231  "<preference>"
13232  "<nvt oid=\"%s\"/>"
13233  "<name>%s</name>"
13234  "<value>%s</value>"
13235  "</preference>"
13236  "</modify_config>",
13237  config_id,
13238  params_value (params, "oid"),
13239  preference_name_escaped,
13240  value);
13241  g_free (preference_name_escaped);
13242  }
13243 
13244  if (ret == -1)
13245  {
13246  g_free (value);
13247  openvas_connection_close (&connection);
13248  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
13249  return gsad_message (credentials,
13250  "Internal error", __FUNCTION__, __LINE__,
13251  "An internal error occurred while saving a config. "
13252  "It is unclear whether the entire config has been saved. "
13253  "Diagnostics: Failure to send command to manager daemon.",
13254  "/omp?cmd=get_configs", response_data);
13255  }
13256  g_free (value);
13257 
13258  modify_config_ret = check_modify_config (credentials, &connection,
13259  params,
13260  "get_config_nvt",
13261  "edit_config_nvt",
13262  &success, response_data);
13263  if (success == 0)
13264  {
13265  openvas_connection_close (&connection);
13266  return modify_config_ret;
13267  }
13268  }
13269 
13270  openvas_connection_close (&connection);
13271  }
13272 
13273  return modify_config_ret;
13274 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int value_size
Definition: gsad_base.h:152
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_config_omp ( 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]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Following page.

Definition at line 12257 of file gsad_omp.c.

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

12259 {
12260  openvas_connection_t connection;
12261  int omp_ret;
12262  char *ret;
12263  gchar *html;
12264  params_t *preferences, *selects, *trends;
12265  const char *config_id, *name, *comment, *scanner_id;
12266  int success;
12267 
12268  config_id = params_value (params, "config_id");
12269  name = params_value (params, "name");
12270  comment = params_value (params, "comment");
12271  scanner_id = params_value (params, "scanner_id");
12272 
12273  CHECK_PARAM_INVALID (config_id, "Save Config", "edit_config");
12274  CHECK_PARAM_INVALID (name, "Save Config", "edit_config");
12275  CHECK_PARAM_INVALID (comment, "Save Config", "edit_config");
12276 
12277  switch (manager_connect (credentials, &connection, &html,
12278  response_data))
12279  {
12280  case 0:
12281  break;
12282  case -1:
12283  if (html)
12284  return html;
12285  /* Fall through. */
12286  default:
12287  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12288  return gsad_message (credentials,
12289  "Internal error", __FUNCTION__, __LINE__,
12290  "An internal error occurred while saving a config. "
12291  "The current list of configs is not available. "
12292  "Diagnostics: Failure to connect to manager daemon.",
12293  "/omp?cmd=get_configs", response_data);
12294  }
12295 
12296  /* Save name and comment. */
12297 
12298  if (scanner_id)
12299  omp_ret = openvas_connection_sendf_xml (&connection,
12300  "<modify_config config_id=\"%s\">"
12301  "<name>%s</name>"
12302  "<comment>%s</comment>"
12303  "<scanner>%s</scanner>"
12304  "</modify_config>",
12305  params_value (params, "config_id"),
12306  name,
12307  comment,
12308  scanner_id);
12309  else
12310  omp_ret = openvas_connection_sendf_xml (&connection,
12311  "<modify_config config_id=\"%s\">"
12312  "<name>%s</name>"
12313  "<comment>%s</comment>"
12314  "</modify_config>",
12315  params_value (params, "config_id"),
12316  name,
12317  comment);
12318 
12319  if (omp_ret == -1)
12320  {
12321  openvas_connection_close (&connection);
12322  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12323  return gsad_message (credentials,
12324  "Internal error", __FUNCTION__, __LINE__,
12325  "An internal error occurred while saving a config. "
12326  "It is unclear whether the entire config has been saved. "
12327  "Diagnostics: Failure to send command to manager daemon.",
12328  "/omp?cmd=get_configs", response_data);
12329  }
12330 
12331  ret = check_modify_config (credentials, &connection, params,
12332  "get_config", "edit_config",
12333  &success, response_data);
12334  if (success == 0)
12335  {
12336  openvas_connection_close (&connection);
12337  return ret;
12338  }
12339  g_free (ret);
12340 
12341  /* Save preferences. */
12342 
12343  preferences = params_values (params, "preference:");
12344  if (preferences)
12345  {
12346  params_iterator_t iter;
12347  char *param_name;
12348  param_t *param;
12349 
12350  params_iterator_init (&iter, preferences);
12351  while (params_iterator_next (&iter, &param_name, &param))
12352  {
12353  gchar *value;
12354 
12355  value = param->value_size
12356  ? g_base64_encode ((guchar *) param->value,
12357  param->value_size)
12358  : g_strdup ("");
12359 
12360  if (openvas_connection_sendf (&connection,
12361  "<modify_config config_id=\"%s\">"
12362  "<preference>"
12363  "<name>%s</name>"
12364  "<value>%s</value>"
12365  "</preference>"
12366  "</modify_config>",
12367  params_value (params, "config_id"),
12368  param_name,
12369  value)
12370  == -1)
12371  {
12372  g_free (value);
12373  openvas_connection_close (&connection);
12374  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12375  return gsad_message (credentials,
12376  "Internal error", __FUNCTION__, __LINE__,
12377  "An internal error occurred while saving a config. "
12378  "It is unclear whether the entire config has been saved. "
12379  "Diagnostics: Failure to send command to manager daemon.",
12380  "/omp?cmd=get_configs", response_data);
12381  }
12382  g_free (value);
12383 
12384  ret = check_modify_config (credentials, &connection, params,
12385  "get_config", "edit_config",
12386  &success, response_data);
12387  if (success == 0)
12388  {
12389  openvas_connection_close (&connection);
12390  return ret;
12391  }
12392  }
12393  }
12394 
12395  /* OSP config file preference. */
12396  ret = save_osp_prefs (credentials, &connection, params,
12397  "get_config", "edit_config",
12398  &success, response_data);
12399  if (success == 0)
12400  {
12401  openvas_connection_close (&connection);
12402  return ret;
12403  }
12404  g_free (ret);
12405 
12406  /* Update the config. */
12407 
12408  trends = params_values (params, "trend:");
12409 
12410  if (openvas_connection_sendf (&connection,
12411  "<modify_config config_id=\"%s\">"
12412  "<family_selection>"
12413  "<growing>%i</growing>",
12414  params_value (params, "config_id"),
12415  trends
12416  && params_value (params, "trend")
12417  && strcmp (params_value (params, "trend"), "0"))
12418  == -1)
12419  {
12420  openvas_connection_close (&connection);
12421  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12422  return gsad_message (credentials,
12423  "Internal error", __FUNCTION__, __LINE__,
12424  "An internal error occurred while saving a config. "
12425  "It is unclear whether the entire config has been saved. "
12426  "Diagnostics: Failure to send command to manager daemon.",
12427  "/omp?cmd=get_configs", response_data);
12428  }
12429 
12430  selects = params_values (params, "select:");
12431 
12432  if (selects)
12433  {
12434  gchar *family;
12435  params_iterator_t iter;
12436  param_t *param;
12437 
12438  params_iterator_init (&iter, selects);
12439  while (params_iterator_next (&iter, &family, &param))
12440  if (openvas_connection_sendf (&connection,
12441  "<family>"
12442  "<name>%s</name>"
12443  "<all>1</all>"
12444  "<growing>%i</growing>"
12445  "</family>",
12446  family,
12447  trends && member1 (trends, family))
12448  == -1)
12449  {
12450  openvas_connection_close (&connection);
12451  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12452  return gsad_message (credentials,
12453  "Internal error", __FUNCTION__, __LINE__,
12454  "An internal error occurred while saving a config. "
12455  "It is unclear whether the entire config has been saved. "
12456  "Diagnostics: Failure to send command to manager daemon.",
12457  "/omp?cmd=get_configs", response_data);
12458  }
12459  }
12460 
12461  if (trends)
12462  {
12463  gchar *family;
12464  params_iterator_t iter;
12465  param_t *param;
12466 
12467  params_iterator_init (&iter, trends);
12468  while (params_iterator_next (&iter, &family, &param))
12469  {
12470  if (param->value_size == 0) continue;
12471  if (param->value[0] == '0') continue;
12472  if (selects && member (selects, family)) continue;
12473  if (openvas_connection_sendf (&connection,
12474  "<family>"
12475  "<name>%s</name>"
12476  "<all>0</all>"
12477  "<growing>1</growing>"
12478  "</family>",
12479  family)
12480  == -1)
12481  {
12482  openvas_connection_close (&connection);
12483  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12484  return gsad_message (credentials,
12485  "Internal error", __FUNCTION__, __LINE__,
12486  "An internal error occurred while saving a config. "
12487  "It is unclear whether the entire config has been saved. "
12488  "Diagnostics: Failure to send command to manager daemon.",
12489  "/omp?cmd=get_configs", response_data);
12490  }
12491  }
12492  }
12493 
12494  if (openvas_connection_sendf (&connection,
12495  "</family_selection>"
12496  "</modify_config>")
12497  == -1)
12498  {
12499  openvas_connection_close (&connection);
12500  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12501  return gsad_message (credentials,
12502  "Internal error", __FUNCTION__, __LINE__,
12503  "An internal error occurred while saving a config. "
12504  "It is unclear whether the entire config has been saved. "
12505  "Diagnostics: Failure to send command to manager daemon.",
12506  "/omp?cmd=get_configs", response_data);
12507  }
12508 
12509  ret = check_modify_config (credentials, &connection, params,
12510  "get_config", "edit_config",
12511  NULL, response_data);
12512 
12513  openvas_connection_close (&connection);
12514  return ret;
12515 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
int value_size
Definition: gsad_base.h:152
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int member1(params_t *params, const char *string)
Look for param with value 1 and name equal to given string.
Definition: gsad_omp.c:721
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_container_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save container task, get next page, XSL transform the result.

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

Definition at line 5000 of file gsad_omp.c.

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

5002 {
5003  gchar *format, *response, *html;
5004  const char *no_redirect, *comment, *name, *task_id;
5005  const char *in_assets, *auto_delete, *auto_delete_data;
5006  int ret;
5007  entity_t entity;
5008 
5009  no_redirect = params_value (params, "no_redirect");
5010  comment = params_value (params, "comment");
5011  in_assets = params_value (params, "in_assets");
5012  name = params_value (params, "name");
5013  task_id = params_value (params, "task_id");
5014  auto_delete = params_value (params, "auto_delete");
5015  auto_delete_data = params_value (params, "auto_delete_data");
5016  CHECK_PARAM_INVALID (name, "Save Task", "edit_task")
5017  CHECK_PARAM_INVALID (comment, "Save Task", "edit_task")
5018  CHECK_PARAM_INVALID (task_id, "Save Task", "edit_task")
5019  CHECK_PARAM_INVALID (in_assets, "Save Task", "edit_task")
5020  CHECK_PARAM_INVALID (auto_delete, "Save Task", "edit_task");
5021  CHECK_PARAM_INVALID (auto_delete_data, "Save Task", "edit_task");
5022 
5023  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
5024  "<name>%%s</name>"
5025  "<comment>%%s</comment>"
5026  "<preferences>"
5027  "<preference>"
5028  "<scanner_name>in_assets</scanner_name>"
5029  "<value>%%s</value>"
5030  "</preference>"
5031  "<preference>"
5032  "<scanner_name>auto_delete</scanner_name>"
5033  "<value>%%s</value>"
5034  "</preference>"
5035  "<preference>"
5036  "<scanner_name>auto_delete_data</scanner_name>"
5037  "<value>%%s</value>"
5038  "</preference>"
5039  "</preferences>"
5040  "</modify_task>");
5041 
5042  response = NULL;
5043  entity = NULL;
5044  ret = ompf (credentials, &response, &entity, response_data,
5045  format, task_id, name, comment,
5046  strcmp (in_assets, "0") ? "yes" : "no",
5047  auto_delete,
5048  auto_delete_data);
5049  g_free (format);
5050  switch (ret)
5051  {
5052  case 0:
5053  case -1:
5054  break;
5055  case 1:
5056  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5057  return gsad_message (credentials,
5058  "Internal error", __FUNCTION__, __LINE__,
5059  "An internal error occurred while saving a task. "
5060  "No new task was created. "
5061  "Diagnostics: Failure to send command to manager daemon.",
5062  "/omp?cmd=get_tasks", response_data);
5063  case 2:
5064  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5065  return gsad_message (credentials,
5066  "Internal error", __FUNCTION__, __LINE__,
5067  "An internal error occurred while saving a task. "
5068  "It is unclear whether the task has been created or not. "
5069  "Diagnostics: Failure to receive response from manager daemon.",
5070  "/omp?cmd=get_tasks", response_data);
5071  default:
5072  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
5073  return gsad_message (credentials,
5074  "Internal error", __FUNCTION__, __LINE__,
5075  "An internal error occurred while saving a task. "
5076  "It is unclear whether the task has been created or not. "
5077  "Diagnostics: Internal Error.",
5078  "/omp?cmd=get_tasks", response_data);
5079  }
5080 
5081  html = response_from_entity (credentials, params, entity,
5082  (no_redirect && strcmp (no_redirect, "0")),
5083  NULL, "get_tasks",
5084  NULL, "edit_task",
5085  "Save Container Task", response_data);
5086  free_entity (entity);
5087  g_free (response);
5088  return html;
5089 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_credential_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save credential, get next page, XSL transform the result.

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

Definition at line 6817 of file gsad_omp.c.

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

6819 {
6820  int ret, change_password, change_passphrase;
6821  int change_community, change_privacy_password;
6822  gchar *html, *response;
6823  const char *no_redirect, *credential_id;
6824  const char *name, *comment, *login, *password, *passphrase;
6825  const char *private_key, *certificate, *community, *privacy_password;
6826  const char *auth_algorithm, *privacy_algorithm, *allow_insecure;
6827  GString *command;
6828  entity_t entity;
6829 
6830  no_redirect = params_value (params, "no_redirect");
6831  credential_id = params_value (params, "credential_id");
6832  name = params_value (params, "name");
6833  comment = params_value (params, "comment");
6834  login = params_value (params, "credential_login");
6835  password = params_value (params, "password");
6836  passphrase = params_value (params, "passphrase");
6837  private_key = params_value (params, "private_key");
6838  certificate = params_value (params, "certificate");
6839  community = params_value (params, "community");
6840  privacy_password = params_value (params, "privacy_password");
6841  auth_algorithm = params_value (params, "auth_algorithm");
6842  privacy_algorithm = params_value (params, "privacy_algorithm");
6843  allow_insecure = params_value (params, "allow_insecure");
6844 
6845  CHECK_PARAM_INVALID (credential_id, "Save Credential", "edit_credential");
6846  CHECK_PARAM_INVALID (name, "Save Credential", "edit_credential");
6847  CHECK_PARAM_INVALID (comment, "Save Credential", "edit_credential");
6848  CHECK_PARAM_INVALID (allow_insecure, "Save Credential", "edit_credential");
6849  if (params_given (params, "certificate"))
6850  CHECK_PARAM_INVALID (certificate, "Save Credential", "edit_credential");
6851  if (params_given (params, "private_key"))
6852  CHECK_PARAM_INVALID (private_key, "Save Credential", "edit_credential");
6853  if (params_given (params, "login"))
6854  CHECK_PARAM_INVALID (login, "Save Credential", "edit_credential");
6855  if (params_given (params, "auth_algorithm"))
6856  CHECK_PARAM_INVALID (auth_algorithm, "Save Credential", "edit_credential");
6857  if (params_given (params, "privacy_algorithm"))
6858  CHECK_PARAM_INVALID (privacy_algorithm,
6859  "Save Credential", "edit_credential");
6860 
6861  change_community = (params_value (params, "change_community") ? 1 : 0);
6862  if (change_community)
6863  CHECK_PARAM_INVALID (community, "Save Credential", "edit_credential");
6864  change_passphrase = (params_value (params, "change_passphrase") ? 1 : 0);
6865  if (change_passphrase)
6866  CHECK_PARAM_INVALID (passphrase, "Save Credential", "edit_credential");
6867  change_password = (params_value (params, "change_password") ? 1 : 0);
6868  if (change_password)
6869  CHECK_PARAM_INVALID (password, "Save Credential", "edit_credential");
6870  change_privacy_password
6871  = (params_value (params, "change_privacy_password") ? 1 : 0);
6872  if (change_privacy_password)
6873  CHECK_PARAM_INVALID (privacy_password,
6874  "Save Credential", "edit_credential");
6875 
6876  /* Prepare command */
6877  command = g_string_new ("");
6878 
6879  xml_string_append (command,
6880  "<modify_credential credential_id=\"%s\">"
6881  "<name>%s</name>"
6882  "<comment>%s</comment>"
6883  "<allow_insecure>%s</allow_insecure>",
6884  credential_id,
6885  name,
6886  comment,
6887  allow_insecure);
6888 
6889  if (auth_algorithm)
6890  xml_string_append (command,
6891  "<auth_algorithm>%s</auth_algorithm>",
6892  auth_algorithm);
6893 
6894  if (certificate && strcmp (certificate, ""))
6895  xml_string_append (command,
6896  "<certificate>%s</certificate>",
6897  certificate);
6898 
6899  if (change_community)
6900  xml_string_append (command,
6901  "<community>%s</community>",
6902  community);
6903 
6904  if (login && strcmp (login, ""))
6905  xml_string_append (command,
6906  "<login>%s</login>",
6907  login);
6908 
6909  if (change_password)
6910  xml_string_append (command,
6911  "<password>%s</password>",
6912  password);
6913 
6914  if (privacy_algorithm || change_privacy_password)
6915  {
6916  xml_string_append (command,
6917  "<privacy>");
6918  if (privacy_algorithm && strcmp (privacy_algorithm, ""))
6919  {
6920  xml_string_append (command,
6921  "<algorithm>%s</algorithm>",
6922  privacy_algorithm);
6923  if (change_privacy_password)
6924  xml_string_append (command,
6925  "<password>%s</password>",
6926  privacy_password);
6927  }
6928  else if (privacy_algorithm)
6929  {
6930  xml_string_append (command,
6931  "<algorithm></algorithm>");
6932  xml_string_append (command,
6933  "<password></password>");
6934  }
6935 
6936  xml_string_append (command,
6937  "</privacy>");
6938  }
6939 
6940  if ((private_key && strcmp (private_key, "")) || change_passphrase)
6941  {
6942  xml_string_append (command,
6943  "<key>");
6944  if (change_passphrase)
6945  xml_string_append (command,
6946  "<phrase>%s</phrase>",
6947  passphrase);
6948  if (private_key)
6949  xml_string_append (command,
6950  "<private>%s</private>",
6951  private_key);
6952  xml_string_append (command,
6953  "</key>");
6954  }
6955 
6956  xml_string_append (command,
6957  "</modify_credential>");
6958 
6959  /* Modify the credential. */
6960  response = NULL;
6961  entity = NULL;
6962  ret = omp (credentials,
6963  &response,
6964  &entity,
6965  response_data,
6966  command->str);
6967  g_string_free (command, TRUE);
6968 
6969  switch (ret)
6970  {
6971  case 0:
6972  break;
6973  case -1:
6974  /* 'omp' set response. */
6975  return response;
6976  case 1:
6977  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6978  return gsad_message (credentials,
6979  "Internal error", __FUNCTION__, __LINE__,
6980  "An internal error occurred while saving a Credential. "
6981  "The Credential was not saved. "
6982  "Diagnostics: Failure to send command to manager daemon.",
6983  "/omp?cmd=get_credentials", response_data);
6984  case 2:
6985  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6986  return gsad_message (credentials,
6987  "Internal error", __FUNCTION__, __LINE__,
6988  "An internal error occurred while saving a Credential. "
6989  "It is unclear whether the Credential has been saved or not. "
6990  "Diagnostics: Failure to receive response from manager daemon.",
6991  "/omp?cmd=get_credentials", response_data);
6992  default:
6993  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
6994  return gsad_message (credentials,
6995  "Internal error", __FUNCTION__, __LINE__,
6996  "An internal error occurred while saving a Credential. "
6997  "It is unclear whether the Credential has been saved or not. "
6998  "Diagnostics: Internal Error.",
6999  "/omp?cmd=get_credentials", response_data);
7000  }
7001 
7002  html = response_from_entity (credentials, params, entity,
7003  (no_redirect && strcmp (no_redirect, "0")),
7004  NULL, "get_credentials",
7005  NULL, "edit_credential",
7006  "Save Credential", response_data);
7007  free_entity (entity);
7008  g_free (response);
7009  return html;
7010 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_filter_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a filter, get all filters, XSL transform the result.

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

Definition at line 24562 of file gsad_omp.c.

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

24564 {
24565  openvas_connection_t connection;
24566  entity_t entity;
24567  gchar *html, *response;
24568  const char *no_redirect, *filter_id, *name, *comment, *term, *type;
24569 
24570  no_redirect = params_value (params, "no_redirect");
24571  filter_id = params_value (params, "filter_id");
24572  name = params_value (params, "name");
24573  comment = params_value (params, "comment");
24574  term = params_value (params, "term");
24575  type = params_value (params, "optional_resource_type");
24576 
24577  CHECK_PARAM_INVALID (filter_id, "Save Filter", "edit_filter");
24578  CHECK_PARAM_INVALID (name, "Save Filter", "edit_filter");
24579  CHECK_PARAM_INVALID (comment, "Save Filter", "edit_filter");
24580  CHECK_PARAM_INVALID (term, "Save Filter", "edit_filter");
24581  CHECK_PARAM_INVALID (type, "Save Filter", "edit_filter");
24582 
24583  switch (manager_connect (credentials, &connection, &html,
24584  response_data))
24585  {
24586  case 0:
24587  break;
24588  case -1:
24589  if (html)
24590  return html;
24591  /* Fall through. */
24592  default:
24593  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24594  return gsad_message (credentials,
24595  "Internal error", __FUNCTION__, __LINE__,
24596  "An internal error occurred while saving a filter. "
24597  "The filter was not saved. "
24598  "Diagnostics: Failure to connect to manager daemon.",
24599  "/omp?cmd=get_filters", response_data);
24600  }
24601 
24602  {
24603  int ret;
24604 
24605  /* Modify the filter. */
24606 
24607  ret = openvas_connection_sendf_xml (&connection,
24608  "<modify_filter filter_id=\"%s\">"
24609  "<name>%s</name>"
24610  "<comment>%s</comment>"
24611  "<term>%s</term>"
24612  "<type>%s</type>"
24613  "</modify_filter>",
24614  filter_id,
24615  name,
24616  comment,
24617  term,
24618  type);
24619 
24620  if (ret == -1)
24621  {
24622  openvas_connection_close (&connection);
24623  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24624  return gsad_message (credentials,
24625  "Internal error", __FUNCTION__, __LINE__,
24626  "An internal error occurred while modifying a filter. "
24627  "The filter was not modified. "
24628  "Diagnostics: Failure to send command to manager daemon.",
24629  "/omp?cmd=get_filters", response_data);
24630  }
24631 
24632  entity = NULL;
24633  if (read_entity_and_text_c (&connection, &entity, &response))
24634  {
24635  openvas_connection_close (&connection);
24636  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24637  return gsad_message (credentials,
24638  "Internal error", __FUNCTION__, __LINE__,
24639  "An internal error occurred while modifying a filter. "
24640  "It is unclear whether the filter has been modified or not. "
24641  "Diagnostics: Failure to receive response from manager daemon.",
24642  "/omp?cmd=get_filters", response_data);
24643  }
24644 
24645  }
24646 
24647  openvas_connection_close (&connection);
24648 
24649  /* Pass response to handler of following page. */
24650 
24651  html = response_from_entity (credentials, params, entity,
24652  (no_redirect && strcmp (no_redirect, "0")),
24653  NULL, "get_filters",
24654  NULL, "edit_filter",
24655  "Save Filter", response_data);
24656 
24657  free_entity (entity);
24658  g_free (response);
24659  return html;
24660 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

char* save_group_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a group, return the next page.

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

Definition at line 20994 of file gsad_omp.c.

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

20996 {
20997  int ret;
20998  gchar *html, *response;
20999  const char *no_redirect, *group_id, *name, *comment, *users;
21000  entity_t entity;
21001 
21002  no_redirect = params_value (params, "no_redirect");
21003  group_id = params_value (params, "group_id");
21004  name = params_value (params, "name");
21005  comment = params_value (params, "comment");
21006  users = params_value (params, "users");
21007 
21008  CHECK_PARAM_INVALID (group_id, "Save Group", "edit_group");
21009  CHECK_PARAM_INVALID (name, "Save Group", "edit_group");
21010  CHECK_PARAM_INVALID (comment, "Save Group", "edit_group");
21011  CHECK_PARAM_INVALID (users, "Save Group", "edit_group");
21012 
21013  /* Modify the Group. */
21014 
21015  response = NULL;
21016  entity = NULL;
21017  ret = ompf (credentials,
21018  &response,
21019  &entity,
21020  response_data,
21021  "<modify_group group_id=\"%s\">"
21022  "<name>%s</name>"
21023  "<comment>%s</comment>"
21024  "<users>%s</users>"
21025  "</modify_group>",
21026  group_id,
21027  name,
21028  comment,
21029  users);
21030 
21031  switch (ret)
21032  {
21033  case 0:
21034  case -1:
21035  break;
21036  case 1:
21037  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21038  return gsad_message (credentials,
21039  "Internal error", __FUNCTION__, __LINE__,
21040  "An internal error occurred while saving a group. "
21041  "The group was not saved. "
21042  "Diagnostics: Failure to send command to manager daemon.",
21043  "/omp?cmd=get_groups", response_data);
21044  case 2:
21045  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21046  return gsad_message (credentials,
21047  "Internal error", __FUNCTION__, __LINE__,
21048  "An internal error occurred while saving a group. "
21049  "It is unclear whether the group has been saved or not. "
21050  "Diagnostics: Failure to receive response from manager daemon.",
21051  "/omp?cmd=get_groups", response_data);
21052  default:
21053  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
21054  return gsad_message (credentials,
21055  "Internal error", __FUNCTION__, __LINE__,
21056  "An internal error occurred while saving a group. "
21057  "It is unclear whether the group has been saved or not. "
21058  "Diagnostics: Internal Error.",
21059  "/omp?cmd=get_groups", response_data);
21060  }
21061 
21062  html = response_from_entity (credentials, params, entity,
21063  (no_redirect && strcmp (no_redirect, "0")),
21064  NULL, "get_groups",
21065  NULL, "edit_group",
21066  "Save Group", response_data);
21067  free_entity (entity);
21068  g_free (response);
21069  return html;
21070 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_my_settings_omp ( credentials_t credentials,
params_t params,
const char *  accept_language,
char **  timezone,
char **  password,
char **  severity,
char **  language,
cmd_response_data_t response_data 
)

Returns page with user's settings, for editing.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[in]accept_languageAccept-Language, from browser.
[out]timezoneTimezone. Caller must free.
[out]passwordPassword. Caller must free.
[out]severitySeverity. Caller must free.
[out]languageLanguage. Caller must free.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 19731 of file gsad_omp.c.

References accept_language_to_env_fmt(), gsad_message(), GSAD_MESSAGE_INVALID_PARAM, cmd_response_data_t::http_status_code, credentials_t::language, manager_connect(), params_t, params_value(), params_values(), credentials_t::password, set_http_status_from_entity(), set_language_code(), credentials_t::severity, credentials_t::timezone, and credentials_t::username.

Referenced by exec_omp_post().

19735 {
19736  openvas_connection_t connection;
19737  gchar *html;
19738  const char *lang, *text, *old_passwd, *passwd, *status, *max;
19739  const char *details_fname, *list_fname, *report_fname;
19740  gchar *lang_64, *text_64, *max_64, *fname_64;
19741  GString *xml;
19742  entity_t entity;
19743  params_t *changed, *defaults, *filters;
19744  int modify_failed = 0;
19745  const char *changed_value;
19746 
19747  changed = params_values (params, "settings_changed:");
19748  *timezone = NULL;
19749  *password = NULL;
19750  *severity = NULL;
19751  *language = NULL;
19752 
19753  text = params_value (params, "text");
19754  old_passwd = params_value (params, "old_password");
19755  passwd = params_value (params, "password");
19756  max = params_value (params, "max");
19757  lang = params_value (params, "lang");
19758  details_fname = params_value (params, "details_fname");
19759  list_fname = params_value (params, "list_fname");
19760  report_fname = params_value (params, "report_fname");
19761  if ((text == NULL)
19762  || (passwd == NULL)
19763  || (old_passwd == NULL)
19764  || (max == NULL)
19765  || (lang == NULL)
19766  || (details_fname == NULL)
19767  || (list_fname == NULL)
19768  || (report_fname == NULL))
19769  return edit_my_settings (credentials, params,
19771  ("Save My Settings"),
19772  response_data);
19773 
19774  switch (manager_connect (credentials, &connection, &html,
19775  response_data))
19776  {
19777  case 0:
19778  break;
19779  case -1:
19780  if (html)
19781  return html;
19782  /* Fall through. */
19783  default:
19784  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19785  return gsad_message (credentials,
19786  "Internal error", __FUNCTION__, __LINE__,
19787  "An internal error occurred while saving settings. "
19788  "The settings remains the same. "
19789  "Diagnostics: Failure to connect to manager daemon.",
19790  "/omp?cmd=get_my_settings", response_data);
19791  }
19792 
19793  xml = g_string_new ("");
19794 
19795  changed_value = params_value (changed, "password");
19796  if ((strlen (passwd) || strlen (old_passwd))
19797  && (changed_value == NULL
19798  || (strcmp (changed_value, "") && strcmp (changed_value, "0"))))
19799  {
19800  gchar *passwd_64;
19801  omp_authenticate_info_opts_t auth_opts;
19802 
19803  /* Send Password setting */
19804 
19805  auth_opts = omp_authenticate_info_opts_defaults;
19806  auth_opts.username = credentials->username;
19807  auth_opts.password = old_passwd;
19808  switch (omp_authenticate_info_ext_c (&connection, auth_opts))
19809  {
19810  case 0:
19811  break;
19812  case 1:
19813  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19814  return gsad_message (credentials,
19815  "Internal error", __FUNCTION__, __LINE__,
19816  "An internal error occurred while saving settings. "
19817  "The settings remains the same. "
19818  "Diagnostics: Manager closed connection during authenticate.",
19819  "/omp?cmd=get_my_settings", response_data);
19820  case 2:
19821  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19822  g_string_append (xml,
19823  "<gsad_msg"
19824  " status_text=\"Password error\""
19825  " operation=\"Save My Settings\">"
19826  "You tried to change your password, but the old"
19827  " password was not provided or was incorrect. "
19828  " Please enter the correct old password or remove"
19829  " old and new passwords to apply any other changes"
19830  " of your settings."
19831  "</gsad_msg>");
19832  return edit_my_settings (credentials, params,
19833  g_string_free (xml, FALSE),
19834  response_data);
19835  default:
19836  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19837  return gsad_message (credentials,
19838  "Internal error", __FUNCTION__, __LINE__,
19839  "An internal error occurred while saving settings. "
19840  "The settings remains the same. "
19841  "Diagnostics: Internal Error.",
19842  "/omp?cmd=get_my_settings", response_data);
19843  }
19844 
19845  passwd_64 = g_base64_encode ((guchar*) passwd, strlen (passwd));
19846 
19847  if (openvas_connection_sendf (&connection,
19848  "<modify_setting>"
19849  "<name>Password</name>"
19850  "<value>%s</value>"
19851  "</modify_setting>",
19852  passwd_64 ? passwd_64 : "")
19853  == -1)
19854  {
19855  g_free (passwd_64);
19856  openvas_connection_close (&connection);
19857  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19858  return gsad_message (credentials,
19859  "Internal error", __FUNCTION__, __LINE__,
19860  "An internal error occurred while saving settings. "
19861  "It is unclear whether all the settings were saved. "
19862  "Diagnostics: Failure to send command to manager daemon.",
19863  "/omp?cmd=get_my_settings", response_data);
19864  }
19865  g_free (passwd_64);
19866 
19867  entity = NULL;
19868  xml_string_append (xml, "<save_setting name=\"Password\">");
19869  if (read_entity_and_string_c (&connection, &entity, &xml))
19870  {
19871  g_string_free (xml, TRUE);
19872  openvas_connection_close (&connection);
19873  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19874  return gsad_message (credentials,
19875  "Internal error", __FUNCTION__, __LINE__,
19876  "An internal error occurred while saving settings. "
19877  "Diagnostics: Failure to receive response from manager daemon.",
19878  "/omp?cmd=get_my_settings", response_data);
19879  }
19880  xml_string_append (xml, "</save_setting>");
19881 
19882  status = entity_attribute (entity, "status");
19883  if (status && (strlen (status) > 0) && (status[0] == '2'))
19884  {
19885  g_free (credentials->password);
19886  credentials->password = g_strdup (passwd);
19887  *password = g_strdup (passwd);
19888  }
19889  else
19890  {
19891  set_http_status_from_entity (entity, response_data);
19892  modify_failed = 1;
19893  }
19894  }
19895 
19896  /* Send Timezone */
19897  changed_value = params_value (changed, "timezone");
19898  if (changed_value == NULL
19899  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19900  {
19901  text_64 = g_base64_encode ((guchar*) text, strlen (text));
19902 
19903  if (openvas_connection_sendf (&connection,
19904  "<modify_setting>"
19905  "<name>Timezone</name>"
19906  "<value>%s</value>"
19907  "</modify_setting>",
19908  text_64 ? text_64 : "")
19909  == -1)
19910  {
19911  g_free (text_64);
19912  openvas_connection_close (&connection);
19913  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19914  return gsad_message (credentials,
19915  "Internal error", __FUNCTION__, __LINE__,
19916  "An internal error occurred while saving settings. "
19917  "It is unclear whether all the settings were saved. "
19918  "Diagnostics: Failure to send command to manager daemon.",
19919  "/omp?cmd=get_my_settings", response_data);
19920  }
19921  g_free (text_64);
19922 
19923  entity = NULL;
19924  xml_string_append (xml, "<save_setting name=\"Timezone\">");
19925  if (read_entity_and_string_c (&connection, &entity, &xml))
19926  {
19927  g_string_free (xml, TRUE);
19928  openvas_connection_close (&connection);
19929  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19930  return gsad_message (credentials,
19931  "Internal error", __FUNCTION__, __LINE__,
19932  "An internal error occurred while saving settings. "
19933  "Diagnostics: Failure to receive response from manager daemon.",
19934  "/omp?cmd=get_my_settings", response_data);
19935  }
19936  xml_string_append (xml, "</save_setting>");
19937 
19938  status = entity_attribute (entity, "status");
19939  if (status && (strlen (status) > 0) && (status[0] == '2'))
19940  {
19941  g_free (credentials->timezone);
19942  credentials->timezone = g_strdup (strlen (text) ? text : "UTC");
19943  *timezone = g_strdup (strlen (text) ? text : "UTC");
19944 
19945  /* Set the timezone, so that the ENVELOPE/TIME
19946  * uses the right timezone. */
19947 
19948  if (setenv ("TZ", credentials->timezone, 1) == -1)
19949  {
19950  openvas_connection_close (&connection);
19951  g_critical ("%s: failed to set TZ\n", __FUNCTION__);
19952  exit (EXIT_FAILURE);
19953  }
19954  tzset ();
19955  }
19956  else
19957  {
19958  set_http_status_from_entity (entity, response_data);
19959  modify_failed = 1;
19960  }
19961  }
19962 
19963  /* Send Rows Per Page */
19964  changed_value = params_value (changed, "max");
19965  if (changed_value == NULL
19966  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
19967  {
19968  max_64 = g_base64_encode ((guchar*) max, strlen (max));
19969 
19970  if (openvas_connection_sendf (&connection,
19971  "<modify_setting"
19972  " setting_id"
19973  "=\"5f5a8712-8017-11e1-8556-406186ea4fc5\">"
19974  "<value>%s</value>"
19975  "</modify_setting>",
19976  max_64 ? max_64 : "")
19977  == -1)
19978  {
19979  g_free (max_64);
19980  openvas_connection_close (&connection);
19981  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19982  return gsad_message (credentials,
19983  "Internal error", __FUNCTION__, __LINE__,
19984  "An internal error occurred while saving settings. "
19985  "It is unclear whether all the settings were saved. "
19986  "Diagnostics: Failure to send command to manager daemon.",
19987  "/omp?cmd=get_my_settings", response_data);
19988  }
19989  g_free (max_64);
19990 
19991  entity = NULL;
19992  xml_string_append (xml,
19993  "<save_setting id=\"%s\">",
19994  "5f5a8712-8017-11e1-8556-406186ea4fc5");
19995  if (read_entity_and_string_c (&connection, &entity, &xml))
19996  {
19997  g_string_free (xml, TRUE);
19998  openvas_connection_close (&connection);
19999  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20000  return gsad_message (credentials,
20001  "Internal error", __FUNCTION__, __LINE__,
20002  "An internal error occurred while saving settings. "
20003  "It is unclear whether all the settings were saved. "
20004  "Diagnostics: Failure to receive response from manager daemon.",
20005  "/omp?cmd=get_my_settings", response_data);
20006  }
20007  xml_string_append (xml, "</save_setting>");
20008  if (! omp_success (entity))
20009  {
20010  set_http_status_from_entity (entity, response_data);
20011  modify_failed = 1;
20012  }
20013  }
20014 
20015  /* Send resource details export file name format. */
20016  changed_value = params_value (changed, "details_fname");
20017  if (changed_value == NULL
20018  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20019  {
20020  fname_64 = g_base64_encode ((guchar*) details_fname, strlen (details_fname));
20021 
20022  if (openvas_connection_sendf (&connection,
20023  "<modify_setting"
20024  " setting_id"
20025  "=\"a6ac88c5-729c-41ba-ac0a-deea4a3441f2\">"
20026  "<value>%s</value>"
20027  "</modify_setting>",
20028  fname_64 ? fname_64 : "")
20029  == -1)
20030  {
20031  g_free (fname_64);
20032  openvas_connection_close (&connection);
20033  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20034  return gsad_message (credentials,
20035  "Internal error", __FUNCTION__, __LINE__,
20036  "An internal error occurred while saving settings. "
20037  "It is unclear whether all the settings were saved. "
20038  "Diagnostics: Failure to send command to manager daemon.",
20039  "/omp?cmd=get_my_settings", response_data);
20040  }
20041  g_free (fname_64);
20042 
20043  entity = NULL;
20044  xml_string_append (xml,
20045  "<save_setting id=\"%s\">",
20046  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
20047  if (read_entity_and_string_c (&connection, &entity, &xml))
20048  {
20049  g_string_free (xml, TRUE);
20050  openvas_connection_close (&connection);
20051  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20052  return gsad_message (credentials,
20053  "Internal error", __FUNCTION__, __LINE__,
20054  "An internal error occurred while saving settings. "
20055  "It is unclear whether all the settings were saved. "
20056  "Diagnostics: Failure to receive response from manager daemon.",
20057  "/omp?cmd=get_my_settings", response_data);
20058  }
20059  xml_string_append (xml, "</save_setting>");
20060  if (omp_success (entity) != 1)
20061  {
20062  set_http_status_from_entity (entity, response_data);
20063  modify_failed = 1;
20064  }
20065  }
20066 
20067  /* Send resource list export file name format. */
20068  changed_value = params_value (changed, "list_fname");
20069  if (changed_value == NULL
20070  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20071  {
20072  fname_64 = g_base64_encode ((guchar*) list_fname, strlen (list_fname));
20073 
20074  if (openvas_connection_sendf (&connection,
20075  "<modify_setting"
20076  " setting_id"
20077  "=\"0872a6ed-4f85-48c5-ac3f-a5ef5e006745\">"
20078  "<value>%s</value>"
20079  "</modify_setting>",
20080  fname_64 ? fname_64 : "")
20081  == -1)
20082  {
20083  g_free (fname_64);
20084  openvas_connection_close (&connection);
20085  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20086  return gsad_message (credentials,
20087  "Internal error", __FUNCTION__, __LINE__,
20088  "An internal error occurred while saving settings. "
20089  "It is unclear whether all the settings were saved. "
20090  "Diagnostics: Failure to send command to manager daemon.",
20091  "/omp?cmd=get_my_settings", response_data);
20092  }
20093  g_free (fname_64);
20094 
20095  entity = NULL;
20096  xml_string_append (xml,
20097  "<save_setting id=\"%s\">",
20098  "a6ac88c5-729c-41ba-ac0a-deea4a3441f2");
20099  if (read_entity_and_string_c (&connection, &entity, &xml))
20100  {
20101  g_string_free (xml, TRUE);
20102  openvas_connection_close (&connection);
20103  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20104  return gsad_message (credentials,
20105  "Internal error", __FUNCTION__, __LINE__,
20106  "An internal error occurred while saving settings. "
20107  "It is unclear whether all the settings were saved. "
20108  "Diagnostics: Failure to receive response from manager daemon.",
20109  "/omp?cmd=get_my_settings", response_data);
20110  }
20111  xml_string_append (xml, "</save_setting>");
20112  if (omp_success (entity) != 1)
20113  {
20114  set_http_status_from_entity (entity, response_data);
20115  modify_failed = 1;
20116  }
20117  }
20118 
20119  /* Send report export file name format. */
20120  changed_value = params_value (changed, "report_fname");
20121  if (changed_value == NULL
20122  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20123  {
20124  fname_64 = g_base64_encode ((guchar*) report_fname, strlen (report_fname));
20125 
20126  if (openvas_connection_sendf (&connection,
20127  "<modify_setting"
20128  " setting_id"
20129  "=\"e1a2ae0b-736e-4484-b029-330c9e15b900\">"
20130  "<value>%s</value>"
20131  "</modify_setting>",
20132  fname_64 ? fname_64 : "")
20133  == -1)
20134  {
20135  g_free (fname_64);
20136  openvas_connection_close (&connection);
20137  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20138  return gsad_message (credentials,
20139  "Internal error", __FUNCTION__, __LINE__,
20140  "An internal error occurred while saving settings. "
20141  "It is unclear whether all the settings were saved. "
20142  "Diagnostics: Failure to send command to manager daemon.",
20143  "/omp?cmd=get_my_settings", response_data);
20144  }
20145  g_free (fname_64);
20146 
20147  entity = NULL;
20148  xml_string_append (xml,
20149  "<save_setting id=\"%s\">",
20150  "e1a2ae0b-736e-4484-b029-330c9e15b900");
20151  if (read_entity_and_string_c (&connection, &entity, &xml))
20152  {
20153  g_string_free (xml, TRUE);
20154  openvas_connection_close (&connection);
20155  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20156  return gsad_message (credentials,
20157  "Internal error", __FUNCTION__, __LINE__,
20158  "An internal error occurred while saving settings. "
20159  "It is unclear whether all the settings were saved. "
20160  "Diagnostics: Failure to receive response from manager daemon.",
20161  "/omp?cmd=get_my_settings", response_data);
20162  }
20163  xml_string_append (xml, "</save_setting>");
20164  if (omp_success (entity) != 1)
20165  {
20166  set_http_status_from_entity (entity, response_data);
20167  modify_failed = 1;
20168  }
20169  }
20170 
20171  /* Send User Interface Language. */
20172  changed_value = params_value (changed, "lang");
20173  if (changed_value == NULL
20174  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20175  {
20176  lang_64 = g_base64_encode ((guchar*) lang, strlen (lang));
20177 
20178  if (openvas_connection_sendf (&connection,
20179  "<modify_setting"
20180  " setting_id"
20181  "=\"6765549a-934e-11e3-b358-406186ea4fc5\">"
20182  "<value>%s</value>"
20183  "</modify_setting>",
20184  lang_64 ? lang_64 : "")
20185  == -1)
20186  {
20187  g_free (lang_64);
20188  openvas_connection_close (&connection);
20189  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20190  return gsad_message (credentials,
20191  "Internal error", __FUNCTION__, __LINE__,
20192  "An internal error occurred while saving settings. "
20193  "It is unclear whether all the settings were saved. "
20194  "Diagnostics: Failure to send command to manager daemon.",
20195  "/omp?cmd=get_my_settings", response_data);
20196  }
20197  g_free (lang_64);
20198 
20199  entity = NULL;
20200  xml_string_append (xml,
20201  "<save_setting id=\"%s\">",
20202  "6765549a-934e-11e3-b358-406186ea4fc5");
20203  if (read_entity_and_string_c (&connection, &entity, &xml))
20204  {
20205  g_string_free (xml, TRUE);
20206  openvas_connection_close (&connection);
20207  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20208  return gsad_message (credentials,
20209  "Internal error", __FUNCTION__, __LINE__,
20210  "An internal error occurred while saving settings. "
20211  "It is unclear whether all the settings were saved. "
20212  "Diagnostics: Failure to receive response from manager daemon.",
20213  "/omp?cmd=get_my_settings", response_data);
20214  }
20215  xml_string_append (xml, "</save_setting>");
20216  if (omp_success (entity))
20217  {
20218  gchar *language_code;
20219  set_language_code (&language_code, lang);
20220  if (language_code)
20221  {
20222  g_free (credentials->language);
20223  credentials->language = language_code;
20224  *language = g_strdup (lang);
20225  }
20226  else
20227  {
20228  g_free (credentials->language);
20229  credentials->language = accept_language_to_env_fmt (accept_language);
20230  *language = NULL;
20231  }
20232  }
20233  else
20234  {
20235  set_http_status_from_entity (entity, response_data);
20236  modify_failed = 1;
20237  }
20238  }
20239 
20240  /* Send default resources */
20241 
20242  defaults = params_values (params, "settings_default:");
20243  if (send_settings_filters (&connection, defaults, changed, xml,
20244  &modify_failed, response_data))
20245  {
20246  openvas_connection_close (&connection);
20247  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20248  return gsad_message (credentials,
20249  "Internal error", __FUNCTION__, __LINE__,
20250  "An internal error occurred while saving settings. "
20251  "It is unclear whether all the settings were saved. "
20252  "Diagnostics: Failure to send command to manager daemon.",
20253  "/omp?cmd=get_my_settings", response_data);
20254  }
20255 
20256  /* Send resources filters */
20257 
20258  filters = params_values (params, "settings_filter:");
20259  if (send_settings_filters (&connection, filters, changed, xml, &modify_failed,
20260  response_data))
20261  {
20262  openvas_connection_close (&connection);
20263  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20264  return gsad_message (credentials,
20265  "Internal error", __FUNCTION__, __LINE__,
20266  "An internal error occurred while saving settings. "
20267  "It is unclear whether all the settings were saved. "
20268  "Diagnostics: Failure to send command to manager daemon.",
20269  "/omp?cmd=get_my_settings", response_data);
20270  }
20271 
20272  /* Send Severity Class. */
20273 
20274  changed_value = params_value (changed, "severity_class");
20275  if (changed_value == NULL
20276  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20277  {
20278  text = params_value (params, "severity_class");
20279  text_64 = (text
20280  ? g_base64_encode ((guchar*) text, strlen (text))
20281  : g_strdup (""));
20282 
20283  if (openvas_connection_sendf (&connection,
20284  "<modify_setting"
20285  " setting_id"
20286  "=\"f16bb236-a32d-4cd5-a880-e0fcf2599f59\">"
20287  "<value>%s</value>"
20288  "</modify_setting>",
20289  text_64 ? text_64 : "")
20290  == -1)
20291  {
20292  g_free (text_64);
20293  openvas_connection_close (&connection);
20294  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20295  return gsad_message (credentials,
20296  "Internal error", __FUNCTION__, __LINE__,
20297  "An internal error occurred while saving settings. "
20298  "It is unclear whether all the settings were saved. "
20299  "Diagnostics: Failure to send command to manager daemon.",
20300  "/omp?cmd=get_my_settings", response_data);
20301  }
20302  g_free (text_64);
20303 
20304  entity = NULL;
20305  xml_string_append (xml,
20306  "<save_setting id=\"%s\">",
20307  "f16bb236-a32d-4cd5-a880-e0fcf2599f59");
20308  if (read_entity_and_string_c (&connection, &entity, &xml))
20309  {
20310  g_string_free (xml, TRUE);
20311  openvas_connection_close (&connection);
20312  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20313  return gsad_message (credentials,
20314  "Internal error", __FUNCTION__, __LINE__,
20315  "An internal error occurred while saving settings. "
20316  "It is unclear whether all the settings were saved. "
20317  "Diagnostics: Failure to receive response from manager daemon.",
20318  "/omp?cmd=get_my_settings", response_data);
20319  }
20320  xml_string_append (xml, "</save_setting>");
20321 
20322  status = entity_attribute (entity, "status");
20323  if (status && (strlen (status) > 0) && (status[0] == '2'))
20324  {
20325  g_free (credentials->severity);
20326  if ((text != NULL) && (strlen (text) > 0))
20327  {
20328  credentials->severity = g_strdup (text);
20329  *severity = g_strdup (text);
20330  }
20331  }
20332  else
20333  {
20334  set_http_status_from_entity (entity, response_data);
20335  modify_failed = 1;
20336  }
20337  }
20338 
20339  /* Send Dynamic Severity setting. */
20340 
20341  changed_value = params_value (changed, "dynamic_severity");
20342  if (changed_value == NULL
20343  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20344  {
20345  text = params_value (params, "dynamic_severity");
20346  text_64 = (text
20347  ? g_base64_encode ((guchar*) text, strlen (text))
20348  : g_strdup (""));
20349 
20350  if (openvas_connection_sendf (&connection,
20351  "<modify_setting"
20352  " setting_id"
20353  "=\"77ec2444-e7f2-4a80-a59b-f4237782d93f\">"
20354  "<value>%s</value>"
20355  "</modify_setting>",
20356  text_64 ? text_64 : "")
20357  == -1)
20358  {
20359  g_free (text_64);
20360  openvas_connection_close (&connection);
20361  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20362  return gsad_message (credentials,
20363  "Internal error", __FUNCTION__, __LINE__,
20364  "An internal error occurred while saving settings. "
20365  "It is unclear whether all the settings were saved. "
20366  "Diagnostics: Failure to send command to manager daemon.",
20367  "/omp?cmd=get_my_settings", response_data);
20368  }
20369  g_free (text_64);
20370 
20371  entity = NULL;
20372  xml_string_append (xml,
20373  "<save_setting id=\"%s\">",
20374  "77ec2444-e7f2-4a80-a59b-f4237782d93f");
20375  if (read_entity_and_string_c (&connection, &entity, &xml))
20376  {
20377  g_string_free (xml, TRUE);
20378  openvas_connection_close (&connection);
20379  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20380  return gsad_message (credentials,
20381  "Internal error", __FUNCTION__, __LINE__,
20382  "An internal error occurred while saving settings. "
20383  "It is unclear whether all the settings were saved. "
20384  "Diagnostics: Failure to receive response from manager daemon.",
20385  "/omp?cmd=get_my_settings", response_data);
20386  }
20387  xml_string_append (xml, "</save_setting>");
20388  if (! omp_success (entity))
20389  {
20390  set_http_status_from_entity (entity, response_data);
20391  modify_failed = 1;
20392  }
20393  }
20394 
20395  /* Send Default Severity setting. */
20396  changed_value = params_value (changed, "default_severity");
20397  if (changed_value == NULL
20398  || (strcmp (changed_value, "") && strcmp (changed_value, "0")))
20399  {
20400  text = params_value (params, "default_severity");
20401  text_64 = (text
20402  ? g_base64_encode ((guchar*) text, strlen (text))
20403  : g_strdup (""));
20404 
20405  if (openvas_connection_sendf (&connection,
20406  "<modify_setting"
20407  " setting_id"
20408  "=\"7eda49c5-096c-4bef-b1ab-d080d87300df\">"
20409  "<value>%s</value>"
20410  "</modify_setting>",
20411  text_64 ? text_64 : "")
20412  == -1)
20413  {
20414  g_free (text_64);
20415  openvas_connection_close (&connection);
20416  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20417  return gsad_message (credentials,
20418  "Internal error", __FUNCTION__, __LINE__,
20419  "An internal error occurred while saving settings. "
20420  "It is unclear whether all the settings were saved. "
20421  "Diagnostics: Failure to send command to manager daemon.",
20422  "/omp?cmd=get_my_settings", response_data);
20423  }
20424  g_free (text_64);
20425 
20426  entity = NULL;
20427  xml_string_append (xml,
20428  "<save_setting id=\"%s\">",
20429  "7eda49c5-096c-4bef-b1ab-d080d87300df");
20430  if (read_entity_and_string_c (&connection, &entity, &xml))
20431  {
20432  g_string_free (xml, TRUE);
20433  openvas_connection_close (&connection);
20434  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
20435  return gsad_message (credentials,
20436  "Internal error", __FUNCTION__, __LINE__,
20437  "An internal error occurred while saving settings. "
20438  "It is unclear whether all the settings were saved. "
20439  "Diagnostics: Failure to receive response from manager daemon.",
20440  "/omp?cmd=get_my_settings", response_data);
20441  }
20442  xml_string_append (xml, "</save_setting>");
20443  if (! omp_success (entity))
20444  {
20445  set_http_status_from_entity (entity, response_data);
20446  modify_failed = 1;
20447  }
20448  }
20449 
20450  openvas_connection_close (&connection);
20451  if (modify_failed)
20452  return edit_my_settings (credentials, params, g_string_free (xml, FALSE),
20453  response_data);
20454  else
20455  return get_my_settings (credentials, params, g_string_free (xml, FALSE),
20456  response_data);
20457 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
char * timezone
User's timezone.
Definition: gsad_base.h:72
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
void set_language_code(gchar **lang, const gchar *language)
Set language code of user.
Definition: gsad_base.c:191
gchar * accept_language_to_env_fmt(const char *accept_language)
Convert an Accept-Language string to the LANGUAGE env variable form.
Definition: xslt_i18n.c:769
char * username
Name of user.
Definition: gsad_base.h:69
#define params_t
Definition: gsad_base.h:61
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
char * severity
Severity class.
Definition: gsad_base.h:78
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279
char * language
Accept-Language browser header.
Definition: gsad_base.h:77
char * password
User's password.
Definition: gsad_base.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

char* save_note_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save note, get next page, XSL transform the result.

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

Definition at line 16237 of file gsad_omp.c.

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

16239 {
16240  gchar *response;
16241  entity_t entity;
16242  const char *no_redirect;
16243  const char *note_id, *text, *hosts, *port, *severity, *note_task_id;
16244  const char *note_result_id, *active, *days;
16245  char *ret;
16246 
16247  no_redirect = params_value (params, "no_redirect");
16248  note_id = params_value (params, "note_id");
16249 
16250  text = params_value (params, "text");
16251  if (text == NULL)
16252  params_given (params, "text") || (text = "");
16253 
16254  if (params_valid (params, "hosts"))
16255  hosts = params_value (params, "hosts");
16256  else if (strcmp (params_original_value (params, "hosts"), ""))
16257  hosts = NULL;
16258  else
16259  hosts = "";
16260 
16261  if (params_valid (params, "port"))
16262  port = params_value (params, "port");
16263  else if (strcmp (params_original_value (params, "port"), ""))
16264  port = NULL;
16265  else
16266  port = "";
16267 
16268  if (params_valid (params, "severity"))
16269  severity = params_value (params, "severity");
16270  else if (strcmp (params_original_value (params, "severity"), ""))
16271  severity = NULL;
16272  else
16273  severity = "";
16274 
16275  note_task_id = params_value (params, "note_task_id");
16276  note_result_id = params_value (params, "note_result_id");
16277 
16278  active = params_value (params, "active");
16279  days = params_value (params, "days");
16280 
16281  CHECK_PARAM_INVALID (note_task_id, "Save Note", "edit_note");
16282  CHECK_PARAM_INVALID (note_result_id, "Save Note", "edit_note");
16283  CHECK_PARAM_INVALID (active, "Save Note", "edit_note");
16284  CHECK_PARAM_INVALID (note_id, "Save Note", "edit_note");
16285  CHECK_PARAM_INVALID (text, "Save Note", "edit_note");
16286  CHECK_PARAM_INVALID (hosts, "Save Note", "edit_note");
16287  CHECK_PARAM_INVALID (port, "Save Note", "edit_note");
16288  CHECK_PARAM_INVALID (severity, "Save Note", "edit_note");
16289  CHECK_PARAM_INVALID (days, "Save Note", "edit_note");
16290 
16291  response = NULL;
16292  entity = NULL;
16293  switch (ompf (credentials,
16294  &response,
16295  &entity,
16296  response_data,
16297  "<modify_note note_id=\"%s\">"
16298  "<active>%s</active>"
16299  "<hosts>%s</hosts>"
16300  "<port>%s</port>"
16301  "<severity>%s</severity>"
16302  "<text>%s</text>"
16303  "<task id=\"%s\"/>"
16304  "<result id=\"%s\"/>"
16305  "</modify_note>",
16306  note_id,
16307  strcmp (active, "1")
16308  ? active
16309  : (days ? days : "-1"),
16310  hosts ? hosts : "",
16311  port ? port : "",
16312  severity ? severity : "",
16313  text ? text : "",
16314  note_task_id,
16315  note_result_id))
16316  {
16317  case 0:
16318  case -1:
16319  break;
16320  case 1:
16321  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16322  return gsad_message (credentials,
16323  "Internal error", __FUNCTION__, __LINE__,
16324  "An internal error occurred while saving a note. "
16325  "The note remains the same. "
16326  "Diagnostics: Failure to send command to manager daemon.",
16327  "/omp?cmd=get_notes", response_data);
16328  case 2:
16329  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16330  return gsad_message (credentials,
16331  "Internal error", __FUNCTION__, __LINE__,
16332  "An internal error occurred while saving a note. "
16333  "It is unclear whether the note has been saved or not. "
16334  "Diagnostics: Failure to receive response from manager daemon.",
16335  "/omp?cmd=get_notes", response_data);
16336  default:
16337  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
16338  return gsad_message (credentials,
16339  "Internal error", __FUNCTION__, __LINE__,
16340  "An internal error occurred while saving a note. "
16341  "It is unclear whether the note has been saved or not. "
16342  "Diagnostics: Internal Error.",
16343  "/omp?cmd=get_notes", response_data);
16344  }
16345 
16346  ret = response_from_entity (credentials, params, entity,
16347  (no_redirect && strcmp (no_redirect, "0")),
16348  NULL, "get_notes",
16349  NULL, "edit_note",
16350  "Save Note", response_data);
16351 
16352  free_entity (entity);
16353  g_free (response);
16354  return ret;
16355 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

char* save_override_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save override, get next page, XSL transform the result.

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

Definition at line 16982 of file gsad_omp.c.

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

16984 {
16985  gchar *response;
16986  entity_t entity;
16987  const char *no_redirect, *override_id, *text, *hosts, *port;
16988  const char *severity, *custom_severity, *new_severity;
16989  const char *override_task_id, *override_result_id, *active, *days;
16990  char *ret;
16991 
16992  no_redirect = params_value (params, "no_redirect");
16993  override_id = params_value (params, "override_id");
16994 
16995  text = params_value (params, "text");
16996  if (text == NULL)
16997  params_given (params, "text") || (text = "");
16998 
16999  if (params_valid (params, "hosts"))
17000  hosts = params_value (params, "hosts");
17001  else if (strcmp (params_original_value (params, "hosts"), ""))
17002  hosts = NULL;
17003  else
17004  hosts = "";
17005 
17006  if (params_valid (params, "port"))
17007  port = params_value (params, "port");
17008  else if (strcmp (params_original_value (params, "port"), ""))
17009  port = NULL;
17010  else
17011  port = "";
17012 
17013  if (params_valid (params, "severity"))
17014  severity = params_value (params, "severity");
17015  else if (strcmp (params_original_value (params, "severity"), ""))
17016  severity = NULL;
17017  else
17018  severity = "";
17019 
17020  custom_severity = params_value (params, "custom_severity");
17021  if (custom_severity && strcmp (custom_severity, "0") != 0)
17022  new_severity = params_value (params, "new_severity");
17023  else
17024  new_severity = params_value (params, "new_severity_from_list");
17025 
17026  override_task_id = params_value (params, "override_task_id");
17027  override_result_id = params_value (params, "override_result_id");
17028 
17029  active = params_value (params, "active");
17030  days = params_value (params, "days");
17031 
17032  CHECK_PARAM_INVALID (override_task_id, "Save Override", "edit_override");
17033  CHECK_PARAM_INVALID (override_result_id, "Save Override", "edit_override");
17034  CHECK_PARAM_INVALID (active, "Save Override", "edit_override");
17035  CHECK_PARAM_INVALID (override_id, "Save Override", "edit_override");
17036  CHECK_PARAM_INVALID (text, "Save Override", "edit_override");
17037  CHECK_PARAM_INVALID (hosts, "Save Override", "edit_override");
17038  CHECK_PARAM_INVALID (port, "Save Override", "edit_override");
17039  CHECK_PARAM_INVALID (severity, "Save Override", "edit_override");
17040  CHECK_PARAM_INVALID (new_severity, "Save Override", "edit_override");
17041  CHECK_PARAM_INVALID (days, "Save Override", "edit_override");
17042 
17043  response = NULL;
17044  entity = NULL;
17045  switch (ompf (credentials,
17046  &response,
17047  &entity,
17048  response_data,
17049  "<modify_override override_id=\"%s\">"
17050  "<active>%s</active>"
17051  "<hosts>%s</hosts>"
17052  "<port>%s</port>"
17053  "<severity>%s</severity>"
17054  "<new_severity>%s</new_severity>"
17055  "<text>%s</text>"
17056  "<task id=\"%s\"/>"
17057  "<result id=\"%s\"/>"
17058  "</modify_override>",
17059  override_id,
17060  strcmp (active, "1")
17061  ? active
17062  : (days ? days : "-1"),
17063  hosts ? hosts : "",
17064  port ? port : "",
17065  severity ? severity : "",
17066  new_severity,
17067  text ? text : "",
17068  override_task_id,
17069  override_result_id))
17070  {
17071  case 0:
17072  case -1:
17073  break;
17074  case 1:
17075  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17076  return gsad_message (credentials,
17077  "Internal error", __FUNCTION__, __LINE__,
17078  "An internal error occurred while saving a override. "
17079  "The override remains the same. "
17080  "Diagnostics: Failure to send command to manager daemon.",
17081  "/omp?cmd=get_overrides", response_data);
17082  case 2:
17083  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17084  return gsad_message (credentials,
17085  "Internal error", __FUNCTION__, __LINE__,
17086  "An internal error occurred while saving a override. "
17087  "It is unclear whether the override has been saved or not. "
17088  "Diagnostics: Failure to receive response from manager daemon.",
17089  "/omp?cmd=get_overrides", response_data);
17090  default:
17091  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17092  return gsad_message (credentials,
17093  "Internal error", __FUNCTION__, __LINE__,
17094  "An internal error occurred while saving a override. "
17095  "It is unclear whether the override has been saved or not. "
17096  "Diagnostics: Internal Error.",
17097  "/omp?cmd=get_overrides", response_data);
17098  }
17099 
17100  ret = response_from_entity (credentials, params, entity,
17101  (no_redirect && strcmp (no_redirect, "0")),
17102  NULL, "get_overrides",
17103  NULL, "edit_override",
17104  "Save Override", response_data);
17105 
17106  free_entity (entity);
17107  g_free (response);
17108  return ret;
17109 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
const char * params_original_value(params_t *params, const char *name)
Get original value of param, before validation.
Definition: gsad_base.c:716
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

char* save_permission_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a permission, get all permissions, XSL transform the result.

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

Definition at line 22740 of file gsad_omp.c.

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

22742 {
22743  gchar *html, *response;
22744  const char *no_redirect;
22745  const char *permission_id, *name, *comment, *resource_id, *resource_type;
22746  const char *subject_id, *subject_type;
22747  entity_t entity;
22748  int ret;
22749 
22750  no_redirect = params_value (params, "no_redirect");
22751  permission_id = params_value (params, "permission_id");
22752  name = params_value (params, "permission");
22753  comment = params_value (params, "comment");
22754  subject_type = params_value (params, "subject_type");
22755  resource_id = params_value (params, "id_or_empty");
22756  resource_type = params_value (params, "optional_resource_type");
22757 
22758  CHECK_PARAM_INVALID (permission_id, "Save Permission", "edit_permission");
22759  CHECK_PARAM_INVALID (name, "Save Permission", "edit_permission");
22760  CHECK_PARAM_INVALID (comment, "Save Permission", "edit_permission");
22761  CHECK_PARAM_INVALID (resource_id, "Save Permission", "edit_permission");
22762  CHECK_PARAM_INVALID (subject_type, "Save Permission", "edit_permission");
22763  if (params_given (params, "optional_resource_type"))
22764  CHECK_PARAM_INVALID (resource_type, "Save Permission", "edit_permission");
22765 
22766  if (strcmp (subject_type, "user") == 0)
22767  subject_id = params_value (params, "user_id");
22768  else if (strcmp (subject_type, "group") == 0)
22769  subject_id = params_value (params, "group_id");
22770  else if (strcmp (subject_type, "role") == 0)
22771  subject_id = params_value (params, "role_id");
22772  else
22773  subject_id = NULL;
22774  CHECK_PARAM_INVALID (subject_id, "Save Permission", "edit_permission");
22775 
22776  /* Modify the permission. */
22777 
22778  response = NULL;
22779  entity = NULL;
22780  ret = ompf (credentials,
22781  &response,
22782  &entity,
22783  response_data,
22784  "<modify_permission permission_id=\"%s\">"
22785  "<name>%s</name>"
22786  "<comment>%s</comment>"
22787  "<subject id=\"%s\">"
22788  "<type>%s</type>"
22789  "</subject>"
22790  "<resource id=\"%s\">"
22791  "<type>%s</type>"
22792  "</resource>"
22793  "</modify_permission>",
22794  permission_id,
22795  name,
22796  comment,
22797  subject_id,
22798  subject_type,
22799  (resource_id && strlen (resource_id)) ? resource_id : "0",
22800  resource_type ? resource_type : "");
22801  switch (ret)
22802  {
22803  case 0:
22804  case -1:
22805  break;
22806  case 1:
22807  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22808  return gsad_message (credentials,
22809  "Internal error", __FUNCTION__, __LINE__,
22810  "An internal error occurred while modifying a permission. "
22811  "The permission was not modified. "
22812  "Diagnostics: Failure to send command to manager daemon.",
22813  "/omp?cmd=get_permissions", response_data);
22814  case 2:
22815  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22816  return gsad_message (credentials,
22817  "Internal error", __FUNCTION__, __LINE__,
22818  "An internal error occurred while modifying a permission. "
22819  "It is unclear whether the permission has been modified or not. "
22820  "Diagnostics: Failure to receive response from manager daemon.",
22821  "/omp?cmd=get_permissions", response_data);
22822  default:
22823  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
22824  return gsad_message (credentials,
22825  "Internal error", __FUNCTION__, __LINE__,
22826  "An internal error occurred while modifying a permission. "
22827  "It is unclear whether the permission has been modified or not. "
22828  "Diagnostics: Internal Error.",
22829  "/omp?cmd=get_permissions", response_data);
22830  }
22831 
22832  html = response_from_entity (credentials, params, entity,
22833  (no_redirect && strcmp (no_redirect, "0")),
22834  NULL, "get_permissions",
22835  NULL, "edit_permission",
22836  "Save Permission", response_data);
22837  free_entity (entity);
22838  g_free (response);
22839  return html;
22840 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_port_list_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a port list, get all port list, XSL transform the result.

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

Definition at line 23251 of file gsad_omp.c.

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

23253 {
23254  int ret;
23255  gchar *html, *response;
23256  const char *no_redirect, *port_list_id, *name, *comment;
23257  entity_t entity;
23258 
23259  no_redirect = params_value (params, "no_redirect");
23260  port_list_id = params_value (params, "port_list_id");
23261  name = params_value (params, "name");
23262  comment = params_value (params, "comment");
23263 
23264  CHECK_PARAM_INVALID (port_list_id, "Save Port List", "edit_port_list");
23265  CHECK_PARAM_INVALID (name, "Save Port List", "edit_port_list");
23266  CHECK_PARAM_INVALID (comment, "Save Port List", "edit_port_list");
23267 
23268  /* Modify the Port List. */
23269 
23270  response = NULL;
23271  entity = NULL;
23272  ret = ompf (credentials,
23273  &response,
23274  &entity,
23275  response_data,
23276  "<modify_port_list port_list_id=\"%s\">"
23277  "<name>%s</name>"
23278  "<comment>%s</comment>"
23279  "</modify_port_list>",
23280  port_list_id,
23281  name,
23282  comment);
23283 
23284  switch (ret)
23285  {
23286  case 0:
23287  case -1:
23288  break;
23289  case 1:
23290  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23291  return gsad_message (credentials,
23292  "Internal error", __FUNCTION__, __LINE__,
23293  "An internal error occurred while saving a Port List. "
23294  "The Port List was not saved. "
23295  "Diagnostics: Failure to send command to manager daemon.",
23296  "/omp?cmd=get_port_lists", response_data);
23297  case 2:
23298  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23299  return gsad_message (credentials,
23300  "Internal error", __FUNCTION__, __LINE__,
23301  "An internal error occurred while saving a Port List. "
23302  "It is unclear whether the Port List has been saved or not. "
23303  "Diagnostics: Failure to receive response from manager daemon.",
23304  "/omp?cmd=get_port_lists", response_data);
23305  default:
23306  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23307  return gsad_message (credentials,
23308  "Internal error", __FUNCTION__, __LINE__,
23309  "An internal error occurred while saving a Port List. "
23310  "It is unclear whether the Port List has been saved or not. "
23311  "Diagnostics: Internal Error.",
23312  "/omp?cmd=get_port_lists", response_data);
23313  }
23314 
23315  html = response_from_entity (credentials, params, entity,
23316  (no_redirect && strcmp (no_redirect, "0")),
23317  NULL, "get_port_lists",
23318  NULL, "edit_port_list",
23319  "Save Port List", response_data);
23320  free_entity (entity);
23321  g_free (response);
23322  return html;
23323 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_report_format_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save report_format, get next page, XSL transform the result.

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

Definition at line 18697 of file gsad_omp.c.

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

18699 {
18700  int ret;
18701  gchar *html, *response;
18702  params_t *preferences, *id_list_params, *include_id_lists;
18703  const char *no_redirect, *report_format_id, *name, *summary, *enable;
18704  entity_t entity;
18705 
18706  no_redirect = params_value (params, "no_redirect");
18707  report_format_id = params_value (params, "report_format_id");
18708  name = params_value (params, "name");
18709  summary = params_value (params, "summary");
18710  enable = params_value (params, "enable");
18711 
18712  CHECK_PARAM_INVALID (report_format_id, "Save Report Format",
18713  "edit_report_format");
18714  CHECK_PARAM_INVALID (name, "Save Report Format", "edit_report_format");
18715  CHECK_PARAM_INVALID (summary, "Save Report Format", "edit_report_format");
18716  CHECK_PARAM_INVALID (enable, "Save Report Format", "edit_report_format");
18717 
18718  id_list_params = params_values (params, "id_list:");
18719  include_id_lists = params_values (params, "include_id_list:");
18720  if (include_id_lists)
18721  {
18722  GHashTable *id_lists;
18723  param_t *param;
18724  gchar *param_name, *pref_name, *value, *old_values, *new_values;
18725  params_iterator_t iter;
18726  GHashTableIter hash_table_iter;
18727 
18728  id_lists = g_hash_table_new_full (g_str_hash, g_str_equal,
18729  g_free, g_free);
18730 
18731  params_iterator_init (&iter, include_id_lists);
18732  while (params_iterator_next (&iter, &param_name, &param))
18733  {
18734  if (param->value == NULL)
18735  continue;
18736 
18737  g_hash_table_insert (id_lists, g_strdup (param_name), g_strdup (""));
18738  }
18739 
18740  params_iterator_init (&iter, id_list_params);
18741  while (params_iterator_next (&iter, &param_name, &param))
18742  {
18743  if (param->value == NULL)
18744  continue;
18745 
18746  gchar *colon_pos = strchr (param->value, ':');
18747 
18748  pref_name = g_strndup (param->value, colon_pos - param->value);
18749  value = g_strdup (colon_pos + 1);
18750 
18751  old_values = g_hash_table_lookup (id_lists, pref_name);
18752 
18753  if (old_values && strcmp (old_values, ""))
18754  {
18755  new_values = g_strdup_printf ("%s,%s", old_values, value);
18756  g_hash_table_insert (id_lists, pref_name, new_values);
18757  g_free (value);
18758  }
18759  else if (old_values)
18760  {
18761  g_hash_table_insert (id_lists, pref_name, value);
18762  }
18763  }
18764 
18765  g_hash_table_iter_init (&hash_table_iter, id_lists);
18766  while (g_hash_table_iter_next (&hash_table_iter,
18767  (void**)&pref_name, (void**)&value))
18768  {
18769  gchar *value_64;
18770 
18771  value_64 = strlen (value)
18772  ? g_base64_encode ((guchar *) value, strlen (value))
18773  : g_strdup ("");
18774 
18775  response = NULL;
18776  entity = NULL;
18777  ret = ompf (credentials,
18778  &response,
18779  &entity,
18780  response_data,
18781  "<modify_report_format"
18782  " report_format_id=\"%s\">"
18783  "<param>"
18784  "<name>%s</name>"
18785  "<value>%s</value>"
18786  "</param>"
18787  "</modify_report_format>",
18788  report_format_id,
18789  pref_name,
18790  value_64);
18791  g_free (value_64);
18792  switch (ret)
18793  {
18794  case 0:
18795  break;
18796  case 1:
18797  response_data->http_status_code
18798  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18799  return gsad_message (credentials,
18800  "Internal error", __FUNCTION__, __LINE__,
18801  "An internal error occurred while saving a Report Format. "
18802  "The Report Format was not saved. "
18803  "Diagnostics: Failure to send command to manager daemon.",
18804  "/omp?cmd=get_report_formats",
18805  response_data);
18806  case 2:
18807  response_data->http_status_code
18808  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18809  return gsad_message (credentials,
18810  "Internal error", __FUNCTION__, __LINE__,
18811  "An internal error occurred while saving a Report Format. "
18812  "It is unclear whether the Report Format has been saved or not. "
18813  "Diagnostics: Failure to receive response from manager daemon.",
18814  "/omp?cmd=get_report_formats",
18815  response_data);
18816  case -1:
18817  default:
18818  response_data->http_status_code
18819  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18820  return gsad_message (credentials,
18821  "Internal error", __FUNCTION__, __LINE__,
18822  "An internal error occurred while saving a Report Format. "
18823  "It is unclear whether the Report Format has been saved or not. "
18824  "Diagnostics: Internal Error.",
18825  "/omp?cmd=get_report_formats",
18826  response_data);
18827  }
18828 
18829  /* TODO Check if succeeded. response_from_entity_if_failed? */
18830  }
18831  }
18832 
18833  /* Modify the Report Format. */
18834 
18835  preferences = params_values (params, "preference:");
18836  if (preferences)
18837  {
18838  param_t *param;
18839  gchar *param_name;
18840  params_iterator_t iter;
18841 
18842  /* The naming is a bit subtle here, because the HTTP request
18843  * parameters are called "param"s and so are the OMP report format
18844  * parameters. */
18845 
18846  params_iterator_init (&iter, preferences);
18847  while (params_iterator_next (&iter, &param_name, &param))
18848  {
18849  int type_start, type_end, count;
18850  /* LDAPsearch[entry]:Timeout value */
18851  count = sscanf (param_name,
18852  "%*[^[][%n%*[^]]%n]:",
18853  &type_start,
18854  &type_end);
18855  if (count == 0 && type_start > 0 && type_end > 0)
18856  {
18857  gchar *value;
18858 
18859  value = param->value_size
18860  ? g_base64_encode ((guchar *) param->value,
18861  param->value_size)
18862  : g_strdup ("");
18863 
18864  response = NULL;
18865  entity = NULL;
18866  ret = ompf (credentials,
18867  &response,
18868  &entity,
18869  response_data,
18870  "<modify_report_format"
18871  " report_format_id=\"%s\">"
18872  "<param>"
18873  "<name>%s</name>"
18874  "<value>%s</value>"
18875  "</param>"
18876  "</modify_report_format>",
18877  report_format_id,
18878  param_name + type_end + 2,
18879  value);
18880  g_free (value);
18881  switch (ret)
18882  {
18883  case 0:
18884  break;
18885  case 1:
18886  response_data->http_status_code
18887  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18888  return gsad_message (credentials,
18889  "Internal error", __FUNCTION__, __LINE__,
18890  "An internal error occurred while saving a Report Format. "
18891  "The Report Format was not saved. "
18892  "Diagnostics: Failure to send command to manager daemon.",
18893  "/omp?cmd=get_report_formats",
18894  response_data);
18895  case 2:
18896  response_data->http_status_code
18897  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18898  return gsad_message (credentials,
18899  "Internal error", __FUNCTION__, __LINE__,
18900  "An internal error occurred while saving a Report Format. "
18901  "It is unclear whether the Report Format has been saved or not. "
18902  "Diagnostics: Failure to receive response from manager daemon.",
18903  "/omp?cmd=get_report_formats",
18904  response_data);
18905  case -1:
18906  default:
18907  response_data->http_status_code
18908  = MHD_HTTP_INTERNAL_SERVER_ERROR;
18909  return gsad_message (credentials,
18910  "Internal error", __FUNCTION__, __LINE__,
18911  "An internal error occurred while saving a Report Format. "
18912  "It is unclear whether the Report Format has been saved or not. "
18913  "Diagnostics: Internal Error.",
18914  "/omp?cmd=get_report_formats",
18915  response_data);
18916  }
18917 
18918  /* TODO Check if succeeded. response_from_entity_if_failed? */
18919  }
18920  }
18921  }
18922 
18923  response = NULL;
18924  entity = NULL;
18925  ret = ompf (credentials,
18926  &response,
18927  &entity,
18928  response_data,
18929  "<modify_report_format"
18930  " report_format_id=\"%s\">"
18931  "<name>%s</name>"
18932  "<summary>%s</summary>"
18933  "<active>%s</active>"
18934  "</modify_report_format>",
18935  report_format_id,
18936  name,
18937  summary,
18938  enable);
18939 
18940  switch (ret)
18941  {
18942  case 0:
18943  break;
18944  case -1:
18945  return response;
18946  case 1:
18947  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18948  return gsad_message (credentials,
18949  "Internal error", __FUNCTION__, __LINE__,
18950  "An internal error occurred while saving a Report Format. "
18951  "The Report Format was not saved. "
18952  "Diagnostics: Failure to send command to manager daemon.",
18953  "/omp?cmd=get_report_formats", response_data);
18954  case 2:
18955  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18956  return gsad_message (credentials,
18957  "Internal error", __FUNCTION__, __LINE__,
18958  "An internal error occurred while saving a Report Format. "
18959  "It is unclear whether the Report Format has been saved or not. "
18960  "Diagnostics: Failure to receive response from manager daemon.",
18961  "/omp?cmd=get_report_formats", response_data);
18962  default:
18963  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
18964  return gsad_message (credentials,
18965  "Internal error", __FUNCTION__, __LINE__,
18966  "An internal error occurred while saving a Report Format. "
18967  "It is unclear whether the Report Format has been saved or not. "
18968  "Diagnostics: Internal Error.",
18969  "/omp?cmd=get_report_formats", response_data);
18970  }
18971 
18972  html = response_from_entity (credentials, params, entity,
18973  (no_redirect && strcmp (no_redirect, "0")),
18974  NULL, "get_report_formats",
18975  NULL, "edit_report_format",
18976  "Save Report Format", response_data);
18977  free_entity (entity);
18978  g_free (response);
18979  return html;
18980 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
int value_size
Definition: gsad_base.h:152
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185

Here is the call graph for this function:

char* save_role_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a role, return the next page.

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

Definition at line 23861 of file gsad_omp.c.

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

23863 {
23864  int ret;
23865  gchar *html, *response;
23866  const char *no_redirect, *role_id, *name, *comment, *users;
23867  entity_t entity;
23868 
23869  no_redirect = params_value (params, "no_redirect");
23870  role_id = params_value (params, "role_id");
23871  name = params_value (params, "name");
23872  comment = params_value (params, "comment");
23873  users = params_value (params, "users");
23874 
23875  CHECK_PARAM_INVALID (role_id, "Save Role", "edit_role");
23876  CHECK_PARAM_INVALID (name, "Save Role", "edit_role");
23877  CHECK_PARAM_INVALID (comment, "Save Role", "edit_role");
23878  CHECK_PARAM_INVALID (users, "Save Role", "edit_role");
23879 
23880  /* Modify the Role. */
23881 
23882  response = NULL;
23883  entity = NULL;
23884  ret = ompf (credentials,
23885  &response,
23886  &entity,
23887  response_data,
23888  "<modify_role role_id=\"%s\">"
23889  "<name>%s</name>"
23890  "<comment>%s</comment>"
23891  "<users>%s</users>"
23892  "</modify_role>",
23893  role_id,
23894  name,
23895  comment,
23896  users);
23897 
23898  switch (ret)
23899  {
23900  case 0:
23901  case -1:
23902  break;
23903  case 1:
23904  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23905  return gsad_message (credentials,
23906  "Internal error", __FUNCTION__, __LINE__,
23907  "An internal error occurred while saving a role. "
23908  "The role was not saved. "
23909  "Diagnostics: Failure to send command to manager daemon.",
23910  "/omp?cmd=get_roles", response_data);
23911  case 2:
23912  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23913  return gsad_message (credentials,
23914  "Internal error", __FUNCTION__, __LINE__,
23915  "An internal error occurred while saving a role. "
23916  "It is unclear whether the role has been saved or not. "
23917  "Diagnostics: Failure to receive response from manager daemon.",
23918  "/omp?cmd=get_roles", response_data);
23919  default:
23920  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
23921  return gsad_message (credentials,
23922  "Internal error", __FUNCTION__, __LINE__,
23923  "An internal error occurred while saving a role. "
23924  "It is unclear whether the role has been saved or not. "
23925  "Diagnostics: Internal Error.",
23926  "/omp?cmd=get_roles", response_data);
23927  }
23928 
23929  html = response_from_entity (credentials, params, entity,
23930  (no_redirect && strcmp (no_redirect, "0")),
23931  NULL, "get_roles",
23932  NULL, "edit_role",
23933  "Save Role", response_data);
23934  free_entity (entity);
23935  g_free (response);
23936  return html;
23937 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
GPtrArray * users
User session data.
Definition: gsad.c:309
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save scanner, get next page, XSL transform the result.

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

Definition at line 17666 of file gsad_omp.c.

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

17668 {
17669  gchar *response = NULL;
17670  entity_t entity = NULL;
17671  const char *no_redirect;
17672  const char *scanner_id, *name, *comment, *port, *host, *type, *ca_pub;
17673  const char *credential_id, *which_cert;
17674  char *html;
17675  int ret, in_use;
17676 
17677  no_redirect = params_value (params, "no_redirect");
17678  scanner_id = params_value (params, "scanner_id");
17679  name = params_value (params, "name");
17680  comment = params_value (params, "comment");
17681  host = params_value (params, "scanner_host");
17682  port = params_value (params, "port");
17683  type = params_value (params, "scanner_type");
17684  which_cert = params_value (params, "which_cert");
17685  ca_pub = params_value (params, "ca_pub");
17686  credential_id = params_value (params, "credential_id");
17687  CHECK_PARAM_INVALID (scanner_id, "Edit Scanner", "edit_scanner");
17688  CHECK_PARAM_INVALID (name, "Edit Scanner", "edit_scanner");
17689  if (params_given (params, "scanner_host") == 0)
17690  in_use = 1;
17691  else
17692  {
17693  in_use = 0;
17694  CHECK_PARAM_INVALID (host, "Edit Scanner", "edit_scanner");
17695  CHECK_PARAM_INVALID (port, "Edit Scanner", "edit_scanner");
17696  CHECK_PARAM_INVALID (type, "Edit Scanner", "edit_scanner");
17697  }
17698  CHECK_PARAM_INVALID (ca_pub, "Edit Scanner", "edit_scanner");
17699  CHECK_PARAM_INVALID (credential_id, "Edit Scanner", "edit_scanner");
17700  CHECK_PARAM_INVALID (which_cert, "Edit Scanner", "edit_scanner");
17701 
17702  if (strcmp (which_cert, "new") == 0 || strcmp (which_cert, "default") == 0)
17703  {
17704  if (ca_pub == NULL)
17705  ca_pub = "";
17706  if (in_use)
17707  ret = ompf (credentials, &response, &entity, response_data,
17708  "<modify_scanner scanner_id=\"%s\">"
17709  "<name>%s</name>"
17710  "<comment>%s</comment>"
17711  "<ca_pub>%s</ca_pub>"
17712  "<credential id=\"%s\"/>"
17713  "</modify_scanner>",
17714  scanner_id, name, comment ?: "",
17715  strcmp (which_cert, "new") == 0 ? ca_pub : "",
17716  credential_id);
17717  else
17718  ret = ompf (credentials, &response, &entity, response_data,
17719  "<modify_scanner scanner_id=\"%s\">"
17720  "<name>%s</name>"
17721  "<comment>%s</comment>"
17722  "<host>%s</host>"
17723  "<port>%s</port>"
17724  "<type>%s</type>"
17725  "<ca_pub>%s</ca_pub>"
17726  "<credential id=\"%s\"/>"
17727  "</modify_scanner>",
17728  scanner_id, name, comment ?: "", host, port, type,
17729  strcmp (which_cert, "new") == 0 ? ca_pub : "",
17730  credential_id);
17731  }
17732  else
17733  {
17734  /* Using existing CA cert. */
17735  if (in_use)
17736  ret = ompf (credentials, &response, &entity, response_data,
17737  "<modify_scanner scanner_id=\"%s\">"
17738  "<name>%s</name>"
17739  "<comment>%s</comment>"
17740  "<credential id=\"%s\"/>"
17741  "</modify_scanner>",
17742  scanner_id, name, comment ?: "", credential_id);
17743  else
17744  ret = ompf (credentials, &response, &entity, response_data,
17745  "<modify_scanner scanner_id=\"%s\">"
17746  "<name>%s</name>"
17747  "<comment>%s</comment>"
17748  "<host>%s</host>"
17749  "<port>%s</port>"
17750  "<type>%s</type>"
17751  "<credential id=\"%s\"/>"
17752  "</modify_scanner>",
17753  scanner_id, name, comment ?: "", host, port, type,
17754  credential_id);
17755  }
17756 
17757  switch (ret)
17758  {
17759  case 0:
17760  case -1:
17761  break;
17762  case 1:
17763  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17764  return gsad_message
17765  (credentials, "Internal error", __FUNCTION__, __LINE__,
17766  "An internal error occurred while saving a scanner. "
17767  "The scanner remains the same. "
17768  "Diagnostics: Failure to send command to manager daemon.",
17769  "/omp?cmd=get_scanners", response_data);
17770  case 2:
17771  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17772  return gsad_message
17773  (credentials, "Internal error", __FUNCTION__, __LINE__,
17774  "An internal error occurred while saving a scanner. "
17775  "It is unclear whether the scanner has been saved or not. "
17776  "Diagnostics: Failure to receive response from manager daemon.",
17777  "/omp?cmd=get_scanners", response_data);
17778  default:
17779  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17780  return gsad_message
17781  (credentials, "Internal error", __FUNCTION__, __LINE__,
17782  "An internal error occurred while saving a scanner. "
17783  "It is unclear whether the scanner has been saved or not. "
17784  "Diagnostics: Internal Error.",
17785  "/omp?cmd=get_scanners", response_data);
17786  }
17787 
17788  html = response_from_entity (credentials, params, entity,
17789  (no_redirect && strcmp (no_redirect, "0")),
17790  NULL, "get_scanners",
17791  NULL, "edit_scanner",
17792  "Save Scanner", response_data);
17793 
17794  free_entity (entity);
17795  g_free (response);
17796  return html;
17797 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_schedule_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save schedule, get next page, XSL transform the result.

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

Definition at line 24753 of file gsad_omp.c.

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

24755 {
24756  gchar *response;
24757  entity_t entity;
24758  const char *no_redirect, *schedule_id, *name, *comment;
24759  const char *hour, *minute, *day_of_month, *month, *year, *timezone;
24760  const char *period, *period_unit, *duration, *duration_unit;
24761  char *ret;
24762 
24763  no_redirect = params_value (params, "no_redirect");
24764  schedule_id = params_value (params, "schedule_id");
24765  name = params_value (params, "name");
24766  comment = params_value (params, "comment");
24767  hour = params_value (params, "hour");
24768  minute = params_value (params, "minute");
24769  day_of_month = params_value (params, "day_of_month");
24770  duration = params_value (params, "duration");
24771  duration_unit = params_value (params, "duration_unit");
24772  month = params_value (params, "month");
24773  period = params_value (params, "period");
24774  period_unit = params_value (params, "period_unit");
24775  year = params_value (params, "year");
24776  timezone = params_value (params, "timezone");
24777 
24778  CHECK_PARAM_INVALID (schedule_id, "Save Schedule", "edit_schedule");
24779  CHECK_PARAM_INVALID (name, "Save Schedule", "edit_schedule");
24780  CHECK_PARAM_INVALID (comment, "Save Schedule", "edit_schedule");
24781  CHECK_PARAM_INVALID (hour, "Save Schedule", "edit_schedule");
24782  CHECK_PARAM_INVALID (minute, "Save Schedule", "edit_schedule");
24783  CHECK_PARAM_INVALID (day_of_month, "Save Schedule", "edit_schedule");
24784  CHECK_PARAM_INVALID (duration, "Save Schedule", "edit_schedule");
24785  CHECK_PARAM_INVALID (duration_unit, "Save Schedule", "edit_schedule");
24786  CHECK_PARAM_INVALID (month, "Save Schedule", "edit_schedule");
24787  CHECK_PARAM_INVALID (period, "Save Schedule", "edit_schedule");
24788  CHECK_PARAM_INVALID (period_unit, "Save Schedule", "edit_schedule");
24789  CHECK_PARAM_INVALID (year, "Save Schedule", "edit_schedule");
24790  CHECK_PARAM_INVALID (timezone, "Save Schedule", "edit_schedule");
24791 
24792  response = NULL;
24793  entity = NULL;
24794  switch (ompf (credentials,
24795  &response,
24796  &entity,
24797  response_data,
24798  "<modify_schedule schedule_id=\"%s\">"
24799  "<name>%s</name>"
24800  "<comment>%s</comment>"
24801  "<first_time>"
24802  "<hour>%s</hour>"
24803  "<minute>%s</minute>"
24804  "<day_of_month>%s</day_of_month>"
24805  "<month>%s</month>"
24806  "<year>%s</year>"
24807  "</first_time>"
24808  "<timezone>%s</timezone>"
24809  "<period>"
24810  "<unit>%s</unit>"
24811  "%s"
24812  "</period>"
24813  "<duration>"
24814  "<unit>%s</unit>"
24815  "%s"
24816  "</duration>"
24817  "</modify_schedule>",
24818  schedule_id,
24819  name ? name : "",
24820  comment ? comment : "",
24821  hour,
24822  minute,
24823  day_of_month,
24824  month,
24825  year,
24826  timezone,
24827  (strcmp (period_unit, "")
24828  ? period_unit
24829  : "second"),
24830  period,
24831  (strcmp (duration_unit, "")
24832  ? duration_unit
24833  : "second"),
24834  duration))
24835  {
24836  case 0:
24837  case -1:
24838  break;
24839  case 1:
24840  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24841  return gsad_message (credentials,
24842  "Internal error", __FUNCTION__, __LINE__,
24843  "An internal error occurred while saving a schedule. "
24844  "The schedule remains the same. "
24845  "Diagnostics: Failure to send command to manager daemon.",
24846  "/omp?cmd=get_schedules", response_data);
24847  case 2:
24848  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24849  return gsad_message (credentials,
24850  "Internal error", __FUNCTION__, __LINE__,
24851  "An internal error occurred while saving a schedule. "
24852  "It is unclear whether the schedule has been saved or not. "
24853  "Diagnostics: Failure to receive response from manager daemon.",
24854  "/omp?cmd=get_schedules", response_data);
24855  default:
24856  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
24857  return gsad_message (credentials,
24858  "Internal error", __FUNCTION__, __LINE__,
24859  "An internal error occurred while saving a schedule. "
24860  "It is unclear whether the schedule has been saved or not. "
24861  "Diagnostics: Internal Error.",
24862  "/omp?cmd=get_schedules", response_data);
24863  }
24864 
24865  ret = response_from_entity (credentials, params, entity,
24866  (no_redirect && strcmp (no_redirect, "0")),
24867  NULL, "get_schedules",
24868  NULL, "edit_schedule",
24869  "Save Schedule", response_data);
24870  free_entity (entity);
24871  g_free (response);
24872  return ret;
24873 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_slave_omp ( credentials_t ,
params_t ,
cmd_response_data_t  
)
char* save_tag_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a tag, get all tags, XSL transform the result.

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

Definition at line 10602 of file gsad_omp.c.

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

10604 {
10605  gchar *response;
10606  const char *name, *comment, *value, *resource_type, *resource_id, *active;
10607  const char *tag_id, *no_redirect;
10608  entity_t entity;
10609  char* ret;
10610 
10611  no_redirect = params_value (params, "no_redirect");
10612  tag_id = params_value (params, "tag_id");
10613  name = params_value (params, "tag_name");
10614  comment = params_value (params, "comment");
10615  value = params_value (params, "tag_value");
10616  resource_type = params_value (params, "resource_type");
10617  resource_id = params_value (params, "resource_id");
10618  active = params_value (params, "active");
10619 
10620  CHECK_PARAM_INVALID (tag_id, "Save Tag", "edit_tag")
10621  CHECK_PARAM_INVALID (name, "Save Tag", "edit_tag")
10622  CHECK_PARAM_INVALID (comment, "Save Tag", "edit_tag")
10623  CHECK_PARAM_INVALID (value, "Save Tag", "edit_tag")
10624  CHECK_PARAM_INVALID (resource_type, "Save Tag", "edit_tag")
10625  CHECK_PARAM_INVALID (resource_id, "Save Tag", "edit_tag")
10626  CHECK_PARAM_INVALID (active, "Save Tag", "edit_tag")
10627 
10628  response = NULL;
10629  entity = NULL;
10630  switch (ompf (credentials,
10631  &response,
10632  &entity,
10633  response_data,
10634  "<modify_tag tag_id=\"%s\">"
10635  "<name>%s</name>"
10636  "<comment>%s</comment>"
10637  "<value>%s</value>"
10638  "<resource id=\"%s\">"
10639  "<type>%s</type>"
10640  "</resource>"
10641  "<active>%s</active>"
10642  "</modify_tag>",
10643  tag_id,
10644  name,
10645  comment,
10646  value,
10647  resource_id,
10648  resource_type,
10649  active))
10650  {
10651  case 0:
10652  case -1:
10653  break;
10654  case 1:
10655  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10656  return gsad_message (credentials,
10657  "Internal error", __FUNCTION__, __LINE__,
10658  "An internal error occurred while saving a tag. "
10659  "The tag remains the same. "
10660  "Diagnostics: Failure to send command to "
10661  "manager daemon.",
10662  "/omp?cmd=get_targets", response_data);
10663  case 2:
10664  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10665  return gsad_message (credentials,
10666  "Internal error", __FUNCTION__, __LINE__,
10667  "An internal error occurred while saving a tag. "
10668  "It is unclear whether the tag has been saved "
10669  "or not. "
10670  "Diagnostics: Failure to receive response from "
10671  "manager daemon.",
10672  "/omp?cmd=get_tags", response_data);
10673  default:
10674  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10675  return gsad_message (credentials,
10676  "Internal error", __FUNCTION__, __LINE__,
10677  "An internal error occurred while saving a tag. "
10678  "It is unclear whether the tag has been saved "
10679  "or not. "
10680  "Diagnostics: Internal Error.",
10681  "/omp?cmd=get_tags", response_data);
10682  }
10683 
10684  ret = response_from_entity (credentials, params, entity,
10685  (no_redirect && strcmp (no_redirect, "0")),
10686  NULL, "get_tags",
10687  NULL, "edit_tag",
10688  "Save Tag", response_data);
10689 
10690  free_entity (entity);
10691  g_free (response);
10692  return ret;
10693 
10694 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
char * edit_tag(credentials_t *credentials, params_t *params, const char *extra_xml, cmd_response_data_t *response_data)
Setup edit_tag XML, XSL transform the result.
Definition: gsad_omp.c:10489
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* save_target_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Modify a target, get all targets, XSL transform the result.

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

Definition at line 11197 of file gsad_omp.c.

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

11199 {
11200  openvas_connection_t connection;
11201  gchar *html, *response;
11202  const char *no_redirect, *name, *hosts, *exclude_hosts, *comment;
11203  const char *target_ssh_credential, *port, *target_smb_credential;
11204  const char *target_esxi_credential, *target_snmp_credential, *target_source;
11205  const char *target_id, *port_list_id, *reverse_lookup_only;
11206  const char *reverse_lookup_unify, *alive_tests, *in_use;
11207  GString *command;
11208 
11209  no_redirect = params_value (params, "no_redirect");
11210  alive_tests = params_value (params, "alive_tests");
11211  name = params_value (params, "name");
11212  comment = params_value (params, "comment");
11213  in_use = params_value (params, "in_use");
11214  target_id = params_value (params, "target_id");
11215 
11216  CHECK_PARAM_INVALID (name, "Save Target", "edit_target");
11217  CHECK_PARAM_INVALID (target_id, "Save Target", "edit_target");
11218  CHECK_PARAM_INVALID (comment, "Save Target", "edit_target");
11219  CHECK_PARAM_INVALID (alive_tests, "Save Target", "edit_target");
11220  CHECK_PARAM_INVALID (in_use, "Save Target", "edit_target");
11221 
11222  if (strcmp (in_use, "0"))
11223  {
11224  entity_t entity;
11225  int ret;
11226 
11227  /* Target is in use. Modify fewer fields. */
11228 
11229  command = g_string_new ("");
11230  xml_string_append (command,
11231  "<modify_target target_id=\"%s\">"
11232  "<name>%s</name>"
11233  "<comment>%s</comment>"
11234  "<alive_tests>%s</alive_tests>"
11235  "</modify_target>",
11236  target_id,
11237  name ? name : "",
11238  comment ? comment : "",
11239  alive_tests);
11240 
11241  response = NULL;
11242  entity = NULL;
11243  ret = omp (credentials, &response, &entity, response_data, command->str);
11244  g_string_free (command, TRUE);
11245  switch (ret)
11246  {
11247  case 0:
11248  case -1:
11249  break;
11250  case 1:
11251  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11252  return gsad_message (credentials,
11253  "Internal error", __FUNCTION__, __LINE__,
11254  "An internal error occurred while saving a target. "
11255  "The target remains the same. "
11256  "Diagnostics: Failure to send command to manager daemon.",
11257  "/omp?cmd=get_targets", response_data);
11258  case 2:
11259  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11260  return gsad_message (credentials,
11261  "Internal error", __FUNCTION__, __LINE__,
11262  "An internal error occurred while saving a target. "
11263  "It is unclear whether the target has been saved or not. "
11264  "Diagnostics: Failure to receive response from manager daemon.",
11265  "/omp?cmd=get_targets", response_data);
11266  default:
11267  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11268  return gsad_message (credentials,
11269  "Internal error", __FUNCTION__, __LINE__,
11270  "An internal error occurred while saving a target. "
11271  "It is unclear whether the target has been saved or not. "
11272  "Diagnostics: Internal Error.",
11273  "/omp?cmd=get_targets", response_data);
11274  }
11275 
11276  html = response_from_entity (credentials, params, entity,
11277  (no_redirect && strcmp (no_redirect, "0")),
11278  NULL, "get_targets",
11279  NULL, "edit_target",
11280  "Save Target", response_data);
11281 
11282  free_entity (entity);
11283  g_free (response);
11284  return html;
11285  }
11286 
11287  hosts = params_value (params, "hosts");
11288  exclude_hosts = params_value (params, "exclude_hosts");
11289  reverse_lookup_only = params_value (params, "reverse_lookup_only");
11290  reverse_lookup_unify = params_value (params, "reverse_lookup_unify");
11291  target_source = params_value (params, "target_source");
11292  port_list_id = params_value (params, "port_list_id");
11293  target_ssh_credential = params_value (params, "ssh_credential_id");
11294  port = params_value (params, "port");
11295  target_smb_credential = params_value (params, "smb_credential_id");
11296  target_esxi_credential = params_value (params, "esxi_credential_id");
11297  target_snmp_credential = params_value (params, "snmp_credential_id");
11298 
11299  CHECK_PARAM_INVALID (target_source, "Save Target", "edit_target");
11300  CHECK_PARAM_INVALID (port_list_id, "Save Target", "edit_target");
11301  CHECK_PARAM_INVALID (target_ssh_credential, "Save Target", "edit_target");
11302  CHECK_PARAM_INVALID (target_smb_credential, "Save Target", "edit_target");
11303  CHECK_PARAM_INVALID (target_esxi_credential, "Save Target", "edit_target");
11304  CHECK_PARAM_INVALID (target_snmp_credential, "Save Target", "edit_target");
11305 
11306  if (strcmp (target_ssh_credential, "--")
11307  && strcmp (target_ssh_credential, "0"))
11308  CHECK_PARAM_INVALID (port, "Save Target", "edit_target");
11309 
11310  switch (manager_connect (credentials, &connection, &html,
11311  response_data))
11312  {
11313  case 0:
11314  break;
11315  case -1:
11316  if (html)
11317  return html;
11318  /* Fall through. */
11319  default:
11320  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11321  return gsad_message (credentials,
11322  "Internal error", __FUNCTION__, __LINE__,
11323  "An internal error occurred while modifying a target. "
11324  "The target was not modified. "
11325  "Diagnostics: Failure to connect to manager daemon.",
11326  "/omp?cmd=get_targets", response_data);
11327  }
11328 
11329  if (hosts == NULL && strcmp (target_source, "manual") == 0)
11330  {
11331  openvas_connection_close (&connection);
11332  return new_target (credentials, params,
11333  GSAD_MESSAGE_INVALID_PARAM ("Modify Target"),
11334  response_data);
11335  }
11336  if (strcmp (target_source, "import") == 0 && name == NULL)
11337  {
11338  gchar *msg;
11339  openvas_connection_close (&connection);
11340  msg = g_strdup_printf (GSAD_MESSAGE_INVALID,
11341  "Given target_source was invalid",
11342  "Modify Target");
11343  html = new_target (credentials, params, msg, response_data);
11344  g_free (msg);
11345  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11346  return html;
11347  }
11348 
11349  {
11350  int ret;
11351  gchar *ssh_credentials_element, *smb_credentials_element;
11352  gchar *esxi_credentials_element, *snmp_credentials_element;
11353  gchar* comment_element;
11354  entity_t entity;
11355 
11356  if (comment)
11357  comment_element = g_strdup_printf ("<comment>%s</comment>", comment);
11358  else
11359  comment_element = g_strdup ("");
11360 
11361  if (strcmp (target_ssh_credential, "--") == 0)
11362  ssh_credentials_element = g_strdup ("");
11363  else
11364  ssh_credentials_element =
11365  g_strdup_printf ("<ssh_credential id=\"%s\">"
11366  "<port>%s</port>"
11367  "</ssh_credential>",
11368  target_ssh_credential,
11369  port);
11370 
11371  if (strcmp (target_smb_credential, "--") == 0)
11372  smb_credentials_element = g_strdup ("");
11373  else
11374  smb_credentials_element =
11375  g_strdup_printf ("<smb_credential id=\"%s\"/>",
11376  target_smb_credential);
11377 
11378  if (strcmp (target_esxi_credential, "--") == 0)
11379  esxi_credentials_element = g_strdup ("");
11380  else
11381  esxi_credentials_element =
11382  g_strdup_printf ("<esxi_credential id=\"%s\"/>",
11383  target_esxi_credential);
11384 
11385  if (strcmp (target_snmp_credential, "--") == 0)
11386  snmp_credentials_element = g_strdup ("");
11387  else
11388  snmp_credentials_element =
11389  g_strdup_printf ("<snmp_credential id=\"%s\"/>",
11390  target_snmp_credential);
11391 
11392  command = g_string_new ("");
11393  xml_string_append (command,
11394  "<modify_target target_id=\"%s\">"
11395  "<name>%s</name>"
11396  "<hosts>%s</hosts>"
11397  "<exclude_hosts>%s</exclude_hosts>"
11398  "<reverse_lookup_only>%s</reverse_lookup_only>"
11399  "<reverse_lookup_unify>%s</reverse_lookup_unify>"
11400  "<port_list id=\"%s\"/>"
11401  "<alive_tests>%s</alive_tests>",
11402  target_id,
11403  name,
11404  strcmp (target_source, "file") == 0
11405  ? params_value (params, "file")
11406  : hosts,
11407  exclude_hosts ? exclude_hosts : "",
11408  reverse_lookup_only ? reverse_lookup_only : "0",
11409  reverse_lookup_unify ? reverse_lookup_unify : "0",
11410  port_list_id,
11411  alive_tests);
11412 
11413  g_string_append_printf (command,
11414  "%s%s%s%s%s"
11415  "</modify_target>",
11416  comment_element,
11417  ssh_credentials_element,
11418  smb_credentials_element,
11419  esxi_credentials_element,
11420  snmp_credentials_element);
11421 
11422  g_free (comment_element);
11423  g_free (ssh_credentials_element);
11424  g_free (smb_credentials_element);
11425  g_free (esxi_credentials_element);
11426  g_free (snmp_credentials_element);
11427 
11428  /* Modify the target. */
11429 
11430  ret = openvas_connection_sendf (&connection, "%s", command->str);
11431  g_string_free (command, TRUE);
11432 
11433  if (ret == -1)
11434  {
11435  openvas_connection_close (&connection);
11436  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11437  return gsad_message (credentials,
11438  "Internal error", __FUNCTION__, __LINE__,
11439  "An internal error occurred while modifying target. "
11440  "No target was modified. "
11441  "Diagnostics: Failure to send command to manager daemon.",
11442  "/omp?cmd=get_targets", response_data);
11443  }
11444 
11445  entity = NULL;
11446  if (read_entity_and_text_c (&connection, &entity, &response))
11447  {
11448  openvas_connection_close (&connection);
11449  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
11450  return gsad_message (credentials,
11451  "Internal error", __FUNCTION__, __LINE__,
11452  "An internal error occurred while modifying a target. "
11453  "It is unclear whether the target has been modified or not. "
11454  "Diagnostics: Failure to receive response from manager daemon.",
11455  "/omp?cmd=get_targets", response_data);
11456  }
11457 
11458  openvas_connection_close (&connection);
11459 
11460  html = response_from_entity (credentials, params, entity,
11461  (no_redirect && strcmp (no_redirect, "0")),
11462  NULL, "get_targets",
11463  NULL, "edit_target",
11464  "Save Target", response_data);
11465  }
11466 
11467  /* Pass response to handler of following page. */
11468 
11469  return html;
11470 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
#define GSAD_MESSAGE_INVALID
Answer for invalid input.
Definition: gsad_base.h:44
#define GSAD_MESSAGE_INVALID_PARAM(op)
Answer for invalid input.
Definition: gsad_base.h:53
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

char* save_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Save task, get next page, XSL transform the result.

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

Definition at line 4754 of file gsad_omp.c.

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

4756 {
4757  gchar *html, *response, *format;
4758  const char *no_redirect;
4759  const char *comment, *name, *schedule_id, *in_assets;
4760  const char *scanner_id, *task_id, *max_checks, *max_hosts;
4761  const char *config_id, *target_id, *hosts_ordering, *alterable, *source_iface;
4762  const char *scanner_type, *schedule_periods, *auto_delete, *auto_delete_data;
4763  const char *apply_overrides, *min_qod;
4764  int ret;
4765  params_t *alerts;
4766  GString *alert_element;
4767  entity_t entity;
4768 
4769  no_redirect = params_value (params, "no_redirect");
4770  comment = params_value (params, "comment");
4771  name = params_value (params, "name");
4772  task_id = params_value (params, "task_id");
4773  in_assets = params_value (params, "in_assets");
4774  apply_overrides = params_value (params, "apply_overrides");
4775  min_qod = params_value (params, "min_qod");
4776  target_id = params_value (params, "target_id");
4777  scanner_type = params_value (params, "scanner_type");
4778  hosts_ordering = params_value (params, "hosts_ordering");
4779  config_id = params_value (params, "config_id");
4780  schedule_id = params_value (params, "schedule_id");
4781  schedule_periods = params_value (params, "schedule_periods");
4782  scanner_id = params_value (params, "scanner_id");
4783  max_checks = params_value (params, "max_checks");
4784  source_iface = params_value (params, "source_iface");
4785  auto_delete = params_value (params, "auto_delete");
4786  auto_delete_data = params_value (params, "auto_delete_data");
4787  max_hosts = params_value (params, "max_hosts");
4788  alterable = params_value (params, "alterable");
4789  CHECK_PARAM_INVALID (scanner_type, "Save Task", "edit_task");
4790  if (!strcmp (scanner_type, "1"))
4791  {
4792  hosts_ordering = "";
4793  max_checks = "";
4794  source_iface = "";
4795  max_hosts = "";
4796  }
4797  else if (!strcmp (scanner_type, "3"))
4798  {
4799  config_id = "0";
4800  hosts_ordering = "";
4801  max_checks = "";
4802  source_iface = "";
4803  max_hosts = "";
4804  }
4805 
4806  CHECK_PARAM_INVALID (name, "Save Task", "edit_task");
4807  CHECK_PARAM_INVALID (comment, "Save Task", "edit_task");
4808  CHECK_PARAM_INVALID (target_id, "Save Task", "edit_task");
4809  CHECK_PARAM_INVALID (hosts_ordering, "Save Task", "edit_task");
4810  CHECK_PARAM_INVALID (config_id, "Save Task", "edit_task");
4811  CHECK_PARAM_INVALID (schedule_id, "Save Task", "edit_task");
4812  if (params_given (params, "schedule_periods"))
4813  {
4814  CHECK (schedule_periods);
4815  }
4816  else
4817  schedule_periods = "0";
4818  CHECK_PARAM_INVALID (scanner_id, "Save Task", "edit_task");
4819  CHECK_PARAM_INVALID (task_id, "Save Task", "edit_task");
4820  CHECK_PARAM_INVALID (max_checks, "Save Task", "edit_task");
4821  CHECK_PARAM_INVALID (source_iface, "Save Task", "edit_task");
4822  CHECK_PARAM_INVALID (auto_delete, "Save Task", "edit_task");
4823  CHECK_PARAM_INVALID (auto_delete_data, "Save Task", "edit_task");
4824  CHECK_PARAM_INVALID (max_hosts, "Save Task", "edit_task");
4825  CHECK_PARAM_INVALID (in_assets, "Save Task", "edit_task");
4826 
4827  if (!strcmp (in_assets, "1"))
4828  {
4829  CHECK_PARAM_INVALID (apply_overrides, "Save Task", "edit_task");
4830  CHECK_PARAM_INVALID (min_qod, "Save Task", "edit_task");
4831  }
4832  else
4833  {
4834  if (!params_given (params, "apply_overrides")
4835  || !params_valid (params, "apply_overrides"))
4836  apply_overrides = "";
4837 
4838  if (!params_given (params, "min_qod")
4839  || !params_valid (params, "min_qod"))
4840  min_qod = "";
4841  }
4842 
4843  alert_element = g_string_new ("");
4844  if (params_given (params, "alert_id_optional:"))
4845  alerts = params_values (params, "alert_id_optional:");
4846  else
4847  alerts = params_values (params, "alert_ids:");
4848 
4849  if (alerts)
4850  {
4851  params_iterator_t iter;
4852  char *name;
4853  param_t *param;
4854 
4855  params_iterator_init (&iter, alerts);
4856  while (params_iterator_next (&iter, &name, &param))
4857  {
4858  if (param->value && strcmp (param->value, "0"))
4859  g_string_append_printf (alert_element,
4860  "<alert id=\"%s\"/>",
4861  param->value ? param->value : "");
4862  }
4863  }
4864 
4865  // Remove Alerts from Task if none are given.
4866  if (strcmp (alert_element->str, "") == 0)
4867  g_string_append_printf (alert_element, "<alert id=\"0\"/>");
4868 
4869  format = g_strdup_printf ("<modify_task task_id=\"%%s\">"
4870  "<name>%%s</name>"
4871  "<comment>%%s</comment>"
4872  "<hosts_ordering>%s</hosts_ordering>"
4873  "%s"
4874  "<target id=\"%%s\"/>"
4875  "<config id=\"%%s\"/>"
4876  "<schedule id=\"%%s\"/>"
4877  "<schedule_periods>%%s</schedule_periods>"
4878  "<scanner id=\"%%s\"/>"
4879  "<preferences>"
4880  "<preference>"
4881  "<scanner_name>max_checks</scanner_name>"
4882  "<value>%%s</value>"
4883  "</preference>"
4884  "<preference>"
4885  "<scanner_name>max_hosts</scanner_name>"
4886  "<value>%%s</value>"
4887  "</preference>"
4888  "<preference>"
4889  "<scanner_name>in_assets</scanner_name>"
4890  "<value>%%s</value>"
4891  "</preference>"
4892  "<preference>"
4893  "<scanner_name>assets_apply_overrides</scanner_name>"
4894  "<value>%%s</value>"
4895  "</preference>"
4896  "<preference>"
4897  "<scanner_name>assets_min_qod</scanner_name>"
4898  "<value>%%s</value>"
4899  "</preference>"
4900  "<preference>"
4901  "<scanner_name>source_iface</scanner_name>"
4902  "<value>%%s</value>"
4903  "</preference>"
4904  "<preference>"
4905  "<scanner_name>auto_delete</scanner_name>"
4906  "<value>%%s</value>"
4907  "</preference>"
4908  "<preference>"
4909  "<scanner_name>auto_delete_data</scanner_name>"
4910  "<value>%%s</value>"
4911  "</preference>"
4912  "</preferences>"
4913  "%s%i%s"
4914  "</modify_task>",
4915  hosts_ordering,
4916  alert_element->str,
4917  alterable ? "<alterable>" : "",
4918  alterable ? strcmp (alterable, "0") : 0,
4919  alterable ? "</alterable>" : "");
4920  response = NULL;
4921  entity = NULL;
4922  ret = ompf (credentials,
4923  &response,
4924  &entity,
4925  response_data,
4926  format,
4927  task_id,
4928  name,
4929  comment,
4930  target_id,
4931  config_id,
4932  schedule_id,
4933  schedule_periods,
4934  scanner_id,
4935  max_checks,
4936  max_hosts,
4937  strcmp (in_assets, "0") ? "yes" : "no",
4938  strcmp (apply_overrides, "0") ? "yes" : "no",
4939  min_qod,
4940  source_iface,
4941  auto_delete,
4942  auto_delete_data);
4943  g_free (format);
4944 
4945  g_string_free (alert_element, TRUE);
4946 
4947  switch (ret)
4948  {
4949  case 0:
4950  case -1:
4951  break;
4952  case 1:
4953  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4954  return gsad_message (credentials,
4955  "Internal error", __FUNCTION__, __LINE__,
4956  "An internal error occurred while saving a task. "
4957  "The task was not saved. "
4958  "Diagnostics: Failure to send command to manager daemon.",
4959  "/omp?cmd=get_tasks", response_data);
4960  case 2:
4961  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4962  return gsad_message (credentials,
4963  "Internal error", __FUNCTION__, __LINE__,
4964  "An internal error occurred while saving a task. "
4965  "It is unclear whether the task has been saved or not. "
4966  "Diagnostics: Failure to receive response from manager daemon.",
4967  "/omp?cmd=get_tasks", response_data);
4968  default:
4969  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
4970  return gsad_message (credentials,
4971  "Internal error", __FUNCTION__, __LINE__,
4972  "An internal error occurred while saving a task. "
4973  "It is unclear whether the task has been saved or not. "
4974  "Diagnostics: Internal Error.",
4975  "/omp?cmd=get_tasks", response_data);
4976  }
4977 
4978  html = response_from_entity (credentials, params, entity,
4979  (no_redirect && strcmp (no_redirect, "0")),
4980  NULL, "get_tasks",
4981  NULL, "edit_task",
4982  "Save Task", response_data);
4983  free_entity (entity);
4984  g_free (response);
4985  return html;
4986 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
#define CHECK(name)
Check a param.
Definition: gsad_omp.c:9772
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
int params_valid(params_t *params, const char *name)
Get whether a param is valid.
Definition: gsad_base.c:764

Here is the call graph for this function:

char* save_user_omp ( credentials_t credentials,
params_t params,
char **  password_return,
char **  modified_user,
int *  logout_user,
cmd_response_data_t response_data 
)

Modify a user, get all users, XSL transform the result.

Parameters
[in]credentialsUsername and password for authentication.
[in]paramsRequest parameters.
[out]password_returnPassword. Caller must free.
[out]modified_userName of user modified. Caller must free.
[out]logout_userWhether the user should be logged out.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 25767 of file gsad_omp.c.

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

Referenced by exec_omp_post().

25770 {
25771  int ret;
25772  gchar *html, *response, *buf;
25773  const char *no_redirect;
25774  const char *user_id, *login, *old_login, *modify_password, *password;
25775  const char *hosts, *hosts_allow, *ifaces, *ifaces_allow;
25776  entity_t entity;
25777  GString *command, *group_elements, *role_elements;
25778  params_t *groups, *roles;
25779  const char *status;
25780 
25781  *password_return = NULL;
25782  *modified_user = NULL;
25783  *logout_user = 0;
25784 
25785  no_redirect = params_value (params, "no_redirect");
25786  /* List of hosts user has/lacks access rights. */
25787  hosts = params_value (params, "access_hosts");
25788  /* Whether hosts grants ("1") or forbids ("0") access. "2" for all
25789  * access. */
25790  hosts_allow = params_value (params, "hosts_allow");
25791  ifaces = params_value (params, "access_ifaces");
25792  ifaces_allow = params_value (params, "ifaces_allow");
25793  login = params_value (params, "login");
25794  old_login = params_value (params, "old_login");
25795  modify_password = params_value (params, "modify_password");
25796  password = params_value (params, "password");
25797  user_id = params_value (params, "user_id");
25798 
25799  CHECK_PARAM_INVALID (user_id, "Edit User", "edit_user");
25800  CHECK_PARAM_INVALID (modify_password, "Edit User", "edit_user");
25801  CHECK_PARAM_INVALID (password, "Edit User", "edit_user");
25802  CHECK_PARAM_INVALID (hosts, "Edit User", "edit_user");
25803  CHECK_PARAM_INVALID (hosts_allow, "Edit User", "edit_user");
25804  CHECK_PARAM_INVALID (ifaces, "Save User", "edit_user");
25805  CHECK_PARAM_INVALID (ifaces_allow, "Save User", "edit_user");
25806 
25807  if (params_given (params, "login")
25808  && !(params_given (params, "current_user")))
25809  {
25810  CHECK_PARAM_INVALID (login, "Save User", "edit_user");
25811  CHECK_PARAM_INVALID (old_login, "Save User", "edit_user");
25812  }
25813 
25814  /* Modify the user. */
25815 
25816  command = g_string_new ("");
25817  buf = g_markup_printf_escaped ("<modify_user user_id=\"%s\">"
25818  "<password modify=\"%s\">"
25819  "%s</password>",
25820  user_id,
25821  modify_password,
25822  password);
25823  g_string_append (command, buf);
25824  g_free (buf);
25825 
25826  if (login)
25827  {
25828  buf = g_markup_printf_escaped ("<new_name>%s</new_name>",
25829  login);
25830  g_string_append (command, buf);
25831  g_free (buf);
25832  }
25833 
25834  buf = g_markup_printf_escaped ("<hosts allow=\"%s\">%s</hosts>"
25835  "<ifaces allow=\"%s\">%s</ifaces>",
25836  hosts_allow, hosts, ifaces_allow, ifaces);
25837  g_string_append (command, buf);
25838  g_free (buf);
25839 
25840  if (modify_password && !strcmp (modify_password, "2"))
25841  g_string_append (command, "<sources><source>ldap_connect</source></sources>");
25842  else if (modify_password && !strcmp (modify_password, "3"))
25843  g_string_append (command, "<sources><source>radius_connect</source></sources>");
25844  else
25845  g_string_append (command, "<sources><source>file</source></sources>");
25846 
25847  group_elements = g_string_new ("<groups>");
25848  if (params_given (params, "group_id_optional:"))
25849  groups = params_values (params, "group_id_optional:");
25850  else
25851  groups = params_values (params, "group_ids:");
25852 
25853  if (groups)
25854  {
25855  params_iterator_t iter;
25856  char *name;
25857  param_t *param;
25858 
25859  params_iterator_init (&iter, groups);
25860  while (params_iterator_next (&iter, &name, &param))
25861  {
25862  if (param->value && strcmp (param->value, "--"))
25863  g_string_append_printf (group_elements,
25864  "<group id=\"%s\"/>",
25865  param->value ? param->value : "");
25866  }
25867  }
25868  g_string_append (command, group_elements->str);
25869  g_string_free (group_elements, TRUE);
25870  g_string_append (command, "</groups>");
25871 
25872  role_elements = g_string_new ("");
25873  if (params_given (params, "role_id_optional:"))
25874  roles = params_values (params, "role_id_optional:");
25875  else
25876  roles = params_values (params, "role_ids:");
25877 
25878  if (roles)
25879  {
25880  params_iterator_t iter;
25881  char *name;
25882  param_t *param;
25883 
25884  params_iterator_init (&iter, roles);
25885  while (params_iterator_next (&iter, &name, &param))
25886  {
25887  if (param->value && strcmp (param->value, "--"))
25888  g_string_append_printf (role_elements,
25889  "<role id=\"%s\"/>",
25890  param->value ? param->value : "");
25891  }
25892  }
25893  else
25894  g_string_append_printf (role_elements, "<role id=\"0\"/>");
25895 
25896  g_string_append (command, role_elements->str);
25897  g_string_free (role_elements, TRUE);
25898 
25899  g_string_append (command, "</modify_user>");
25900 
25901  response = NULL;
25902  entity = NULL;
25903  ret = omp (credentials,
25904  &response,
25905  &entity,
25906  response_data,
25907  command->str);
25908  g_string_free (command, TRUE);
25909  switch (ret)
25910  {
25911  case 0:
25912  status = entity_attribute (entity, "status");
25913  if (status && (strlen (status) > 0) && (status[0] == '2'))
25914  {
25915  *modified_user
25916  = g_strdup (old_login ? old_login : credentials->username);
25917 
25918  if (strcmp (modify_password, "0")
25919  || (login && strcmp (old_login, login)))
25920  *logout_user = 1;
25921 
25922  if (strcmp (modify_password, "0")
25923  && strcmp (modify_password, "2")
25924  && strcmp (modify_password, "3")
25925  && params_given (params, "current_user"))
25926  {
25927  g_free (credentials->password);
25928  credentials->password = g_strdup (password);
25929  *password_return = g_strdup (password);
25930  }
25931  }
25932  break;
25933  case -1:
25934  break;
25935  case 1:
25936  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25937  return gsad_message (credentials,
25938  "Internal error", __FUNCTION__, __LINE__,
25939  "An internal error occurred while saving a user. "
25940  "The user was not saved. "
25941  "Diagnostics: Failure to send command to manager daemon.",
25942  "/omp?cmd=get_users", response_data);
25943  case 2:
25944  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25945  return gsad_message (credentials,
25946  "Internal error", __FUNCTION__, __LINE__,
25947  "An internal error occurred while saving a user. "
25948  "It is unclear whether the user has been saved or not. "
25949  "Diagnostics: Failure to receive response from manager daemon.",
25950  "/omp?cmd=get_users", response_data);
25951  default:
25952  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
25953  return gsad_message (credentials,
25954  "Internal error", __FUNCTION__, __LINE__,
25955  "An internal error occurred while saving a user. "
25956  "It is unclear whether the user has been saved or not. "
25957  "Diagnostics: Internal Error.",
25958  "/omp?cmd=get_users", response_data);
25959  }
25960 
25961  if (omp_success (entity)
25962  && (!strcmp (modify_password, "2")
25963  || !strcmp (modify_password, "3"))
25964  && params_given (params, "current_user"))
25965  {
25966  free_entity (entity);
25967  g_free (response);
25968  html = logout (credentials,
25969  "Authentication method changed."
25970  " Please login with LDAP password.",
25971  response_data);
25972  }
25973  else
25974  html = response_from_entity (credentials, params, entity,
25975  (no_redirect && strcmp (no_redirect, "0")),
25976  NULL, "get_users",
25977  NULL, "edit_user",
25978  "Save User", response_data);
25979  free_entity (entity);
25980  g_free (response);
25981  return html;
25982 }
params_t * params_values(params_t *params, const char *name)
Get values of param.
Definition: gsad_base.c:748
gchar * value
Definition: gsad_base.h:146
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
int params_given(params_t *params, const char *name)
Get whether a param was given at all.
Definition: gsad_base.c:666
#define CHECK_PARAM_INVALID(name, op_name, next_cmd)
Check a param using the direct response method.
Definition: gsad_omp.c:1204
char * username
Name of user.
Definition: gsad_base.h:69
#define params_t
Definition: gsad_base.h:61
Request parameter.
Definition: gsad_base.h:144
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
gboolean params_iterator_next(params_iterator_t *iterator, char **name, param_t **param)
Increment a params iterator.
Definition: gsad_base.c:858
#define params_iterator_init
Definition: gsad_base.h:187
#define params_iterator_t
Definition: gsad_base.h:185
char * password
User's password.
Definition: gsad_base.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

char* start_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Start a task, get all tasks, XSL transform the result.

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

Definition at line 5176 of file gsad_omp.c.

References resource_action().

5178 {
5179  return resource_action (credentials, params, "task", "start", response_data);
5180 }
char * resource_action(credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, XSL transform result.
Definition: gsad_omp.c:3224

Here is the call graph for this function:

char* stop_task_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Stop a task, get all tasks, XSL transform the result.

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

Definition at line 5144 of file gsad_omp.c.

References resource_action().

5146 {
5147  return resource_action (credentials, params, "task", "stop", response_data);
5148 }
char * resource_action(credentials_t *credentials, params_t *params, const char *type, const char *action, cmd_response_data_t *response_data)
Perform action on resource, get next page, XSL transform result.
Definition: gsad_omp.c:3224

Here is the call graph for this function:

char* sync_cert_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with a CERT feed and XSL transform the result.

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

Definition at line 24190 of file gsad_omp.c.

24192 {
24193  return sync_feed (credentials, params,
24194  "sync_cert", "Synchronize CERT Feed", "the CERT feed",
24195  response_data);
24196 }
char* sync_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Sync config, get configs, XSL transform the result.

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

Definition at line 12106 of file gsad_omp.c.

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

12108 {
12109  GString *xml;
12110  openvas_connection_t connection;
12111  gchar *html;
12112  const char *config_id, *next;
12113  char *ret;
12114 
12115  config_id = params_value (params, "config_id");
12116  CHECK_PARAM (config_id, "Synchronize Config", get_configs);
12117  switch (manager_connect (credentials, &connection, &html,
12118  response_data))
12119  {
12120  case 0:
12121  break;
12122  case -1:
12123  if (html)
12124  return html;
12125  /* Fall through. */
12126  default:
12127  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12128  return gsad_message
12129  (credentials, "Internal error", __FUNCTION__, __LINE__,
12130  "An internal error occurred while synchronizing a config. "
12131  "The config is not synchronized. "
12132  "Diagnostics: Failure to connect to manager daemon.",
12133  "/omp?cmd=get_configs", response_data);
12134  }
12135 
12136  if (openvas_connection_sendf (&connection, "<sync_config config_id=\"%s\"/>",
12137  config_id)
12138  == -1)
12139  {
12140  openvas_connection_close (&connection);
12141  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12142  return gsad_message
12143  (credentials, "Internal error", __FUNCTION__, __LINE__,
12144  "An internal error occurred while synchronizing a config. "
12145  "The config is not synchronized. "
12146  "Diagnostics: Failure to send command to manager daemon.",
12147  "/omp?cmd=get_configs", response_data);
12148  }
12149 
12150  xml = g_string_new ("");
12151 
12152  if (read_string_c (&connection, &xml))
12153  {
12154  g_string_free (xml, TRUE);
12155  openvas_connection_close (&connection);
12156  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
12157  return gsad_message
12158  (credentials, "Internal error", __FUNCTION__, __LINE__,
12159  "An internal error occurred while synchronizing a config. "
12160  "It is unclear whether the config has been synchronized or not. "
12161  "Diagnostics: Failure to receive response from manager daemon.",
12162  "/omp?cmd=get_configs", response_data);
12163  }
12164 
12165  next = params_value (params, "next");
12166  if (next && !strcmp (next, "get_config"))
12167  ret = get_config (credentials, params, xml->str, 0, response_data);
12168  else
12169  ret = get_configs (credentials, params, xml->str, response_data);
12170  openvas_connection_close (&connection);
12171  g_string_free (xml, TRUE);
12172  return ret;
12173 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1184
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

char* sync_feed_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with an NVT feed and XSL transform the result.

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

Definition at line 24154 of file gsad_omp.c.

24156 {
24157  return sync_feed (credentials, params,
24158  "sync_feed", "Synchronize Feed", "the NVT feed",
24159  response_data);
24160 }
char* sync_scap_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Synchronize with a SCAP feed and XSL transform the result.

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

Definition at line 24172 of file gsad_omp.c.

24174 {
24175  return sync_feed (credentials, params,
24176  "sync_scap", "Synchronize Feed", "the SCAP feed",
24177  response_data);
24178 }
char* test_alert_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Test an alert, get all alerts XSL transform the result.

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

Definition at line 9238 of file gsad_omp.c.

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

9240 {
9241  openvas_connection_t connection;
9242  gchar *html, *response;
9243  const char *no_redirect, *alert_id;
9244  entity_t entity;
9245 
9246  no_redirect = params_value (params, "no_redirect");
9247  alert_id = params_value (params, "alert_id");
9248 
9249  if (alert_id == NULL)
9250  {
9251  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
9252  return gsad_message (credentials,
9253  "Internal error", __FUNCTION__, __LINE__,
9254  "An internal error occurred while testing an alert. "
9255  "Diagnostics: Required parameter was NULL.",
9256  "/omp?cmd=get_alerts", response_data);
9257  }
9258  switch (manager_connect (credentials, &connection, &html,
9259  response_data))
9260  {
9261  case 0:
9262  break;
9263  case -1:
9264  if (html)
9265  return html;
9266  /* Fall through. */
9267  default:
9268  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9269  return gsad_message (credentials,
9270  "Internal error", __FUNCTION__, __LINE__,
9271  "An internal error occurred while testing an alert. "
9272  "Diagnostics: Failure to connect to manager daemon.",
9273  "/omp?cmd=get_alerts", response_data);
9274  }
9275 
9276  /* Test the alert. */
9277 
9278  if (openvas_connection_sendf (&connection,
9279  "<test_alert alert_id=\"%s\"/>",
9280  alert_id)
9281  == -1)
9282  {
9283  openvas_connection_close (&connection);
9284  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9285  return gsad_message (credentials,
9286  "Internal error", __FUNCTION__, __LINE__,
9287  "An internal error occurred while testing an alert. "
9288  "Diagnostics: Failure to send command to manager daemon.",
9289  "/omp?cmd=get_alerts", response_data);
9290  }
9291 
9292  entity = NULL;
9293  if (read_entity_and_text_c (&connection, &entity, &response))
9294  {
9295  openvas_connection_close (&connection);
9296  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
9297  return gsad_message (credentials,
9298  "Internal error", __FUNCTION__, __LINE__,
9299  "An internal error occurred while testing an alert. "
9300  "Diagnostics: Failure to receive response from manager daemon.",
9301  "/omp?cmd=get_alerts", response_data);
9302  }
9303 
9304  /* Cleanup, and return transformed XML. */
9305 
9306  openvas_connection_close (&connection);
9307  html = response_from_entity (credentials, params, entity,
9308  (no_redirect && strcmp (no_redirect, "0")),
9309  NULL, "get_alerts",
9310  NULL, "get_alerts",
9311  "Test Alert", response_data);
9312 
9313  free_entity (entity);
9314  g_free (response);
9315  return html;
9316 }
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

char* toggle_tag_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Set tag enabled status.

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

Definition at line 10816 of file gsad_omp.c.

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

10818 {
10819  openvas_connection_t connection;
10820  gchar *html, *response;
10821  const char *no_redirect, *tag_id, *enable;
10822  entity_t entity;
10823 
10824  no_redirect = params_value (params, "no_redirect");
10825  tag_id = params_value (params, "tag_id");
10826  enable = params_value (params, "enable");
10827 
10828  if (tag_id == NULL)
10829  {
10830  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10831  return gsad_message (credentials,
10832  "Internal error", __FUNCTION__, __LINE__,
10833  "An internal error occurred while modifying a tag. "
10834  "The tag was not modified. "
10835  "Diagnostics: Required parameter tag_id was NULL.",
10836  "/omp?cmd=get_tasks", response_data);
10837  }
10838  if (enable == NULL)
10839  {
10840  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
10841  return gsad_message (credentials,
10842  "Internal error", __FUNCTION__, __LINE__,
10843  "An internal error occurred while modifying a tag. "
10844  "The tag was not modified. "
10845  "Diagnostics: Required parameter enable was NULL.",
10846  "/omp?cmd=get_tasks", response_data);
10847  }
10848 
10849  switch (manager_connect (credentials, &connection, &html,
10850  response_data))
10851  {
10852  case 0:
10853  break;
10854  case -1:
10855  if (html)
10856  return html;
10857  /* Fall through. */
10858  default:
10859  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10860  return gsad_message (credentials,
10861  "Internal error", __FUNCTION__, __LINE__,
10862  "An internal error occurred while modifying a tag."
10863  " The tag is not modified. "
10864  "Diagnostics: Failure to connect to"
10865  " manager daemon.",
10866  "/omp?cmd=get_tasks", response_data);
10867  }
10868 
10869  /* Delete the resource and get all resources. */
10870 
10871  if (openvas_connection_sendf (&connection,
10872  "<modify_tag tag_id=\"%s\">"
10873  "<active>%s</active>"
10874  "</modify_tag>",
10875  tag_id,
10876  enable)
10877  == -1)
10878  {
10879  openvas_connection_close (&connection);
10880  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10881  return gsad_message (credentials,
10882  "Internal error", __FUNCTION__, __LINE__,
10883  "An internal error occurred while modifying a tag. "
10884  "The tag is not modified. "
10885  "Diagnostics: Failure to send command to"
10886  " manager daemon.",
10887  "/omp?cmd=get_tasks", response_data);
10888  }
10889 
10890  entity = NULL;
10891  if (read_entity_and_text_c (&connection, &entity, &response))
10892  {
10893  openvas_connection_close (&connection);
10894  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
10895  return gsad_message (credentials,
10896  "Internal error", __FUNCTION__, __LINE__,
10897  "An internal error occurred while modifying a tag. "
10898  "It is unclear whether the tag has been modified"
10899  " or not. "
10900  "Diagnostics: Failure to read response from"
10901  " manager daemon.",
10902  "/omp?cmd=get_tasks", response_data);
10903  }
10904 
10905  if (! omp_success (entity))
10906  set_http_status_from_entity (entity, response_data);
10907  html = response_from_entity (credentials, params, entity,
10908  (no_redirect && strcmp (no_redirect, "0")),
10909  NULL, "get_tags",
10910  NULL, "get_tags",
10911  "Toggle Tag", response_data);
10912 
10913  free_entity (entity);
10914  g_free (response);
10915  openvas_connection_close (&connection);
10916 
10917  return html;
10918 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682
int manager_connect(credentials_t *, openvas_connection_t *, gchar **, cmd_response_data_t *)
Connect to OpenVAS Manager daemon.
Definition: gsad_omp.c:28279

Here is the call graph for this function:

char* upload_config_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload scan config page.

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

Definition at line 11632 of file gsad_omp.c.

11634 {
11635  return upload_config (credentials, params, NULL, response_data);
11636 }
char* upload_port_list_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload port list page.

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

Definition at line 22903 of file gsad_omp.c.

22905 {
22906  return upload_port_list (credentials, params, NULL, response_data);
22907 }
char* upload_report_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Return the upload report page.

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

Definition at line 3956 of file gsad_omp.c.

3958 {
3959  return upload_report (credentials, params, NULL, response_data);
3960 }
char* verify_agent_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify agent, get agents, XSL transform the result.

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

Definition at line 7598 of file gsad_omp.c.

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

7600 {
7601  gchar *html, *response;
7602  const char *agent_id;
7603  int ret;
7604  entity_t entity;
7605 
7606  agent_id = params_value (params, "agent_id");
7607  if (agent_id == NULL)
7608  {
7609  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
7610  return gsad_message (credentials,
7611  "Internal error", __FUNCTION__, __LINE__,
7612  "An internal error occurred while verifying an agent. "
7613  "Diagnostics: Required parameter was NULL.",
7614  "/omp?cmd=get_agents", response_data);
7615  }
7616  response = NULL;
7617  entity = NULL;
7618  ret = ompf (credentials,
7619  &response,
7620  &entity,
7621  response_data,
7622  "<verify_agent agent_id=\"%s\" />",
7623  agent_id);
7624 
7625  switch (ret)
7626  {
7627  case 0:
7628  case -1:
7629  break;
7630  case 1:
7631  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7632  return gsad_message (credentials,
7633  "Internal error", __FUNCTION__, __LINE__,
7634  "An internal error occurred while verifying a agent. "
7635  "The agent was not verified. "
7636  "Diagnostics: Failure to send command to manager daemon.",
7637  "/omp?cmd=get_agents", response_data);
7638  case 2:
7639  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7640  return gsad_message (credentials,
7641  "Internal error", __FUNCTION__, __LINE__,
7642  "An internal error occurred while verifying a agent. "
7643  "It is unclear whether the agent was verified or not. "
7644  "Diagnostics: Failure to send command to manager daemon.",
7645  "/omp?cmd=get_agents", response_data);
7646  default:
7647  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7648  return gsad_message (credentials,
7649  "Internal error", __FUNCTION__, __LINE__,
7650  "An internal error occurred while verifying a agent. "
7651  "It is unclear whether the agent was verified or not. "
7652  "Diagnostics: Failure to send command to manager daemon.",
7653  "/omp?cmd=get_agents", response_data);
7654  }
7655 
7656  if (omp_success (entity))
7657  {
7658  html = next_page (credentials, params, response, response_data);
7659  if (html == NULL)
7660  {
7661  free_entity (entity);
7662  g_free (response);
7663  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
7664  return gsad_message (credentials,
7665  "Internal error", __FUNCTION__, __LINE__,
7666  "An internal error occurred while verifying a agent. "
7667  "It is unclear whether the agent was verified or not. "
7668  "Diagnostics: Failure to receive response from manager daemon.",
7669  "/omp?cmd=get_agents", response_data);
7670  }
7671  }
7672  else
7673  {
7674  set_http_status_from_entity (entity, response_data);
7675  html = get_agents (credentials, params, response, response_data);
7676  }
7677  free_entity (entity);
7678  g_free (response);
7679  return html;
7680 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* verify_report_format_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify report format, get report formats, XSL transform the result.

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

Definition at line 18992 of file gsad_omp.c.

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

18994 {
18995  int ret;
18996  gchar *html, *response;
18997  const char *report_format_id;
18998  entity_t entity;
18999 
19000  report_format_id = params_value (params, "report_format_id");
19001  if (report_format_id == NULL)
19002  {
19003  response_data->http_status_code = MHD_HTTP_BAD_REQUEST;
19004  return gsad_message (credentials,
19005  "Internal error", __FUNCTION__, __LINE__,
19006  "An internal error occurred while verifying a report format. "
19007  "Diagnostics: Required parameter was NULL.",
19008  "/omp?cmd=get_report_formats", response_data);
19009  }
19010 
19011  /* Verify the report format. */
19012 
19013  response = NULL;
19014  entity = NULL;
19015  ret = ompf (credentials,
19016  &response,
19017  &entity,
19018  response_data,
19019  "<verify_report_format report_format_id=\"%s\"/>",
19020  report_format_id);
19021 
19022  switch (ret)
19023  {
19024  case 0:
19025  case -1:
19026  break;
19027  case 1:
19028  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19029  return gsad_message (credentials,
19030  "Internal error", __FUNCTION__, __LINE__,
19031  "An internal error occurred while verifying a report format. "
19032  "The report format was not verified. "
19033  "Diagnostics: Failure to send command to manager daemon.",
19034  "/omp?cmd=get_report_formats", response_data);
19035  case 2:
19036  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19037  return gsad_message (credentials,
19038  "Internal error", __FUNCTION__, __LINE__,
19039  "An internal error occurred while verifying a report format. "
19040  "It is unclear whether the report format was verified or not. "
19041  "Diagnostics: Failure to send command to manager daemon.",
19042  "/omp?cmd=get_report_formats", response_data);
19043  default:
19044  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19045  return gsad_message (credentials,
19046  "Internal error", __FUNCTION__, __LINE__,
19047  "An internal error occurred while verifying a report format. "
19048  "It is unclear whether the report format was verified or not. "
19049  "Diagnostics: Failure to send command to manager daemon.",
19050  "/omp?cmd=get_report_formats", response_data);
19051  }
19052 
19053  if (omp_success (entity))
19054  {
19055  html = next_page (credentials, params, response, response_data);
19056  if (html == NULL)
19057  {
19058  free_entity (entity);
19059  g_free (response);
19060  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
19061  return gsad_message (credentials,
19062  "Internal error", __FUNCTION__, __LINE__,
19063  "An internal error occurred while verifying a report format. "
19064  "It is unclear whether the report format was verified or not. "
19065  "Diagnostics: Failure to receive response from manager daemon.",
19066  "/omp?cmd=get_report_formats", response_data);
19067  }
19068  }
19069  else
19070  {
19071  set_http_status_from_entity (entity, response_data);
19072  html = get_report_formats (credentials, params, response, response_data);
19073  }
19074  free_entity (entity);
19075  g_free (response);
19076  return html;
19077 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* verify_scanner_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Verify scanner, get scanners, XSL transform the result.

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

Definition at line 17323 of file gsad_omp.c.

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

17325 {
17326  gchar *html, *response;
17327  const char *scanner_id, *next;
17328  int ret;
17329  entity_t entity;
17330 
17331  scanner_id = params_value (params, "scanner_id");
17332  CHECK_PARAM (scanner_id, "Verify Scanner", get_scanners);
17333 
17334 
17335  ret = ompf (credentials,
17336  &response,
17337  &entity,
17338  response_data,
17339  "<verify_scanner scanner_id=\"%s\"/>",
17340  scanner_id);
17341 
17342  switch (ret)
17343  {
17344  case 0:
17345  case -1:
17346  break;
17347  case 1:
17348  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17349  return gsad_message (credentials,
17350  "Internal error", __FUNCTION__, __LINE__,
17351  "An internal error occurred while verifying a scanner. "
17352  "The scanner was not verified. "
17353  "Diagnostics: Failure to send command to manager daemon.",
17354  "/omp?cmd=get_scanners", response_data);
17355  case 2:
17356  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17357  return gsad_message (credentials,
17358  "Internal error", __FUNCTION__, __LINE__,
17359  "An internal error occurred while verifying a scanner. "
17360  "It is unclear whether the scanner was verified or not. "
17361  "Diagnostics: Failure to send command to manager daemon.",
17362  "/omp?cmd=get_scanners", response_data);
17363  default:
17364  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17365  return gsad_message (credentials,
17366  "Internal error", __FUNCTION__, __LINE__,
17367  "An internal error occurred while verifying a scanner. "
17368  "It is unclear whether the scanner was verified or not. "
17369  "Diagnostics: Failure to send command to manager daemon.",
17370  "/omp?cmd=get_scanners", response_data);
17371  }
17372 
17373  if (omp_success (entity))
17374  {
17375  html = next_page (credentials, params, response, response_data);
17376  if (html == NULL)
17377  {
17378  free_entity (entity);
17379  g_free (response);
17380  response_data->http_status_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
17381  return gsad_message (credentials,
17382  "Internal error", __FUNCTION__, __LINE__,
17383  "An internal error occurred while verifying a scanner. "
17384  "It is unclear whether the scanner was verified or not. "
17385  "Diagnostics: Failure to receive response from manager daemon.",
17386  "/omp?cmd=get_scanners", response_data);
17387  }
17388  }
17389  else
17390  {
17391  set_http_status_from_entity (entity, response_data);
17392  next = params_value (params, "next");
17393  if (next && !strcmp (next, "get_scanner"))
17394  html = get_scanner (credentials, params, response, response_data);
17395  else
17396  html = get_scanners (credentials, params, response, response_data);
17397  }
17398 
17399  free_entity (entity);
17400  g_free (response);
17401  return html;
17402 }
void set_http_status_from_entity(entity_t entity, cmd_response_data_t *response_data)
Set the HTTP status according to OMP response entity.
Definition: gsad_omp.c:879
char * gsad_message(credentials_t *credentials, const char *title, const char *function, int line, const char *msg, const char *backurl, cmd_response_data_t *response_data)
Handles fatal errors.
Definition: gsad_base.c:440
#define CHECK_PARAM(name, op_name, ret_func)
Check a param.
Definition: gsad_omp.c:1184
const char * params_value(params_t *params, const char *name)
Get value of param.
Definition: gsad_base.c:682

Here is the call graph for this function:

char* wizard_get_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns a wizard_get page.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 26749 of file gsad_omp.c.

26751 {
26752  return wizard_get (credentials, params, NULL, response_data);
26753 }
char* wizard_omp ( credentials_t credentials,
params_t params,
cmd_response_data_t response_data 
)

Returns a wizard page.

Parameters
[in]credentialsCredentials of user issuing the action.
[in]paramsRequest parameters.
[out]response_dataExtra data return for the HTTP response.
Returns
Result of XSL transformation.

Definition at line 26628 of file gsad_omp.c.

26630 {
26631  return wizard (credentials, params, NULL, response_data);
26632 }