import { readFile } from 'node:fs/promises' const reportPath = process.argv[2] if (!reportPath) throw new Error('Pfad zum OSV-JSON-Report fehlt.') const report = JSON.parse(await readFile(reportPath, 'utf8')) const findings = report.results.flatMap(result => result.packages.flatMap(entry => entry.groups.map(group => ({ packageName: entry.package.name, packageVersion: entry.package.version, ids: group.ids.join(', '), severity: Number(group.max_severity) || 0 })) ) ) for (const finding of findings) { console.log(`OSV: ${finding.ids} in ${finding.packageName}@${finding.packageVersion} (CVSS ${finding.severity})`) } const critical = findings.filter(finding => finding.severity >= 9) if (critical.length > 0) { console.error(`OSV-Scanner: ${critical.length} kritische(r) Befund(e) (CVSS >= 9.0).`) process.exitCode = 1 }