From 6dbefbddecaed1367a6b90cb1a72ab81bd4b14e8 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Wed, 18 Dec 2019 15:10:58 +0100 Subject: [PATCH 1/3] Apply usage_type of tasks in get_aggregates The option was only applied for configs and ignored for tasks before. --- src/manage_sql.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 026992295..189d1a824 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -64721,10 +64721,8 @@ type_extra_where (const char *type, int trash, const char *filter, } else if (strcasecmp (type, "TASK") == 0) { - if (trash) - extra_where = g_strdup (" AND hidden = 2"); - else - extra_where = g_strdup (" AND hidden = 0"); + gchar *usage_type = g_hash_table_lookup (extra_params, "usage_type"); + extra_where = tasks_extra_where (trash, usage_type); } else if (strcasecmp (type, "TLS_CERTIFICATE") == 0) { From 2bb2d47319c4fa18ac1b6ac1c6d98220e558cfa6 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Wed, 18 Dec 2019 15:13:12 +0100 Subject: [PATCH 2/3] Add tasks usage_type fix to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee11f2812..2b7593975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Use right format specifier for merge_ovaldef version [#874](https://github.com/greenbone/gvmd/pull/874) - Fix creation of "Super" permissions [#892](https://github.com/greenbone/gvmd/pull/892) - Setup general task preferences to launch an osp openvas task. [#898](https://github.com/greenbone/gvmd/pull/898) +- Apply usage_type of tasks in get_aggregates (9.0) [#912](https://github.com/greenbone/gvmd/pull/912) ### Removed - Remove 1.3.6.1.4.1.25623.1.0.90011 from Discovery config (9.0) [#847](https://github.com/greenbone/gvmd/pull/847) From b7cbe85c6b91359337d501f332600b4241e82dec Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Thu, 19 Dec 2019 14:19:51 +0100 Subject: [PATCH 3/3] Test if extra_params is NULL in type_extra_where If no extra parameters like usage_type are set g_hash_table_lookup would otherwise generate a warning. --- src/manage_sql.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 189d1a824..0994a5278 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -64714,14 +64714,24 @@ type_extra_where (const char *type, int trash, const char *filter, if (strcasecmp (type, "CONFIG") == 0 && extra_params) { - gchar *usage_type = g_hash_table_lookup (extra_params, "usage_type"); + gchar *usage_type; + if (extra_params) + usage_type = g_hash_table_lookup (extra_params, "usage_type"); + else + usage_type = NULL; + extra_where = configs_extra_where (usage_type); if (extra_where == NULL) extra_where = g_strdup (""); } else if (strcasecmp (type, "TASK") == 0) { - gchar *usage_type = g_hash_table_lookup (extra_params, "usage_type"); + gchar *usage_type; + if (extra_params) + usage_type = g_hash_table_lookup (extra_params, "usage_type"); + else + usage_type = NULL; + extra_where = tasks_extra_where (trash, usage_type); } else if (strcasecmp (type, "TLS_CERTIFICATE") == 0)