Repository navigation
fix(client): a cancel always wins over a late answer; fix flaky tests - #68
Merged
Merged
Conversation
After a hang-up, the deadline, a stop or a signal, ssh-agent gives no signature and ssh-grant says cancelled, even when an answer arrives at the same moment. Three flaky tests now wait for the real events. Closes #63
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.
What
Flaky tests that failed now and then, also in CI, and one real bug that the stress runs found.
TestAgentLogin/approved(test bug): the test SSH server counted a login only after it had answered the client, so the test could read the count too early. The server now counts the end of every handshake, and the tests wait for it.cmd/nodkeyTestBrokerStartsAndStops(test bug): a probe script was written and run at once; a child process that a parallel test started at that moment kept a copy of the write handle, so running the probe failed with "text file busy" (go.dev/issue/22315). Test files are now written while holdingsyscall.ForkLock.cmd/nodkeywith two test processes at once (test bug): one could take the other's broker port between restarts. Ports are now reserved across processes.nodkey ssh-agentandnodkey ssh-grant(code bug): Go's HTTP client can still return an answer that arrives during a cancel. After ssh hung up, the agent printed "denied", and with an approval at that same moment it could hand ssh a signature after it had cancelled the request;ssh-grantprinted "allowed" after a Ctrl-C. Now a hang-up, the deadline, an agent stop or a signal always wins: no signature, "cancelled", and the signal is raised again. Not a security hole (ssh was already gone; the grants are written in the audit log), but it broke the fail-closed rule.Tests
CI=true go test -race -count=200 -cpu 1,2,4 -run TestAgent ./internal/client/and-count=50 ./cmd/nodkey/pass on Go 1.27 and 1.26. New:TestAgentCancelWinsOverALateAnswer,TestSSHGrantCancelWinsOverALateAnswer.Review
Two rounds with the security-reviewer agent; no test got weaker, and
nodkey runalready handled the late answer correctly.Closes #63