Repository navigation
fix: doctor and keychain warning follow-ups from the #17 review - #19
Merged
Merged
Conversation
Each test fails on main: doctor quotes the parser's text for a corrupt credentials.json, a tool that cannot start reads as exited timeout, and the credential temp file and service.log are written through a symlink.
doctor now says credentials.json could not be read (invalid JSON) instead of the parser's text, which quotes part of a credential. Ran carries the spawn error and signal, so a keychain or service tool that cannot start says could not run, not exited timeout. Writes of the credential and state temp files, the service files and service.log, and the chmod of an existing service.log, go through one helper that never follows a symlink.
6 tasks
Mutation testing showed the hand-rolled write loop added nothing over writeFileSync on a descriptor, and that a real spawn failure and a tail with no whole line were untested. AGENTS.md names the new module.
parsilver
marked this pull request as ready for review
November 16, 2026 00:25
Contributor
Author
|
Ready for review. Five of the six acceptance criteria are met, with tests. CI is green on Ubuntu and macOS. The sixth asks for green on three OSes, but CI has no Windows job; adding one is a separate decision, explained in the description. |
parsilver
commented
Nov 16, 2026
parsilver
left a comment
Contributor
Author
There was a problem hiding this comment.
Verdict: no Blocker. Merging.
- Corrupt
credentials.json:Store.readdrops the parser's text. The new doctor test, with a real credential inside broken JSON, fails on the old code and passesexpectNoSecretsnow. ended(): it tells apart a timeout, a program that could not run, a stop by signal and an exit status. It replaces every?? "timeout"in the keychains and the service manager.- Redaction: the
starttest's fake refusal now carries the credential and still shows[redacted], so it proves the order. private-file.ts:createPrivateremoves what is at the path, creates withO_CREAT|O_EXCL|O_NOFOLLOWat 0600 andfchmods the descriptor.makePrivatedoes lstat and thenfchmodon anO_NOFOLLOWdescriptor.- Every private write and chmod goes through these two.
- On Windows, where
O_NOFOLLOWis absent, the lstat check is the guard. That is acceptable for a user-profile path.
CI is green on macOS and Linux. Releases are manual, so nothing to deploy.
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.
Closes #18
Follow-ups from the #17 review: doctor no longer prints the JSON parser's text, keychain and service failures say how the tool ended, two tests now prove redaction, and Tether's private files are never written or chmodded through a symbolic link.
Acceptance criteria
Corrupt
credentials.json.Store.readturns aSyntaxErrorinto<file> could not be read (invalid JSON)and drops the parser's message. Other read errors keep the system message, which never quotes file contents. Test:tether doctor > fails, without quoting it, when credentials.json is not valid JSON. It writes broken JSON that holds the issued credential, expects the new FAIL line and exit 1, and callsexpectNoSecrets. Before the fix the test fails and the output readscould not be read: Unexpected token 'd', ...\"ential\": tdc_119007f\"... is not valid JSON, which is part of a real credential."could not run", not "exited timeout".
Rannow carries the spawn error code and the signal.ended()inrun.tsreturnsexited N,timed out(checked first, because a spawnSync timeout also sets SIGTERM),could not run, orwas stopped (SIG). Both keychains use it for refusals and for the "did not answer" reason, and the service manager's failure text uses it too, since it had the same?? "timeout"pattern. Tests:the macOS / Secret Service keychain's tool(ENOENT, ETIMEDOUT with SIGTERM, SIGKILL),run > reports a program that cannot start ... as one that could not run(a real spawn), andtether service on Linux > says what systemd printed, or its exit status(now also checkscould not run).startwarning test. The fake keychain's refusal reason contains the credential. The test expects(the test keychain is locked: [redacted])and passesexpectNoSecrets.Doctor FAIL test. The locked-keychain doctor test calls
expectNoSecrets.No following symlinks. The new
src/client/private-file.tsholds every write and chmod of a user-only file:createPrivateremoves whatever is at the path (a link is removed as a link), then creates the file withO_CREAT|O_EXCL|O_NOFOLLOWat 0600 and callsfchmodon that descriptor. It writes the temp files forcredentials.json, the other state files andtasks.jsonl, and the launchd, systemd and Windows service files.makePrivatetakes back an existingservice.logat launchd install. It does an lstat check, thenfchmodon a descriptor opened withO_NOFOLLOW.cutToTailtrimsservice.logon one descriptor: lstat check,O_RDWR|O_NOFOLLOW,fstat, read the tail,ftruncate, write,fchmod.A symlink makes the call fail with
<file> is a symbolic link; Tether does not write through one. Remove it.The exception is the temp file, which is replaced. Windows has noO_NOFOLLOW, so the lstat check stands in there. Tests:files Tether writes(a symlinked credential temp file and a symlinkedservice.log; the target's bytes and mode stay unchanged) andtether service on macOS ... refuses a log that is a symbolic link(install fails before anylaunchctlcall).CI green on all three OSes. CI runs on Ubuntu and macOS, and both are green on this PR. The CI matrix has no Windows job, so there is no third OS to be green on. Windows is only built by the release workflow, which doesn't run tests. Adding a Windows job is a separate decision. Many existing tests assume POSIX modes and symlinks, so it would need its own work. I left that out of this PR.
Commands and output
RED on
mainwith the new tests: 11 failed, 107 passed in the touched suites, each failing for the reason it targets.Quality gates (changed code)
runat 7.0 (CC 7, 90% covered),withCredentialat 6.2, andmacKeychainandsecretToolKeychainat 6.0. The new module's functions score 4.0 or less.dryer srcfound no duplicate candidates.private-file.ts,run.ts): 13 killed, 3 survived. All three survivors are??to||inrun()(input, stdout, stderr). They are equivalent: the only falsy value besides null or undefined is"", which gives""either way. The first mutation run left four more survivors. Two were in a hand-rolled write loop, now replaced bywriteFileSyncon the descriptor. The other two needed new tests: a real spawn failure, and a tail with no whole line.Risks
service.logis cut in place on one descriptor, as before, so launchd's append keeps working.service.lognow failstether service installon macOS, andtether startprints "Could not trim the service log" every ten minutes. That is on purpose, and the message names the file.Not verified
O_NOFOLLOWis missing, but I didn't run them on Windows.TETHER_REAL_SERVICE=1) runs in CI on macOS, not locally.CI
Ubuntu and macOS are green on the head commit. The first macOS run failed in
runClaudeCode > kills the whole process group, a test this PR doesn't touch. It waits for its record file to exist and then parses it, so it can read a half-written file (Unexpected end of JSON input). A rerun of the failed job passed. That flake is worth its own issue.