@@ -289,6 +289,27 @@ def extract_local_project_data(project_name, oss_fuzz_path,
289289 debug_report = oss_fuzz .extract_local_introspector_debug_info (
290290 project_name , oss_fuzz_path )
291291
292+ if debug_report :
293+ all_files_in_project = debug_report .get ('all_files_in_project' , [])
294+ all_header_files_in_project = set ()
295+ for elem in all_files_in_project :
296+ source_file = elem .get ('source_file' , '' )
297+ if source_file .endswith ('.h' ):
298+ normalized_file = os .path .normpath (source_file )
299+ if '/usr/local/' in normalized_file or '/usr/include/' in normalized_file :
300+ continue
301+ all_header_files_in_project .add (normalized_file )
302+
303+ all_header_files = {
304+ 'project' : project_name .split ('###' )[0 ],
305+ 'all-header-files' : list (all_header_files_in_project )
306+ }
307+ else :
308+ all_header_files = {
309+ 'project' : project_name .split ('###' )[0 ],
310+ 'all-header-files' : list ()
311+ }
312+
292313 # Refine the data
293314 all_function_list = oss_fuzz .extract_local_introspector_function_list (
294315 project_name , oss_fuzz_path )
@@ -351,6 +372,7 @@ def extract_local_project_data(project_name, oss_fuzz_path,
351372 'project_timestamp' : project_timestamp ,
352373 "introspector-data-dict" : introspector_data_dict ,
353374 "coverage-data-dict" : code_coverage_data_dict ,
375+ 'all-header-files' : all_header_files ,
354376 }
355377
356378
@@ -449,6 +471,27 @@ def extract_project_data(project_name, date_str, should_include_details,
449471 else :
450472 debug_report = None
451473
474+ if debug_report :
475+ all_files_in_project = debug_report .get ('all_files_in_project' , [])
476+ all_header_files_in_project = set ()
477+ for elem in all_files_in_project :
478+ source_file = elem .get ('source_file' , '' )
479+ if source_file .endswith ('.h' ):
480+ normalized_file = os .path .normpath (source_file )
481+ if '/usr/local/' in normalized_file or '/usr/include/' in normalized_file :
482+ continue
483+ all_header_files_in_project .add (normalized_file )
484+
485+ all_header_files = {
486+ 'project' : project_name .split ('###' )[0 ],
487+ 'all-header-files' : list (all_header_files_in_project )
488+ }
489+ else :
490+ all_header_files = {
491+ 'project' : project_name .split ('###' )[0 ],
492+ 'all-header-files' : list ()
493+ }
494+
452495 # Currently, we fail if any of code_coverage_summary of introspector_report is
453496 # None. This should later be adjusted such that we can continue if we only
454497 # have code coverage but no introspector data. However, we need to adjust
@@ -551,6 +594,7 @@ def extract_project_data(project_name, date_str, should_include_details,
551594 'project_timestamp' : project_timestamp ,
552595 "introspector-data-dict" : introspector_data_dict ,
553596 "coverage-data-dict" : code_coverage_data_dict ,
597+ 'all-header-files' : all_header_files ,
554598 }
555599 return
556600
@@ -571,6 +615,7 @@ def analyse_list_of_projects(date, projects_to_analyse,
571615 function_list = list ()
572616 constructor_list = list ()
573617 project_timestamps = list ()
618+ all_header_files = list ()
574619 accummulated_fuzzer_count = 0
575620 accummulated_function_count = 0
576621 accummulated_covered_functions = 0
@@ -645,6 +690,9 @@ def analyse_list_of_projects(date, projects_to_analyse,
645690 'function_coverage_estimate' ] += introspector_dictionary [
646691 'functions_covered_estimate' ]
647692
693+ all_header_files .append (
694+ analyses_dictionary [project_key ]['all-header-files' ])
695+
648696 coverage_dictionary = analyses_dictionary [project_key ].get (
649697 'coverage-data-dict' , None )
650698 if coverage_dictionary != None :
@@ -662,7 +710,7 @@ def analyse_list_of_projects(date, projects_to_analyse,
662710 # - all constructors (maybe empty)
663711 # - a list of project timestamps
664712 # - the DB timestamp
665- return function_list , constructor_list , project_timestamps , db_timestamp
713+ return function_list , constructor_list , project_timestamps , db_timestamp , all_header_files
666714
667715
668716def extend_db_timestamps (db_timestamp , output_directory ):
@@ -752,9 +800,13 @@ def extend_func_db(function_list, output_directory, target):
752800 json .dump (all_functions , f )
753801
754802
755- def update_db_files (db_timestamp , project_timestamps , function_list ,
756- constructor_list , output_directory ,
757- should_include_details ):
803+ def update_db_files (db_timestamp ,
804+ project_timestamps ,
805+ function_list ,
806+ constructor_list ,
807+ output_directory ,
808+ should_include_details ,
809+ all_header_files = dict ()):
758810 logger .info (
759811 "Updating the database with DB snapshot. Number of functions in total: %d"
760812 % (db_timestamp ['function_count' ]))
@@ -763,6 +815,9 @@ def update_db_files(db_timestamp, project_timestamps, function_list,
763815 extend_func_db (constructor_list , output_directory ,
764816 DB_JSON_ALL_CONSTRUCTORS )
765817
818+ with open ('all-header-files.json' , 'w' ) as f :
819+ f .write (json .dumps (all_header_files ))
820+
766821 extend_db_json_files (project_timestamps , output_directory )
767822 extend_db_timestamps (db_timestamp , output_directory )
768823
@@ -840,14 +895,15 @@ def analyse_set_of_dates(dates, projects_to_analyse, output_directory,
840895 if force_creation :
841896 is_end = True
842897
843- function_list , constructor_list , project_timestamps , db_timestamp = analyse_list_of_projects (
898+ function_list , constructor_list , project_timestamps , db_timestamp , all_header_files = analyse_list_of_projects (
844899 date , projects_to_analyse , should_include_details = is_end )
845900 update_db_files (db_timestamp ,
846901 project_timestamps ,
847902 function_list ,
848903 constructor_list ,
849904 output_directory ,
850- should_include_details = is_end )
905+ should_include_details = is_end ,
906+ all_header_files = all_header_files )
851907
852908
853909def get_date_at_offset_as_str (day_offset = - 1 ):
@@ -1074,13 +1130,18 @@ def create_local_db(oss_fuzz_path):
10741130 extract_local_project_data (project , oss_fuzz_path , analyses_dictionary )
10751131
10761132 # Accummulate the data from all the projects.
1133+ all_header_files = []
10771134 for project_key in analyses_dictionary :
10781135 # Append project timestamp to the list of timestamps
10791136 project_timestamp = analyses_dictionary [project_key ][
10801137 'project_timestamp' ]
10811138 project_timestamps .append (project_timestamp )
10821139 db_timestamp ['fuzzer_count' ] += project_timestamp ['fuzzer-count' ]
10831140
1141+ # Extend all header files
1142+ all_header_files .append (
1143+ analyses_dictionary [project_key ]['all-header-files' ])
1144+
10841145 # Accummulate all function list and branch blockers
10851146 introspector_dictionary = project_timestamp .get (
10861147 'introspector-data' , None )
@@ -1120,7 +1181,8 @@ def create_local_db(oss_fuzz_path):
11201181 function_list ,
11211182 constructor_list ,
11221183 os .getcwd (),
1123- should_include_details = True )
1184+ should_include_details = True ,
1185+ all_header_files = all_header_files )
11241186
11251187
11261188def create_db (max_projects , days_to_analyse , output_directory , input_directory ,
0 commit comments