๐Ÿ›ก๏ธ Interven
SaaS Agent Protection

GitHub Copilot

Protect GitHub Copilot Coding Agent tool calls via the preToolUse hook.

GitHub Copilot

GitHub Copilot Coding Agent supports preToolUse hooks โ€” synchronous scripts that run before every tool call (bash, edit, create, view, grep, glob, ...). Drop in @interven/copilot-hook and every tool call gets scanned through Interven before it runs.

Setup

1. Get an API key

app.intervensecurity.com/api-keys โ†’ mint key (iv_live_...).

2. Add the hook to your repo

Create .github/hooks/preToolUse.json:

{
  "command": "npx",
  "args": ["-y", "@interven/copilot-hook"],
  "env": {
    "INTERVEN_API_KEY": "iv_live_your_key_here"
  }
}

Commit and push.

3. Verify

Trigger a Copilot Coding Agent task. Watch decisions land in Activity.

How it works

Copilot wants to run `bash rm -rf production-data/`
       โ†“ Coding Agent invokes preToolUse hook
@interven/copilot-hook reads { toolName, toolArgs } from stdin
       โ†“ POST /v1/scan with method, url, body
Interven runs full policy + risk pipeline
       โ†“ returns ALLOW / DENY / SANITIZE / REQUIRE_APPROVAL
Hook writes JSON: { permissionDecision: "deny", reason: "DESTRUCTIVE_ACTION" }
       โ†“ Coding Agent honors the decision
Copilot is blocked

Decision mapping

Interven decisionCopilot result
ALLOWTool executes
DENYTool blocked, agent gets reason codes
SANITIZETool executes (hooks can't rewrite args), but scan logged with SANITIZE for audit
REQUIRE_APPROVALTool blocked. After analyst approves, agent retries within 10 min for auto-allow

Environment variables

VariableDefaultNotes
INTERVEN_API_KEYrequiredInterven API key
INTERVEN_GATEWAYhttps://api.intervensecurity.comOverride for self-hosted
INTERVEN_TIMEOUT_MS5000Hard timeout per scan
INTERVEN_FAIL_CLOSED0Set to 1 to deny on hook failures (default: fail open to avoid breaking dev loop)

Limitations

  • The hook can allow or deny. It cannot rewrite tool arguments.
  • preToolUse hooks are not enforced in subagents (GitHub issue #2392).
  • Failures default to fail-open. For high-stakes repos, set INTERVEN_FAIL_CLOSED=1.