@@ -160,6 +160,7 @@ def __init__(self, filename: str, data_dict_yaml: Dict[Any, Any]):
160
160
)
161
161
162
162
func_profile = FunctionProfile (elem )
163
+ logger .info (f"Adding { func_profile .function_name } " )
163
164
self .all_class_functions [func_profile .function_name ] = func_profile
164
165
165
166
def refine_paths (self , basefolder : str ) -> None :
@@ -187,9 +188,21 @@ def set_all_reached_functions(self) -> None:
187
188
sets self.functions_reached_by_fuzzer to all functions reached
188
189
by LLVMFuzzerTestOneInput
189
190
"""
190
- self .functions_reached_by_fuzzer = (self
191
- .all_class_functions ["LLVMFuzzerTestOneInput" ]
192
- .functions_reached )
191
+ if "LLVMFuzzerTestOneInput" in self .all_class_functions :
192
+ self .functions_reached_by_fuzzer = (
193
+ self .all_class_functions ["LLVMFuzzerTestOneInput" ].functions_reached
194
+ )
195
+ return
196
+
197
+ # Find Python entrypoint
198
+ for func_name in self .all_class_functions :
199
+ if "TestOneInput" in func_name :
200
+ reached = self .all_class_functions [func_name ].functions_reached
201
+ self .functions_reached_by_fuzzer = reached
202
+ return
203
+
204
+ # TODO: make fuzz-introspector exceptions
205
+ raise Exception
193
206
194
207
def reaches (self , func_name : str ) -> bool :
195
208
return func_name in self .functions_reached_by_fuzzer
@@ -495,12 +508,21 @@ def get_function_summaries(self) -> Tuple[int, int, int, float, float]:
495
508
)
496
509
497
510
def get_complexity_summaries (self ) -> Tuple [int , int , int , float , float ]:
498
-
499
511
complexity_reached , complexity_unreached = self .get_total_complexity ()
500
512
total_complexity = complexity_unreached + complexity_reached
501
513
502
- reached_complexity_percentage = (float (complexity_reached ) / (total_complexity )) * 100.0
503
- unreached_complexity_percentage = (float (complexity_unreached ) / (total_complexity )) * 100.0
514
+ try :
515
+ reached_complexity_percentage = (float (complexity_reached ) / (total_complexity )) * 100.0
516
+ except Exception :
517
+ logger .info ("Total complexity is 0" )
518
+ reached_complexity_percentage = 0
519
+ try :
520
+ unreached_complexity_percentage = (
521
+ (float (complexity_unreached ) / (total_complexity )) * 100.0
522
+ )
523
+ except Exception :
524
+ logger .info ("Total complexity is 0" )
525
+ unreached_complexity_percentage = 0
504
526
505
527
return (
506
528
total_complexity ,
@@ -560,10 +582,19 @@ def read_fuzzer_data_file_to_profile(filename: str) -> Optional[FuzzerProfile]:
560
582
return None
561
583
562
584
FP = FuzzerProfile (filename , data_dict_yaml )
563
- if "LLVMFuzzerTestOneInput" not in FP .all_class_functions :
564
- return None
565
585
566
- return FP
586
+ # Check we have a valid entrypoint
587
+ if "LLVMFuzzerTestOneInput" in FP .all_class_functions :
588
+ return FP
589
+
590
+ # Check for python fuzzers. The following assumes the entrypoint
591
+ # currently has "TestOneInput" int its name
592
+ for name in FP .all_class_functions :
593
+ if "TestOneInput" in name :
594
+ return FP
595
+
596
+ logger .info ("Found no fuzzer entrypoints" )
597
+ return None
567
598
568
599
569
600
def add_func_to_reached_and_clone (merged_profile_old : MergedProjectProfile ,
0 commit comments