···
···
const keys = Object.getOwnPropertyNames(target)
for (let i = 0; i < keys.length; i++) {
-
if (key !== 'prototype') {
Object.defineProperty(standin, key, {
get: safeKey(target, key)
···
// It _might_ be safe to expose the Function constructor like this... who knows
safeGlobal!.Function = SafeFunction;
// Lastly, we also disallow certain property accesses on the safe global
-
return (safeGlobal = mask(safeGlobal!));
···
···
const keys = Object.getOwnPropertyNames(target)
for (let i = 0; i < keys.length; i++) {
+
(typeof standin !== 'function' || (key !== 'arguments' && key !== 'caller'))
Object.defineProperty(standin, key, {
get: safeKey(target, key)
···
// It _might_ be safe to expose the Function constructor like this... who knows
safeGlobal!.Function = SafeFunction;
// Lastly, we also disallow certain property accesses on the safe global
+
// Wrap any given target with a Proxy preventing access to unscopables
+
if (typeof Proxy === 'function') {
+
// Wrap the target in a Proxy that disallows access to some keys
+
return (safeGlobal = new Proxy(safeGlobal!, {
+
// Return a value, if it's allowed to be returned and mask this value
+
const key = safeKey(target, _key);
+
return key !== undefined ? target[key] : undefined;
+
getOwnPropertyDescriptor: noop,
+
// NOTE: Some property accesses may leak through here without the Proxy
+
return (safeGlobal = mask(safeGlobal));