npm.io
1.1.0 • Published 6 years ago

mongo-sanitize

Licence
MIT
Version
1.1.0
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
142

mongo-sanitize

For the passionately lazy, a standalone module that sanitizes inputs against query selector injection attacks:

var sanitize = require('mongo-sanitize');

// The sanitize function will strip out any keys that start with '

If sanitize() is passed an object, it will mutate the original object.

in the input, // so you can pass it to MongoDB without worrying about malicious users overwriting // query selectors. var clean = sanitize(req.params.username); Users.findOne({ name: clean }, function(err, doc) { // ... });

If __INLINE_CODE_0__ is passed an object, it will mutate the original object.

Keywords