(...segments: string[])
| 67 | } |
| 68 | |
| 69 | function resolveDirectoryWithinAttachmentsRoot(...segments: string[]): string { |
| 70 | const attachmentsRoot = getCurrentAttachmentsDirectory() |
| 71 | const resolvedPath = path.resolve( |
| 72 | attachmentsRoot, |
| 73 | ...segments.map((segment) => validatePathSegment(segment, 'path segment')) |
| 74 | ) |
| 75 | |
| 76 | if (!isPathWithinRoot(resolvedPath, attachmentsRoot)) { |
| 77 | throw new Error('Resolved path escapes attachments root') |
| 78 | } |
| 79 | |
| 80 | return resolvedPath |
| 81 | } |
| 82 | |
| 83 | export async function saveAttachmentFile(options: { |
| 84 | fileId: string |
no test coverage detected