feat: erweitere OSV-Scanner mit JSON-Ausgabe und kritischen Befunden
This commit is contained in:
26
scripts/check-osv-severity.mjs
Normal file
26
scripts/check-osv-severity.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user