From f8fb9b3597467a1256adb5cf6735c2d8cc1d1470 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 4 Jan 2024 11:27:15 +0200 Subject: [PATCH 1/5] Add: new cmd get_trash_targets --- src/gsad.c | 1 + src/gsad_gmp.c | 33 ++++++++++++++++++++++++++++++--- src/gsad_gmp.h | 3 +++ src/gsad_validator.c | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/gsad.c b/src/gsad.c index b5c535681..328568272 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1527,6 +1527,7 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (get_tls_certificate) ELSE (get_tls_certificates) ELSE (get_trash) + ELSE (get_trash_targets) ELSE (get_user) ELSE (get_users) ELSE (get_vulns) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 3d3efab33..6f2f9fe19 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -10917,8 +10917,6 @@ get_trash (gvm_connection_t *connection, credentials_t *credentials, GET_TRASH_RESOURCE ("GET_TAGS", "get_tags", "tags"); - GET_TRASH_RESOURCE ("GET_TARGETS", "get_targets", "targets"); - GET_TRASH_RESOURCE ("GET_TASKS", "get_tasks", "tasks"); GET_TRASH_RESOURCE ("GET_TICKETS", "get_tickets", "tickets"); @@ -10929,7 +10927,6 @@ get_trash (gvm_connection_t *connection, credentials_t *credentials, return envelope_gmp (connection, credentials, params, g_string_free (xml, FALSE), response_data); } -#undef GET_TRASH_RESOURCE /** * @brief Get all trash, envelope the result. @@ -10948,6 +10945,36 @@ get_trash_gmp (gvm_connection_t *connection, credentials_t *credentials, return get_trash (connection, credentials, params, NULL, response_data); } +/** + * @brief Setup trash page XML, envelope the result. + * + * @param[in] connection Connection to manager. + * @param[in] credentials Username and password for authentication. + * @param[in] params Request parameters. + * @param[in] extra_xml Extra XML to insert inside page element. + * @param[out] response_data Extra data return for the HTTP response. + * + * @return Enveloped XML object. + */ +char * +get_trash_targets_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_TARGETS", "get_targets", "targets"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +#undef GET_TRASH_RESOURCE + /** * @brief Send settings resource filters. * diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index bf2db4d36..c041964ec 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -621,6 +621,9 @@ char * get_trash_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * +get_trash_targets_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * restore_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..c2a260fbd 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -188,6 +188,7 @@ init_validator () "|(get_tls_certificate)" "|(get_tls_certificates)" "|(get_trash)" + "|(get_trash_targets)" "|(get_user)" "|(get_users)" "|(get_vulns)" From 5c7182aba91a21d109eaf4748e1eaba49b03d8c1 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 4 Jan 2024 18:22:34 +0200 Subject: [PATCH 2/5] Add: a get_trash command per resource --- src/gsad.c | 16 ++ src/gsad_gmp.c | 433 +++++++++++++++++++++++++++++++++++++++++++ src/gsad_gmp.h | 48 +++++ src/gsad_validator.c | 16 ++ 4 files changed, 513 insertions(+) diff --git a/src/gsad.c b/src/gsad.c index 7fbaabd50..ada1b6e1f 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1528,7 +1528,23 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (get_tls_certificate) ELSE (get_tls_certificates) ELSE (get_trash) + ELSE (get_trash_alerts) + ELSE (get_trash_configs) + ELSE (get_trash_credentials) + ELSE (get_trash_filters) + ELSE (get_trash_groups) + ELSE (get_trash_notes) + ELSE (get_trash_overrides) + ELSE (get_trash_permissions) + ELSE (get_trash_port_lists) + ELSE (get_trash_report_formats) + ELSE (get_trash_roles) + ELSE (get_trash_scanners) + ELSE (get_trash_schedules) + ELSE (get_trash_tags) ELSE (get_trash_targets) + ELSE (get_trash_tasks) + ELSE (get_trash_tickets) ELSE (get_user) ELSE (get_users) ELSE (get_vulns) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 41acd5ba4..cca997954 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -10975,6 +10975,385 @@ get_trash_gmp (gvm_connection_t *connection, credentials_t *credentials, return get_trash (connection, credentials, params, NULL, response_data); } +/** + * @brief Setup trash page XML, 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_trash_alerts_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_ALERTS", "get_alerts", "alerts"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_configs_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_CONFIGS", "get_configs", "configs"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_credentials_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_CREDENTIALS", "get_credentials", "credentials"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_filters_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_FILTERS", "get_filters", "filters"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_groups_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_GROUPS", "get_groups", "groups"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_notes_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_NOTES", "get_notes", "notes"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_overrides_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_OVERRIDES", "get_overrides", "overrides"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_permissions_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_PERMISSIONS", "get_permissions", "permissions"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_port_lists_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_PORT_LISTS", "get_port_lists", "port_lists"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_report_formats_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats", "report_formats"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_roles_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_ROLES", "get_roles", "roles"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_scanners_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_SCANNERS", "get_scanners", "scanners"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_schedules_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_SCHEDULES", "get_schedules", "schedules"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_tags_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_TAGS", "get_tags", "tags"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + + /** * @brief Setup trash page XML, envelope the result. * @@ -11003,6 +11382,60 @@ get_trash_targets_gmp (gvm_connection_t *connection, credentials_t *credentials, g_string_free (xml, FALSE), response_data); } +/** + * @brief Setup trash page XML, 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_trash_tasks_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_TASKS", "get_tasks", "tasks"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_tickets_gmp (gvm_connection_t *connection, credentials_t *credentials, + params_t *params, cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + + GET_TRASH_RESOURCE ("GET_TICKETS", "get_tickets", "tickets"); + + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + #undef GET_TRASH_RESOURCE /** diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index 894fdb45a..56287df57 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -625,9 +625,57 @@ char * get_trash_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * +get_trash_alerts_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_configs_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_credentials_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_filters_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_groups_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_notes_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_overrides_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_port_lists_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_report_formats_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_roles_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_scanners_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_schedules_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_tags_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * get_trash_targets_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * +get_trash_tasks_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * +get_trash_tickets_gmp (gvm_connection_t *, credentials_t *, params_t *params, + cmd_response_data_t *); +char * restore_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 542cb734d..986347421 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -189,7 +189,23 @@ init_validator () "|(get_tls_certificate)" "|(get_tls_certificates)" "|(get_trash)" + "|(get_trash_alerts)" + "|(get_trash_configs)" + "|(get_trash_credentials)" + "|(get_trash_filters)" + "|(get_trash_groups)" + "|(get_trash_notes)" + "|(get_trash_overrides)" + "|(get_trash_permissions)" + "|(get_trash_port_lists)" + "|(get_trash_report_formats)" + "|(get_trash_roles)" + "|(get_trash_scanners)" + "|(get_trash_schedules)" + "|(get_trash_tags)" "|(get_trash_targets)" + "|(get_trash_tasks)" + "|(get_trash_tickets)" "|(get_user)" "|(get_users)" "|(get_vulns)" From 045d66d5ba2827c72dc1f9b66a1d5a4823b5c256 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 8 Jan 2024 14:13:35 +0200 Subject: [PATCH 3/5] Remove old get_trash command --- src/gsad.c | 1 - src/gsad_gmp.c | 84 -------------------------------------------- src/gsad_validator.c | 1 - 3 files changed, 86 deletions(-) diff --git a/src/gsad.c b/src/gsad.c index ada1b6e1f..92a2fec8a 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1527,7 +1527,6 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (get_tickets) ELSE (get_tls_certificate) ELSE (get_tls_certificates) - ELSE (get_trash) ELSE (get_trash_alerts) ELSE (get_trash_configs) ELSE (get_trash_credentials) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index cca997954..2001e3ead 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -165,10 +165,6 @@ static char * get_asset (gvm_connection_t *, credentials_t *, params_t *, const char *, cmd_response_data_t *); -static char * -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 *, cmd_response_data_t *); @@ -10895,86 +10891,6 @@ run_wizard_gmp (gvm_connection_t *connection, credentials_t *credentials, } \ } -/** - * @brief Setup trash page XML, envelope the result. - * - * @param[in] connection Connection to manager. - * @param[in] credentials Username and password for authentication. - * @param[in] params Request parameters. - * @param[in] extra_xml Extra XML to insert inside page element. - * @param[out] response_data Extra data return for the HTTP response. - * - * @return Enveloped XML object. - */ -char * -get_trash (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, const char *extra_xml, - cmd_response_data_t *response_data) -{ - GString *xml; - - xml = g_string_new (""); - - if (extra_xml) - g_string_append (xml, extra_xml); - - GET_TRASH_RESOURCE ("GET_CONFIGS", "get_configs", "configs"); - - GET_TRASH_RESOURCE ("GET_CREDENTIALS", "get_credentials", "credentials"); - - GET_TRASH_RESOURCE ("GET_ALERTS", "get_alerts", "alerts"); - - GET_TRASH_RESOURCE ("GET_GROUPS", "get_groups", "groups"); - - GET_TRASH_RESOURCE ("GET_FILTERS", "get_filters", "filters"); - - GET_TRASH_RESOURCE ("GET_NOTES", "get_notes", "notes"); - - GET_TRASH_RESOURCE ("GET_OVERRIDES", "get_overrides", "overrides"); - - GET_TRASH_RESOURCE ("GET_PERMISSIONS", "get_permissions", "permissions"); - - GET_TRASH_RESOURCE ("GET_PORT_LISTS", "get_port_lists", "port lists"); - - GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats", - "report formats"); - - GET_TRASH_RESOURCE ("GET_ROLES", "get_roles", "roles"); - - GET_TRASH_RESOURCE ("GET_SCANNERS", "get_scanners", "scanners"); - - GET_TRASH_RESOURCE ("GET_SCHEDULES", "get_schedules", "schedules"); - - GET_TRASH_RESOURCE ("GET_TAGS", "get_tags", "tags"); - - GET_TRASH_RESOURCE ("GET_TASKS", "get_tasks", "tasks"); - - GET_TRASH_RESOURCE ("GET_TICKETS", "get_tickets", "tickets"); - - /* Cleanup, and return transformed XML. */ - - g_string_append (xml, ""); - return envelope_gmp (connection, credentials, params, - g_string_free (xml, FALSE), response_data); -} - -/** - * @brief Get all trash, 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_trash_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) -{ - return get_trash (connection, credentials, params, NULL, response_data); -} - /** * @brief Setup trash page XML, envelope the result. * diff --git a/src/gsad_validator.c b/src/gsad_validator.c index 986347421..4d47d832b 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -188,7 +188,6 @@ init_validator () "|(get_tickets)" "|(get_tls_certificate)" "|(get_tls_certificates)" - "|(get_trash)" "|(get_trash_alerts)" "|(get_trash_configs)" "|(get_trash_credentials)" From d1c694cd3395f5f5525a62f6844daa86fa47c5b4 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 8 Jan 2024 14:14:43 +0200 Subject: [PATCH 4/5] Clang format --- src/gsad_gmp.c | 39 +++++++++++++++++++++++---------------- src/gsad_gmp.h | 12 ++++++------ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 2001e3ead..c4a3f2ad4 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -10956,8 +10956,9 @@ get_trash_configs_gmp (gvm_connection_t *connection, credentials_t *credentials, * @return Enveloped XML object. */ char * -get_trash_credentials_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_credentials_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11064,8 +11065,9 @@ get_trash_notes_gmp (gvm_connection_t *connection, credentials_t *credentials, * @return Enveloped XML object. */ char * -get_trash_overrides_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_overrides_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11091,8 +11093,9 @@ get_trash_overrides_gmp (gvm_connection_t *connection, credentials_t *credential * @return Enveloped XML object. */ char * -get_trash_permissions_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_permissions_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11118,8 +11121,9 @@ get_trash_permissions_gmp (gvm_connection_t *connection, credentials_t *credenti * @return Enveloped XML object. */ char * -get_trash_port_lists_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_port_lists_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11145,14 +11149,16 @@ get_trash_port_lists_gmp (gvm_connection_t *connection, credentials_t *credentia * @return Enveloped XML object. */ char * -get_trash_report_formats_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_report_formats_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; xml = g_string_new (""); - GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats", "report_formats"); + GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats", + "report_formats"); /* Cleanup, and return transformed XML. */ @@ -11199,8 +11205,9 @@ get_trash_roles_gmp (gvm_connection_t *connection, credentials_t *credentials, * @return Enveloped XML object. */ char * -get_trash_scanners_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_scanners_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11226,8 +11233,9 @@ get_trash_scanners_gmp (gvm_connection_t *connection, credentials_t *credentials * @return Enveloped XML object. */ char * -get_trash_schedules_gmp (gvm_connection_t *connection, credentials_t *credentials, - params_t *params, cmd_response_data_t *response_data) +get_trash_schedules_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) { GString *xml; @@ -11269,7 +11277,6 @@ get_trash_tags_gmp (gvm_connection_t *connection, credentials_t *credentials, g_string_free (xml, FALSE), response_data); } - /** * @brief Setup trash page XML, envelope the result. * diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index 56287df57..8cf7af265 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -631,8 +631,8 @@ char * get_trash_configs_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * -get_trash_credentials_gmp (gvm_connection_t *, credentials_t *, params_t *params, - cmd_response_data_t *); +get_trash_credentials_gmp (gvm_connection_t *, credentials_t *, + params_t *params, cmd_response_data_t *); char * get_trash_filters_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); @@ -646,14 +646,14 @@ char * get_trash_overrides_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * -get_trash_permissions_gmp (gvm_connection_t *, credentials_t *, params_t *params, - cmd_response_data_t *); +get_trash_permissions_gmp (gvm_connection_t *, credentials_t *, + params_t *params, cmd_response_data_t *); char * get_trash_port_lists_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * -get_trash_report_formats_gmp (gvm_connection_t *, credentials_t *, params_t *params, - cmd_response_data_t *); +get_trash_report_formats_gmp (gvm_connection_t *, credentials_t *, + params_t *params, cmd_response_data_t *); char * get_trash_roles_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); From dfa3e0c112019fbbeed000c5fabf64e0972abfc8 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 26 Feb 2024 21:55:18 +0200 Subject: [PATCH 5/5] Add get_trash_report_configs --- src/gsad.c | 1 + src/gsad_gmp.c | 28 +++++++++++++++++++++++++++- src/gsad_gmp.h | 3 +++ src/gsad_validator.c | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/gsad.c b/src/gsad.c index 318640204..83e286854 100644 --- a/src/gsad.c +++ b/src/gsad.c @@ -1614,6 +1614,7 @@ exec_gmp_get (http_connection_t *con, gsad_connection_info_t *con_info, ELSE (get_trash_overrides) ELSE (get_trash_permissions) ELSE (get_trash_port_lists) + ELSE (get_trash_report_configs) ELSE (get_trash_report_formats) ELSE (get_trash_roles) ELSE (get_trash_scanners) diff --git a/src/gsad_gmp.c b/src/gsad_gmp.c index 33b078d7f..1a2c2e1d1 100644 --- a/src/gsad_gmp.c +++ b/src/gsad_gmp.c @@ -11555,7 +11555,7 @@ get_trash_port_lists_gmp (gvm_connection_t *connection, * @return Enveloped XML object. */ char * -get_trash_report_formats_gmp (gvm_connection_t *connection, +get_trash_report_configs_gmp (gvm_connection_t *connection, credentials_t *credentials, params_t *params, cmd_response_data_t *response_data) { @@ -11566,6 +11566,32 @@ get_trash_report_formats_gmp (gvm_connection_t *connection, GET_TRASH_RESOURCE ("GET_REPORT_CONFIGS", "get_report_configs", "report configs"); + /* Cleanup, and return transformed XML. */ + + g_string_append (xml, ""); + return envelope_gmp (connection, credentials, params, + g_string_free (xml, FALSE), response_data); +} + +/** + * @brief Setup trash page XML, 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_trash_report_formats_gmp (gvm_connection_t *connection, + credentials_t *credentials, params_t *params, + cmd_response_data_t *response_data) +{ + GString *xml; + + xml = g_string_new (""); + GET_TRASH_RESOURCE ("GET_REPORT_FORMATS", "get_report_formats", "report_formats"); diff --git a/src/gsad_gmp.h b/src/gsad_gmp.h index 9e846cd5b..cd45f733d 100644 --- a/src/gsad_gmp.h +++ b/src/gsad_gmp.h @@ -674,6 +674,9 @@ char * get_trash_port_lists_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * +get_trash_report_configs_gmp (gvm_connection_t *, credentials_t *, + params_t *params, cmd_response_data_t *); +char * get_trash_report_formats_gmp (gvm_connection_t *, credentials_t *, params_t *params, cmd_response_data_t *); char * diff --git a/src/gsad_validator.c b/src/gsad_validator.c index 312438533..87745e475 100644 --- a/src/gsad_validator.c +++ b/src/gsad_validator.c @@ -203,6 +203,7 @@ init_validator () "|(get_trash_overrides)" "|(get_trash_permissions)" "|(get_trash_port_lists)" + "|(get_trash_report_configs)" "|(get_trash_report_formats)" "|(get_trash_roles)" "|(get_trash_scanners)"