From 595fc3e8b0210f23eff23ff853474e8700af2b85 Mon Sep 17 00:00:00 2001 From: Andrew Pollock Date: Tue, 10 Oct 2023 13:55:55 +1000 Subject: [PATCH] Add a URL rewriter for Savannah repo URLs (#1713) Manually tested with data from [CVE-2023-40303](https://oss-vdb-test.wl.r.appspot.com/vulnerability/CVE-2023-40303) ``` In [1]: import osv In [2]: import source_mapper In [3]: vcs = source_mapper.get_vcs_viewer_for_url("https://git.savannah.gnu.org/git/inetutils.git") In [4]: vcs.get_source_url_for_revision("e4e65c03f4c11292a3e40ef72ca3f194c8bffdd6") Out[4]: 'https://git.savannah.gnu.org/cgit/inetutils.git/commit?id=e4e65c03f4c11292a3e40ef72ca3f194c8bffdd6' ``` --- gcp/appengine/source_mapper.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcp/appengine/source_mapper.py b/gcp/appengine/source_mapper.py index 37889db60bb..30614a74d5e 100644 --- a/gcp/appengine/source_mapper.py +++ b/gcp/appengine/source_mapper.py @@ -89,12 +89,21 @@ class MercurialVCS(VCSViewer): r'&revcount={range_limit}') +class SavannahVCS(VCSViewer): + VCS_URL_REGEX = re.compile( + r'(https?://git\.savannah\.(?:non)?gnu\.org)/git/(.*\.git)$') + VCS_REVISION_SUB = r'\1/cgit/\2/commit?id={revision}' + VCS_REVISION_DIFF_SUB = (r'\1/cgit/\2/diff/' + r'?id={end_revision}&id2={start_revision}') + + VCS_LIST = [ FreeDesktopVCS, GitHubVCS, GitLabVCS, GoogleSourceVCS, MercurialVCS, + SavannahVCS, ]