* Early-exit deny enforcement for the AST too-complex and checkSemantics * paths. Returns the exact-match result if non-passthrough (deny/ask/allow), * then checks prefix/wildcard deny rules. Returns null if neither matched, * meaning the caller should fall through to ask. Extracted to keep * ba
( input: z.infer<typeof BashTool.inputSchema>, toolPermissionContext: ToolPermissionContext, )
| 1390 | * bashToolHasPermission under Bun's feature() DCE complexity threshold. |
| 1391 | */ |
| 1392 | function checkEarlyExitDeny( |
| 1393 | input: z.infer<typeof BashTool.inputSchema>, |
| 1394 | toolPermissionContext: ToolPermissionContext, |
| 1395 | ): PermissionResult | null { |
| 1396 | const exactMatchResult = bashToolCheckExactMatchPermission( |
| 1397 | input, |
| 1398 | toolPermissionContext, |
| 1399 | ) |
| 1400 | if (exactMatchResult.behavior !== 'passthrough') { |
| 1401 | return exactMatchResult |
| 1402 | } |
| 1403 | const denyMatch = matchingRulesForInput( |
| 1404 | input, |
| 1405 | toolPermissionContext, |
| 1406 | 'prefix', |
| 1407 | ).matchingDenyRules[0] |
| 1408 | if (denyMatch !== undefined) { |
| 1409 | return { |
| 1410 | behavior: 'deny', |
| 1411 | message: `Permission to use ${BashTool.name} with command ${input.command} has been denied.`, |
| 1412 | decisionReason: { type: 'rule', rule: denyMatch }, |
| 1413 | } |
| 1414 | } |
| 1415 | return null |
| 1416 | } |
| 1417 | |
| 1418 | /** |
| 1419 | * checkSemantics-path deny enforcement. Calls checkEarlyExitDeny (exact-match |
no test coverage detected