You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sandbox inheritied properties flattened after vm.runInNewContext #5350
on node-4.5.1 when using a sandbox Object with inherited properties, after running sandbox in vm.runInNewContext all properties up the prototype chain are copied to sandbox Object, even if they are not changed by code, though the prototype chain is still there. here is a failing test case
'use strict';letvm=require('vm'),assert=require('assert');letbase=Object.create(null);base.x=1;base.y=2;letsandbox=Object.create(base);sandbox.z=3;console.log('base:\n%j',base);console.log('sandbox:\n%j',sandbox);console.log("sandbox's own keys:\n%j",Object.keys(sandbox));letcode='x = 0; z = 4;';letresult=vm.runInNewContext(code,sandbox);console.log('result: %s',result);console.log('base:\n%j',base);console.log('sandbox:\n%j',sandbox);console.log("sandbox's own keys:\n%j",Object.keys(sandbox));assert((Object.keys(sandbox)).indexOf('y')===-1);// fails
note that the same problem occurs even if code is empty, as well as with vm.runInContext.
not sure if this is expected behavior or not, but i was surprised to have sandbox modified like that. if it is normal, i did not find any mention of it in the docs, and would ask if someone could kindly explain why?
@waynedpj do you see the same behaviour with the last stable version of nodejs ?
I also see some strange behaviours with the sandbox object properties on node 5.7 (but not exactly the same problem as your), but i'm still investigating before opening an issue.
@abenhamdine yes, i still see the same issue w/ 5.7. i have been investigating this further, and though i am not totally following what is going on yet, i suspect that this flattening of sandbox's prototype chain might be happening here in CopyProperties. but i am not familiar enough yet w/ Node.js's C++ code yet ;)
does your issue involve the sandbox being modified unexpectedly?
please let us know if you find anything and thanks.
Activity
abenhamdine commentedon Feb 29, 2016
@waynedpj do you see the same behaviour with the last stable version of nodejs ?
I also see some strange behaviours with the sandbox object properties on node 5.7 (but not exactly the same problem as your), but i'm still investigating before opening an issue.
waynedpj commentedon Feb 29, 2016
@abenhamdine yes, i still see the same issue w/ 5.7. i have been investigating this further, and though i am not totally following what is going on yet, i suspect that this flattening of sandbox's prototype chain might be happening here in
CopyProperties. but i am not familiar enough yet w/ Node.js's C++ code yet ;)does your issue involve the sandbox being modified unexpectedly?
please let us know if you find anything and thanks.
waynedpj commentedon Feb 29, 2016
PS. @abenhamdine which strange behaviors are you seeing?
abenhamdine commentedon Feb 29, 2016
I just opened an issue : #5491
jasnell commentedon Apr 19, 2016
Pretty certain this is the same issue as #2734
jasnell commentedon Apr 19, 2016
@nodejs/v8 ... can anyone on the v8 site assist with this one?
jeisinger commentedon Apr 19, 2016
I'll sync with Domenic and Ali to understand the exact requirements here.
16 remaining items
fhinkel commentedon Oct 23, 2017
This got fixed in #16293.
waynedpj commentedon Oct 23, 2017
thanks!
test: fix test for inherited properties on vm
test: fix test for inherited properties on vm
test: fix test for inherited properties on vm
test: fix test for inherited properties on vm
test: fix test for inherited properties on vm