moving
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user