Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/host-command-tool-smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main(): Promise<void> {

const registry = createHostToolRegistry([
createHostCommandTool({
name: "host.node-smoke",
name: "host/node_smoke",
description: "Runs a bounded Node.js host command for smoke coverage.",
command: process.execPath,
args: ["-e", "console.log(JSON.stringify({ cwd: process.cwd(), args: process.argv.slice(1), token: process.env.SMOKE_TOKEN || null }))", "--"],
Expand All @@ -33,12 +33,12 @@ async function main(): Promise<void> {
const runtime = await createRuntime({
backend: "wordpress-playground",
environment: { kind: "wordpress", version: "latest" },
policy: { network: "deny", filesystem: "sandbox", commands: ["host.node-smoke"], secrets: "none", approvals: "never" },
policy: { network: "deny", filesystem: "sandbox", commands: ["host/node_smoke"], secrets: "none", approvals: "never" },
hostTools: registry,
}, createPlaygroundRuntimeBackend())

const ok = await runtime.execute({
command: "host.node-smoke",
command: "host/node_smoke",
args: [`input-json=${JSON.stringify({ args: ["--flag"], cwd: nested, env: { SMOKE_TOKEN: "allowed" } })}`],
})
const okBody = JSON.parse(ok.stdout) as HostToolResult
Expand All @@ -49,15 +49,15 @@ async function main(): Promise<void> {
assert(typeof okBody.output.stdout === "string" && okBody.output.stdout.includes("allowed"), "host command should pass explicitly allowed env")

const deniedCwd = await runtime.execute({
command: "host.node-smoke",
command: "host/node_smoke",
args: [`input-json=${JSON.stringify({ cwd: tmpdir() })}`],
})
const deniedCwdBody = JSON.parse(deniedCwd.stdout) as HostToolResult
assert(deniedCwdBody.status === "error", "host command cwd escapes should fail closed")
assert(deniedCwdBody.error.message.includes("outside allowed roots"), "host command cwd errors should be explicit")

const deniedEnv = await runtime.execute({
command: "host.node-smoke",
command: "host/node_smoke",
args: [`input-json=${JSON.stringify({ env: { SECRET_TOKEN: "blocked" } })}`],
})
const deniedEnvBody = JSON.parse(deniedEnv.stdout) as HostToolResult
Expand Down