Repository navigation
fix(redact): install-prepush-hook never refreshes a stale managed hook, so shipped wrapper fixes never reach an existing install - #2731
Closed
schienbiz wants to merge 1 commit into
Conversation
The marker check returned before the only writer, so once a repo had the hook, no later change to the wrapper could ever reach it. The `printf x` fail-open fix (v1.64.0.0) has still not landed in any repo that received the hook before it, and a wrapper naming a gstack that has since moved stays pointed at a dead path for the same reason. Compare the body against what this version generates: rewrite on drift, stay a no-op when identical. The chained pre-push.local is untouched on both paths. The existing trailing-newline regression test cannot catch this — it installs into a repo with no prior managed hook, the one case that was never broken.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Contributor
|
Thanks for this, @schienbiz. The fix is now on main: gstack-redact rewrites the managed pre-push hook when its body has drifted (fixed in v1.78.0.0, #2752). Closing as superseded; if you still see the problem on the latest gstack, please open an issue with ./setup --status output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
installPrepushHookreturns before the onlywriteFileSyncwhenever the existing hook carries the managed marker:There is no version stamp in the marker and no comparison against what the current version generates, so the wrapper a repo receives on its first install is the wrapper it keeps forever. No migration touches
pre-pusheither (all 12 undergstack-upgrade/migrations/checked), and./setupdoes not call the command.That has already cost one shipped security fix.
_input="$(cat; printf x)"— the sentinel that stops a chainedpre-push.localfrom silently failing open — landed in v1.64.0.0. Sixteen repos here got the hook before that and were still running_input="$(cat)"after upgrading v1.60.1.0 → v1.72.0.0. Eight versions, zero delivery. Measured, one shape per column, with a chained.localbuilt on a barewhile read:.localsees$(cat)(pre-v1.64)$(cat; printf x)(v1.64+)Zero refs, exit 0 — the guard reports success having scanned nothing, which is precisely the failure
printf xwas added to close.bin/gstack-redact-prepushitself is unaffected (it reads stdin asreadFileSync(0).split("\n"), so a missing trailing newline costs it no line), so this only bites the chained-hook seam.The same freeze hits a second, non-security case:
prepushBinis baked in as an absolute path. Move or reinstall gstack elsewhere and the stale wrapper keeps naming abunscript that is no longer there, with no way to repair it short ofuninstall+install— anduninstallrenamespre-push.localback overpre-push, so that route eats the user's chained hook.This is the same shape as #2444 (
link_codex_skill_dirsskipping already-installed skill dirs, "reports ready but never refreshes"), also filed against 1.60.1.0.The fix
Hoist the
wrapperconstruction above the existence check, then compare bodies:existing === wrapper→already installed, no write, no mtime change (idempotent, as before).refreshed stale managed pre-push hook at <path>.pre-push.localand chain it.pre-push.localis never read, renamed, or written on any of the three paths — it is the user's, not gstack's.Content equality rather than a version stamp keeps the marker format untouched and means a wrapper is judged by what it actually is, not by what it claims. The trade-off, stated plainly: a hand-edited hook still carrying the managed marker is overwritten. That seems right — the marker is gstack's ownership claim and
pre-push.localis the documented seam for user code — but the refresh says so on stdout rather than doing it silently, and I'll take a different policy if you prefer one.One consequence worth naming: with both a global and a vendored gstack installed, whichever one runs the command last now owns the
prepushBinpath, where before it was frozen at whichever installed first. Last-writer-wins is the lesser evil against frozen-at-a-dead-path, but it is a behaviour change.Tests
Two added to
test/redact-prepush-hook.test.ts:a stale managed hook is rewritten, and the refresh delivers the newline fix— plants the verbatim v1.63-era wrapper plus a bare-while read.local, runs install, and asserts the body gainsprintf x, the.localsurvives untouched, and — the half that matters — the refreshed wrapper actually delivers the final ref line to that.local.install stays idempotent: an up-to-date managed hook is not rewritten— second run printsalready installed, neverrefreshed, with byte-identical content and unchanged mtime.Receipts, per the standard in the v1.69 notes — the first test fails on a scratch worktree of
b5a951efor the right reason:With the fix:
28 pass, 0 failin that file, and200 pass, 0 failacrossredact-prepush-hook,fs-utils,gstack-redact-cli,redact-engine,redact-engine-autoredact,redact-pattern-lint,redact-doc-resolver.bun run test:freeis not clean on this machine atb5a951eitself — I ran it on a pristine worktree of upstream HEAD to get a baseline before reading my own run. Baseline fails 22 tests (bun-polyfillspawn/serve,gstack-developer-profile --migrate,bump:/DRIFT-REPAIR, a browser-skills E2E); my branch fails a subset of the same set. The one name appearing on my side and not on the baseline's iscodex-hardening's bash-native watchdog deadline test, which fails 1-in-3 on a pristineb5a951eand 1-in-3 on this branch, and contains zero references to redact. No test fails on this branch that does not also fail upstream.Happy to add a CHANGELOG entry / VERSION bump if you'd rather this land as its own release than be absorbed into a wave.