Skip to content

fix(cli): write config.json owner-only from config set - #266

Merged
V3RON merged 3 commits into
mainfrom
bug/252
Oct 2, 2026
Merged

V3RON merged 3 commits into
mainfrom
bug/252

Conversation

@V3RON

@V3RON V3RON commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Closes #252

simlock config set now writes config.json with mode 0600, set on the temp file at creation, as admin.token already is. The file can hold gateway.token. The atomic rename replaces the old file, so under a usual umask it came out 0644, and a hand-set chmod 600 was lost on the next write.

docs/CONFIGURATION.md now says the file is owner-only. The gateway.token comment in src/core/config.ts says the same.

Release note: a config.json written before this change keeps its mode until the next config set. Run chmod 600 ~/.simlock/config.json on one that holds a token.

  • Regression test: src/cli/index.test.ts, "writes the config.json holding gateway.token owner-only, whether it creates the file or replaces an owner-only one" (the triage test), now passing. It fails on its mode assertion with the mode removed.
  • Added "makes a config.json that others could read owner-only on the next config set". It fails on its mode assertion against a version that keeps an existing file's mode.
  • pnpm check green.

Review

Spec review: 1 finding, 0 fixed. Code review: 2 findings, 2 fixed. The code review was not re-run on the commit that fixed its findings.

Rejected:

  • The CONFIGURATION.md line telling users to chmod 600 ~/.simlock/config.json goes beyond the fix, and its path assumes the default home. Rejected: the triage asked the docs to say the file is owner-only, and a file from before the fix stays 0644, so the reader needs the step. The same page already names the file ~/.simlock/config.json.

Written by an agent.

@V3RON
V3RON merged commit e89992c into main Oct 2, 2026
14 checks passed
V3RON added a commit that referenced this pull request Oct 16, 2026
)

Closes #258

### Status
Ready for the gate. Both regression tests probed (fail at 0o644).

- [x] `tokens.json` is written owner-only (0o600) —
`src/http/token-store.ts:147`, pinned by `src/http/token-store.test.ts`
- [x] `state.json` is written owner-only (0o600) —
`src/core/registry.ts:950`, pinned by `src/core/registry.test.ts`
- [x] The false comments are corrected — `src/gateway/drain-store.ts:16`
is scoped to the files it lists (`daemon.log`, `events.jsonl`,
`instance.json` stay 0644); `src/daemon/admin-secret.ts:3-5` needed no
change: its claim is true once both files are 0600

Existing 0644 files are re-tightened on their next write, as
`config.json` was after #266; no migration.

## Assumptions
none

## Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 0 blocking, 0
fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 1 note.
Rounds: 1. Tokens: 0.3M.

*Written by an agent.*
@V3RON
V3RON deleted the bug/252 branch November 6, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simlock config set writes config.json with the default file mode, so gateway.token in it is readable by other local users

1 participant