Skip to content
Back to search

orca

MarketplaceWorks with Claude CodeGitHub

OrcaCode Review — the open code review harness. Multi-model reviews, merge gates, and no markup. Pay only for inference.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/continuum-ai-corp--orca-code-review/badge.svg)](/listings/continuum-ai-corp--orca-code-review)

HTML

<a href="/listings/continuum-ai-corp--orca-code-review"><img src="/api/listings/continuum-ai-corp--orca-code-review/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

One command teaches your AI what OrcaCode Review is. Everything after that, you just ask for.

npx @orcarouter/code-review

It asks how you will use it — local review, the GitHub Action, or both — detects which coding agents you use, installs the matching skills, and stops. Then:

> **you:** set up OrcaCode Review in this repo

Your agent writes the workflow, walks you through the API key, and sets the merge gate — asking only the questions that are actually yours to answer.

<p align="center"> </p>

The same goes for everything else:

| Say | It does | | --- | --- | | *"review my changes"* | Reviews them **locally**, itself — see [below](#review-locally-your-agent-is-the-engine) | | *"why didn't the review run?"* | Diagnoses the secret, the trigger, the base branch, the gate | | *"make OrcaCode Review block P0 only"* | Retunes the merge policy | | *"remove OrcaCode Review from this repo"* | Drops the required check first, then the workflow | | *"what can OrcaCode Review do?"* | Explains itself |

**Claude Code** can install the skill as a plugin instead, which keeps it updated:

/plugin marketplace add Continuum-AI-Corp/orca-code-review
/plugin install orca-code-review

36 agent platforms

The same catalog the [OrcaDub MCP server](https://github.com/Continuum-AI-Corp/orcadub-mcp-server) uses, so IDs and paths match across Orca products. Detected agents are pre-ticked; `/` filters the list. For CI or dotfiles, the same choices are flags (`--mode`, `--scope`, `--platform`, `--yes`) — `--help` lists them.

Prefer to wire it by hand? The manual steps are below.

Claude Code, Cursor, Codex, OpenCode, Windsurf, Cline, RooCode, Continue, GitHub Copilot, Gemini CLI, Amazon Q Developer, Qwen Code, Kilo Code, Auggie, Kimi Code, Kiro, Lingma, Junie, CodeBuddy Code, CoStrict, Crush, Factory Droid, iFlow, Pi, Qoder, Antigravity, Antigravity 2.0, Bob Shell, ForgeCode, Trae, Trae CN, ZCode, MimoCode, Hermes, OpenClaw, Command Code.

Two skills: `orca-review` for reviewing locally and `orca-review-action` for the GitHub Action. The installer asks which you want, or both. An existing identical skill is left unchanged; an existing **different** one is preserved unless you pass `--force`.

Language

The CLI speaks **English, Simplified Chinese, Japanese and Korean**, picked from your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`). The guided flow opens with a language screen; `ORCACODE_LANG=zh` pins it for good.

Traditional Chinese locales (`zh-TW`, `zh-HK`) fall back to English on purpose — the vocabulary diverges enough that serving Simplified reads worse than not translating at all.

Menus are arrow-key driven — `↑↓` to move, `Enter` to pick. Multi-select adds `space` to toggle, `a`/`n` for all/none, and `/` to filter (`ctrl-u` clears it), which is how you find one agent among 36 without scrolling. Terminals without raw mode fall back to typing a number.

Only prose is translated — flags, platform IDs, workflow inputs, and shell commands stay verbatim, because you still have to type them.

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 26 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "name": "orca",
  3. "owner": {
  4. "name": "Continuum-AI-Corp",
  5. "url": "https://github.com/Continuum-AI-Corp"
  6. },
  7. "metadata": {
  8. "description": "Skills for OrcaRouter products.",
  9. "version": "2.1.0"
  10. },
  11. "plugins": [
  12. {
  13. "name": "orca-code-review",
  14. "source": "./",
  15. "description": "Review code changes locally with your own agent as the engine, and set up, reconfigure, troubleshoot, or remove OrcaCode Review — AI pull-request review powered by OrcaRouter — in any GitHub repository.",
  16. "category": "code-review",
  17. "keywords": [
  18. "code-review",
  19. "github-actions",
  20. "ci",
  21. "pull-request",
  22. "local-review"
  23. ]
  24. }
  25. ]
  26. }
README.md · README · 320 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # OrcaCode Review
  2. **[AI code review](https://www.orcarouter.ai/code-review) that catches serious issues before they merge — powered by ****[OrcaRouter](https://www.orcarouter.ai/)****.**
  3. Automatically review every pull request, post findings directly on the affected lines, and block serious issues from merging.
  4. **P0/P1 → ❌ Block** · **Findings → 💬 Comment** · **Clean → ✅ Pass**
  5. ---
  6. <p align="center">
  7. <img src="docs/demo-install.gif" alt="npx @orcarouter/code-review: pick how you will use it, where to install, which agents — done" width="900">
  8. </p>
  9. ---
  10. ## How it works
  11. ```text
  12. PR → Review → Merge Gate
  13. │
  14. P0/P1?
  15. ↓
  16. BLOCK
  17. ```
  18. Every push gets one review. Findings post on the affected lines, and P0/P1 blocks the merge.
  19. **You choose the model in OrcaRouter. OrcaCode handles the review.**
  20. ### What you get
  21. * 🔍 Automatic review on every PR
  22. * 💬 Inline findings on the affected lines
  23. * 🛑 Merge gate for serious issues
  24. * 🧠 Choose your own review model
  25. * 🎯 Precision filtering to reduce false positives
  26. * 🔒 OrcaRouter guardrails + security policies
  27. * 🔄 Re-run anytime with `/orcacode-review`
  28. ---
  29. ## Install
  30. One command teaches your AI what OrcaCode Review is. Everything after that, you just ask for.
  31. ```bash
  32. npx @orcarouter/code-review
  33. ```
  34. It asks how you will use it — local review, the GitHub Action, or both — detects which coding agents you use, installs the matching skills, and stops. Then:
  35. > **you:** set up OrcaCode Review in this repo
  36. Your agent writes the workflow, walks you through the API key, and sets the merge gate — asking only the questions that are actually yours to answer.
  37. <p align="center">
  38. <img src="docs/demo-setup.gif" alt="Claude Code with the orca-review-action skill: asks the merge-gate decisions, writes the workflow, hands the API key step to you" width="900">
  39. </p>
  40. The same goes for everything else:
  41. | Say | It does |
  42. | --- | --- |
  43. | *"review my changes"* | Reviews them **locally**, itself — see [below](#review-locally-your-agent-is-the-engine) |
  44. | *"why didn't the review run?"* | Diagnoses the secret, the trigger, the base branch, the gate |
  45. | *"make OrcaCode Review block P0 only"* | Retunes the merge policy |
  46. | *"remove OrcaCode Review from this repo"* | Drops the required check first, then the workflow |
  47. | *"what can OrcaCode Review do?"* | Explains itself |
  48. **Claude Code** can install the skill as a plugin instead, which keeps it updated:
  49. ```text
  50. /plugin marketplace add Continuum-AI-Corp/orca-code-review
  51. /plugin install orca-code-review
  52. ```
  53. ### 36 agent platforms
  54. The same catalog the [OrcaDub MCP server](https://github.com/Continuum-AI-Corp/orcadub-mcp-server) uses, so IDs and paths match across Orca products. Detected agents are pre-ticked; `/` filters the list. For CI or dotfiles, the same choices are flags (`--mode`, `--scope`, `--platform`, `--yes`) — `--help` lists them.
  55. Prefer to wire it by hand? The manual steps are below.
  56. Claude Code, Cursor, Codex, OpenCode, Windsurf, Cline, RooCode, Continue, GitHub Copilot, Gemini CLI, Amazon Q Developer, Qwen Code, Kilo Code, Auggie, Kimi Code, Kiro, Lingma, Junie, CodeBuddy Code, CoStrict, Crush, Factory Droid, iFlow, Pi, Qoder, Antigravity, Antigravity 2.0, Bob Shell, ForgeCode, Trae, Trae CN, ZCode, MimoCode, Hermes, OpenClaw, Command Code.
  57. Two skills: `orca-review` for reviewing locally and `orca-review-action` for the GitHub Action. The installer asks which you want, or both. An existing identical skill is left unchanged; an existing **different** one is preserved unless you pass `--force`.
  58. ### Language
  59. The CLI speaks **English, Simplified Chinese, Japanese and Korean**, picked from your locale (`LC_ALL` / `LC_MESSAGES` / `LANG`). The guided flow opens with a language screen; `ORCACODE_LANG=zh` pins it for good.
  60. Traditional Chinese locales (`zh-TW`, `zh-HK`) fall back to English on purpose — the vocabulary diverges enough that serving Simplified reads worse than not translating at all.
  61. Menus are arrow-key driven — `↑↓` to move, `Enter` to pick. Multi-select adds `space` to toggle, `a`/`n` for all/none, and `/` to filter (`ctrl-u` clears it), which is how you find one agent among 36 without scrolling. Terminals without raw mode fall back to typing a number.
  62. Only prose is translated — flags, platform IDs, workflow inputs, and shell commands stay verbatim, because you still have to type them.
  63. ---
  64. ## Review locally — your agent is the engine
  65. The Action pays a model in CI to review every PR. You can also run the **same review, right now, in your terminal**, with no Action, no OrcaRouter account, and no API key — because the model is the one your coding agent already has.
  66. > **you:** review my changes
  67. <p align="center">
  68. <img src="docs/demo-review.gif" alt="Claude Code with the orca-review skill reviewing a pull request by number: plan, review, submit, verdict" width="900">
  69. </p>
  70. Claude Code, Codex, Cursor, or any of the 36 platforms picks up the `orca-review` skill and becomes the reviewer. You say what to review; the skill handles the rest:
  71. | Say | It reviews |
  72. | --- | --- |
  73. | *"review my changes"* | Uncommitted work if the tree is dirty, otherwise this branch against its base |
  74. | *"review this branch"*, *"review that commit"* | The range you named |
  75. | *"review PR 556"* | That pull request — **without checking it out**. It is fetched into a private ref; your work tree stays exactly where it was. Fork PRs included |
  76. | *"is this safe to merge?"* | Same, and the gate answers |
  77. Behind the skill are two CLI commands your agent runs for you: `review plan` decides what is in scope — with the reasons for what is not — and hands the agent the per-language checklists, the P0–P3 rubric, and your repo's own `AGENTS.md`/`CLAUDE.md` conventions; `review submit` verifies every finding is filed on the right line, drops duplicates, applies the merge gate, and prints the report your agent relays to you. Nothing that decides what blocks is left to the model.
  78. **It is the same severity contract the Action enforces** — the same `rules/severity-instruction.md`, the same position check, the same result shape. A P1 you find here is a P1 that would block there. That parity is the point: *"it passed locally"* has to mean something.
  79. The file selection is the engine's, without the engine: the exclusion rules and per-language checklists from [Open Code Review](https://github.com/alibaba/open-code-review) (Apache-2.0) ship inside this package, so a local review filters the same files CI would. Nothing extra to install.
  80. Settings that should stick live in a committed `.orcacode-review.json` — which severities block, which language to report in, paths never to review, extra checklists for parts of the tree. You do not write it by hand: after your first review in a repo the agent offers to save the settings it just used, and later *"from now on only block on P0 locally"* or *"never review docs/"* edits the right key.
  81. Scripting your own harness instead of using an agent? `review plan --json` and `review submit --json` are a stable, versioned contract; [`skills/orca-review/references/contract.md`](skills/orca-review/references/contract.md) is the reference.
  82. ---
  83. ## Quick Start
  84. ### 1. Enable OrcaCode Review
  85. Go to [**OrcaRouter**](https://www.orcarouter.ai/) → **Apps → OrcaCode Review** and turn it on.
  86. Configure your models, review mode, severity rules, merge policy, and other settings directly from the console.
  87. ### 2. Install the GitHub Action
  88. [**Install OrcaCode Review from GitHub Marketplace →**](https://github.com/marketplace/actions/orca-code-review)
  89. Add this workflow as `.github/workflows/orca-code-review.yml` (or let `npx @orcarouter/code-review` write it). Use the whole file, not just the `uses:` step: the job's `if:` is what keeps the paid `/orcacode-review` command to maintainers, and the concurrency block is what stops any commenter from cancelling a running review. The action also refuses an outsider's command on its own, but the workflow is the first gate.
  90. ```yaml
  91. name: OrcaCode Review
  92. on:
  93. pull_request_target:
  94. types: [opened, synchronize, reopened, ready_for_review, edited]
  95. issue_comment:
  96. types: [created]
  97. permissions:
  98. contents: read
  99. pull-requests: write
  100. issues: write
  101. statuses: write # used from v1.7.0 (unreleased): the verdict on the PR head
  102. jobs:
  103. review:
  104. runs-on: ubuntu-latest
  105. concurrency:
  106. group: ${{ github.workflow }}-${{ github.event_name == 'issue_comment' && 'comment' || 'pr' }}-${{ github.event.pull_request.number || github.event.issue.number }}
  107. cancel-in-progress: ${{ github.event_name != 'issue_comment' }}
  108. if: |
  109. (github.event_name == 'pull_request_target' &&
  110. (github.event.action != 'edited' || github.event.changes.base)) ||
  111. (github.event_name == 'issue_comment' &&
  112. github.event.issue.pull_request &&
  113. (startsWith(github.event.comment.body, '/orcacode-review') ||
  114. startsWith(github.event.comment.body, '/orcacode review') ||
  115. startsWith(github.event.comment.body, '@orcacode-review') ||
  116. startsWith(github.event.comment.body, '@orcacode review')) &&
  117. contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
  118. steps:
  119. - uses: Continuum-AI-Corp/orca-code-review@6d253e0399c84848fedc8801176d6bea77817762 # v1.6.0
  120. with:
  121. orcarouter-api-key: ${{ secrets.ORCAROUTER_API_KEY }}
  122. ```
  123. The action is pinned to a release **commit**, with its version in the comment, rather than to a tag that can be moved: enable Dependabot's `github-actions` updates and each new release arrives as a reviewable PR. The full example, with every optional input, is [`workflows/orca-code-review.yml`](workflows/orca-code-review.yml).
  124. ### 3. Add your API key
  125. Create or copy a key from [**OrcaRouter → API Keys**](https://www.orcarouter.ai/console/token).
  126. Add it to your GitHub repository as:
  127. ```text
  128. ORCAROUTER_API_KEY
  129. ```
  130. under **Settings → Secrets and variables → Actions**.
  131. ### 4. Open a PR
  132. **That's it.**
  133. OrcaCode automatically reviews new PRs and pushes, posts findings inline, and reports the merge gate.
  134. ---
  135. ## Severity
  136. | Severity | Meaning | Merge gate | Posted inline |
  137. | -------- | -------------------- | ---------- | ---------------------- |
  138. | **P0** | Critical / blocker | ❌ Block | Always |
  139. | **P1** | High severity | ❌ Block | Always |
  140. | **P2** | Advisory | ✅ Pass | Per Report severities |
  141. | **P3** | Nit / style | ✅ Pass | Per Report severities |
  142. Two independent settings, and the defaults above are the shipped ones:
  143. * **Merge policy** decides what blocks.
  144. * **Report severities** decides what gets posted on the diff.
  145. A severity that blocks is always posted, whatever Report severities says — a
  146. failing check with nothing on the diff explaining it is worse than a noisy one.
  147. Narrowing Report severities never changes the gate, and the PR summary always
  148. counts every finding, so a muted P2 still shows up there.
  149. Customize the rubric and both policies from **OrcaRouter → Apps → OrcaCode Review**.
  150. ---
  151. ## Configure without touching YAML
  152. Manage OrcaCode from **OrcaRouter → Apps → OrcaCode Review**:
  153. * **Model** — choose your reviewer
  154. * **Review mode** — every push, ready for review, or on demand
  155. * **Merge policy** — choose which severities block
  156. * **Report severities** — choose which severities post on the diff
  157. * **Exhaustive review** — run additional passes over the same diff
  158. * **Quiet mode** — keep P2 findings in the summary
  159. * **Custom rubric** — define your own review rules
  160. * **Guardrails** — add security and policy checks
  161. **Change your review strategy anytime. No GitHub workflow edits required.**
  162. ---
  163. ## Re-run a review
  164. Comment on any PR:
  165. ```text
  166. /orcacode-review
  167. ```
  168. to request another review. Only an **owner, member or collaborator** can: the workflow's `if:` ignores the command from anyone else.
  169. From v1.7.0 (unreleased) the action itself ignores an outsider's command too, whatever the workflow says, and the verdict lands on the PR's head commit as the `OrcaCode Review` status. On a PR **from a fork**, name the commit you looked at — `/orcacode-review <sha>`, at least 7 characters of it: the action reviews exactly that commit, and only while it is still the PR's head, so the fork cannot push something else in between. A bare command there, or a commit that is no longer the head, gets a reply with the current head and the command to use. Same-repository PRs keep the bare command.
  170. ---
  171. ## Block merges
  172. To make P0/P1 findings actually prevent merging:
  173. **GitHub → Settings → Branches / Rulesets → Require status checks to pass**
  174. Add the **`review`** check (the workflow's job) as required. An oversized diff fails it by default (`on-oversized-diff: "pass"` makes that advisory); a skipped review — on-demand mode, auto-review off, a draft, an author outside `auto-review-authors` — passes it with a notice on the PR.
  175. From v1.7.0 (unreleased), the action also writes an **`OrcaCode Review`** commit status on the PR's head commit at the end of every run (grant `statuses: write`). It is green only when a review actually ran on that commit and the gate passed; a skipped review reads **"Not reviewed: …"**. Require that status instead of the `review` job once your workflow pins the release that writes it: it is the only check an on-demand `/orcacode-review` run can update on the PR (GitHub reports that run's own job check on the default branch), and it keeps an unreviewed PR from merging while the job stays green. `on-skipped-review: "fail"` fails the job on a skip too.
  176. ---
  177. ## Upgrading: what changes from v1.7.0 (unreleased)
  178. Security hardening that changes what you may see. The installer, the example workflow and the quickstart above still pin **v1.6.0**, so none of this applies until you pin the release that ships it. Inputs are unchanged except for three new ones; defaults that close a hole are new.
  179. | What changed | What you will notice | To keep the old behaviour |
  180. | --- | --- | --- |
  181. | `auto-review-authors` unset on a **public** repo now means `OWNER,MEMBER,COLLABORATOR` (private repos: everyone, as before) | Fork PRs from outsiders are no longer auto-reviewed on your wallet; a maintainer can `/orcacode-review` them | `auto-review-authors: "OWNER,MEMBER,COLLABORATOR,CONTRIBUTOR,FIRST_TIME_CONTRIBUTOR,FIRST_TIMER,MANNEQUIN,NONE"` (`"*"` works too from v1.7.0 (unreleased), but v1.6.0 reads it as nobody) |
  182. | New `status-context` (default `"OrcaCode Review"`) | A commit status on the PR head after every run, on-demand runs included: green only for a reviewed head whose gate passed; a skipped review is **"Not reviewed"**. Grant `statuses: write`; require this status instead of the `review` job | `status-context: ""` |
  183. | New `on-skipped-review` (default `"pass"`) | Nothing, by default: a skipped review still passes the job. `"fail"` fails the job on a skip too | — |
  184. | New `bot-login` (default `""`) | Only for a custom GitHub App token: name its login (`"my-app[bot]"`) so the action recognises its earlier notices and edits them instead of posting new ones | — |
  185. | Comment commands are checked by the action | `/orcacode-review` from anyone but an owner, member or collaborator, or any other comment, is a no-op | — |
  186. | The pusher is checked, not only the author | A push to a fork PR by someone other than its author, who cannot write to your repository, is not auto-reviewed (the status says "Not reviewed"); a maintainer can `/orcacode-review` it | `auto-review-authors: "*"` |
  187. | An allowlist of events | The action runs only on `pull_request` / `pull_request_target` (opened, synchronize, reopened, ready_for_review, a retargeting edit) and `issue_comment` (created); anything else — `pull_request_review`, `pull_request_review_comment`, a push — is a no-op that says why | — |
  188. | A settings fetch that gets no settings — a 4xx (an ordinary, non-CI key gets one on every run) or an outage | The workflow's inputs apply for that run, exactly as with `settings: "false"`, and the log names the cause. `block-on` in the workflow is the outage floor: set it to what the dashboard enforces if an outage must not loosen the gate | — |
  189. | The gate fails closed | A result the gate cannot read now fails the check instead of passing | — |
  190. | `engine-version` must be pinned | Only versions with checksums in `scripts/engine-pins.json` install; anything else fails the run | — |
  191. | `orcarouter-url` must be https | A plain-http gateway URL fails the run at its first step, with an error naming `orcarouter-url` and the fix (put TLS in front of a self-hosted gateway). Plain http stays allowed to this machine — `localhost`, `127.0.0.0/8`, `[::1]`. The settings fetch and the run report no longer send the key over plain http either | — |
  192. | What is posted is sanitised | @mentions don't ping, HTML is shown as text, off-site links are shown as code, at most 50 findings are posted per review, guardrail details are hidden on public repos | — |
  193. | The checkout is hardened | Symlinks are removed, the PR's `.gitattributes` cannot hide the diff, the base `.gitignore` applies; the summary lists changed files the engine skips. Lockfiles (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lockb`, `go.sum`, `Cargo.lock`, `poetry.lock`, `composer.lock`, `Gemfile.lock`, by file name) are not counted toward `max-diff-kb` / `max-diff-files`, so a dependency bump does not skip a PR; the summary lists them | — |
  194. | Severity is never lowered | Duplicates keep the most severe tag; the judge cannot drop a P0 or a security finding | — |
  195. | Shipped workflows | Per-job concurrency (a comment cannot cancel a running review; a newer comment replaces only a comment run still pending), re-run on `reopened` and on a retargeted base (`edited`), `statuses: write`, the action pinned to a commit SHA | Update your copy from [`workflows/orca-code-review.yml`](workflows/orca-code-review.yml) |
  196. Self-hosted runners need git 2.31 or newer for private-repository fetches (the token travels in `GIT_CONFIG_*` environment variables, not on git's command line).
  197. ---
  198. ## Security & Privacy
  199. OrcaCode reads the PR diff and repository files required for review. **It does not execute PR code.** From v1.7.0 (unreleased), **the review engine never holds your API key** — an in-job proxy adds it on the way to OrcaRouter — and everything posted to the PR is sanitised and has your key and token redacted.
  200. Optional run reporting sends only review metadata — repository, PR, commit SHA, tier, severity counts, gate result, and engine version.
  201. **No source code, diff, or finding text is included in run reports.**
  202. OrcaRouter guardrails can add secret detection, PII detection, prompt-injection protection, code-security rules, and external security scanners.
  203. See [`SECURITY.md`](./SECURITY.md) for details.
  204. ---
  205. ## Under the hood
  206. OrcaCode Review uses [Open Code Review](https://github.com/alibaba/open-code-review) as its review engine and **OrcaRouter for model routing, policy, and control**.
  207. **OrcaCode decides how to review. OrcaRouter decides what model runs it.**
  208. ## License
  209. [MIT](./LICENSE) © Continuum-AI-Corp.
  210. Open Code Review is Apache-2.0. Attribution is preserved in [`NOTICE`](./NOTICE).
scripts/publish-guard.test.mjs · Bundled script · 239 lines
  1. // publish-guard.mjs — the one funnel every byte the action posts to GitHub goes
  2. // through (comments, reviews, the PR description, commit statuses).
  3. //
  4. // Two jobs, both because what the action posts is partly written by the PR:
  5. // 1. sanitizeUntrusted(): finding text and file paths come from the engine,
  6. // which read a fork's files. They must not ping people (@org/team), carry
  7. // HTML (<img>, <details>, comments that fake the action's own markers),
  8. // link anywhere but this repository and the OrcaRouter docs, forge
  9. // headings ("## OrcaCode Review ✅ No findings"), or run on without bound.
  10. // 2. redactSecrets() / guardGithub(): the OrcaRouter key and the GitHub token
  11. // never appear in anything posted — raw, base64 (at any alignment inside a
  12. // longer base64 run), base64url, URL-encoded, or as the Basic-auth value.
  13. import { describe, test } from "node:test";
  14. import assert from "node:assert/strict";
  15. import {
  16. sanitizeUntrusted,
  17. codeSpan,
  18. redactSecrets,
  19. guardGithub,
  20. MAX_FINDING_CHARS,
  21. } from "./publish-guard.mjs";
  22. const REPO = { owner: "acme", repo: "widgets" };
  23. const clean = (t) => sanitizeUntrusted(t, { repo: REPO });
  24. describe("sanitizeUntrusted: mentions", () => {
  25. test("@user and @org/team are neutralised with a zero-width joiner", () => {
  26. const out = clean("cc @alice and @acme/security-team please look");
  27. assert.doesNotMatch(out, /@alice|@acme\//);
  28. assert.match(out, /@\u200Dalice/);
  29. assert.match(out, /@\u200Dacme\/security-team/);
  30. });
  31. test("a mention inside code is neutralised too (GitHub would not ping, but a mis-parse must not)", () => {
  32. assert.doesNotMatch(clean("use `@Override` here"), /@Override/);
  33. });
  34. });
  35. describe("sanitizeUntrusted: HTML", () => {
  36. test("<img> and other tags are escaped, not rendered", () => {
  37. const out = clean('see <img src="https://evil.example/t.png" onerror=alert(1)> and <details>x</details>');
  38. assert.doesNotMatch(out, /<img|<details/i);
  39. assert.match(out, /&lt;img/);
  40. });
  41. test("HTML comments are removed — including ones faking the action's markers", () => {
  42. const out = clean("before <!-- orca-code-review-summary --> after <!-- unclosed");
  43. assert.doesNotMatch(out, /<!--|orca-code-review-summary/);
  44. assert.match(out, /before/);
  45. assert.match(out, /after/);
  46. });
  47. test("code spans and fenced blocks keep their < characters", () => {
  48. assert.match(clean("the type `List<String>` is raw"), /`List<String>`/);
  49. assert.match(clean("```html\n<div onclick=x>\n```"), /<div onclick=x>/);
  50. });
  51. test("an escaped backtick does not open a code span", () => {
  52. assert.doesNotMatch(clean("\\`<img src=x>`"), /<img/);
  53. });
  54. test("an unclosed backtick does not make the rest code", () => {
  55. assert.doesNotMatch(clean("`<img src=x>"), /<img/);
  56. });
  57. test("a code span cannot run across a blank line", () => {
  58. assert.doesNotMatch(clean("`a\n\n<img src=x>`"), /<img/);
  59. });
  60. });
  61. describe("sanitizeUntrusted: links", () => {
  62. test("[x](https://evil) is not a link any more", () => {
  63. const out = clean("click [here](https://evil.example/phish) now");
  64. assert.doesNotMatch(out, /\]\(https:\/\/evil/);
  65. assert.match(out, /`https:\/\/evil\.example\/phish`/, "the URL stays visible, defanged in code");
  66. });
  67. test("images are not rendered", () => {
  68. assert.doesNotMatch(clean("![logo](https://evil.example/i.png)"), /!\[[^\]]*\]\(/);
  69. });
  70. test("a bare URL to another host is defanged; this repo and the docs host stay links", () => {
  71. const out = clean(
  72. "a https://evil.example/x b https://github.com/acme/widgets/blob/main/a.js#L3 " +
  73. "c https://github.com/other/repo d https://www.orcarouter.ai/code-review e www.evil.example",
  74. );
  75. assert.match(out, /`https:\/\/evil\.example\/x`/);
  76. assert.match(out, /`https:\/\/github\.com\/other\/repo`/);
  77. assert.match(out, /`www\.evil\.example`/);
  78. assert.match(out, /[^`]https:\/\/github\.com\/acme\/widgets\/blob\/main\/a\.js#L3/);
  79. assert.match(out, /[^`]https:\/\/www\.orcarouter\.ai\/code-review/);
  80. });
  81. test("a reference-style link definition cannot form", () => {
  82. const out = clean("[ref]\n\n[ref]: https://evil.example");
  83. assert.doesNotMatch(out, /^\[ref\]:/m);
  84. });
  85. });
  86. describe("sanitizeUntrusted: forged structure and size", () => {
  87. test("a finding cannot start a heading (no fake '## OrcaCode Review ✅ No findings')", () => {
  88. const out = clean("ok\n## 🐳 OrcaCode Review\n\n✅ **No findings**\n===\n");
  89. assert.doesNotMatch(out, /^\s{0,3}#/m);
  90. assert.doesNotMatch(out, /^\s{0,3}=+\s*$/m);
  91. });
  92. test("length is capped", () => {
  93. const out = clean("x".repeat(MAX_FINDING_CHARS * 2));
  94. assert.ok(out.length <= MAX_FINDING_CHARS + 40, `got ${out.length}`);
  95. assert.match(out, /truncated/);
  96. });
  97. });
  98. describe("codeSpan: a file path as inline code", () => {
  99. test("backticks, newlines and control characters cannot break out", () => {
  100. const out = codeSpan("a`b\n## x\u0000.js");
  101. assert.equal((out.match(/`/g) || []).length, 2);
  102. assert.doesNotMatch(out, /\n/);
  103. });
  104. });
  105. describe("redactSecrets", () => {
  106. const KEY = "sk-orca-0123456789abcdefXYZ";
  107. const TOKEN = "ghs_16C7e42F292c6912E7710c838347Ae178B4a";
  108. const secrets = [KEY, TOKEN];
  109. const b64 = (s) => Buffer.from(s).toString("base64");
  110. test("raw values", () => {
  111. const out = redactSecrets(`key=${KEY} token=${TOKEN}`, secrets);
  112. assert.ok(!out.includes(KEY) && !out.includes(TOKEN));
  113. assert.match(out, /\[REDACTED\]/);
  114. });
  115. test("base64, base64url and URL-encoded forms", () => {
  116. const weird = "sk/orca+key=0123456789&?";
  117. for (const form of [b64(KEY), b64(KEY).replace(/=+$/, ""), Buffer.from(weird).toString("base64url"), encodeURIComponent(weird)]) {
  118. const out = redactSecrets(`x ${form} y`, [KEY, weird]);
  119. assert.ok(!out.includes(form), `not redacted: ${form}`);
  120. }
  121. });
  122. test("base64 of the secret embedded at any alignment in a longer run", () => {
  123. for (const prefix of ["", "a", "ab", "abc", "Authorization: Basic "]) {
  124. const blob = b64(`${prefix}${KEY}${"tail-bytes"}`);
  125. const out = redactSecrets(blob, [KEY]);
  126. assert.notEqual(out, blob, `prefix ${JSON.stringify(prefix)} slipped through`);
  127. }
  128. });
  129. test("the GitHub Basic-auth value is redacted", () => {
  130. const basic = b64(`x-access-token:${TOKEN}`);
  131. assert.ok(!redactSecrets(`AUTHORIZATION: basic ${basic}`, secrets).includes(basic));
  132. });
  133. test("short or empty secrets are ignored rather than shredding the text", () => {
  134. assert.equal(redactSecrets("a b c", ["", "a", undefined]), "a b c");
  135. });
  136. test("hex, lower, upper and mixed case", () => {
  137. const hex = Buffer.from(KEY).toString("hex");
  138. const mixed = [...hex].map((c, i) => (i % 2 ? c.toUpperCase() : c)).join("");
  139. for (const form of [hex, hex.toUpperCase(), mixed]) {
  140. const out = redactSecrets(`dump: ${form} end`, [KEY]);
  141. assert.ok(!out.includes(form), `not redacted: ${form}`);
  142. assert.match(out, /^dump: \[REDACTED\] end$/);
  143. }
  144. });
  145. test("a copy split by invisible characters (zero-width, joiners, soft hyphen, bidi marks) is redacted", () => {
  146. for (const z of ["​", "‌", "‍", "⁠", "", "­", "‎"]) {
  147. const split = [...KEY].join(z);
  148. const out = redactSecrets(`x ${split} y`, [KEY]);
  149. assert.equal(out, "x [REDACTED] y", `split by U+${z.codePointAt(0).toString(16)}`);
  150. }
  151. const b64split = b64(KEY).replace(/(.{4})/g, "$1​");
  152. assert.ok(!redactSecrets(b64split, [KEY]).replace(/​/g, "").includes(b64(KEY).slice(4, 20)));
  153. });
  154. test("invisible characters elsewhere are left alone (a neutralised @‍mention stays neutralised)", () => {
  155. const text = `ping @‍alice about ${KEY}`;
  156. assert.equal(redactSecrets(text, [KEY]), "ping @‍alice about [REDACTED]");
  157. });
  158. });
  159. describe("guardGithub: every posting method is redacted on the way out", () => {
  160. const KEY = "sk-orca-0123456789abcdefXYZ";
  161. function fake() {
  162. const calls = [];
  163. const rec = (name) => async (args) => {
  164. calls.push({ name, args });
  165. return { data: {} };
  166. };
  167. return {
  168. calls,
  169. github: {
  170. paginate: async () => [],
  171. rest: {
  172. issues: { createComment: rec("createComment"), updateComment: rec("updateComment"), listComments: rec("listComments") },
  173. pulls: { createReview: rec("createReview"), update: rec("pullsUpdate"), get: rec("pullsGet") },
  174. repos: { createCommitStatus: rec("createCommitStatus") },
  175. },
  176. },
  177. };
  178. }
  179. test("comment, review (body + inline bodies), PR description and status description", async () => {
  180. const { github, calls } = fake();
  181. const gh = guardGithub(github, { secrets: [KEY] });
  182. await gh.rest.issues.createComment({ body: `a ${KEY}` });
  183. await gh.rest.issues.updateComment({ body: `b ${KEY}` });
  184. await gh.rest.pulls.createReview({ body: `c ${KEY}`, comments: [{ path: "x", body: `d ${KEY}` }] });
  185. await gh.rest.pulls.update({ body: `e ${KEY}` });
  186. await gh.rest.repos.createCommitStatus({ description: `f ${KEY}` });
  187. assert.equal(calls.length, 5);
  188. assert.ok(!JSON.stringify(calls).includes(KEY), JSON.stringify(calls));
  189. });
  190. test("reads pass through untouched", async () => {
  191. const { github, calls } = fake();
  192. const gh = guardGithub(github, { secrets: [KEY] });
  193. await gh.rest.pulls.get({ pull_number: 1 });
  194. assert.equal(calls[0].name, "pullsGet");
  195. assert.equal(gh.paginate, github.paginate);
  196. });
  197. test("secrets default to the CR_REDACT_* environment variables", async () => {
  198. const { github, calls } = fake();
  199. process.env.CR_REDACT_API_KEY = KEY;
  200. try {
  201. const gh = guardGithub(github);
  202. await gh.rest.issues.createComment({ body: `z ${KEY}` });
  203. } finally {
  204. delete process.env.CR_REDACT_API_KEY;
  205. }
  206. assert.ok(!calls[0].args.body.includes(KEY));
  207. });
  208. });

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.