@exortek/express-mongo-sanitize 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -4
  2. package/src/index.js +11 -2
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@exortek/express-mongo-sanitize",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Express middleware for NoSQL injection prevention — sanitizes request data",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
7
7
  "types": "types/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "import": "./src/index.js",
10
11
  "require": "./src/index.js",
11
12
  "types": "./types/index.d.ts"
12
13
  }
@@ -20,7 +21,7 @@
20
21
  "url": "git+https://github.com/ExorTek/nosql-sanitize.git",
21
22
  "directory": "packages/express"
22
23
  },
23
- "homepage": "https://github.com/ExorTek/nosql-sanitize/tree/main/packages/express#readme",
24
+ "homepage": "https://github.com/ExorTek/nosql-sanitize/tree/master/packages/express#readme",
24
25
  "bugs": {
25
26
  "url": "https://github.com/ExorTek/nosql-sanitize/issues"
26
27
  },
@@ -55,8 +56,8 @@
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/express": "^5.0.6",
58
- "express": "npm:express@5.1.0",
59
- "express4": "npm:express@4.21.2"
59
+ "express": "npm:express@5.2.1",
60
+ "express4": "npm:express@4.22.1"
60
61
  },
61
62
  "files": [
62
63
  "src/",
package/src/index.js CHANGED
@@ -5,10 +5,8 @@ const {
5
5
  handleRequest,
6
6
  shouldSkipRoute,
7
7
  sanitizeString,
8
- cleanUrl,
9
8
  log,
10
9
  isString,
11
- NoSQLSanitizeError,
12
10
  } = require('@exortek/nosql-sanitize-core');
13
11
 
14
12
  /**
@@ -19,6 +17,11 @@ const {
19
17
  const expressMongoSanitize = (options = {}) => {
20
18
  const opts = resolveOptions(options);
21
19
 
20
+ log(opts.debug, 'info', 'PLUGIN', 'Initializing nosql-sanitize plugin', {
21
+ mode: opts.mode,
22
+ sanitizeObjects: [...opts.sanitizeObjects] || opts.sanitizeObjects,
23
+ });
24
+
22
25
  return (req, res, next) => {
23
26
  const requestPath = req.path || req.url;
24
27
 
@@ -37,6 +40,7 @@ const expressMongoSanitize = (options = {}) => {
37
40
  };
38
41
  }
39
42
 
43
+ log(opts.debug, 'info', 'PLUGIN', 'Plugin initialized');
40
44
  next();
41
45
  };
42
46
  };
@@ -48,12 +52,17 @@ const expressMongoSanitize = (options = {}) => {
48
52
  */
49
53
  const paramSanitizeHandler = (options = {}) => {
50
54
  const opts = resolveOptions(options);
55
+ log(opts.debug, 'info', 'PLUGIN', 'Initializing nosql-sanitize param handler', {
56
+ mode: opts.mode,
57
+ sanitizeObjects: [...opts.sanitizeObjects] || opts.sanitizeObjects,
58
+ });
51
59
 
52
60
  return function (req, res, next, value, paramName) {
53
61
  const key = paramName || this?.name;
54
62
  if (key && req.params && isString(value)) {
55
63
  req.params[key] = sanitizeString(value, opts, true);
56
64
  }
65
+ log(opts.debug, 'info', 'PLUGIN', 'Param sanitized', { key, value });
57
66
  next();
58
67
  };
59
68
  };