github / github/copilot-cli

`preToolUse` agent hook denial does not work

Aberta
#3,874 3 comentários 0 reações 0 responsáveis Ver no GitHub
area:permissions area:plugins
Linguagem predominante
Shell
Estrelas
11.2k
Forks
1.9k
Merge médio
14h 16min
PRs com merge (30d)
6

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp, powershell, shell
Domínio
cli, security
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
58/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.