Skip to content

Change: scan progress calculation. #880

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
23 changes: 21 additions & 2 deletions openvasd/openvasd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,26 @@
cJSON *host = scanning->child;
while (host)
{
running_hosts_progress_sum += cJSON_GetNumberValue (host);
int finished_tests, total_tests, single_host_progress;

if (!cJSON_IsObject (host))
{
progress = 0;
goto cleanup;

Check warning on line 1324 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1323-L1324

Added lines #L1323 - L1324 were not covered by tests
}

finished_tests = get_member_value_or_fail (host, "finished_tests");
total_tests = get_member_value_or_fail (host, "total_tests");

Check warning on line 1328 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1327-L1328

Added lines #L1327 - L1328 were not covered by tests

if (total_tests <= 0 || finished_tests < 0)
{
progress = 0;
goto cleanup;

Check warning on line 1333 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1332-L1333

Added lines #L1332 - L1333 were not covered by tests
}

single_host_progress = (100 * finished_tests / total_tests);

Check warning on line 1336 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1336

Added line #L1336 was not covered by tests

running_hosts_progress_sum += single_host_progress;

Check warning on line 1338 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1338

Added line #L1338 was not covered by tests
host = host->next;
}

Expand All @@ -1333,7 +1352,7 @@
progress = (running_hosts_progress_sum + 100 * (alive + finished))
/ (all + finished - dead);
else
progress = 100;
progress = 0;

Check warning on line 1355 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1355

Added line #L1355 was not covered by tests

cleanup:
if (err != NULL)
Expand Down
Loading