From b93caf0b30b980e3fa452d050b1b7608f7985b46 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Sat, 19 Oct 2024 14:52:45 +0100 Subject: [PATCH] webapp: show project repository link (#1787) Signed-off-by: David Korczynski --- tools/web-fuzzing-introspection/app/webapp/__init__.py | 4 +++- tools/web-fuzzing-introspection/app/webapp/models.py | 4 +++- tools/web-fuzzing-introspection/app/webapp/routes.py | 10 +++++++++- .../app/webapp/templates/project-profile.html | 6 ++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/web-fuzzing-introspection/app/webapp/__init__.py b/tools/web-fuzzing-introspection/app/webapp/__init__.py index 6bb15560..cb8d7078 100644 --- a/tools/web-fuzzing-introspection/app/webapp/__init__.py +++ b/tools/web-fuzzing-introspection/app/webapp/__init__.py @@ -56,7 +56,9 @@ def load_db() -> None: fuzzer_count=project_timestamp['fuzzer-count'], introspector_url=project_timestamp.get('introspector_url', None), - project_url=project_timestamp.get('project_url', None))) + project_url=project_timestamp.get('project_url', None), + project_repository=project_timestamp.get( + 'project_repository', None))) # If we're caching, then remove the timestamp file. if 'G_ANALYTICS_TAG' in os.environ: os.remove(project_timestamps_file) diff --git a/tools/web-fuzzing-introspection/app/webapp/models.py b/tools/web-fuzzing-introspection/app/webapp/models.py index 1853d6e8..bc326e5b 100644 --- a/tools/web-fuzzing-introspection/app/webapp/models.py +++ b/tools/web-fuzzing-introspection/app/webapp/models.py @@ -81,7 +81,8 @@ def __init__(self, introspector_data: Optional[Dict[str, Any]], fuzzer_count: int, introspector_url: Optional[str] = None, - project_url: Optional[str] = None): + project_url: Optional[str] = None, + project_repository: Optional[str] = None): self.project_name = project_name # date in the format Y-m-d self.date = date @@ -91,6 +92,7 @@ def __init__(self, self.fuzzer_count = fuzzer_count self.introspector_url = introspector_url self.project_url = project_url + self.project_repository = project_repository def has_introspector(self) -> bool: return self.introspector_data != None diff --git a/tools/web-fuzzing-introspection/app/webapp/routes.py b/tools/web-fuzzing-introspection/app/webapp/routes.py index 85e627ff..6c7c870f 100644 --- a/tools/web-fuzzing-introspection/app/webapp/routes.py +++ b/tools/web-fuzzing-introspection/app/webapp/routes.py @@ -407,6 +407,7 @@ def project_profile(): latest_fuzz_introspector_report = None latest_introspector_datestr = "" project_url = '' + project_repo = '' for ps in project_statistics: if ps.project_name == project.name: real_stats.append(ps) @@ -429,6 +430,8 @@ def project_profile(): latest_introspector_datestr = datestr if ps.project_url: project_url = ps.project_url + if ps.project_repository: + project_repo = ps.project_repository if not project_url: project_url = f'https://github.com/google/oss-fuzz/tree/master/projects/{project.name}' @@ -470,7 +473,8 @@ def project_profile(): project_url=project_url, page_main_url=page_texts.get_page_main_url(), page_main_name=page_texts.get_page_name(), - base_cov_url=page_texts.get_default_coverage_base()) + base_cov_url=page_texts.get_default_coverage_base(), + project_repo=project_repo) # Either this is a wrong project or we only have a build status for it all_build_status = data_storage.get_build_status() @@ -493,6 +497,7 @@ def project_profile(): latest_coverage_report = None latest_fuzz_introspector_report = None latest_introspector_datestr = "" + project_repo = '' for ps in project_statistics: if ps.project_name == project.name: real_stats.append(ps) @@ -508,6 +513,8 @@ def project_profile(): latest_fuzz_introspector_report = get_introspector_url( project.name, datestr) latest_introspector_datestr = datestr + if ps.project_repository: + project_repo = ps.project_repository if datestr and len(real_stats) > 0: latest_coverage_report = get_coverage_report_url( @@ -529,6 +536,7 @@ def project_profile(): project_url=project_url, latest_statistics=latest_statistics, latest_introspector_datestr=latest_introspector_datestr, + project_repo=project_repo, page_main_name=page_texts.get_page_name(), page_main_url=page_texts.get_page_main_url(), page_base_title=page_texts.get_page_base_title(), diff --git a/tools/web-fuzzing-introspection/app/webapp/templates/project-profile.html b/tools/web-fuzzing-introspection/app/webapp/templates/project-profile.html index c5ea3d46..230fea54 100644 --- a/tools/web-fuzzing-introspection/app/webapp/templates/project-profile.html +++ b/tools/web-fuzzing-introspection/app/webapp/templates/project-profile.html @@ -21,6 +21,12 @@

Project: {{ project.name }}

{{page_main_name}} project link + {% if project_repo %} + + Project repository + link + + {% endif %} Build status: Fuzzers