Skip to content
Merged
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
201 changes: 105 additions & 96 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -16619,6 +16619,19 @@ struct print_report_context
int warnings; ///< Number of warnings.
int false_positives; ///< Number of false positives.
int total_result_count; ///< Total number of results.
// Filtered counts.
GHashTable *f_host_false_positives; ///< False positives per host.
GHashTable *f_host_holes; ///< Holes per host.
GHashTable *f_host_infos; ///< Infos per host.
GHashTable *f_host_logs; ///< Logs per hosts.
GHashTable *f_host_ports; ///< Ports per host.
GHashTable *f_host_warnings; ///< Warnings per hosts.
// Filtered counts: audit.
GHashTable *f_host_criticals; ///< Criticals per host.
GHashTable *f_host_compliant; ///< Compliants per host.
GHashTable *f_host_incomplete; ///< Incompletes per host.
GHashTable *f_host_notcompliant; ///< Notcompliants per host.
GHashTable *f_host_undefined; ///< Undefineds per host.
};

/**
Expand Down Expand Up @@ -16777,12 +16790,6 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
int search_phrase_exact, apply_overrides;
double severity, f_severity;
GString *filters_buffer, *filters_extra_buffer, *host_summary_buffer;
GHashTable *f_host_ports;
GHashTable *f_host_holes, *f_host_warnings, *f_host_infos;
GHashTable *f_host_logs, *f_host_false_positives;
GHashTable *f_host_compliant, *f_host_notcompliant;
GHashTable *f_host_incomplete, *f_host_undefined;
GHashTable *f_host_criticals = NULL;
task_status_t run_status;
int f_compliance_yes, f_compliance_no;
int f_compliance_incomplete, f_compliance_undefined;
Expand All @@ -16801,16 +16808,17 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
orig_f_false_positives = orig_f_warnings = orig_f_logs = orig_f_infos = 0;
orig_f_holes = orig_f_criticals = 0;
host_summary_buffer = NULL;
f_host_ports = NULL;
f_host_holes = NULL;
f_host_warnings = NULL;
f_host_infos = NULL;
f_host_logs = NULL;
f_host_false_positives = NULL;
f_host_compliant = NULL;
f_host_notcompliant = NULL;
f_host_incomplete = NULL;
f_host_undefined = NULL;
ctx.f_host_criticals = NULL;
ctx.f_host_ports = NULL;
ctx.f_host_holes = NULL;
ctx.f_host_warnings = NULL;
ctx.f_host_infos = NULL;
ctx.f_host_logs = NULL;
ctx.f_host_false_positives = NULL;
ctx.f_host_compliant = NULL;
ctx.f_host_notcompliant = NULL;
ctx.f_host_incomplete = NULL;
ctx.f_host_undefined = NULL;

ctx.delta = delta;
ctx.get = get;
Expand Down Expand Up @@ -17348,18 +17356,19 @@ print_report_xml_start (report_t report, report_t delta, task_t task,

/* Port summary. */

f_host_ports = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_ports = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);

reuse_result_iterator = 0;
if (get->details && (delta == 0))
{
reuse_result_iterator = 1;
if (print_report_port_xml (report, out, get, first_result, max_results,
sort_order, sort_field, f_host_ports, &results))
sort_order, sort_field, ctx.f_host_ports,
&results))
{
g_free (term);
g_hash_table_destroy (f_host_ports);
g_hash_table_destroy (ctx.f_host_ports);
goto fail;
}
}
Expand Down Expand Up @@ -17430,7 +17439,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
get, term, sort_field))
{
g_free (term);
g_hash_table_destroy (f_host_ports);
g_hash_table_destroy (ctx.f_host_ports);
goto fail;
}
}
Expand All @@ -17445,7 +17454,7 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
res = init_result_get_iterator (&results, get, report, NULL, NULL);
if (res)
{
g_hash_table_destroy (f_host_ports);
g_hash_table_destroy (ctx.f_host_ports);
goto fail;
}
}
Expand All @@ -17469,29 +17478,30 @@ print_report_xml_start (report_t report, report_t delta, task_t task,

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);
f_host_notcompliant = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_incomplete = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_undefined = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_compliant = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_notcompliant = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_incomplete = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_undefined = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
}
else
{
f_host_criticals = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_holes = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_warnings = g_hash_table_new_full (g_str_hash, g_str_equal,
ctx.f_host_criticals = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_holes = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_warnings = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_infos = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_logs = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_infos = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_logs = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
f_host_false_positives = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
ctx.f_host_false_positives = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free, NULL);
}

if (delta && get->details)
Expand Down Expand Up @@ -17561,25 +17571,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;
f_host_result_counts = ctx.f_host_compliant;
if (ctx.count_filtered)
f_compliance_yes++;
}
else if (strcasecmp (compliance, "no") == 0)
{
f_host_result_counts = f_host_notcompliant;
f_host_result_counts = ctx.f_host_notcompliant;
if (ctx.count_filtered)
f_compliance_no++;
}
else if (strcasecmp (compliance, "incomplete") == 0)
{
f_host_result_counts = f_host_incomplete;
f_host_result_counts = ctx.f_host_incomplete;
if (ctx.count_filtered)
f_compliance_incomplete++;
}
else if (strcasecmp (compliance, "undefined") == 0)
{
f_host_result_counts = f_host_undefined;
f_host_result_counts = ctx.f_host_undefined;
if (ctx.count_filtered)
f_compliance_undefined++;
}
Expand Down Expand Up @@ -17612,37 +17622,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;
f_host_result_counts = ctx.f_host_logs;
if (ctx.count_filtered)
f_logs++;
}
else if (strcasecmp (level, "critical") == 0)
{
f_host_result_counts = f_host_criticals;
f_host_result_counts = ctx.f_host_criticals;
if (ctx.count_filtered)
f_criticals++;
}
else if (strcasecmp (level, "high") == 0)
{
f_host_result_counts = f_host_holes;
f_host_result_counts = ctx.f_host_holes;
if (ctx.count_filtered)
f_holes++;
}
else if (strcasecmp (level, "medium") == 0)
{
f_host_result_counts = f_host_warnings;
f_host_result_counts = ctx.f_host_warnings;
if (ctx.count_filtered)
f_warnings++;
}
else if (strcasecmp (level, "low") == 0)
{
f_host_result_counts = f_host_infos;
f_host_result_counts = ctx.f_host_infos;
if (ctx.count_filtered)
f_infos++;
}
else if (strcasecmp (level, "false positive") == 0)
{
f_host_result_counts = f_host_false_positives;
f_host_result_counts = ctx.f_host_false_positives;
if (ctx.count_filtered)
f_false_positives++;
}
Expand Down Expand Up @@ -17846,17 +17856,17 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
ctx.tsk_usage_type,
lean,
host_summary_buffer,
f_host_ports,
f_host_criticals,
f_host_holes,
f_host_warnings,
f_host_infos,
f_host_logs,
f_host_false_positives,
f_host_compliant,
f_host_notcompliant,
f_host_incomplete,
f_host_undefined))
ctx.f_host_ports,
ctx.f_host_criticals,
ctx.f_host_holes,
ctx.f_host_warnings,
ctx.f_host_infos,
ctx.f_host_logs,
ctx.f_host_false_positives,
ctx.f_host_compliant,
ctx.f_host_notcompliant,
ctx.f_host_incomplete,
ctx.f_host_undefined))
{
goto failed_print_report_host;
}
Expand All @@ -17876,39 +17886,38 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
ctx.tsk_usage_type,
lean,
host_summary_buffer,
f_host_ports,
f_host_criticals,
f_host_holes,
f_host_warnings,
f_host_infos,
f_host_logs,
f_host_false_positives,
f_host_compliant,
f_host_notcompliant,
f_host_incomplete,
f_host_undefined))

ctx.f_host_ports,
ctx.f_host_criticals,
ctx.f_host_holes,
ctx.f_host_warnings,
ctx.f_host_infos,
ctx.f_host_logs,
ctx.f_host_false_positives,
ctx.f_host_compliant,
ctx.f_host_notcompliant,
ctx.f_host_incomplete,
ctx.f_host_undefined))
goto failed_print_report_host;
}
cleanup_iterator (&hosts);
}
if (strcmp (ctx.tsk_usage_type, "audit") == 0)
{
g_hash_table_destroy (f_host_compliant);
g_hash_table_destroy (f_host_notcompliant);
g_hash_table_destroy (f_host_incomplete);
g_hash_table_destroy (f_host_undefined);
g_hash_table_destroy (ctx.f_host_compliant);
g_hash_table_destroy (ctx.f_host_notcompliant);
g_hash_table_destroy (ctx.f_host_incomplete);
g_hash_table_destroy (ctx.f_host_undefined);
}
else
{
g_hash_table_destroy (f_host_criticals);
g_hash_table_destroy (f_host_holes);
g_hash_table_destroy (f_host_warnings);
g_hash_table_destroy (f_host_infos);
g_hash_table_destroy (f_host_logs);
g_hash_table_destroy (f_host_false_positives);
g_hash_table_destroy (ctx.f_host_criticals);
g_hash_table_destroy (ctx.f_host_holes);
g_hash_table_destroy (ctx.f_host_warnings);
g_hash_table_destroy (ctx.f_host_infos);
g_hash_table_destroy (ctx.f_host_logs);
g_hash_table_destroy (ctx.f_host_false_positives);
}
g_hash_table_destroy (f_host_ports);
g_hash_table_destroy (ctx.f_host_ports);

/* Print TLS certificates */

Expand Down Expand Up @@ -18011,24 +18020,24 @@ print_report_xml_start (report_t report, report_t delta, task_t task,
failed_print_report_host:
if (host_summary_buffer)
g_string_free (host_summary_buffer, TRUE);
g_hash_table_destroy (f_host_ports);
g_hash_table_destroy (ctx.f_host_ports);

g_free (compliance_levels);
if (strcmp (ctx.tsk_usage_type, "audit") == 0)
{
g_hash_table_destroy (f_host_compliant);
g_hash_table_destroy (f_host_notcompliant);
g_hash_table_destroy (f_host_incomplete);
g_hash_table_destroy (f_host_undefined);
g_hash_table_destroy (ctx.f_host_compliant);
g_hash_table_destroy (ctx.f_host_notcompliant);
g_hash_table_destroy (ctx.f_host_incomplete);
g_hash_table_destroy (ctx.f_host_undefined);
}
else
{
g_hash_table_destroy (f_host_criticals);
g_hash_table_destroy (f_host_holes);
g_hash_table_destroy (f_host_warnings);
g_hash_table_destroy (f_host_infos);
g_hash_table_destroy (f_host_logs);
g_hash_table_destroy (f_host_false_positives);
g_hash_table_destroy (ctx.f_host_criticals);
g_hash_table_destroy (ctx.f_host_holes);
g_hash_table_destroy (ctx.f_host_warnings);
g_hash_table_destroy (ctx.f_host_infos);
g_hash_table_destroy (ctx.f_host_logs);
g_hash_table_destroy (ctx.f_host_false_positives);
}
fail:
tz_revert (ctx.zone, ctx.tz, ctx.old_tz_override);
Expand Down
Loading