* Read a file as a Buffer within a worktree. * * SECURITY: Enforces symlink-escape check. If the file is a symlink * pointing outside the worktree, this will throw PathValidationError. * * @throws PathValidationError with code "SYMLINK_ESCAPE" if file escapes worktree
( worktreePath: string, filePath: string, )
| 303 | * @throws PathValidationError with code "SYMLINK_ESCAPE" if file escapes worktree |
| 304 | */ |
| 305 | async readFileBuffer( |
| 306 | worktreePath: string, |
| 307 | filePath: string, |
| 308 | ): Promise<Buffer> { |
| 309 | assertRegisteredWorktree(worktreePath); |
| 310 | const fullPath = resolvePathInWorktree(worktreePath, filePath); |
| 311 | |
| 312 | // Block reads through symlinks that escape the worktree |
| 313 | await assertRealpathInWorktree(worktreePath, fullPath); |
| 314 | |
| 315 | return readFile(fullPath); |
| 316 | }, |
| 317 | |
| 318 | /** |
| 319 | * Write content to a file within a worktree. |
nothing calls this directly
no test coverage detected