Codex Security 可以帮助你把已接受的待处理发现转化为经过测试的代码改动。你可以在发现工作区(findings workspace)UI 中修复发现,也可以从提示词、命令行或 CI/CD 调用修复工作流。每种方式都会让 Codex 验证问题、提出聚焦 patch、添加回归覆盖,并验证合法行为仍然正常。
建议先修复一个已接受的发现,用来评估 patch 和验证质量。等工作流达到你的标准后,再通过把每个发现放进独立任务或 CI/CD job,扩展到更多已接受的发现。让每个修复保持聚焦,会让代码改动和证据更容易审查。
在 UI 中修复发现
在发现工作区中打开一个已接受的发现,生成、审查、应用并验证它的 patch。
1. 生成聚焦 patch
打开发现,选择 Patch 标签页,然后选择 Generate patch。Codex 会在可行时验证或复现问题,并写入 patch 产物,而不会修改选中的 checkout。
2. 审查建议 diff
阅读每个变更的源码文件和回归测试文件。如果想在编辑器里查看完整 patch,请使用 Open diff in editor。拒绝过宽的重构、无关清理,或会削弱其它安全控制的改动。
3. 本地应用 patch
只有当 diff 可以接受时,才选择 Apply patch locally。Codex 会把精确生成的 patch 应用到 working tree,并记录该状态。继续之前,请审查 working-tree diff。
4. 验证修复
选择 Verify fix。Codex 会重新运行原始 reproducer 或最强可用 exploit check、聚焦回归覆盖、合法行为检查、附近 bypass 检查,以及相关仓库测试。
5. 有意地关闭发现
验证不会自动关闭发现。请审查命令、结果和剩余证据缺口(proof gap),然后用准确原因关闭发现,或继续保持打开以便后续处理。
从 CLI 修复发现
当你已经有来自扫描、ticket、advisory、disclosure、安全评估或内部审查的发现时,可以使用 Codex CLI:
下面的命令假设 Codex Security 已经安装在 codex exec 使用的 CODEX_HOME 中。全新的 CI runner 默认没有安装 marketplace 插件。
Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Validate the issue, make the smallest safe change, add focused regression coverage, and verify that the issue no longer reproduces.请包含已知的 source、sink、攻击者输入、影响、预期不变量、reproducer、受影响文件和验证命令。Codex 可以检查仓库来补齐缺失的技术细节,但在猜测产品策略或预期安全不变量前应先询问。
对于自动化运行,在 checkout 代码、准备好发现报告,并在该 CODEX_HOME 中预先安装并配置插件后,把提示词传给 codex exec:
codex exec 'Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Validate the issue, make the smallest safe change, add focused regression coverage, and verify that the issue no longer reproduces.'在 CI/CD 中扫描并修复发现
在调用这些技能前,请先在 runner 的 CODEX_HOME 中预先安装并配置 Codex Security。下面的命令会使用已安装的插件;它本身不会安装插件。
在 CI/CD 中,可以用一次 Codex 运行扫描 diff,并为扫描发现的每个发现生成修复。这个 job 不需要发现 ID 或报告路径作为输入。Codex 会把扫描得到的发现带入同一次运行的修复流程。
这个 all-in-one 运行应当:
- 解析该变更的 base 和 head revisions。
- 对该 diff 运行
$codex-security:security-diff-scan。 - 对扫描返回的每个发现调用
$codex-security:fix-finding。 - 生成聚焦 patch 和回归覆盖,然后验证每个修复。
- 返回扫描结果、patch、测试、验证命令,以及任何无法修复的发现。
例如:
codex exec 'Use $codex-security:security-diff-scan to review changes from <base-revision> to HEAD. For every finding returned by the scan, use $codex-security:fix-finding to generate and verify a minimal fix. Continue until every finding has either a verified fix or an explicit explanation of why it could not be fixed. Return the scan results, patches, tests, verification commands, and remaining failures.'验证后,通过你常规的代码评审和发布流程合并 patch。如果要在修复前把发现交给另一个团队,请参见导出或跟踪发现。