Skip to content
Isonapse
Install

Block whole kinds of action

Refuse every action of a kind, such as any sudo or dd command, for every agent. Only an action rule that names that exact action can allow it again.

Works with: All four agents. Supported hosts has the detail for each agent.

Steps

  1. 1. Start from your current policy

    isonapse hook policy export my-policy.lua

    This writes your active policy to my-policy.lua. Copy the rules you want from the example below into it. If the file already has a section of the same name, add the lines to that section.

  2. 2. Check that it loads

    isonapse hook policy check my-policy.lua

    This loads the file the way Isonapse does and names any file or folder pattern that can never match. It changes nothing.

  3. 3. Make it active

    isonapse hook policy activate my-policy.lua

    The terminal shows the exact change, and one approval with your login password makes it active. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.

  4. 4. Undo it

    isonapse hook policy revisions
    isonapse hook policy rollback <revision>

    The first lists earlier policies; the second restores one, with one approval and the password you log in to this computer with. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.

What it does not do

  • A shell command is matched by the program Isonapse's shell analysis attributes it to. Unusual shell forms can be misread.

The policy

The whole example, 02-blocked-capabilities.lua, from the examples Isonapse publishes.

-- 02-blocked-capabilities.lua — the simplest deny.
--
-- `blocked_capabilities` is a map from AGENT pattern to a list of
-- CAPABILITY strings the gate must DENY for that agent. An exact agent
-- string matches one agent only; `"agent:*"` matches every agent whose ID
-- starts with `agent:`; `"*"` matches every agent.
--
-- Capabilities are the identifiers the gate sees on a `propose_action`
-- request:
--
--   - `tool:Bash`               — any Bash invocation
--   - `tool:Bash:git`           — git specifically (after subcommand split)
--   - `tool:Bash:rm`, `tool:Bash:sudo`, `tool:Bash:dd` — destructive defaults
--   - `tool:Read`, `tool:Write`, `tool:Edit`
--   - `tool:WebFetch`
--   - `tool:mcp:<encoded-server>:<encoded-tool>` — MCP capabilities (server-scoped)
--   - `cap:shell-exec`, `cap:file-write`, `cap:http-request` — internal capabilities
--
-- A DENY here wins over every rule except an `actions` rule that names the
-- exact capability: only such a rule can allow it again.
--
-- Try it:
--   * `agent:untrusted` proposing `cap:shell-exec` -> DENIED
--   * `agent:audit` proposing `cap:shell-exec` -> falls through (allowed)
--   * Any agent proposing `tool:Bash:sudo` -> DENIED (wildcard pattern)

return {
  policy_version = "blocked-capabilities-v1",

  blocked_capabilities = {
    -- Exact agent ID: untrusted shells are off-limits.
    ["agent:untrusted"] = {
      "cap:shell-exec",
      "cap:file-write",
    },

    -- Wildcard pattern: NO agent is allowed to escalate via sudo / dd,
    -- regardless of trust level. A broader `actions` rule, such as one on
    -- `tool:Bash`, cannot allow them again; only a rule that names
    -- `tool:Bash:sudo` itself can (see 05-action-rules.lua).
    ["*"] = {
      "tool:Bash:sudo",
      "tool:Bash:dd",
    },
  },
}

Stuck? Help finds the message you see.