Same Maven project scanned three ways (pom.xml, SBOM, jars): captured output, false-positive evidence, suppression files with expiry, CI gate, -Pfixed profile. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7h4ZNF4BDUpJk3Zou
20 lines
801 B
Python
Executable File
20 lines
801 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""A severity gate for osv-scanner, which has no built-in threshold flag.
|
|
|
|
gate.py osv.json <minimum-cvss> exits 1 when any finding has a CVSS score >= the minimum
|
|
"""
|
|
import os, subprocess, sys
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
out = subprocess.run([sys.executable, os.path.join(HERE, "normalise.py"), "osv", sys.argv[1]],
|
|
capture_output=True, text=True, check=True).stdout
|
|
limit = float(sys.argv[2])
|
|
bad = []
|
|
for line in out.splitlines():
|
|
_, comp, vid, score = line.split("\t")
|
|
if score and float(score) >= limit:
|
|
bad.append((score, vid, comp))
|
|
for score, vid, comp in sorted(bad, reverse=True)[:5]:
|
|
print(f" {score:>5} {vid} {comp}")
|
|
print(f"{len(bad)} finding(s) with CVSS >= {limit}")
|
|
sys.exit(1 if bad else 0)
|