harden the pilot against hostile PR content, add review skills + a cost model #7
Reference in New Issue
Block a user
Delete Branch "harden/security-and-robustness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two commits.
harden(pilot)— the reviewer runs an opencode agent withbash: "*": allowover a checkout of the PR author's branch, and the pod holds a Gitea Write credential. There was no wall between those two facts._build_envnow allow-lists the subprocess environment instead of inheriting it, soPRAGENT_BOT_TOKENandWEBHOOK_SECRETnever reach the agent.sanitize_workdirdeletes author-controlled agent-instruction files (nestedAGENTS.md,CLAUDE.md,.cursorrules, a repoopencode.json/.opencode) before opencode starts.--- UNTRUSTED ---markers; the agent, the three lens subagents andreview-methodologynow report injection attempts as acriticalfinding instead of obeying them..pr-review.jsonis read from the base branch, not the PR head.(repo, index, sha)claim that closes the check-then-act race in the sha dedupe; request bodies capped.a//b/prefixes; the CI template pinsPRAGENT_ENGINE=ollama.feat(factory)— five conditionally-loaded skills (attention-tiering,linter-playbook,security-lens,malicious-change,comment-craft) andpilot/cost_model.py, which prices a review against published Claude and OpenAI rates from measured factory prompt sizes.Tests: 68 -> 122.
Labelled
AI-REVIEW+AI-USAGEto exercise the newly deployed image end to end.🤖 AI Review · pragent pilot · glm-5.2:cloud ·
30d2a3d7Tier:
full(~1200 changed lines, security-sensitive: subprocess env, file I/O, tar extraction, CI, secrets). This PR hardens the pragent pilot against hostile PR content — allow-listed subprocess env (no bot token/webhook secret reach the agent), sanitize_workdir strips author-controlled agent-instruction files before opencode starts, _extract_tar_strip_one blocks tar-slip via escaping symlinks/traversal/symlink-through-writes, .pr-review.json is read from the base branch, the container runs as uid 10001, review concurrency is bounded, and an in-flight (repo,index,sha) claim closes the sha-dedupe check-then-act race; plus five conditionally-loaded review skills and a per-review cost model. Verified the tar guards against chained-symlink, parent-replacement and hardlink escape attempts (all blocked), confirmed _ENV_ALLOW drops every secret, confirmed sanitize runs before drop_factory, ran ruff on changed files (no new diagnostics on added lines), and ran the full suite (122 passed). No prompt-injection attempts directed at the reviewer were found — the injection-looking strings are all in the defensive docs/tests that define detection. No actionable defects.🔋 AI usage
glm-5.2:cloud· engine: opencode · agent steps: 28 · duration: 348.3sNo issues found.
🤖 AI Review · pragent pilot · glm-5.2:cloud ·
2613b3e3AI review produced no parseable output.
🤖 AI Review · pragent pilot · glm-5.2:cloud ·
5d28f970Tier:
full. This PR hardens the pragent pilot against hostile PR content: allow-listed subprocess env (no bot token/webhook secret reach the agent), sanitize_workdir strips author-controlled agent-instruction files before opencode starts, _extract_tar_strip_one blocks tar-slip via escaping symlinks/traversal/writes-through-symlinks, .pr-review.json is read from the base branch (URL-encoded), the container runs as uid 10001, review concurrency is bounded, and an in-flight (repo,index,sha) claim closes the sha-dedupe race; plus five conditionally-loaded review skills and a per-review cost model. Independently verified: tar guards block hardlink/dir-symlink/chained-symlink escapes, _build_env leaks no secrets, README cost figures reproduce exactly from cost_model.py, ruff/pyright errors are all on pre-existing untouched lines, and all 131 tests pass. No prompt-injection attempts directed at the reviewer. No actionable defects.🔋 AI usage
glm-5.2:cloud· engine: opencode · agent steps: 31 · duration: 189.8sNo issues found.
🤖 AI Review · pragent pilot · glm-5.2:cloud ·
80501840Tier: full (~1200 changed lines, 23 files, security-sensitive: subprocess env, tar extraction, Dockerfile, webhook HMAC, CI). This PR hardens the pragent pilot against hostile PR content — _build_env allow-lists the subprocess env (PRAGENT_BOT_TOKEN/WEBHOOK_SECRET never reach the agent), sanitize_workdir strips author-controlled agent-instruction files before opencode starts, _extract_tar_strip_one blocks tar-slip via escaping symlinks/traversal/writes-through-symlinks, .pr-review.json is read from the base branch, the container runs as uid 10001, review concurrency is bounded, and an in-flight (repo,index,sha) claim closes the sha-dedupe race — plus five conditionally-loaded review skills and a calibrated per-review cost model. Independently verified: ruff (16 diagnostics, all on pre-existing untouched lines), pyright (2 errors, both pre-existing), 131 tests pass, the tar-slip defense holds against chained/escaping/dangling-symlink variants (escaping links are rejected at creation so a later file's parent symlink can only point inside dest), the env allow-list drops every secret, and the cost model reproduces the README's $10.79/review and ~$1,740/month figures exactly. No prompt-injection attempts directed at the reviewer — the injection-looking strings are all in defensive test fixtures/docs that define detection. No actionable defects.
🔋 AI usage
glm-5.2:cloud· engine: opencode · agent steps: 26 · duration: 212.3sNo issues found.