Skip to content

Commit

Permalink
Add: New GMP command get_resource_names to get names and uuids for
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a-h-abdelsalam authored and timopollmeier committed Dec 8, 2023
1 parent 751dfcc commit fa43112
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gsad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
3 changes: 3 additions & 0 deletions src/gsad_gmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
2 changes: 2 additions & 0 deletions src/gsad_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ init_validator ()
"|(get_groups)"
"|(get_info)"
"|(get_license)"
"|(get_resource_names)"
"|(get_note)"
"|(get_notes)"
"|(get_nvt_families)"
Expand Down Expand Up @@ -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]$");
Expand Down

0 comments on commit fa43112

Please sign in to comment.