(filePath: string)
| 53 | } |
| 54 | |
| 55 | export async function readPrivateFile(filePath: string): Promise<Buffer> { |
| 56 | const info = await stat(filePath); |
| 57 | // Windows does not have Unix-style permission bits; libuv synthesises the |
| 58 | // mode from the read-only attribute, so a private writable file is reported |
| 59 | // as 0o666 and a read-only one as 0o444. The ACL-based security model is |
| 60 | // different, so this check only makes sense on POSIX systems. |
| 61 | if (process.platform !== 'win32' && (info.mode & 0o077) !== 0) { |
| 62 | throw new PrivateFileTooPermissiveError(filePath, info.mode & 0o777); |
| 63 | } |
| 64 | return readFile(filePath); |
| 65 | } |
no test coverage detected