Skip to content

Commit 83c8a82

Browse files
committed
Download grype from my own server
Far higher reliability than githubj;wq
1 parent bfc21fc commit 83c8a82

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

.github/workflows/ci.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import glob
66
import io
7-
import json
7+
import lzma
88
import os
99
import shlex
1010
import shutil
@@ -196,24 +196,12 @@ def install_bundle(dest: str = '', which: str = '') -> None:
196196
os.chdir(cwd)
197197

198198

199-
def install_grype() -> str:
200-
dest = '/tmp'
201-
rq = Request('https://api.github.com/repos/anchore/grype/releases/latest', headers={
202-
'Accept': 'application/vnd.github.v3+json',
203-
})
204-
m = json.loads(download_with_retry(rq))
205-
for asset in m['assets']:
206-
if asset['name'].endswith('_linux_amd64.tar.gz'):
207-
url = asset['browser_download_url']
208-
break
209-
else:
210-
raise ValueError('Could not find linux binary for grype')
211-
os.makedirs(dest, exist_ok=True)
212-
data = download_with_retry(url)
213-
with tarfile.open(fileobj=io.BytesIO(data), mode='r') as tf:
214-
tf.extract('grype', path=dest, filter='fully_trusted')
215-
exe = os.path.join(dest, 'grype')
216-
subprocess.check_call([exe, 'db', 'update'])
199+
def install_grype(exe: str = '/tmp/grype') -> str:
200+
raw = download_with_retry('https://download.calibre-ebook.com/ci/grype.xz')
201+
raw = lzma.decompress(raw)
202+
with open(exe, 'wb') as f:
203+
f.write(raw)
204+
os.fchmod(f.fileno(), 0o755)
217205
return exe
218206

219207

0 commit comments

Comments
 (0)