Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve "Failed to find..." messages (20.08) #1395

Merged
merged 5 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Allow config to sync even if NVT family is not available [#1366](https://github.com/greenbone/gvmd/pull/1366)
- Delete report format dirs last when deleting a user [#1368](https://github.com/greenbone/gvmd/pull/1368)
- Fix sorting in get_aggregates and its documentation [#1375](https://github.com/greenbone/gvmd/pull/1375)
- Improve "Failed to find..." messages [#1395](https://github.com/greenbone/gvmd/pull/1395)

### Removed
- Remove DROP from vulns creation [#1281](http://github.com/greenbone/gvmd/pull/1281)
Expand Down
25 changes: 15 additions & 10 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11133,7 +11133,7 @@ handle_get_alerts (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_alerts", "alert", get_alerts_data->get.filt_id,
("get_alerts", "filter", get_alerts_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -11697,7 +11697,7 @@ handle_get_configs (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_configs", "config", get_configs_data->get.filt_id,
("get_configs", "filter", get_configs_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -12067,7 +12067,7 @@ handle_get_credentials (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client ("get_credentials",
"credential",
"filter",
get_credentials_data->get.filt_id,
gmp_parser))
{
Expand Down Expand Up @@ -12856,7 +12856,7 @@ handle_get_groups (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_groups", "group", get_groups_data->get.filt_id,
("get_groups", "filter", get_groups_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -13112,8 +13112,13 @@ handle_get_info (gmp_parser_t *gmp_parser, GError **error)
switch (ret)
{
case 1:
if (send_find_error_to_client ("get_info", "type",
get_info_data->type,
if (send_find_error_to_client ("get_info",
get_info_data->name
? "name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would break if name/id contained a ".

It was safe for type because it's checked above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a general issue with send_find_error_to_client that was only avoided so far because of the id validation in GSA, so I'll change that function to XML escape the input.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue should be addressed with 9504567.

: "ID",
get_info_data->name
? get_info_data->name
: get_info_data->get.id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -14027,7 +14032,7 @@ handle_get_port_lists (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_port_lists", "port_list",
("get_port_lists", "filter",
get_port_lists_data->get.filt_id, gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -15360,7 +15365,7 @@ handle_get_roles (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_roles", "role", get_roles_data->get.filt_id,
("get_roles", "filter", get_roles_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -16940,7 +16945,7 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_tasks", "task", get_tasks_data->get.filt_id,
("get_tasks", "filter", get_tasks_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down Expand Up @@ -17658,7 +17663,7 @@ handle_get_users (gmp_parser_t *gmp_parser, GError **error)
break;
case 2:
if (send_find_error_to_client
("get_users", "user", get_users_data->get.filt_id,
("get_users", "filter", get_users_data->get.filt_id,
gmp_parser))
{
error_send_to_client (error);
Expand Down
8 changes: 4 additions & 4 deletions src/gmp_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ send_find_error_to_client (const char* command, const char* type,
gchar *msg;
gboolean ret;

msg = g_strdup_printf ("<%s_response status=\""
STATUS_ERROR_MISSING
"\" status_text=\"Failed to find %s '%s'\"/>",
command, type, id);
msg = g_markup_printf_escaped ("<%s_response status=\""
STATUS_ERROR_MISSING
"\" status_text=\"Failed to find %s '%s'\"/>",
command, type, id);
ret = send_to_client (msg, gmp_parser->client_writer,
gmp_parser->client_writer_data);
g_free (msg);
Expand Down