mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: add getOwnPropertyDescriptor to sandbox proxies for enhanced property handling
This commit is contained in:
@@ -123,6 +123,27 @@ function createSandboxProxy(
|
||||
);
|
||||
});
|
||||
},
|
||||
getOwnPropertyDescriptor(
|
||||
fnTarget: (...args: unknown[]) => unknown,
|
||||
prop: string | symbol,
|
||||
): PropertyDescriptor | undefined {
|
||||
if (
|
||||
typeof prop === "string" &&
|
||||
BLOCKED_SANDBOX_PROPERTIES.has(prop)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
const desc: PropertyDescriptor | undefined =
|
||||
Reflect.getOwnPropertyDescriptor(fnTarget, prop);
|
||||
if (desc && "value" in desc) {
|
||||
desc.value = createSandboxProxy(
|
||||
desc.value,
|
||||
cache,
|
||||
fnTarget as GenericObject,
|
||||
);
|
||||
}
|
||||
return desc;
|
||||
},
|
||||
},
|
||||
);
|
||||
return fnProxy;
|
||||
@@ -165,6 +186,20 @@ function createSandboxProxy(
|
||||
return !(typeof k === "string" && BLOCKED_SANDBOX_PROPERTIES.has(k));
|
||||
});
|
||||
},
|
||||
getOwnPropertyDescriptor(
|
||||
objTarget: GenericObject,
|
||||
prop: string | symbol,
|
||||
): PropertyDescriptor | undefined {
|
||||
if (typeof prop === "string" && BLOCKED_SANDBOX_PROPERTIES.has(prop)) {
|
||||
return undefined;
|
||||
}
|
||||
const desc: PropertyDescriptor | undefined =
|
||||
Reflect.getOwnPropertyDescriptor(objTarget, prop);
|
||||
if (desc && "value" in desc) {
|
||||
desc.value = createSandboxProxy(desc.value, cache, objTarget);
|
||||
}
|
||||
return desc;
|
||||
},
|
||||
});
|
||||
|
||||
cache.set(target, objProxy);
|
||||
|
||||
Reference in New Issue
Block a user