@contrast/assess 1.52.0 → 1.54.0

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 (84) hide show
  1. package/lib/crypto-analysis/install/math.js +0 -1
  2. package/lib/dataflow/propagation/common.js +6 -6
  3. package/lib/dataflow/propagation/install/JSON/parse.js +7 -3
  4. package/lib/dataflow/propagation/install/JSON/stringify.js +7 -6
  5. package/lib/dataflow/propagation/install/array-prototype-join.js +5 -8
  6. package/lib/dataflow/propagation/install/buffer.js +4 -4
  7. package/lib/dataflow/propagation/install/contrast-methods/add.js +42 -38
  8. package/lib/dataflow/propagation/install/contrast-methods/string.js +4 -2
  9. package/lib/dataflow/propagation/install/contrast-methods/tag.js +3 -1
  10. package/lib/dataflow/propagation/install/decode-uri-component.js +5 -7
  11. package/lib/dataflow/propagation/install/ejs/escape-xml.js +4 -3
  12. package/lib/dataflow/propagation/install/ejs/template.js +1 -1
  13. package/lib/dataflow/propagation/install/encode-uri.js +5 -7
  14. package/lib/dataflow/propagation/install/escape-html.js +4 -3
  15. package/lib/dataflow/propagation/install/escape.js +5 -7
  16. package/lib/dataflow/propagation/install/handlebars-utils-escape-expression.js +4 -3
  17. package/lib/dataflow/propagation/install/joi/boolean.js +1 -3
  18. package/lib/dataflow/propagation/install/joi/expression.js +1 -3
  19. package/lib/dataflow/propagation/install/joi/number.js +1 -3
  20. package/lib/dataflow/propagation/install/joi/string-schema.js +2 -6
  21. package/lib/dataflow/propagation/install/joi/utils.js +2 -4
  22. package/lib/dataflow/propagation/install/joi/values.js +1 -3
  23. package/lib/dataflow/propagation/install/mongoose/schema-map.js +1 -3
  24. package/lib/dataflow/propagation/install/mongoose/schema-mixed.js +1 -3
  25. package/lib/dataflow/propagation/install/mongoose/schema-string.js +4 -5
  26. package/lib/dataflow/propagation/install/mustache-escape.js +4 -3
  27. package/lib/dataflow/propagation/install/mysql-connection-escape.js +9 -8
  28. package/lib/dataflow/propagation/install/path/basename.js +6 -7
  29. package/lib/dataflow/propagation/install/path/common.js +1 -0
  30. package/lib/dataflow/propagation/install/path/dirname.js +6 -8
  31. package/lib/dataflow/propagation/install/path/extname.js +8 -22
  32. package/lib/dataflow/propagation/install/path/format.js +6 -10
  33. package/lib/dataflow/propagation/install/path/join-and-resolve.js +7 -13
  34. package/lib/dataflow/propagation/install/path/normalize.js +8 -18
  35. package/lib/dataflow/propagation/install/path/parse.js +8 -18
  36. package/lib/dataflow/propagation/install/path/relative.js +8 -15
  37. package/lib/dataflow/propagation/install/path/toNamespacedPath.js +7 -18
  38. package/lib/dataflow/propagation/install/pug/index.js +1 -1
  39. package/lib/dataflow/propagation/install/pug-runtime-escape.js +6 -5
  40. package/lib/dataflow/propagation/install/querystring/escape.js +3 -1
  41. package/lib/dataflow/propagation/install/querystring/parse.js +3 -2
  42. package/lib/dataflow/propagation/install/querystring/stringify.js +4 -4
  43. package/lib/dataflow/propagation/install/reg-exp-prototype-exec.js +4 -3
  44. package/lib/dataflow/propagation/install/sequelize/query-generator.js +0 -1
  45. package/lib/dataflow/propagation/install/sequelize/sql-string.js +16 -17
  46. package/lib/dataflow/propagation/install/sql-template-strings.js +6 -10
  47. package/lib/dataflow/propagation/install/string/concat.js +4 -4
  48. package/lib/dataflow/propagation/install/string/format-methods.js +4 -4
  49. package/lib/dataflow/propagation/install/string/html-methods.js +5 -6
  50. package/lib/dataflow/propagation/install/string/index.js +4 -3
  51. package/lib/dataflow/propagation/install/string/match-all.js +7 -6
  52. package/lib/dataflow/propagation/install/string/match.js +10 -9
  53. package/lib/dataflow/propagation/install/string/replace.js +5 -6
  54. package/lib/dataflow/propagation/install/string/slice.js +4 -3
  55. package/lib/dataflow/propagation/install/string/split.js +11 -11
  56. package/lib/dataflow/propagation/install/string/substring.js +4 -3
  57. package/lib/dataflow/propagation/install/string/trim.js +4 -3
  58. package/lib/dataflow/propagation/install/unescape.js +6 -14
  59. package/lib/dataflow/propagation/install/url/domain-parsers.js +6 -5
  60. package/lib/dataflow/propagation/install/url/parse.js +17 -17
  61. package/lib/dataflow/propagation/install/url/searchParams.js +36 -25
  62. package/lib/dataflow/propagation/install/url/url.js +3 -2
  63. package/lib/dataflow/propagation/install/util-format.js +4 -3
  64. package/lib/dataflow/propagation/install/validator/hooks.js +0 -1
  65. package/lib/dataflow/sinks/install/eval.js +3 -1
  66. package/lib/dataflow/sinks/install/fastify/unvalidated-redirect.js +1 -1
  67. package/lib/dataflow/sinks/install/function.js +3 -4
  68. package/lib/dataflow/sinks/install/marsdb.js +3 -1
  69. package/lib/dataflow/sinks/install/mongodb.js +3 -1
  70. package/lib/dataflow/sinks/install/mssql.js +4 -3
  71. package/lib/dataflow/sinks/install/mysql.js +3 -1
  72. package/lib/dataflow/sinks/install/restify.js +3 -1
  73. package/lib/dataflow/sinks/install/sqlite3.js +4 -2
  74. package/lib/dataflow/sinks/install/vm.js +6 -4
  75. package/lib/dataflow/sources/handler.js +2 -3
  76. package/lib/dataflow/sources/install/fastify/fastify.js +5 -5
  77. package/lib/dataflow/tag-utils.js +15 -1
  78. package/lib/dataflow/tracker.js +0 -5
  79. package/lib/event-factory.js +1 -1
  80. package/lib/session-configuration/install/express-session.js +0 -1
  81. package/lib/session-configuration/install/fastify-cookie.js +0 -3
  82. package/lib/session-configuration/install/hapi.js +0 -1
  83. package/lib/session-configuration/install/koa.js +0 -3
  84. package/package.json +10 -10
@@ -31,19 +31,19 @@ module.exports = function (core) {
31
31
 
32
32
  const source = sources.fastifyInstrumentation.fastify = {
33
33
  install() {
34
- depHooks.resolve({ name: 'fastify', version: '>=3.2.0 <5' }, (fastify) => patcher.patch(fastify, {
34
+ depHooks.resolve({ name: 'fastify', version: '>=3.2.0 <6' }, (fastify) => patcher.patch(fastify, {
35
35
  name: 'fastify.constructor',
36
36
  patchType,
37
37
  post({ result: server, funcKey }) {
38
38
  server.addHook('preValidation', function preValidationHandler(request, reply, done) {
39
+ const sourceContext = getSourceContext();
40
+ if (!sourceContext) return done();
41
+
39
42
  const bodyType = request?.headers?.['content-type']?.includes('/json')
40
43
  ? InputType.JSON_VALUE
41
44
  : typeof request.body == 'object'
42
45
  ? InputType.PARAMETER_VALUE
43
46
  : InputType.BODY;
44
- const sourceContext = getSourceContext();
45
-
46
- if (!sourceContext) return;
47
47
 
48
48
  [
49
49
  { key: 'query', inputType: InputType.QUERYSTRING, alreadyTrackedFlag: 'parsedQuery' },
@@ -71,7 +71,7 @@ module.exports = function (core) {
71
71
  }
72
72
  });
73
73
 
74
- done();
74
+ return done();
75
75
  });
76
76
  },
77
77
  }));
@@ -14,7 +14,7 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- const { empties, primordials: { StringPrototypeSplit } } = require('@contrast/common');
17
+ const { empties, primordials: { StringPrototypeSplit, StringPrototypeSubstr } } = require('@contrast/common');
18
18
 
19
19
  //
20
20
  // This module implements tag range manipulation functions. There are generally
@@ -536,6 +536,19 @@ function getAdjustedUntrackedValue(origValue) {
536
536
  return origValue?.constructor?.name ?? (origValue === null ? 'null' : typeof origValue);
537
537
  }
538
538
 
539
+ /**
540
+ * Truncation spec: https://github.com/Contrast-Security-Inc/assess-specifications/blob/master/vulnerability/truncate-event-snapshots.md
541
+ * While the spec calls to truncate the middle of strings, we're going to just chop off the end.
542
+ * This way we don't have to recalculate all of the tag ranges to adjust for truncating.
543
+ * @param {string} str input string to be truncated
544
+ * @param {number} len
545
+ * @returns {string}
546
+ */
547
+ function truncateStringValue(str, len = 103) {
548
+ if (str.length <= len) return str;
549
+ return `${StringPrototypeSubstr.call(str, 0, len)}...`;
550
+ }
551
+
539
552
  module.exports = {
540
553
  createSubsetTags,
541
554
  createAppendTags,
@@ -546,4 +559,5 @@ module.exports = {
546
559
  createOverlappingTags,
547
560
  createEscapeTagRanges,
548
561
  getAdjustedUntrackedValue,
562
+ truncateStringValue,
549
563
  };
@@ -37,10 +37,6 @@ module.exports = function tracker(core) {
37
37
  return objMap.get(value) || null;
38
38
  }
39
39
 
40
- function isTracked(value) {
41
- return distringuish.isExternal(value);
42
- }
43
-
44
40
  function track(value, metadata) {
45
41
  let ret = Object.create(null);
46
42
 
@@ -152,6 +148,5 @@ module.exports = function tracker(core) {
152
148
  untrack,
153
149
  getData,
154
150
  getInfo: getData,
155
- isTracked,
156
151
  };
157
152
  };
@@ -45,7 +45,7 @@ module.exports = Core.makeComponent({
45
45
 
46
46
  eventFactory.createdEvents = new WeakSet();
47
47
 
48
- eventFactory.createSourceEvent = function(data = {}) {
48
+ eventFactory.createSourceEvent = function(data) {
49
49
  if (!data.result?.value) {
50
50
  logger.debug(SOURCE_EVENT_MSG, `invalid result: ${data.name}`);
51
51
  return null;
@@ -69,7 +69,6 @@ module.exports = function (core) {
69
69
  value: optionsString,
70
70
  }],
71
71
  context: `expressSession(${optionsString})`,
72
- history: [],
73
72
  name: 'express.hookedSessionConstructor',
74
73
  moduleName: 'express-session',
75
74
  methodName: '',
@@ -59,7 +59,6 @@ module.exports = function (core) {
59
59
  value: displayArg
60
60
  }],
61
61
  context: `fastifyCookie(${displayArg})`,
62
- history: [],
63
62
  name: 'fastifyCookie',
64
63
  moduleName: '@fastify/cookie',
65
64
  methodName: '',
@@ -71,8 +70,6 @@ module.exports = function (core) {
71
70
  tracked: false,
72
71
  },
73
72
  source: 'P0',
74
- stack: [],
75
- tags: {},
76
73
  framework: '@fastify/cookie',
77
74
  });
78
75
 
@@ -56,7 +56,6 @@ module.exports = function (core) {
56
56
  value: inspect(options),
57
57
  }],
58
58
  context: `state(${inspect(data.args)})`,
59
- history: [],
60
59
  name: `hapi.${server}.state`,
61
60
  moduleName: 'hapi',
62
61
  methodName: '',
@@ -72,7 +72,6 @@ module.exports = function (core) {
72
72
  value: displayArg
73
73
  }],
74
74
  context: `ctx.cookies.set(${displayArg})`,
75
- history: [],
76
75
  name: 'koaCookie',
77
76
  moduleName: 'koa',
78
77
  methodName: '',
@@ -84,8 +83,6 @@ module.exports = function (core) {
84
83
  tracked: false,
85
84
  },
86
85
  source: 'P',
87
- stack: [],
88
- tags: {},
89
86
  framework: 'koa',
90
87
  });
91
88
  if (!httpOnly) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/assess",
3
- "version": "1.52.0",
3
+ "version": "1.54.0",
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)",
@@ -21,16 +21,16 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@contrast/common": "1.32.0",
24
- "@contrast/config": "1.45.0",
25
- "@contrast/core": "1.50.0",
26
- "@contrast/dep-hooks": "1.19.0",
24
+ "@contrast/config": "1.46.0",
25
+ "@contrast/core": "1.51.0",
26
+ "@contrast/dep-hooks": "1.20.0",
27
27
  "@contrast/distringuish": "^5.1.0",
28
- "@contrast/instrumentation": "1.29.0",
29
- "@contrast/logger": "1.23.0",
30
- "@contrast/patcher": "1.22.0",
31
- "@contrast/rewriter": "1.26.0",
32
- "@contrast/route-coverage": "1.40.0",
33
- "@contrast/scopes": "1.20.0",
28
+ "@contrast/instrumentation": "1.30.0",
29
+ "@contrast/logger": "1.24.0",
30
+ "@contrast/patcher": "1.23.0",
31
+ "@contrast/rewriter": "1.27.0",
32
+ "@contrast/route-coverage": "1.42.0",
33
+ "@contrast/scopes": "1.21.0",
34
34
  "semver": "^7.6.0"
35
35
  }
36
36
  }