Skip to content

Commit 851cfed

Browse files
akosoclaude
andcommitted
feat(auth): chmod parent dir 0700 on every save (not just on create)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5671c1f commit 851cfed

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/auth/credentials-store.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe('credentials store', () => {
3939
expect(stats.mode & 0o777).toBe(0o600)
4040
})
4141

42+
test('saveCredentials chmods parent dir 0700', async () => {
43+
await saveCredentials(sampleCreds)
44+
const dirStats = await stat(join(tmpHome, 'mna'))
45+
expect(dirStats.mode & 0o777).toBe(0o700)
46+
})
47+
4248
test('saveCredentials then loadCredentials roundtrips', async () => {
4349
await saveCredentials(sampleCreds)
4450
const loaded = await loadCredentials()

‎src/auth/credentials-store.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function loadCredentials(): Promise<Credentials | null> {
3232
export async function saveCredentials(creds: Credentials): Promise<void> {
3333
const path = credentialsPath()
3434
await mkdir(dirname(path), { recursive: true, mode: 0o700 })
35+
await chmod(dirname(path), 0o700)
3536
await writeFile(path, `${JSON.stringify(creds, null, 2)}\n`, { mode: 0o600 })
3637
await chmod(path, 0o600)
3738
}

0 commit comments

Comments
 (0)