Write the CLI server-connection store owner-only, and make its tests run - #1576
Open
GeiserX wants to merge 1 commit into
Open
Write the CLI server-connection store owner-only, and make its tests run#1576GeiserX wants to merge 1 commit into
GeiserX wants to merge 1 commit into
Conversation
server-connections.json holds a bearer token, or an OAuth access token and its long-lived refresh token, rewritten on every silent refresh. It was created with no mode, so the umask applied and it landed world-readable. Create it 0600 with a follow-up chmod, matching the local-server manifest in the same directory. Both steps matter: mode applies only on create, and the chmod covers rewriting an existing looser file -- the common path here. Separately, four tests in this file were it(..., () => Effect.gen(...)). An Effect is not thenable, so vitest passed them without running their bodies; a deliberately falsified assertion still passed. They are now it.effect.
This was referenced Aug 13, 2026
Author
|
Context for this one: #1585 explains why this PR and twelve others exist — they came out of a single pass over credential handling, asking for each credential where it ends up, how long it stays, and who can read it once it's there. This PR stands alone and doesn't depend on any of the others. |
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.
TL;DR
Two things, both in
apps/cli/src/server-profile.*.1.
~/.executor/server-connections.jsonwas world-readable. It holds a bearer token, or an OAuth access token and its long-lived refresh token, and it is rewritten on every silent refresh. No mode was set, so the umask applied and it landed0644. Now0600, matching what the local-server manifest already does for the sibling secret in the same directory.2. Four tests in that file never ran. They are
it("…", () => Effect.gen(…)). AnEffectis not a thenable, so Vitest saw a non-promise return, called the test passed, and never executed the body. I found this because my new assertions passed against code I had deliberately broken.The permissions change
Both steps are needed, and this is your own existing pattern —
local-server-manifest.tswrites the sibling secret exactly this way, with a comment explaining why.modeapplies only when the file is created, so it closes the window where a fresh store is briefly world-readable; thechmodcovers rewriting a store that already exists with looser permissions.That second case matters more here than it does for the manifest: this file is rewritten on every silent token refresh, so overwrite is the common path, and it is also the path that upgrades an existing user's
0644store left behind by an older version.The tests that were not running
This is the part worth a second look, because it is easy to reproduce:
Effecthas no.then, so this returns a value Vitest neither awaits nor runs. I verified it rather than assumed it: changing a pre-existing assertion toexpect(store.defaultProfile).toBe("THIS_IS_DELIBERATELY_WRONG")still reported 4 passed.Switched to
it.effect, they execute and pass — so no production behaviour was wrong, the tests simply were not checking it. Two other tests in the file are ordinary synchronous ones and are left asit.I swept the rest of the repo for the same shape and this is the only file affected. The two other candidates turned out to be a helper signature and a set of
await Effect.runPromise(…)tests, both fine.Tests
Two added, covering the two mechanisms separately: a fresh store is created
0600, and a pre-existing0644store is tightened on rewrite.Mutation-checked, each mutation verified to have landed, with an unmutated control before and after:
chmodmodeThe survivor is honest rather than a gap: with the
chmodstill running, the final mode is0600either way. Themodeargument closes the window between create and chmod, which no assertion about final filesystem state can observe. It is kept for the same reason the manifest keeps it.Package: 73 passed / 8 files.
tsgo --noEmit,oxlint --deny-warningsandoxfmt --checkclean.