What is the problem this feature will solve?
The current FS API does not have limits on what paths are accessed. Most of the time we works with FS operations that are bounded to certain folders like the current package's root. However, a bad code or even a malicious user-input can lead to unintended operations or security risks.
What is the feature you are proposing to solve the problem?
Provide an API like Go's os.Root.
An example API would looks like this:
const root = process.cwd()
const fs = new fs.Root(root)
fs.readFileSync("../out/of/bound/path") // Error out of bound file operation
fs.readFileSync("./misdirectedlink") // Error -> symlinks are checked against root
fs.rmSync(path.join(root, "../bad_path"), {force: true, recursive: true}); // wipes unintended files should throw error
What alternatives have you considered?
There's currently a 3rd party package @openclaw/fs-safe. but I think it should have been built-in.
What is the problem this feature will solve?
The current FS API does not have limits on what paths are accessed. Most of the time we works with FS operations that are bounded to certain folders like the current package's root. However, a bad code or even a malicious user-input can lead to unintended operations or security risks.
What is the feature you are proposing to solve the problem?
Provide an API like Go's
os.Root.An example API would looks like this:
What alternatives have you considered?
There's currently a 3rd party package @openclaw/fs-safe. but I think it should have been built-in.