From e708679b2c40f3eff1b035e0b3f75c242d6df5c0 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Tue, 29 Aug 2023 16:05:09 +0200 Subject: [PATCH 1/3] Change: Skip tags in get_config_family --- src/gsad_gmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index fedcff813..ec3416959 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -6968,7 +6968,7 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials, "", config_id, family, sort_field ? sort_field : "nvts.name", sort_order ? sort_order : "ascending") @@ -7012,6 +7012,7 @@ get_config_family (gvm_connection_t *connection, credentials_t *credentials, " preferences_config_id=\"%s\"" " preference_count=\"1\"" " skip_cert_refs=\"1\"" + " skip_tags=\"1\"" " sort_field=\"%s\"" " sort_order=\"%s\"/>", family, config_id, From 89058203c752851fa509cfb032247062a5ecac00 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Tue, 5 Sep 2023 17:42:08 +0200 Subject: [PATCH 2/3] Move all part of edit_config_family to edit_config_family_all --- src/gsad.c | 1 + src/gsad_gmp.c | 139 +++++++++++++++++++++++++------------------ src/gsad_gmp.h | 3 + src/gsad_validator.c | 1 + 4 files changed, 87 insertions(+), 57 deletions(-) diff --git a/src/gsad.c b/src/gsad.c index 3d9fb7435..7a014e269 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1296,6 +1296,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 ec3416959..fed8a80e6 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 * @@ -6935,17 +6935,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; @@ -6998,55 +6996,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); @@ -7066,7 +7015,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); } /** @@ -7084,7 +7033,83 @@ 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 e77d1b0c9..0f85e49c6 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)" From 9138d80c9f9e9e8a31612ece738acc9ced418b6a Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Tue, 17 Oct 2023 14:06:45 +0200 Subject: [PATCH 3/3] Clang format --- src/gsad_gmp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index a3e8b3ad4..3d3efab33 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -7076,11 +7076,11 @@ edit_config_family_all_gmp (gvm_connection_t *connection, 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); + 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)) @@ -7089,11 +7089,11 @@ edit_config_family_all_gmp (gvm_connection_t *connection, 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); + 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, "");