Socket
Socket
Sign inDemoInstall

express-auto-sanitize

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-auto-sanitize

Express middleware that automatically sanitize user inputs


Version published
Weekly downloads
58
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

GitHub license Download

Installation

npm i --save express-auto-sanitize

Usage

Import the module with this declaration at the top of the file:

const sanitizer = require('express-auto-sanitize')

Mount the middleware

const options = {
    query: Boolean,
    body: Boolean,
    cookies: Boolean,
    original: Boolean, // will keep the original version in req.original
    sanitizerFunction: Function // use your personnal sanitizing algorithm
}
app.use(sanitizer(options))

Note: if you use the body option, make sure you mount the sanitizer between the body-parser/cookie-parser middleware and your routes declaration.

Output

After the middleware has processed the input, the original version will be stored in req.original and the safe version will replace the dangerous input.

app.get('/', (req, res) => {
    console.log(req.query.exampleParam) // safe and sanitized
    console.log(req.original.query.exampleParam) // potentially dangerous
})

License

express-auto-sanitize is MIT licensed.

Keywords

FAQs

Last updated on 27 May 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc