fix: harden residual route and restore checks

This commit is contained in:
jb
2026-09-19 10:01:23 -04:00
parent cb86497724
commit 01b8b4642b
7 changed files with 45 additions and 11 deletions
+2
View File
@@ -2,6 +2,7 @@ import { expect, test } from 'bun:test';
import {
parseRestoreMarkerPhase,
RESTORE_MARKER_CONFIRMATION,
SYNTHETIC_CHARACTER_ID_MIN,
validateRestoreMarkerTarget,
validateRestoreMarkerWrite,
} from '../src/lib/server/restore-marker';
@@ -16,6 +17,7 @@ test('restore marker rejects non-loopback targets before any backend call', () =
expect(() => validateRestoreMarkerTarget('https://production.example.test')).toThrow('loopback');
expect(() => validateRestoreMarkerTarget('http://192.0.2.10:3210')).toThrow('loopback');
expect(validateRestoreMarkerTarget('http://127.0.0.1:3210').hostname).toBe('127.0.0.1');
expect(SYNTHETIC_CHARACTER_ID_MIN).toBeGreaterThan(2_000_000_000);
});
test('restore marker requires explicit disposable confirmation for writes', () => {
+2
View File
@@ -26,6 +26,8 @@ test('Gitea workflow keeps source checks separate and holds unverified container
test('Authenticated route limits remain user-keyed after rollout gates', () => {
expect(chatRoute).toContain('chat:${current?.userId ?? event.getClientAddress()}');
expect(syncRoute).toContain('sync:${current?.userId ?? event.getClientAddress()}');
expect(chatRoute.indexOf('protectMutation')).toBeLessThan(chatRoute.indexOf('const current = await session(event)'));
expect(syncRoute.indexOf('protectMutation')).toBeLessThan(syncRoute.indexOf('const current = await session(event)'));
expect(chatRoute.indexOf("capabilityEnabled('assistant_dispatch'")).toBeLessThan(chatRoute.indexOf('const current = await session(event)'));
expect(syncRoute.indexOf("capabilityEnabled('asset_sync'")).toBeLessThan(syncRoute.indexOf('const current = await session(event)'));
expect(layoutRoute).toContain('assistant_dispatch');