guardrails: run the content scan's secret and machine-path checks through gitleaks to fit the 3 s hook ceiling

オープン
#20,992 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
54/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
bash, git, shell

調査の方向性

Read plugins/guardrails/git-hooks/content-scan.sh, lib/git-hooks/check-lib.sh, and the guardrails entries.json tool declarations; compare the existing secret and machine-path rules with the cases in plugins/guardrails/git-hooks/*.test.sh. Run the pre-commit and pre-push content tests, then use scripts/check-git-hook-time-budget.sh --force --sizes 120,2000,10000 on Windows Git Bash. Done means the tests retain their asserted behavior, both hooks meet the scaled 3 s budget at every size, and the exemption is removed.

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

説明

host-run

Context

The guardrails pre-commit and pre-push content scan (secrets plus machine-specific paths) is the one git-hook job over the owner's 3 s ceiling on very large changes, so under #20945 it is exempt from that ceiling. On 10 staged files of 10,000 lines (Windows Git Bash, hyperfine, 10 runs) plugins/guardrails/git-hooks/pre-commit-content.sh took 2061 ms; gitleaks git --staged took 327 ms on the same commit and reported a planted fake token. Its two largest costs in a sequential bash -x trace (2.610 s traced total) are shared changed-line work, checks_added_ranges awk in lib/git-hooks/check-lib.sh (0.635 s over two calls) and added_only awk in plugins/guardrails/git-hooks/content-scan.sh (0.245 s), which both its secret and machine-path checks use; the secret-only step is small, so swapping only the secret detector does not help. Decision record: #20945 (issuecomment-7398359436).

Proposed work

  • Express the guardrails machine-path patterns and exemptions as gitleaks rules, so one native gitleaks pass covers secrets and machine paths on the staged (pre-commit) and pushed (pre-push) range.
  • Keep today's findings: every case plugins/guardrails/git-hooks/*.test.sh covers still blocks or passes the same way.
  • Declare gitleaks as a guardrails git-hook tool (entries.json tools), with the missing-tool behavior the formatter PATH-probe checklist sets.
  • Then drop the content scan's exemption from the hook budget.

Acceptance criteria

  • bash plugins/guardrails/git-hooks/pre-commit-content.test.sh and pre-push-content.test.sh pass unchanged in what they assert.
  • scripts/check-git-hook-time-budget.sh --force on Windows Git Bash puts guardrails pre-commit and pre-push content at or under the scaled 3 s budget at every --sizes arm (120, 2000, 10000 lines).
  • The content scan's hook-budget exemption is removed.

References

  • Part of #20945.
主要言語
Shell
スター
22
フォーク
2
平均マージ
3時間 20分
マージ済み PR(30日)
956

環境構築

はじめの一歩

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

melodic-software/claude-code-plugins のほかの issue

melodic-software/claude-code-plugins の issue をすべて見る

似ている issue

Shell/Bash の issue をもっと見る

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

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