Skip to content

Commit c2741d8

Browse files
author
Arifdev1
committed
webapp: save Fuzz Introspector reports in a .zip file (#1326)
This makes all introspector data available through the API, which can be useful for experimenation and exploration. Discussed in ossf/fuzz-introspector#1323 Ref: ossf/fuzz-introspector#1323 (comment) Signed-off-by: David Korczynski <[email protected]>
1 parent 4fb0f1a commit c2741d8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tools/web-fuzzing-introspection/app/static/assets/db/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ backup
33
outdir*
44
oss-fuzz-clone
55
db-archive.zip
6+
raw-introspector-reports.zip

tools/web-fuzzing-introspection/app/static/assets/db/web_db_creator_from_summary.py

+22
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
DB_JSON_ALL_CURRENT_FUNCS = 'all-project-current.json'
3333
DB_JSON_ALL_BRANCH_BLOCKERS = 'all-branch-blockers.json'
3434
DB_BUILD_STATUS_JSON = 'build-status.json'
35+
DB_RAW_INTROSPECTOR_REPORTS = 'raw-introspector-reports'
3536

3637
ALL_JSON_FILES = [
3738
DB_JSON_DB_TIMESTAMP,
@@ -266,6 +267,16 @@ def rename_annotated_cfg(original_annotated_cfg):
266267
return new_annotated_cfg
267268

268269

270+
def save_fuzz_introspector_report(introspector_report, project_name, date_str):
271+
if not os.path.isdir(DB_RAW_INTROSPECTOR_REPORTS):
272+
os.mkdir(DB_RAW_INTROSPECTOR_REPORTS)
273+
274+
report_dst = os.path.join(DB_RAW_INTROSPECTOR_REPORTS,
275+
'%s-%s.json' % (project_name, date_str))
276+
with open(report_dst, 'w') as report_fd:
277+
json.dump(introspector_report, report_fd)
278+
279+
269280
def extract_project_data(project_name, date_str, should_include_details,
270281
manager_return_dict):
271282
"""
@@ -307,6 +318,9 @@ def extract_project_data(project_name, date_str, should_include_details,
307318
introspector_report_url = get_introspector_report_url_report(
308319
project_name, date_str.replace("-", ""))
309320

321+
# Save the report
322+
save_fuzz_introspector_report(introspector_report, project_name, date_str)
323+
310324
# Currently, we fail if any of code_coverage_summary of introspector_report is
311325
# None. This should later be adjusted such that we can continue if we only
312326
# have code coverage but no introspector data. However, we need to adjust
@@ -691,6 +705,14 @@ def update_db_files(db_timestamp, project_timestamps, function_list,
691705
DB_JSON_ALL_PROJECT_TIMESTAMP,
692706
compress_type=zipfile.ZIP_DEFLATED)
693707

708+
# ZIP the archived introspector reports
709+
shutil.make_archive(DB_RAW_INTROSPECTOR_REPORTS, 'zip',
710+
DB_RAW_INTROSPECTOR_REPORTS)
711+
712+
# Cleanup DB_RAW_INTROSPECTOR_REPORTS
713+
if os.path.isdir(DB_RAW_INTROSPECTOR_REPORTS):
714+
shutil.rmtree(DB_RAW_INTROSPECTOR_REPORTS)
715+
694716

695717
def update_build_status(build_dict):
696718
with open(DB_BUILD_STATUS_JSON, "w") as f:

0 commit comments

Comments
 (0)