npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

logsguardian

v0.1.0

Published

Middleware RASP de deteccion de amenazas (SQLi, XSS, Path Traversal, Command Injection) para Node.js/Express, con inferencia ONNX (Random Forest + Isolation Forest)

Readme

logsguardian

RASP middleware for Node.js/Express — detects SQL Injection, XSS, Path Traversal, and Command Injection in real time.

logsguardian inspects every incoming HTTP request against a hybrid ML model (Random Forest + Isolation Forest, running as ONNX in dedicated worker_threads) and blocks the ones it recognizes as attacks, without adding a separate WAF or IDS to your stack.

Models are trained offline and shipped fixed with each release — this package does not learn or retrain itself from your traffic after installation.


Install

npm install logsguardian

Requires Node.js ≥ 20 and Express 4 or 5 (peer dependency).

Quick start

npx logsguardian config init

This writes logsguardian.config.js in the current directory. Then mount the middleware after your body parsers (express.urlencoded/express.json, and any multer instance if your app accepts file uploads):

const express = require('express');
const { logsguardian } = require('logsguardian');
const config = require('./logsguardian.config.js');

const app = express();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(logsguardian(config));

That's it — every request past this point is inspected. Attacks get an HTTP 403; everything else is forwarded unchanged.

Configuration

// logsguardian.config.js
module.exports = {
  mode: 'block',       // 'block' (HTTP 403 on detected attacks) or 'monitor' (log only, never blocks)
  threshold: 0.35,      // RF confidence (0–1) above which a request is blocked. Lower = more attacks
                         // caught, more false positives. Higher = fewer false positives, more misses.
  model: 'hybrid',       // 'rf' (blocking only), 'if' (anomaly logging only), or 'hybrid' (both)
  timeoutMs: 50,          // fail-open timeout — if inference doesn't finish in time, the request passes
  dbPath: './logsguardian.db', // SQLite event log + webhook registry
};

Start in mode: 'monitor' if you want to see what logsguardian would have blocked before turning on enforcement.

Full option reference (including webhookUrl, event schema, decision policy): docs/api.md in the monorepo.

CLI

logsguardian --help

| Group | Commands | |---|---| | config | init, show, set <key> <value>, validate | | attacks | list, summary, inspect <type> — query the detection log | | endpoints | top, profile <route>, report — attack activity by route | | webhooks | add <url>, remove <id>, list, test <id> — manage notification destinations at runtime, no restart needed |

Full reference: docs/commands.md in the monorepo.

What it detects

SQL Injection, Cross-Site Scripting (XSS), Path Traversal / Local File Inclusion, and Command Injection — classified by a Random Forest trained on a labeled corpus of ~380,000 HTTP requests, cross-checked against OWASP Top 10 2021 and MITRE ATT&CK. A secondary Isolation Forest flags statistically anomalous requests for logging (never blocking) even when they don't match a known signature.

Known limitations

  • No online learning — detection quality depends on the model version you install, not on how long it has run.
  • Latency overhead does not yet clear this project's own ≤10% relative-latency target in every measured environment, though absolute overhead is small (low single-digit milliseconds in most configurations). See docs/results.md in the monorepo.
  • Designed to run alongside a WAF, not replace one. In a defense-in-depth evaluation against ModSecurity + OWASP CRS, logsguardian independently caught most of what a well-configured WAF missed — but neither layer alone is complete.
  • Only the four attack classes above are covered — no DDoS, BOLA, or authentication-vector detection.
  • pass_anomaly events (from the Isolation Forest) currently fire more often on ordinary benign traffic than their offline-calibrated rate suggests — treat that signal as noisy, not precise, until this is recalibrated.

Source

This package is part of the logSguarDian monorepo, built as a thesis project at Universidad del Valle de Guatemala. Issues and source: see the monorepo's packages/core.