This commit is contained in:
Oleg Maslov
2026-09-02 10:14:22 +02:00
parent 0c3e2ead3b
commit b20b138fe4
771 changed files with 161561 additions and 9027 deletions

View File

@@ -10,8 +10,10 @@ import ExcelJS from 'exceljs';
import type { ToolDefinition } from './tools.js';
function resolveSafe(workspace: string, filePath: string): string {
const resolved = path.resolve(workspace, filePath);
if (!resolved.startsWith(path.resolve(workspace))) {
const root = path.resolve(workspace);
const resolved = path.resolve(root, filePath);
const relative = path.relative(root, resolved);
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
throw new Error(`Path resolves outside workspace: ${filePath}`);
}
return resolved;