From 85bc69b328033d2bbfad988fa31a7f7433d23452 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 18 Dec 2025 14:23:55 +0200 Subject: [PATCH 1/7] Change: move count_filtered into the report printing context --- src/manage_sql.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 93e671dac..7c5baf678 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17564,6 +17564,7 @@ print_report_clean_filter (gchar **term, const get_data_t *get) */ struct print_report_context { + int count_filtered; ///< Whether to count filtered results. gchar *tz; ///< TZ. gchar *zone; ///< Zone. char *old_tz_override; ///< Old TZ. @@ -17671,7 +17672,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, int f_criticals = 0, f_holes, f_infos, f_logs, f_warnings, f_false_positives; int orig_f_criticals, orig_f_holes, orig_f_infos, orig_f_logs; int orig_f_warnings, orig_f_false_positives, orig_filtered_result_count; - int search_phrase_exact, apply_overrides, count_filtered; + int search_phrase_exact, apply_overrides; double severity, f_severity; GString *filters_buffer, *filters_extra_buffer, *host_summary_buffer; GHashTable *f_host_ports; @@ -17860,7 +17861,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, ""); } - count_filtered = (delta || (ignore_pagination && get->details)); + ctx.count_filtered = (delta || (ignore_pagination && get->details)); if (report) { @@ -17889,7 +17890,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, /* Get total counts of filtered results. */ - if (count_filtered) + if (ctx.count_filtered) { /* We're getting all the filtered results, so we can count them as we * print them, to save time. */ @@ -18319,7 +18320,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, f_compliance_yes = f_compliance_no = 0; f_compliance_incomplete = f_compliance_undefined = 0; - if (count_filtered == 0) + if (ctx.count_filtered == 0) { report_compliance_f_counts (report, get, @@ -18336,7 +18337,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, } else { - if (count_filtered) + if (ctx.count_filtered) { /* We're getting all the filtered results, so we can count them as we * print them, to save time. */ @@ -18499,25 +18500,25 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (strcasecmp (compliance, "yes") == 0) { f_host_result_counts = f_host_compliant; - if (count_filtered) + if (ctx.count_filtered) f_compliance_yes++; } else if (strcasecmp (compliance, "no") == 0) { f_host_result_counts = f_host_notcompliant; - if (count_filtered) + if (ctx.count_filtered) f_compliance_no++; } else if (strcasecmp (compliance, "incomplete") == 0) { f_host_result_counts = f_host_incomplete; - if (count_filtered) + if (ctx.count_filtered) f_compliance_incomplete++; } else if (strcasecmp (compliance, "undefined") == 0) { f_host_result_counts = f_host_undefined; - if (count_filtered) + if (ctx.count_filtered) f_compliance_undefined++; } else @@ -18550,37 +18551,37 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (strcasecmp (level, "log") == 0) { f_host_result_counts = f_host_logs; - if (count_filtered) + if (ctx.count_filtered) f_logs++; } else if (strcasecmp (level, "critical") == 0) { f_host_result_counts = f_host_criticals; - if (count_filtered) + if (ctx.count_filtered) f_criticals++; } else if (strcasecmp (level, "high") == 0) { f_host_result_counts = f_host_holes; - if (count_filtered) + if (ctx.count_filtered) f_holes++; } else if (strcasecmp (level, "medium") == 0) { f_host_result_counts = f_host_warnings; - if (count_filtered) + if (ctx.count_filtered) f_warnings++; } else if (strcasecmp (level, "low") == 0) { f_host_result_counts = f_host_infos; - if (count_filtered) + if (ctx.count_filtered) f_infos++; } else if (strcasecmp (level, "false positive") == 0) { f_host_result_counts = f_host_false_positives; - if (count_filtered) + if (ctx.count_filtered) f_false_positives++; } else @@ -18624,7 +18625,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, (strchr (compliance_levels, 'u') ? f_compliance_undefined : 0)); else { - if (count_filtered) + if (ctx.count_filtered) f_compliance_count = f_compliance_yes + f_compliance_no + f_compliance_incomplete @@ -18697,7 +18698,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, (strchr (levels, 'f') ? orig_f_false_positives : 0)); else { - if (count_filtered) + if (ctx.count_filtered) filtered_result_count = f_criticals + f_holes + f_infos + f_logs + f_warnings + f_false_positives; From 0a4ed7d6c3a0125c47d0e10c4d1dfea7722cbc19 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 18 Dec 2025 14:31:48 +0200 Subject: [PATCH 2/7] Change: move filtered_result_count into the report printing context --- src/manage_sql.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index 7c5baf678..b1f742705 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17564,10 +17564,11 @@ print_report_clean_filter (gchar **term, const get_data_t *get) */ struct print_report_context { - int count_filtered; ///< Whether to count filtered results. - gchar *tz; ///< TZ. - gchar *zone; ///< Zone. - char *old_tz_override; ///< Old TZ. + int count_filtered; ///< Whether to count filtered results. + int filtered_result_count; ///< Filtered result count. + gchar *tz; ///< TZ. + gchar *zone; ///< Zone. + char *old_tz_override; ///< Old TZ. }; /** @@ -17664,7 +17665,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, gchar *delta_states, *timestamp; int min_qod_int; char *uuid, *tsk_uuid = NULL, *start_time, *end_time; - int total_result_count, filtered_result_count; + int total_result_count; array_t *result_hosts; int reuse_result_iterator; iterator_t results, delta_results; @@ -17695,7 +17696,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, delta_states = NULL; min_qod = NULL; search_phrase = NULL; - total_result_count = filtered_result_count = 0; + total_result_count = 0; f_compliance_count = 0; orig_filtered_result_count = 0; orig_f_false_positives = orig_f_warnings = orig_f_logs = orig_f_infos = 0; @@ -17895,7 +17896,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, /* We're getting all the filtered results, so we can count them as we * print them, to save time. */ - filtered_result_count = 0; + ctx.filtered_result_count = 0; } else { @@ -17904,8 +17905,8 @@ print_report_xml_start (report_t report, report_t delta, task_t task, report_counts_id (report, &criticals, &holes, &infos, &logs, &warnings, &false_positives, NULL, get, NULL); - filtered_result_count = criticals + holes + infos + logs + warnings - + false_positives; + ctx.filtered_result_count = criticals + holes + infos + logs + + warnings + false_positives; } } @@ -18442,7 +18443,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, overrides_details, sort_order, sort_field, result_hosts_only, &orig_filtered_result_count, - &filtered_result_count, + &ctx.filtered_result_count, &orig_f_criticals, &f_criticals, &orig_f_holes, &f_holes, &orig_f_infos, &f_infos, @@ -18699,8 +18700,8 @@ print_report_xml_start (report_t report, report_t delta, task_t task, else { if (ctx.count_filtered) - filtered_result_count = f_criticals + f_holes + f_infos + f_logs - + f_warnings + f_false_positives; + ctx.filtered_result_count = f_criticals + f_holes + f_infos + f_logs + + f_warnings + f_false_positives; PRINT (out, "" @@ -18725,7 +18726,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, "", total_result_count, total_result_count, - filtered_result_count, + ctx.filtered_result_count, criticals, (strchr (levels, 'c') ? f_criticals : 0), holes, From e38275bd578dc4895fabef55ed0f1eb2413f5347 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 22 Dec 2025 21:11:06 +0200 Subject: [PATCH 3/7] Change: move result counts into the report printing context --- src/manage_sql.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index b1f742705..a8ae1d79b 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17569,6 +17569,13 @@ struct print_report_context gchar *tz; ///< TZ. gchar *zone; ///< Zone. char *old_tz_override; ///< Old TZ. + // Counts. + int criticals; ///< Number of criticals. + int holes; ///< Number of holes. + int infos; ///< Number of infos. + int logs; ///< Number of logs. + int warnings; ///< Number of warnings. + int false_positives; ///< Number of false positives. }; /** @@ -17669,7 +17676,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, array_t *result_hosts; int reuse_result_iterator; iterator_t results, delta_results; - int criticals = 0, holes, infos, logs, warnings, false_positives; int f_criticals = 0, f_holes, f_infos, f_logs, f_warnings, f_false_positives; int orig_f_criticals, orig_f_holes, orig_f_infos, orig_f_logs; int orig_f_warnings, orig_f_false_positives, orig_filtered_result_count; @@ -17902,11 +17908,11 @@ print_report_xml_start (report_t report, report_t delta, task_t task, { /* Beware, we're using the full variables temporarily here, but * report_counts_id counts the filtered results. */ - report_counts_id (report, &criticals, &holes, &infos, &logs, &warnings, - &false_positives, NULL, get, NULL); + report_counts_id (report, &ctx.criticals, &ctx.holes, &ctx.infos, &ctx.logs, &ctx.warnings, + &ctx.false_positives, NULL, get, NULL); - ctx.filtered_result_count = criticals + holes + infos + logs - + warnings + false_positives; + ctx.filtered_result_count = ctx.criticals + ctx.holes + ctx.infos + ctx.logs + + ctx.warnings + ctx.false_positives; } } @@ -18342,8 +18348,8 @@ print_report_xml_start (report_t report, report_t delta, task_t task, { /* We're getting all the filtered results, so we can count them as we * print them, to save time. */ - report_counts_id_full (report, &criticals, &holes, &infos, &logs, - &warnings, &false_positives, &severity, + report_counts_id_full (report, &ctx.criticals, &ctx.holes, &ctx.infos, &ctx.logs, + &ctx.warnings, &ctx.false_positives, &severity, get, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); @@ -18351,8 +18357,8 @@ print_report_xml_start (report_t report, report_t delta, task_t task, f_false_positives = f_severity = 0; } else - report_counts_id_full (report, &criticals, &holes, &infos, &logs, - &warnings, &false_positives, &severity, + report_counts_id_full (report, &ctx.criticals, &ctx.holes, &ctx.infos, &ctx.logs, + &ctx.warnings, &ctx.false_positives, &severity, get, NULL, &f_criticals, &f_holes, &f_infos, &f_logs, &f_warnings, &f_false_positives, &f_severity); @@ -18727,23 +18733,23 @@ print_report_xml_start (report_t report, report_t delta, task_t task, total_result_count, total_result_count, ctx.filtered_result_count, - criticals, + ctx.criticals, (strchr (levels, 'c') ? f_criticals : 0), - holes, + ctx.holes, (strchr (levels, 'h') ? f_holes : 0), - holes, + ctx.holes, (strchr (levels, 'h') ? f_holes : 0), - infos, + ctx.infos, (strchr (levels, 'l') ? f_infos : 0), - infos, + ctx.infos, (strchr (levels, 'l') ? f_infos : 0), - logs, + ctx.logs, (strchr (levels, 'g') ? f_logs : 0), - warnings, + ctx.warnings, (strchr (levels, 'm') ? f_warnings : 0), - warnings, + ctx.warnings, (strchr (levels, 'm') ? f_warnings : 0), - false_positives, + ctx.false_positives, (strchr (levels, 'f') ? f_false_positives : 0)); PRINT (out, From c2cd1c13d125bbacf9822d3b801f0a3be8ea9dbe Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 22 Dec 2025 21:35:25 +0200 Subject: [PATCH 4/7] Change: move total_result_count into the report printing context --- src/manage_sql.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index a8ae1d79b..a2f253f0a 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17576,6 +17576,7 @@ struct print_report_context int logs; ///< Number of logs. int warnings; ///< Number of warnings. int false_positives; ///< Number of false positives. + int total_result_count; ///< Total number of results. }; /** @@ -17672,7 +17673,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, gchar *delta_states, *timestamp; int min_qod_int; char *uuid, *tsk_uuid = NULL, *start_time, *end_time; - int total_result_count; array_t *result_hosts; int reuse_result_iterator; iterator_t results, delta_results; @@ -17702,7 +17702,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, delta_states = NULL; min_qod = NULL; search_phrase = NULL; - total_result_count = 0; f_compliance_count = 0; orig_filtered_result_count = 0; orig_f_false_positives = orig_f_warnings = orig_f_logs = orig_f_infos = 0; @@ -17888,9 +17887,9 @@ print_report_xml_start (report_t report, report_t delta, task_t task, &total_false_positives, NULL, all_results_get, NULL); - total_result_count = total_criticals + total_holes + total_infos - + total_logs + total_warnings - + total_false_positives; + ctx.total_result_count = total_criticals + total_holes + + total_infos + total_logs + + total_warnings + total_false_positives; get_data_reset (all_results_get); free (all_results_get); } @@ -18730,8 +18729,8 @@ print_report_xml_start (report_t report, report_t delta, task_t task, "%i" "" "", - total_result_count, - total_result_count, + ctx.total_result_count, + ctx.total_result_count, ctx.filtered_result_count, ctx.criticals, (strchr (levels, 'c') ? f_criticals : 0), From 51c252dd4d3fae59d0e77fbcc2d4d3fff7135b92 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 22 Dec 2025 21:46:32 +0200 Subject: [PATCH 5/7] Change: move tsk_usage_type into the report printing context --- src/manage_sql.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index a2f253f0a..87c3b61ae 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17569,6 +17569,7 @@ struct print_report_context gchar *tz; ///< TZ. gchar *zone; ///< Zone. char *old_tz_override; ///< Old TZ. + gchar *tsk_usage_type; ///< Usage type of task, like "audit" // Counts. int criticals; ///< Number of criticals. int holes; ///< Number of holes. @@ -17592,6 +17593,7 @@ typedef struct print_report_context print_report_context_t; static void print_report_context_cleanup (print_report_context_t *ctx) { + g_free (ctx->tsk_usage_type); g_free (ctx->tz); g_free (ctx->zone); free (ctx->old_tz_override); @@ -17689,7 +17691,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, GHashTable *f_host_incomplete, *f_host_undefined; GHashTable *f_host_criticals = NULL; task_status_t run_status; - gchar *tsk_usage_type = NULL; int f_compliance_yes, f_compliance_no; int f_compliance_incomplete, f_compliance_undefined; int f_compliance_count; @@ -17789,7 +17790,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, levels = levels ? levels : g_strdup ("chmlgdf"); - if (task && (task_uuid (task, &tsk_uuid) || task_usage_type(task, &tsk_usage_type))) + if (task && (task_uuid (task, &tsk_uuid) || task_usage_type (task, &ctx.tsk_usage_type))) { fclose (out); g_free (term); @@ -17872,7 +17873,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (report) { /* Get total counts of full results. */ - if (strcmp (tsk_usage_type, "audit")) + if (strcmp (ctx.tsk_usage_type, "audit")) { if (delta == 0) { @@ -17933,7 +17934,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, filters_extra_buffer = g_string_new (""); - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { compliance_levels = compliance_levels ? compliance_levels : g_strdup ("yniu"); @@ -17991,7 +17992,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (report) { - const char *report_type = (strcmp (tsk_usage_type, "audit") == 0) + const char *report_type = (strcmp (ctx.tsk_usage_type, "audit") == 0) ? "audit_report" : "report"; int tag_count = resource_tag_count (report_type, report, 1); @@ -18073,7 +18074,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, gchar *progress_xml; iterator_t tags; - const char *task_type = (strcmp (tsk_usage_type, "audit") == 0) + const char *task_type = (strcmp (ctx.tsk_usage_type, "audit") == 0) ? "audit" : "task"; int task_tag_count = resource_tag_count (task_type, task, 1); @@ -18313,7 +18314,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, int compliance_incomplete = 0, compliance_undefined = 0; int total_compliance_count = 0; - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { report_compliance_counts (report, get, &compliance_yes, &compliance_no, &compliance_incomplete, &compliance_undefined); @@ -18411,7 +18412,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, /* Quiet erroneous compiler warning. */ result_hosts = NULL; - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { f_host_compliant = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -18498,7 +18499,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, array_add_new_string (result_hosts, result_iterator_host (&results)); - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { const char* compliance; compliance = result_iterator_compliance (&results); @@ -18613,7 +18614,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, /* Print result counts and severity. */ - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { if (delta) PRINT (out, @@ -18787,7 +18788,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (print_report_host_xml (out, &hosts, result_host, - tsk_usage_type, + ctx.tsk_usage_type, lean, host_summary_buffer, f_host_ports, @@ -18817,7 +18818,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (print_report_host_xml (out, &hosts, NULL, - tsk_usage_type, + ctx.tsk_usage_type, lean, host_summary_buffer, f_host_ports, @@ -18836,7 +18837,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, } cleanup_iterator (&hosts); } - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { g_hash_table_destroy (f_host_compliant); g_hash_table_destroy (f_host_notcompliant); @@ -18928,7 +18929,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task, g_free (min_qod); g_free (delta_states); g_free (compliance_levels); - g_free (tsk_usage_type); if (host_summary && host_summary_buffer) *host_summary = g_string_free (host_summary_buffer, FALSE); @@ -18959,7 +18959,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task, g_hash_table_destroy (f_host_ports); g_free (compliance_levels); - if (strcmp (tsk_usage_type, "audit") == 0) + if (strcmp (ctx.tsk_usage_type, "audit") == 0) { g_hash_table_destroy (f_host_compliant); g_hash_table_destroy (f_host_notcompliant); From d7495802e6e27a7efc7a6b4fb33e91ea4b08e910 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 22 Dec 2025 22:56:51 +0200 Subject: [PATCH 6/7] Change: add a few args to the report printing context --- src/manage_sql.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/manage_sql.c b/src/manage_sql.c index 87c3b61ae..f4b05e4fa 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17565,10 +17565,13 @@ print_report_clean_filter (gchar **term, const get_data_t *get) struct print_report_context { int count_filtered; ///< Whether to count filtered results. + report_t delta; ///< Report to compare with. int filtered_result_count; ///< Filtered result count. + const get_data_t *get; ///< GET command data. gchar *tz; ///< TZ. gchar *zone; ///< Zone. char *old_tz_override; ///< Old TZ. + report_t report; ///< Report. gchar *tsk_usage_type; ///< Usage type of task, like "audit" // Counts. int criticals; ///< Number of criticals. @@ -17719,6 +17722,10 @@ print_report_xml_start (report_t report, report_t delta, task_t task, f_host_incomplete = NULL; f_host_undefined = NULL; + ctx.delta = delta; + ctx.get = get; + ctx.report = report; + /** @todo Leaks on error in PRINT and PRINT_XML. The process normally exits * then anyway. */ From 132c4a2c4f27d37da0f4b74b742a34cfc5be8e1c Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 22 Dec 2025 22:58:24 +0200 Subject: [PATCH 7/7] Change: move total counting out of print_report_xml_start --- src/manage_sql.c | 96 ++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/src/manage_sql.c b/src/manage_sql.c index f4b05e4fa..16db462d3 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -17640,6 +17640,58 @@ print_report_init_zone (print_report_context_t *ctx) return 0; } +/** + * @brief Get result count totals for print_report_xml_start. + * + * @param[in] ctx Printing context. + */ +static void +print_report_get_totals (print_report_context_t *ctx) +{ + if (strcmp (ctx->tsk_usage_type, "audit")) + { + if (ctx->delta == 0) + { + int total_criticals = 0, total_holes, total_infos, total_logs; + int total_warnings, total_false_positives; + get_data_t *all_results_get; + + all_results_get = report_results_get_data (1, -1, 0, 0); + + report_counts_id (ctx->report, &total_criticals, &total_holes, + &total_infos, &total_logs, &total_warnings, + &total_false_positives, NULL, all_results_get, + NULL); + + ctx->total_result_count = total_criticals + total_holes + + total_infos + total_logs + + total_warnings + total_false_positives; + get_data_reset (all_results_get); + free (all_results_get); + } + + /* Get total counts of filtered results. */ + + if (ctx->count_filtered) + { + /* We're getting all the filtered results, so we can count them as we + * print them, to save time. */ + ctx->filtered_result_count = 0; + } + else + { + /* Beware, we're using the full variables temporarily here, but + * report_counts_id counts the filtered results. */ + report_counts_id (ctx->report, &ctx->criticals, &ctx->holes, &ctx->infos, &ctx->logs, &ctx->warnings, + &ctx->false_positives, NULL, ctx->get, NULL); + + ctx->filtered_result_count = ctx->criticals + ctx->holes + ctx->infos + ctx->logs + + ctx->warnings + ctx->false_positives; + + } + } +} + /** * @brief Print the main XML content for a report to a file. * @@ -17880,51 +17932,9 @@ print_report_xml_start (report_t report, report_t delta, task_t task, if (report) { /* Get total counts of full results. */ - if (strcmp (ctx.tsk_usage_type, "audit")) - { - if (delta == 0) - { - int total_criticals = 0, total_holes, total_infos, total_logs; - int total_warnings, total_false_positives; - get_data_t *all_results_get; - - all_results_get = report_results_get_data (1, -1, 0, 0); - - report_counts_id (report, &total_criticals, &total_holes, - &total_infos, &total_logs, &total_warnings, - &total_false_positives, NULL, all_results_get, - NULL); - - ctx.total_result_count = total_criticals + total_holes - + total_infos + total_logs - + total_warnings + total_false_positives; - get_data_reset (all_results_get); - free (all_results_get); - } - - /* Get total counts of filtered results. */ - - if (ctx.count_filtered) - { - /* We're getting all the filtered results, so we can count them as we - * print them, to save time. */ - - ctx.filtered_result_count = 0; - } - else - { - /* Beware, we're using the full variables temporarily here, but - * report_counts_id counts the filtered results. */ - report_counts_id (report, &ctx.criticals, &ctx.holes, &ctx.infos, &ctx.logs, &ctx.warnings, - &ctx.false_positives, NULL, get, NULL); - - ctx.filtered_result_count = ctx.criticals + ctx.holes + ctx.infos + ctx.logs - + ctx.warnings + ctx.false_positives; + print_report_get_totals (&ctx); - } - } /* Get report run status. */ - report_scan_run_status (report, &run_status); }