fix(codex-auth): restrict symlink fallback and harden copy path (#1365)

This commit is contained in:
Kai (Tam Nhu) Tran
2026-05-23 21:43:51 -04:00
committed by GitHub
parent 1065f68eae
commit 0bd2e577b2
2 changed files with 38 additions and 4 deletions
@@ -143,6 +143,19 @@ describe('ensureSharedConfigSymlink', () => {
expect(stderrChunks.join('')).toContain('symlink unavailable');
});
it('rethrows symlink errors that are not fallback-safe', () => {
fs.writeFileSync(sharedConfigPath, 'model = "gpt-5.5"\n', { mode: 0o600 });
const symlinkSpy = spyOn(fs, 'symlinkSync').mockImplementation(() => {
throw Object.assign(new Error('simulated race'), { code: 'EEXIST' });
});
try {
expect(() => ensureSharedConfigSymlink(profileDir, sharedConfigPath)).toThrow(/simulated race/);
} finally {
symlinkSpy.mockRestore();
}
});
it('preserves edited fallback copies on later repair attempts', () => {
fs.writeFileSync(sharedConfigPath, 'model = "gpt-5.5"\n', { mode: 0o600 });
const linkPath = path.join(profileDir, 'config.toml');