@aikidosec/firewall
Version:
Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.
31 lines (30 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-console */
const mod = require("node:module");
const shouldEnableFirewall_1 = require("../helpers/shouldEnableFirewall");
const isFirewallSupported_1 = require("../helpers/isFirewallSupported");
const protect_1 = require("../agent/protect");
const isNewHookSystemUsed_1 = require("../agent/isNewHookSystemUsed");
const indexImportGuard_1 = require("../helpers/indexImportGuard");
const node_worker_threads_1 = require("node:worker_threads");
(0, isNewHookSystemUsed_1.setIsNewHookSystemUsed)(true);
const isSupported = (0, isFirewallSupported_1.default)();
const shouldEnable = (0, shouldEnableFirewall_1.default)();
const notAlreadyImported = (0, indexImportGuard_1.checkIndexImportGuard)();
function start() {
if (!isSupported || !shouldEnable || !notAlreadyImported) {
return;
}
if (!("registerHooks" in mod) || typeof mod.registerHooks !== "function") {
console.error("AIKIDO: Error: Zen requires that your Node.js version supports the `module.registerHooks` API. Please upgrade to a newer version of Node.js.");
return;
}
if (!node_worker_threads_1.isMainThread) {
console.warn("AIKIDO: Zen does not instrument worker threads. Zen will only be active in the main thread.");
return;
}
console.warn("AIKIDO: The new instrumentation system with ESM support is still under active development and not suitable for production use.");
(0, protect_1.protectWithNewInstrumentation)();
}
start();