Files
bare-operating-system/scripts/fuzz-boot-policy-json.mjs
T
2026-04-04 16:39:15 -04:00

32 lines
715 B
JavaScript

#!/usr/bin/env node
/**
* Tiny fuzz harness for boot.policy.json parsing tolerance (host-side).
* Generates random JSON-looking strings and ensures JSON.parse does not throw the process.
*/
import crypto from 'node:crypto'
let throws = 0
for (let i = 0; i < 500; i++) {
const buf = crypto.randomBytes(64 + (i % 128))
const s = buf.toString('base64')
try {
JSON.parse(s)
} catch {
throws++
}
try {
JSON.parse('{"x":' + s.slice(0, 20))
} catch {
throws++
}
}
console.log(
JSON.stringify({
schema: 1,
ok: true,
iterations: 500,
expectedParseFailures: throws,
note: 'fuzz-boot-policy-json: JSON.parse noise only; stock policy merge is in kernel/init.js'
})
)