Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/book-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
node scripts/check-chapter08-dependency-review-contract.js
node scripts/check-chapter08-dependency-review-contract.js --self-test

- name: Check Chapter 13 Codex Action supply-chain contract
run: |
node scripts/check-chapter13-codex-action-contract.js
node scripts/check-chapter13-codex-action-contract.js --self-test

- name: Install dependencies (book-formatter)
working-directory: book-formatter
run: npm ci
Expand Down
36 changes: 26 additions & 10 deletions docs/chapters/chapter13/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ jobs:
- **権限を最小化**: 差分レビュー用途なら `contents: read` と、コメント投稿用の `pull-requests: write` 程度に絞る
- **Secrets境界を明記**: `secrets.OPENAI_API_KEY` を `with.openai-api-key` に渡し、ログ/PR本文へ出さない
- **実行範囲を制御**: ラベル付与などで実行を明示し、意図しないタイミングでの課金・外部送信を避ける
- **安全策を明示**: `sandbox`(FS/network)と `safety-strategy`(OS権限)を明示し、権限境界を固定する
- **安全策を明示**: `permission-profile: ":read-only"`(FS/network)と `safety-strategy: drop-sudo`(OS権限)を明示し、権限境界を固定する
- **供給網を固定**: actionを監査済みfull-length commit SHAへpinし、human-readable tagとCodex CLIのexact versionを併記する

以下はサンプルです(導入時は、モデル/課金/ポリシー・データ送信範囲を組織の基準に合わせて設計してください)。

Expand All @@ -794,19 +795,17 @@ jobs:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge

- name: Pre-fetch base and head refs
run: |
git fetch --no-tags origin \
${{ github.event.pull_request.base.ref }} \
+refs/pull/${{ github.event.pull_request.number }}/head
# checkoutの認証中に履歴を取得し、その後credentialを除去する
fetch-depth: 0
persist-credentials: false

Comment thread
ootakazuhiko marked this conversation as resolved.
- name: Run Codex (read-only)
id: run_codex
uses: openai/codex-action@v1
uses: openai/codex-action@52fe01ec70a42f454c9d2ebd47598f9fd6893d56 # v1.11
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
sandbox: read-only
codex-version: 0.144.6
permission-profile: ":read-only"
safety-strategy: drop-sudo
prompt: |
Review ONLY the changes introduced by the PR.
Expand Down Expand Up @@ -841,14 +840,31 @@ jobs:
```
{% endraw %}

#### pin更新手順

1. upstreamのversion tagをAPIで取得し、annotated tagならtarget commitまでdereferenceする。tag名だけでなくfull SHAを記録する。
2. 旧SHAと候補SHAの`action.yml`、`dist/`、依存lockfile、CHANGELOG、open security issueを比較し、upstream CIと依存auditを確認する。
3. actionのfull SHA、`# v1.11`のようなversion comment、`codex-version`のexact versionを同じPRで更新する。
4. label gate、`contents: read`、`persist-credentials: false`、`:read-only` permission profile、`drop-sudo`が維持されることをreview/CIで確認する。
5. test PRでラベル未付与時の非実行と、ラベル付与時のread-only reviewを確認してからmergeする。

この例のaction commitは`v1.11`が指す`52fe01ec70a42f454c9d2ebd47598f9fd6893d56`、Codex CLIは`0.144.6`を2026-07-19に監査したものです。同日時点のupstream source checkoutでは`pnpm audit`が10件(high 3 / moderate 5 / low 2)を指摘しましたが、`openai/codex-action`の公開Security Advisoryは確認できず、通常実行経路での到達可能性は未評価です。依存関係と新releaseを定期的に再監査してください。self-hosted/ARC、`unprivileged-user`、同一jobでの複数回実行はupstream既知issueを再確認するまで本例の対象外です。

監査時に参照する一次情報:

- [GitHub Actionsのsecure use](https://docs.github.com/en/actions/reference/security/secure-use)
- [監査済みCodex Action commit](https://github.com/openai/codex-action/commit/52fe01ec70a42f454c9d2ebd47598f9fd6893d56)
- [Codex Actionのsecurity guidance](https://github.com/openai/codex-action/blob/52fe01ec70a42f454c9d2ebd47598f9fd6893d56/docs/security.md)
- [Codex Actionの公開Security Advisory](https://github.com/openai/codex-action/security/advisories)

### 13.4.2 注意:Secrets/権限/外部送信の線引き
CodexのようなエージェントをCIに組み込む場合、失敗の大半は「実装」ではなく「権限境界/Secrets運用」で発生します。

- **Actions権限**: `permissions:` を明示し、用途ごとにワークフローを分ける
- **Secrets**: ログ/Artifacts/コメントへの混入を前提にレビュー観点へ入れる
- **外部送信**: どの情報が外部へ送られるか(プロンプト、差分、ログ)を定義し、許容範囲を決める

注: `sandbox` / `safety-strategy` は補助策であり、Secretsの露出(ログ/コメント)を自動でゼロにするものではありません。Secrets運用(出さない/残さない)と監査設計(根拠の記録)を組み合わせて境界を設計してください。
注: `permission-profile` / `safety-strategy` は補助策であり、Secretsの露出(ログ/コメント)を自動でゼロにするものではありません。Secrets運用(出さない/残さない)と監査設計(根拠の記録)を組み合わせて境界を設計してください。

詳細は第11章(Secrets/権限境界/監査)を参照してください。

Expand Down
19 changes: 11 additions & 8 deletions examples/workflows/codex-pr-review-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# - このworkflowは `openai/codex-action` を利用する third-party の例です(GitHub Copilotのネイティブ機能ではありません)。
# - `OPENAI_API_KEY`(または同等のAPIキー)をSecretsに格納し、外部送信範囲と課金を前提に導入可否を判断してください。
# - 意図しない実行を避けるため、ラベル(例: `codex-review`)で実行をゲートしています。
# - action codeは監査済みv1.11 commit、実行時のCodex CLIもexact versionへ固定しています。
# - pin更新時はupstream tagをcommitまでdereferenceし、action.yml/dist/lockfile/CI/auditの差分を
# レビューしてから、full SHA・version comment・codex-versionを同じPRで更新します。
# - GitHub-hosted runnerの単発実行を前提とし、self-hosted/ARCや同一jobでの複数回実行は
# upstream既知issueを再監査するまで対象外です。

name: Codex PR Review Comment (on label)

Expand All @@ -22,23 +27,21 @@ jobs:
with:
# Explicitly check out the PR's merge commit.
ref: refs/pull/${{ github.event.pull_request.number }}/merge

- name: Pre-fetch base and head refs
run: |
git fetch --no-tags origin \
${{ github.event.pull_request.base.ref }} \
+refs/pull/${{ github.event.pull_request.number }}/head
# Fetch history while checkout can authenticate, then remove the credential.
fetch-depth: 0
persist-credentials: false

# If you want Codex to build and run code, install any dependencies that
# need to be downloaded before the "Run Codex" step because Codex's
# default sandbox disables network access.

- name: Run Codex (read-only)
id: run_codex
uses: openai/codex-action@v1
uses: openai/codex-action@52fe01ec70a42f454c9d2ebd47598f9fd6893d56 # v1.11
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
sandbox: read-only
codex-version: 0.144.6
permission-profile: ":read-only"
safety-strategy: drop-sudo
prompt: |
This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}.
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"deploy": "bash scripts/deploy.sh",
"clean": "rm -rf _site public output temp",
"lint:light": "markdownlint --config .markdownlint-src.json 'src/**/*.md' --ignore node_modules",
"test:light": "npm run check:security && npm run check:metadata && npm run check:chapter08-codeql && npm run check:chapter08-codeql:self-test && npm run check:chapter08-dependency-review && npm run check:chapter08-dependency-review:self-test && npm run check:issue-240-ux && npm run lint:light && npm run build",
"test:light": "npm run check:security && npm run check:metadata && npm run check:chapter08-codeql && npm run check:chapter08-codeql:self-test && npm run check:chapter08-dependency-review && npm run check:chapter08-dependency-review:self-test && npm run check:chapter13-codex-action && npm run check:chapter13-codex-action:self-test && npm run check:issue-240-ux && npm run lint:light && npm run build",
"help": "echo 'Available commands:\n npm run setup - Interactive setup\n npm run build - Build the book\n npm run preview - Local preview\n npm run deploy - Deploy to GitHub Pages'",
"build:generate": "node scripts/build-simple.js",
"check:metadata": "node scripts/check-metadata-consistency.js",
Expand All @@ -28,7 +28,9 @@
"check:chapter08-codeql:self-test": "node scripts/check-chapter08-codeql-contract.js --self-test",
"check:chapter08-dependency-review": "node scripts/check-chapter08-dependency-review-contract.js",
"check:chapter08-dependency-review:self-test": "node scripts/check-chapter08-dependency-review-contract.js --self-test",
"check:issue-240-ux": "node scripts/check-issue-240-ux.js"
"check:issue-240-ux": "node scripts/check-issue-240-ux.js",
"check:chapter13-codex-action": "node scripts/check-chapter13-codex-action-contract.js",
"check:chapter13-codex-action:self-test": "node scripts/check-chapter13-codex-action-contract.js --self-test"
},
"dependencies": {
"fs-extra": "^11.3.5",
Expand Down
Loading