From fdd2efb641796fb4c108baaab951fb1042c7439d Mon Sep 17 00:00:00 2001 From: trick77 <1525566+trick77@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:27:14 +0100 Subject: [PATCH] permissions-cluster-info: ask before printing the token or streaming oc whoami * and oc config view * allowed --show-token and --raw, which put the user's full token into the model context without a prompt. oc logs -f and oc get -w/--watch never end and hung the agent without a prompt. Ask rules after the wildcard allows now catch them in every flag position; last-match-wins makes them override, and remove still clears the wildcards. --- README.md | 2 +- presets/permissions-cluster-info.conf | 29 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 799f14f..5edf649 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ something outside your opencode config say so in their description. | `permissions-deny-destructive` | Permissions | merge | In the bundle. Hard-denies `sudo`, root/home-anchored `rm -rf`, `dd`, `mkfs`, force-push, `reset --hard` | | `permissions-deny-cluster-write` | Permissions | merge | In the bundle. Hard-denies mutating and exec `oc`, `kubectl`, `helm` verbs — no prompt, not bypassable by `--auto` | | `permissions-build-tools` | Permissions | merge | Not in the bundle. Build tools (node, npm, mvn, gradle, make, python, pip, cargo, go) | -| `permissions-cluster-info` | Permissions | merge | Not in the bundle. Read-only `oc` (OpenShift) inspection — grants read access to whichever cluster you are logged into | +| `permissions-cluster-info` | Permissions | merge | Not in the bundle. Read-only `oc` (OpenShift) inspection — grants read access to whichever cluster you are logged into. Printing the token (`oc whoami -t`, `oc config view --raw`) and streaming (`oc logs -f`, `oc get -w`) still ask; combined short flags such as `-cf` are not recognised | | `permissions-webfetch-ask` | Permissions | merge | Not in the bundle. Requires approval before opencode uses the webfetch tool | | `mcp-http` | MCP | replace | Add an HTTP MCP server (localhost or remote) with one custom header (prompts for id, URL, header name, header value) | | `mcp-http-noauth` | MCP | replace | Add an HTTP MCP server (localhost or remote) without auth headers (prompts for id, URL) | diff --git a/presets/permissions-cluster-info.conf b/presets/permissions-cluster-info.conf index c3df994..a356598 100644 --- a/presets/permissions-cluster-info.conf +++ b/presets/permissions-cluster-info.conf @@ -1,12 +1,10 @@ // @name: permissions-cluster-info -// @description: Auto-allows read-only oc (OpenShift) inspection commands. Split -// out of permissions-container-info in its 0.2.0 so cluster access is an -// explicit opt-in. Caveats: this grants read access to whichever cluster you -// happen to be logged into, including production, and oc get can dump -// base64-encoded secret values to your terminal. Pair with -// permissions-deny-cluster-write, installed after it. +// @description: Auto-allows read-only oc (OpenShift) inspection commands on +// whichever cluster you are logged into, production included; oc get can +// print base64-encoded Secrets. Printing the token and streaming (-f, -w) +// still ask. Install permissions-deny-cluster-write after it. // @author: Jan -// @version: 0.1.0 +// @version: 0.2.0 // @path: permission.bash // @mode: merge { @@ -30,5 +28,20 @@ "oc config view": "allow", "oc config view *": "allow", "oc config get-contexts": "allow", - "oc config current-context": "allow" + "oc config current-context": "allow", + + "oc whoami -t*": "ask", + "oc whoami * -t": "ask", + "oc whoami * -t *": "ask", + "oc whoami *-t=*": "ask", + "oc whoami *--show-token*": "ask", + "oc config view *--raw*": "ask", + "oc get -w*": "ask", + "oc get * -w": "ask", + "oc get * -w *": "ask", + "oc get *-w=*": "ask", + "oc get *--watch*": "ask", + "oc logs -f*": "ask", + "oc logs * -f*": "ask", + "oc logs *--follow*": "ask" }