@contrast/assess 1.27.2 → 1.28.1

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 (63) hide show
  1. package/lib/constants.js +3 -3
  2. package/lib/crypto-analysis/install/crypto.js +1 -1
  3. package/lib/dataflow/propagation/install/JSON/parse.js +2 -2
  4. package/lib/dataflow/propagation/install/JSON/stringify.js +10 -11
  5. package/lib/dataflow/propagation/install/array-prototype-join.js +10 -12
  6. package/lib/dataflow/propagation/install/buffer.js +3 -1
  7. package/lib/dataflow/propagation/install/contrast-methods/add.js +73 -72
  8. package/lib/dataflow/propagation/install/contrast-methods/number.js +4 -5
  9. package/lib/dataflow/propagation/install/contrast-methods/string.js +3 -2
  10. package/lib/dataflow/propagation/install/contrast-methods/tag.js +3 -6
  11. package/lib/dataflow/propagation/install/joi/boolean.js +2 -4
  12. package/lib/dataflow/propagation/install/joi/expression.js +2 -4
  13. package/lib/dataflow/propagation/install/joi/index.js +1 -1
  14. package/lib/dataflow/propagation/install/joi/number.js +2 -4
  15. package/lib/dataflow/propagation/install/joi/string-schema.js +8 -3
  16. package/lib/dataflow/propagation/install/joi/values.js +5 -1
  17. package/lib/dataflow/propagation/install/path/format.js +7 -4
  18. package/lib/dataflow/propagation/install/path/parse.js +4 -5
  19. package/lib/dataflow/propagation/install/querystring/escape.js +1 -1
  20. package/lib/dataflow/propagation/install/querystring/parse.js +6 -7
  21. package/lib/dataflow/propagation/install/querystring/stringify.js +1 -1
  22. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +2 -3
  23. package/lib/dataflow/propagation/install/string/concat.js +22 -23
  24. package/lib/dataflow/propagation/install/string/html-methods.js +6 -7
  25. package/lib/dataflow/propagation/install/string/index.js +3 -3
  26. package/lib/dataflow/propagation/install/string/match-all.js +10 -15
  27. package/lib/dataflow/propagation/install/string/match.js +5 -4
  28. package/lib/dataflow/propagation/install/string/replace.js +22 -16
  29. package/lib/dataflow/propagation/install/string/slice.js +7 -6
  30. package/lib/dataflow/propagation/install/string/split.js +17 -16
  31. package/lib/dataflow/propagation/install/string/substring.js +9 -8
  32. package/lib/dataflow/propagation/install/string/trim.js +4 -5
  33. package/lib/dataflow/propagation/install/url/parse.js +1 -1
  34. package/lib/dataflow/propagation/install/url/searchParams.js +2 -1
  35. package/lib/dataflow/propagation/install/url/url.js +1 -1
  36. package/lib/dataflow/sinks/install/child-process.js +1 -1
  37. package/lib/dataflow/sinks/install/express/reflected-xss.js +7 -5
  38. package/lib/dataflow/sinks/install/express/unvalidated-redirect.js +1 -2
  39. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -3
  40. package/lib/dataflow/sinks/install/fs.js +1 -1
  41. package/lib/dataflow/sinks/install/function.js +1 -1
  42. package/lib/dataflow/sinks/install/hapi/unvalidated-redirect.js +1 -2
  43. package/lib/dataflow/sinks/install/http/request.js +6 -5
  44. package/lib/dataflow/sinks/install/koa/unvalidated-redirect.js +2 -2
  45. package/lib/dataflow/sinks/install/libxmljs.js +1 -1
  46. package/lib/dataflow/sinks/install/marsdb.js +1 -2
  47. package/lib/dataflow/sinks/install/mongodb.js +46 -9
  48. package/lib/dataflow/sinks/install/mysql.js +1 -1
  49. package/lib/dataflow/sinks/install/postgres.js +1 -3
  50. package/lib/dataflow/sinks/install/sequelize.js +1 -2
  51. package/lib/dataflow/sinks/install/vm.js +1 -1
  52. package/lib/dataflow/sources/install/body-parser1.js +12 -5
  53. package/lib/dataflow/sources/install/cookie-parser1.js +4 -3
  54. package/lib/dataflow/sources/install/qs6.js +7 -5
  55. package/lib/dataflow/sources/install/querystring.js +8 -2
  56. package/lib/dataflow/tag-utils.js +22 -5
  57. package/lib/get-source-context.js +2 -1
  58. package/lib/index.js +13 -0
  59. package/lib/session-configuration/install/express-session.js +1 -3
  60. package/lib/session-configuration/install/fastify-cookie.js +1 -1
  61. package/lib/session-configuration/install/hapi.js +1 -3
  62. package/lib/session-configuration/install/koa.js +1 -1
  63. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -15,9 +15,12 @@
15
15
 
16
16
  'use strict';
17
17
 
18
+ const { inspect } = require('util');
18
19
  const { callChildComponentMethodsSync } = require('@contrast/common');
19
20
 
20
21
  module.exports = function assess(core) {
22
+ const { scopes: { instrumentation } } = core;
23
+
21
24
  const assess = core.assess = {
22
25
  install() {
23
26
  if (!core.config.getEffectiveValue('assess.enable')) {
@@ -30,6 +33,16 @@ module.exports = function assess(core) {
30
33
  },
31
34
  };
32
35
 
36
+ // todo: this is temporary fix for using inspect during creation of event
37
+ // data. once all uses of inspect are refactored out of remaining sinks and
38
+ // propagators etc, this can also be removed.
39
+ const store = { lock: true, name: 'assess.inspect' };
40
+ assess.inspect = function(val, opts) {
41
+ return instrumentation.isLocked() ?
42
+ inspect(val, opts) :
43
+ instrumentation.run(store, inspect, val, opts);
44
+ };
45
+
33
46
  require('./rule-scopes')(core);
34
47
  require('./get-policy')(core);
35
48
  require('./make-source-context')(core);
@@ -14,7 +14,6 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const util = require('util');
18
17
  const { toLowerCase } = require('@contrast/common');
19
18
  const { patchType } = require('../common');
20
19
 
@@ -27,6 +26,7 @@ const { patchType } = require('../common');
27
26
  module.exports = function (core) {
28
27
  const {
29
28
  assess: {
29
+ inspect, // todo: remove
30
30
  getSourceContext,
31
31
  eventFactory: { createSessionEvent },
32
32
  sessionConfiguration: {
@@ -40,8 +40,6 @@ module.exports = function (core) {
40
40
 
41
41
  const expressSession = core.assess.sessionConfiguration.expressSession = {};
42
42
 
43
- const inspect = patcher.unwrap(util.inspect);
44
-
45
43
  expressSession.install = function () {
46
44
  return depHooks.resolve({ name: 'express-session' }, (session) => {
47
45
  // Return the hooked function as the export.
@@ -14,7 +14,6 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const { inspect } = require('util');
18
17
  const { toLowerCase } = require('@contrast/common');
19
18
  const { patchType } = require('../common');
20
19
 
@@ -27,6 +26,7 @@ const { patchType } = require('../common');
27
26
  module.exports = function (core) {
28
27
  const {
29
28
  assess: {
29
+ inspect, // todo: remove
30
30
  getSourceContext,
31
31
  eventFactory: { createSessionEvent },
32
32
  sessionConfiguration: {
@@ -14,12 +14,12 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const util = require('util');
18
17
  const { patchType } = require('../common');
19
18
 
20
19
  module.exports = function (core) {
21
20
  const {
22
21
  assess: {
22
+ inspect, // todo: remove
23
23
  eventFactory: { createSessionEvent },
24
24
  sessionConfiguration: {
25
25
  handleHttpOnly,
@@ -33,8 +33,6 @@ module.exports = function (core) {
33
33
 
34
34
  const hapiSession = core.assess.sessionConfiguration.hapiSession = {};
35
35
 
36
- const inspect = patcher.unwrap(util.inspect);
37
-
38
36
  hapiSession.install = function () {
39
37
  return depHooks.resolve({ name: '@hapi/hapi', version: '>=18 <22' }, (hapi) => {
40
38
  ['server', 'Server'].forEach((server) => {
@@ -14,7 +14,6 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const { inspect } = require('util');
18
17
  const { patchType } = require('../common');
19
18
 
20
19
  /**
@@ -26,6 +25,7 @@ const { patchType } = require('../common');
26
25
  module.exports = function (core) {
27
26
  const {
28
27
  assess: {
28
+ inspect, // todo: remove
29
29
  getSourceContext,
30
30
  eventFactory: { createSessionEvent },
31
31
  sessionConfiguration: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/assess",
3
- "version": "1.27.2",
3
+ "version": "1.28.1",
4
4
  "description": "Contrast service providing framework-agnostic Assess support",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,7 +17,7 @@
17
17
  "test": "../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.20.1",
20
+ "@contrast/common": "1.21.0",
21
21
  "@contrast/distringuish": "^4.4.0",
22
22
  "@contrast/scopes": "1.4.1"
23
23
  }