-
-
Couldn't load subscription status.
- Fork 33.6k
Closed
Labels
v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.
Description
- Version: master
- Platform: all
- Subsystem: vm
Very similar to #17480, except the issue now is with Object.getOwnPropertyDescriptor rather than in operator.
const globals = {};
const handlers = {};
const realHandlers = Reflect.ownKeys(Reflect).reduce((handlers, p) => {
handlers[p] = (t, ...args) => {
// Avoid printing the Receiver argument, which can lead to an infinite loop.
console.log(p, ...(p === 'get' || p === 'set' ? args.slice(0, -1) : args));
return Reflect[p](t, ...args);
};
return handlers;
}, {});
const proxy = vm.createContext(new Proxy(globals, handlers));
// Indirection needed to mitigate against #17465
// https://github.com/nodejs/node/issues/17465
const globalProxy = vm.runInContext('this', proxy);
for (const k of Reflect.ownKeys(globalProxy)) {
Object.defineProperty(globals, k, Object.getOwnPropertyDescriptor(globalProxy, k));
}
Object.assign(handlers, realHandlers);
Object.getOwnPropertyDescriptor(proxy, "a")
// prints "getOwnPropertyDescriptor a"
// returns undefined
vm.runInContext('Object.getOwnPropertyDescriptor(this, "a")', proxy);
// prints "get Object"
// prints "getOwnPropertyDescriptor a"
// prints "get a"
// prints "get a"
// returns { value: undefined,
// writable: true,
// enumerable: false,
// configurable: true } (because of https://github.com/nodejs/node/issues/17465)Metadata
Metadata
Assignees
Labels
v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.vmIssues and PRs related to the vm subsystem.Issues and PRs related to the vm subsystem.