File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff 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
10261045cleanup :
10271046 if (err != NULL )
You can’t perform that action at this time.
0 commit comments