-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot register ts-node
into sandboxed NodeVM
instance due to TypeError: 'set' on proxy: trap returned falsish
#443
Comments
ts-node
in sandbox modets-node
into sandboxed NodeVM
instance due to TypeError: 'set' on proxy: trap returned falsish
As a workaround I did something like the following (actual code differs, as I'm also working around some path issues). Important security note: I'm not using sandbox mode for security purposes. I'm just using it to make sure that transitive dependencies of the script that I'm executing in the VM are loaded with the same global context as the script that I'm executing, rather than the host's global context. const tsNodePath = resolveInUserScriptPath(); // function not included for brevity
const compiler = require(tsNodePath).create().compile;
// see #442 comments for implementation of NonStrictNodeVM
const vm = new NonStrictNodeVM({
allowAsync: true,
console: "inherit",
require: {
builtin: [ "*" ],
context: "sandbox",
external: true
},
sandbox: { /* globals go here */ },
compiler
}) |
This is likely caused by the ts-node module trying to write to properties from a builtin module which are exposed in the sandbox as read-only. |
Is there any way to allow some built-in properties to be settable? |
I have the same problem, is there any update? |
When I attempt to register
ts-node
into an instance ofNodeVM
withoptions.require.context = "sandbox"
, I observe the following error. I believe this is likely becausets-node
is trying to modify some global state that the sandbox has made read only?Note that I'm using the
NonStrictNodeVM
workaround from #442.The text was updated successfully, but these errors were encountered: