Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Secret-in-commit hooks never run: Claude Code doesn't set $TOOL_INPUT

オープン 初心者向け
#124 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
shell
領域
devtools

調査の方向性

.claude/settings.json と、現在 echo "$TOOL_INPUT" を grep にパイプしている 3 つのフックコマンド(PreToolUse が 2 つ、PostToolUse が 1 つ)を読む。Claude Code hooks reference によれば、ツール入力は stdin 上で届くため、パイプを外して grep に stdin を直接読ませ、ブロックメッセージは stderr へ送って Claude Code が却下理由として報告するようにする。各フックが終了コード 2 で終了し、ステージ済みの .env または git commit 呼び出しをブロックしたときに完了とみなす。検証は、Claude Code が送信する JSON をフックに与えて行う。

索引モデルが issue の本文から書いたものです。

説明

The two PreToolUse hooks in .claude/settings.json that stop a commit containing a sensitive file or a possible secret, and the PostToolUse security scan, all start with echo "$TOOL_INPUT" | grep -q 'git commit'. Claude Code passes the tool call to a hook as JSON on stdin and does not set $TOOL_INPUT (the hooks reference lists the variables it does set), so the grep never matches and none of the three checks runs.

I checked with Claude Code 2.1.292 that TOOL_INPUT is empty inside a hook. Then, in a repo with .env staged and fed the JSON Claude Code sends for git commit -m wip, both PreToolUse hooks exit 0 and the commit would go ahead.

The fix is to drop echo "$TOOL_INPUT" | so grep reads stdin. Sending the message to stderr also makes it the reason Claude Code gives for the block:

"command": "if grep -q 'git commit'; then git diff --cached --name-only | grep -E '\\.(env|pem|key|p12)$' && echo >&2 '⛔ BLOCKED: Sensitive file in commit' && exit 2 || exit 0; fi"

With that change and the same staged .env, the first hook exits 2 with "Sensitive file in commit" and the second exits 2 with "Possible secret in commit". The same one-line change applies to the PostToolUse scan.

Found this while testing Claude Code guards for Paveo. Happy to open a PR with the fix.

主要言語
Go
スター
75
フォーク
2
平均マージ
16日 4時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nylas/cli のほかの issue

nylas/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。