@@ -222,7 +222,7 @@ describe("tool.bash permissions", () => {
222222 }
223223 await bash . execute (
224224 {
225- command : "git log --oneline -5 " ,
225+ command : "ls -la " ,
226226 } ,
227227 testCtx ,
228228 )
@@ -302,6 +302,53 @@ describe("tool.bash permissions", () => {
302302 } )
303303} )
304304
305+ describe ( "tool.bash blocklist" , ( ) => {
306+ test ( "blocks git by default" , async ( ) => {
307+ await Instance . provide ( {
308+ directory : projectRoot ,
309+ fn : async ( ) => {
310+ const bash = await BashTool . init ( )
311+ await expect ( bash . execute ( { command : "git status" } , ctx ) ) . rejects . toThrow (
312+ "Bash command 'git' is not allowed. Please use a different command or tool." ,
313+ )
314+ } ,
315+ } )
316+ } )
317+
318+ test ( "allows git when ALLOW_GIT=1" , async ( ) => {
319+ const prev = process . env . ALLOW_GIT
320+ process . env . ALLOW_GIT = "1"
321+ try {
322+ await Instance . provide ( {
323+ directory : projectRoot ,
324+ fn : async ( ) => {
325+ const bash = await BashTool . init ( )
326+ const result = await bash . execute ( { command : "git --version >/dev/null 2>&1 || true" } , ctx )
327+ expect ( result . metadata . exit ) . toBe ( 0 )
328+ } ,
329+ } )
330+ } finally {
331+ if ( prev === undefined ) {
332+ delete process . env . ALLOW_GIT
333+ } else {
334+ process . env . ALLOW_GIT = prev
335+ }
336+ }
337+ } )
338+
339+ test ( "blocks commands in chained segments" , async ( ) => {
340+ await Instance . provide ( {
341+ directory : projectRoot ,
342+ fn : async ( ) => {
343+ const bash = await BashTool . init ( )
344+ await expect ( bash . execute ( { command : "echo ok && nohup sleep 1" } , ctx ) ) . rejects . toThrow (
345+ "Bash command 'nohup' is not allowed. Please use a different command or tool." ,
346+ )
347+ } ,
348+ } )
349+ } )
350+ } )
351+
305352describe ( "tool.bash truncation" , ( ) => {
306353 test ( "truncates output exceeding line limit" , async ( ) => {
307354 await Instance . provide ( {
0 commit comments