npm.io
1.0.1 • Published 5 years ago

rsi-mongo-sanitize

Licence
MIT
Version
1.0.1
Deps
0
Size
4 kB
Vulns
0
Weekly
0

rsi-mongo-sanitize

Extends mongo-sanitize which sanitizes inputs against query selector injection attacks to allow RSI query parameters

import { sanitize } from "rsi-mongo-sanitize";

// The sanitize function will strip out any keys that start with '
var sanitize = require('rsi-mongo-sanitize');

var clean = sanitize.sanitize(req.params.username);

Users.findOne({ name: clean }, function(err, doc) {
  // ...
});

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

in the input, // except those which are special RSI query parameters // so you can pass it to MongoDB without worrying about malicious users overwriting // query selectors. const clean = sanitize(req.params.username); Users.findOne({ name: clean }, function(err, doc) { // ... });
__CODE_BLOCK_1__

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

Keywords