From ae17f197f912af6a065ed03234bc471ef82ec0a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 11:14:33 +0000 Subject: [PATCH 1/2] ci: replace pinact with the GitHub Actions workflow lockfile Workflows go back to exact release tags; the commit each tag resolves to is meant to be recorded in .github/workflows/actions.lock, generated by `gh actions-lock`, and a new CI job runs `gh actions-lock --verify`. pinact is removed everywhere: the CI check, the mise tool and its lock entry, and the global pre-commit helper that SHA-pinned staged workflows in every repository. A re-install deletes that helper from machines that have it, but only when its marker shows setup put it there. Renovate regenerates actions.lock itself, so the pinDigest rule is gone. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UPEgcrCmartGXXU6TnZrvg --- .dotfiles/git-hooks/dispatch | 8 --- .dotfiles/git-hooks/install.sh | 21 +++--- .dotfiles/git-hooks/pinact-staged | 60 ---------------- .dotfiles/setup/git-hooks.sh | 2 +- .github/workflows/bump-tools.yml | 8 +-- .github/workflows/quality.yml | 37 +++++++--- .mise.toml | 5 +- README.ja.md | 4 +- README.md | 4 +- docs/supply-chain.ja.md | 29 ++++---- docs/supply-chain.md | 29 ++++---- mise.lock | 46 ------------- renovate.json | 9 +-- tests/git-hooks-test.sh | 111 +++++------------------------- tests/mise-pins-test.sh | 1 - 15 files changed, 96 insertions(+), 278 deletions(-) delete mode 100755 .dotfiles/git-hooks/pinact-staged diff --git a/.dotfiles/git-hooks/dispatch b/.dotfiles/git-hooks/dispatch index 827f6db..e399969 100755 --- a/.dotfiles/git-hooks/dispatch +++ b/.dotfiles/git-hooks/dispatch @@ -46,14 +46,6 @@ if [ "$hook" = post-checkout ] && [ "${1:-}" = "$null_head" ] && fi fi -# Pin the exact workflow snapshot about to be committed. The helper updates the -# index without staging unrelated working-tree edits, then mirrors its small -# fix back to the working tree when that can be done without a conflict. -dispatch_dir="$(cd "$(dirname "$0")" && pwd)" -if [ "$hook" = pre-commit ] && [ -x "$dispatch_dir/pinact-staged" ]; then - "$dispatch_dir/pinact-staged" || exit $? -fi - # Forward to the repository's own hook. Resolve it through git-common-dir # rather than `git rev-parse --git-path`, which honours core.hooksPath and # would point straight back at this script. diff --git a/.dotfiles/git-hooks/install.sh b/.dotfiles/git-hooks/install.sh index 67ff1e4..28aab60 100755 --- a/.dotfiles/git-hooks/install.sh +++ b/.dotfiles/git-hooks/install.sh @@ -13,10 +13,14 @@ HOOKS_DIR="${GIT_HOOKS_DIR:-$HOME/.config/git/hooks}" # the base URL it exported rather than resolving main a second time. RAW_BASE="${DOTFILES_RAW_BASE:-https://raw.githubusercontent.com/bmthd/dotfiles/${DOTFILES_REF:-main}}" DISPATCH_URL="$RAW_BASE/.dotfiles/git-hooks/dispatch" -PINACT_STAGED_URL="$RAW_BASE/.dotfiles/git-hooks/pinact-staged" # Identifies a dispatch this script wrote, so a re-run refreshes its own files # and only its own. MARKER="bmthd/dotfiles global git hook dispatcher" +# The helper that used to SHA-pin staged workflows with pinact. Workflow pinning +# is now the job of each repository's own .github/workflows/actions.lock, which +# a machine-wide hook cannot write for a repository that never opted in, so the +# helper is gone — and removed from machines it was installed on, but only when +# the marker proves this script put it there. PINACT_MARKER="bmthd/dotfiles staged pinact helper" # githooks(5), including the server-side and p4 hooks. core.hooksPath replaces @@ -42,11 +46,6 @@ if [ -e "$HOOKS_DIR/dispatch" ] && ! grep -q "$MARKER" "$HOOKS_DIR/dispatch" 2> echo "⚠ $HOOKS_DIR/dispatch exists and was not written by this script; aborting" exit 1 fi -if [ -e "$HOOKS_DIR/pinact-staged" ] && - ! grep -q "$PINACT_MARKER" "$HOOKS_DIR/pinact-staged" 2> /dev/null; then - echo "⚠ $HOOKS_DIR/pinact-staged exists and was not written by this script; aborting" - exit 1 -fi local_dispatch="$(cd "$(dirname "$0")" && pwd)/dispatch" if [ -f "$local_dispatch" ]; then @@ -57,14 +56,10 @@ elif ! curl -fsSL "$DISPATCH_URL" -o "$HOOKS_DIR/dispatch"; then fi chmod +x "$HOOKS_DIR/dispatch" -local_pinact_staged="$(cd "$(dirname "$0")" && pwd)/pinact-staged" -if [ -f "$local_pinact_staged" ]; then - cp "$local_pinact_staged" "$HOOKS_DIR/pinact-staged" -elif ! curl -fsSL "$PINACT_STAGED_URL" -o "$HOOKS_DIR/pinact-staged"; then - echo "⚠ Failed to download the staged pinact helper" - exit 1 +if [ -f "$HOOKS_DIR/pinact-staged" ] && + grep -q "$PINACT_MARKER" "$HOOKS_DIR/pinact-staged" 2> /dev/null; then + rm -f "$HOOKS_DIR/pinact-staged" fi -chmod +x "$HOOKS_DIR/pinact-staged" skipped=() for hook in "${HOOK_NAMES[@]}"; do diff --git a/.dotfiles/git-hooks/pinact-staged b/.dotfiles/git-hooks/pinact-staged deleted file mode 100755 index 3076adb..0000000 --- a/.dotfiles/git-hooks/pinact-staged +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -# bmthd/dotfiles staged pinact helper. Pins staged GitHub Actions references -# without adding unstaged content. -set -euo pipefail - -repo="$(git rev-parse --show-toplevel)" -files=() -while IFS= read -r -d '' file; do - files+=("$file") -done < <(git diff --cached --name-only --diff-filter=ACMR -z -- \ - ':(glob).github/workflows/*.yml' ':(glob).github/workflows/*.yaml') - -if [[ ${#files[@]} -eq 0 ]]; then - exit 0 -fi - -if ! command -v pinact > /dev/null 2>&1; then - echo "✗ pinact is required to commit GitHub Actions workflows (run: mise install pinact)" >&2 - exit 1 -fi - -staged="$(mktemp -d)" -trap 'rm -rf "$staged"' EXIT -pin_files=() -for file in "${files[@]}"; do - mkdir -p "$staged/original/$(dirname "$file")" "$staged/pinned/$(dirname "$file")" - git show ":$file" > "$staged/original/$file" - cp "$staged/original/$file" "$staged/pinned/$file" - pin_files+=("$staged/pinned/$file") -done - -pinact run --branch-to-tag '^main$' --branch-to-tag '^master$' "${pin_files[@]}" - -patch="$staged/worktree.patch" -: > "$patch" -for file in "${files[@]}"; do - diff -U0 --label "a/$file" --label "b/$file" \ - "$staged/original/$file" "$staged/pinned/$file" >> "$patch" || status=$? - if [[ ${status:-0} -gt 1 ]]; then - exit "$status" - fi - unset status -done - -if [[ ! -s "$patch" ]]; then - : -elif git -C "$repo" apply --unidiff-zero --check "$patch" 2> /dev/null; then - git -C "$repo" apply --unidiff-zero "$patch" -else - echo "⚠ pinact fixed the staged snapshot; conflicting unstaged workflow edits were left unchanged" >&2 -fi - -for file in "${files[@]}"; do - if ! cmp -s "$staged/original/$file" "$staged/pinned/$file"; then - printf 'pinact: pinned %s\n' "$file" - fi - mode="$(git ls-files -s -- "$file" | awk 'NR == 1 { print $1 }')" - blob="$(git hash-object -w "$staged/pinned/$file")" - git update-index --cacheinfo "$mode,$blob,$file" -done diff --git a/.dotfiles/setup/git-hooks.sh b/.dotfiles/setup/git-hooks.sh index ca2d439..fe2092c 100755 --- a/.dotfiles/setup/git-hooks.sh +++ b/.dotfiles/setup/git-hooks.sh @@ -4,7 +4,7 @@ # comment there. RAW_BASE="${DOTFILES_RAW_BASE:-https://raw.githubusercontent.com/bmthd/dotfiles/${DOTFILES_REF:-main}}" INSTALLER="$(mktemp)" -# The installer downloads dispatch and pinact-staged itself, so hand it the +# The installer downloads dispatch itself, so hand it the # same base rather than letting it fall back to main on its own. export DOTFILES_RAW_BASE="$RAW_BASE" if curl -fsSL "$RAW_BASE/.dotfiles/git-hooks/install.sh" -o "$INSTALLER"; then diff --git a/.github/workflows/bump-tools.yml b/.github/workflows/bump-tools.yml index 06b32b6..c6440a5 100644 --- a/.github/workflows/bump-tools.yml +++ b/.github/workflows/bump-tools.yml @@ -30,12 +30,12 @@ jobs: steps: - name: Mint a token for the bypass-listed App id: app-token - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + uses: actions/create-github-app-token@v3.3.0 with: client-id: ${{ secrets.BUMP_APP_CLIENT_ID }} private-key: ${{ secrets.BUMP_APP_PRIVATE_KEY }} - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: # Keep the App token as the push credential; the default GITHUB_TOKEN # would be rejected by the ruleset. @@ -44,8 +44,8 @@ jobs: # Resolving the `npm:` tools reaches the npm registry, so send that # traffic through the same malware-blocking proxy the installed machines # use. Anonymous mode needs no bot-id and no extra permissions. - - uses: flatt-security/setup-takumi-guard-npm@14f07d0cbc739b42a1b7c70a04c2b84cd1318ddd # v1.4.0 - - uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 + - uses: flatt-security/setup-takumi-guard-npm@v1.4.0 + - uses: jdx/mise-action@v4.3.0 with: install: false diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index a5aeb18..50e5c7f 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -15,12 +15,12 @@ jobs: name: Mise runs-on: ubuntu-latest steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 # Resolving the `npm:` tools below reaches the npm registry, so send that # traffic through the same malware-blocking proxy the installed machines # use. Anonymous mode needs no bot-id and no extra permissions. - - uses: flatt-security/setup-takumi-guard-npm@14f07d0cbc739b42a1b7c70a04c2b84cd1318ddd # v1.4.0 - - uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 + - uses: flatt-security/setup-takumi-guard-npm@v1.4.0 + - uses: jdx/mise-action@v4.3.0 with: install: false - name: Validate tool config parses @@ -42,23 +42,40 @@ jobs: # checks that a task and its script still agree. - name: Test the setup task facade run: bash tests/setup-facade-test.sh - - name: Verify immutable GitHub Actions references - run: mise x pinact -- pinact run --check --verify-comment - env: - GITHUB_TOKEN: ${{ github.token }} + + actions-lock: + # Actions refuses to run an onboarded workflow whose `uses:` has no entry in + # .github/workflows/actions.lock, but only once the job starts. --verify + # catches a missing entry, or a locked commit that no longer verifies + # upstream, on the PR that introduces it. Renovate regenerates the lockfile + # in its own PRs; a hand edit to a workflow needs `gh actions-lock` rerun. + name: Actions lockfile + runs-on: ubuntu-latest + permissions: + contents: read + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + # Pinned: the extension is what decides whether every other action here + # is trustworthy, so it is not one to take at whatever main is today. + - run: gh extension install github/gh-actions-lock --pin v0.4.1 + - run: gh actions-lock --verify shellcheck: name: ShellCheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0 + - uses: actions/checkout@v7.0.1 + - uses: ludeeus/action-shellcheck@2.0.0 syntax: name: Shell syntax runs-on: ubuntu-latest steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 - name: bash -n run: | bash -n install.sh diff --git a/.mise.toml b/.mise.toml index 33d6d9a..db7f66c 100644 --- a/.mise.toml +++ b/.mise.toml @@ -43,7 +43,6 @@ pnpm = { version = "latest" } bun = { version = "latest" } ghq = { version = "latest" } jq = { version = "latest" } -pinact = { version = "latest" } uv = { version = "latest" } "cargo:similarity-ts" = { version = "latest" } "npm:@antfu/ni" = { version = "latest" } @@ -54,7 +53,9 @@ oci = { version = "latest" } cloudflared = { version = "latest" } wrangler = { version = "latest" } hunk = { version = "latest" } -github-cli = { version = "latest", postinstall = "gh extension install github/gh-stack 2>/dev/null || gh extension upgrade stack 2>/dev/null || true" } +# gh-actions-lock regenerates .github/workflows/actions.lock after a hand edit +# to a workflow; CI only verifies it. +github-cli = { version = "latest", postinstall = "gh extension install github/gh-stack 2>/dev/null || gh extension upgrade stack 2>/dev/null || true; gh extension install github/gh-actions-lock 2>/dev/null || gh extension upgrade actions-lock 2>/dev/null || true" } # `depends = ["node"]` on the npm: tools below: their postinstall shells out to # `npx`, which only exists once node is installed. Without the explicit # dependency mise may run it while node is still being (re)installed — `mise diff --git a/README.ja.md b/README.ja.md index 80c6652..2800e54 100644 --- a/README.ja.md +++ b/README.ja.md @@ -40,7 +40,7 @@ curl -fsSL https://raw.githubusercontent.com/bmthd/dotfiles/main/install.sh | ba - **エージェントスキル** — Claude Code / OpenCode / Cursor / Codex / Gemini CLI の 5 つに同じものを導入 - **プラグイン** — Codex、pstack、および公式プラグイン (TypeScript LSP) - **npm レジストリ** — マルウェアを遮断する [Takumi Guard](https://npm.flatt.tech/) プロキシ経由に変更 -- **グローバル git フック** — 新しい worktree の mise config を trust し、repository hook と部分 stage を維持したまま、commit 前に staged GitHub Actions 参照を pin する ([`.dotfiles/git-hooks`](.dotfiles/git-hooks)) +- **グローバル git フック** — repository hook を維持したまま、新しい worktree の mise config を trust する ([`.dotfiles/git-hooks`](.dotfiles/git-hooks)) - **シェルの起動ファイル** — mise の有効化と更新通知を、mise が所有し書き換えられるブロックとして `~/.zshrc` と `~/.bashrc` に書き込む([`.mise.toml`](.mise.toml) の `[bootstrap.mise_shell_activate]` と `[dotfiles]`) セットアップはいつでも mise タスクとして再実行できます。 @@ -85,7 +85,7 @@ mise の設定はもう含まれません。リポジトリ側のコピーは `~ | [`mise.lock`](mise.lock) | 実際に入るバージョンとチェックサム。`~/.config/mise/mise.lock` に配置される | | [`.agents/skills`](.agents/skills) | このリポジトリ専用のスキル。汎用のものは [bmthd/skills](https://github.com/bmthd/skills) に分離 | | [`renovate.json`](renovate.json) | GitHub Actions の更新 PR の方針 | -| [`.githooks`](.githooks) | `[tools]` を守る repository 固有の pre-commit フック。global dispatcher は先に pinact を実行してからここへ処理を渡す | +| [`.githooks`](.githooks) | `[tools]` を守る repository 固有の pre-commit フック。global dispatcher からここへ処理を渡す | ツールのバージョンは `mise upgrade` ではなく、毎日走る [`bump-tools.yml`](.github/workflows/bump-tools.yml) が `mise.lock` を進めることで上がります。 手元で先に進めたい場合は `mise lock --bump --minimum-release-age 2d --global`。 diff --git a/README.md b/README.md index d61da98..9732b67 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Afterwards, restart the shell or run `source ~/.zshrc` (`source ~/.bashrc` for b - **Agent skills** — the same set installed for Claude Code, OpenCode, Cursor, Codex, and Gemini CLI - **Plugins** — Codex, pstack, plus the official plugins (TypeScript LSP) - **npm registry** — routed through [Takumi Guard](https://npm.flatt.tech/), a proxy that refuses known-malicious packages -- **Global git hooks** — trust mise configs in new worktrees and pin staged GitHub Actions references before commit, while preserving repository hooks and partial staging ([`.dotfiles/git-hooks`](.dotfiles/git-hooks)) +- **Global git hooks** — trust mise configs in new worktrees while preserving repository hooks ([`.dotfiles/git-hooks`](.dotfiles/git-hooks)) - **Shell startup** — the mise activation and the update notice, written into `~/.zshrc` and `~/.bashrc` as blocks mise owns and can rewrite (`[bootstrap.mise_shell_activate]` and `[dotfiles]` in [`.mise.toml`](.mise.toml)) The setup can be re-run at any time as a mise task. @@ -79,7 +79,7 @@ All of the setup logic lives in mise. | [`mise.lock`](mise.lock) | The versions and checksums that actually get installed, installed to `~/.config/mise/mise.lock` | | [`.agents/skills`](.agents/skills) | Skills specific to this repository; the general-purpose ones live in [bmthd/skills](https://github.com/bmthd/skills) | | [`renovate.json`](renovate.json) | Update policy for GitHub Actions PRs | -| [`.githooks`](.githooks) | A repository pre-commit hook guarding the `[tools]` block; the global dispatcher runs pinact first and then forwards here | +| [`.githooks`](.githooks) | A repository pre-commit hook guarding the `[tools]` block; the global dispatcher forwards here | Tool versions move when the daily [`bump-tools.yml`](.github/workflows/bump-tools.yml) advances `mise.lock`, not through `mise upgrade`. To get ahead locally: `mise lock --bump --minimum-release-age 2d --global`. diff --git a/docs/supply-chain.ja.md b/docs/supply-chain.ja.md index c788c9f..c7f9704 100644 --- a/docs/supply-chain.ja.md +++ b/docs/supply-chain.ja.md @@ -10,7 +10,7 @@ | 成果物の完全性 | `mise.lock` のチェックサム | ロックした成果物と異なるバイト列。ただし **checksum を記録する backend に限る** ([カバー範囲](#カバー範囲-どのツールに何が効くか)) | | 成果物の provenance | backend の検証 + `locked_verify_provenance` | 対応する成果物で、記録済み provenance を検証できなくなった場合 | | パッケージ | `~/.npmrc` の [Takumi Guard](https://npm.flatt.tech/) プロキシ | npm 経由すべて。特にロックできない実行時の `npx ctx7@latest` / `npx skills add` | -| Action のソース | `pinact` が検証する完全な commit SHA | GitHub Actions の release tag の移動や侵害 | +| Action のソース | `.github/workflows/actions.lock` に記録した commit SHA | GitHub Actions の release tag の移動や侵害。推移的に使われる action も含む | ## バージョン: `latest` 宣言 + ロックファイル @@ -68,7 +68,7 @@ checksum による保護は mise ではなく backend の性質です。 policy が必須とし、下のチェックが検証するのもこの 2 つです。lockfile にあるほかの platform variation はそのまま残し、ここでは主張しません: -`aqua:anomalyco/opencode`, `aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:cloudflare/cloudflared`, `aqua:jqlang/jq`, `aqua:modem-dev/hunk`, `aqua:pnpm/pnpm`, `aqua:suzuki-shunsuke/pinact`, `aqua:x-motemen/ghq`, `core:bun`, `core:node`, `github:rtk-ai/rtk` +`aqua:anomalyco/opencode`, `aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:cloudflare/cloudflared`, `aqua:jqlang/jq`, `aqua:modem-dev/hunk`, `aqua:pnpm/pnpm`, `aqua:x-motemen/ghq`, `core:bun`, `core:node`, `github:rtk-ai/rtk` version と backend しか記録していないもの。上の補集合であり、許可リストの例外と同じ集合です: @@ -80,7 +80,7 @@ version と backend しか記録していないもの。上の補集合であり さらに検証済みの provenance を lockfile に持つもの: -`aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:jqlang/jq`, `aqua:pnpm/pnpm`, `aqua:suzuki-shunsuke/pinact` +`aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:jqlang/jq`, `aqua:pnpm/pnpm` この 4 つのリストは、CI のたびに [`tests/mise-pins-test.sh`](../tests/mise-pins-test.sh) が `mise.lock` と突き合わせます。 @@ -89,7 +89,7 @@ backend が checksum を得たり失ったりしたときに、この文書が checksum が保証するのは、`mise.lock` の値を基準とした完全性です。 そのバイト列を誰が build または publish したかという真正性までは保証しません。 真正性については、backend と upstream release が対応する場合に mise が検証済み provenance を記録します。 -現在は、すでにその provenance を提供している `github-cli`、`jq`、`pinact`、`pnpm`、`uv` について、記録されたすべての platform 成果物に `github-attestations` を必須とします。 +現在は、すでにその provenance を提供している `github-cli`、`jq`、`pnpm`、`uv` について、記録されたすべての platform 成果物に `github-attestations` を必須とします。 各期待値は現在の正確な aqua backend にも結び付けるため、upstream identity の変更には policy の再審査が必要です。 これらの記録が消えるか別の値へ変わると、後退として検出します。 @@ -97,19 +97,20 @@ checksum が保証するのは、`mise.lock` の値を基準とした完全性 この保証は mise と upstream release の双方が provenance を提供する成果物に限られます。 checksum しかない tool や、明示した version-only の例外に provenance を追加する設定ではありません。 -## Action のソース: 不変な commit SHA +## Action のソース: workflow lockfile -[`.github/workflows`](../.github/workflows) 以下の `uses:` は、すべて 40 文字の完全な commit SHA に固定します。 -行末には release tag をコメントとして残すため、実行時に可変な tag を信頼せず、レビューでは元のバージョンを読めます。 +workflow は action を正確な release tag (`actions/checkout@v7.0.1`) で参照し、[`.github/workflows/actions.lock`](../.github/workflows/actions.lock) がその tag の解決先 commit と、名前の裏にある owner と repository の数値 ID を記録します。 +Actions は tag の現在の指し先ではなく lock した commit を実行し、`uses:` に entry がない job は実行しません。workflow ファイルに SHA を書く方式と違い、action がさらに使う action も lockfile の対象になります。 -二つの経路で `pinact` がこの状態を維持します。 -CI の `pinact run --check --verify-comment` は、未固定の参照に加えて、SHA とバージョンコメントの不整合も拒否します。 -global pre-commit dispatcher は staged workflow に pinact を実行してから、従来どおり repository 固有の pre-commit hook へ処理を渡します。 -pinact は index の一時コピーを修正し、生成した blob だけを index に戻すため、未 stage の編集や部分 stage の内容が commit に混ざりません。 -同じ修正を working tree へ安全に適用できる場合は反映し、競合する未 stage 編集は変更せずに残します。 +lockfile は [`gh actions-lock`](https://github.com/github/gh-actions-lock) 拡張が生成し、手で編集しません。 +Renovate は `uses:` を上げる PR の中で lockfile も再生成します。workflow を手で編集したら `gh actions-lock` を実行して結果を commit します。 +CI の `Actions lockfile` job は `gh actions-lock --verify` を実行し、lockfile にない参照や、upstream で検証できなくなった commit があれば失敗します。 +ほかのすべての action を信頼してよいかを判定するのはこの拡張なので、CI では release を固定して入れます。 -pinact 自体も mise の管理対象であり、`mise.lock` が checksum とバージョンを固定します。 -その lock entry は、ほかのツールと同じ日次の `--minimum-release-age 2d` gate を通って更新されます。 +lockfile の diff は依存の変更としてレビューします。`commit` の変化は新しく実行されるコードで、`owner_id` や `repo_id` の変化は、名前の裏の repository が lock したものと別物になったことを意味します。 + +これは以前の `pinact` による構成を置き換えます。全 repository で staged workflow を SHA に固定していた global pre-commit hook も含みます。 +lockfile は repository ごとの opt-in で、machine 全体の hook が勝手に作るものではないため、hook は移植せずに削除しました。 ## パッケージ: npm レジストリのプロキシ diff --git a/docs/supply-chain.md b/docs/supply-chain.md index fe6e17f..a19427a 100644 --- a/docs/supply-chain.md +++ b/docs/supply-chain.md @@ -10,7 +10,7 @@ The defense is four layers, each covering a different range. | Artifact integrity | checksums in `mise.lock` | bytes that differ from the locked artifact, **on the backends that record one** — see [coverage](#coverage-which-tools-get-what) | | Artifact provenance | backend verification + `locked_verify_provenance` | supported artifacts whose recorded provenance no longer verifies | | Package | the [Takumi Guard](https://npm.flatt.tech/) proxy in `~/.npmrc` | everything through npm, especially the run-time `npx ctx7@latest` / `npx skills add` that cannot be locked | -| Action source | full commit SHAs verified by `pinact` | movement or compromise of a GitHub Actions release tag | +| Action source | commit SHAs recorded in `.github/workflows/actions.lock` | movement or compromise of a GitHub Actions release tag, including in transitive actions | ## Version: `latest` declarations plus a lockfile @@ -64,7 +64,7 @@ These record a checksum for the two platforms this repository installs on, `linu That is the pair the policy requires and the pair the check below verifies; the other platform variants in the lockfile are left intact and are not asserted here: -`aqua:anomalyco/opencode`, `aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:cloudflare/cloudflared`, `aqua:jqlang/jq`, `aqua:modem-dev/hunk`, `aqua:pnpm/pnpm`, `aqua:suzuki-shunsuke/pinact`, `aqua:x-motemen/ghq`, `core:bun`, `core:node`, `github:rtk-ai/rtk` +`aqua:anomalyco/opencode`, `aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:cloudflare/cloudflared`, `aqua:jqlang/jq`, `aqua:modem-dev/hunk`, `aqua:pnpm/pnpm`, `aqua:x-motemen/ghq`, `core:bun`, `core:node`, `github:rtk-ai/rtk` These record nothing but a version and a backend — the list above's complement, and the same set as the allowlisted exceptions: @@ -76,33 +76,34 @@ These record nothing but a version and a backend — the list above's complement And these additionally carry verified provenance in the lockfile: -`aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:jqlang/jq`, `aqua:pnpm/pnpm`, `aqua:suzuki-shunsuke/pinact` +`aqua:astral-sh/uv`, `aqua:cli/cli`, `aqua:jqlang/jq`, `aqua:pnpm/pnpm` [`tests/mise-pins-test.sh`](../tests/mise-pins-test.sh) checks these four lists against `mise.lock` on every CI run, so a backend that gains or loses a checksum fails here rather than quietly making this page a lie. A checksum establishes integrity relative to the value in `mise.lock`; it does not establish who built or published those bytes. For authenticity, mise records verified provenance when a backend and release provide it. -The policy currently requires `github-attestations` on every recorded platform asset for `github-cli`, `jq`, `pinact`, `pnpm`, and `uv`, because those tools already provide that provenance. +The policy currently requires `github-attestations` on every recorded platform asset for `github-cli`, `jq`, `pnpm`, and `uv`, because those tools already provide that provenance. Each expectation is also bound to its current exact aqua backend, so switching the upstream identity requires policy review. Removing or changing one of those entries is treated as a regression. `.mise.toml` sets `locked_verify_provenance = true`, so installation re-runs cryptographic provenance verification instead of trusting the lockfile's prior verification result. This guarantee applies only to artifacts for which mise and the upstream release provide provenance; it does not add provenance to the checksum-only tools or the explicit version-only exceptions. -## Action source: immutable commit SHAs +## Action source: the workflow lockfile -Every `uses:` reference under [`.github/workflows`](../.github/workflows) is pinned to a full 40-character commit SHA. -The release tag remains in an end-of-line comment, so a review still shows the recognizable version without trusting that mutable tag at run time. +Workflows reference actions by an exact release tag (`actions/checkout@v7.0.1`), and [`.github/workflows/actions.lock`](../.github/workflows/actions.lock) records the commit each tag resolved to, along with the numeric owner and repository IDs behind the name. +Actions runs the locked commit, not whatever the tag points at now, and refuses a job whose `uses:` has no entry. Unlike SHA pins in the workflow file, the lockfile also covers the actions that those actions use. -`pinact` performs both enforcement paths. -CI runs `pinact run --check --verify-comment`, which rejects an unpinned reference and a SHA whose version comment no longer matches. -The global pre-commit dispatcher runs pinact first for staged workflow files, then forwards to the repository's own pre-commit hook as before. -It pins a temporary copy of the index and writes the resulting blobs back to the index, so unrelated unstaged edits and partial staging do not leak into the commit. -When the same fix applies cleanly to the working tree, the hook mirrors it there; a conflicting unstaged edit is left untouched. +The lockfile is generated by the [`gh actions-lock`](https://github.com/github/gh-actions-lock) extension and is never edited by hand. +Renovate regenerates it in the same PR that bumps a `uses:` line; after editing a workflow by hand, run `gh actions-lock` and commit the result. +CI's `Actions lockfile` job runs `gh actions-lock --verify`, which fails when a reference is missing from the lockfile or a locked commit no longer verifies upstream. +The extension itself is installed at a pinned release there, since it is what decides whether every other action is trustworthy. -pinact itself is a mise-managed tool and is checksum-pinned in `mise.lock`. -Its lock entry advances through the same daily `--minimum-release-age 2d` gate as the rest of the toolchain. +Review a lockfile diff as a dependency change: a changed `commit` is new code to run, and a changed `owner_id` or `repo_id` means the repository behind the name is no longer the one that was locked. + +This replaces the earlier `pinact` setup, including the global pre-commit hook that SHA-pinned staged workflows in every repository. +A lockfile is a per-repository opt-in, which a machine-wide hook has no business creating, so the hook was removed rather than ported. ## Package: the npm registry proxy diff --git a/mise.lock b/mise.lock index c49ed3c..54814a5 100644 --- a/mise.lock +++ b/mise.lock @@ -407,52 +407,6 @@ url = "https://opencode.ai/files/bin/2.2.7/opencode-linux-x64.tar.gz" checksum = "sha256:811c42be9cad489ea8c411ead49e06f691deee4957ba9a0a56a159a7d6c1abdc" url = "https://opencode.ai/files/bin/2.2.7/opencode-darwin-arm64.zip" -[[tools.pinact]] -version = "5.0.2" -backend = "aqua:suzuki-shunsuke/pinact" - -[tools.pinact."platforms.linux-arm64"] -checksum = "sha256:326e27f5b3b5fca21e6a169b2785ba2023df3dd9ee82dd0f4e438cb1220b68d7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_arm64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205656" -provenance = "github-attestations" - -[tools.pinact."platforms.linux-arm64-musl"] -checksum = "sha256:326e27f5b3b5fca21e6a169b2785ba2023df3dd9ee82dd0f4e438cb1220b68d7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_arm64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205656" -provenance = "github-attestations" - -[tools.pinact."platforms.linux-x64"] -checksum = "sha256:7f003d8f51e984c2264d2009d430e3e0e87ae404a0e2dc2a9a277b0f731bf5b7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_amd64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205650" -provenance = "github-attestations" - -[tools.pinact."platforms.linux-x64-baseline"] -checksum = "sha256:7f003d8f51e984c2264d2009d430e3e0e87ae404a0e2dc2a9a277b0f731bf5b7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_amd64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205650" -provenance = "github-attestations" - -[tools.pinact."platforms.linux-x64-musl"] -checksum = "sha256:7f003d8f51e984c2264d2009d430e3e0e87ae404a0e2dc2a9a277b0f731bf5b7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_amd64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205650" -provenance = "github-attestations" - -[tools.pinact."platforms.linux-x64-musl-baseline"] -checksum = "sha256:7f003d8f51e984c2264d2009d430e3e0e87ae404a0e2dc2a9a277b0f731bf5b7" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_linux_amd64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205650" -provenance = "github-attestations" - -[tools.pinact."platforms.macos-arm64"] -checksum = "sha256:9b9545d53376654005daaee5ab736d579887205ca3df99925c8fe8358c6e7fdb" -url = "https://github.com/suzuki-shunsuke/pinact/releases/download/v5.0.2/pinact_darwin_arm64.tar.gz" -url_api = "https://api.github.com/repos/suzuki-shunsuke/pinact/releases/assets/675205643" -provenance = "github-attestations" - [[tools.pnpm]] version = "12.18.0" backend = "aqua:pnpm/pnpm" diff --git a/renovate.json b/renovate.json index 78a3caa..f5c2421 100644 --- a/renovate.json +++ b/renovate.json @@ -11,14 +11,7 @@ }, "packageRules": [ { - "description": "Digest pins are not a new release, so the age check would only stall them", - "matchUpdateTypes": [ - "pinDigest" - ], - "minimumReleaseAge": null - }, - { - "description": "Workflow action bumps are reviewed together, so batch them into one PR instead of one per action", + "description": "Workflow action bumps are reviewed together, so batch them into one PR instead of one per action. Renovate regenerates .github/workflows/actions.lock in that PR, so no digests are pinned in the workflows themselves and no pinDigest rule is needed.", "matchManagers": [ "github-actions" ], diff --git a/tests/git-hooks-test.sh b/tests/git-hooks-test.sh index e8d5c2d..fe35b74 100755 --- a/tests/git-hooks-test.sh +++ b/tests/git-hooks-test.sh @@ -10,10 +10,10 @@ # git's hook search path rather than extending it, so a dispatcher that # forgot to forward would silently disable lefthook, pre-commit and # friends in every repository on the machine -# 4. pinact fixes the staged workflow snapshot without staging unrelated -# working-tree edits, including in a partially staged file +# 4. the pinact helper an earlier version installed is removed again, but a +# file of that name somebody else put there is not # -# mise and pinact are stubbed: the hooks only have to invoke them correctly. +# mise is stubbed: the hooks only have to invoke it correctly. # The global git config is redirected so the test never touches the real one. set -euo pipefail @@ -28,25 +28,6 @@ cat > "$work/bin/mise" <<'STUB' printf '%s\n' "$*" >> "$MISE_CALL_LOG" STUB chmod +x "$work/bin/mise" -cat > "$work/bin/pinact" <<'STUB' -#!/usr/bin/env bash -if [[ "${PINACT_FAIL:-}" = 1 ]]; then - exit 3 -fi -shift # run -files=() -while [[ $# -gt 0 ]]; do - case "$1" in - --branch-to-tag) shift 2 ;; - *) files+=("$1"); shift ;; - esac -done -for file in "${files[@]}"; do - sed -i.bak 's|actions/checkout@v4|actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4|' "$file" - rm -f "$file.bak" -done -STUB -chmod +x "$work/bin/pinact" export PATH="$work/bin:$PATH" export MISE_CALL_LOG="$work/mise-calls.log" export GIT_CONFIG_GLOBAL="$work/gitconfig" @@ -61,11 +42,6 @@ if [[ "$(git config --global --get core.hooksPath)" != "$hooks" ]]; then exit 1 fi -if [[ ! -x "$hooks/pinact-staged" ]]; then - echo "✗ install.sh did not install the staged pinact helper" >&2 - exit 1 -fi - # Every client-side hook has to be linked, or it stops running everywhere. for hook in pre-commit prepare-commit-msg commit-msg post-checkout post-merge \ pre-push pre-rebase post-rewrite; do @@ -164,76 +140,25 @@ if [[ ! -L "$theirs/post-checkout" ]]; then exit 1 fi -# The helper name is in a user-owned global hooks directory too. An unrelated -# existing file must stop installation before either managed file is replaced. -collision="$work/helper-collision" -mkdir -p "$collision" -printf '#!/bin/sh\necho mine\n' > "$collision/pinact-staged" -chmod +x "$collision/pinact-staged" -if GIT_HOOKS_DIR="$collision" bash "$repo_root/.dotfiles/git-hooks/install.sh" > /dev/null; then - echo "✗ install.sh overwrote a pre-existing staged pinact helper" >&2 - exit 1 -fi -if ! grep -q 'echo mine' "$collision/pinact-staged"; then - echo "✗ install.sh changed the pre-existing staged pinact helper" >&2 - exit 1 -fi - -# pre-commit pins the snapshot in the index, not an unstaged version of the -# same workflow. The working tree should receive the same one-line fix while -# retaining unrelated unstaged edits. -git config --global core.hooksPath "$hooks" -pin_repo="$work/pin-repo" -git init -q "$pin_repo" -mkdir -p "$pin_repo/.github/workflows" -cat > "$pin_repo/.github/workflows/quality.yml" <<'YAML' -name: Quality -jobs: - test: - steps: - - uses: actions/checkout@v4 -YAML -git -C "$pin_repo" add .github/workflows/quality.yml -printf '%s\n' '# unstaged note' >> "$pin_repo/.github/workflows/quality.yml" -git -C "$pin_repo" -c user.email=t@example.com -c user.name=t commit -qm pin - -pinned='actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4' -if ! git -C "$pin_repo" show HEAD:.github/workflows/quality.yml | grep -qF "$pinned"; then - echo "✗ pre-commit did not pin the staged workflow content" >&2 - exit 1 -fi -if git -C "$pin_repo" show HEAD:.github/workflows/quality.yml | grep -qF 'unstaged note'; then - echo "✗ pre-commit mixed an unstaged workflow edit into the commit" >&2 - exit 1 -fi -if ! grep -qF "$pinned" "$pin_repo/.github/workflows/quality.yml" || - ! grep -qF 'unstaged note' "$pin_repo/.github/workflows/quality.yml"; then - echo "✗ pre-commit did not preserve the partially staged working tree" >&2 +# Machines installed before workflow pinning moved to actions.lock carry the +# old pinact helper. A re-install removes it — but only one this script wrote: +# the directory is user-owned, and the same name may be somebody's own file. +stale="$work/stale-helper" +mkdir -p "$stale" +printf '#!/bin/sh\n# bmthd/dotfiles staged pinact helper\n' > "$stale/pinact-staged" +GIT_HOOKS_DIR="$stale" bash "$repo_root/.dotfiles/git-hooks/install.sh" > /dev/null +if [[ -e "$stale/pinact-staged" ]]; then + echo "✗ install.sh left the old staged pinact helper in place" >&2 exit 1 fi -# An API or pinning failure must block the commit and leave both snapshots -# untouched. -printf '%s\n' ' - uses: actions/checkout@v4' >> "$pin_repo/.github/workflows/quality.yml" -git -C "$pin_repo" add .github/workflows/quality.yml -before_index="$(git -C "$pin_repo" show :.github/workflows/quality.yml)" -before_worktree="$(cat "$pin_repo/.github/workflows/quality.yml")" -if PINACT_FAIL=1 git -C "$pin_repo" -c user.email=t@example.com -c user.name=t commit -qm fail; then - echo "✗ pre-commit allowed a commit after pinact failed" >&2 +foreign="$work/foreign-helper" +mkdir -p "$foreign" +printf '#!/bin/sh\necho mine\n' > "$foreign/pinact-staged" +GIT_HOOKS_DIR="$foreign" bash "$repo_root/.dotfiles/git-hooks/install.sh" > /dev/null +if ! grep -q 'echo mine' "$foreign/pinact-staged" 2> /dev/null; then + echo "✗ install.sh removed a pinact-staged it did not write" >&2 exit 1 fi -if [[ "$(git -C "$pin_repo" show :.github/workflows/quality.yml)" != "$before_index" ]] || - [[ "$(cat "$pin_repo/.github/workflows/quality.yml")" != "$before_worktree" ]]; then - echo "✗ pre-commit changed repository state after pinact failed" >&2 - exit 1 -fi - -# The global hook runs in every repository. A commit with no staged workflow -# must not require pinact to be installed or available on PATH. -git -C "$pin_repo" reset -q HEAD -- .github/workflows/quality.yml -mv "$work/bin/pinact" "$work/bin/pinact.disabled" -printf '%s\n' 'ordinary file' > "$pin_repo/note.txt" -git -C "$pin_repo" add note.txt -git -C "$pin_repo" -c user.email=t@example.com -c user.name=t commit -qm ordinary echo "git hook tests passed" diff --git a/tests/mise-pins-test.sh b/tests/mise-pins-test.sh index 6628eab..8ce4282 100755 --- a/tests/mise-pins-test.sh +++ b/tests/mise-pins-test.sh @@ -134,7 +134,6 @@ VERSION_ONLY_ALLOWLIST = { PROVENANCE_REQUIRED = { "github-cli": ("aqua:cli/cli", "github-attestations"), "jq": ("aqua:jqlang/jq", "github-attestations"), - "pinact": ("aqua:suzuki-shunsuke/pinact", "github-attestations"), "pnpm": ("aqua:pnpm/pnpm", "github-attestations"), "uv": ("aqua:astral-sh/uv", "github-attestations"), } From 7da07d6da0a2eb60c4ff1f3613f5970ea73ae7dd Mon Sep 17 00:00:00 2001 From: bmth <81406938+bmthd@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:40:36 +0900 Subject: [PATCH 2/2] ci: add actions.lock Co-Authored-By: Claude Opus 5.5 --- .github/workflows/actions.lock | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/actions.lock diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 0000000..c532ae5 --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,41 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/bump-tools.yml': + - 'actions/checkout@v7.0.1' + - 'actions/create-github-app-token@v3.3.0' + - 'flatt-security/setup-takumi-guard-npm@v1.4.0' + - 'jdx/mise-action@v4.3.0' + '.github/workflows/quality.yml': + - 'actions/checkout@v7.0.1' + - 'flatt-security/setup-takumi-guard-npm@v1.4.0' + - 'jdx/mise-action@v4.3.0' + - 'ludeeus/action-shellcheck@2.0.0' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/create-github-app-token@v3.3.0': + ref: 'v3.3.0' + commit: 'sha1-64ab729a6294000f5aa4a4bc0b73d1f32bc45510' + owner_id: 44036562 + repo_id: 642580244 + 'flatt-security/setup-takumi-guard-npm@v1.4.0': + ref: 'v1.4.0' + commit: 'sha1-14f07d0cbc739b42a1b7c70a04c2b84cd1318ddd' + owner_id: 88821409 + repo_id: 1160374496 + 'jdx/mise-action@v4.3.0': + ref: 'v4.3.0' + commit: 'sha1-c2a87611a18de5b3828c5652fe268e992400cb5c' + owner_id: 216188 + repo_id: 738284564 + 'ludeeus/action-shellcheck@2.0.0': + ref: '2.0.0' + commit: 'sha1-00cae500b08a931fb5698e11e79bfbd38e612a38' + owner_id: 15093472 + repo_id: 174679242