Full book sources (00–08), vorlagen/beispiele, PDF pipeline, and links to books.maatini.space/projects/copilot-cli-harness for ZIPs, stand, and errata.
3.6 KiB
Permissions-Hinweise (Copilot CLI)
Stand: Mitte/Ende 2026 · Primär: docs.github.com/en/copilot
Dieses Dokument ist kein 1:1-settings.json-Schema-Dump. Es erklärt die harten Hebel und zeigt sichere Startmuster.
Schichten (kurz)
| Hebel | Wo | Wirkung |
|---|---|---|
| Tool-Prompt (interaktiv) | Session | Yes / Session-Allow / No + Feedback |
| CLI-Flags | Startbefehl | --allow-tool, --deny-tool, --allow-all-tools, … |
| Gespeicherte Approvals | ~/.copilot/permissions-config.json (oder $COPILOT_HOME) |
pro Location (Repo-Root) |
| Settings | settings.json Hierarchie |
u. a. URL allow/deny, permissions.disableBypassPermissionsMode |
Precedence (Flags): --deny-tool schlägt --allow-tool und --allow-all-tools.
Enge Allowlist (Startbefehl)
Minimum für Test/Git-Lesen – bewusst ohne Write-Freifahrt:
copilot \
--allow-tool='shell(pytest)' \
--allow-tool='shell(ruff)' \
--allow-tool='shell(git status)' \
--allow-tool='shell(git diff)' \
--allow-tool='shell(git log)' \
--deny-tool='shell(rm)' \
--deny-tool='shell(git push)'
Headless / CI (Beispiel – Scope anpassen):
copilot -p "Führe die Unit-Tests aus und fasse Fehler zusammen. Keine Codeänderungen." \
--allow-tool='shell(pytest)' \
--deny-tool='shell(rm)' \
--deny-tool='write'
Achtung:
--allow-all-tools/--allow-all//yologeben dem Agenten dieselben Rechte wie du – ohne Einzel-Approval. Nur mit Sandbox, enger CWD und Team-Policy.
permissions-config.json (gespeicherte Approvals)
Pfad-Default: ~/.copilot/permissions-config.json.
Speichert Approvals pro Location (Git-Root), keine Deny-Regeln. Denys über Flags/Settings.
Kopiervorlage (Standalone): permissions-config.example.json.
Beispielstruktur (Pfade und Namen anpassen; nicht blind committen – oft user-lokal):
{
"locations": {
"/Users/YOUR-USER/src/your-org/your-repo": {
"tool_approvals": [
{
"kind": "commands",
"commandIdentifiers": [
"pytest",
"pytest -q",
"ruff check .",
"ruff format .",
"git status",
"git diff",
"git log",
"git:*"
]
}
],
"allowed_directories": []
}
}
}
Hinweise aus der Doku:
- Shell-Matching: literal;
git:*matchtgitund Subcommands; kein allgemeines Glob wiegit* kind: "write"freigibt Datei-Schreiben (Path-Gate kann trotzdem greifen)- MCP:
kind: "mcp",serverName,toolNameodernullfür alle Tools des Servers - Während laufender Session nicht wild editieren
Settings: URL und Bypass sperren
User: ~/.copilot/settings.json
Repo: .github/copilot/settings.json
Local (gitignore): .github/copilot/settings.local.json
{
// Deny schlägt Allow
"deniedUrls": ["*.evil.example"],
"allowedUrls": ["*.github.com", "docs.github.com"],
// Wenn "disable": --allow-all / --yolo etc. werden unterdrückt
// (MDM-Wert "disable" kann User-Override blocken – Enterprise)
"permissions": {
"disableBypassPermissionsMode": "disable"
}
}
Nur Keys setzen, die in der aktuellen Doku/copilot help config vorkommen.
Faustregel
| Aussage | Mittel |
|---|---|
| „Sollte nicht …“ | Custom Instructions (weich) |
| „Darf nicht …“ | --deny-tool, Hooks, Sandbox, MDM |
| „Darf ohne Rückfrage …“ | enge --allow-tool oder gespeicherte Approvals |
Siehe Kapitel 02 und 04 im Buch.