From ec29b1f0e8b2fcb28426eea931aa942ffd8481ec Mon Sep 17 00:00:00 2001 From: Rex P Date: Tue, 13 Jan 2026 16:24:47 +1100 Subject: [PATCH 1/5] Add a fallback method --- osv/repos.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/osv/repos.py b/osv/repos.py index 78da8c93292..2e1c5681b8d 100644 --- a/osv/repos.py +++ b/osv/repos.py @@ -118,6 +118,7 @@ class RepoInaccessibleError(Exception): def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): """Perform a clone.""" # Don't user Gitter for oss-fuzz-vulns repo because it requires auth + logging.info('Cloning %s to %s.', git_url, checkout_dir) if GITTER_HOST and git_url != 'ssh://github.com/google/oss-fuzz-vulns': try: os.makedirs(checkout_dir, exist_ok=True) @@ -132,17 +133,18 @@ def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): if resp.status_code == 400: raise GitCloneError(f'Failed to clone repo: {resp.text}') - resp.raise_for_status() + # If return is successful write out the repo, otherwise fall back to + # original cloning method + if resp.status_code == 200: + with open(f'{checkout_dir}.zst', 'wb') as f: + shutil.copyfileobj(resp.raw, f) - with open(f'{checkout_dir}.zst', 'wb') as f: - shutil.copyfileobj(resp.raw, f) + cmd = ['tar', '-xf', f'{checkout_dir}.zst', '-C', checkout_dir] + subprocess.run(cmd, check=True) + # Remove after extraction. + os.remove(f'{checkout_dir}.zst') - cmd = ['tar', '-xf', f'{checkout_dir}.zst', '-C', checkout_dir] - subprocess.run(cmd, check=True) - # Remove after extraction. - os.remove(f'{checkout_dir}.zst') - - return pygit2.Repository(checkout_dir) + return pygit2.Repository(checkout_dir) except requests.RequestException as e: raise GitCloneError(f'Failed to clone repo: {e}') from e except subprocess.CalledProcessError as e: From 9164acbf95e8c007dd023044830e665a9f9079c2 Mon Sep 17 00:00:00 2001 From: Rex P Date: Tue, 13 Jan 2026 16:27:00 +1100 Subject: [PATCH 2/5] Actually log errors as well --- osv/repos.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osv/repos.py b/osv/repos.py index 2e1c5681b8d..19f5afdd79a 100644 --- a/osv/repos.py +++ b/osv/repos.py @@ -145,6 +145,9 @@ def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): os.remove(f'{checkout_dir}.zst') return pygit2.Repository(checkout_dir) + else: + logging.error(f'Failed to clone repo through gitter, ' + f'status: {resp.status_code}, response: {resp.text}') except requests.RequestException as e: raise GitCloneError(f'Failed to clone repo: {e}') from e except subprocess.CalledProcessError as e: From 64f48235f5c7040d90b08eb81370456b6be06a2d Mon Sep 17 00:00:00 2001 From: Rex P Date: Tue, 13 Jan 2026 16:27:52 +1100 Subject: [PATCH 3/5] Fix lints --- osv/repos.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osv/repos.py b/osv/repos.py index 19f5afdd79a..3fc496e4968 100644 --- a/osv/repos.py +++ b/osv/repos.py @@ -145,9 +145,10 @@ def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): os.remove(f'{checkout_dir}.zst') return pygit2.Repository(checkout_dir) - else: - logging.error(f'Failed to clone repo through gitter, ' - f'status: {resp.status_code}, response: {resp.text}') + + logging.error( + f'Failed to clone repo through gitter, ' + f'status: %d, response: %s', resp.status_code, resp.text) except requests.RequestException as e: raise GitCloneError(f'Failed to clone repo: {e}') from e except subprocess.CalledProcessError as e: From d322a4266f26e408e05087f70dea99259377cf95 Mon Sep 17 00:00:00 2001 From: Rex P Date: Tue, 13 Jan 2026 18:23:46 +1100 Subject: [PATCH 4/5] Fix lintsstsstswgs again --- osv/repos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osv/repos.py b/osv/repos.py index 3fc496e4968..a05cac8c4b0 100644 --- a/osv/repos.py +++ b/osv/repos.py @@ -147,7 +147,7 @@ def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): return pygit2.Repository(checkout_dir) logging.error( - f'Failed to clone repo through gitter, ' + 'Failed to clone repo through gitter, ' f'status: %d, response: %s', resp.status_code, resp.text) except requests.RequestException as e: raise GitCloneError(f'Failed to clone repo: {e}') from e From d2ca8cc64c71dbf05d74224a7a7de449dd697886 Mon Sep 17 00:00:00 2001 From: Rex P Date: Tue, 13 Jan 2026 18:41:58 +1100 Subject: [PATCH 5/5] asdfsdsdfgsdf --- osv/repos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osv/repos.py b/osv/repos.py index a05cac8c4b0..6a3e145ed71 100644 --- a/osv/repos.py +++ b/osv/repos.py @@ -148,7 +148,7 @@ def clone(git_url, checkout_dir, git_callbacks=None, blobless=False): logging.error( 'Failed to clone repo through gitter, ' - f'status: %d, response: %s', resp.status_code, resp.text) + 'status: %d, response: %s', resp.status_code, resp.text) except requests.RequestException as e: raise GitCloneError(f'Failed to clone repo: {e}') from e except subprocess.CalledProcessError as e: