Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gsad.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ exec_gmp_get (gsad_http_connection_t *con, gsad_connection_info_t *con_info,
ELSE (get_port_list)
ELSE (get_port_lists)
ELSE (get_report)
ELSE (get_report_errors)
ELSE (get_report_hosts)
ELSE (get_report_ports)
ELSE (get_report_tls_certificates)
Expand Down
95 changes: 95 additions & 0 deletions src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9574,6 +9574,101 @@ get_report_gmp (gvm_connection_t *connection, gsad_credentials_t *credentials,
return get_report (connection, credentials, params, NULL, response_data);
}

/**
* @brief Get report errors and return the result.
*
* @param[in] connection Connection to manager.
* @param[in] credentials Username and password for authentication.
* @param[in] params Request parameters.
* @param[out] response_data Extra data return for the HTTP response.
*
* @return Report errors XML.
*/
char *
get_report_errors_gmp (gvm_connection_t *connection,
gsad_credentials_t *credentials, params_t *params,
cmd_response_data_t *response_data)
{
GString *xml;
entity_t entity;
const char *report_id;
const char *filter;
const char *filter_id;
gboolean details, ignore_pagination;
int ret;

details = params_value_bool (params, "details");
ignore_pagination = params_value_bool (params, "ignore_pagination");

report_id = params_value (params, "report_id");
filter = params_value (params, "filter");
filter_id = params_value (params, "filter_id");

CHECK_VARIABLE_INVALID (report_id, "Get Report Errors");

if (filter == NULL || filter_id)
filter = "";

ret = gvm_connection_sendf_xml (connection,
"<get_report_errors"
" report_id=\"%s\""
" details=\"%d\""
" ignore_pagination=\"%d\""
" filter=\"%s\""
" filt_id=\"%s\"/>",
report_id, details, ignore_pagination, filter,
filter_id ? filter_id : FILT_ID_NONE);

if (ret == -1)
{
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while getting report errors. "
"The report errors could not be delivered. "
"Diagnostics: Failure to send command to manager daemon.",
response_data);
}

xml = g_string_new ("<get_report_errors>");

entity = NULL;
if (read_entity_and_string_c (connection, &entity, &xml))
{
cmd_response_data_set_status_code (response_data,
MHD_HTTP_INTERNAL_SERVER_ERROR);
return gsad_message (
credentials, "Internal error", __func__, __LINE__,
"An internal error occurred while getting report errors. "
"The report errors could not be delivered. "
"Diagnostics: Failure to receive response from manager daemon.",
response_data);
}

if (gmp_success (entity) != 1)
{
gchar *message;

set_http_status_from_entity (entity, response_data);

message =
gsad_message (credentials, "Error", __func__, __LINE__,
entity_attribute (entity, "status_text"), response_data);

g_string_free (xml, TRUE);
free_entity (entity);
return message;
}

free_entity (entity);

g_string_append (xml, "</get_report_errors>");

return envelope_gmp (connection, credentials, params,
g_string_free (xml, FALSE), response_data);
}

/**
* @brief Get report hosts and return the result.
*
Expand Down
3 changes: 3 additions & 0 deletions src/gsad_gmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ char *
get_report_gmp (gvm_connection_t *, gsad_credentials_t *, params_t *,
cmd_response_data_t *);
char *
get_report_errors_gmp (gvm_connection_t *, gsad_credentials_t *, params_t *,
cmd_response_data_t *);
char *
get_report_hosts_gmp (gvm_connection_t *, gsad_credentials_t *, params_t *,
cmd_response_data_t *);
char *
Expand Down
1 change: 1 addition & 0 deletions src/gsad_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ gsad_init_validator ()
"|(get_port_list)"
"|(get_port_lists)"
"|(get_report)"
"|(get_report_errors)"
"|(get_report_hosts)"
"|(get_report_ports)"
"|(get_report_tls_certificates)"
Expand Down
Loading