Skip to content

Commit

Permalink
fix stop scan
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Jul 17, 2024
1 parent bafda40 commit 8182e40
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -7647,7 +7647,7 @@ delete_resource (const char *type, const char *resource_id, int ultimate)
static int
stop_openvasd_task (task_t task)
{
int ret = -1;
int ret = 0;
report_t scan_report;
char *scan_id;
task_t previous_task;
Expand All @@ -7659,29 +7659,33 @@ stop_openvasd_task (task_t task)

previous_task = current_scanner_task;
previous_report = global_current_report;

scan_report = task_running_report (task);
scan_id = report_uuid (scan_report);
if (!scan_id)
goto end_stop_openvasd;
{
ret = -1;
goto end_stop_openvasd;
}
scanner = task_scanner (task);
connector = openvasd_scanner_connect (scanner, scan_id);
if (!connector)
goto end_stop_openvasd;
{
ret = -1;
goto end_stop_openvasd;
}

current_scanner_task = task;
global_current_report = task_running_report (task);
set_task_run_status (task, TASK_STATUS_STOP_REQUESTED);
response = openvasd_stop_scan (&connector);
if (response->code < 0)
{
ret = -1;
g_free (scan_id);
goto end_stop_openvasd;
}

response = openvasd_delete_scan (&connector);
g_free (scan_id);

end_stop_openvasd:
openvasd_connector_free(&connector);
set_task_end_time_epoch (task, time (NULL));
Expand All @@ -7693,9 +7697,8 @@ stop_openvasd_task (task_t task)
}
current_scanner_task = previous_task;
global_current_report = previous_report;
if (ret)
return -1;
return 0;

return ret;
}

/**
Expand Down

0 comments on commit 8182e40

Please sign in to comment.