场景 112 · Codex Use Case

用 GitHub Actions 创建自定义安全审查流程

配置 GitHub Actions,在拟合入改动上运行 Codex Security 并保存结果,让团队可重复地检查发现、证据和覆盖报告。

SecurityEngineering
Create custom review workflows with GitHub ActionsSecurityEngineering

原文核对:2026-11-10 · 中文正文 · 英文提示词与演示

场景定位

配置 GitHub Actions,在拟合入改动上运行 Codex Security 并保存结果,让团队可重复地检查发现、证据和覆盖报告。

难度
中级
时间跨度
长时间运行

适合用于

  • 将安全检查接入 GitHub Actions 的平台和应用安全团队。
  • 配置自定义审查触发条件和扫描范围的仓库维护者。
  • 需要可重复审查并保留发现、证据及覆盖报告的团队。

除了通过 Codex 执行安全审查,还可以创建运行 Codex Security CLI 的自定义工作流。官方已将该流程打包为便于使用的 GitHub Action。

官方代码示例
name: Codex Security review
on:
  workflow_dispatch:
  schedule:
    - cron: '23 7 * * 1' # Mondays at 07:23 UTC

permissions:
  contents: read

jobs:
  security:
    runs-on: ubuntu-24.04
    steps:
      - name: Set up the Ubuntu sandbox
        run: |
          sudo apt-get update
          sudo apt-get install --yes bubblewrap apparmor-profiles
          sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict

      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: openai/codex-security@3f61e5150981a5087c32e4395bbaa8ce5ce0c3e3 # action-v0.3.0
        with:
          model: gpt-5.6-sol
          effort: high
        env:
          OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}

这些流程也可应用于 GitLab、BitBucket、Jenkins 等其他代码管理或自动化工具。更多说明见“在 CI 中运行 Codex Security”。

展开英文原文对照

Make security reviews a repeatable part of your development process. Configure a GitHub Actions workflow that runs Codex Security on proposed changes and saves the results for your team to inspect.

Instead of enforcing security reviews through Codex, it is also possible to create custom workflows that run the Codex Security CLI. We’ve packaged this workflow to easily be used as a GitHub Action.

官方代码示例
name: Codex Security review
on:
  workflow_dispatch:
  schedule:
    - cron: '23 7 * * 1' # Mondays at 07:23 UTC

permissions:
  contents: read

jobs:
  security:
    runs-on: ubuntu-24.04
    steps:
      - name: Set up the Ubuntu sandbox
        run: |
          sudo apt-get update
          sudo apt-get install --yes bubblewrap apparmor-profiles
          sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict

      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: openai/codex-security@3f61e5150981a5087c32e4395bbaa8ce5ce0c3e3 # action-v0.3.0
        with:
          model: gpt-5.6-sol
          effort: high
        env:
          OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}

These workflows can also be applied to other source code management tools like GitLab, BitBucket, or Jenkins. Take a look at our documentation page to learn more: Run Codex Security in CI.