github / github/copilot-cli

`preToolUse` agent hook denial does not work

未关闭
#3,874 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:permissions area:plugins
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Describe the bug

Running chat session from Copilot CLI, I have installed a hook that denies all commands.

### Affected version

- GitHub Copilot Chat Extension `v1.0.65`

### Steps to reproduce the behavior

**.github/hooks/hooks.json**

```json
{
"version": 1,
"hooks": {
"preToolUse": [
{
"cwd": "src",
"bash": "bin/Debug/net10.0/hook",
"powershell": "bin/Debug/net10.0/hook",
"timeoutSec": 15
}
]
}
}
```

A simple C# `hook.exe` program:

**Program.cs**

```csharp
Console.WriteLine("{\"permissionDecision\":\"deny\"}");
Environment.Exit(2);
```

Here is a simple session prompt:

> Give me the latest powershell `Get-Date`

I tried _everything_:

- Exit code `2`
- `{"permissionDecision": "deny"}` response to `preToolUse` hook events.
- `{"behavior":"deny"}` response to `permissionRequest` hook events.

Still, the tool is called and never denied.

### Expected behavior

The tool call SHOULD be denied.

### Additional context

_No response_

贡献指南

打开贡献指南

调研方向

Start by reproducing the denial flow from .github/hooks/hooks.json with the C# Program.cs hook and the Copilot CLI session described. Compare the preToolUse exit code and permissionDecision output with the observed tool call; done means the requested tool is not executed when the hook denies it.

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, powershell, shell
领域
cli, security
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
58/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。