github / github/copilot-cli

`preToolUse` agent hook denial does not work

Đang mở
#3,874 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:permissions area:plugins
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

### 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_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, powershell, shell
Lĩnh vực
cli, security
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.