1.0.0 • Published 2 months ago

trapdog v1.0.0

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
2 months ago

Trapdog

Installation

npm install trapdog@latest

Setup / Usage

To integrate trapdog with your Express site, simply follow this straightforward example. Ensure that you initialize trapdog after parsing the request body.

!NOTE If you intend to utilise the trapdog analyzer, it's essential to utilise a file for your SQLite configuration rather than relying on :memory:.

const express = require('express');
const trapdog = require('trapdog');

const app = express();
const port = 3001;

// Parse the request body before using trapdog
app.use(express.urlencoded({ extended: true }));
app.use(express.json());

// Initialize trapdog middleware with your configurations
app.use(trapdog({
    // Your trapdog configurations here
}));

// Define your routes
app.get('/', (req, res) => {
  res.send('Hello, World!');
});

// Start the server
app.listen(port, () => {
  console.log(`Server is running at http://localhost:${port}`);
});

Configuration

!WARNING Misconfiguring Trapdog can create security vulnerabilities in your web application and potentially disrupt its functionality. It's essential to properly configure Trapdog to avoid these risks and maintain the integrity of your application.

{
    "block": boolean,         // Default: true
    "xss_confidence": number, // Default: 80
    "fingerprint": boolean,   // Default: true
    "verbose": boolean,       // Default: false
    "verbose:emoji": boolean, // Default: true
    "sqlite": string,         // Default: ":memory:"
    "hidden": boolean         // Default: false
}

List of Modules