27 lines
992 B
JavaScript
27 lines
992 B
JavaScript
// Validates audit-results/FINDINGS.json parses and reports counts per severity.
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
|
|
const file = path.resolve("audit-results/FINDINGS.json");
|
|
const raw = fs.readFileSync(file, "utf8");
|
|
const data = JSON.parse(raw); // throws if invalid
|
|
|
|
const findings = data.findings;
|
|
const bySeverity = {};
|
|
for (const f of findings) {
|
|
bySeverity[f.severity] = (bySeverity[f.severity] || 0) + 1;
|
|
}
|
|
const byConfidence = {};
|
|
for (const f of findings) {
|
|
byConfidence[f.confidence] = (byConfidence[f.confidence] || 0) + 1;
|
|
}
|
|
|
|
const ids = findings.map((f) => f.id);
|
|
const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);
|
|
if (dupes.length) throw new Error("duplicate ids: " + dupes.join(","));
|
|
|
|
console.log("FINDINGS.json: VALID JSON");
|
|
console.log("total findings:", findings.length);
|
|
console.log("by severity:", JSON.stringify(bySeverity));
|
|
console.log("by confidence:", JSON.stringify(byConfidence));
|
|
console.log("ids:", ids.join(", "));
|