补丁

效率工具 社区

技能解读

当前原文的自动摘译,尚未人工审校。

工作空间

./src — 当前 HEAD 上的存储库,在默认分支上,可写 ./context.json — 具有 scrutineer.api_base、scrutineer.token、scrutineer.repository_id、scrutineer.finding_id(必需;此技能仅在查找范围内有意义) ./report.json — 在此编写补丁 + 基本原理 ./schema.json — report.json的形状

该怎么办

阅读./context.json。如果scrutineer.finding_id丢失,将{"error": "no finding_id in context.json; patch is finding-scoped"}写入report.json并退出0。获取结果:GET {api_base}/findings/{finding_id}和Authorization: Bearer {token}。阅读location、cwe、trace、boundary、validation、rating。这五个共同告诉您接收器在哪里,易受攻击的输入流是什么样的,以及您需要阻止哪些危险行为。

拒绝打补丁

在任何这些情况下编写{"error": "...", "rationale": "..."}并退出 0 — 不要发布一个坏补丁:发现的散文太薄(空跟踪,空验证)。你需要知道水槽在哪里以及应该停止哪些行为。该修复是架构性的(例如“重写整个模块以不被破坏”)而不是可本地化的。修补技能建议进行手术修复;较大的更改是维护者的问题评论,而不是差异。

约束条件

不要推。不要承诺。不要打开 PR。监查员的工作空间是短暂且孤立的;您的差异是唯一在扫描中幸存下来的东西。不要添加依赖项,除非漏洞确实需要依赖项(例如,代码库已在其他地方使用的清理程序库)。补丁中的新顶级部门几乎总是意味着修复位置错误。不要编辑 lockfile、go.sum、Gemfile.lock、package-lock.json、Cargo.lock 等,除非您还更改了拥有它的清单。杂散的锁定文件搅动使得差异难以审查。

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
效率工具
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@tomevault-io · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
允许外网请求
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# patch

Propose a minimal code patch that fixes a confirmed finding. You are not shipping the fix; you are handing the analyst a starting diff and explaining what it does. The analyst reviews, edits if needed, and opens a PR by hand.

## Workspace

- `./src` — the repository at its current HEAD, on the default branch, writable
- `./context.json` — has `scrutineer.api_base`, `scrutineer.token`, `scrutineer.repository_id`, `scrutineer.finding_id` (required; this skill only makes sense finding-scoped)
- `./report.json` — write the patch + rationale here
- `./schema.json` — shape of `report.json`

## What to do

1. Read `./context.json`. If `scrutineer.finding_id` is missing, write `{"error": "no finding_id in context.json; patch is finding-scoped"}` to `report.json` and exit 0.

2. Fetch the finding: `GET {api_base}/findings/{finding_id}` with `Authorization: Bearer {token}`. Read `location`, `cwe`, `trace`, `boundary`, `validation`, `rating`. These five together tell you where the sink is, what the vulnerable input flow looks like, and what dangerous behaviour you need to stop.

3. Inside `./src`, edit files to fix the finding. Constraints:

   - **Minimal.** Change only what the fix requires. Do not refactor surrounding code, rename variables, reformat unrelated lines, or upgrade dependencies unless the fix inherently requires it.
   - **In place.** Fix the sink where it lives. If the finding's `location` is `pkg/foo/bar.go:42`, that is where the patch should land (or at the nearest layer where a guard is sensible — e.g. the input validator that feeds the sink).
   - **Consistent.** Match the existing code style and idioms. If the codebase uses a specific sanitiser, validator, or helper for similar cases, reuse it. Do not introduce a new helper module for a one-off fix.
   - **Safe.** The patch must not break the reproduction's documented legitimate behaviour — only block the dangerous path. If you cannot tell where the dangerous path diverges from legitimate use, stop and write an inconclusive report (see below).
   - **Include a test when practical.** If the repo has a test suite that covers the vulnerable code path, add a regression test that would fail without your patch. If the repo has no tests, or the sink is in a place that is hard to cover, skip this and say why in `rationale`.

4. Once you have a working tree edit, generate a unified diff against HEAD:

   ```sh
   cd src
   git add -N .
   git diff HEAD -- . > /tmp/patch.diff
   ```

   Read `/tmp/patch.diff` and put its contents into `report.json` under the `patch` field. Do not commit; the diff is the artefact. If the diff is empty, something went wrong — do not write an empty patch. Write `{"error": "patch produced no diff"}` and exit 0.

5. POST a finding note summarising the patch: `POST {api_base}/findings/{finding_id}/notes` with:

   ```json
   {
     "body": "Proposed patch in scan #{scan_id}.\n\nFiles changed: ...\n\n{short rationale}\n\nApply with: `git apply` the diff from the scan report.",
     "by": "patch"
   }
   ```

   The note lives on the finding page; the full diff lives in `report.json` and is viewable on the scan page.

6. Do not PATCH any editable fields on the finding. Specifically:
   - Do not set `fix_commit` — that field means a shipped upstream fix, not a proposal. The analyst sets it after their PR merges.
   - Do not set `fix_version` — same reason.
   - Do not touch `status`. Lifecycle transitions belong to the analyst.

7. Write `./report.json`:

   ```json
   {
     "patch": "diff --git a/pkg/foo/bar.go b/pkg/foo/bar.go\n...",
     "rationale": "Short prose — two or three sentences. What the guard is, why it blocks the trace, what legitimate input it still lets through.",
     "files_changed": ["pkg/foo/bar.go", "pkg/foo/bar_test.go"],
     "base_commit": "<HEAD sha from ./src>",
     "tests_added": true,
     "notes": "Optional: anything the analyst should know — a second sink you spotted but didn't patch, a style choice you weren't sure of, a test you couldn't write."
   }
   ```

   `base_commit` is the HEAD sha the diff applies to. The analyst needs this to `git am` or `git apply` cleanly — if they rebased since the scan, they know the patch may not apply and can regenerate.

## Refusing to patch

Write `{"error": "...", "rationale": "..."}` and exit 0 in any of these cases — do not ship a bad patch:

- The finding prose is too thin (empty Trace, empty Validation). You need both to know where the sink is and what behaviour to stop.
- The fix is architectural (e.g. "rewrite this whole module to not shell out") rather than localisable. A patch skill proposes a surgical fix; larger changes are an issue comment for the maintainer, not a diff.
- The codebase is in a language or framework you cannot confidently edit without risking regressions. It is better to say so than to produce a plausible-looking but wrong patch.
- The finding has already been fixed upstream. Check `git log -- {location}` — if a recent commit looks like it addressed the sink, surface the SHA in `notes` and refuse to duplicate.

## Constraints

- Do not push. Do not commit. Do not open a PR. The scrutineer workspace is ephemeral and isolated; your diff is the only thing that survives the scan.
- Do not add dependencies unless the vulnerability genuinely requires one (e.g. a sanitiser library the codebase already uses elsewhere). New top-level deps in a patch almost always mean the fix is in the wrong place.
- Do not edit the lockfile, go.sum, Gemfile.lock, package-lock.json, Cargo.lock, etc. unless you also changed the manifest that owns it. Stray lockfile churn makes diffs hard to review.
- Do not touch files outside what the fix requires. CI config, docs unrelated to the fix, README — leave alone.

---
> Source: [alexandre-daubois/scrutineer](https://github.com/alexandre-daubois/scrutineer) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。