New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-sanitize-escape

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-sanitize-escape

Express middleware for the sanitizer module using Caja's HTML Sanitizer and HTML escape using htmlencode.

  • 0.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
265
decreased by-40.85%
Maintainers
1
Weekly downloads
 
Created
Source

express-sanitized

Build Status

Installation

npm install express-sanitize-middleware

Usage

Place this directly after all express.use(bodyParser) middlewares and before any express middleware that accesses query or body parameters, e.g.:

var bodyParser = require('body-parser');
var express = require('express');
var expressSanitized = require('express-sanitize-escape');

app.use(bodyParser.urlencoded);
app.use(bodyParser.json);
app.use(expressSanitized()); // this line follows app.use(bodyParser.json) or the last body parser middleware

Output

The string

'<script>document.write('cookie monster')</script> download now'

will be sanitized to ' download now'.

and

'< > ' " &'

will be escaped to &lt; &gt; &#39; &quot; &amp;

Limitations

This is a basic implementation of Caja-HTML-Sanitizer with the specific purpose of mitigating against persistent XSS risks. And node-htmlencode to escape all html entities

Caveats

This module trusts the dependencies to provide basic persistent XSS risk mitigation. A user of this package should review all packages and make their own decision on security and fitness for purpose.

This module was inspired by express-sanitizer and express-sanitized. The difference here is: This middleware automatically sanitizes post and query values parameter. And automatically html escapes all strings.

Changelog

v0.6.1

  • Added additional test for nested object and an array
  • Added chai js for testing

v0.6.0

  • Added htmlencoding
  • Change filer to recurse through all values of the object and sanitize only values that are strings
  • Updated docs to express 4.x and new bodyParser middleware
  • Added License file

v0.5.1

  • Initial release

Contributors

License

Copyright (c) 2016 Finger Food Studios justin@fingerfoodstudios.com, MIT License

Keywords

FAQs

Package last updated on 23 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc