Skip to content

feat: repo-maintenance にサプライチェーン保護・本番リリース統制チェックを追加 - #580

Merged
keito4 merged 1 commit into
mainfrom
feat/repo-maintenance-security-hardening
Mar 15, 2026
Merged

feat: repo-maintenance にサプライチェーン保護・本番リリース統制チェックを追加#580
keito4 merged 1 commit into
mainfrom
feat/repo-maintenance-security-hardening

Conversation

@keito4

@keito4 keito4 commented Mar 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • repo-maintenance コマンドにセキュリティ強化チェック5項目を追加
  • 既存の「更新の自動化」に加え「サプライチェーン保護」と「本番リリース統制」を厚くする方針

追加チェック項目

Environment カテゴリ

  • 2.9 GitHub Actions Security Hardening Check — 3rd-party actions のフル SHA 固定、GITHUB_TOKENpermissions 明示、許可 actions 制限、pull_request_target の安全性チェック

Setup カテゴリ

  • 3.19 Push Protection Check — Secret scanning の push protection 有効化確認・自動有効化
  • 3.20 Dependency Review Checkactions/dependency-review-action の CI 組み込み確認・テンプレート生成
  • 3.21 Deployment Environment Protection Check — GitHub Environments の required reviewers / branch policy 確認

Discovery カテゴリ

  • 5.3 Provenance / SBOM Audit — Artifact Attestations、SBOM 生成、npm Trusted Publishing(OIDC)の確認(公開リポジトリのみ)

Test plan

  • /repo-maintenance --mode check-only で新チェック項目が正常に表示される
  • /repo-maintenance --mode full で各チェックが正常に実行・修正提案される
  • サマリーレポートに新項目が含まれる
  • Related Commands テーブルに新項目が含まれる

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added five new security and supply-chain checks: Actions hardening, push protection, dependency review, deployment environment protection, and provenance/SBOM audit.
    • Expanded maintenance summary to display status of all new checks.
  • Documentation

    • Enhanced guidance for configuring and validating security and deployment controls.

Actions SHA固定・権限制限、Push Protection、Dependency Review、
Deployment Environment Protection、Provenance/SBOM Audit の5項目を追加。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the feature 新機能 label Mar 15, 2026
@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request adds comprehensive security and compliance checks to the repo-maintenance command documentation, including GitHub Actions security hardening, push protection verification, dependency review validation, deployment environment protection checks, and provenance/SBOM audit capabilities with remediation guidance.

Changes

Cohort / File(s) Summary
Repo Maintenance Documentation
.claude/commands/repo-maintenance.md
Added GitHub Actions security hardening section (2.9) with SHA pinning and GITHUB_TOKEN guidance; new checks for Push Protection (3.19), Dependency Review (3.20), and Deployment Environment Protection (3.21); introduced Provenance/SBOM Audit (5.3) in Discovery section to assess build provenance, SBOM generation, and npm Trusted Publishing. Expanded summary outputs to reflect all new checks with validation logic and full-mode remediation templates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Checks now guard the Actions flow,
SBOM and provenance aglow,
Push protection, environments too,
Security hardened through and through!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title in Japanese accurately describes the main changes: adding supply chain protection and production release control checks to repo-maintenance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/repo-maintenance-security-hardening
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4

keito4 commented Mar 15, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項(重大度順)

  1. デフォルト権限の説明が誤り
    permissions 未設定時のデフォルトを「write-all」と断定していますが、実際はリポジトリ設定の「Default workflow permissions」に依存し、近年の既定値は read であるケースが一般的です。誤った前提に基づく警告文になっています。
    影響: 誤検知・誤案内(DX低下、不要な修正誘導)
    対象: .claude/commands/repo-maintenance.md:309-312

  2. deployment_branch_policy の取得ロジックが常に null になる
    gh api ... --jq '.environments[] | {name, protection_rules}'deployment_branch_policy を切り落としているため、直後の jq '.deployment_branch_policy' は常に null になります。結果として本番環境の branch policy が設定済みでも未設定扱いになります。
    影響: 誤検知・誤案内(DX低下、不要な設定誘導)
    対象: .claude/commands/repo-maintenance.md:1680-1691

総評
patch is incorrect
理由: 誤った前提(デフォルト権限の断定)とロジック上の欠陥(deployment_branch_policy の常時 null)により、誤検知・誤案内を導入しています。
信頼度: 0.62


⚠️ 修正が必要です

上記のレビューで問題が指摘されています。修正してからマージしてください。


🤖 Generated by post_pr_ai_review.py hook

@keito4

keito4 commented Mar 15, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項(重大度順)

  1. deployment_branch_policy の判定が常に null になり、誤検知します。gh api ... --jq '.environments[] | {name, protection_rules}'deployment_branch_policy を取得していないのに jq '.deployment_branch_policy' を読んでいるため、production でも常に「未設定」扱いになります。結果として誤った警告・案内を出します。.claude/commands/repo-maintenance.md:1680
  2. GITHUB_TOKEN 権限制限のチェックが top-level の permissions: しか見ておらず、job-level に正しく設定しているワークフローを誤検知します。本文では「workflow/job レベルで permissions を明示」と書いているため、ロジックと説明が不一致です。.claude/commands/repo-maintenance.md:309
  3. GITHUB_TOKEN のデフォルト権限を「write-all」と断定していますが、実際はリポジトリ/Org 設定で read がデフォルトになり得ます。誤った前提で不要な警告を出し、運用判断を誤らせます。.claude/commands/repo-maintenance.md:311
  4. Provenance/SBOM 監査のセクションで REPO が未定義のまま gh api "repos/$REPO/..." を呼んでいます。これだと API 呼び出しが失敗し、公開判定や推奨事項が正しく出ません。.claude/commands/repo-maintenance.md:1931

判定: patch is incorrect
理由: 新規追加ロジックに誤検知・未定義変数による失敗が含まれており、手順/結果の正確性を損なうため。
信頼度: 0.36


⚠️ 修正が必要です

上記のレビューで問題が指摘されています。修正してからマージしてください。


🤖 Generated by post_pr_ai_review.py hook

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c81adc806d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

echo "⏭️ GitHub Environments 未使用"
else
# 各環境の保護ルールを確認
gh api "repos/$REPO/environments" --jq '.environments[] | {name, protection_rules}' 2>/dev/null | while read -r env; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Collect environment issues without a pipeline subshell

Because the environment loop is fed by a pipe, Bash executes the while body in a subshell, so ISSUES+=(...) updates are discarded when the loop exits. In repositories where production environments are misconfigured, this check will still finish with an empty ISSUES array and report no problems, so the new protection audit silently fails.

Useful? React with 👍 / 👎.

echo "⏭️ GitHub Environments 未使用"
else
# 各環境の保護ルールを確認
gh api "repos/$REPO/environments" --jq '.environments[] | {name, protection_rules}' 2>/dev/null | while read -r env; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep branch policy field in environment inspection output

The --jq filter narrows each environment object to {name, protection_rules}, but later logic reads .deployment_branch_policy; since that field was dropped, it is always null and every production/prod environment is flagged as missing branch policy even when configured correctly. This creates systematic false positives in the new deployment-protection check.

Useful? React with 👍 / 👎.

@keito4
keito4 merged commit bc67fbd into main Mar 15, 2026
7 of 8 checks passed
@claude

claude Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

PR レビュー: repo-maintenance にサプライチェーン保護・本番リリース統制チェックを追加

サプライチェーン保護の観点で価値の高い追加です。全体的な方向性は良いですが、いくつかバグと不整合が見つかりました。

バグ

3.21: サブシェル問題で ISSUES 配列への追加が反映されない

パイプの右辺はサブシェルになるため、ループ内の ISSUES+= が外部スコープに伝播しません。

修正案: パイプをプロセス置換に変更する

5.3: RELEASES が空の場合の算術比較エラー

API 失敗時に RELEASES が空文字となり算術比較エラーになります。修正案: RELEASESが未設定の場合に0をデフォルト値とする

不整合

3.20 の YAML テンプレートがタグ参照(SHA 未固定)

2.9 で SHA ピン留めを推奨しているのに、提示するテンプレート自体がタグ参照になっています。テンプレートを SHA 固定にするか、npx pin-github-action での後処理を明記すべきです。

改善提案

2.9: pull_request_target の誤検知リスク

「ワークフローファイル内に pull_request_target: と secrets. が両方存在すれば警告」という粒度です。同ファイルの無関係な job に secrets が使われていても警告が出ます。精度向上か誤検知前提の注記追加を検討してください。

2.9: github/ org の除外根拠を補足

github/codeql-action は GitHub 管理ですが github/ org にはサードパーティも存在します。現在の除外パターンの根拠をコメントで補足すると保守しやすくなります。

3.21: multiline JSON のパース

--jq は複数オブジェクトをストリーム出力するため、ネストした JSON が正しくパースできません。jq -c で compact 出力を確保してください。

良い点

  • 各チェックに攻撃シナリオと推奨値の表が付いており、利用者が判断しやすい
  • 権限不足・未使用環境を「スキップ」として適切に区別している
  • Step 6 のサマリーレポートも整合して更新されている
  • check-only と full モードの設計が一貫している

3.21 のサブシェルバグ と 5.3 の空文字チェック漏れ は実行時に期待通り動作しない問題です。3.20 のテンプレートが自己矛盾(SHA 未固定)になっている点も次の機会に修正することを推奨します。

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.97.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 新機能 released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant