Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/cursor-approve/tests/test_context_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ def test_no_shell_denies_shell_and_write(self):
run = self.steps["Run the axis"]
self.assertIn('["Shell(*)", "Write(**)", "WebFetch(*)"]', run)
self.assertIn("rm -rf -- .cursor", run)
self.assertIn("rm -f -- .cursorignore .cursorindexingignore", run)

def test_checkout_axes_are_allowed_a_shell(self):
# An empty allow list makes --print reject every shell call, so a
# checkout axis reviewed without ever running git. The allow rule is
# explicit, and a transcript where every shell call was rejected fails.
run = self.steps["Run the axis"]
self.assertIn('if os.environ["NO_SHELL"] != "true":\n allow.append("Shell(*)")', run)
self.assertIn('"rejected" in outcome', run)
self.assertIn('if os.environ["NO_SHELL"] != "true" and shell_rejected and not shell_ok:', run)

def test_every_axis_must_make_a_tool_call(self):
run = self.steps["Run the axis"]
self.assertIn(" if not recognized:\n", run)
self.assertNotIn('if os.environ["NO_SHELL"] == "true" and not recognized', run)

def test_business_and_design_require_no_shell_and_no_checkout(self):
check = self.steps["Check inputs"]
Expand Down
42 changes: 35 additions & 7 deletions .github/workflows/cursor-axis-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ name: Cursor axis (base)
# → no MCP server at all.
# no_shell true → deny cursor-agent's shell and file-write tools, and fail
# the job if the transcript shows one was called anyway. Required
# (with checkout false) for business and design.
# (with checkout false) for business and design. false → the
# shell is ALLOWED (an explicit Shell(*) rule), and the job fails
# if every shell call in the transcript was rejected.
# Secrets:
# CURSOR_API_KEY
# LINEAR_KEY, NOTION_TOKEN, SLACK_TOKEN optional, read-only bot tokens for
Expand Down Expand Up @@ -329,6 +331,9 @@ jobs:
# PR-authored .cursor/mcp.json or cli.json, so the proxy is the ONLY
# MCP server and the PR cannot widen the permissions below.
rm -rf -- .cursor
# A PR-authored ignore file could hide its own changes from the
# read and search tools of the reviewer judging it.
rm -f -- .cursorignore .cursorindexingignore
mkdir -m 700 .cursor
python3 - "$fifo_dir" <<'PY'
import json, os, sys
Expand All @@ -347,6 +352,14 @@ jobs:
# Write(**) is the permission behind the edit and delete tools too;
# WebFetch(*) keeps an agent that has read company context off the network.
deny = ["Shell(*)", "Write(**)", "WebFetch(*)"] if os.environ["NO_SHELL"] == "true" else []
# A checkout axis gets its shell by an explicit allow rule. --print
# has no one to approve a command, so with an empty allow list every
# shell call comes back `rejected` and the agent reviews blind; the
# transcript check below fails the job if that ever happens again.
# This is the same unsandboxed-shell-over-PR-code exposure the
# cursor-review panel already accepts (see its header).
if os.environ["NO_SHELL"] != "true":
allow.append("Shell(*)")
for name, value in (("mcp.json", {"mcpServers": servers}),
Comment thread
mattmillerai marked this conversation as resolved.
Resolved
("cli.json", {"permissions": {"allow": allow, "deny": deny}})):
with open(os.path.join(".cursor", name), "w", encoding="utf-8") as f:
Expand All @@ -365,9 +378,9 @@ jobs:
# its own artifact. With no_shell, a shell or file-write tool call in
# the transcript means this cursor-agent did not enforce the deny
# list: fail rather than trust a verdict from an agent that had them.
# A no_shell agent must read the fetched change, so a transcript with
# NO recognizable tool call means the stream-json shape drifted and
# the guard cannot see: fail closed then too. With context tools, the
# Any agent must read the change, so a transcript with NO recognizable
# tool call means the stream-json shape drifted and the guards cannot
# see: fail closed then too, on every axis. With context tools, the
# uploaded transcript keeps only each tool call's name, never its
# arguments or results (Linear, Notion and Slack content). The raw
# stream stays outside the uploaded directory, so a timeout or a
Expand All @@ -378,6 +391,7 @@ jobs:
forbidden = ("shellToolCall", "writeToolCall", "editToolCall", "deleteToolCall")
redact = bool(os.environ["CONTEXT_SOURCES"])
result, called, recognized, kept = None, set(), 0, []
shell_ok, shell_rejected = 0, 0
with open(sys.argv[1], encoding="utf-8", errors="replace") as f:
for line in f:
try:
Expand All @@ -393,6 +407,13 @@ jobs:
names = [k for k in call if k.endswith("ToolCall")]
recognized += bool(names)
called.update(k for k in call if k in forbidden)
shell = call.get("shellToolCall")
if event.get("subtype") == "completed" and isinstance(shell, dict):
outcome = shell.get("result")
if isinstance(outcome, dict) and "rejected" in outcome:
shell_rejected += 1
else:
shell_ok += 1
if redact:
event = {"type": "tool_call", "subtype": event.get("subtype"),
"call_id": event.get("call_id"), "tools": sorted(call)}
Expand All @@ -404,9 +425,16 @@ jobs:
if os.environ["NO_SHELL"] == "true" and called:
sys.exit(f"::error::no_shell is set but the agent called {', '.join(sorted(called))}; "
"this cursor-agent version does not enforce the deny list")
if os.environ["NO_SHELL"] == "true" and not recognized:
sys.exit("::error::no_shell is set but the transcript has no recognizable tool call; "
"its stream-json shape may have changed, so the deny-list check cannot run")
# Every axis must read something, so no recognizable tool call means
# the stream-json shape drifted (or the agent judged blind): fail.
if not recognized:
sys.exit("::error::the transcript has no recognizable tool call; its stream-json "
"shape may have changed, or the agent read nothing before its verdict")
# A checkout axis whose every shell call was rejected never ran the
# git its prompt points at: the allow rule above stopped working.
if os.environ["NO_SHELL"] != "true" and shell_rejected and not shell_ok:
sys.exit(f"::error::all {shell_rejected} shell call(s) were rejected; this axis is "
"meant to have a shell, so its verdict would be blind")
if result is None:
sys.exit("::error::the cursor-agent transcript has no result event")
with open(sys.argv[2], "w", encoding="utf-8") as f:
Expand Down
14 changes: 10 additions & 4 deletions docs/callers/cursor-approve.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ holds the tokens: the agent can search, but never holds a credential.
|---|---|---|---|
| business | PR title, body, changed-file list with line counts — no checkout, no shell | `linear_search`, `linear_get_issue`, `notion_search`, `notion_get_page`, `slack_search`, `slack_history` | `CURSOR_API_KEY`, `LINEAR_KEY`, `NOTION_TOKEN`, `SLACK_TOKEN` |
| design | PR title, body, merge-base diff cut at 200 KB — no checkout, no shell | `linear_search`, `linear_get_issue`, `notion_search`, `notion_get_page` | `CURSOR_API_KEY`, `LINEAR_KEY`, `NOTION_TOKEN` |
| completeness | Full read-only checkout (`persist-credentials: false`), shell allowed for `git` | `linear_search`, `linear_get_issue` | `CURSOR_API_KEY`, `LINEAR_KEY` |
| completeness | Full read-only checkout (`persist-credentials: false`), with a shell | `linear_search`, `linear_get_issue` | `CURSOR_API_KEY`, `LINEAR_KEY` |

A missing token leaves that source unconfigured; the axis still runs. The tokens
are read-only bot identities (Linear and Notion as the tools bot, Slack as the
Expand Down Expand Up @@ -432,9 +432,15 @@ context. A prompt injection in any of it can make the agent repeat that context
into its verdict summary, which lands on the PR, or steer its verdict. That is
acceptable on private repositories only, where everyone who can read the PR can
already read the company, and is why the axes refuse to run on a public one.
The completeness axis keeps a shell for `git`: on a hosted runner (passwordless
`sudo`) a hostile agent could read the running proxy's memory, so its Linear
token is protected by policy and prompt, not by the sandbox.
The checkout axes (correctness, conformance, completeness) have a shell, granted
by an explicit `Shell(*)` allow rule: `--print` has no one to approve a command,
so without that rule every shell call is rejected and the axis reviews without
ever running `git`. The job fails if every shell call in a checkout axis's
transcript was rejected, and on any axis whose transcript shows no tool call.
That shell is the same unsandboxed exposure over PR code that the cursor-review
panel already accepts. For completeness it also means: on a hosted runner
(passwordless `sudo`) a hostile agent could read the running proxy's memory, so
its Linear token is protected by policy and prompt, not by the sandbox.

## Trust model

Expand Down
Loading