Skip to content

Commit b585b86

Browse files
jjnicolabjoernricks
authored andcommitted
Change: scan progress calculation.
Since the information send by openvasd changed.
1 parent 69bf2f0 commit b585b86

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

openvasd/openvasd.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,26 @@ openvasd_get_scan_progress_ext (openvasd_connector_t conn,
10061006
cJSON *host = scanning->child;
10071007
while (host)
10081008
{
1009-
running_hosts_progress_sum += cJSON_GetNumberValue (host);
1009+
int finished_tests, total_tests, single_host_progress;
1010+
1011+
if (!cJSON_IsObject (host))
1012+
{
1013+
progress = 0;
1014+
goto cleanup;
1015+
}
1016+
1017+
finished_tests = get_member_value_or_fail (host, "finished_tests");
1018+
total_tests = get_member_value_or_fail (host, "total_tests");
1019+
1020+
if (total_tests <= 0 || finished_tests < 0)
1021+
{
1022+
progress = 0;
1023+
goto cleanup;
1024+
}
1025+
1026+
single_host_progress = (100 * finished_tests / total_tests);
1027+
1028+
running_hosts_progress_sum += single_host_progress;
10101029
host = host->next;
10111030
}
10121031
}
@@ -1021,7 +1040,7 @@ openvasd_get_scan_progress_ext (openvasd_connector_t conn,
10211040
progress = (running_hosts_progress_sum + 100 * (alive + finished))
10221041
/ (all + finished - dead);
10231042
else
1024-
progress = 100;
1043+
progress = 0;
10251044

10261045
cleanup:
10271046
if (err != NULL)

0 commit comments

Comments
 (0)