Ship remaining roadmap items: encrypted registry vault, peer invite/revoke, Swarm/plugins behind flags, binary streams, engine create validation, deploy rollback, schema validation, fleet/access UI, metrics, fuzz/load/soak tests, systemd packaging, and release tooling. Mark ROADMAP fully complete.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Lightweight RPC argument fuzz — ensures schema + handlers never crash the process.
|
||||
*/
|
||||
import test from 'brittle'
|
||||
import { validateMethodArgs } from '../shared/schema.js'
|
||||
import { Methods, roleAllows, Roles } from '../shared/protocol.js'
|
||||
|
||||
const FUZZ_PAYLOADS = [
|
||||
null,
|
||||
undefined,
|
||||
'',
|
||||
42,
|
||||
true,
|
||||
[],
|
||||
{ __proto__: { admin: true } },
|
||||
{ id: 'x'.repeat(10_000) },
|
||||
{ image: '../../etc/passwd' },
|
||||
{ stackName: 'a', composeContent: 'services:\n x:\n image: n\n' },
|
||||
{ path: '/../../../../etc' },
|
||||
{ username: 'u', password: 'p'.repeat(2000) },
|
||||
{ role: 'admin\n' },
|
||||
{ limit: -1, offset: -5 },
|
||||
{ limit: 999999 },
|
||||
]
|
||||
|
||||
test('fuzz validateMethodArgs never throws', (t) => {
|
||||
const methods = Object.values(Methods)
|
||||
let checked = 0
|
||||
for (const method of methods) {
|
||||
for (const payload of FUZZ_PAYLOADS) {
|
||||
try {
|
||||
const r = validateMethodArgs(method, payload)
|
||||
t.ok(typeof r.ok === 'boolean')
|
||||
checked += 1
|
||||
} catch (err) {
|
||||
t.fail(`${method} threw: ${err.message}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
t.ok(checked > 100)
|
||||
})
|
||||
|
||||
test('fuzz roleAllows never throws', (t) => {
|
||||
for (const method of Object.values(Methods)) {
|
||||
for (const role of [Roles.viewer, Roles.operator, Roles.admin, 'nope', '', null]) {
|
||||
try {
|
||||
const allowed = roleAllows(role, method)
|
||||
t.ok(typeof allowed === 'boolean')
|
||||
} catch (err) {
|
||||
t.fail(`roleAllows threw: ${err.message}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user