From b2ae7a5193d9b9bec7a05e1cc42cfabacee5a81d Mon Sep 17 00:00:00 2001 From: Ahmed Abdelsalam Date: Wed, 6 Dec 2023 20:48:35 +0100 Subject: [PATCH] Add: New GMP command get_resource_names to get names and uuids for items of given type. To be used in GSA to load tag resources where only the names and uuids are needed in order to improve performance when loading large number of tags. --- src/gsad.c | 1 + src/gsad_gmp.c | 31 +++++++++++++++++++++++++++++++ src/gsad_gmp.h | 3 +++ src/gsad_validator.c | 2 ++ 4 files changed, 37 insertions(+) diff --git a/src/gsad.c b/src/gsad.c index b5c535681..335fb6f0d 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1491,6 +1491,7 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (get_groups) ELSE (get_info) ELSE (get_license) + ELSE (get_resource_names) ELSE (get_note) ELSE (get_notes) ELSE (get_nvt_families) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 3d3efab33..77f657f01 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -16472,6 +16472,37 @@ get_license_gmp (gvm_connection_t *connection, credentials_t *credentials, return get_license (connection, credentials, params, NULL, response_data); } +/** + * @brief Get resource names, envelope 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 Enveloped XML object. + */ +char * +get_resource_names_gmp (gvm_connection_t *connection, + credentials_t *credentials, + params_t *params, + cmd_response_data_t *response_data) +{ + const gchar *type; + gmp_arguments_t *arguments; + + type = params_value (params, "resource_type"); + + CHECK_VARIABLE_INVALID(type, "Get Resource Names"); + + arguments = gmp_arguments_new (); + + gmp_arguments_add (arguments, "type", type); + + return get_many (connection, "resource_names", credentials, params, arguments, + response_data); +} + /** * @brief Modify a theia license * diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index bf2db4d36..b564003ab 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -407,6 +407,9 @@ char * get_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *, cmd_response_data_t *); char * +get_resource_names_gmp (gvm_connection_t *, credentials_t *, params_t *, + cmd_response_data_t *); +char * save_permission_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 b4254d160..47fd1e2cd 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -152,6 +152,7 @@ init_validator () "|(get_groups)" "|(get_info)" "|(get_license)" + "|(get_resource_names)" "|(get_note)" "|(get_notes)" "|(get_nvt_families)" @@ -388,6 +389,7 @@ init_validator () gvm_validator_add (validator, "name", "^[[:graph:] ]*$"); gvm_validator_add (validator, "info_name", "(?s)^.*$"); gvm_validator_add (validator, "info_type", "(?s)^.*$"); + gvm_validator_add (validator, "resource_type", "(?s)^.*$"); gvm_validator_add (validator, "info_id", "^([[:alnum:]\\-_.:\\/~()']|&)+$"); gvm_validator_add (validator, "details", "^[0-1]$");