Add vuln-scan: Dependency-Check 13.0.0 vs Trivy 0.76.2 vs OSV-Scanner 2.7.1
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
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f32c088174
commit
7c677a39d2
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compares the findings of the three tools using normalise.py.
|
||||
|
||||
compare.py osv.json trivy.json dc.json
|
||||
|
||||
Prints (1) findings per component per tool, (2) which advisory ids only one or two tools report,
|
||||
(3) advisories all three report but with different severity buckets.
|
||||
Severity buckets use the CVSS v3 ranges: >=9.0 CRITICAL, >=7.0 HIGH, >=4.0 MEDIUM, else LOW.
|
||||
"""
|
||||
import collections, subprocess, sys, os
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def load(tool, path):
|
||||
out = subprocess.run([sys.executable, os.path.join(HERE, "normalise.py"), tool, path],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
return [l.split("\t") for l in out.splitlines()]
|
||||
|
||||
def bucket(sev):
|
||||
if ":" in sev: # dependency-check: "LABEL:score" -> trust the tool's own label
|
||||
return sev.split(":")[0].upper()
|
||||
s = sev
|
||||
try:
|
||||
x = float(s)
|
||||
return "CRITICAL" if x >= 9 else "HIGH" if x >= 7 else "MEDIUM" if x >= 4 else "LOW"
|
||||
except ValueError:
|
||||
return sev.split(":")[0].upper() or "NONE"
|
||||
|
||||
def main():
|
||||
osv, trivy, dc = (load(t, p) for t, p in zip(("osv", "trivy", "dc"), sys.argv[1:4]))
|
||||
names = ("osv-scanner", "trivy", "dependency-check")
|
||||
data = dict(zip(names, (osv, trivy, dc)))
|
||||
|
||||
comps = sorted({r[1] for rows in data.values() for r in rows})
|
||||
print("findings per component (advisory ids, deduplicated)")
|
||||
print(f' {"component":55} ' + " ".join(f"{n:>17}" for n in names))
|
||||
for c in comps:
|
||||
cells = [len({r[2] for r in rows if r[1] == c}) for rows in data.values()]
|
||||
print(f" {c:55} " + " ".join(f"{x:>17}" for x in cells))
|
||||
print(f' {"TOTAL (component, id) pairs":55} ' + " ".join(f"{len({(r[1], r[2]) for r in rows}):>17}" for rows in data.values()))
|
||||
|
||||
pairs = {n: {(r[1], r[2]) for r in rows} for n, rows in data.items()}
|
||||
allp = set().union(*pairs.values())
|
||||
print("\nreported by every tool:", len(set.intersection(*pairs.values())))
|
||||
print("\nreported by only some tools (O = osv-scanner, T = trivy, D = dependency-check)")
|
||||
for p in sorted(allp - set.intersection(*pairs.values())):
|
||||
who = "".join(l if p in pairs[n] else "-" for l, n in zip("OTD", names))
|
||||
print(f" {who} {p[1]:16} {p[0]}")
|
||||
|
||||
print("\nsame advisory, different severity bucket")
|
||||
sev = {n: {(r[1], r[2]): bucket(r[3]) for r in rows} for n, rows in data.items()}
|
||||
shown = 0
|
||||
for p in sorted(set.intersection(*pairs.values())):
|
||||
b = [sev[n][p] for n in names]
|
||||
if len(set(b)) > 1:
|
||||
shown += 1
|
||||
print(f" {p[1]:16} {p[0].split(':')[1]:18} osv={b[0]:9} trivy={b[1]:9} dc={b[2]}")
|
||||
if not shown:
|
||||
print(" none")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user