@contrast/assess 1.77.0 → 1.78.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.
@@ -15,7 +15,7 @@
15
15
 
16
16
  'use strict';
17
17
 
18
- const { primordials: { ArrayPrototypeJoin } } = require('@contrast/common');
18
+ const { isString, primordials: { ArrayPrototypeJoin } } = require('@contrast/common');
19
19
  const { createAppendTags, getAdjustedUntrackedValue } = require('../../../tag-utils');
20
20
  const { patchType } = require('../../common');
21
21
 
@@ -42,10 +42,31 @@ module.exports = function(core) {
42
42
  metadata.push({ tracked: true, value: strInfo.value });
43
43
  history.add(strInfo);
44
44
  tags = createAppendTags(tags, strInfo.tags, globalOffset);
45
+ globalOffset += strInfo.value.length;
45
46
  } else {
46
47
  metadata.push({ tracked: false, value: getAdjustedUntrackedValue(arg) });
48
+ // See NODE-3995
49
+ // CAP wraps objects and overrides toString with a method that creates
50
+ // side effects that we need to avoid by not coercing to string
51
+ if (isString(arg)) {
52
+ globalOffset += arg.length;
53
+ } else if (typeof arg !== 'object') {
54
+ globalOffset += `${arg}`.length;
55
+ } else if (arg === null) {
56
+ globalOffset += 4;
57
+ } else if (arg instanceof RegExp) {
58
+ globalOffset += arg.source.length + arg.flags.length + 2;
59
+ } else if (arg instanceof Date) {
60
+ globalOffset += new Date(arg.getTime()).toString().length;
61
+ } else if (arg instanceof String || arg instanceof Number || arg instanceof Boolean) { // boxed primitives
62
+ globalOffset += `${arg.valueOf()}`.length;
63
+ } else if (arg instanceof Error) {
64
+ globalOffset += arg.message.length + 7;
65
+ } else {
66
+ globalOffset += 15; // [object Object]
67
+ }
47
68
  }
48
- globalOffset += `${arg}`.length + (isIteratingArray ? 1 : 0);
69
+ globalOffset += isIteratingArray ? 1 : 0;
49
70
  }
50
71
  return [metadata, tags];
51
72
  }
@@ -173,7 +173,7 @@ module.exports = function(core) {
173
173
  tags: trackedArgs[vulnerableArgIdx].tags,
174
174
  source: 'P1',
175
175
  stacktraceOpts: {
176
- contructorOpt: hooked,
176
+ constructorOpt: hooked,
177
177
  },
178
178
  });
179
179
 
@@ -118,7 +118,7 @@ module.exports = function (core) {
118
118
  tags: strInfo.tags,
119
119
  source: 'P0',
120
120
  stacktraceOpts: {
121
- contructorOpt: orig
121
+ constructorOpt: orig
122
122
  },
123
123
  });
124
124
 
@@ -100,7 +100,7 @@ module.exports = function(core) {
100
100
  tags: strInfo.tags,
101
101
  source: `P${i}`,
102
102
  stacktraceOpts: {
103
- contructorOpt: data.hooked,
103
+ constructorOpt: data.hooked,
104
104
  },
105
105
  });
106
106
 
@@ -130,7 +130,7 @@ module.exports = function (core) {
130
130
  tags: strInfo.tags,
131
131
  source: `P${origArgs.length - 1}`,
132
132
  stacktraceOpts: {
133
- contructorOpt: hooked,
133
+ constructorOpt: hooked,
134
134
  },
135
135
  });
136
136
 
@@ -102,7 +102,7 @@ module.exports = function(core) {
102
102
  tags: strInfo.tags,
103
103
  source: 'P0',
104
104
  stacktraceOpts: {
105
- contructorOpt: data.hooked,
105
+ constructorOpt: data.hooked,
106
106
  },
107
107
  });
108
108
 
@@ -91,7 +91,7 @@ module.exports = function (core) {
91
91
  tags: strInfo.tags,
92
92
  source: 'P0',
93
93
  stacktraceOpts: {
94
- contructorOpt: data.hooked,
94
+ constructorOpt: data.hooked,
95
95
  },
96
96
  });
97
97
 
@@ -108,7 +108,7 @@ module.exports = function(core) {
108
108
  tags: strInfo.tags,
109
109
  source: 'P0',
110
110
  stacktraceOpts: {
111
- contructorOpt: data.hooked,
111
+ constructorOpt: data.hooked,
112
112
  },
113
113
  });
114
114
 
@@ -81,7 +81,7 @@ module.exports = function(core) {
81
81
  tags: strInfo.tags,
82
82
  source: 'P0',
83
83
  stacktraceOpts: {
84
- contructorOpt: data.hooked,
84
+ constructorOpt: data.hooked,
85
85
  },
86
86
  });
87
87
 
@@ -120,7 +120,7 @@ module.exports = function (core) {
120
120
  tags: queryInfo?.tags,
121
121
  source: 'P0',
122
122
  stacktraceOpts: {
123
- contructorOpt: hooked,
123
+ constructorOpt: hooked,
124
124
  },
125
125
  });
126
126
 
@@ -92,7 +92,7 @@ module.exports = function(core) {
92
92
  tags: strInfo.tags,
93
93
  source: 'P0',
94
94
  stacktraceOpts: {
95
- contructorOpt: data.hooked,
95
+ constructorOpt: data.hooked,
96
96
  },
97
97
  });
98
98
 
@@ -231,7 +231,7 @@ module.exports = function (core) {
231
231
  : vulnerableArg.strInfo.tags,
232
232
  source: `P${vulnerableArg.idx}`,
233
233
  stacktraceOpts: {
234
- contructorOpt: hooked,
234
+ constructorOpt: hooked,
235
235
  },
236
236
  });
237
237
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/assess",
3
- "version": "1.77.0",
3
+ "version": "1.78.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)",
@@ -13,26 +13,26 @@
13
13
  "main": "lib/index.js",
14
14
  "types": "lib/index.d.ts",
15
15
  "engines": {
16
- "npm": ">=6.13.7 <7 || >= 8.3.1",
17
- "node": ">= 18.7.0"
16
+ "npm": ">=8.5.5",
17
+ "node": ">=18.7.0"
18
18
  },
19
19
  "scripts": {
20
20
  "test": "bash ../scripts/test.sh"
21
21
  },
22
22
  "dependencies": {
23
- "@contrast/common": "1.41.1",
24
- "@contrast/config": "1.60.0",
25
- "@contrast/core": "1.65.0",
26
- "@contrast/dep-hooks": "1.34.0",
23
+ "@contrast/common": "1.42.0",
24
+ "@contrast/config": "1.61.0",
25
+ "@contrast/core": "1.66.0",
26
+ "@contrast/dep-hooks": "1.35.0",
27
27
  "@contrast/distringuish": "6.0.2",
28
- "@contrast/instrumentation": "1.44.0",
29
- "@contrast/logger": "1.38.0",
30
- "@contrast/patcher": "1.37.0",
31
- "@contrast/rewriter": "1.42.0",
32
- "@contrast/route-coverage": "1.59.0",
33
- "@contrast/scopes": "1.35.0",
34
- "@contrast/sources": "1.11.0",
35
- "@contrast/stack-trace-factory": "1.6.0",
36
- "semver": "7.6.0"
28
+ "@contrast/instrumentation": "1.45.0",
29
+ "@contrast/logger": "1.39.0",
30
+ "@contrast/patcher": "1.38.0",
31
+ "@contrast/rewriter": "1.43.0",
32
+ "@contrast/route-coverage": "1.60.0",
33
+ "@contrast/scopes": "1.36.0",
34
+ "@contrast/sources": "1.12.0",
35
+ "@contrast/stack-trace-factory": "1.7.0",
36
+ "semver": "7.8.5"
37
37
  }
38
38
  }