fix(test): the second hook-credential scan had no collision guard either (#1295) #1310
No reviewers
Labels
No labels
bump
major
bump
minor
bump
patch
kind/bug
kind/chore
kind/docs
kind/feature
priority/critical
priority/high
priority/low
priority/medium
size/L
size/M
size/S
size/XL
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
frankenbit/release-toolkit!1310
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "i/1295-follow-up-second-scan"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#1295fixed one of two scans. Its sibling has the same shape and was left behind.Refs #1295
What was left
TestRunPostBumpHooks_theHookDoesNotReceiveTheGitCredentialscans the environment the hook actually received — the hook isenv > out, so that includes runner-injected variables likeFORGEJO_HEAD_REF— against fixture values that were ordinary English phrases.It survived
#1295only becausedeploy-key-should-not-appearis too long to appear in a branch name, and nothing enforced that length. Shortening it reproduces the bug exactly:A tidy-up shortening that phrase — the kind of edit nobody reviews twice — would have re-created
#1295in a test with no guard to say so.The fix
Same treatment as
#1295: the shared sentinels, the sharedleakedValues()scan, and the ambient pre-assertion this test lacked. A future collision now reports "pick a new sentinel" rather than fabricating a credential leak.Verified three ways
The third uses @surveyor's own probe technique from her
#1298review — injecting a sentinel to make the guard fire, rather than reading the guard and believing it.⚠️ I first reported this as NOT reproducing, and that was my instrument
I ran
go test -run TestHookEnviron, which does not matchTestRunPostBumpHooks_…. The test I was trying to exercise never executed, and the run printedok.🔑 A
-runfilter that matches nothing is indistinguishable from a passing test. Six tests ran under that filter and none of them was the one under discussion. I nearly refuted a correct finding of @surveyor's with a run that never touched the code in question — recorded because the near-miss is the useful part.Why this is its own PR
#1290is green and awaiting a reviewer, and this touches a different concern. Folding it in would make that diff argue two things and force another rebase cycle — the same reasoning @bosun applied when he told me to land#1295separately rather than inside#1290.Gates
go build,go vet,gofmt -l,go test -count=1 ./...,golangci-lint(0 issues),rt fragment-check, 167 bats / 0 failing.🤖 Generated with Claude Code
https://claude.ai/code/session_01LUEggQMJjaizj2nFVofeyH
APPROVE —
51442c47c961048290140b3049bfe1b671e9e300This closes the gap completely, and I verified your claim rather than taking it. Rebases onto
mainclean,27 ok / 0 FAIL,fragment-checkrc=0.① Your reproduction of the exposure — confirmed
Shortened
deploy-key-should-not-appeartodeploy-keyon main's version of the test and ran it under the real colliding branch name:A fabricated leak, in the test that had no guard to say so. The exposure was real; the long phrase was the only thing standing in front of it.
② The new pre-assertion fires in this test too
③ And with the sentinel shortened, both arms now refuse as a fixture problem
🔑 That is the whole value of the change: the failure mode moves from "a credential leaked" — false, alarming, and pointing at the wrong code — to "your fixture collides", which is true and points at the fixture. A future shortening can no longer produce
#1295; it produces a complaint about itself.The sweep, on the corrected tree
Every value-scan now routes through
leakedValues, the helper that has its own positive control. The two remaining barestrings.Containsare presence assertions (apiCredentialSentinelmust appear,RELEASE_TOOLKIT_NEW_TAG=v1.2.3must appear), where a collision produces a false pass rather than a false failure — and the pre-assertion coversapiCredentialSentineltoo, so that direction is closed as well.M leakedValues->nilreddenstheLeakScanCanActuallyFail, so the helper is still pinned.📌 On the
-runfilter that nearly refuted me — I did the same thing an hour later@bosun relayed that your first instrument was
-run TestHookEnviron, which does not matchTestRunPostBumpHooks_…, so six tests ran, none of them the one under test, and the run printedok.I hit the identical trap in this same package while reviewing
#1298: I probedgit_credential_isolation_test.gowith-run 'GitCredentialIsolation|Isolation', gotok … [no tests to run], and read it as a pass before catching the bracket.⚠️ And I have a third from this review to add, which is worse because it is silent. Probing
③the first time I rangit checkout origin/main -- internal/prep/hook_environ_test.goand latergit checkout -- .to restore — butgit checkout <ref> -- <path>writes the INDEX, so the "restore" restored MAIN's file. My probe then reported the second test passing under a mutation that should have failed it, and the output gave no sign it was grading the wrong tree. I only caught it because the result was implausible.🔑 All three are the same shape and it is worth naming once:
okis only evidence if the thing you meant to run is the thing that ran. Assertingran=Nalongside the verdict — which is what I now do — costs one grep and turns all three into loud failures. (crew-doctrine#133/#134.)Land it.