@@ -10169,6 +10169,100 @@ get_report_tls_certificates_gmp (gvm_connection_t *connection,
1016910169 g_string_free (xml, FALSE), response_data);
1017010170}
1017110171
10172+ /**
10173+ * @brief Get report vulnerabilities and return the result.
10174+ *
10175+ * @param[in] connection Connection to manager.
10176+ * @param[in] credentials Username and password for authentication.
10177+ * @param[in] params Request parameters.
10178+ * @param[out] response_data Extra data return for the HTTP response.
10179+ *
10180+ * @return Report vulnerabilities XML.
10181+ */
10182+ char *
10183+ get_report_vulns_gmp (gvm_connection_t *connection,
10184+ gsad_credentials_t *credentials, params_t *params,
10185+ gsad_command_response_data_t *response_data)
10186+ {
10187+ GString *xml;
10188+ entity_t entity;
10189+ const char *report_id;
10190+ const char *filter;
10191+ const char *filter_id;
10192+ gboolean details, ignore_pagination;
10193+ int ret;
10194+
10195+ details = params_value_bool (params, "details");
10196+ ignore_pagination = params_value_bool (params, "ignore_pagination");
10197+
10198+ report_id = params_value (params, "report_id");
10199+ filter = params_value (params, "filter");
10200+ filter_id = params_value (params, "filter_id");
10201+
10202+ CHECK_VARIABLE_INVALID (report_id, "Get Report Vulnerabilities");
10203+
10204+ if (filter == NULL || filter_id)
10205+ filter = "";
10206+
10207+ ret = gvm_connection_sendf_xml (connection,
10208+ "<get_report_vulns"
10209+ " report_id=\"%s\""
10210+ " details=\"%d\""
10211+ " ignore_pagination=\"%d\""
10212+ " filter=\"%s\""
10213+ " filt_id=\"%s\"/>",
10214+ report_id, details, ignore_pagination, filter,
10215+ filter_id ? filter_id : FILT_ID_NONE);
10216+
10217+ if (ret == -1)
10218+ {
10219+ gsad_command_response_data_set_status_code (
10220+ response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10221+ return gsad_http_create_gsad_message (
10222+ credentials,
10223+ "An internal error occurred while getting report vulnerabilities. "
10224+ "The report vulnerabilities could not be delivered. "
10225+ "Diagnostics: Failure to send command to manager daemon.",
10226+ response_data);
10227+ }
10228+
10229+ xml = g_string_new ("<get_report_vulns>");
10230+
10231+ entity = NULL;
10232+ if (read_entity_and_string_c (connection, &entity, &xml))
10233+ {
10234+ gsad_command_response_data_set_status_code (
10235+ response_data, MHD_HTTP_INTERNAL_SERVER_ERROR);
10236+ return gsad_http_create_gsad_message (
10237+ credentials,
10238+ "An internal error occurred while getting report vulnerabilities. "
10239+ "The report vulnerabilities could not be delivered. "
10240+ "Diagnostics: Failure to receive response from manager daemon.",
10241+ response_data);
10242+ }
10243+
10244+ if (gmp_success (entity) != 1)
10245+ {
10246+ gchar *message;
10247+
10248+ set_http_status_from_entity (entity, response_data);
10249+
10250+ message = gsad_http_create_gsad_message (
10251+ credentials, entity_attribute (entity, "status_text"), response_data);
10252+
10253+ g_string_free (xml, TRUE);
10254+ free_entity (entity);
10255+ return message;
10256+ }
10257+
10258+ free_entity (entity);
10259+
10260+ g_string_append (xml, "</get_report_vulns>");
10261+
10262+ return envelope_gmp (connection, credentials, params,
10263+ g_string_free (xml, FALSE), response_data);
10264+ }
10265+
1017210266/**
1017310267 * @brief Run alert for a report.
1017410268 *
0 commit comments