@aikidosec/firewall
Version:
Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks
21 lines (20 loc) • 955 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.startTestAgent = startTestAgent;
const wrapRequire_1 = require("../agent/hooks/wrapRequire");
const createTestAgent_1 = require("./createTestAgent");
/**
* Start a test agent for testing purposes
*/
function startTestAgent(opts) {
const agent = (0, createTestAgent_1.createTestAgent)(opts);
agent.start(opts.wrappers);
// In order to support multiple versions of the same package, we need to rewrite the package name
// e.g. In our sources and sinks, we use the real package name `hooks.addPackage("undici")`
// but in the tests we want to `require("undici-v6")` instead of `require("undici")`
// The `__internalRewritePackageName` function allows us to do this
Object.keys(opts.rewrite).forEach((packageName) => {
(0, wrapRequire_1.__internalRewritePackageName)(packageName, opts.rewrite[packageName]);
});
return agent;
}