UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks

28 lines (27 loc) 960 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.applyHooks = applyHooks; const wrapRequire_1 = require("./hooks/wrapRequire"); const wrapExport_1 = require("./hooks/wrapExport"); /** * Hooks allows you to register packages and then wrap specific methods on * the exports of the package. This doesn't do the actual wrapping yet. * * This method wraps the require function and sets up the hooks. * Globals are wrapped directly. */ function applyHooks(hooks) { (0, wrapRequire_1.setPackagesToPatch)(hooks.getPackages()); (0, wrapRequire_1.setBuiltinModulesToPatch)(hooks.getBuiltInModules()); (0, wrapRequire_1.wrapRequire)(); hooks.getGlobals().forEach((g) => { const name = g.getName(); if (!global[name]) { return; } (0, wrapExport_1.wrapExport)(global, name, { name: name, type: "global", }, g.getInterceptors()); }); }