From b31848bba26f2195b389532d43cd08a0ec255d2f Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Mon, 30 Sep 2024 14:34:13 +0100 Subject: [PATCH] webapp: add more refined data to must-include projects (#1751) * webapp: add more refined data to must-include projects Signed-off-by: David Korczynski * nit Signed-off-by: David Korczynski --------- Signed-off-by: David Korczynski --- .../assets/db/web_db_creator_from_summary.py | 27 +++++++++++++++---- .../webapp/templates/projects-overview.html | 4 +-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tools/web-fuzzing-introspection/app/static/assets/db/web_db_creator_from_summary.py b/tools/web-fuzzing-introspection/app/static/assets/db/web_db_creator_from_summary.py index ea790cc1..0b103877 100644 --- a/tools/web-fuzzing-introspection/app/static/assets/db/web_db_creator_from_summary.py +++ b/tools/web-fuzzing-introspection/app/static/assets/db/web_db_creator_from_summary.py @@ -26,6 +26,7 @@ import subprocess import zipfile from threading import Thread +from typing import List, Any import constants import oss_fuzz @@ -53,6 +54,7 @@ '0'))) MUST_INCLUDES = set() +MUST_INCLUDE_WITH_LANG: List[Any] = [] logging.getLogger("requests").setLevel(logging.WARNING) logging.getLogger("urllib3").setLevel(logging.WARNING) @@ -956,8 +958,14 @@ def update_db_files(db_timestamp, extend_db_timestamps(db_timestamp, output_directory) if must_include_not_in_ossfuzz: + to_dump = [] + for project in must_include_not_in_ossfuzz: + for elem in MUST_INCLUDE_WITH_LANG: + if elem['project'] == project: + to_dump.append(elem) + with open('projects-not-in-oss-fuzz.json', 'w') as f: - f.write(json.dumps(list(must_include_not_in_ossfuzz))) + f.write(json.dumps(list(to_dump))) # Write a zip folder the values that make sense to save if should_include_details: @@ -1158,12 +1166,21 @@ def setup_webapp_cache(): def extract_must_includes(must_include_arg): + global MUST_INCLUDE_WITH_LANG must_include = set() if os.path.isfile(must_include_arg): - with open(must_include_arg, "r") as f: - for line in f: - if line.strip(): - must_include.add(line.strip()) + + if must_include_arg.endswith('.json'): + with open(must_include_arg, 'r') as f: + contents = json.load(f) + MUST_INCLUDE_WITH_LANG = contents + for project in contents: + must_include.add(project['project']) + else: + with open(must_include_arg, "r") as f: + for line in f: + if line.strip(): + must_include.add(line.strip()) elif os.path.isdir(must_include_arg): # Convenient when reading OSS-Fuzz-gen benchmark folder for filename in os.listdir(must_include_arg): diff --git a/tools/web-fuzzing-introspection/app/webapp/templates/projects-overview.html b/tools/web-fuzzing-introspection/app/webapp/templates/projects-overview.html index f024509e..7b2ee15a 100644 --- a/tools/web-fuzzing-introspection/app/webapp/templates/projects-overview.html +++ b/tools/web-fuzzing-introspection/app/webapp/templates/projects-overview.html @@ -45,12 +45,12 @@

{% endfor %} {% for project in projects_not_in_ossfuzz %} - {{project}} + {{project.project}} + {{project.language}} Not in OSS-Fuzz N/A N/A N/A - N/A {% endfor %}