Skip to content

fix: doctor and keychain warning follow-ups from the #17 review #18

Closed

Description

@parsilver

Acceptance criteria

  • doctor (through store.apps()) prints "could not be read (invalid JSON)" for a corrupt credentials.json, not the parser's own text, which can quote part of a credential. A test with a corrupt file holding a fake secret runs expectNoSecrets.
  • When secret-tool (or security) can't be started, the keychain warning says "could not run", not "exited timeout".
  • The start warning test uses a fake keychain whose refusal reason contains the secret, so expectNoSecrets proves redaction happens before printing.
  • The doctor FAIL test calls expectNoSecrets.
  • Writes and chmods of the credential file and service.log refuse to follow a symlink (O_NOFOLLOW or an lstat check).
  • CI is green on all three OSes.

Activity

  1. parsilver commented on Nov 15, 2026

    @parsilver
    ContributorAuthor

    Work has started.

  2. parsilver commented on Nov 15, 2026

    @parsilver
    ContributorAuthor

    Plan:

    • Corrupt credentials.json: Store.read turns a SyntaxError into " could not be read (invalid JSON)" and drops the parser's text, which quotes part of the file. Other read errors (permissions) keep the system message, which never holds file contents. Test: pair, overwrite credentials.json with broken JSON that holds the issued credential, run doctor, expect the new line, exit 1, and expectNoSecrets.
    • "could not run" vs "exited timeout": Ran gains the spawn error code, and one function in run.ts says how a program ended: "exited N", "timed out", "could not run" (spawn failed, e.g. ENOENT) or "was stopped" (killed by a signal). The macOS and Secret Service keychains use it for both refusals and the "did not answer" reason; the service manager's failure text uses it too, the same ?? "timeout" pattern. Tests: a fake runner that returns status null with ENOENT, and one with ETIMEDOUT, for both keychains.
    • start warning test: a fake keychain whose refusal reason contains the device credential; the warning still prints and expectNoSecrets passes, which proves the stderr log redacts it.
    • Doctor FAIL test: the locked-keychain doctor test calls expectNoSecrets.
    • No following symlinks: one helper writes a file 0600 with O_NOFOLLOW (plus an lstat check, since Windows has no O_NOFOLLOW) and sets the mode with fchmod on that descriptor; another sets an existing file to 0600 the same way. Store.write (credentials.json and the other state files go through its temp file) and trimServiceLog use them; so do the launchd install, which takes back an existing service.log, and the service file write. A symlink there makes the call fail with a message naming the file, and the link's target is left untouched. Tests: a symlink at the store's temp file and at service.log (over the trim size) pointing at a file outside the home; the call fails and the target's bytes and mode are unchanged. Same for launchd install with a symlinked service.log.

    Invariants: no secret in any output; credential and log files stay 0600; the rename-into-place write stays atomic; the service log is still cut in place, not renamed.

    CI note: the CI matrix runs Ubuntu and macOS; Windows is covered by the release build only. I will check that the code paths stay valid on Windows (no O_NOFOLLOW there) but cannot run it.

  3. parsilver commented on Nov 15, 2026

    @parsilver
    ContributorAuthor

    In progress on draft PR #19 (branch fix/18-doctor-keychain-warning-follow). Tests went red first for the expected reasons; the fix is pushed. Taken from the plan review: Ran also carries the signal so a timeout still reads "timed out", temp files are removed and created exclusively (a stale link cannot block or redirect a write), the service log is cut on one descriptor, and the task-log temp file goes through the same helper. Next: full suite, quality gates, then ready for review.

  4. parsilver commented on Nov 16, 2026

    @parsilver
    ContributorAuthor

    In review: PR #19 is ready. Done: corrupt credentials.json reads as invalid JSON without quoting it; a keychain or service tool that cannot start says could not run; both redaction tests call expectNoSecrets; private files are never written or chmodded through a symlink. CI is green on Ubuntu and macOS. Waiting on: review. Open point: the criterion asks for three OSes, but CI has no Windows job.

    Notes: claude-code.test.ts > kills the whole process group is flaky on macOS: it parses its record file as soon as the file exists, which can be mid-write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions