UNPKG

@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.

34 lines (33 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = shouldEnableFirewall; const envToBool_1 = require("./envToBool"); const isAikidoCI_1 = require("./isAikidoCI"); const isDebugging_1 = require("./isDebugging"); const shouldBlock_1 = require("./shouldBlock"); /** * Only enable firewall if at least one of the following environment variables is set to a valid value: * - AIKIDO_BLOCKING * - AIKIDO_BLOCK * - AIKIDO_TOKEN * - AIKIDO_DEBUG */ function shouldEnableFirewall() { if ((0, envToBool_1.envToBool)(process.env.AIKIDO_DISABLE)) { return false; } if ((0, shouldBlock_1.shouldBlock)()) { return true; } if (process.env.AIKIDO_TOKEN) { return true; } if ((0, isDebugging_1.isDebugging)()) { return true; } if (!(0, isAikidoCI_1.isAikidoCI)()) { // eslint-disable-next-line no-console console.log("AIKIDO: Zen is disabled. Configure one of the following environment variables to enable it: AIKIDO_BLOCK, AIKIDO_TOKEN, AIKIDO_DEBUG."); } return false; }