mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-08 06:26:45 +02:00
fix: address review informational issues + add regression tests
- Add cookie-import to CHAIN_WRITE set for chain command routing - Add path validation to snapshot -a -o output path - Fix package.json version to match 0.3.1 - Use crypto.randomUUID() for temp DB paths (unpredictable filenames) - Add regression tests for chain cookie-import and snapshot path validation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1523,4 +1523,38 @@ describe('Path traversal prevention', () => {
|
||||
expect(err.message).toContain('Path must be within');
|
||||
}
|
||||
});
|
||||
|
||||
test('snapshot -a -o rejects path outside safe dirs', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/basic.html'], bm);
|
||||
// First get a snapshot so refs exist
|
||||
await handleMetaCommand('snapshot', ['-i'], bm, () => {});
|
||||
try {
|
||||
await handleMetaCommand('snapshot', ['-a', '-o', '/etc/evil.png'], bm, () => {});
|
||||
expect(true).toBe(false);
|
||||
} catch (err: any) {
|
||||
expect(err.message).toContain('Path must be within');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Chain command: cookie-import in chain ──────────────────────
|
||||
|
||||
describe('Chain with cookie-import', () => {
|
||||
test('cookie-import works inside chain', async () => {
|
||||
await handleWriteCommand('goto', [baseUrl + '/basic.html'], bm);
|
||||
const tmpCookies = '/tmp/test-chain-cookies.json';
|
||||
fs.writeFileSync(tmpCookies, JSON.stringify([
|
||||
{ name: 'chain_test', value: 'chain_value', domain: 'localhost', path: '/' }
|
||||
]));
|
||||
try {
|
||||
const commands = JSON.stringify([
|
||||
['cookie-import', tmpCookies],
|
||||
]);
|
||||
const result = await handleMetaCommand('chain', [commands], bm, async () => {});
|
||||
expect(result).toContain('[cookie-import]');
|
||||
expect(result).toContain('Loaded 1 cookie');
|
||||
} finally {
|
||||
try { fs.unlinkSync(tmpCookies); } catch {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user