Skip to main content

Function: assertWritableWithin()

assertWritableWithin(root, dest, what?): Promise<void>

Checks that a write to dest lands inside root. The directory dest is written into is resolved by its real path at the time of the call, following every symlink, also one that does not lead anywhere yet; dest itself is not resolved, because what is there is replaced, not followed (see prepareFixedNameWrite). root itself is trusted: it is resolved, wherever it points.

Only the build configuration is trusted. A symlink among copied files (the app directory, extraResources/extraFiles sources, node_modules) can make a lexically correct destination land elsewhere on the build machine, which this refuses.

Parameters​

root​

string

dest​

string

what?​

string = "file"

Returns​

Promise<void>

Throws​

InvalidConfigurationError with code ERR_PATH_OUTSIDE_ROOT