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

Merged
merged 1 commit into from
May 27, 2025
Merged
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 @@ -1006,7 +1006,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 1014 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1013-L1014

Added lines #L1013 - L1014 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 1018 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1017-L1018

Added lines #L1017 - L1018 were not covered by tests

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

Check warning on line 1023 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1022-L1023

Added lines #L1022 - L1023 were not covered by tests
}

single_host_progress = (100 * finished_tests / total_tests);

Check warning on line 1026 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1026

Added line #L1026 was not covered by tests

running_hosts_progress_sum += single_host_progress;

Check warning on line 1028 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1028

Added line #L1028 was not covered by tests
host = host->next;
}
}
Expand All @@ -1021,7 +1040,7 @@
progress = (running_hosts_progress_sum + 100 * (alive + finished))
/ (all + finished - dead);
else
progress = 100;
progress = 0;

Check warning on line 1043 in openvasd/openvasd.c

View check run for this annotation

Codecov / codecov/patch

openvasd/openvasd.c#L1043

Added line #L1043 was not covered by tests

cleanup:
if (err != NULL)
Expand Down