diff --git a/src/gsad.c b/src/gsad.c index 4067a8016..b5c535681 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1363,6 +1363,7 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (auth_settings) ELSE (edit_alert) ELSE (edit_config_family) + ELSE (edit_config_family_all) ELSE (export_alert) ELSE (export_alerts) ELSE (export_asset) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 8300564a6..3d3efab33 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -170,7 +170,7 @@ get_trash (gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *); static char * -get_config_family (gvm_connection_t *, credentials_t *, params_t *, int, +get_config_family (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *); static char * @@ -6923,17 +6923,15 @@ save_config_gmp (gvm_connection_t *connection, credentials_t *credentials, * @brief Get details of a family for a config, envelope the result. * * @param[in] connection Connection to manager. - * @param[in] credentials Username and password for authentication. - * @param[in] params Request parameters. - * @param[in] edit 0 for config view page, else config edit page. + * @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 Enveloped XML object. */ static char * get_config_family (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, int edit, - cmd_response_data_t *response_data) + params_t *params, cmd_response_data_t *response_data) { GString *xml; const char *config_id, *family, *sort_field, *sort_order; @@ -6986,56 +6984,6 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials, response_data); } - if (edit) - { - /* Get the details for all NVT's in the family. */ - - g_string_append (xml, ""); - - if (gvm_connection_sendf (connection, - "", - family, config_id, - sort_field ? sort_field : "nvts.name", - sort_order ? sort_order : "ascending") - == -1) - { - g_string_free (xml, TRUE); - 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 list of configs. " - "The current list of configs is not available. " - "Diagnostics: Failure to send command to manager daemon.", - response_data); - } - - if (read_string_c (connection, &xml)) - { - g_string_free (xml, TRUE); - 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 list of configs. " - "The current list of configs is not available. " - "Diagnostics: Failure to receive response from manager daemon.", - response_data); - } - - g_string_append (xml, ""); - } - g_string_append (xml, ""); return envelope_gmp (connection, credentials, params, g_string_free (xml, FALSE), response_data); @@ -7055,7 +7003,7 @@ char * get_config_family_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data) { - return get_config_family (connection, credentials, params, 0, response_data); + return get_config_family (connection, credentials, params, response_data); } /** @@ -7073,7 +7021,84 @@ edit_config_family_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data) { - return get_config_family (connection, credentials, params, 1, response_data); + return get_config_family (connection, credentials, params, response_data); +} + +/** + * @brief Get all details of a family for editing a config, envelope 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 Enveloped XML object. + */ +char * +edit_config_family_all_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) +{ + GString *xml; + const char *config_id, *family, *sort_field, *sort_order; + + config_id = params_value (params, "config_id"); + family = params_value (params, "family"); + + CHECK_VARIABLE_INVALID (config_id, "Get Scan Config Family") + CHECK_VARIABLE_INVALID (family, "Get Scan Config Family") + + xml = g_string_new (""); + + /* Get the details for all NVT's in the family. */ + + sort_field = params_value (params, "sort_field"); + sort_order = params_value (params, "sort_order"); + + if (gvm_connection_sendf (connection, + "", + family, config_id, + sort_field ? sort_field : "nvts.name", + sort_order ? sort_order : "ascending") + == -1) + { + g_string_free (xml, TRUE); + 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 list of configs. " + "The current list of configs is not available. " + "Diagnostics: Failure to send command to manager daemon.", + response_data); + } + + if (read_string_c (connection, &xml)) + { + g_string_free (xml, TRUE); + 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 list of configs. " + "The current list of configs is not available. " + "Diagnostics: Failure to receive response from manager daemon.", + response_data); + } + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); } /** diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index 54c5dea8b..bf2db4d36 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -297,6 +297,9 @@ char * edit_config_family_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *); char * +edit_config_family_all_gmp (gvm_connection_t *, credentials_t *, params_t *, + cmd_response_data_t *); +char * get_config_family_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *); char * diff --git a/src/gsad_validator.c b/src/gsad_validator.c index df8f8fc1e..b4254d160 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -90,6 +90,7 @@ init_validator () "|(download_key_pub)" "|(edit_alert)" "|(edit_config_family)" + "|(edit_config_family_all)" "|(auth_settings)" "|(empty_trashcan)" "|(export_alert)"