GeezerVison is showing github.com — vm: fix property descriptors of sandbox properties · nodejs/node@659dadd
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_contextify.cc +10-4Lines changed: 10 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ using v8::None; |
30 | 30 | using v8::Object; |
31 | 31 | using v8::ObjectTemplate; |
32 | 32 | using v8::Persistent; |
| 33 | +using v8::PropertyAttribute; |
33 | 34 | using v8::PropertyCallbackInfo; |
34 | 35 | using v8::Script; |
35 | 36 | using v8::ScriptCompiler; |
@@ -406,10 +407,15 @@ class ContextifyContext { |
406 | 407 | Local<Object> proxy_global = PersistentToLocal(isolate, |
407 | 408 | ctx->proxy_global_); |
408 | 409 |
|
409 | | - bool in_sandbox = sandbox->GetRealNamedProperty(property).IsEmpty(); |
410 | | - bool in_proxy_global = |
411 | | - proxy_global->GetRealNamedProperty(property).IsEmpty(); |
412 | | - if (!in_sandbox || !in_proxy_global) { |
| 410 | + if (sandbox->HasRealNamedProperty(property)) { |
| 411 | + PropertyAttribute propAttr = |
| 412 | + sandbox->GetRealNamedPropertyAttributes(property).FromJust(); |
| 413 | + args.GetReturnValue().Set(propAttr); |
| 414 | + } else if (proxy_global->HasRealNamedProperty(property)) { |
| 415 | + PropertyAttribute propAttr = |
| 416 | + proxy_global->GetRealNamedPropertyAttributes(property).FromJust(); |
| 417 | + args.GetReturnValue().Set(propAttr); |
| 418 | + } else { |
413 | 419 | args.GetReturnValue().Set(None); |
414 | 420 | } |
415 | 421 | } |
|
Collapse file
Copy file name to clipboard +25Lines changed: 25 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var common = require('../common'); |
| 4 | +var assert = require('assert'); |
| 5 | + |
| 6 | +var vm = require('vm'); |
| 7 | + |
| 8 | +var x = {}; |
| 9 | +Object.defineProperty(x, 'prop', { |
| 10 | + configurable: false, |
| 11 | + enumerable: false, |
| 12 | + writable: false, |
| 13 | + value: 'val' |
| 14 | +}); |
| 15 | +var o = vm.createContext(x); |
| 16 | + |
| 17 | +var code = 'Object.getOwnPropertyDescriptor(this, "prop")'; |
| 18 | +var res = vm.runInContext(code, o, 'test'); |
| 19 | + |
| 20 | +assert(res); |
| 21 | +assert.equal(typeof res, 'object'); |
| 22 | +assert.equal(res.value, 'val'); |
| 23 | +assert.equal(res.configurable, false, 'should not be configurable'); |
| 24 | +assert.equal(res.enumerable, false, 'should not be enumerable'); |
| 25 | +assert.equal(res.writable, false, 'should not be writable'); |