Skip to content

Commit 5f69451

Browse files
committed
test: add test capturing env var prefix permission bypass (anomalyco#16075)
1 parent 3242308 commit 5f69451

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎packages/opencode/test/tool/bash.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,35 @@ describe("tool.bash permissions", () => {
290290
})
291291
})
292292

293+
test("strips inline env var prefix from permission pattern", async () => {
294+
await using tmp = await tmpdir({ git: true })
295+
await Instance.provide({
296+
directory: tmp.path,
297+
fn: async () => {
298+
const bash = await BashTool.init()
299+
const requests: Array<Omit<PermissionNext.Request, "id" | "sessionID" | "tool">> = []
300+
const testCtx = {
301+
...ctx,
302+
ask: async (req: Omit<PermissionNext.Request, "id" | "sessionID" | "tool">) => {
303+
requests.push(req)
304+
},
305+
}
306+
await bash.execute(
307+
{
308+
command: 'CI=true git commit -m "test"',
309+
description: "Commit with env prefix",
310+
},
311+
testCtx,
312+
)
313+
const bashReq = requests.find((r) => r.permission === "bash")
314+
expect(bashReq).toBeDefined()
315+
// TODO: fix #16075 — flip these assertions when the bug is fixed
316+
expect(bashReq!.patterns).toContain('CI=true git commit -m "test"')
317+
expect(bashReq!.patterns).not.toContain('git commit -m "test"')
318+
},
319+
})
320+
})
321+
293322
test("always pattern has space before wildcard to not include different commands", async () => {
294323
await using tmp = await tmpdir({ git: true })
295324
await Instance.provide({

0 commit comments

Comments
 (0)