Repository navigation
fix(hooks): turn off core.fsmonitor and hooks on the remaining hook git calls - #17082
Conversation
A repository whose .git/config names a core.fsmonitor command runs it from hook::file_is_gitignored, spd_gitignored, hardcoded-path-check, resolve-convention-pattern, normalize-eol and worktree-remove-gate, because each reads the index without the command-line overrides. Refs #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lcheck-clean Refs #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
HOOK_GIT in lib/hook-utils.sh holds the one git command a hook runs in a repository it did not create: git --no-pager -c core.fsmonitor=false -c core.hooksPath=/dev/null. Command-line configuration outranks the repository's own, so a core.fsmonitor named in a planted .git/config no longer runs when a hook reads the index. Each hook git call now starts with it; normalize-eol.sh, harness-ops-paths.sh and worktree-remove-gate source hook-utils.sh for it. The POSIX-sh resolver and the Node settings-write-ask hook pass the same arguments, since neither can read a bash array. Shared copies regenerated by sync-shared-copies.sh. Closes #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t shim The hook's git calls now lead with the HOOK_GIT overrides, so -C is no longer the first argument the shim sees. Refs #16959 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #17082, incremental
|
|
claude-review reviewed Code review (blocking only): routing hook git calls through
|
The fragments said every git command a hook runs passes the overrides and that no command named in a repository's config runs. Neither holds: bash-format, markdown-format and source-control hooks load scripts outside hooks/ that still call git plainly, and a .gitattributes content filter can still run through git status. The fragments now name the hooks/ scripts, fsmonitor and git hooks only, and the three plugins name what remains under issue 16959. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…gments javascript-format.sh and python-format.sh source their plugins' git-hooks/adapters.sh, which still run plain git ls-files, so their Security fragments now say those calls are not yet covered, as the bash-format fragment does. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Lint Shell failed on the PR head. worktree-remove-gate.sh sourced
hook-utils.sh above its first early exit, which check-killswitch-hoist
refuses; the source now sits just before the first git call. The source
added to normalize-eol.sh made shellcheck follow hook-utils.sh from
eol-normalizer.test.sh and report SC2031; normalize-eol.sh no longer
sources it and runs "${HOOK_GIT[@]-git}", since eol-normalizer.sh
sources hook-utils.sh first, as abort-boundary.sh does.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Lane run report
Failed GitHub API calls
|
Lane-Activity: pr-unblock/resolve-conflicts
Lane run report
Failed GitHub API calls
|
#17104 added hook::git_untrusted for the three ignore checks. Drop this branch's HOOK_GIT array, and the array the merge from main left beside the function, and call the function at the remaining hook git call sites. Sites a bash function cannot reach without an extra process or at all (a `( … )` subshell or pipeline tail, an exec'd argv, `command git`, POSIX sh, Node, a library sourced without hook-utils.sh) write the same overrides out. block-dangerous-git's width probe and the hardcoded-path-check and temp-scratch probes used `$(exec git … 2>…)` for one process; a function cannot be exec'd, so the width probe runs `exec 2>&1` first inside the substitution and the other two put the redirect on a group around the assignment: one clone each under strace, as before. The comments that explained the old `exec` are removed. Trim lib/hook-git.test.sh to the sites #17104's tests do not cover, and reword the 22 fragments to what this branch adds. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Held by the session that owns this PR. After #17104 landed the same kind of hardening on |
|
The pr-verify verifier failed head What it wrote (42 lines)This pull request leaves the merge queue, and ci-status holds it out while it carries |
|
Owner decision, 2026-11-18, typed in the owning session: "go w/ recommendations" on Q74, option A: an independent reviewer read the rebuilt diff against #17104, the body is rewritten to match, and the pull request merges with its The review found one helper ( |
Refs: #16959
Summary
Hooks ran git in the edited file's repository without command-line overrides, so a
core.fsmonitorcommand named in that repository's own.git/configran whenever a hook read the index. #17104 (merged) addedhook::git_untrustedinlib/hook-utils.sh, which passes--no-pager -c core.fsmonitor=false -c core.hooksPath=/dev/null(the overrides PR #16954 uses), and routed the three git ignore checks through it:hook::file_is_gitignored, guardrailsspd_gitignoredandhardcoded-path-check's ignore check. This pull request gives the same overrides to the other git calls inplugins/*/hooks/**andlib/hook-utils.sh, about 40 call sites: most call that helper, and about ten write the same four arguments out literally (listed under Fix). They include the seven that still started a planted fsmonitor on main: the convention resolver's twols-filescalls and itscheck-ignore,stale-path-verify's twols-filescalls,normalize-eol'scheck-attr, andworktree-remove-gate'sstatus. No check answers differently.Fix
lib/hook-utils.sh:hook::repo_root_uncached_tocallshook::git_untrustedandhook::in_git_working_treepasses its overrides; the function's comment now covers every hook git call and says why some callers write the overrides out. No second helper: theHOOK_GITarray this branch first added, and the array the merge from main left beside the function, are removed.hook::git_untrusted.harness-ops-paths.shandworktree-remove-gate.shdid not loadhook-utils.sh; they now source it (worktree-remove-gate.shbelow its early exits, socheck-killswitch-hoistholds). That load is a new dependency forworktree-remove-gate.sh: if itshook-utils.shcopy fails to load, the gate's first git call fails and it refuses the removal (fails closed).lib/resolve-convention-pattern.shand its guardrails copy (POSIX sh, one-linercp_git),settings-write-ask.mjs(Node argv),abort-boundary.sh(command gitskips functions, and it can run beforehook-utils.shis sourced),normalize-eol.sh(its tests source it withouthook-utils.sh),block-root-delete-target.sh(rdt_bounded_toexecs its argv),hook::in_git_working_treeand source-controlgit_unlocated(last command of a( … )subshell, where a function costs bash a second process: the spawn-budget suite counted 22/25/24 process creations instead of 20/24/23 until these were written out), and the two pipeline sites instale-path-verify.shandharness-ops-paths.sh. Withmce::git_execinblock-main-checkout-edit.sh(PR feat(guardrails): deny edits in a main checkout on its default branch #16954, untouched) that is about nine places. The alternative a lanes bot's merge from main put on this branch (HOOK_GITarray plushook::git_untrusteddelegating to it) keeps one bash source for the overrides at the cost of a second helper; this branch keeps main's single function instead. Either can be switched later without changing behaviour.$(exec git … 2>…)to keep one process; a function cannot be exec'd, so the redirect moved:block-dangerous-gitrepo_oid_widthrunsexec 2>&1first inside the substitution, andrepo_is_temp_scratchandhardcoded-path-check'srev-parseput2>/dev/nullon a group around the assignment. Measured withstrace -f -e trace=clone,clone3,execveon bash 5.3 for those shapes: one clone each, as before.scripts/sync-shared-copies.sh(22hook-utils.shcopies, the guardrails resolver copy, the harness-opsharness-ops-paths.shcopy). Onepatchfragment per carrier plugin (22), each naming only what this pull request adds beyond fix(hooks): turn off config-driven commands on the git ignore checks hooks run #17104's fragments.Call sites this pull request adds
"Reads index" marks the subcommands that started the planted fsmonitor when probed against git 2.53.
lib/hook-utils.shhook::in_git_working_tree,hook::repo_root_uncached_to(all 22 carriers)lib/resolve-convention-pattern.sh(+ guardrails copy)stale-path-verify.shnormalize-eol.shworktree-remove-gate.shhardcoded-path-check.shabort-boundary.sh,block-dangerous-git.sh,block-fix-request-post.shblock-dangerous-git.shx2,block-no-verify.sh,block-root-delete-target.sh,block-convention-violation.shblock-convention-violation.sh,block-noncanonical-commit.sh(repo_git_probe)block-unresolved-pr-merge.sh, autonomylane-stop-gate.sh,desktop-notification.shsettings-write-ask.mjsharness-ops-paths.sh(+ harness-ops copy)pr-linkage-mcp-gate.shworktree-add-containment-gate.sh(git_unlocated)Not changed:
plugins/testing/hooks/judge-lib.sh(no hook loads it),lib/hook-test-sink.shand its copies (test helper),block-root-delete-target-fixtures.sh(test fixture).Verification
bash lib/hook-git.test.sh: a repository whose.git/confignames acore.fsmonitorcommand that leaves a marker file, run through the convention resolver,normalize-eol.shandworktree-remove-gate.sh, each also asserting the hook's answer is unchanged. Itshook::file_is_gitignored, secret-pattern-detection and hardcoded-path-check cases were dropped: fix(hooks): turn off config-driven commands on the git ignore checks hooks run #17104's own tests cover those sites. Not covered:stale-path-verify.sh's twols-filescalls have no planted-fsmonitor case, and the resolver has one case (its tracked-file check), so the test covers three of the hooks that read the index, not each of the seven sites.lib/hook-git.test.sh5/0,lib/resolve-convention-pattern.test.sh125/0, guardrailssecret-pattern-detection315/0,hardcoded-path-check173/0,abort-boundary391/0,block-convention-violation185/0,block-fix-request-post316/0,block-no-verify470/0,block-unresolved-pr-merge726/0,stale-path-verify151/0,settings-write-ask24/0,block-root-delete-targetand-bto-fand-resolveall 0 failures; eol-normalizereol-git-add12/0; source-controlworktree-remove-gate63/0,worktree-add-containment-gate48/0,pr-linkage-mcp-gate57/0; desktop-notification 49/0; session-telemetryharness-ops-paths37/0.worktree-gates-spawn-budget: process creations exactly 20, 24, 23 and 23 as budgeted.mainon this host:lib/hook-utils.test.sh713/1 (a locally installed biome),eol-normalizer63/1 (misenodeshim),block-dangerous-git1089/5 andblock-noncanonical-commit292/2 (strace execve counts 2 higher through mise shims),lane-stop-gate126/2, and the spawn-budget execve counts (shims). No process-creation count changed.secret-pattern-detection.test.sh's git shim recorded-Conly as the first argument; it now finds-Canywhere, since the overrides come first.shellcheck --rcfile .shellcheckrc -xon every changed shell file: clean.scripts/check-affected.sh: 18 passed, 1 skipped over 68 changed files.Remaining
Issue #16959 stays open for these; this pull request links it with
Refs:because they are not done here.hooks/:bash-format.sh,markdown-format.sh,javascript-format.shandpython-format.shsource their plugins'git-hooks/adapters.sh(and markdown-format'smarkdown-gates.sh), which run plaingit ls-files;worktree-create-gate.shruns source-control'sscripts/worktree-create.sh, which usesscripts/lib/worktree-facts.shandscripts/worktree-root-resolve.sh; alsoscripts/reap-project-plugin-records.sh.git statusinworktree-remove-gate.sh(and inside itsgit worktree remove) rehashes a touched tracked file through its.gitattributesfilter=<driver>, which runsfilter.<driver>.cleanor.processfrom the repository's config. Command-line-ccannot switch off a driver whose name is unknown; a status check that skips rehashing needs its own study.worktree-create.shrunsgit worktree add, which runs the repository's post-checkout hook, so passingcore.hooksPath=/dev/nullthere would change what it does.Related
hook::git_untrustedand covered the three ignore checks; this branch was rebuilt on it.🤖 Generated with Claude Code