Graphorin API reference v0.1.0
Graphorin API reference / @graphorin/security / / ensureFileMode
Function: ensureFileMode()
ts
function ensureFileMode(
path,
mode,
opts?): Promise<void>;Defined in: packages/security/src/hardening/file-modes.ts:45
Ensure a file is at the supplied POSIX mode. The function:
- On Windows / non-POSIX hosts, calls
warn(...)and returns. - Else opens the file, runs
fchmodif the process started with--permission, otherwise plainchmod. - Verifies the mode via
lstatand throwsFileModeMismatchErrorif the post-condition fails.
Parameters
| Parameter | Type |
|---|---|
path | string |
mode | number |
opts? | { warn?: (message) => void; } |
opts.warn? | (message) => void |
Returns
Promise<void>