MCPcopy Create free account
hub / github.com/Kong/insomnia / blockMethods

Function blockMethods

packages/insomnia/src/scripting/require-interceptor.ts:28–37  ·  view source on GitHub ↗
(target: object, blocked: string[], label: string)

Source from the content-addressed store, hash-verified

26
27// wraps `target` with a Proxy restricting access to dangerious methods within the accepted modules.
28const blockMethods = (target: object, blocked: string[], label: string): object =>
29 new Proxy(target, {
30 get(t, prop) {
31 if (typeof prop === 'string' && blocked.includes(prop)) {
32 throw new Error(`${label}.${prop} is not available in sandbox scripts`);
33 }
34 const value = (t as any)[prop];
35 return typeof value === 'function' ? value.bind(t) : value;
36 },
37 });
38
39export const requireInterceptor = (moduleName: string): any => {
40 if (moduleName === 'timers') {

Callers 1

requireInterceptorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected