@@ -29,6 +29,22 @@ test('mutate paths use a denylist (base system read-only, rest writable)', async
|
||||
t.absent(s.bareAgentPathAllowedMutate('/'))
|
||||
})
|
||||
|
||||
test('normalize guest script strips ctx redeclare and export', async (t) => {
|
||||
const s = load()
|
||||
const n = s.bareAgentNormalizeGuestScript
|
||||
const exported = n(
|
||||
'export async function run(ctx, argv) {\n const vfs = ctx.vfs\n}\nexport { run }\n'
|
||||
)
|
||||
t.ok(exported.includes('async function run(ctx, argv)'))
|
||||
t.absent(exported.includes('export'))
|
||||
const rebound = n('const ctx = {}\nctx.console.log(1)\n')
|
||||
t.ok(rebound.includes('async function run(ctx, argv)'))
|
||||
t.absent(/const ctx/.test(rebound))
|
||||
const plain = n('ctx.console.log("hi")')
|
||||
t.ok(plain.includes('async function run(ctx, argv)'))
|
||||
t.ok(plain.includes('ctx.console.log'))
|
||||
})
|
||||
|
||||
test('reads allow any absolute path including kernel /proc', async (t) => {
|
||||
const s = load()
|
||||
t.ok(s.bareAgentPathAllowedRead('/home/guest/x'))
|
||||
|
||||
Reference in New Issue
Block a user