Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930import { resolveReadableSystemPath } from './path-security';
const FILE_READING_COMMANDS = new Set(['cat', 'ls']);
function statusError(message: string, statusCode: number): Error & { statusCode: number } { return Object.assign(new Error(message), { statusCode });}
// Legacy `cat`/`ls` args must pass the same path gate as /system/fs/read.export async function validateLegacyExecRequest(command: string, args: string[]): Promise<void> { if (!FILE_READING_COMMANDS.has(command)) { return; }
const pathArgs = args.filter((arg) => !arg.startsWith('-')); if (command === 'cat' && pathArgs.length === 0) { throw statusError('cat requires at least one file path', 400); }
await Promise.all(pathArgs.map(async (requestedPath) => { const resolved = await resolveReadableSystemPath(requestedPath); if (command === 'ls') { return; } if (!resolved) { throw statusError('Failed to validate file path', 400); } }));}