Skip to content

Commit

Permalink
Fix: Handle alert_filter_get with and without a filter selected.
Browse files Browse the repository at this point in the history
Merge pull request #2148 from greenbone/GEA-469_scans_interrupted_by_alerts
  • Loading branch information
jhelmold authored Mar 7, 2024
2 parents 6a0f436 + f283ea2 commit 56eaac9
Showing 1 changed file with 41 additions and 40 deletions.
81 changes: 41 additions & 40 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -12139,25 +12139,21 @@ generate_alert_filter_get (alert_t alert, const get_data_t *base_get_data,
if (filter_return)
*filter_return = filter;

(*alert_filter_get) = g_malloc0 (sizeof (get_data_t));
(*alert_filter_get)->details = base_get_data->details;
(*alert_filter_get)->ignore_pagination = base_get_data->ignore_pagination;
(*alert_filter_get)->ignore_max_rows_per_page
= base_get_data->ignore_max_rows_per_page;

if (filter)
{
(*alert_filter_get) = g_malloc0 (sizeof (get_data_t));
(*alert_filter_get)->details = base_get_data->details;
(*alert_filter_get)->ignore_pagination = base_get_data->ignore_pagination;
(*alert_filter_get)->ignore_max_rows_per_page
= base_get_data->ignore_max_rows_per_page;
(*alert_filter_get)->filt_id = g_strdup (filt_id);
(*alert_filter_get)->filter = filter_term (filt_id);
}
else
(*alert_filter_get) = NULL;

ignore_pagination = alert_data (alert, "method",
"composer_ignore_pagination");
if (ignore_pagination)
{
(*alert_filter_get)->ignore_pagination = atoi (ignore_pagination);
g_free (ignore_pagination);
(*alert_filter_get)->filt_id = NULL;
(*alert_filter_get)->filter = g_strdup("");
}

/* Adjust filter for report composer.
Expand All @@ -12168,39 +12164,44 @@ generate_alert_filter_get (alert_t alert, const get_data_t *base_get_data,
* We simply use these fields to adjust the filter. In the future we'll
* remove the filter terms and extend the way we get the report. */

if (filter)
gchar *include_notes, *include_overrides;

ignore_pagination = alert_data (alert, "method",
"composer_ignore_pagination");
if (ignore_pagination)
{
gchar *include_notes, *include_overrides;
(*alert_filter_get)->ignore_pagination = atoi (ignore_pagination);
g_free (ignore_pagination);
}

include_notes = alert_data (alert, "method",
"composer_include_notes");
if (include_notes)
{
gchar *new_filter;
include_notes = alert_data (alert, "method",
"composer_include_notes");
if (include_notes)
{
gchar *new_filter;

new_filter = g_strdup_printf ("notes=%i %s",
atoi (include_notes),
(*alert_filter_get)->filter);
g_free ((*alert_filter_get)->filter);
(*alert_filter_get)->filter = new_filter;
(*alert_filter_get)->filt_id = NULL;
g_free (include_notes);
}
new_filter = g_strdup_printf ("notes=%i %s",
atoi (include_notes),
(*alert_filter_get)->filter);
g_free ((*alert_filter_get)->filter);
(*alert_filter_get)->filter = new_filter;
(*alert_filter_get)->filt_id = NULL;
g_free (include_notes);
}

include_overrides = alert_data (alert, "method",
"composer_include_overrides");
if (include_overrides)
{
gchar *new_filter;
include_overrides = alert_data (alert, "method",
"composer_include_overrides");
if (include_overrides)
{
gchar *new_filter;

new_filter = g_strdup_printf ("overrides=%i %s",
atoi (include_overrides),
(*alert_filter_get)->filter);
g_free ((*alert_filter_get)->filter);
(*alert_filter_get)->filter = new_filter;
(*alert_filter_get)->filt_id = NULL;
g_free (include_overrides);
}
new_filter = g_strdup_printf ("overrides=%i %s",
atoi (include_overrides),
(*alert_filter_get)->filter);
g_free ((*alert_filter_get)->filter);
(*alert_filter_get)->filter = new_filter;
(*alert_filter_get)->filt_id = NULL;
g_free (include_overrides);
}

return 0;
Expand Down

0 comments on commit 56eaac9

Please sign in to comment.