mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Add a check dependencies action
Use the gyre tool to scan all binaries and generate a report
This commit is contained in:
50
.github/workflows/ci.py
vendored
50
.github/workflows/ci.py
vendored
@@ -156,11 +156,13 @@ def setup_bundle_env() -> None:
|
|||||||
os.environ['PATH'] = '{}:{}'.format(os.path.join(SW, 'bin'), os.environ['PATH'])
|
os.environ['PATH'] = '{}:{}'.format(os.path.join(SW, 'bin'), os.environ['PATH'])
|
||||||
|
|
||||||
|
|
||||||
def install_bundle() -> None:
|
def install_bundle(dest: str = '', which: str = '') -> None:
|
||||||
|
dest = dest or SW
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
os.makedirs(SW)
|
os.makedirs(dest, exist_ok=True)
|
||||||
os.chdir(SW)
|
os.chdir(dest)
|
||||||
with urlopen(BUNDLE_URL.format('macos' if is_macos else 'linux')) as f:
|
which = which or ('macos' if is_macos else 'linux')
|
||||||
|
with urlopen(BUNDLE_URL.format(which)) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
|
with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
|
||||||
try:
|
try:
|
||||||
@@ -172,13 +174,49 @@ def install_bundle() -> None:
|
|||||||
for dirpath, dirnames, filenames in os.walk('.'):
|
for dirpath, dirnames, filenames in os.walk('.'):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')):
|
if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')):
|
||||||
replace_in_file(os.path.join(dirpath, f), '/sw/sw', SW)
|
replace_in_file(os.path.join(dirpath, f), '/sw/sw', dest)
|
||||||
replaced += 1
|
replaced += 1
|
||||||
if replaced < 2:
|
if replaced < 2:
|
||||||
raise SystemExit('Failed to replace path to SW in bundle')
|
raise SystemExit('Failed to replace path to SW in bundle')
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
||||||
|
def install_grype() -> str:
|
||||||
|
dest = os.path.join(SW, 'bin')
|
||||||
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
with urlopen('https://get.anchore.io/grype') as f:
|
||||||
|
data = f.read()
|
||||||
|
installer = os.path.join(dest, 'grype-installer')
|
||||||
|
with open(installer, 'wb') as f:
|
||||||
|
f.write(data)
|
||||||
|
os.chmod(installer, 0o766)
|
||||||
|
subprocess.check_call([installer, '-b', dest])
|
||||||
|
return os.path.join(dest, 'grype')
|
||||||
|
|
||||||
|
|
||||||
|
IGNORED_DEPENDENCY_CVES = [
|
||||||
|
# Python stdlib
|
||||||
|
'CVE-2025-8194', # DoS in tarfile
|
||||||
|
'CVE-2025-6069', # DoS in HTMLParser
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def check_dependencies() -> None:
|
||||||
|
grype = install_grype()
|
||||||
|
with open((gc := os.path.expanduser('~/.grype.yml')), 'w') as f:
|
||||||
|
print('ignore:', file=f)
|
||||||
|
for x in IGNORED_DEPENDENCY_CVES:
|
||||||
|
print(' - vulnerability:', x, file=f)
|
||||||
|
dest = os.path.join(SW, 'linux')
|
||||||
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
install_bundle(dest, os.path.basename(dest))
|
||||||
|
dest = os.path.join(SW, 'macos')
|
||||||
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
install_bundle(dest, os.path.basename(dest))
|
||||||
|
if (cp := subprocess.run([grype, '--config', gc, '--fail-on', 'medium', SW])).returncode != 0:
|
||||||
|
raise SystemExit(cp.returncode)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
if is_bundle:
|
if is_bundle:
|
||||||
setup_bundle_env()
|
setup_bundle_env()
|
||||||
@@ -200,6 +238,8 @@ def main() -> None:
|
|||||||
q = '\n'.join(filter(lambda x: not x.rstrip().endswith('_generated.go'), q.strip().splitlines())).strip()
|
q = '\n'.join(filter(lambda x: not x.rstrip().endswith('_generated.go'), q.strip().splitlines())).strip()
|
||||||
if q:
|
if q:
|
||||||
raise SystemExit(q)
|
raise SystemExit(q)
|
||||||
|
elif action == 'check-dependencies':
|
||||||
|
check_dependencies()
|
||||||
else:
|
else:
|
||||||
raise SystemExit(f'Unknown action: {action}')
|
raise SystemExit(f'Unknown action: {action}')
|
||||||
|
|
||||||
|
|||||||
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@@ -199,6 +199,29 @@ jobs:
|
|||||||
- name: Run benchmarks
|
- name: Run benchmarks
|
||||||
run: ./benchmark.py
|
run: ./benchmark.py
|
||||||
|
|
||||||
|
dependecy-scanner:
|
||||||
|
name: Scan dependencies for vulnerabilities
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
KITTY_BUNDLE: 1
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
fetch-depth: 10
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Checkout bypy
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
persist-credentials: false
|
||||||
|
repository: kovidgoyal/bypy
|
||||||
|
path: bypy-src
|
||||||
|
|
||||||
|
- name: Check dependencies
|
||||||
|
run: python3 .github/workflows/ci.py check-dependencies
|
||||||
|
|
||||||
linux-dev:
|
linux-dev:
|
||||||
name: Test ./dev.sh and benchmark
|
name: Test ./dev.sh and benchmark
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user