Skip to content

Commit

Permalink
Fix: Handle missing report getting task severity
Browse files Browse the repository at this point in the history
The task_severity_double function now no longer tries to get the
severity from an undefined report if no report matches the criteria.
Instead it passes the report row id 0 to report_severity, which will
always return SEVERITY_MISSING in this case.

This fixes the check for the "Severity changed" alert condition not
working correctly if the task has no second report for comparison.
  • Loading branch information
timopollmeier committed Aug 9, 2023
1 parent d80473b commit 91aebae
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -18861,13 +18861,12 @@ task_severity_double (task_t task, int overrides, int min_qod, int offset)
|| task_target (task) == 0 /* Container task. */)
return SEVERITY_MISSING;

sql_int64 (&report,
"SELECT id FROM reports"
" WHERE reports.task = %llu"
" AND reports.scan_run_status = %u"
" ORDER BY reports.creation_time DESC"
" LIMIT 1 OFFSET %d",
task, TASK_STATUS_DONE, offset);
report = sql_int64_0 ("SELECT id FROM reports"
" WHERE reports.task = %llu"
" AND reports.scan_run_status = %u"
" ORDER BY reports.creation_time DESC"
" LIMIT 1 OFFSET %d",
task, TASK_STATUS_DONE, offset);

return report_severity (report, overrides, min_qod);
}
Expand Down Expand Up @@ -24694,6 +24693,9 @@ report_severity (report_t report, int overrides, int min_qod)
double severity;
iterator_t iterator;

if (report == 0)
return SEVERITY_MISSING;

init_iterator (&iterator,
"SELECT max(severity)"
" FROM report_counts"
Expand Down

0 comments on commit 91aebae

Please sign in to comment.