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

@cjtecho/cjshield

v0.2.1

Published

Policy-driven request security for Node.js: XSS, HTML sanitization, SQL injection, command injection and path traversal detection with Express and Fastify integrations.

Readme

@cjtecho/cjshield

Policy-driven request security for Node.js, with Express and Fastify integrations.

CJShield inspects incoming HTTP requests for XSS, SQL injection, command injection and path traversal, sanitizes the HTML fields you declare, and blocks or reports suspicious requests according to a JSON policy.

CJShield is an additional defensive layer. It does not replace parameterized queries, safe process APIs, output encoding or safe file-path handling, and it does not provide complete protection against any attack category.

Installation

npm install @cjtecho/cjshield

Requires Node.js 22.12 or later. Express (4.22+ or 5.2+) and Fastify (5.12.6+) are optional peer dependencies: install the framework you use.

Express

import express from 'express';
import { createShield, loadPreset } from '@cjtecho/cjshield';
import { cjshield } from '@cjtecho/cjshield/express';

const app = express();
const shield = createShield({ policy: loadPreset('default') });

app.use(express.json()); // body parsers first
app.use(cjshield({ shield })); // then CJShield, before your routes

app.post('/comments', (req, res) => {
  res.json({ saved: req.body });
});

Fastify

import Fastify from 'fastify';
import { createShield, loadPreset } from '@cjtecho/cjshield';
import { cjshield } from '@cjtecho/cjshield/fastify';

const app = Fastify();
const shield = createShield({ policy: loadPreset('default') });

app.addHook('preValidation', cjshield({ shield }));

app.post('/comments', async (request) => ({ saved: request.body }));

What happens to each request

| Result | What CJShield does | | --------------------------------- | ---------------------------------------------------------------------------------------------- | | Nothing suspicious | The request continues unchanged. | | Suspicious, policy says monitor | The request continues; the finding is reported to your onEvent callback. | | Suspicious, policy says block | CJShield responds 403 {"error":"Request blocked","requestId":"…"} and your route never runs. | | HTML field declared in the policy | The field is sanitized before your route sees it. |

Responses never contain the payload or detection details, and events never contain request values, passwords, tokens or session cookies.

To log what CJShield finds, pass a callback:

cjshield({ shield, onEvent: (event) => logger.info(event) });

Policies

Start from a preset:

| Preset | Use it for | | --------- | ------------------------------------------------------------------------------------------- | | monitor | Rollout: reports findings, never blocks. Start here to check for false positives. | | default | Blocks high-confidence command injection and path traversal; reports XSS and SQL injection. | | strict | Blocks high-confidence findings for every detector, and fails closed on internal errors. |

const shield = createShield({ policy: loadPreset('monitor') });

For your own policy (per-route rules, HTML fields, exceptions, limits), write a JSON file and load it with await loadPolicyFile('./cjshield.policy.json'). The format is described by the policy schema, which ships in the package as @cjtecho/cjshield/spec/policy.v1.schema.json. Rule IDs (for events and bypassRules exceptions) are listed in @cjtecho/cjshield/spec/rules.v1.json.

Security

Please report vulnerabilities privately, as described in SECURITY.md in the package.

Support

For support, queries, or feedback: Email: [email protected]

License

Proprietary. Free to install and use in your applications; copying, modifying, redistributing and reverse engineering are not permitted. See LICENSE in the package.