Closed Mahmoud-Abousereaa closed 1 year ago
Hi @XmiliaH ,
I am encountering an issue trying to set a property on one of the built-in modules.
Here is an example of the code
const {NodeVM} = require('vm2'); const vm = new NodeVM({ require: { external: true, builtin: ['url'], context: 'sandbox', }, strict: true, }); vm.run(` const URL = require('url').URL; const url = new URL('someurl'); url.pathname = url.pathname + '/test'; `);
The above code throws the following error
From what I understand the URL class is not extending any proxied class, therefore, I was expecting that it should be possible to modify its properties.
I am running node v14.19.3
This is the expected behavior. The builtin modules are loaded in the host and are read-only in the sandbox and instances created with it too.
Hi @XmiliaH ,
I am encountering an issue trying to set a property on one of the built-in modules.
Here is an example of the code
The above code throws the following error
set' on proxy: trap returned falsish for property 'pathname
From what I understand the URL class is not extending any proxied class, therefore, I was expecting that it should be possible to modify its properties.
I am running node v14.19.3