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 🙏

© 2024 – Pkg Stats / Ryan Hefner

owasp-nodejs-security-pack

v1.0.3

Published

`owasp-nodejs-security-pack` is a Node.js library designed to provide robust, plug-and-play middleware for securing your Express applications. It offers various middleware utilities to enhance security, prevent vulnerabilities, and streamline the integrat

Downloads

176

Readme

owasp-nodejs-security-pack

owasp-nodejs-security-pack is a Node.js library designed to provide robust, plug-and-play middleware for securing your Express applications. It offers various middleware utilities to enhance security, prevent vulnerabilities, and streamline the integration of security best practices.


Installation

Install the package using npm:

npm install owasp-nodejs-security-pack

Features

  1. Signature Verification Middleware: Validates digital signatures to ensure message integrity.
  2. Brute Force Protection: Prevents excessive requests from a single client.
  3. Composable Middleware: Combine multiple middleware functions into a single one.
  4. Content-Type Validator: Restricts requests to specific content types.
  5. Hybrid Encryption: Encrypts data with RSA and AES hybrid approach.
  6. Output Escaping: Sanitizes responses to prevent XSS attacks.
  7. HTTP Parameter Pollution Prevention: Protects against parameter pollution attacks.
  8. Rate Limiting: Restricts the number of requests from an IP within a time window.

Usage

1. Signature Verification Middleware

Validates the signature of incoming requests using a public key.

import { verifySignatureMiddleware } from "owasp-nodejs-security-pack";

app.use(verifySignatureMiddleware);

2. Brute Force Protection

Prevents excessive requests from a single client by tracking request history.

import { createBruteForceMiddleware } from "owasp-nodejs-security-pack";

const bruteForceMiddleware = createBruteForceMiddleware({
  maxRequests: 100,
  windowMs: 15 * 60 * 1000, // 15 minutes
  blockDurationMs: 15 * 60 * 1000, // 15 minutes
  message: "Too many requests from this IP"
});

app.use(bruteForceMiddleware);

3. Composable Middleware

Combine multiple middleware functions into a single one.

import { composeMiddleware } from "owasp-nodejs-security-pack";

const combinedMiddleware = composeMiddleware(middleware1, middleware2, middleware3);
app.use(combinedMiddleware);

4. Content-Type Validator

Restricts requests to specific content types.

import { createContentTypeMiddleware } from "owasp-nodejs-security-pack";

const contentTypeMiddleware = createContentTypeMiddleware({
  allowedTypes: ["json", "form-data"],
  errorMessage: "Only JSON and Form Data are supported"
});

app.use(contentTypeMiddleware);

5. Hybrid Encryption

Encrypts data using RSA and AES for secure data transfer.

import { encryptDataHybrid } from "owasp-nodejs-security-pack";

const encryptedData = encryptDataHybrid({
  name: "Sensitive Data",
  description: "This is a secure message."
});
console.log(encryptedData);

6. Output Escaping

Sanitizes response data to prevent XSS attacks.

import { createOutputEscapingMiddleware } from "owasp-nodejs-security-pack";

const outputEscaping = createOutputEscapingMiddleware({
  escapeMode: "partial",
  customEscapeFields: ["name", "description"],
  excludeFields: ["id", "timestamp"]
});

app.use(outputEscaping);

7. HTTP Parameter Pollution Prevention

Prevents attacks using parameter pollution in query, body, or params.

import { createHPPMiddleware } from "owasp-nodejs-security-pack";

const hppMiddleware = createHPPMiddleware({
  whitelist: ["allowedParam"],
  blockedParams: ["criticalParam"],
  errorMessage: "Invalid request parameters"
});

app.use(hppMiddleware);

8. Rate Limiting

Restricts the number of requests from an IP within a specified time window.

import { rateLimiter } from "owasp-nodejs-security-pack";

app.use(rateLimiter);

Contributing

We welcome contributions! Please fork the repository and submit a pull request with your changes.


License

This project is licensed under the MIT License. See the LICENSE file for details.

Enjoy secure coding! 🚀

Author

Gunjan Sharma (Senior Software Engineer & Blockchain Enthusiast)