Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle "interrupted" OSP status #1146

Merged
merged 2 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix and simplify parse_iso_time and add tests [#1129](https://github.com/greenbone/gvmd/pull/1129)
- Fix gvm-manage-certs. [#1140](https://github.com/greenbone/gvmd/pull/1140)
- Fix CVE scanner and results handling [#1141](https://github.com/greenbone/gvmd/pull/1141)
- Handle INTERRUPTED scans [#1146](https://github.com/greenbone/gvmd/pull/1146)

### Removed
- Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)
Expand Down
23 changes: 21 additions & 2 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ truncate_text (gchar *string, size_t max_len, gboolean xml, const char *suffix)
// move the offset to the start of that entity.
ssize_t entity_start_offset = offset;

while (entity_start_offset >= 0
while (entity_start_offset >= 0
&& string[entity_start_offset] != '&')
{
entity_start_offset --;
Expand Down Expand Up @@ -3545,7 +3545,8 @@ get_osp_scan_status (const char *scan_id, const char *host, int port,
* @param[in] report The report.
* @param[in] scan_id The UUID of the scan on the scanner.
*
* @return 0 if success, -1 if error, -2 if scan was stopped.
* @return 0 if success, -1 if error, -2 if scan was stopped,
* -3 if the scan was interrupted.
*/
static int
handle_osp_scan (task_t task, report_t report, const char *scan_id)
Expand Down Expand Up @@ -3628,6 +3629,19 @@ handle_osp_scan (task_t task, report_t report, const char *scan_id)
queued_status_updated = TRUE;
}
}
else if (osp_scan_status == OSP_SCAN_STATUS_INTERRUPTED)
{
result_t result = make_osp_result
(task, "", "", "",
threat_message_type ("Error"),
"Task interrupted unexpectedly", "", "",
QOD_DEFAULT);
report_add_result (report, result);
delete_osp_scan (scan_id, host, port, ca_pub, key_pub,
key_priv);
rc = -3;
break;
}
else if (progress >= 0 && progress < 100
&& osp_scan_status == OSP_SCAN_STATUS_STOPPED)
{
Expand Down Expand Up @@ -4560,6 +4574,11 @@ fork_osp_scan_handler (task_t task, target_t target, int from,
set_task_run_status (task, TASK_STATUS_STOPPED);
set_report_scan_run_status (global_current_report, TASK_STATUS_STOPPED);
}
else if (rc == -3)
{
set_task_run_status (task, TASK_STATUS_INTERRUPTED);
set_report_scan_run_status (global_current_report, TASK_STATUS_INTERRUPTED);
}

set_task_end_time_epoch (task, time (NULL));
set_scan_end_time_epoch (global_current_report, time (NULL));
Expand Down