Skip to content

chore: harden CI/CD against supply-chain attacks#164

Merged
sasagar merged 2 commits into
devfrom
chore/issue-162-supply-chain-hardening
May 13, 2026
Merged

chore: harden CI/CD against supply-chain attacks#164
sasagar merged 2 commits into
devfrom
chore/issue-162-supply-chain-hardening

Conversation

@sasagar
Copy link
Copy Markdown
Collaborator

@sasagar sasagar commented May 13, 2026

Closes #162

Summary

直近で連続している supply-chain 攻撃(tj-actions/changed-files の compromise、shai-hulud npm worm、nx/chalk/debug の悪性版配布など)に対する CI/CD 側の防御を導入。

Changes

.github/workflows/*.yml

  • すべての Actions を commit SHA に固定(コメントで semver を併記)
    • oven-sh/setup-bun0c5077e5... (v2.2.0)
    • softprops/action-gh-release3bb12739... (v2.6.2)
    • actions/checkoutde0fac2e... (v6.0.0)
    • setup-node/github-script/configure-pages/upload-pages-artifact/deploy-pages も SHA 固定
  • Bun を 1.3.14 に固定latest 廃止)
  • Node を 24 (LTS) に bump(旧 20、2026-04 で EOL)
  • bun install --frozen-lockfile を CI の全 install step で強制
  • GITHUB_TOKEN 既定権限を contents: read に変更し、release/tag job のみ contents: write を opt-in
  • Dependency Review job を PR チェックに追加(fail-on-severity: high
  • CI を pull_request: [main, dev] 両方でトリガーするよう拡張

.github/dependabot.yml(新規)

  • github-actions ecosystem を週次更新(pinned SHA の追従用)
  • npm ecosystem を root / backend / frontend / shared の 4 ディレクトリで週次更新
  • minor/patch は単一 PR にグループ化、major は個別 PR

Out of scope (next phase)

  • Sigstore/cosign 署名と build provenance attestation
  • 本番ホストの egress allowlist

Test plan

  • CI が緑になる(自身がこの PR で更新したワークフロー自体で検証される)
  • Dependency Review job が PR で走る(この PR でも実行されることを確認)
  • frozen-lockfile が走り、想定外の lockfile 差分があれば fail することを確認

Risk

  • bun-version: latest から固定したので、Bun の新バージョンが出るたび手動 bump が必要(Dependabot は Bun runtime には対応していないため、BUN_VERSION 環境変数を手動更新で運用)
  • 全 Actions SHA 固定後、v6/v2 などの tag rewrite による「便利な自動更新」は無くなる代わりに Dependabot PR ベース運用になる

Summary by CodeRabbit

リリースノート

  • Chores
    • GitHub Actions ワークフローとアクション依存関係をセキュリティと安定性向上のため更新しました。
    • Dependabot 自動更新機能を設定し、定期的な依存関係チェックを有効化しました。

Review Change Stack

- Pin all GitHub Actions to commit SHAs (third-party + official)
- Pin Bun to 1.3.14 and Node to 24 (was: latest/20)
- Add bun install --frozen-lockfile to all install steps
- Default workflow GITHUB_TOKEN to contents: read; opt-in to write per job
- Add Dependency Review action to PR checks (fails on high severity)
- Add Dependabot config for github-actions and npm (root + 3 packages)

Mitigates: tj-actions/changed-files style tag-rewrite attacks,
shai-hulud-style malicious dep injection via lockfile drift,
over-privileged tokens leaking via compromised actions.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@sasagar has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 6 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e52d694d-6bab-40ec-a676-6c946f3ca695

📥 Commits

Reviewing files that changed from the base of the PR and between 25563dd and 3350ad1.

📒 Files selected for processing (1)
  • .github/workflows/docs.yml
📝 Walkthrough

Walkthrough

GitHub リポジトリの CI/CD パイプラインをサプライチェーン攻撃に対して強化。Dependabot で GitHub Actions と npm 依存の自動週次更新を設定し、6 個のワークフロー全体で Actions を commit SHA に固定、デフォルト権限を読み取り専用化、Bun 依存の frozen-lockfile 強制実行、Node.js バージョンを 24 に昇格。

Changes

CI/CD サプライチェーン攻撃対策

Layer / File(s) Summary
Dependabot Weekly Update Configuration
.github/dependabot.yml
新規 Dependabot v2 設定ファイルが GitHub Actions と npm 依存(root、backend、frontend、shared)の週次更新スケジュール、PR 数上限、commit メッセージフォーマット、グループ化ルール、ラベル付与を定義。
Workflow Permissions and GitHub Actions SHA Pinning
.github/workflows/auto-tag.yml, .github/workflows/close-issues.yml, .github/workflows/docs.yml, .github/workflows/release.yml, .github/workflows/sync-dev.yml
全ワークフローがデフォルト権限を contents: read に統一、必要なジョブにのみ contents: write を割り当て。actions/checkoutsoftprops/action-gh-releaseactions/github-scriptactions/deploy-pages 等をフローティング tag から commit SHA に固定。
Bun Lockfile and Build Environment Hardening
.github/workflows/ci.yml
CI ワークフローが全ジョブで bun install --frozen-lockfile を強制実行し lockfile 整合性を保証。BUN_VERSION を pinned 環境変数として複数ジョブで参照。SQLite テスト用 Node.js を v24 に昇格、dependency-review・lint・unit-tests・sqlite-tests・build ジョブで setup-bun を SHA 固定。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Rabbit は SHA に action を固定して、
Tag の改ざんを防ぎ、
Bun の frozen-lockfile で依存を守り、
Dependabot の週次更新で常に警戒。
サプライチェーン堅牢化、完成! 🔐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: harden CI/CD against supply-chain attacks' accurately and concisely summarizes the main change: implementing CI/CD hardening measures through GitHub Actions SHA pinning, dependency management improvements, and security configurations.
Linked Issues check ✅ Passed The PR implements all major coding requirements from issue #162: GitHub Actions SHA pinning across all workflows, bun install --frozen-lockfile enforcement, GITHUB_TOKEN permissions minimization, and dependabot.yml configuration with github-actions and npm ecosystems.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #162 scope: workflow hardening, Bun version pinning to 1.3.14, Node.js v24 upgrade for compatibility, and Dependabot configuration. No out-of-scope modifications detected.
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
  • Commit unit tests in branch chore/issue-162-supply-chain-hardening

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
.github/workflows/docs.yml (1)

50-50: ⚡ Quick win

Bun バージョンを環境変数として定義することを検討してください。

ci.yml では env.BUN_VERSION を使用していますが、このワークフローでは Bun バージョンがハードコードされています。一貫性を保ち、メンテナンス性を向上させるため、このワークフローにも BUN_VERSION 環境変数を追加し、bun-version: ${{ env.BUN_VERSION }} を使用することを推奨します。

♻️ 提案される修正

ファイル上部の on: セクションの後に env セクションを追加:

 on:
   push:
     branches: [main]
   ...
   workflow_dispatch:
 
+env:
+  BUN_VERSION: "1.3.14"
+
 # Sets permissions of the GITHUB_TOKEN...

そして、setup-bun ステップを更新:

       - name: Setup Bun
         uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
         with:
-          bun-version: "1.3.14"
+          bun-version: ${{ env.BUN_VERSION }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs.yml at line 50, The workflow hardcodes bun-version:
"1.3.14"; add an env variable BUN_VERSION at the top-level workflow env (set to
the same version or use existing env.BUN_VERSION) and update the setup-bun step
to use bun-version: ${{ env.BUN_VERSION }}; ensure references to env.BUN_VERSION
(and the setup-bun step name) are consistent so the workflow uses the
environment variable instead of the literal string.
.github/dependabot.yml (1)

94-94: 💤 Low value

ファイル末尾に改行を追加することを検討してください。

POSIX テキストファイルの慣例に従い、ファイル末尾には改行を含めることが推奨されます。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/dependabot.yml at line 94, dependabot 設定ファイルの末尾に改行がないため POSIX
準拠にする必要があります; 対象ファイル(dependabot
設定ファイル)の終端に改行文字を1つ追加してファイルを保存し、必ずテキストエディタやコミット時に改行が維持されることを確認してください。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/dependabot.yml:
- Line 94: dependabot 設定ファイルの末尾に改行がないため POSIX 準拠にする必要があります; 対象ファイル(dependabot
設定ファイル)の終端に改行文字を1つ追加してファイルを保存し、必ずテキストエディタやコミット時に改行が維持されることを確認してください。

In @.github/workflows/docs.yml:
- Line 50: The workflow hardcodes bun-version: "1.3.14"; add an env variable
BUN_VERSION at the top-level workflow env (set to the same version or use
existing env.BUN_VERSION) and update the setup-bun step to use bun-version: ${{
env.BUN_VERSION }}; ensure references to env.BUN_VERSION (and the setup-bun step
name) are consistent so the workflow uses the environment variable instead of
the literal string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9697f4c4-2dd8-4d33-880d-265a41549037

📥 Commits

Reviewing files that changed from the base of the PR and between cab99a4 and 25563dd.

📒 Files selected for processing (7)
  • .github/dependabot.yml
  • .github/workflows/auto-tag.yml
  • .github/workflows/ci.yml
  • .github/workflows/close-issues.yml
  • .github/workflows/docs.yml
  • .github/workflows/release.yml
  • .github/workflows/sync-dev.yml

Address CodeRabbit nitpick: hoist Bun version to env.BUN_VERSION
in docs.yml for consistency with ci.yml.

Skipped: trailing-newline nitpick on dependabot.yml — file
already ends with LF (verified via wc -l / tail -c).
@sasagar
Copy link
Copy Markdown
Collaborator Author

sasagar commented May 13, 2026

@coderabbitai レビューありがとうございます。Nitpick 2 件のうち 1 件を対応しました。

✅ Fixed

  • .github/workflows/docs.yml: bun-versionenv.BUN_VERSION 経由に変更し ci.yml と統一しました(commit 3350ad1

⏭️ Skipped (false positive)

  • .github/dependabot.yml の trailing newline: ファイルは既に LF で終端しています。
    • wc -l → 93 lines(=コンテンツ末尾の LF をカウント済み)
    • tail -c 3 | xxd6368 0a("ch\n")で末尾改行を確認

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Tip

For best results, initiate chat on the files or code changes.

@sasagar ご確認とご対応ありがとうございます!

  • .github/workflows/docs.ymlbun-versionenv.BUN_VERSION):修正を確認しました。ci.yml との統一が図られ、将来の Bun バージョン変更も一箇所で管理できるようになりましたね 👍
  • .github/dependabot.yml の trailing newlinetail -c 3 | xxd で末尾 0a(LF)が確認できているとのこと、こちらの指摘は誤検知でした。申し訳ありません。スキップいただいて正解です。

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@sasagar sasagar merged commit d6acd1a into dev May 13, 2026
11 checks passed
@sasagar sasagar deleted the chore/issue-162-supply-chain-hardening branch May 13, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant